Make health correctly recalculate its cached values when the entity changes owner.
Following e16c4c4800
, the ModifierManager no longer sends
ValueModificationMessages when an entity changes owner to/from
INVALID_ENTITY. This happens in particular when the entity is renamed.
For now, components must check on their own in OwnershipChanged.
Reported By: Freagarach
Patch By: Angen
Reviewed By: wraitii
Fixes #5588
Differential Revision: https://code.wildfiregames.com/D2286
This was SVN commit r22912.
This commit is contained in:
parent
4d4bf579b2
commit
14fff267a1
@ -409,11 +409,8 @@ Health.prototype.UpdateActor = function()
|
||||
cmpVisual.SetVariant("health", newDamageVariant);
|
||||
};
|
||||
|
||||
Health.prototype.OnValueModification = function(msg)
|
||||
Health.prototype.RecalculateValues = function()
|
||||
{
|
||||
if (msg.component != "Health")
|
||||
return;
|
||||
|
||||
let oldMaxHitpoints = this.GetMaxHitpoints();
|
||||
let newMaxHitpoints = ApplyValueModificationsToEntity("Health/Max", +this.template.Max, this.entity);
|
||||
if (oldMaxHitpoints != newMaxHitpoints)
|
||||
@ -431,8 +428,20 @@ Health.prototype.OnValueModification = function(msg)
|
||||
|
||||
if (this.regenRate != oldRegenRate || this.idleRegenRate != oldIdleRegenRate)
|
||||
this.CheckRegenTimer();
|
||||
}
|
||||
|
||||
Health.prototype.OnValueModification = function(msg)
|
||||
{
|
||||
if (msg.component == "Health")
|
||||
this.RecalculateValues();
|
||||
};
|
||||
|
||||
Health.prototype.OnOwnershipChanged = function(msg)
|
||||
{
|
||||
if (msg.to != INVALID_PLAYER)
|
||||
this.RecalculateValues();
|
||||
}
|
||||
|
||||
Health.prototype.RegisterHealthChanged = function(from)
|
||||
{
|
||||
this.CheckRegenTimer();
|
||||
|
Loading…
Reference in New Issue
Block a user