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

饥荒圣诞树的装饰代码

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-04-28 汽车装饰 3519浏览
  • 建筑装饰材料包括多个类别,主要用于建筑物的内部和外部装饰。以下是一些主要的建筑装饰材料:1. 墙体材料:包括乳胶漆、木饰面板、墙砖、饰线板等。其中,乳胶漆是常见的墙面装饰材料,具有色彩丰富、易于施工和保养
    2025-04-27 装饰材料 3614浏览
  • 婚车后面的装饰是婚礼中的重要环节,旨在为婚礼增添喜庆和美好的氛围。以下是婚车后面的装饰建议:1. 喜字或囍字装饰:可以在婚车的车尾部分贴上醒目的喜字或囍字,代表新婚的喜悦和祝福。2. 鲜花装饰:使用鲜花作为装
    2025-04-27 1225浏览
  • 重庆卓坊装饰是一家专业从事室内设计、施工及软装配套服务的装饰公司,具有多年的行业经验和良好的市场口碑。关于公司的具体情况,可以从以下几个方面进行了解:1. 设计与创意:卓坊装饰拥有专业的设计团队,能够根据
    2025-04-27 装饰 565浏览
  • 栏目推荐
  • 怀化金煌装饰是一家在怀化地区专业从事家居装饰的公司,具有多年的经验和良好的口碑。他们的服务质量和专业水平得到了客户的广泛认可。具体来说,怀化金煌装饰有以下几个方面的优势:1. 设计能力:他们拥有一支专业的
    2025-02-27 装饰 1624浏览
  • 客厅玄关是家居装饰中的重要部分,它不仅可以增加空间的美感,还能为家庭带来独特的氛围。现场画装饰作为玄关的一部分,可以增添艺术气息和个性化元素。以下是一些关于客厅玄关现场画装饰的建议:1. 选择主题:玄关画
    2025-02-26 9316浏览
  • 万圣节是西方的一个重要节日,为孩子们带来无尽的欢乐和惊喜。为了装饰幼儿园的门户以营造节日氛围,我们可以采取以下创意方案:一、设计主题:以万圣节为主题,注重安全性和趣味性,让孩子们感受到节日的神秘与欢乐
    2025-02-26 万圣节装饰 8867浏览
  • 栏目热点
  • 大转弯装饰材料市场是一个专业的建材市场,涵盖了各种类型的建筑装饰材料,包括但不限于门窗、墙面、地面、吊顶、灯具以及其他各种附件。在这个市场中,可以购买到各种类型的装饰材料和商品,从而满足建筑和装饰项目
  • 张家港鸟巢装饰不错

    查看详情

    张家港鸟巢装饰不错
  • 写诗词怎样装饰花边

    查看详情

    写诗词怎样装饰花边
  • 全站推荐
  • 厨房的水管连接到卫生间的方式根据具体的房屋结构和管道布局而定,以下是一般的方法和步骤:1. 确定厨房和卫生间的位置:首先需要确定厨房和卫生间的位置,以便确定水管的走向。2. 预留洞口:在确定好管道走向后,需要
    2025-04-08 水管 1285浏览
  • 卧室门上有个灯泡,这一设计很常见。门上的灯泡主要为了提供方便的照明,便于在进入或离开房间时能够清晰地看到周围环境。下面列举一些关于卧室门上灯泡的考虑因素和使用建议:1. 照明功能:灯泡的基本功能是提供照明
    2025-04-08 灯泡 3288浏览
  • 在客厅装修中,选择美缝剂还是墙布,主要取决于您的具体需求和装修风格。美缝剂和墙布各有其优点和缺点:美缝剂:1. 优点:美缝剂的色彩丰富,可以根据个人喜好选择颜色,还能很好地与瓷砖搭配,提升整体装修档次。此
    2025-04-08 墙布 3702浏览
  • 友情链接
    底部分割线