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

饥荒圣诞树的装饰代码

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-12-02 陶瓷装饰 3042浏览
  • 壁纸小装饰手工制作是通过对剩余或专用壁纸进行裁剪、拼贴、立体塑造等工艺,制作成墙面点缀物或独立装饰品的过程。以下是专业级制作指南及相关数据:一、核心材料与工具 类别 推荐选择 用途说明 基础材料 PVC/纯纸/
    2025-12-01 壁纸 8190浏览
  • 壁挂数码万年历装饰画是一种融合时间显示、日历功能与艺术装饰的智能家居产品,通过数字化显示技术实现万年历、温度湿度、节日提醒等功能,同时兼顾美学设计,成为现代家居/办公室装饰的关键元素。一、核心功能与技术
    2025-12-01 装饰画 7478浏览
  • 针对无锡装饰装潢设计市场的专业需求,以下从行业概况、设计流程、主流风格、参考数据和公司推荐等方面提供系统化分析:一、无锡装饰装潢行业核心特征无锡作为长三角重要经济城市,其装饰市场呈现三大特点:1. 苏南文
    2025-11-30 5272浏览
  • 栏目推荐
  • 北京作为中国北方重要的商业中心,拥有多个大型装饰建材市场。根据行业数据和市场影响力,目前北京最大的装饰城主要包括燕山装饰城(即马甸建材市场)和十里河装饰城。以下是详细对比分析: 名称 位置 总面积(
    2025-10-19 装饰城 5968浏览
  • 电箱遮挡装饰画竖款是一种在建筑装饰中常见的解决方案,主要用于美化配电箱区域或遮挡其视觉影响。以下从设计规范、材料选择、安装方式及安全隐患等方面进行专业分析:1. 设计规范 配电箱作为电力系统的核心设备,其遮
    2025-10-18 装饰画 2539浏览
  • 百合花黑白装饰画是指以百合花为主要题材,通过黑白线条、明暗对比和几何构图等手法创作的装饰性绘画作品。此类画作常用于艺术设计、室内装饰、平面印刷等领域,具有简约美学和象征意义。以下是关于百合花黑白装饰画
    2025-10-18 装饰画 6412浏览
  • 栏目热点
  • 新长宁装饰材料市场是位于上海市长宁区的一家大型专业装饰建材市场,其前身为上海新长宁集团建材有限公司投资建设,是上海地区知名的装饰材料集散地之一。市场主要经营各类室内外装饰材料、建材、家居用品及配套服务
  • 苏州轩庭装饰怎么样

    查看详情

    苏州轩庭装饰怎么样
  • 圆工件表面装饰线

    查看详情

    圆工件表面装饰线
  • 全站推荐
  • 新式墙面板材装饰是当前建筑装饰领域的重要技术方向,广泛应用于商业空间、住宅、公共建筑等场景。其核心在于材料创新、功能集成与施工便捷性的提升。以下是专业分类与技术解析:一、主流新型墙面板材类型及特性
    2025-11-29 9444浏览
  • 厨房橱柜障碍物尺寸是指在厨房布局设计中,为避免操作干涉或安全隐患,橱柜与周边物体(如墙体、电器、管道等)之间需预留的最小间距或最大限制值。合理的障碍物尺寸设计直接影响厨房操作的流畅性、安全性及空间利用
    2025-11-29 橱柜障碍物 872浏览
  • 重庆卧室装修经验丰富的公司推荐及专业解析在重庆选择卧室装修公司时,需综合考察设计能力、施工工艺、材料品质、售后服务四大核心要素。以下是经过行业口碑、项目案例、资质认证筛选的优质企业: 公司名称 成立
    2025-11-29 卧室装修 3055浏览
  • 友情链接
    底部分割线