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

饥荒圣诞树的装饰代码

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-11-15 灯饰 5780浏览
  • 装饰设计团队合作是现代室内设计行业不可或缺的环节,涉及多专业协同、流程管理及目标一致性等核心要素。其成功依赖于明确的分工、高效的沟通机制和统一的设计语言。装饰设计团队合作的核心要素包括:专业分工协作、
    2025-11-14 装饰设 3980浏览
  • 漯河创艺装饰设计是河南省漯河市的一家本土装饰设计企业,专注于住宅、商业空间的定制化设计与施工服务。以下从专业角度对其业务模式、设计理念及市场表现进行综合分析:一、企业基础信息 成立时间注册资本资质等级设
    2025-11-13 装饰 4654浏览
  • 梦见给别人装饰可能反映了你对生活中某种美学和秩序的渴望,或者你在现实生活中可能有意无意地在帮助他人实现他们的愿景或目标。接下来,我们从多个角度对这个梦境进行解析,并给出专业建议。梦见给别人装饰的可能象
    2025-11-13 6219浏览
  • 栏目推荐
  • 装饰摆件创意情侣款是家居装饰与情感表达的结合体,它不仅承载着美化空间的功能,更象征着情侣间的独特纽带与浪漫记忆。这类产品通常注重设计原创性、材质情感化和互动趣味性,旨在通过艺术形式强化伴侣间的亲密关系
    2025-09-21 摆件 7833浏览
  • 在中国,从事装修装饰工程需要具备相应的资质,不同工程规模和类型对资质要求不同。以下是主要资质分类和相关要求:1. 建筑装修装饰工程专业承包资质 - 分为一级和二级。一级资质可承接各类装修装饰工程,二级资质可
    2025-09-19 3328浏览
  • 兄弟装饰茶园店的电话可通过以下方式获取: 1. 官网查询:访问兄弟装饰集团官方网站(www.xdzs.com),在“门店信息”或“联系我们”板块查找茶园分店的详细联系方式,通常包括座机、手机及客服热线。 2. 第三方平台核实:
    2025-09-19 6990浏览
  • 栏目热点
  • 鲁中装饰材料城转让涉及多个关键环节和注意事项,需综合评估市场环境、法律风险及经营策略,以下是具体分析: 一、转让核心事项1. 产权明晰 - 需核查不动产权证、土地性质(商业/工业)、剩余使用年限。若为租赁物业
  • 新乡市金港装饰广场

    查看详情

    新乡市金港装饰广场
  • 弱电箱装饰画液压

    查看详情

    弱电箱装饰画液压
  • 全站推荐
  • 蓝色屋顶在传统风水学中并无明确禁忌,但需结合建筑整体环境、五行属性及居住者命理综合分析。以下为专业性内容解析:一、蓝色在风水中的象征意义蓝色属水,象征冷静、智慧与流动。在五行理论中,水能生木、克火,适
    2025-11-11 5015浏览
  • 交易员办公室的摆件摆放不仅仅是装饰的问题,更是一个结合心理暗示、风水学和工作环境优化的综合考量。通过合理摆放适当的摆件,可以提升交易员的专注力、判断力和整体工作效率。以下是一些与交易员办公室摆件摆放相
    2025-11-11 摆件 8201浏览
  • 装饰设计服务计划方案是为客户提供专业的装饰设计服务的详细规划,与室内设计、空间规划、材料选材等相关,旨在满足客户对空间功能和美观的需求。以下是关于装饰设计服务计划方案的详细内容。一、装饰设计服务的基本
    2025-11-11 装饰设计 2577浏览
  • 友情链接
    底部分割线