Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Gate.js
Show First 20 Lines • Show All 244 Lines • ▼ Show 20 Lines | |||||
* gate will start a timer and attempt to close on each simulation update. | * gate will start a timer and attempt to close on each simulation update. | ||||
*/ | */ | ||||
Gate.prototype.CloseGate = function() | Gate.prototype.CloseGate = function() | ||||
{ | { | ||||
let cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); | let cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); | ||||
if (!cmpObstruction) | if (!cmpObstruction) | ||||
return; | return; | ||||
// The gate can't be closed if there are entities colliding with it. | // The gate can't be closed if there are units colliding with it. | ||||
// NB: because walls are overlapping, they requires special care to not break | // This doesn't consider static entities, as it is assumed either: | ||||
// in particular, walls do not block construction, so walls from skirmish maps | // - the gate couldn't be built in the first place | ||||
// do not appear in this check even if they have different control groups from the gate. | // - the gate was put there by some higher power (e.g. skirmish replacements, atlas). | ||||
// This no longer works if gates are made to check for entities blocking movement. | // In either case we probably don't want to account for them. | ||||
// Fixing that would let us change this code, but it sounds decidedly non-trivial. | // TODO: this precludes some "gate blocker" from existing. | ||||
let collisions = cmpObstruction.GetEntitiesBlockingConstruction(); | let collisions = cmpObstruction.GetUnitsBlockingMovement(); | ||||
if (collisions.length) | if (collisions.length) | ||||
{ | { | ||||
if (!this.timer) | if (!this.timer) | ||||
{ | { | ||||
// Set an "instant" timer which will run on the next simulation turn. | // Set an "instant" timer which will run on the next simulation turn. | ||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | ||||
this.timer = cmpTimer.SetTimeout(this.entity, IID_Gate, "OperateGate", 0); | this.timer = cmpTimer.SetTimeout(this.entity, IID_Gate, "OperateGate", 0); | ||||
} | } | ||||
Show All 18 Lines |
Wildfire Games · Phabricator