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

饥荒圣诞树的装饰代码

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

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 家居废旧物品改造为装饰品(Upcycling)是一种兼具环保性与艺术性的设计实践,可通过创意设计赋予废弃材料新价值。以下是专业级改造方案及注意事项:一、核心改造原则:1. 功能性转化:保留物品原始结构特征,重构用途(
    2026-01-10 装饰品 5309浏览
  • 关于深圳远鹏装饰集团有限公司(以下简称“远鹏装饰”),以下是基于公开信息的专业整理与分析:一、企业基础信息 项目 内容 成立时间 1993年 总部地点 深圳市福田保税区 注册资本 5.18亿元
    2026-01-09 装饰 5150浏览
  • 针对电表箱装饰画在淘宝平台的选购需求,以下从功能性、设计要点、主流产品类型及安全注意事项进行专业解析,并提供数据对比供参考。一、电表箱装饰画的核心功能与选购标准电表箱装饰画主要用于遮盖电表箱、优化室内
    2026-01-09 装饰画 9358浏览
  • 邯郸装饰材料市场作为河北省南部重要的建材集散中心,主要分布在邯山区、丛台区及复兴区的核心商圈,涵盖基础建材、装饰主材、软装配饰、智能家居等全产业链产品。以下为专业市场分析及数据对比:一、核心装饰材料市
    2026-01-09 装饰材料市 6097浏览
  • 栏目推荐
  • 常州地铁车厢装饰设计充分考虑了城市文化特色、功能性需求与现代美学的融合,以下为专业分析:一、车厢主题与装饰特点常州地铁1号线以"东经120度"为设计主线——该经线贯穿常州主城区,车厢内采用蓝色系为主色调,座椅
    2025-12-04 装饰 6566浏览
  • 别墅大宅装饰设计是高端住宅领域的综合艺术,需平衡功能性、美学价值、空间叙事性与个性化需求。以下从核心原则、关键环节、流行风格及成本控制等方面展开专业解析。一、别墅大宅设计核心原则1. 功能分区逻辑化:采用
    2025-12-04 装饰设 9477浏览
  • 在人物装饰画的临摹中,"笑"的表情捕捉是核心难点之一,需结合线条的装饰性变形、色彩符号化及结构夸张化处理。以下从专业角度解析关键要点:一、笑的表情装饰化临摹逻辑1. 肌肉结构解构:真实笑容依赖颧大肌上提(嘴角
    2025-12-04 装饰画 2895浏览
  • 栏目热点
  • 漯河创艺装饰设计是河南省漯河市的一家本土装饰设计企业,专注于住宅、商业空间的定制化设计与施工服务。以下从专业角度对其业务模式、设计理念及市场表现进行综合分析:一、企业基础信息 成立时间注册资本资质等级设
  • 民宿室外墙面装饰

    查看详情

    民宿室外墙面装饰
  • 装饰柜风水颜色搭配

    查看详情

    装饰柜风水颜色搭配
  • 全站推荐
  • 别墅阳台改造为客厅需兼顾结构安全、功能适配性和美学设计。需重点解决承重评估、环境控制、空间整合三大核心问题,具体步骤如下:一、结构安全改造方案1. 荷载评估:委托专业机构检测阳台基础结构,悬挑式阳台承重标
    2026-01-08 2808浏览
  • 窗帘行业的品牌加盟选择需综合考量品牌影响力、加盟支持政策、产品竞争力及盈利模式成熟度。以下是专业分析与推荐:一、核心窗帘加盟品牌对比(2024年主流品牌) 品牌名称品牌特点加盟费用范围(万元)初始投资要求
    2026-01-08 窗帘 4031浏览
  • 家具上门维修的费用因维修类型、家具材质、损坏程度、服务商定价及地区差异而异。以下为专业解答及详细数据参考:一、常见家具维修项目及参考价格表 维修类型 价格范围() 备注 沙发皮质修补(局部) 1
    2026-01-08 2993浏览
  • 友情链接
    底部分割线