mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 14:43:52 +00:00
Use only one getter for range overlays instead of three to four in the Heal and Auras component.
Move default Heal range visualization texture properties to the template and only display Heal ranges if the template was given. Differential Revision: https://code.wildfiregames.com/D1128 Refs #3915, #4349, D238, D432, D568 This was SVN commit r20624.
This commit is contained in:
@@ -168,7 +168,7 @@ session.showstatusbars = Tab ; Toggle display of status bars
|
||||
session.highlightguarding = PgDn ; Toggle highlight of guarding units
|
||||
session.highlightguarded = PgUp ; Toggle highlight of guarded units
|
||||
session.toggleattackrange = "Alt+C" ; Toggle display of attack range overlays of selected defensive structures
|
||||
session.toggleaurarange = "Alt+V" ; Toggle display of aura range overlays of selected units and structures
|
||||
session.toggleaurasrange = "Alt+V" ; Toggle display of aura range overlays of selected units and structures
|
||||
session.togglehealrange = "Alt+B" ; Toggle display of heal range overlays of selected units
|
||||
|
||||
; > HOTKEYS ONLY
|
||||
@@ -348,7 +348,7 @@ camerajump.threshold = 40 ; How close do we have to be to the actual loc
|
||||
timeelapsedcounter = false ; Show the game duration in the top right corner
|
||||
batchtrainingsize = 5 ; Number of units to be trained per batch (when pressing the hotkey)
|
||||
attackrange = true ; Display attack range overlays of selected defensive structures
|
||||
aurarange = true ; Display aura range overlays of selected units and structures
|
||||
aurasrange = true ; Display aura range overlays of selected units and structures
|
||||
healrange = true ; Display heal range overlays of selected units
|
||||
|
||||
[gui.session.minimap]
|
||||
|
||||
@@ -101,8 +101,8 @@
|
||||
<action on="Press">toggleRangeOverlay("Attack");</action>
|
||||
</object>
|
||||
|
||||
<object hotkey="session.toggleaurarange">
|
||||
<action on="Press">toggleRangeOverlay("Aura");</action>
|
||||
<object hotkey="session.toggleaurasrange">
|
||||
<action on="Press">toggleRangeOverlay("Auras");</action>
|
||||
</object>
|
||||
|
||||
<object hotkey="session.togglehealrange">
|
||||
|
||||
@@ -797,7 +797,7 @@ function onSimulationUpdate()
|
||||
handleNotifications();
|
||||
updateGUIObjects();
|
||||
|
||||
for (let type of ["Attack", "Aura", "Heal"])
|
||||
for (let type of ["Attack", "Auras", "Heal"])
|
||||
Engine.GuiInterfaceCall("EnableVisualRangeOverlayType", {
|
||||
"type": type,
|
||||
"enabled": Engine.ConfigDB_GetValue("user", "gui.session." + type.toLowerCase() + "range") == "true"
|
||||
@@ -1280,7 +1280,7 @@ function toggleConfigBool(configName)
|
||||
|
||||
/**
|
||||
* Toggles the display of range overlays of selected entities for the given range type.
|
||||
* @param {string} type - for example "Aura"
|
||||
* @param {string} type - for example "Auras"
|
||||
*/
|
||||
function toggleRangeOverlay(type)
|
||||
{
|
||||
|
||||
@@ -66,29 +66,6 @@ Auras.prototype.GetRange = function(name)
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the names of any range auras - used to render their ranges.
|
||||
*/
|
||||
Auras.prototype.GetVisualAuraRangeNames = function()
|
||||
{
|
||||
return this.GetAuraNames().filter(auraName => this.IsRangeAura(auraName) && this[auraName].isApplied);
|
||||
};
|
||||
|
||||
Auras.prototype.GetLineTexture = function(name)
|
||||
{
|
||||
return this.auras[name].rangeOverlay ? this.auras[name].rangeOverlay.lineTexture : "outline_border.png";
|
||||
};
|
||||
|
||||
Auras.prototype.GetLineTextureMask = function(name)
|
||||
{
|
||||
return this.auras[name].rangeOverlay ? this.auras[name].rangeOverlay.lineTextureMask : "outline_border_mask.png";
|
||||
};
|
||||
|
||||
Auras.prototype.GetLineThickness = function(name)
|
||||
{
|
||||
return this.auras[name].rangeOverlay ? this.auras[name].rangeOverlay.lineThickness : 0.2;
|
||||
};
|
||||
|
||||
Auras.prototype.GetClasses = function(name)
|
||||
{
|
||||
return this.auras[name].affects;
|
||||
@@ -104,6 +81,35 @@ Auras.prototype.GetAffectedPlayers = function(name)
|
||||
return this.affectedPlayers[name];
|
||||
};
|
||||
|
||||
Auras.prototype.GetRangeOverlays = function()
|
||||
{
|
||||
let rangeOverlays = [];
|
||||
|
||||
for (let name of this.GetAuraNames())
|
||||
{
|
||||
if (!this.IsRangeAura(name) || !this[name].isApplied)
|
||||
continue;
|
||||
|
||||
rangeOverlays.push(
|
||||
this.auras[name].rangeOverlay ?
|
||||
{
|
||||
"radius": this.GetRange(name),
|
||||
"texture": this.auras[name].rangeOverlay.lineTexture,
|
||||
"textureMask": this.auras[name].rangeOverlay.lineTextureMask,
|
||||
"thickness": this.auras[name].rangeOverlay.lineThickness
|
||||
} :
|
||||
// Specify default in order not to specify it in about 40 auras
|
||||
{
|
||||
"radius": this.GetRange(name),
|
||||
"texture": "outline_border.png",
|
||||
"textureMask": "outline_border_mask.png",
|
||||
"thickness": 0.2
|
||||
});
|
||||
}
|
||||
|
||||
return rangeOverlays;
|
||||
};
|
||||
|
||||
Auras.prototype.CalculateAffectedPlayers = function(name)
|
||||
{
|
||||
var affectedPlayers = this.auras[name].affectedPlayers || ["Player"];
|
||||
@@ -278,7 +284,7 @@ Auras.prototype.Clean = function()
|
||||
let cmpRangeVisualization = Engine.QueryInterface(this.entity, IID_RangeVisualization);
|
||||
if (cmpRangeVisualization)
|
||||
{
|
||||
cmpRangeVisualization.UpdateVisualAuraRanges();
|
||||
cmpRangeVisualization.UpdateRangeOverlays("Auras");
|
||||
cmpRangeVisualization.RegenerateRangeVisualizations(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,19 +87,17 @@ Heal.prototype.GetHealableClasses = function()
|
||||
return this.template.HealableClasses._string || "";
|
||||
};
|
||||
|
||||
Heal.prototype.GetLineTexture = function()
|
||||
Heal.prototype.GetRangeOverlays = function()
|
||||
{
|
||||
return this.template.RangeOverlay ? this.template.RangeOverlay.LineTexture : "heal_overlay_range.png";
|
||||
};
|
||||
if (!this.template.RangeOverlay)
|
||||
return [];
|
||||
|
||||
Heal.prototype.GetLineTextureMask = function()
|
||||
{
|
||||
return this.template.RangeOverlay ? this.template.RangeOverlay.LineTextureMask : "heal_overlay_range_mask.png";
|
||||
};
|
||||
|
||||
Heal.prototype.GetLineThickness = function()
|
||||
{
|
||||
return this.template.RangeOverlay ? +this.template.RangeOverlay.LineThickness : 0.35;
|
||||
return [{
|
||||
"radius": this.GetRange().max,
|
||||
"texture": this.template.RangeOverlay.LineTexture,
|
||||
"textureMask": this.template.RangeOverlay.LineTextureMask,
|
||||
"thickness": +this.template.RangeOverlay.LineThickness
|
||||
}]
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ RangeVisualization.prototype.Init = function()
|
||||
this.enabled = false;
|
||||
this.enabledRangeTypes = {
|
||||
"Attack": false,
|
||||
"Aura": false,
|
||||
"Auras": false,
|
||||
"Heal": false
|
||||
};
|
||||
|
||||
@@ -22,42 +22,11 @@ RangeVisualization.prototype.Deserialize = function(data)
|
||||
this.Init();
|
||||
};
|
||||
|
||||
RangeVisualization.prototype.UpdateVisualAttackRanges = function()
|
||||
RangeVisualization.prototype.UpdateRangeOverlays = function(componentName)
|
||||
{
|
||||
let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|
||||
if (cmpAttack)
|
||||
this.rangeVisualizations.set("Attack", cmpAttack.GetRangeOverlays());
|
||||
};
|
||||
|
||||
RangeVisualization.prototype.UpdateVisualAuraRanges = function()
|
||||
{
|
||||
let cmpAuras = Engine.QueryInterface(this.entity, IID_Auras);
|
||||
if (!cmpAuras)
|
||||
return;
|
||||
|
||||
this.rangeVisualizations.set("Aura", []);
|
||||
|
||||
for (let auraName of cmpAuras.GetVisualAuraRangeNames())
|
||||
this.rangeVisualizations.get("Aura").push({
|
||||
"radius": cmpAuras.GetRange(auraName),
|
||||
"texture": cmpAuras.GetLineTexture(auraName),
|
||||
"textureMask": cmpAuras.GetLineTextureMask(auraName),
|
||||
"thickness": cmpAuras.GetLineThickness(auraName),
|
||||
});
|
||||
};
|
||||
|
||||
RangeVisualization.prototype.UpdateVisualHealRanges = function()
|
||||
{
|
||||
let cmpHeal = Engine.QueryInterface(this.entity, IID_Heal);
|
||||
if (!cmpHeal)
|
||||
return;
|
||||
|
||||
this.rangeVisualizations.set("Heal", [{
|
||||
"radius": cmpHeal.GetRange().max,
|
||||
"texture": cmpHeal.GetLineTexture(),
|
||||
"textureMask": cmpHeal.GetLineTextureMask(),
|
||||
"thickness": cmpHeal.GetLineThickness(),
|
||||
}]);
|
||||
let cmp = Engine.QueryInterface(this.entity, global["IID_" + componentName]);
|
||||
if (cmp)
|
||||
this.rangeVisualizations.set(componentName, cmp.GetRangeOverlays());
|
||||
};
|
||||
|
||||
RangeVisualization.prototype.SetEnabled = function(enabled, enabledRangeTypes, forceUpdate)
|
||||
@@ -95,7 +64,8 @@ RangeVisualization.prototype.OnOwnershipChanged = function(msg)
|
||||
if (msg.to == -1)
|
||||
return;
|
||||
for (let type in this.enabledRangeTypes)
|
||||
this["UpdateVisual" + type + "Ranges"]();
|
||||
this.UpdateRangeOverlays(type);
|
||||
|
||||
this.RegenerateRangeVisualizations(false);
|
||||
};
|
||||
|
||||
@@ -106,7 +76,7 @@ RangeVisualization.prototype.OnValueModification = function(msg)
|
||||
msg.valueNames.indexOf("Attack/Ranged/MaxRange") == -1)
|
||||
return;
|
||||
|
||||
this["UpdateVisual" + msg.component + "Ranges"]();
|
||||
this.UpdateRangeOverlays(msg.component);
|
||||
this.RegenerateRangeVisualizations(false);
|
||||
};
|
||||
|
||||
@@ -116,7 +86,7 @@ RangeVisualization.prototype.OnValueModification = function(msg)
|
||||
RangeVisualization.prototype.OnDeserialized = function(msg)
|
||||
{
|
||||
for (let type in this.enabledRangeTypes)
|
||||
this["UpdateVisual" + type + "Ranges"]();
|
||||
this.UpdateRangeOverlays(type);
|
||||
};
|
||||
|
||||
Engine.RegisterComponentType(IID_RangeVisualization, "RangeVisualization", RangeVisualization);
|
||||
|
||||
@@ -53,11 +53,12 @@ TS_ASSERT_EQUALS(cmpHeal.GetHealableClasses(), "Support Infantry");
|
||||
|
||||
TS_ASSERT_EQUALS(cmpHeal.GetUnhealableClasses(), "Cavalry");
|
||||
|
||||
TS_ASSERT_EQUALS(cmpHeal.GetLineTexture(), "heal_overlay_range.png");
|
||||
|
||||
TS_ASSERT_EQUALS(cmpHeal.GetLineTextureMask(), "heal_overlay_range_mask.png");
|
||||
|
||||
TS_ASSERT_EQUALS(cmpHeal.GetLineThickness(), 0.35);
|
||||
TS_ASSERT_UNEVAL_EQUALS(cmpHeal.GetRangeOverlays(), [{
|
||||
"radius": 20 + 300,
|
||||
"texture": "heal_overlay_range.png",
|
||||
"textureMask": "heal_overlay_range_mask.png",
|
||||
"thickness": 0.35
|
||||
}]);
|
||||
|
||||
// Test PerformHeal
|
||||
let target = 70;
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
<Rate>2000</Rate>
|
||||
<UnhealableClasses datatype="tokens"/>
|
||||
<HealableClasses datatype="tokens">Human</HealableClasses>
|
||||
<RangeOverlay>
|
||||
<LineTexture>heal_overlay_range.png</LineTexture>
|
||||
<LineTextureMask>heal_overlay_range_mask.png</LineTextureMask>
|
||||
<LineThickness>0.35</LineThickness>
|
||||
</RangeOverlay>
|
||||
</Heal>
|
||||
<Health>
|
||||
<Max>1000</Max>
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
<Rate>2000</Rate>
|
||||
<UnhealableClasses datatype="tokens"/>
|
||||
<HealableClasses datatype="tokens">Human</HealableClasses>
|
||||
<RangeOverlay>
|
||||
<LineTexture>heal_overlay_range.png</LineTexture>
|
||||
<LineTextureMask>heal_overlay_range_mask.png</LineTextureMask>
|
||||
<LineThickness>0.35</LineThickness>
|
||||
</RangeOverlay>
|
||||
</Heal>
|
||||
<Health>
|
||||
<Max>85</Max>
|
||||
|
||||
Reference in New Issue
Block a user