欢迎访问雅美居装饰装修网,专注于装饰装修百科知识解答!
当前位置:雅美居装饰装修网 >> 装饰 >> 圣诞树 >> 百科详情

饥荒圣诞树的装饰代码

2024-02-13 装饰 责编:雅美居装饰装修网 6161浏览

```lua

饥荒圣诞树的装饰代码

local assets =

{

Asset("ANIM", "anim/tree_christmas.zip"),

}

local function oninit(inst)

inst.AnimState:PlayAnimation("idle", true)

inst.AnimState:PushAnimation("festive_loop", true)

end

local function fn()

local inst = CreateEntity()

inst.entity:AddTransform()

inst.entity:AddAnimState()

inst.entity:AddSoundEmitter()

inst.entity:AddNetwork()

MakeObstaclePhysics(inst, 1)

inst.AnimState:SetBank("tree_christmas")

inst.AnimState:SetBuild("tree_christmas")

inst.AnimState:PlayAnimation("idle", true)

MakeSnowCoveredPristine(inst)

if not TheWorld.ismastersim then

return inst

end

inst:AddComponent("inspectable")

inst:AddComponent("burnable")

inst.components.burnable:AddBurnFX("tree_christmas_fireFx", Vector3(0, 5, 0), "tree_christmas_burn")

inst:ListenForEvent("onignite", function(inst) inst.AnimState:PlayAnimation("fire_loop", true) end)

inst:ListenForEvent("onextinguish", function(inst) inst.AnimState:PlayAnimation("idle", true) end)

inst:AddComponent("transformer")

inst.components.transformer:SetBeast("crocodile")

inst.components.transformer.cantags = {"prey"}

inst.components.transformer.onchargedelta = {1, 1.5} --回复两个百分比能量

inst:AddComponent("workable")

inst.components.workable:SetWorkAction(ACTIONS.CHOP)

inst.components.workable:SetWorkLeft(10)

inst.components.workable:SetOnWorkCallback(function(inst, worker, workleft)

inst.AnimState:PlayAnimation("chop")

inst.AnimState:PushAnimation("idle", true)

inst.SoundEmitter:PlaySound("dontstarve/winter/destroy_orb")

inst.components.lootdropper:SpawnLootPrefab("log")

end)

inst.components.workable:SetOnFinishCallback(function(inst, worker)

inst:Remove()

end)

inst:AddComponent("lootdropper")

---------------------winter's feast-----------------------------

inst.AnimState:Hide("BIRD") -- 隐藏鸟

inst:AddTag("winter_treestar")

inst:ListenForEvent("ornamenttransform", function()

inst.AnimState:OverrideSymbol("tree_christmas_01", "tree_christmas", "tree_christmas_star")

end)

MakeSnowCovered(inst)

inst.OnSave = function(inst, data)

data.isstar = inst.starhide

end

inst.OnLoad = function(inst, data)

if data and data.isstar then

inst.starhide = data.isstar

else -- 默认状态即 starhide == nil

inst:RemoveComponent("winter_tree") -- 掉落 isstar=true 材料

end

end

MakeHauntableIgnite(inst)

inst.OnEntityReplicated = inst.OnEntityReplicated or function(inst)

if inst._winter_tree_decor then

inst._winter_tree_decor:Remove()

inst._winter_tree_decor = nil

end

if inst._Task ~= nil then

inst._Task:Cancel()

inst._Task = nil

end

inst:RestartWinterLight()

end

inst.RestartWinterLight = function(inst)

if not inst:IsValid() then

inst._Task:Cancel()

return

end

if inst._winter_tree_decor == nil then

inst._winter_tree_decor = SpawnPrefab("winter_tree_decor")

inst._winter_tree_decor.entity:SetParent(inst.entity)

end

local x, y, z = inst.Transform:GetWorldPosition()

inst._winter_tree_decor.Transform:SetPosition(x, y + 10, z)

if inst.components.winter_tree ~= nil and inst.components.winter_tree.status == "light" then

if inst._Task == nil then

local offset = math.random(0, 2 * PI)

inst._Task = inst:DoPeriodicTask((3 + 4 * math.random()) * FRAMES, function(inst)

inst:PushEvent("lightchange", {offset = offset})

end)

end

elseif inst._Task ~= nil then

inst._Task:Cancel()

inst._Task = nil

end

end

---------------------winter's feast-----------------------------

inst:DoTaskInTime(0, oninit)

inst:SetPrefabNameOverride("tree")

return inst

end

local function fn_decor()

local inst = CreateEntity()

inst.entity:AddTransform()

--[[Non-networked entity]]

inst:AddTag("CLASSIFIED")

inst:AddTag("FX")

inst:AddTag("NOCLICK")

inst:AddTag("NOBLOCK")

inst:AddTag("DECOR")

inst:AddTag("NOPLAYERS")

inst:AddTag("sittable")

inst:AddTag("nosteal")

return inst

end

return Prefab("tree_christmas", fn, assets, prefabs),

Prefab("winter_tree_decor", fn_decor, MakeDecor) -- "winter_tree_decor" 实际基础是 "generic_snowfall", 因为都是在雪中飘的

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 成都实创装饰作为国内知名装饰企业——实创装饰集团在西南地区的重要分部,其招聘信息需通过官方渠道或权威招聘平台获取最新动态。以下为基于行业常规情况的专业化分析与建议:一、招聘岗位与要求(示例参考) 岗位类
    2026-01-25 装饰 6891浏览
  • 装饰面包鳄鱼是一种创意烘焙作品,通过面团塑形、烘焙与装饰工艺,制作出鳄鱼造型的面包。其特点在于造型逼真、装饰材料丰富,常用于儿童派对、主题甜品台或烘焙技艺展示。以下是专业制作流程与扩展内容:一、基础材
    2026-01-25 面包 9003浏览
  • 针对女士装饰皮带的选购需求,以下基于品牌定位、设计风格、材质工艺及市场反馈,提供专业推荐及分析。装饰性皮带的核心价值在于提升造型层次感,需兼顾美学设计与佩戴舒适度。一、国际奢侈品牌适合追求高端品质与经
    2026-01-25 皮带 5452浏览
  • 将木装饰线条固定到墙上是室内装饰中的常见工艺,需根据墙面材质、线条类型及施工环境选择合适的方法。以下是专业安装流程及注意事项:一、安装前准备1. 工具清单:电钻、气钉(或手动钉)、结构胶、激光水平仪、卷尺
    2026-01-25 装饰线条 8568浏览
  • 栏目推荐
  • 关于新疆克拉玛依装饰城的工程项目及市场活跃度问题,结合行业数据和市场调研分析如下:一、克拉玛依装饰产业市场现状克拉玛依市作为新疆重要的能源工业城市,近年来伴随城市功能升级和人口增长,建筑装饰行业整体需
    2025-12-09 装饰城 7729浏览
  • 针对少儿英语教室装饰的专业性设计,需结合语言学习特点、儿童心理发展及空间功能性进行规划。以下是核心要点与数据参考:一、色彩与视觉设计少儿英语教室建议采用高饱和度主色+柔和辅助色组合,研究表明儿童对色彩的
    2025-12-08 装饰 4715浏览
  • 关于龙口加乐加装饰公司的专业评估,我基于全网公开信息(企业资质、行业口碑、客户反馈等)进行综合分析,具体如下:一、公司基础信息龙口加乐加装饰是一家总部位于山东烟台龙口市的本地装修企业,注册时间不详(公
    2025-12-08 装饰 565浏览
  • 栏目热点
  • 针对无锡装饰装潢设计市场的专业需求,以下从行业概况、设计流程、主流风格、参考数据和公司推荐等方面提供系统化分析:一、无锡装饰装潢行业核心特征无锡作为长三角重要经济城市,其装饰市场呈现三大特点:1. 苏南文
  • 重庆建筑装饰协会网站

    查看详情

    重庆建筑装饰协会网站
  • 合肥装饰网店设计

    查看详情

    合肥装饰网店设计
  • 全站推荐
  • 地板胶的价格因材质、品牌、厚度、施工工艺及市场区域等因素差异较大。以下为专业分析和数据参考:一、地板胶的类型及价格范围地板胶主要分为PVC地板胶、橡胶地板胶、亚麻地板胶等类别,不同材质的性能与成本差异显著
    2026-01-20 地板胶 2140浏览
  • 在风水学中,健康的住宅布局需遵循气场流通、阴阳平衡的基本原则。最健康的风水模式需综合考量采光、通风、空间布局、五行调和等核心要素,同时规避形煞与磁场干扰。以下从专业角度解析关键要点:一、健康风水的核心
    2026-01-20 8311浏览
  • 针对刚租租屋装修的需求,需兼顾法规合规性、成本控制及功能性提升。以下是分步专业指南:一、装修前置准备(核心步骤)1. 租赁合同审查确认合同中装修条款:57%的纠纷源于擅自硬装改造(住建部2023数据)。优先获取房东
    2026-01-20 8090浏览
  • 友情链接
    底部分割线