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

饥荒圣诞树的装饰代码

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-12-27 装饰 6985浏览
  • 西安不锈钢装饰条是建筑装饰、室内装修中广泛应用的金属材料,因其耐腐蚀、强度高、美观耐用等特点受到市场青睐。以下从产品分类、应用场景、市场分析及选购建议等方面进行专业解析。一、不锈钢装饰条核心参数与分类
    2025-12-27 装饰条 5890浏览
  • 中式装饰装修工程是以中国传统文化为核心,融合传统建筑元素与现代功能需求的室内外空间设计体系。其核心在于平衡形制、材料、工艺、色彩四大要素,体现东方美学中“天人合一”的理念。以下是专业解析:一、核心设计
    2025-12-27 8650浏览
  • 幸福居装饰材料城是中国珠三角地区一家规模较大的装饰材料综合型商贸平台,专注于建材批发、零售及产业链整合服务。以下为专业分析和扩展信息:一、核心业务与市场定位幸福居装饰材料城以一站式家居建材采购为核心,
    2025-12-27 装饰材料 1355浏览
  • 栏目推荐
  • 小丑装饰作为一种跨越历史与文化的视觉符号,其寓意具有多面性与复杂性,既可代表欢乐与颠覆,也可象征危险与荒诞。以下是基于艺术史、社会学和心理学的综合分析:一、小丑装饰的核心象征体系 领域正面寓意寓意 戏剧
    2025-11-22 装饰 6537浏览
  • 手工折纸草莓装饰花瓶是一种结合立体折纸技艺与创意家居装饰的手工项目,通过模块化组合实现观赏性与实用性的统一。以下从材料选择、制作流程及设计原理三方面进行专业解析:一、核心材料与工具配置表 类别 推荐
    2025-11-22 花瓶 1538浏览
  • 针对德阳田园建筑装饰的定位与业务分析,结合行业实践与区域装饰市场特点,整理专业信息如下:一、企业核心业务与特色德阳田园建筑装饰以田园风格设计与本土化施工服务为核心竞争力,业务涵盖:• 住宅/商业空间设计•
    2025-11-21 建筑装饰 7406浏览
  • 栏目热点
  • 云岩区现代装饰风格装修是一种结合了现代简约、功能性和美观性的设计风格,适用于现代公寓、别墅等居住空间。以下是关于云岩区现代装饰风格装修的一些关键点和建议:1. 色彩搭配:现代装饰风格通常采用简洁明快的色彩
  • 海口华浔装饰招聘

    查看详情

    海口华浔装饰招聘
  • 天津东丽区装饰资质

    查看详情

    天津东丽区装饰资质
  • 全站推荐
  • 拆卸客厅小小射灯需根据灯具类型(嵌入式或轨道式)选择对应方法,操作前务必确保断电安全。以下是专业步骤及扩展建议:一、嵌入式小射灯拆卸步骤1. 断电:关闭客厅电源总闸,使用电笔确认线路无电。2. 拆除灯罩:部分
    2025-12-25 射灯 3302浏览
  • 易格家具淘宝代购假货问题是近年来家具消费领域的常见投诉之一。由于代购渠道的隐蔽性、供应链多层嵌套以及监管难度大,假货风险显著增加。以下是专业分析及解决方案:一、易格家具假货的常见特征1. 产品细节差异:仿
    2025-12-25 假货 3755浏览
  • 针对黄冈高品质墙面漆购买渠道的问题,结合专业建材市场分布、品牌授权情况及消费者反馈,整理以下权威信息:一、专业购买渠道推荐1. 大型建材市场:• 黄冈居然之家(黄州店):聚集立邦、多乐士、三棵树等十大品牌授
    2025-12-25 墙面漆 6849浏览
  • 友情链接
    底部分割线