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

饥荒圣诞树的装饰代码

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

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 关于深圳远鹏装饰集团有限公司(以下简称“远鹏装饰”),以下是基于公开信息的专业整理与分析:一、企业基础信息 项目 内容 成立时间 1993年 总部地点 深圳市福田保税区 注册资本 5.18亿元
    2026-01-09 装饰 5150浏览
  • 针对电表箱装饰画在淘宝平台的选购需求,以下从功能性、设计要点、主流产品类型及安全注意事项进行专业解析,并提供数据对比供参考。一、电表箱装饰画的核心功能与选购标准电表箱装饰画主要用于遮盖电表箱、优化室内
    2026-01-09 装饰画 9358浏览
  • 邯郸装饰材料市场作为河北省南部重要的建材集散中心,主要分布在邯山区、丛台区及复兴区的核心商圈,涵盖基础建材、装饰主材、软装配饰、智能家居等全产业链产品。以下为专业市场分析及数据对比:一、核心装饰材料市
    2026-01-09 装饰材料市 6097浏览
  • 赏月餐桌中心装饰需兼顾节日氛围、美观性及实用性,核心在于通过自然元素与光影设计烘托团圆意境。以下是专业级设计方案及关键数据:▼ 一、核心设计要素1. 色彩搭配:以金、白、深蓝为主色调,象征月光、夜空与丰收。
    2026-01-08 装饰 4252浏览
  • 栏目推荐
  • 讲台上的花盆装饰品兼具美学价值与功能性,需根据空间特性、使用场景及植物属性进行科学搭配。以下从装饰类型、材料选择、摆放原则及养护要点展开说明,并附专业数据对比。一、常见讲台花盆装饰类型 类型代表植物/材
    2025-12-04 花盆 7155浏览
  • 苏州泥巴公社装饰全称为“苏州泥巴公社装饰设计工程有限公司”,曾是互联网家装品牌“泥巴公社”的苏州分公司。根据公开资料及用户反馈,该公司因经营问题已于2018年前后倒闭,涉及大量消费者投诉、施工停滞及资金链断
    2025-12-04 装饰 3509浏览
  • 关于上海峦瑞装饰设计的专业,基于公开资料整理如下:一、公司基础信息 项目 数据内容 公司全称 上海峦瑞建筑装饰设计有限公司 成立时间 2017年前后(具体需工商确认) 注册地址 上海市闵行区(
    2025-12-03 装饰设 7089浏览
  • 栏目热点
  • 昆山金典铭筑装饰是一家位于中国江苏省昆山市的室内装饰企业,主要提供住宅及商业空间的装修设计、施工与软装服务。根据公开信息,公司成立于2010年,注册资本为500万元,法人代表为张伟。其业务范围涵盖整体家装、办公
  • 临夏宾馆装饰定制

    查看详情

    临夏宾馆装饰定制
  • 酒柜装饰品摆件画

    查看详情

    酒柜装饰品摆件画
  • 全站推荐
  • 樟子松是一种常见的松木类家具用材,主要产自北欧、俄罗斯等高寒地区。作为经济型实木选项,其优缺点鲜明,适用于特定场景。以下从专业角度分析:一、樟子松家具的优点1. 稳定性较高:樟子松生长缓慢,木质密度适中(
    2026-01-05 樟子松家具 4119浏览
  • 针对淮安环保地板保养的专业需求,需结合当地气候特点(温带季风气候、年均湿度约75%-85%)及环保地板材质特性进行科学维护。以下从日常清洁、环境调控、深度养护三个维度提供标准化方案,并附关键数据参考:一、环保地
    2026-01-05 地板 6077浏览
  • 以下为家居风水布置的专业指导方案,结合传统风水理论与现代空间规划原则:一、核心区域风水布局要点1. 大门布局(气口纳吉):- 避免直对电梯、楼梯或卫生间- 门槛保持完整,门外宜整洁明亮- 门色选择按五行相生:东/东
    2026-01-05 风水 1615浏览
  • 友情链接
    底部分割线