mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Simplify GuiInterface.prototype.GetTemplateData
Some statements could be inlined and only passing relevant aura templates to the TemplateHelper isn't required, so we can simply always pass all of them and save the work.
This commit is contained in:
parent
a89ce596a4
commit
a2befad973
1 changed files with 2 additions and 25 deletions
|
|
@ -643,31 +643,8 @@ GuiInterface.prototype.GetAverageRangeForBuildings = function(player, cmd)
|
||||||
|
|
||||||
GuiInterface.prototype.GetTemplateData = function(player, data)
|
GuiInterface.prototype.GetTemplateData = function(player, data)
|
||||||
{
|
{
|
||||||
const templateName = data.templateName;
|
const template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager)?.GetTemplate(data.templateName);
|
||||||
const owner = data.player !== undefined ? data.player : player;
|
return template && g_TemplateHelper.computeDataFromPlayer(template, AuraTemplates.GetAll(), Resources, data.player || player);
|
||||||
const cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
|
|
||||||
const template = cmpTemplateManager.GetTemplate(templateName);
|
|
||||||
|
|
||||||
if (!template)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
const aurasTemplate = {};
|
|
||||||
|
|
||||||
if (!template.Auras)
|
|
||||||
return g_TemplateHelper.computeDataFromPlayer(template, aurasTemplate, Resources, owner);
|
|
||||||
|
|
||||||
const auraNames = template.Auras._string.split(/\s+/);
|
|
||||||
|
|
||||||
for (const name of auraNames)
|
|
||||||
{
|
|
||||||
const auraTemplate = AuraTemplates.Get(name);
|
|
||||||
if (!auraTemplate)
|
|
||||||
error("Template " + templateName + " has undefined aura " + name);
|
|
||||||
else
|
|
||||||
aurasTemplate[name] = auraTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_TemplateHelper.computeDataFromPlayer(template, aurasTemplate, Resources, owner);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GuiInterface.prototype.AreRequirementsMet = function(player, data)
|
GuiInterface.prototype.AreRequirementsMet = function(player, data)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue