Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Health.js
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | Health.prototype.Init = function() | ||||
// (Allowing 0 initial HP would break our death detection code) | // (Allowing 0 initial HP would break our death detection code) | ||||
this.hitpoints = +(this.template.Initial || this.GetMaxHitpoints()); | this.hitpoints = +(this.template.Initial || this.GetMaxHitpoints()); | ||||
this.regenRate = ApplyValueModificationsToEntity("Health/RegenRate", +this.template.RegenRate, this.entity); | this.regenRate = ApplyValueModificationsToEntity("Health/RegenRate", +this.template.RegenRate, this.entity); | ||||
this.idleRegenRate = ApplyValueModificationsToEntity("Health/IdleRegenRate", +this.template.IdleRegenRate, this.entity); | this.idleRegenRate = ApplyValueModificationsToEntity("Health/IdleRegenRate", +this.template.IdleRegenRate, this.entity); | ||||
this.CheckRegenTimer(); | this.CheckRegenTimer(); | ||||
this.UpdateActor(); | this.UpdateActor(); | ||||
}; | }; | ||||
Health.prototype.Update = function(newTemplate) | |||||
{ | |||||
this.template = newTemplate; | |||||
this.RecalculateValues(); | |||||
}; | |||||
/** | /** | ||||
* Returns the current hitpoint value. | * Returns the current hitpoint value. | ||||
* This is 0 if (and only if) the unit is dead. | * This is 0 if (and only if) the unit is dead. | ||||
*/ | */ | ||||
Health.prototype.GetHitpoints = function() | Health.prototype.GetHitpoints = function() | ||||
{ | { | ||||
return this.hitpoints; | return this.hitpoints; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 454 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator