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

饥荒圣诞树的装饰代码

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

```

文章标签:圣诞树
本站申明:雅美居装饰装修网为装饰装修类百科展示网站,网站所有信息均来源于网络,若有误或侵权请联系本站!
为您推荐
  • 西安不锈钢装饰条是建筑装饰、室内装修中广泛应用的金属材料,因其耐腐蚀、强度高、美观耐用等特点受到市场青睐。以下从产品分类、应用场景、市场分析及选购建议等方面进行专业解析。一、不锈钢装饰条核心参数与分类
    2025-12-27 装饰条 5890浏览
  • 中式装饰装修工程是以中国传统文化为核心,融合传统建筑元素与现代功能需求的室内外空间设计体系。其核心在于平衡形制、材料、工艺、色彩四大要素,体现东方美学中“天人合一”的理念。以下是专业解析:一、核心设计
    2025-12-27 8650浏览
  • 幸福居装饰材料城是中国珠三角地区一家规模较大的装饰材料综合型商贸平台,专注于建材批发、零售及产业链整合服务。以下为专业分析和扩展信息:一、核心业务与市场定位幸福居装饰材料城以一站式家居建材采购为核心,
    2025-12-27 装饰材料 1355浏览
  • 《我的世界》房屋内部装饰专业指南一、核心设计原则1. 空间比例控制:房间宽度建议5-7格,高度3-4格,生存模式需平衡空间利用与资源消耗2. 视觉层次构建:通过阶梯式地台(+0.5格高差)或悬挑梁(横梁下挂灯笼)创造立体空
    2025-12-26 装饰 2390浏览
  • 栏目推荐
  • 装饰设计团队合作是现代室内设计行业不可或缺的环节,涉及多专业协同、流程管理及目标一致性等核心要素。其成功依赖于明确的分工、高效的沟通机制和统一的设计语言。装饰设计团队合作的核心要素包括:专业分工协作、
    2025-11-14 装饰设 3980浏览
  • 漯河创艺装饰设计是河南省漯河市的一家本土装饰设计企业,专注于住宅、商业空间的定制化设计与施工服务。以下从专业角度对其业务模式、设计理念及市场表现进行综合分析:一、企业基础信息 成立时间注册资本资质等级设
    2025-11-13 装饰 4654浏览
  • 梦见给别人装饰可能反映了你对生活中某种美学和秩序的渴望,或者你在现实生活中可能有意无意地在帮助他人实现他们的愿景或目标。接下来,我们从多个角度对这个梦境进行解析,并给出专业建议。梦见给别人装饰的可能象
    2025-11-13 6219浏览
  • 栏目热点
  • 江苏作为我国重要的制造业基地,环保装饰墙板市场发展迅速。该地区的墙板企业依托完善的产业链和先进的生产工艺,在环保性能、设计多样性及施工便捷性方面具有显著优势。以下从市场概况、材料分类、核心品牌、价格体
  • 圣诞节旋转木马装饰

    查看详情

    圣诞节旋转木马装饰
  • 住宅住宅装饰工程合同

    查看详情

    住宅住宅装饰工程合同
  • 全站推荐
  • 大连横山寺是辽南地区知名佛教寺院,其风水格局遵循中国传统堪舆学理论,以“山环水抱、藏风聚气”为核心特征。结合实地环境与建筑布局分析如下:一、风水格局解析1. 地形地势:寺院坐落于大黑山北麓峡谷中,呈三面环
    2025-12-22 横山寺 2494浏览
  • 本命年摆放钟馗摆件是中国传统民俗文化中化解太岁、驱邪纳吉的常见方式。以下从文化渊源、风水原则、摆放禁忌及选购建议等方面进行专业解析:一、钟馗在本命年文化中的象征意义钟馗作为道教神话中的“赐福镇宅圣君”
    2025-12-22 钟馗摆件 5780浏览
  • 以下是关于东莞装饰圈报价大全的专业分析及数据整理,涵盖家装、工装等主流项目的市场行情,并结合影响价格的核心因素进行说明。一、东莞装修报价分类及市场行情东莞装修报价主要分为半包(人工+辅材)、全包(人工+主
    2025-12-22 装饰圈 3808浏览
  • 友情链接
    底部分割线