private void ResetFollowOrder() { this._followedEntity = (GameEntity)null; this._followTacticalPosition = (TacticalPosition)null; if (this._ladders.Any <SiegeLadder>()) { this._followedEntity = (this._ladders.FirstOrDefault <SiegeLadder>((Func <SiegeLadder, bool>)(l => !l.IsDeactivated && l.InitialWaitPosition.HasScriptOfType <TacticalPosition>())) ?? this._ladders.FirstOrDefault <SiegeLadder>((Func <SiegeLadder, bool>)(l => !l.IsDeactivated))).InitialWaitPosition; if ((NativeObject)this._followedEntity == (NativeObject)null) { this._followedEntity = this._ladders.FirstOrDefault <SiegeLadder>((Func <SiegeLadder, bool>)(l => !l.IsDeactivated)).InitialWaitPosition; } this._followOrder = MovementOrder.MovementOrderFollowEntity(this._followedEntity); } else if (this._breachedWallSegment != null) { this._followedEntity = this._breachedWallSegment.GameEntity.CollectChildrenEntitiesWithTag("attacker_wait_pos").FirstOrDefault <GameEntity>(); this._followOrder = MovementOrder.MovementOrderFollowEntity(this._followedEntity); } else { this._followOrder = MovementOrder.MovermentOrderNull; } if (!((NativeObject)this._followedEntity != (NativeObject)null)) { return; } this._followTacticalPosition = this._followedEntity.GetFirstScriptOfType <TacticalPosition>(); }
private void RecreateFollowEntityOrder() { this._followEntityOrder = MovementOrder.MovementOrderStop; UsableMachine usableMachine = this._primarySiegeWeapons.Where <UsableMachine>((Func <UsableMachine, bool>)(psw => !psw.IsDeactivated && psw is IPrimarySiegeWeapon && !(psw as IPrimarySiegeWeapon).HasCompletedAction())).FirstOrDefault <UsableMachine>(); if (usableMachine == null) { return; } this._followEntityOrder = MovementOrder.MovementOrderFollowEntity(usableMachine.WaitEntity); }
protected virtual void OnTick( Func <Agent, bool> isAgentManagedByThisMachineAI, Team potentialUsersTeam, float dt) { this._tickCounter = ++this._tickCounter % 200; foreach (StandingPoint standingPoint in this.UsableMachine.StandingPoints) { if (isAgentManagedByThisMachineAI(standingPoint.UserAgent)) { Agent userAgent = standingPoint.UserAgent; if (this.HasActionCompleted || potentialUsersTeam != null && this.UsableMachine.IsDisabledForBattleSideAI(potentialUsersTeam.Side) || userAgent.IsRunningAway) { this.HandleAgentStopUsingStandingPoint(userAgent, standingPoint); } } List <KeyValuePair <Agent, UsableMissionObject.MoveInfo> > list = standingPoint.MovingAgents.ToList <KeyValuePair <Agent, UsableMissionObject.MoveInfo> >(); List <Agent> agentList = new List <Agent>(); for (int index = list.Count - 1; index >= 0; --index) { Agent key = list[index].Key; if (isAgentManagedByThisMachineAI(key)) { if (this.HasActionCompleted || potentialUsersTeam != null && this.UsableMachine.IsDisabledForBattleSideAI(potentialUsersTeam.Side) || key.IsRunningAway) { this.HandleAgentStopUsingStandingPoint(key, standingPoint); } else { if (standingPoint.HasAlternative() && this.UsableMachine.IsInRangeToCheckAlternativePoints(key)) { StandingPoint pointAlternativeTo = this.UsableMachine.GetBestPointAlternativeTo(standingPoint, key); if (pointAlternativeTo != standingPoint) { standingPoint.OnMoveToStopped(key); key.AIMoveToGameObjectEnable((UsableMissionObject)pointAlternativeTo, this.GetScriptedFrameFlags(key)); if (standingPoint == this.UsableMachine.CurrentlyUsedAmmoPickUpPoint) { this.UsableMachine.CurrentlyUsedAmmoPickUpPoint = pointAlternativeTo; continue; } continue; } } if (standingPoint.HasUserPositionsChanged(key)) { WorldFrame userFrameForAgent = standingPoint.GetUserFrameForAgent(key); string debugString = this.UsableMachine.GameEntity.Name + " Id:" + (object)this.UsableMachine.Id.Id + " " + standingPoint.GameEntity.Name; key.SetScriptedPositionAndDirection(ref userFrameForAgent.Origin, userFrameForAgent.Rotation.f.AsVec2.RotationInRadians, false, this.GetScriptedFrameFlags(key), debugString); } if (!standingPoint.IsDisabled && !standingPoint.HasUser && !key.IsAIPaused() && key.CanReachAndUseObject((UsableMissionObject)standingPoint, standingPoint.GetUserFrameForAgent(key).Origin.GetGroundVec3().DistanceSquared(key.Position))) { key.UseGameObject((UsableMissionObject)standingPoint); key.SetScriptedFlags(key.GetScriptedFlags() & ~standingPoint.DisableScriptedFrameFlags); agentList.Add(key); } } } } } if (!((NativeObject)this._lastActiveWaitStandingPoint != (NativeObject)this.UsableMachine.WaitEntity)) { return; } foreach (Formation formation in potentialUsersTeam.FormationsIncludingSpecial.Where <Formation>((Func <Formation, bool>)(f => f.IsUsingMachine(this.UsableMachine) && f.MovementOrder.OrderEnum == MovementOrder.MovementOrderEnum.FollowEntity && (NativeObject)f.MovementOrder.TargetEntity == (NativeObject)this._lastActiveWaitStandingPoint))) { formation.MovementOrder = !(this is SiegeTowerAI) ? MovementOrder.MovementOrderFollowEntity(this.UsableMachine.WaitEntity) : this.NextOrder; } this._lastActiveWaitStandingPoint = this.UsableMachine.WaitEntity; }