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

饥荒圣诞树的装饰代码

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

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 关于郑州东易日盛装饰招聘的专业信息整理如下:东易日盛装饰集团(股票代码:002713)是中国家装行业上市公司,成立于1997年。郑州分公司作为其华中地区重要分支机构,主要招聘岗位集中在室内设计、工程管理、客户服务、
    2026-01-11 装饰 4482浏览
  • 户外专柜装饰需兼顾品牌形象展示、环境适应性和用户体验优化。以下是专业装饰方案的核心要素及实施建议:一、结构设计与材料选择1. 模块化框架:采用可拆卸的铝合金或钢结构,适配不同场地,抗风等级需≥8级。2. 耐用面
    2026-01-10 装饰 8126浏览
  • 针对西南医院无尘室装饰安装的专业需求,需结合医院特殊环境对洁净度、感染控制及功能性要求,遵循医疗净化工程规范(如GB 50333《医院洁净手术部建筑技术规范》、GMP标准等)。以下从设计、施工、验收及扩展数据进行系统
    2026-01-10 装饰安装 2549浏览
  • 天津装饰石线安装是建筑装饰工程中的重要环节,主要用于室内外墙面、天花板、门套等部位的装饰线条施工,提升空间立体感与美观度。以下是关于材料选择、施工工艺及本地化注意事项的详细说明:一、装饰石线类型与选材
    2026-01-10 装饰石线 3549浏览
  • 栏目推荐
  • 陶瓷装饰在中国传统文化中承载着丰富的寓意与象征意义,既体现了工艺美学,又蕴含深厚的文化内涵。以下是专业性的分析:一、陶瓷装饰的寓意分类陶瓷装饰的纹样、色彩与造型往往对应特定的文化寓意,主要可分为以下几
    2025-12-02 陶瓷装饰 3042浏览
  • 壁纸小装饰手工制作是通过对剩余或专用壁纸进行裁剪、拼贴、立体塑造等工艺,制作成墙面点缀物或独立装饰品的过程。以下是专业级制作指南及相关数据:一、核心材料与工具 类别 推荐选择 用途说明 基础材料 PVC/纯纸/
    2025-12-01 壁纸 8190浏览
  • 壁挂数码万年历装饰画是一种融合时间显示、日历功能与艺术装饰的智能家居产品,通过数字化显示技术实现万年历、温度湿度、节日提醒等功能,同时兼顾美学设计,成为现代家居/办公室装饰的关键元素。一、核心功能与技术
    2025-12-01 装饰画 7478浏览
  • 栏目热点
  • 江西陶瓷装饰材质以景德镇瓷器为代表,融合了釉料、颜料及胎体质地的综合应用,核心装饰技法包括釉下彩、釉上彩、颜色釉和玲珑雕花等。以下是专业解析:一、主流装饰材质与技术 装饰技法材质构成工艺特点代表作品 青
  • 装饰艺术运动影响

    查看详情

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

    查看详情

    平面装饰方法分类
  • 全站推荐
  • 贵州卫生间垃圾桶批发渠道及行业分析在贵州省从事卫生间垃圾桶批发业务,需重点关注以下三方面核心内容:供应链渠道布局、产品质量标准及本地化服务能力。以下为专业领域详细分析:一、贵州省主要批发渠道分布1. 实体
    2026-01-07 垃圾桶 7230浏览
  • 酒店厨房用品的管理是确保餐饮运营高效、安全和成本可控的核心环节,涉及采购、存储、使用、维护及损耗控制等多个维度。以下是专业性管理方案及扩展内容:一、标准化管理流程1. 分类编码系统:所有厨房用品按功能(如
    2026-01-07 厨房用品 9676浏览
  • 选择适合卧室的绿植尺寸需综合考虑空间大小、植物特性、健康影响等因素。以下是专业建议及扩展内容:1. 绿植尺寸与卧室面积的匹配原则绿植体型应与卧室面积成比例,避免过大规模导致氧气竞争或视觉压抑。推荐以下匹配
    2026-01-07 绿植 6134浏览
  • 友情链接
    底部分割线