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

饥荒圣诞树的装饰代码

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-10-30 装饰 2467浏览
  • 关于“绿色家装饰”在北京的地址,以下是基于公开信息的专业整理和推荐: 公司名称 地址 联系方式 营业时间 官网/平台链接 绿色家装饰 北京市朝阳区北三环东路36号绿色家园装饰城 010-5645 6789(电话)
    2025-10-30 装饰地址 4731浏览
  • 江苏作为我国重要的制造业基地,环保装饰墙板市场发展迅速。该地区的墙板企业依托完善的产业链和先进的生产工艺,在环保性能、设计多样性及施工便捷性方面具有显著优势。以下从市场概况、材料分类、核心品牌、价格体
    2025-10-30 墙板 5908浏览
  • 以下是关于广东星艺装饰的招聘信息及相关内容的专业整理,数据来源于公开渠道和公司官方信息。由于招聘信息可能随时间变化,建议访问公司官网或招聘平台获取最新动态。 岗位名称 工作地点 岗位职责 任职要求
    2025-10-29 装饰 7437浏览
  • 栏目推荐
  • 丛一楼装饰是江西省内较为知名的本土装修公司,成立于2003年,主打一站式家居装饰服务。以下是其核心特点和行业对比分析:1. 本土化优势 深耕江西市场20年,对当地气候、户型、消费习惯有较深理解,比如针对南方潮湿环
    2025-09-14 1502浏览
  • 新年装饰拉花拉旗的选购与布置要点:1. 材质选择无纺布:环保耐用,色彩饱和度高,可重复使用2-3年。适合室内悬挂,抗皱性强。PVC塑料:防水防晒,适合户外门头装饰。注意选择厚度≥0.15mm的高弹性材质,避免低温脆化。植
    2025-09-14 6996浏览
  • 关于南京匠道装饰的法人信息及相关企业背景,以下为综合分析:1. 法人登记信息 南京匠道装饰工程有限公司的法定代表人需通过国家企业信用信息公示系统(网址:http://www.gsxt.gov.cn)查询最新备案数据。企业法人可能因股权
    2025-09-14 2604浏览
  • 栏目热点
  • 今朝装饰的墙面工艺涵盖了从基层处理到表面装饰的全流程,注重细节和耐久性,以下是核心工艺要点及技术解析: 1. 基层处理 - 墙面检查与修补:检测空鼓、裂缝,剔除松脱层,用水泥砂浆或石膏填补凹陷,确保基层平整
  • 张店安坤装饰材料

    查看详情

    张店安坤装饰材料
  • 楼梯装饰装修清单

    查看详情

    楼梯装饰装修清单
  • 全站推荐
  • 卫生间管道水位低是一个涉及建筑排水系统设计与维护的专业问题,通常会导致排水不畅、异味返流或积水现象。以下是对此问题的详细分析和解决方案。一、常见原因分析1. 排水管堵塞:管道内油脂、头发、异物等堆积会降低
    2025-10-23 管道水位 6190浏览
  • 在家居厨房环境中,水槽作为日常用水的重要设施,其周围的防水设计直接影响到整体空间的使用安全与美观。以下从专业角度解析水槽防水设计的核心要素、常用材料及施工要点。一、防水设计的重要性水槽区域因频繁接触水
    2025-10-23 水槽 7184浏览
  • 芦荟在卧室中的种植对人类健康和居住环境可能产生一定影响,但需结合其生理特性及实际应用场景综合分析。以下是专业性内容: 影响维度 具体表现 科学依据 呼吸作用特性 芦荟在夜间通过气孔吸收氧气,释放
    2025-10-23 芦荟 9963浏览
  • 友情链接
    底部分割线