Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/garrisonManager.js
Show First 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | if (gameState.ai.Config.debug > 2) | ||||
warn(" we try to garrison a unit with plan " + ent.getMetadata(PlayerID, "plan") + " and role " + ent.getMetadata(PlayerID, "role") + | warn(" we try to garrison a unit with plan " + ent.getMetadata(PlayerID, "plan") + " and role " + ent.getMetadata(PlayerID, "role") + | ||||
" and subrole " + ent.getMetadata(PlayerID, "subrole") + " and transport " + ent.getMetadata(PlayerID, "transport")); | " and subrole " + ent.getMetadata(PlayerID, "subrole") + " and transport " + ent.getMetadata(PlayerID, "transport")); | ||||
} | } | ||||
if (ent.getMetadata(PlayerID, "plan") !== undefined) | if (ent.getMetadata(PlayerID, "plan") !== undefined) | ||||
ent.setMetadata(PlayerID, "plan", -2); | ent.setMetadata(PlayerID, "plan", -2); | ||||
else | else | ||||
ent.setMetadata(PlayerID, "plan", -3); | ent.setMetadata(PlayerID, "plan", -3); | ||||
ent.setMetadata(PlayerID, "subrole", "garrisoning"); | ent.setMetadata(PlayerID, "subrole", PETRA.Worker.SUBROLE_GARRISONING); | ||||
ent.setMetadata(PlayerID, "garrisonHolder", holder.id()); | ent.setMetadata(PlayerID, "garrisonHolder", holder.id()); | ||||
ent.setMetadata(PlayerID, "garrisonType", type); | ent.setMetadata(PlayerID, "garrisonType", type); | ||||
ent.garrison(holder); | ent.garrison(holder); | ||||
}; | }; | ||||
/** | /** | ||||
This is the end of the pre-garrison state, either because the entity is really garrisoned | This is the end of the pre-garrison state, either because the entity is really garrisoned | ||||
or because it has changed its order (i.e. because the garrisonHolder was destroyed) | or because it has changed its order (i.e. because the garrisonHolder was destroyed) | ||||
This function is for internal use inside garrisonManager. From outside, you should also update | This function is for internal use inside garrisonManager. From outside, you should also update | ||||
the holder and then using cancelGarrison should be the preferred solution | the holder and then using cancelGarrison should be the preferred solution | ||||
*/ | */ | ||||
PETRA.GarrisonManager.prototype.leaveGarrison = function(ent) | PETRA.GarrisonManager.prototype.leaveGarrison = function(ent) | ||||
{ | { | ||||
ent.setMetadata(PlayerID, "subrole", undefined); | ent.setMetadata(PlayerID, "subrole", PETRA.Worker.SUBROLE_EMPTY); | ||||
if (ent.getMetadata(PlayerID, "plan") === -2) | if (ent.getMetadata(PlayerID, "plan") === -2) | ||||
ent.setMetadata(PlayerID, "plan", -1); | ent.setMetadata(PlayerID, "plan", -1); | ||||
else | else | ||||
ent.setMetadata(PlayerID, "plan", undefined); | ent.setMetadata(PlayerID, "plan", undefined); | ||||
ent.setMetadata(PlayerID, "garrisonHolder", undefined); | ent.setMetadata(PlayerID, "garrisonHolder", undefined); | ||||
}; | }; | ||||
/** Cancel a pre-garrison state */ | /** Cancel a pre-garrison state */ | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator