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

饥荒圣诞树的装饰代码

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

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 拆卸装饰门锁需根据锁体类型确定具体操作流程。以下是专业拆卸指南及关联知识扩展:一、工具准备基础工具包:十字/一字螺丝刀、内六角扳手、尖嘴钳、橡皮锤、润滑剂(如WD-40)。防护工具:手套、护目镜(防止碎屑飞溅
    2026-01-04 门锁 8789浏览
  • 装饰读书笔记需兼顾功能性与审美性,通过科学排版和视觉引导提升信息检索效率与知识记忆留存率。以下是专业方与实用技巧:核心步骤与工具: 类型工具/方法功能定位 结构书签索引贴/分色标签章节定位与主题分类 概念标
    2026-01-03 9178浏览
  • 以下是关于庭院拉花装饰在婚礼场景中的应用的专业解析及建议:一、庭院拉花的作用与设计原则庭院拉花是婚礼现场装饰的核素之一,主要用于:1. 空间氛围营造:通过立体结构增强庭院层次感2. 视觉动线引导:沿仪式通道或
    2026-01-03 装饰 5870浏览
  • 翔安别墅外墙装饰需综合考虑气候适应性、材料耐久性、美学设计及功能性需求。厦门翔安区属亚热带海洋性气候,高温多雨、盐雾腐蚀强,材料选择需重点关注耐候性、防水性、抗紫外线及防霉抗菌性能。以下是常用外墙装饰
    2026-01-03 装饰 6600浏览
  • 栏目推荐
  • 潮州装饰型材定制是本地建材产业链的重要分支,聚焦于铝型材、不锈钢型材、木质装饰件及陶瓷配件的个性化加工服务。潮州作为广东东部的制造业重镇,依托本地不锈钢产业带和陶瓷产业集群,形成了完整的定制化生产体系
    2025-11-27 装饰型材 2384浏览
  • 汽车装饰是指通过加装、改装或替换配件提升车辆美观度、舒适性和功能性的行为,涵盖外观装饰、内饰升级、功能性改装三大领域。以下是专业分类及代表性项目:一、外观装饰1. 漆面保护与改色• 隐形车衣(PPF):聚氨酯材
    2025-11-26 3977浏览
  • 上海颐居装饰设计有限公司是专注于高端住宅、商业空间及别墅项目的全案设计与施工服务企业,倡导“人性化设计+精细化施工”理念,以下从核心维度解析其业务特色与行业定位: 核心指标 详细说明 行业对比 设
    2025-11-26 装饰 4388浏览
  • 栏目热点
  • 装饰设计团队合作是现代室内设计行业不可或缺的环节,涉及多专业协同、流程管理及目标一致性等核心要素。其成功依赖于明确的分工、高效的沟通机制和统一的设计语言。装饰设计团队合作的核心要素包括:专业分工协作、
  • 车内装饰挂件木质

    查看详情

    车内装饰挂件木质
  • 幼儿园班级门装饰

    查看详情

    幼儿园班级门装饰
  • 全站推荐
  • 针对江苏遮光窗帘盒生产厂家的查询,结合行业数据与产业链分布,江苏作为中国纺织制品及家居装饰材料的重要生产基地,集中了一批具备规模化生产和定制化服务能力的窗帘盒制造商,尤其在苏州、南通、无锡等地形成了产
    2025-12-25 窗帘盒 9006浏览
  • 以下是关于辽宁墙面伸缩缝厂家的专业信息整理,涵盖企业联系方式及行业相关内容扩展:墙面伸缩缝是建筑工程中用于适应结构变形、防止墙体开裂的关键构件,广泛应用于桥梁、隧道、厂房及建筑外墙。辽宁地区作为工业大
    2025-12-25 伸缩缝厂 8034浏览
  • 波风水门(四代目火影)是《火影忍者》中极具标志性的角色,其能力体系以空间忍术、速度、战术创造力为核心。若在穿越/系统流作品中设定"开局融合波风水门模板",需深入理解其能力本质及战术逻辑。以下为专业解析:一
    2025-12-25 水门模板 6651浏览
  • 友情链接
    底部分割线