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

饥荒圣诞树的装饰代码

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

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 成都隆诚建筑装饰集团有限责任公司是一家专业从事建筑装饰设计、施工与工程管理服务的综合性企业。以下从企业资质、核心业务、项目案例及行业地位等维度进行专业解析:一、企业基础信息数据项详情备注成立时间2003年工
    2025-12-17 建筑装饰 4026浏览
  • 兰州活动隔断装饰设计是针对商业、办公、酒店等空间灵活分区需求的专业解决方案,需兼顾功能性、美观性、隔音性三大核心。以下是专业分析及扩展内容:一、活动隔断的核心设计要素 1. 结构类型:悬挂式(承重顶轨)、推
    2025-12-17 隔断装饰设 3691浏览
  • 关于宜家铁艺沙发床的装饰与选购,需结合材质特性、空间适配性及功能需求进行专业设计。以下是细分解析:一、宜家铁艺沙发床核心设计特征宜家现有产品线中独立铁艺框架沙发床较少,多以钢木混合结构为主。代表性系列
    2025-12-16 装饰 4643浏览
  • 华东地区是中国装饰板材行业的核心区域之一,覆盖了上海、江苏、浙江、安徽等经济发达省份。以下从市场分布、产品类别、主要企业及产业趋势四个方面进行专业分析:一、华东装饰板材市场分布华东装饰板材市场呈现集群
    2025-12-16 板材 7362浏览
  • 栏目推荐
  • 肌理画装饰画大幅作为艺术与工艺的结合体,其独特性在于通过物理纹理与视觉层次传递艺术意境。这类作品常用于空间装饰以增强艺术氛围,以下是相关专业解析:肌理画的核心工艺特征:以手工制作的材质肌理为核心,结合
    2025-10-27 装饰画 4759浏览
  • 西安景家装饰工程有限公司是一家专注于建筑装饰工程领域的专业企业,其业务范围涵盖室内外装修、幕墙工程、建筑智能化系统集成等。根据公开资料显示,该公司成立于2010年,注册资金为500万元,总部位于陕西省西安市雁塔
    2025-10-27 装饰工 568浏览
  • 汽车后门加装金属装饰是一种常见的外观改造方式,主要用于提升车辆的视觉效果、品牌辨识度或个性化需求。以下是关于这一主题的专业解析:金属装饰的类型与材料常见的金属装饰包括:不锈钢条、铝合金板、碳纤维饰条、
    2025-10-27 9727浏览
  • 栏目热点
  • 以下是装饰宿舍桌子的专业建议,结合功能性设计、空间优化与个性化需求,帮助您打造整洁有序且富有格调的学习生活区。 装饰方向具体建议注意事项 收纳整理 使用分层收纳架、洞洞板或抽屉分隔盒,将书本、文具、
  • 内墙装饰供应厂家排名

    查看详情

    内墙装饰供应厂家排名
  • 浙江雅琪诺装饰材料

    查看详情

    浙江雅琪诺装饰材料
  • 全站推荐
  • 在定制家具领域,计算成本需严格遵循行业标准公式,并综合考虑材料、工艺、五金配件等因素。以下是专业计算方法及关键数据说明:一、核心计算公式1. 展开面积计价法(适用柜体类家具)公式:总价 = 展开面积(㎡)× 单
    2025-12-12 定制家具 4086浏览
  • 厕所墙面刮平干净是瓷砖铺贴、防水层施工或墙面翻新的重要前置步骤,需严格按照施工工艺操作以避免后期空鼓、开裂等问题。以下是专业施工流程及关键注意事项:一、墙面刮平施工步骤1. 基层处理• 铲除原墙面的涂料、油
    2025-12-12 墙面 6704浏览
  • 关于木地板保养照片真实性的辨别与专业建议,需结合保养方法、材料验证、效果对比等多维度分析。以下是系统性解答及扩展内容:一、真实木地板保养照片的核心验证点1. 细节纹理:真实保养后的木地板应保留木材天然纹理
    2025-12-12 保养照片 5806浏览
  • 友情链接
    底部分割线