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

饥荒圣诞树的装饰代码

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

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 选择装饰画时,需要考虑多个因素以确保其与空间风格、功能需求和个人审美相匹配。以下是一些专业的选择建议:1. 确定房间的主题风格首先,明确房间的整体风格(如现代简约、复古经典、乡村风或北欧风)。不同风格的房
    2025-11-09 装饰画 3164浏览
  • 广饶装饰材料市场位于中国山东省东营市广饶县,是区域内重要的建材集散地之一。该市场主要服务于本地及周边地区的建筑装饰行业,涵盖多种装饰材料的销售与批发。市场概况:广饶装饰材料市场以建材批发、零售为主,覆
    2025-11-09 装饰材料 9758浏览
  • 面对面装饰是近年来在装修行业中兴起的一种服务模式,强调通过线下实体门店或面对面沟通方式为客户提供个性化设计方案和施工服务。这种模式的核心优势在于服务透明度高,客户可直接与设计师、工长沟通需求,减少信息
    2025-11-08 装饰 9843浏览
  • 中国装饰行业资质管理主要由中国建筑装饰协会(CBDA)及各地行业协会协同监管。以下是关于装饰协会资质查询的专业指南及相关扩展内容:一、装饰协会资质查询途径1. 中国建筑装饰协会官网:通过CBDA官网(www.cbda.cn)的“资
    2025-11-08 装饰协会 9601浏览
  • 栏目推荐
  • 装饰装修阶段监理细则是指导监理人员在装饰装修工程施工过程中,开展质量、进度、投资控制和合同、信息管理,以及履行安全生产管理职责的操作性技术文件。它依据工程监理规划、相关工程设计文件、技术标准及合同文件
    2025-09-30 监理细则 750浏览
  • 家用汽车内饰装饰是指车主根据个人审美、功能需求和安全性考量,对车辆内部空间进行的各类美化、优化与个性化改造。它不仅是提升驾乘舒适度与愉悦感的重要方式,更能反映车主的品味与个性。专业的汽车内饰装饰需兼顾
    2025-09-30 9487浏览
  • 关于北京融发装饰的招聘信息,经过对主流招聘平台(如BOSS直聘、智联招聘、前程无忧等)及企业官方渠道的检索,目前未能获取到该公司实时、确切的在招岗位详情。以下是根据此类查询提供的结构化专业信息与建议。通常情
    2025-09-30 装饰 5271浏览
  • 栏目热点
  • 黑白装饰画作为卧室一角的点睛之笔,既能提升空间质感,又能通过明暗对比营造出独特的视觉效果。以下是关于黑白装饰画在卧室应用的详细解析: 1. 构图与主题选择几何抽象风格:以蒙德里安式的线条分割或康定斯基的抽象
  • 灵山风情小镇装饰

    查看详情

    灵山风情小镇装饰
  • 济南观为装饰设计

    查看详情

    济南观为装饰设计
  • 全站推荐
  • 装修地板发生变色是一个常见的质量问题,其成因复杂,涉及材料、环境、使用和安装等多个层面。理解这些原因对于预防变色至关重要。以下从主要成因、不同材料表现、解决方法及预防措施等方面进行专业解析。## 一、 地板
    2025-11-04 地板 1167浏览
  • 关于清远迁坟风水大师的问题,涉及传统阴宅风水的传承与实践领域。以下是基于专业研究整理的核心内容:---一、迁坟风水学说基础中国传统风水学中,迁坟本质是对祖坟能量平衡的调整。祖宅影响三代人运势,若阴煞过重需
    2025-11-04 4534浏览
  • 专业问题:生肖龙摆放生肖鸡 - 这个查询涉及中国十二生肖文化中的摆放禁忌和风水原则,旨在提供专业准确的解释。十二生肖是中国传统文化的重要组成部分,源于古代农历年份周期,每个生肖对应一个年份,各有其象征和运
    2025-11-04 生肖鸡 5798浏览
  • 友情链接
    底部分割线