1
0
forked from mirrors/0ad
Files
0ad/binaries/data/mods/public/simulation/components/Loot.js
T
elexis 52f311da2b Merge resource agnostic branch by s0600204, fixes #3934.
Remove all occurances of hardcoded resources in the simulation, GUI and
AI code by
specifying resources as JSON files in a new simulation subdirectory and
accessing them through a globally defined prototype.

This was SVN commit r18964.
2016-11-19 14:29:45 +00:00

28 lines
608 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 +(this.template.xp || 0);
};
Loot.prototype.GetResources = function()
{
let ret = {};
for (let res of Resources.GetCodes())
ret[res] = +(this.template[res] || 0);
return ret;
};
Engine.RegisterComponentType(IID_Loot, "Loot", Loot);