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

饥荒圣诞树的装饰代码

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-21 装饰城 2348浏览
  • 边锋游戏大厅作为国内知名的棋牌类游戏平台,其装饰系统主要围绕个性化展示和用户体验优化展开,涵盖游戏主界面、角色形象、聊天框特效等模块。以下从核心功能、装饰类别、数据指标及扩展内容四方面进行专业解析。一
    2025-12-21 装饰 2816浏览
  • 南通易尚空间装饰是一家立足于江苏省南通市的综合性装饰设计企业,专注于住宅、商业空间、办公环境等领域的全案设计与施工服务。以下从公司背景、业务范围、市场定位及行业数据等方面展开专业分析。一、公司核心信息
    2025-12-21 装饰 8999浏览
  • 甲状腺“山谷状装饰”并非标准医学术语,推测可能指代甲状腺在影像学检查(如超声或CT)中呈现的特殊形态特征,或与甲状腺解剖形态相关的病理改变。以下从专业角度进行解析:一、可能指向的解剖或病理概念1. 甲状腺峡部
    2025-12-21 装饰 4448浏览
  • 栏目推荐
  • 装饰工程施工组织设计是指导装饰工程从开工到竣工全过程各项活动的技术、经济和组织协调的综合性文件,是施工单位编制施工计划、指导现场施工、进行各项管理工作的行动纲领。一份科学合理的施工组织设计能够确保工程
    2025-11-03 施工组织 8461浏览
  • 镜头装饰拆卸是摄影设备维护中的常见需求,不同的装饰组件(如遮光罩、镜片套、快速切换滤镜等)具有不同的结构设计和拆卸方法。以下是专业的拆卸指南:1. 步骤化拆卸流程① 识别装饰类型:观察镜头外圈组件类型,常见
    2025-11-03 镜头装饰 9166浏览
  • 行唐绿色装饰设计项目 是一个专注于可持续发展和环保理念的装饰设计案例,该项目可能位于中国河北省石家庄市行唐县或相关区域,旨在通过创新的设计和技术,实现室内环境的生态保护和资源优化。以下是基于专业性内容
    2025-11-03 装饰 5860浏览
  • 栏目热点
  • 建筑装饰管理研究是一个涉及建筑装饰行业全产业链管理的综合学科,涵盖设计、施工、材料、成本、质量、安全、环保等多个维度。该研究领域以提升建筑装饰项目的管理效率与质量为核心目标,结合现代管理理论与技术手段
  • 绍兴室外装饰企业

    查看详情

    绍兴室外装饰企业
  • 金州家装装饰材料

    查看详情

    金州家装装饰材料
  • 全站推荐
  • 在家中摆放花瓶是常见的装饰方式,但其材质、形状、颜色及摆放位置皆有讲究,某些花瓶可能触犯风水禁忌或存在安全隐患。以下是需避免的花瓶类型及相关科学、文化依据:一、风水学忌讳的花瓶类型1. 破裂或残缺的花瓶:
    2025-12-03 花瓶 4073浏览
  • 家居风水是中国传统堪舆学的重要组成部分,核心在于通过布局调整气场流动(气),实现人与环境的和谐共生。要实现“上等风水”,需重点关注家中四类核心区域的布局原则:一、四大核心区域的风水要点 功能区风水定位最
    2025-12-03 3052浏览
  • 装饰模式(Decorator Pattern)和代理模式(Proxy Pattern)是两种常见的结构型设计模式,虽然都通过包装对象实现功能增强,但设计目标和应用场景有所不同。以下从定义、结构、应用场景和核心差异进行专业分析。一、装饰模式(
    2025-12-03 装饰模式 5612浏览
  • 友情链接
    底部分割线