Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Resistance.js
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
Resistance.prototype.SetInvulnerability = function(invulnerability) | Resistance.prototype.SetInvulnerability = function(invulnerability) | ||||
{ | { | ||||
this.invulnerable = invulnerability; | this.invulnerable = invulnerability; | ||||
Engine.PostMessage(this.entity, MT_InvulnerabilityChanged, { "entity": this.entity, "invulnerability": invulnerability }); | Engine.PostMessage(this.entity, MT_InvulnerabilityChanged, { "entity": this.entity, "invulnerability": invulnerability }); | ||||
}; | }; | ||||
/** | /** | ||||
* Calculate the effective resistance of an entity to a particular effect. | * Calculate the effective resistance of an entity. | ||||
* ToDo: Support resistance against status effects. | * ToDo: Support resistance against status effects. | ||||
* @param {string} effectType - The type of attack effect the resistance has to be calculated for (e.g. "Damage", "Capture"). | |||||
* @return {Object} - An object of the type { "Damage": { "Crush": number, "Hack": number }, "Capture": number }. | * @return {Object} - An object of the type { "Damage": { "Crush": number, "Hack": number }, "Capture": number }. | ||||
*/ | */ | ||||
Resistance.prototype.GetEffectiveResistanceAgainst = function(effectType) | Resistance.prototype.GetEffectiveResistance = function() | ||||
{ | { | ||||
let ret = {}; | return this.GetResistanceOfForm(Engine.QueryInterface(this.entity, IID_Foundation) ? "Foundation" : "Entity"); | ||||
let template = this.GetResistanceOfForm(Engine.QueryInterface(this.entity, IID_Foundation) ? "Foundation" : "Entity"); | |||||
if (template[effectType]) | |||||
ret[effectType] = template[effectType]; | |||||
return ret; | |||||
}; | }; | ||||
/** | /** | ||||
* Get all separate resistances for showing in the GUI. | * Get all separate resistances for showing in the GUI. | ||||
* @return {Object} - All resistances ordered by type. | * @return {Object} - All resistances ordered by type. | ||||
*/ | */ | ||||
Resistance.prototype.GetFullResistance = function() | Resistance.prototype.GetFullResistance = function() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator