Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Trigger.js
Show First 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | |||||
Trigger.prototype.OnGlobalDiplomacyChanged = function(msg) | Trigger.prototype.OnGlobalDiplomacyChanged = function(msg) | ||||
{ | { | ||||
this.CallEvent("DiplomacyChanged", msg); | this.CallEvent("DiplomacyChanged", msg); | ||||
}; | }; | ||||
/** | /** | ||||
* Execute a function after a certain delay. | * Execute a function after a certain delay. | ||||
* | * | ||||
* @param {Number} time - delay in milleseconds | * @param {Number} time - Delay in milliseconds. | ||||
bb: mille == good amount of money, milli => small rubbish
Also below | |||||
Done Inline Actions. bb: . | |||||
Done Inline Actions. bb: . | |||||
* @param {String} action - Name of the action function | * @param {String} action - Name of the action function. | ||||
Done Inline Actionsadd periods while on it Hyphen not needed bb: add periods while on it
Hyphen not needed | |||||
Done Inline Actionshyphen not even supported as intended http://usejsdoc.org/tags-returns.html Typically have added periods if there was more than one sentence, but it's true that it's grammatically correct for the first sentence too, so meh, adding periods and might even have to do that in future diffs. elexis: hyphen not even supported as intended http://usejsdoc.org/tags-returns.html
Typically have… | |||||
* @param {Object} data - will be passed to the action function | * @param {Object} data - Arbitrary object that will be passed to the action function. | ||||
* @return {Number} The ID of the timer, so it can be stopped later. | |||||
Done Inline Actionsperiod bb: period | |||||
*/ | */ | ||||
Trigger.prototype.DoAfterDelay = function(miliseconds, action, data) | Trigger.prototype.DoAfterDelay = function(time, action, data) | ||||
{ | { | ||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | ||||
return cmpTimer.SetTimeout(SYSTEM_ENTITY, IID_Trigger, "DoAction", time, { | |||||
"action": action, | |||||
"data": data | |||||
}); | |||||
}; | |||||
return cmpTimer.SetTimeout(SYSTEM_ENTITY, IID_Trigger, "DoAction", miliseconds, { | /** | ||||
* Execute a function each time a certain delay has passed. | |||||
Done Inline ActionsExecute a function each time a certain delay has passed. bb: Execute a function each time **a** certain delay has passed. | |||||
* | |||||
* @param {Number} interval - Interval in milleseconds between consecutive calls. | |||||
Done Inline ActionsMake clear it is both the time of first call and the interval between calls. bb: Make clear it is both the time of first call and the interval between calls. | |||||
Done Inline Actionsby making that initial delay an optional argument elexis: by making that initial delay an optional argument | |||||
* @param {String} action - Name of the action function. | |||||
* @param {Object} data - Arbitrary object that will be passed to the action function. | |||||
Done Inline Actionskeep sinc with doAfterDelay bb: keep sinc with `doAfterDelay` | |||||
* @param {Number} [start] - Optional initial delay in milleseconds before starting the calls. | |||||
Done Inline ActionsKeep capital letters consistent, also above hyphen not needed bb: Keep capital letters consistent, also above
hyphen not needed
More periods | |||||
* If not given, interval will be used. | |||||
* @return {Number} the ID of the timer, so it can be stopped later. | |||||
Done Inline ActionsCaps in this whole jsDoc too bb: Caps in this whole jsDoc too | |||||
*/ | |||||
Trigger.prototype.DoRepeatedly = function(time, action, data, start) | |||||
{ | |||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | |||||
return cmpTimer.SetInterval(SYSTEM_ENTITY, IID_Trigger, "DoAction", start !== undefined ? start : time, time, { | |||||
"action": action, | "action": action, | ||||
"data": data | "data": data | ||||
}); | }); | ||||
}; | }; | ||||
/** | /** | ||||
* Called by the trigger listeners to exucute the actual action. Including sanity checks. | * Called by the trigger listeners to exucute the actual action. Including sanity checks. | ||||
*/ | */ | ||||
Show All 9 Lines |
Wildfire Games · Phabricator
mille == good amount of money, milli => small rubbish
Also below