mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 14:23:56 -07:00
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
binaries/data/mods/public/simulation/components/[H-P]*
Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
26 lines
753 B
JavaScript
26 lines
753 B
JavaScript
function Loot() {}
|
|
|
|
Loot.prototype.Schema =
|
|
"<a:help>Specifies the loot credited when this entity is killed.</a:help>" +
|
|
"<a:example>" +
|
|
"<xp>35</xp>" +
|
|
"<metal>10</metal>" +
|
|
"</a:example>" +
|
|
Resources.BuildSchema("nonNegativeInteger", ["xp"]);
|
|
|
|
Loot.prototype.Serialize = null; // we have no dynamic state to save
|
|
|
|
Loot.prototype.GetXp = function()
|
|
{
|
|
return Math.floor(ApplyValueModificationsToEntity("Loot/xp", +(this.template.xp || 0), this.entity));
|
|
};
|
|
|
|
Loot.prototype.GetResources = function()
|
|
{
|
|
const ret = {};
|
|
for (const res of Resources.GetCodes())
|
|
ret[res] = Math.floor(ApplyValueModificationsToEntity("Loot/" + res, +(this.template[res] || 0), this.entity));
|
|
return ret;
|
|
};
|
|
|
|
Engine.RegisterComponentType(IID_Loot, "Loot", Loot);
|