Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/globalscripts/DamageTypes.js
/** | /** | ||||
* This class provides a cache for accessing damage types metadata stored in JSON files. | * This class provides a cache for accessing damage types metadata stored in JSON files. | ||||
* Note that damage types need not be defined in JSON files to be handled in-game. | * Note that damage types need not be defined in JSON files to be handled in-game. | ||||
* (this is intended to simplify modding) | * (this is intended to simplify modding) | ||||
* This class must be initialised before using, as initialising it directly in globalscripts would | * This class must be initialised before using, as initialising it directly in globalscripts would | ||||
* introduce disk I/O every time e.g. a GUI page is loaded. | * introduce disk I/O every time e.g. a GUI page is loaded. | ||||
*/ | */ | ||||
class DamageTypesMetadata | class DamageTypesMetadata | ||||
{ | { | ||||
constructor() | constructor() | ||||
{ | { | ||||
this.damageTypeData = {}; | this.damageTypeData = {}; | ||||
let files = Engine.ListDirectoryFiles("simulation/data/template_helpers/damage_types", "*.json", false); | let files = Engine.ListDirectoryFiles("simulation/data/damage_types", "*.json", false); | ||||
for (let filename of files) | for (let filename of files) | ||||
{ | { | ||||
let data = Engine.ReadJSONFile(filename); | let data = Engine.ReadJSONFile(filename); | ||||
if (!data) | if (!data) | ||||
continue; | continue; | ||||
if (data.code in this.damageTypeData) | if (data.code in this.damageTypeData) | ||||
{ | { | ||||
Show All 35 Lines |
Wildfire Games · Phabricator