Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Auras.js
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | rangeOverlays.push( | ||||
"radius": this.GetRange(name), | "radius": this.GetRange(name), | ||||
"texture": rangeOverlay.lineTexture, | "texture": rangeOverlay.lineTexture, | ||||
"textureMask": rangeOverlay.lineTextureMask, | "textureMask": rangeOverlay.lineTextureMask, | ||||
"thickness": rangeOverlay.lineThickness | "thickness": rangeOverlay.lineThickness | ||||
} : | } : | ||||
// Specify default in order not to specify it in about 40 auras | // Specify default in order not to specify it in about 40 auras | ||||
{ | { | ||||
"radius": this.GetRange(name), | "radius": this.GetRange(name), | ||||
"texture": "outline_border.png", | "texture": "outline_border.png", | ||||
"textureMask": "outline_border_mask.png", | "textureMask": "outline_border_mask.png", | ||||
"thickness": 0.2 | "thickness": 0.2 | ||||
}); | }); | ||||
} | } | ||||
return rangeOverlays; | return rangeOverlays; | ||||
}; | }; | ||||
Auras.prototype.CalculateAffectedPlayers = function(name) | Auras.prototype.CalculateAffectedPlayers = function(name) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
Auras.prototype.IsRangeAura = function(name) | Auras.prototype.IsRangeAura = function(name) | ||||
{ | { | ||||
return this.GetType(name) == "range"; | return this.GetType(name) == "range"; | ||||
}; | }; | ||||
Auras.prototype.IsGlobalAura = function(name) | Auras.prototype.IsGlobalAura = function(name) | ||||
{ | { | ||||
return this.GetType(name) == "global" || this.GetType(name) == "player"; | return this.GetType(name) == "global"; | ||||
elexis: I'm not too familiar with the template modification functions, but it looks indeed cleaner to… | |||||
}; | }; | ||||
Auras.prototype.IsPlayerAura = function(name) | Auras.prototype.IsPlayerAura = function(name) | ||||
{ | { | ||||
return this.GetType(name) == "player"; | return this.GetType(name) == "player"; | ||||
}; | }; | ||||
/** | /** | ||||
Show All 38 Lines | for (let name of auraNames) | ||||
this[name].isApplied = this.CanApply(name); | this[name].isApplied = this.CanApply(name); | ||||
var affectedPlayers = this.GetAffectedPlayers(name); | var affectedPlayers = this.GetAffectedPlayers(name); | ||||
if (!affectedPlayers.length) | if (!affectedPlayers.length) | ||||
continue; | continue; | ||||
if (this.IsGlobalAura(name)) | if (this.IsGlobalAura(name)) | ||||
{ | { | ||||
for (let player of affectedPlayers) | |||||
{ | |||||
this.ApplyTemplateBonus(name, affectedPlayers); | this.ApplyTemplateBonus(name, affectedPlayers); | ||||
for (let player of affectedPlayers) | |||||
this.ApplyBonus(name, cmpRangeManager.GetEntitiesByPlayer(player)); | |||||
continue; | |||||
Done Inline Actions(I'm not a fan of forEach unless we need a function to address closure issues or if both arguments of forEach are used, as we use for-loops everywhere else consistently for the same use case.) elexis: (I'm not a fan of `forEach` unless we need a function to address closure issues or if both… | |||||
} | |||||
if (this.IsPlayerAura(name)) | if (this.IsPlayerAura(name)) | ||||
{ | { | ||||
let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); | let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); | ||||
let playerEnts = affectedPlayers.map(player => cmpPlayerManager.GetPlayerByID(player)); | this.ApplyBonus(name, affectedPlayers.map(p => cmpPlayerManager.GetPlayerByID(p))); | ||||
Not Done Inline ActionsSo the primary bugfix is this ApplyTemplateBonus call not performed anymore for auras affecting player entities? elexis: So the primary bugfix is this `ApplyTemplateBonus` call not performed anymore for auras… | |||||
Not Done Inline Actions(Maybe shorten by inlining cmpPlayerManager) elexis: (Maybe shorten by inlining `cmpPlayerManager`) | |||||
this.ApplyBonus(name, playerEnts); | |||||
} | |||||
Not Done Inline ActionsBugfix was this whole thing was applied affectedPlayers.length times instead of just once. temple: Bugfix was this whole thing was applied `affectedPlayers.length` times instead of just once. | |||||
else | |||||
this.ApplyBonus(name, cmpRangeManager.GetEntitiesByPlayer(player)); | |||||
} | |||||
continue; | continue; | ||||
} | } | ||||
Not Done Inline ActionsThis if-continue-if-continue pattern looks cleaner than the nesting before too. elexis: This if-continue-if-continue pattern looks cleaner than the nesting before too.
(It also makes… | |||||
if (!this.IsRangeAura(name)) | if (!this.IsRangeAura(name)) | ||||
{ | { | ||||
this.ApplyBonus(name, targetUnitsClone[name]); | this.ApplyBonus(name, targetUnitsClone[name]); | ||||
continue; | continue; | ||||
} | } | ||||
needVisualizationUpdate = true; | needVisualizationUpdate = true; | ||||
▲ Show 20 Lines • Show All 227 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
I'm not too familiar with the template modification functions, but it looks indeed cleaner to me to have a 1 to 1 / bijective mapping between type property and function return value.