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

饥荒圣诞树的装饰代码

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-11 灯笼 6416浏览
  • 关于“昆山饰全饰美装饰”,目前信息有限,建议先确认企业名称准确性。此名称可能为非正规注册名称或公司别名,以下信息基于已公开资料整理: 企业名称 类型 成立时间 注册地址 饰全饰美装饰 装修公司
    2025-10-11 装饰 1405浏览
  • 关于海口华浔装饰的招聘信息,需结合公司当前动态及平台发布内容综合分析。以下是基于全网公开信息整理的专业内容: 招聘时间 招聘岗位 人数 工作地点 薪资范围 岗位要求 2023年8月-2023年12月 室内设计
    2025-10-10 装饰 1676浏览
  • 天津东丽区装饰资质是建筑装饰企业在开展相关业务时必须具备的法定资格,其审批与管理由天津市住房和城乡建设委员会(以下简称“市住建委”)及东丽区相关部门负责。以下内容涵盖资质分类、办理流程、核心要求及注意
    2025-10-10 装饰资 8338浏览
  • 栏目推荐
  • 新乡市金港装饰广场是河南省新乡市规模较大的建材装饰类专业市场,主要服务于家居装修、建材采购、装饰设计等需求。以下是关于该广场的详细分析及相关扩展知识:1. 地理位置与交通便利性 金港装饰广场通常位于新乡市
    2025-08-24 8641浏览
  • 弱电箱装饰画液压系统的设计与应用涉及多个专业领域的知识,以下是详细分析:1. 液压驱动原理 液压系统通过封闭管路内的不可压缩流体传递压力,通常采用微型液压缸或线性执行器作为动力源。装饰画液压驱动需考虑低速
    2025-08-23 2654浏览
  • 顺花园餐厅的装饰画选择需要综合考虑空间氛围、风格定位、文化内涵以及实用性等因素。以下从专业角度提供详细建议:1. 主题与风格的匹配 - 自然元素优先:花园餐厅适合选用植物花卉、鸟类昆虫等题材的水彩或油画,推荐
    2025-08-23 6259浏览
  • 栏目热点
  • 关于惠州苹果装饰的招聘信息,目前公开渠道难以查询到最新官方动态。但结合行业经验,可提供以下扩展分析及求职建议:1. 行业背景参考 苹果装饰曾为全国性连锁品牌,但2018年因资金链问题多地分公司倒闭。建议核实惠
  • 新家乔迁装饰布置

    查看详情

    新家乔迁装饰布置
  • 西安贵家大宅装饰

    查看详情

    西安贵家大宅装饰
  • 全站推荐
  • 在风水学中,镇宅植物的选择需结合五行原理、宅邸方位及居住者的命理特征。以下为专业推荐的镇宅花卉及详细解析: 花卉名称 象征意义 风水作用 最佳摆放位置 养护要点 仙人掌 象征守护与 可化解煞气
    2025-10-20 5029浏览
  • 高级附魔台的摆放位置需遵循特定规则,以确保其功能正常运作。以下是基于主流游戏环境(如《Minecraft》)的专业解析:在《Minecraft》中,高级附魔台(Enchanting Table)是用于对物品进行附魔的核心建筑,其摆放需满足以下条件
    2025-10-20 魔台摆放 3097浏览
  • 装饰小品是建筑空间设计中用于提升环境美感、丰富空间层次的重要元素,通常指体积较小、具有艺术性和实用性的装饰性构件。其分类依据功能、形式和应用场景的不同,可分为以下几类: 类型 定义与特点 常见形式
    2025-10-20 装饰 1878浏览
  • 友情链接
    底部分割线