prefabs/trap_teeth.lua
464748495051525354555657
inst.AnimState:PlayAnimation("trap_idle")
end
local function OnDropped(inst)
if inst.components.mine then
inst.components.mine:Reset()
end
end
local function MakeTeethTrapNormal()
local inst = CreateEntity()
local trans = inst.entity:AddTransform()
4647484950515253545556575859606162636465666768697071
inst.AnimState:PlayAnimation("trap_idle")
end
local function SetInactive(inst)
inst.AnimState:PlayAnimation("inactive")
end
local function OnDropped(inst)
inst.components.mine:Deactivate()
end
local function ondeploy(inst, pt, deployer)
inst.components.mine:Reset()
inst.Physics:Teleport(pt:Get())
end
--legacy save support - mines used to start out activated
local function onload(inst, data)
if not data or not data.mine then
inst.components.mine:Reset()
end
end
local function MakeTeethTrapNormal()
local inst = CreateEntity()
local trans = inst.entity:AddTransform()
79808182838485
inst.components.mine:SetOnExplodeFn(OnExplode)
inst.components.mine:SetOnResetFn(OnReset)
inst.components.mine:SetOnSprungFn(SetSprung)
inst.components.mine:StartTesting()
inst:AddComponent("finiteuses")
inst.components.finiteuses:SetMaxUses(TUNING.TRAP_TEETH_USES)
93949596979899100
inst.components.mine:SetOnExplodeFn(OnExplode)
inst.components.mine:SetOnResetFn(OnReset)
inst.components.mine:SetOnSprungFn(SetSprung)
inst.components.mine:SetOnDeactivateFn(SetInactive)
--inst.components.mine:StartTesting()
inst:AddComponent("finiteuses")
inst.components.finiteuses:SetMaxUses(TUNING.TRAP_TEETH_USES)
868788899091
inst.components.finiteuses:SetUses(TUNING.TRAP_TEETH_USES)
inst.components.finiteuses:SetOnFinished( onfinished_normal )
return inst
end
101102103104105106107108109110111112
inst.components.finiteuses:SetUses(TUNING.TRAP_TEETH_USES)
inst.components.finiteuses:SetOnFinished( onfinished_normal )
inst:AddComponent("deployable")
inst.components.deployable.ondeploy = ondeploy
inst.components.deployable.min_spacing = .75
inst.components.mine:Deactivate()
inst.OnLoad = onload
return inst
end
102103104105106107108109110111
inst.components.finiteuses:SetMaxUses(1)
inst.components.finiteuses:SetUses(1)
inst.components.finiteuses:SetOnFinished( onfinished_maxwell )
return inst
end
return Prefab( "common/inventory/trap_teeth", MakeTeethTrapNormal, assets),
Prefab( "common/inventory/trap_teeth_maxwell", MakeTeethTrapMaxwell, assets)
123124125126127128129130131132133134135136
inst.components.finiteuses:SetMaxUses(1)
inst.components.finiteuses:SetUses(1)
inst.components.finiteuses:SetOnFinished( onfinished_maxwell )
inst.components.mine:Reset()
inst.AnimState:PlayAnimation("idle")
return inst
end
return Prefab( "common/inventory/trap_teeth", MakeTeethTrapNormal, assets),
MakePlacer("common/trap_teeth_placer", "trap_teeth", "trap_teeth", "idle"),
Prefab( "common/inventory/trap_teeth_maxwell", MakeTeethTrapMaxwell, assets)