Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/helpers/Commands.js
Show First 20 Lines • Show All 456 Lines • ▼ Show 20 Lines | "unset-rallypoint": function(player, cmd, data) | ||||
} | } | ||||
}, | }, | ||||
"resign": function(player, cmd, data) | "resign": function(player, cmd, data) | ||||
{ | { | ||||
data.cmpPlayer.SetState("defeated", markForTranslation("%(player)s has resigned.")); | data.cmpPlayer.SetState("defeated", markForTranslation("%(player)s has resigned.")); | ||||
}, | }, | ||||
"occupy-turret": function(player, cmd, data) | |||||
{ | |||||
GetFormationUnitAIs(data.entities, player).forEach(cmpUnitAI => { | |||||
cmpUnitAI.OccupyTurret(cmd.target, cmd.queued); | |||||
}); | |||||
}, | |||||
"garrison": function(player, cmd, data) | "garrison": function(player, cmd, data) | ||||
{ | { | ||||
if (!CanPlayerOrAllyControlUnit(cmd.target, player, data.controlAllUnits)) | if (!CanPlayerOrAllyControlUnit(cmd.target, player, data.controlAllUnits)) | ||||
{ | { | ||||
if (g_DebugCommands) | if (g_DebugCommands) | ||||
warn("Invalid command: garrison target cannot be controlled by player "+player+" (or ally): "+uneval(cmd)); | warn("Invalid command: garrison target cannot be controlled by player "+player+" (or ally): "+uneval(cmd)); | ||||
return; | return; | ||||
} | } | ||||
Show All 19 Lines | var g_Commands = { | ||||
"stop": function(player, cmd, data) | "stop": function(player, cmd, data) | ||||
{ | { | ||||
GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { | GetFormationUnitAIs(data.entities, player, cmd, data.formation).forEach(cmpUnitAI => { | ||||
cmpUnitAI.Stop(cmd.queued); | cmpUnitAI.Stop(cmd.queued); | ||||
}); | }); | ||||
}, | }, | ||||
"leave-turret": function(player, cmd, data) | |||||
{ | |||||
let notUnloaded = 0; | |||||
for (let ent of data.entities) | |||||
{ | |||||
let cmpTurretable = Engine.QueryInterface(ent, IID_Turretable); | |||||
if (!cmpTurretable || !cmpTurretable.LeaveTurret()) | |||||
++notUnloaded; | |||||
} | |||||
if (notUnloaded) | |||||
notifyUnloadFailure(player); | |||||
}, | |||||
"unload-turrets": function(player, cmd, data) | |||||
{ | |||||
let notUnloaded = 0; | |||||
for (let ent of data.entities) | |||||
{ | |||||
let cmpTurretHolder = Engine.QueryInterface(ent, IID_TurretHolder); | |||||
for (let turret of cmpTurretHolder.GetEntities()) | |||||
{ | |||||
let cmpTurretable = Engine.QueryInterface(turret, IID_Turretable); | |||||
if (!cmpTurretable || !cmpTurretable.LeaveTurret()) | |||||
++notUnloaded; | |||||
} | |||||
} | |||||
if (notUnloaded) | |||||
notifyUnloadFailure(player); | |||||
}, | |||||
"unload": function(player, cmd, data) | "unload": function(player, cmd, data) | ||||
{ | { | ||||
if (!CanPlayerOrAllyControlUnit(cmd.garrisonHolder, player, data.controlAllUnits)) | if (!CanPlayerOrAllyControlUnit(cmd.garrisonHolder, player, data.controlAllUnits)) | ||||
{ | { | ||||
if (g_DebugCommands) | if (g_DebugCommands) | ||||
warn("Invalid command: unload target cannot be controlled by player "+player+" (or ally): "+uneval(cmd)); | warn("Invalid command: unload target cannot be controlled by player "+player+" (or ally): "+uneval(cmd)); | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 330 Lines • ▼ Show 20 Lines | for (let ent of data.entities) | ||||
cmpResourceDropsite.SetSharing(cmd.shared); | cmpResourceDropsite.SetSharing(cmd.shared); | ||||
} | } | ||||
}, | }, | ||||
}; | }; | ||||
/** | /** | ||||
* Sends a GUI notification about unit(s) that failed to ungarrison. | * Sends a GUI notification about unit(s) that failed to ungarrison. | ||||
*/ | */ | ||||
function notifyUnloadFailure(player, garrisonHolder) | function notifyUnloadFailure(player) | ||||
{ | { | ||||
var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); | let cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); | ||||
cmpGUIInterface.PushNotification({ | cmpGUIInterface.PushNotification({ | ||||
"type": "text", | "type": "text", | ||||
"players": [player], | "players": [player], | ||||
"message": markForTranslation("Unable to ungarrison unit(s)"), | "message": markForTranslation("Unable to unload unit(s)."), | ||||
"translateMessage": true | "translateMessage": true | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Sends a GUI notification about worker(s) that failed to go back to work. | * Sends a GUI notification about worker(s) that failed to go back to work. | ||||
*/ | */ | ||||
function notifyBackToWorkFailure(player) | function notifyBackToWorkFailure(player) | ||||
▲ Show 20 Lines • Show All 917 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator