Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/common-api/shared.js
Show First 20 Lines • Show All 352 Lines • ▼ Show 20 Lines | m.SharedScript.prototype.setMetadata = function(player, ent, key, value) | ||||
this.updateEntityCollections('metadata', ent); | this.updateEntityCollections('metadata', ent); | ||||
this.updateEntityCollections('metadata.' + key, ent); | this.updateEntityCollections('metadata.' + key, ent); | ||||
}; | }; | ||||
m.SharedScript.prototype.getMetadata = function(player, ent, key) | m.SharedScript.prototype.getMetadata = function(player, ent, key) | ||||
{ | { | ||||
let metadata = this._entityMetadata[player][ent.id()]; | let metadata = this._entityMetadata[player][ent.id()]; | ||||
return metada && metadata[key]; | |||||
if (!metadata || !(key in metadata)) | |||||
return undefined; | |||||
return metadata[key]; | |||||
}; | }; | ||||
m.SharedScript.prototype.deleteMetadata = function(player, ent, key) | m.SharedScript.prototype.deleteMetadata = function(player, ent, key) | ||||
{ | { | ||||
let metadata = this._entityMetadata[player][ent.id()]; | let metadata = this._entityMetadata[player][ent.id()]; | ||||
if (!metadata || !(key in metadata)) | if (!metadata || !(key in metadata)) | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | m.SharedScript.prototype.changeEntityInResourceMapHelper = function(ent, multiplication = 1) | ||||
const strength = multiplication * ent.resourceSupplyMax() / this.normalizationFactor[grp]; | const strength = multiplication * ent.resourceSupplyMax() / this.normalizationFactor[grp]; | ||||
this.resourceMaps[resource].addInfluence(x, y, this.influenceRadius[grp] / cellSize, strength / 2, "constant"); | this.resourceMaps[resource].addInfluence(x, y, this.influenceRadius[grp] / cellSize, strength / 2, "constant"); | ||||
this.resourceMaps[resource].addInfluence(x, y, this.influenceRadius[grp] / cellSize, strength / 2); | this.resourceMaps[resource].addInfluence(x, y, this.influenceRadius[grp] / cellSize, strength / 2); | ||||
this.ccResourceMaps[resource].addInfluence(x, y, this.ccInfluenceRadius[grp] / cellSize, strength, "constant"); | this.ccResourceMaps[resource].addInfluence(x, y, this.ccInfluenceRadius[grp] / cellSize, strength, "constant"); | ||||
}; | }; | ||||
return m; | return m; | ||||
}(API3); | }(API3); | ||||
Lint: no-use-before-define: 'API3' was used before it was defined. | |||||
Wildfire Games · Phabricator
'API3' was used before it was defined.