prefabs/evergreens.lua
103104105106107108109110111112113114115116117118119120121122123124125126127128129130
return build
end
local function OnBurnt(inst)
inst:DoTaskInTime( 0.5,
function()
if inst.components.burnable then
inst.components.burnable:Extinguish()
end
inst:RemoveComponent("burnable")
inst:RemoveComponent("propagator")
inst:RemoveComponent("growable")
inst.components.lootdropper:SetLoot({})
if GetBuild(inst).drop_pinecones then
inst.components.lootdropper:AddChanceLoot("pinecone", 0.1)
end
if inst.components.workable then
inst.components.workable:SetWorkLeft(1)
inst.components.workable:SetOnWorkCallback(nil)
inst.components.workable:SetOnFinishCallback(chop_down_burnt_tree)
end
end)
inst.AnimState:PlayAnimation(inst.anims.burnt, true)
inst.AnimState:SetRayTestOnBB(true);
inst:AddTag("burnt")
103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
return build
end
local function OnBurnt(inst, imm)
local function changes()
if inst.components.burnable then
inst.components.burnable:Extinguish()
end
inst:RemoveComponent("burnable")
inst:RemoveComponent("propagator")
inst:RemoveComponent("growable")
inst.components.lootdropper:SetLoot({})
if GetBuild(inst).drop_pinecones then
inst.components.lootdropper:AddChanceLoot("pinecone", 0.1)
end
if inst.components.workable then
inst.components.workable:SetWorkLeft(1)
inst.components.workable:SetOnWorkCallback(nil)
inst.components.workable:SetOnFinishCallback(chop_down_burnt_tree)
end
end
if imm then
changes()
else
inst:DoTaskInTime( 0.5, changes)
end
inst.AnimState:PlayAnimation(inst.anims.burnt, true)
inst.AnimState:SetRayTestOnBB(true);
inst:AddTag("burnt")
263264265266267268
local function chop_down_tree(inst, chopper)
inst:RemoveComponent("burnable")
inst:RemoveComponent("propagator")
inst:RemoveComponent("workable")
inst.SoundEmitter:PlaySound("dontstarve/forest/treefall")
268269270271272273274
local function chop_down_tree(inst, chopper)
inst:RemoveComponent("burnable")
MakeSmallBurnable(inst)
inst:RemoveComponent("propagator")
inst:RemoveComponent("workable")
inst.SoundEmitter:PlaySound("dontstarve/forest/treefall")
366367368369370371372
local function handler_growfromseed (inst, data)
inst.components.growable:SetStage(1)
inst.AnimState:PlayAnimation("grow_seed_to_short")
inst.SoundEmitter:PlaySound("dontstarve/forest/treeGrow")
372373374375376377378
local function handler_growfromseed (inst)
inst.components.growable:SetStage(1)
inst.AnimState:PlayAnimation("grow_seed_to_short")
inst.SoundEmitter:PlaySound("dontstarve/forest/treeGrow")
396397398399400401402403404405
end
if data.burnt then
OnBurnt(inst)
elseif data.stump then
inst:RemoveComponent("workable")
inst:RemoveComponent("burnable")
inst:RemoveComponent("propagator")
inst:RemoveComponent("growable")
RemovePhysicsColliders(inst)
402403404405406407408409410411412
end
if data.burnt then
OnBurnt(inst, true)
elseif data.stump then
inst:RemoveComponent("burnable")
MakeSmallBurnable(inst)
inst:RemoveComponent("workable")
inst:RemoveComponent("propagator")
inst:RemoveComponent("growable")
RemovePhysicsColliders(inst)
414415416417418419
end
end
local function makefn(build, stage, data)
local function fn(Sim)
421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
end
end
local function OnEntitySleep(inst)
inst:RemoveComponent("burnable")
inst:RemoveComponent("propagator")
inst:RemoveComponent("inspectable")
end
local function OnEntityWake(inst)
if not inst:HasTag("burnt") and not inst:HasTag("fire") and not inst:HasTag("stump") then
if not inst.components.burnable then
MakeLargeBurnable(inst)
inst.components.burnable:SetFXLevel(5)
inst.components.burnable:SetOnBurntFn(tree_burnt)
end
if not inst.components.propagator then
MakeLargePropagator(inst)
end
end
if not inst.components.inspectable then
inst:AddComponent("inspectable")
inst.components.inspectable.getstatus = inspect_tree
end
end
local function makefn(build, stage, data)
local function fn(Sim)
451452453454455456
MakeLargeBurnable(inst)
inst.components.burnable:SetFXLevel(5)
inst.components.burnable:SetOnBurntFn(tree_burnt)
MakeLargePropagator(inst)
-------------------
485486487488489490491
MakeLargeBurnable(inst)
inst.components.burnable:SetFXLevel(5)
inst.components.burnable:SetOnBurntFn(tree_burnt)
MakeLargePropagator(inst)
-------------------
476477478479480481482483
inst.components.growable.loopstages = true
inst.components.growable:StartGrowing()
inst:ListenForEvent("growfromseed", handler_growfromseed )
---------------------
--PushSway(inst)
511512513514515516517
inst.components.growable.loopstages = true
inst.components.growable:StartGrowing()
inst.growfromseed = handler_growfromseed
---------------------
--PushSway(inst)
498499500501502503504505
end
if data =="stump" then
inst:RemoveComponent("workable")
inst:RemoveComponent("burnable")
inst:RemoveComponent("propagator")
inst:RemoveComponent("growable")
RemovePhysicsColliders(inst)
532533534535536537538539540
end
if data =="stump" then
inst:RemoveComponent("burnable")
MakeSmallBurnable(inst)
inst:RemoveComponent("workable")
inst:RemoveComponent("propagator")
inst:RemoveComponent("growable")
RemovePhysicsColliders(inst)
511512513514515516
inst.components.workable:SetWorkLeft(1)
end
return inst
end
return fn
546547548549550551552553554555556
inst.components.workable:SetWorkLeft(1)
end
inst.OnEntitySleep = OnEntitySleep
inst.OnEntityWake = OnEntityWake
return inst
end
return fn