Differential D3663 Diff 19803 ps/trunk/binaries/data/mods/public/simulation/components/EntityLimits.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/EntityLimits.js
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
const TRAINING = "training"; | const TRAINING = "training"; | ||||
const BUILD = "build"; | const BUILD = "build"; | ||||
EntityLimits.prototype.Init = function() | EntityLimits.prototype.Init = function() | ||||
{ | { | ||||
this.limit = {}; | this.limit = {}; | ||||
this.count = {}; // counts entities which change the limit of the given category | // Counts entities which change the limit of the given category. | ||||
this.count = {}; | |||||
this.changers = {}; | this.changers = {}; | ||||
this.removers = {}; | this.removers = {}; | ||||
this.classCount = {}; // counts entities with the given class, used in the limit removal | // Counts entities with the given class, used in the limit removal. | ||||
this.classCount = {}; | |||||
this.removedLimit = {}; | this.removedLimit = {}; | ||||
this.matchTemplateCount = {}; | this.matchTemplateCount = {}; | ||||
for (var category in this.template.Limits) | for (var category in this.template.Limits) | ||||
{ | { | ||||
this.limit[category] = +this.template.Limits[category]; | this.limit[category] = +this.template.Limits[category]; | ||||
this.count[category] = 0; | this.count[category] = 0; | ||||
if (category in this.template.LimitChangers) | if (category in this.template.LimitChangers) | ||||
{ | { | ||||
this.changers[category] = {}; | this.changers[category] = {}; | ||||
for (var c in this.template.LimitChangers[category]) | for (var c in this.template.LimitChangers[category]) | ||||
this.changers[category][c] = +this.template.LimitChangers[category][c]; | this.changers[category][c] = +this.template.LimitChangers[category][c]; | ||||
} | } | ||||
if (category in this.template.LimitRemovers) | if (category in this.template.LimitRemovers) | ||||
{ | { | ||||
this.removedLimit[category] = this.limit[category]; // keep a copy of removeable limits for possible restoration | // Keep a copy of removable limits for possible restoration. | ||||
this.removedLimit[category] = this.limit[category]; | |||||
this.removers[category] = {}; | this.removers[category] = {}; | ||||
for (var c in this.template.LimitRemovers[category]) | for (var c in this.template.LimitRemovers[category]) | ||||
{ | { | ||||
this.removers[category][c] = this.template.LimitRemovers[category][c]._string.split(/\s+/); | this.removers[category][c] = this.template.LimitRemovers[category][c]._string.split(/\s+/); | ||||
if (c === "RequiredClasses") | if (c === "RequiredClasses") | ||||
for (var cls of this.removers[category][c]) | for (var cls of this.removers[category][c]) | ||||
this.classCount[cls] = 0; | this.classCount[cls] = 0; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator