protected internal override void TickOccasionally() { base.TickOccasionally(); this._targetWeapons.RemoveAll((Predicate <SiegeWeapon>)(tw => tw.IsDestroyed)); if (this._targetWeapons.Count == 0) { this.DetermineTargetWeapons(); } if (this.formation.AI.ActiveBehavior != this) { return; } if (this._targetWeapons.Count == 0) { if (this.CurrentOrder != (object)MovementOrder.MovementOrderCharge) { this.CurrentOrder = MovementOrder.MovementOrderCharge; } this._isTargetPrimaryWeapon = false; } else { SiegeWeapon siegeWeapon = this._targetWeapons.MinBy <SiegeWeapon, float>((Func <SiegeWeapon, float>)(tw => this.formation.QuerySystem.AveragePosition.DistanceSquared(tw.GameEntity.GlobalPosition.AsVec2))); if (this.CurrentOrder.OrderEnum != MovementOrder.MovementOrderEnum.AttackEntity || this.LastTargetWeapon != siegeWeapon) { this.LastTargetWeapon = siegeWeapon; this.CurrentOrder = MovementOrder.MovementOrderAttackEntity(this.LastTargetWeapon.GameEntity, true); } } this.formation.MovementOrder = this.CurrentOrder; }
private void ResetOrderPositions() { this._primarySiegeWeapons = Mission.Current.ActiveMissionObjects.FindAllWithType <UsableMachine>().Where <UsableMachine>((Func <UsableMachine, bool>)(amo => amo is IPrimarySiegeWeapon)).Select <UsableMachine, IPrimarySiegeWeapon>((Func <UsableMachine, IPrimarySiegeWeapon>)(amo => amo as IPrimarySiegeWeapon)).ToList <IPrimarySiegeWeapon>(); this._primarySiegeWeapons.RemoveAll((Predicate <IPrimarySiegeWeapon>)(uM => uM.WeaponSide != this.behaviorSide)); IEnumerable <ICastleKeyPosition> source = TeamAISiegeComponent.SiegeLanes.Where <SiegeLane>((Func <SiegeLane, bool>)(sl => sl.LaneSide == this.behaviorSide)).SelectMany <SiegeLane, ICastleKeyPosition>((Func <SiegeLane, IEnumerable <ICastleKeyPosition> >)(sila => (IEnumerable <ICastleKeyPosition>)sila.DefensePoints)); this._innerGate = this._teamAISiegeComponent.InnerGate; this._isGateLane = this._teamAISiegeComponent.OuterGate.DefenseSide == this.behaviorSide; this._wallSegment = !this._isGateLane ? (!(source.FirstOrDefault <ICastleKeyPosition>((Func <ICastleKeyPosition, bool>)(dp => dp is WallSegment && (dp as WallSegment).IsBreachedWall)) is WallSegment wallSegment) ? this._primarySiegeWeapons.MaxBy <IPrimarySiegeWeapon, float>((Func <IPrimarySiegeWeapon, float>)(psw => psw.SiegeWeaponPriority)).TargetCastlePosition as WallSegment : wallSegment) : (WallSegment)null; this._stopOrder = MovementOrder.MovementOrderStop; this._chargeOrder = MovementOrder.MovementOrderCharge; bool flag = this._teamAISiegeComponent.OuterGate != null && this.behaviorSide == this._teamAISiegeComponent.OuterGate.DefenseSide; this._attackEntityOrderOuterGate = !flag || this._teamAISiegeComponent.OuterGate.IsDeactivated || this._teamAISiegeComponent.OuterGate.State == CastleGate.GateState.Open ? MovementOrder.MovementOrderStop : MovementOrder.MovementOrderAttackEntity(this._teamAISiegeComponent.OuterGate.GameEntity, false); this._attackEntityOrderInnerGate = !flag || this._teamAISiegeComponent.InnerGate == null || (this._teamAISiegeComponent.InnerGate.IsDeactivated || this._teamAISiegeComponent.InnerGate.State == CastleGate.GateState.Open) ? MovementOrder.MovementOrderStop : MovementOrder.MovementOrderAttackEntity(this._teamAISiegeComponent.InnerGate.GameEntity, false); this._castleGateMoveOrder = MovementOrder.MovementOrderMove(this._teamAISiegeComponent.OuterGate.MiddleFrame.Origin); this._wallSegmentMoveOrder = !this._isGateLane ? MovementOrder.MovementOrderMove(this._wallSegment.MiddleFrame.Origin) : this._castleGateMoveOrder; this._facingOrder = FacingOrder.FacingOrderLookAtEnemy; }