Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/RallyPoint.js
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||
RallyPoint.prototype.Reset = function() | RallyPoint.prototype.Reset = function() | ||||
{ | { | ||||
this.Unset(); | this.Unset(); | ||||
var cmpRallyPointRenderer = Engine.QueryInterface(this.entity, IID_RallyPointRenderer); | var cmpRallyPointRenderer = Engine.QueryInterface(this.entity, IID_RallyPointRenderer); | ||||
if (cmpRallyPointRenderer) | if (cmpRallyPointRenderer) | ||||
cmpRallyPointRenderer.Reset(); | cmpRallyPointRenderer.Reset(); | ||||
}; | }; | ||||
/** | |||||
* @param {number} entity - The entity ID of the entity to order to the rally point. | |||||
* @param {string[]} ignore - The commands to ignore when performed on this.entity. | |||||
* E.g. "garrison" when unloading. | |||||
*/ | |||||
RallyPoint.prototype.OrderToRallyPoint = function(entity, ignore = []) | |||||
{ | |||||
let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | |||||
if (!cmpOwnership) | |||||
return; | |||||
let owner = cmpOwnership.GetOwner(); | |||||
let cmpEntOwnership = Engine.QueryInterface(entity, IID_Ownership); | |||||
if (!cmpEntOwnership || cmpEntOwnership.GetOwner() != owner) | |||||
return; | |||||
let commands = GetRallyPointCommands(this, [entity]); | |||||
if (!commands.length || | |||||
commands[0].target == this.entity && ignore.includes(commands[0].type)) | |||||
return; | |||||
for (let command of commands) | |||||
ProcessCommand(owner, command); | |||||
}; | |||||
RallyPoint.prototype.OnGlobalEntityRenamed = function(msg) | RallyPoint.prototype.OnGlobalEntityRenamed = function(msg) | ||||
{ | { | ||||
for (var data of this.data) | for (var data of this.data) | ||||
{ | { | ||||
if (!data) | if (!data) | ||||
continue; | continue; | ||||
if (data.target && data.target == msg.entity) | if (data.target && data.target == msg.entity) | ||||
data.target = msg.newentity; | data.target = msg.newentity; | ||||
Show All 28 Lines |
Wildfire Games · Phabricator