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

饥荒圣诞树的装饰代码

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

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 关于湖南龙鑫装饰的信息,目前公开渠道可查的内容较多,以下从多个维度进行整理分析:1. 工程质量问题 - 多地业主投诉存在偷工减料现象,如墙面涂料层数不足、防水工程不达标导致渗漏。部分案例中隐蔽工程(水电布线)
    2025-06-19 装饰 4890浏览
  • 装饰的英文是"decoration",在室内设计和建筑领域涵盖以下专业术语及相关扩展知识:1. Interior Decoration(室内装饰) 指通过家具、织物、艺术品等元素提升空间美感,强调美学搭配而非结构改造。19世纪由Elsie de Wolfe确立为职业
    2025-06-19 装饰 5101浏览
  • 土地节装饰简笔画的创作可从以下元素入手:1. 土地神形象 - 绘制头戴圆顶帽、蓄白胡须的老者形象,手持木质拐杖或金元宝。面部表情慈祥,可添加皱纹线条突出年龄感。 - 传统服饰参考明代风格,交领右衽,衣纹用流畅
    2025-06-19 装饰 8337浏览
  • 鲜花装饰篮子制作教程一、材料准备1. 基础容器选择推荐使用柳编、藤编或麦秆材质的篮子,直径建议25-35cm防水处理:内部需铺设纸或PE防水膜固定材料:花泥(OASIS品牌最佳)、绿铁丝(24#/26#)二、花材处理技巧1. 主花要求:
    2025-06-18 装饰 2954浏览
  • 栏目推荐
  • 集成墙面是一种新型的墙面装饰材料,它的装饰效果多样且具有诸多优势。1. 样式丰富:集成墙面表面有丰富的装饰效果和图案选择,包括木纹、石纹、布艺纹理等,能够模拟各种自然纹理和人造纹理的外观。因此,它可以根据
    2025-05-14 2350浏览
  • 以下是一个简单的圣诞树装饰品的简笔画教程:1. 绘制一个三角形作为圣诞树的基本形状。2. 在圣诞树的树枝上绘制多个彩球作为装饰。彩球可以是不同的颜色,使其看起来更加多彩和活泼。可以绘制大小不同的彩球,以添加层
    2025-05-14 装饰品 4212浏览
  • 仿古挂画是一种很好的室内装饰元素,通过合适的搭配和布局,可以让您的家居空间更具文化底蕴和艺术气息。以下是一些关于如何装饰仿古挂画的建议:1. 选择合适的挂画:首先,要根据房间的风格和装饰需求选择合适的仿古
    2025-05-13 挂画 3674浏览
  • 栏目热点
  • 农村土豪可能会选择一种既豪华又低调的方式来装饰他们的房子。这样的装饰风格通常融合了传统与现代元素,同时注重细节和品质。以下是一些可能的装饰方式和特点:1. 内部装修:可能会采用高档的装修材料,如大理石、实
  • 我的世界黑白装饰画

    查看详情

    我的世界黑白装饰画
  • 装饰材料代理加盟

    查看详情

    装饰材料代理加盟
  • 全站推荐
  • 汽车尾箱地板拆装是一项需要一定动手能力的操作,通常涉及以下步骤和注意事项:1. 清空尾箱空间 拆卸前需移除尾箱内所有物品,包括备胎、工具箱、隔板等,确保操作区域干净无阻碍。部分车型的备胎槽下方可能隐藏固定
    2025-06-13 尾箱 8243浏览
  • 根据风水学理论,属猪的人在购房时需综合考虑方位、五行、流年等因素,以下为具体分析建议:1. 吉利方位 属猪者五行属水,宜选择五行相生的方位增强运势: - 北方(坎卦,五行属水):与生肖猪属性一致,利财运与
    2025-06-13 2886浏览
  • 在卫生间摆放盆景有利有弊,需综合考虑环境条件和植物特性。以下是详细分析:一、有利方面 1. 净化空气:部分植物如绿萝、常春藤、波士顿蕨能吸收甲醛、氨气等挥发性有机物,适合湿度较高的卫生间环境。 2. 调节湿度:
    2025-06-13 盆景 3470浏览
  • 友情链接
    底部分割线