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

饥荒圣诞树的装饰代码

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", 因为都是在雪中飘的

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 天水宝马装饰装修是一家专业从事室内装修设计与施工的公司,主打高品质的装修服务。作为甘肃省内知名的装饰企业之一,宝马装饰以其专业的设计团队、先进的施工技术和优质的服务赢得了广大客户的信赖。核心服务包括:
    2025-11-10 9328浏览
  • 在家中放置花篮可以为室内增添不少生机和美感,尤其是鲜花的色彩和香气能够提升整体的居住舒适度。如何选择适合的花篮花篮的材质有很多种,比如塑料、藤编、陶瓷等。选择与家中装饰风格相符的花篮,可以让花卉更好地
    2025-11-10 花篮 2751浏览
  • 装饰艺术运动(Art Deco)是20世纪初兴起并持续到1940年代的重要设计风格,其影响深远,涉及建筑、时尚、工业设计、平面艺术、电影等多个领域。这一运动源于法国,随后在美国等工业化国家广泛传播,成为当时现代生活方式和
    2025-11-10 装饰艺 3758浏览
  • 平面装饰方法是指在二维平面上通过色彩、线条、图形、材质等元素进行视觉美化与功能提升的设计手段。根据装饰原理和应用领域,其分类主要包含以下几类:一、按装饰原理分类1. 色彩装饰法:通过色相、明度、饱和度的搭
    2025-11-09 平面装饰 4367浏览
  • 栏目推荐
  • 邯郸大学教室门装饰是校园文化建设的重要组成部分,它不仅关乎美观性,更涉及功能性、安全性和教育意义。专业的教室门装饰应综合考虑材料选择、设计主题、实用需求以及校园整体风格,以提升学习环境的质量和师生体验
    2025-10-07 装饰 9537浏览
  • 幼儿新年教室墙面装饰是一项融合教育性、安全性与艺术性的专业工作。它不仅是营造节日氛围,更是重要的环境创设环节,能激发幼儿对传统文化的兴趣,促进其认知、审美和动手能力的发展。以下是基于幼儿教育理念的专业
    2025-10-07 9763浏览
  • 婚房客厅装饰是婚礼筹备中的重要环节,它不仅承载着新婚生活的美好愿景,还体现了新人的审美与情感表达。一个成功的婚房客厅装饰应注重氛围营造、色彩搭配、功能性和个性化元素的结合。以下是专业建议和数据分析,帮
    2025-10-07 9204浏览
  • 栏目热点
  • 圆工件表面装饰线是指在圆柱形、圆锥形或其他旋转对称的工件表面上,通过机械加工、蚀刻、激光雕刻或镀层等工艺制作的具有装饰性或功能性的线条图案。这些线条可以是连续的、间断的、平行的、螺旋的,或构成更复杂的
  • 心中的风景装饰画

    查看详情

    心中的风景装饰画
  • 济宁轻舟装饰项链

    查看详情

    济宁轻舟装饰项链
  • 全站推荐
  • 卫生间装修后能否使用燃气,主要取决于燃气系统的安全性验收结果,而非单纯的时间周期。若涉及燃气管道或设备改动,必须由燃气公司或专业资质人员验收合格后,方可通气使用。以下是专业分析和关键数据:一、核心影响
    2025-11-22 436浏览
  • 照片在卧室的装饰布局需结合空间美学、功能需求和风水原则。根据设计心理学和室内装饰规范,以下为8个推荐位置及其设计逻辑: 位置 优势 注意事项 适用照片类型 床头正上方 卧室主要视觉焦点,增强空间
    2025-11-22 照片 4283浏览
  • 通州客厅石膏线吊顶是一种常见的天花板装饰方案,兼具美观性与功能性。以下是专业性解答及相关扩展内容:一、石膏线吊顶核心优势1. 造型多样化:适用于欧式、美式、现代简约等多种装修风格。2. 空间修饰:可隐藏管线、
    2025-11-22 吊顶 8234浏览
  • 友情链接
    底部分割线