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

饥荒圣诞树的装饰代码

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

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 杭州交换空间装饰是杭州地区一家专注于局部装修、空间改造、软装设计的装饰公司,其业务模式借鉴了央视《交换空间》节目理念,强调高性价比、短工期、个性化设计。以下为专业解析:一、核心业务与服务模式杭州交换空
    2026-01-22 装饰 4864浏览
  • 车里安全座椅装饰的专业指南在车内安全座椅(尤其是儿童安全座椅)的装饰过程中,需严格遵循安全性与功能性原则。以下从专业角度解析装饰的合规性、材料选择及风险规避方案。一、安全座椅装饰的合规性要求根据国际标
    2026-01-22 座椅装饰 6902浏览
  • 针对滨州室外装饰设计招聘的查询,结合当前市场趋势与企业需求,以下为专业分析及数据汇总:一、滨州室外装饰设计招聘现状滨州市对室外装饰设计人才的需求主要集中在商业综合体、景观工程及建筑外立面改造领域。近期
    2026-01-22 装饰设计 9009浏览
  • 针对酒店装饰画马克笔的专业需求,需综合考虑色彩表现力、耐光性、耐久性、环保性等核心要素。以下从工具选型、技法应用及行业标准三个维度展开分析:一、专业马克笔选型标准酒店装饰画需适应公共场所的复杂环境,建
    2026-01-22 装饰画 2637浏览
  • 栏目推荐
  • 关于宜宾嘉仁装饰刘梅的专业信息如下:1. 企业基础信息根据公开工商数据,刘梅为宜宾嘉仁装饰工程有限公司的主要负责人。企业基础信息整理如下:项目内容企业全称宜宾嘉仁装饰工程有限公司成立时间2016年9月22日(存续状
    2025-12-07 装饰 4524浏览
  • 吧台和餐厅装饰的专业方案需综合功能性、美学设计及用户体验,以下是分场景的详细指导,涵盖商业与家庭空间:一、核心设计原则1. 功能分区:• 吧台区:工作区宽度≥70cm,顾客区留出90cm通行空间• 餐区:单人位宽度60-70
    2025-12-07 装饰 2734浏览
  • 居家装饰系统(Home Decoration System)是指通过系统性规划与设计,实现居住空间功能优化、美学提升及环境协调的综合解决方案。其核心涵盖空间布局、风格定位、材料选择、智能集成及可持续性设计等维度,旨在满足个性化居住
    2025-12-06 装饰系统 4524浏览
  • 栏目热点
  • 新式墙面板材装饰是当前建筑装饰领域的重要技术方向,广泛应用于商业空间、住宅、公共建筑等场景。其核心在于材料创新、功能集成与施工便捷性的提升。以下是专业分类与技术解析:一、主流新型墙面板材类型及特性
  • 大连金尚装饰坑人新闻

    查看详情

    大连金尚装饰坑人新闻
  • 云岩区现代装饰风格装修

    查看详情

    云岩区现代装饰风格装修
  • 全站推荐
  • 针对卫生间一楼的利用问题,需综合考虑功能拓展、空间优化及实用性。以下从功能性利用、商用价值开发、家装设计建议及数据参考四个维度展开说明。一、功能性利用方向一楼卫生间因靠近出入口,适合承担多重角色:1. 公
    2026-01-16 2397浏览
  • 更换厨房风扇叶是一项需要谨慎操作的任务,涉及电器安全与机械安装知识。以下是专业步骤及注意事项:一、更换前准备1. 断电:关闭电源并拔掉插座,确保安全。2. 工具准备:螺丝刀(十字/一字)、扳手、橡胶手套、新风扇
    2026-01-16 风扇叶 7407浏览
  • 在现代室内设计中,客厅与餐厅不吊顶的方案逐渐成为趋势,尤其适用于追求极简主义、层高有限或预算受限的居住空间。以下是针对该需求的专业分析及解决方案:一、不吊顶的优势与适用场景1. 层高最大化:保留原始层高(
    2026-01-16 吊顶 3963浏览
  • 友情链接
    底部分割线