widgets/healthbadge.lua
345678
local HealthBadge = Class(Badge, function(self, owner)
Badge._ctor(self, "health", owner)
self.topperanim = self.underNumber:AddChild(UIAnim())
self.topperanim:GetAnimState():SetBank("effigy_topper")
3456789101112131415
local HealthBadge = Class(Badge, function(self, owner)
Badge._ctor(self, "health", owner)
self.sanityarrow = self.underNumber:AddChild(UIAnim())
self.sanityarrow:GetAnimState():SetBank("sanity_arrow")
self.sanityarrow:GetAnimState():SetBuild("sanity_arrow")
self.sanityarrow:GetAnimState():PlayAnimation("neutral")
self.sanityarrow:SetClickable(false)
self.topperanim = self.underNumber:AddChild(UIAnim())
self.topperanim:GetAnimState():SetBank("effigy_topper")
91011121314
self.topperanim:GetAnimState():SetBuild("effigy_topper")
self.topperanim:GetAnimState():PlayAnimation("anim")
self.topperanim:SetClickable(false)
end)
1617181920212223
self.topperanim:GetAnimState():SetBuild("effigy_topper")
self.topperanim:GetAnimState():PlayAnimation("anim")
self.topperanim:SetClickable(false)
self:StartUpdating()
end)
19202122
self.topperanim:GetAnimState():SetPercent("anim", penaltypercent)
end
return HealthBadge
2829303132333435363738394041424344454647
self.topperanim:GetAnimState():SetPercent("anim", penaltypercent)
end
function HealthBadge:OnUpdate(dt)
local down = self.owner.components.temperature:IsFreezing() or self.owner.components.hunger:IsStarving() or self.owner.components.health.takingfiredamage
local anim = down and "arrow_loop_decrease_most" or "neutral"
if anim and self.arrowdir ~= anim then
self.arrowdir = anim
self.sanityarrow:GetAnimState():PlayAnimation(anim, true)
end
end
return HealthBadge