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

饥荒圣诞树的装饰代码

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. 主题契合度:主体物需与装饰场景风格(如现代简约、新
    2026-01-26 装饰画 6505浏览
  • 高密装饰材料市场作为山东省潍坊市高密市的重要产业聚集地,在华东地区具有显著的行业影响力。以下从市场分布、核心产品、产业特色及发展趋势等方面进行专业分析。一、市场分布与核心业态高密装饰材料市场主要分布在
    2026-01-26 装饰材料 2511浏览
  • 幼儿园墙面装饰画环创是幼儿园环境创设的核心环节,需兼顾教育性、审美性、互动性与安全性。以下是专业级设计要点及数据支持:一、核心设计原则1. 主题统一性:需围绕幼儿园教学大纲设定主题(如自然认知、传统文化、
    2026-01-26 装饰画 5117浏览
  • 新车装饰主要分为功能性加装和美观性装饰两大类,根据车辆定位和车主需求,可选择的项目存在显著差异。以下是专业分类及推荐方案:一、基础必备装饰(推荐指数★★★★★) 项目 功能说明 技术参数 价格区间(元) 车
    2026-01-26 装饰 3414浏览
  • 栏目推荐
  • 关于武汉六西格玛装饰的专业性调研结果及相关行业信息梳理如下:一、公司基础信息 项目内容 注册名称武汉六西格玛装饰工程有限公司 成立时间2017年(工商登记信息) 注册资本1000万元 经营范围建筑装饰工程设计施工、
    2025-12-13 装饰 8756浏览
  • 中国装饰设计联盟是中国室内设计与装饰行业的全国性专业组织,通常由设计机构、装饰企业、高等院校、材料供应商等共同组成,致力于推动行业技术交流、标准制定及产业升级。以下是关于该联盟及相关行业的专业解析:一
    2025-12-13 装饰设计联 9977浏览
  • 位面积构成装饰画是一种基于平面构成原理的装饰艺术形式,通过几何单元的面积分割与重组创造视觉韵律。其核心在于运用点、线、面的量化关系,结合材质、色彩、比例的协同作用,实现装饰性与功能性的统一。一、构成原
    2025-12-13 装饰画 5717浏览
  • 栏目热点
  • 上海颐居装饰设计有限公司是专注于高端住宅、商业空间及别墅项目的全案设计与施工服务企业,倡导“人性化设计+精细化施工”理念,以下从核心维度解析其业务特色与行业定位: 核心指标 详细说明 行业对比 设
  • 装饰艺术运动影响

    查看详情

    装饰艺术运动影响
  • 平面装饰方法分类

    查看详情

    平面装饰方法分类
  • 全站推荐
  • 在厨房装修中,集成灶与墙面不一致的问题常见于安装误差、尺寸不匹配或设计规划不当。以下是专业分析与解决方案:一、常见原因分析1. 尺寸偏差:集成灶标准宽度多为750mm、900mm,若预留空间与墙面未对齐会导致缝隙。2. 安
    2026-01-18 集成灶 2773浏览
  • 关于贵州大娄山风水布局的分析,需结合其地理特征、历史脉络及传统风水理论。大娄山属云贵高原东北部核心山脉,橫跨黔北、渝南,是乌江与綦江水系的分水岭,其风水格局对区域发展具有深远影响。一、大娄山的整体风水
    2026-01-18 风水布局 2525浏览
  • 书桌的摆放形式根据空间功能、人体工程学及设计美学可分为多种类型,主要围绕空间利用率、工作效率与视觉效果进行规划。以下是专业分类及扩展说明:一、书桌摆放的核心原则1. 人体工学适配:确保坐姿时视线与屏幕平齐
    2026-01-18 书桌 3251浏览
  • 友情链接
    底部分割线