Documentation: ManaReloaderComponent
Jump to navigation
Jump to search
This component does not have any properties.
When an entity has this component and it's enabled,
it causes the mana
field on the entity's AbilityComponent
to update according to the mana_charge_speed
.
Lua Code Sample: ManaReloaderComponent updates |
-- This Lua code approximates what the engine does when updating ManaReloader components
-- Runs on every frame for every component
function update_ManaReloaderComponent(entity_id, component_id)
if not ComponentGetIsEnabled(component_id) then
return
end
local ability_comp =
EntityGetFirstComponentIncludingDisabled(entity_id, "AbilityComponent")
local mana = ComponentGetValue2(ability_comp, "mana")
local mana_max = ComponentGetValue2(ability_comp, "mana_max")
local mana_charge_speed = ComponentGetValue2(ability_comp, "mana_charge_speed")
local new_mana = math.min(mana_max, mana + mana_charge_speed * 0.016666567)
ComponentSetValue2(ability_comp, "mana", new_mana)
end
|