public BehaviorUseMurderHole(Formation formation)
            : base(formation)
        {
            this.behaviorSide = formation.AI.Side;
            WorldPosition position = new WorldPosition(Mission.Current.Scene, UIntPtr.Zero, (formation.Team.TeamAI as TeamAISiegeDefender).MurderHolePosition, false);

            this._outerGate        = (formation.Team.TeamAI as TeamAISiegeDefender).OuterGate;
            this._innerGate        = (formation.Team.TeamAI as TeamAISiegeDefender).InnerGate;
            this._batteringRam     = Mission.Current.ActiveMissionObjects.FindAllWithType <BatteringRam>().FirstOrDefault <BatteringRam>();
            this.CurrentOrder      = MovementOrder.MovementOrderMove(position);
            this.BehaviorCoherence = 0.0f;
        }
 protected internal override void TickOccasionally()
 {
     this._behaviourState = this.CheckAndChangeState();
     this.CalculateCurrentOrder();
     foreach (IPrimarySiegeWeapon primarySiegeWeapon in this._primarySiegeWeapons)
     {
         UsableMachine usable = primarySiegeWeapon as UsableMachine;
         if (!usable.IsDeactivated && !primarySiegeWeapon.HasCompletedAction() && !this.formation.IsUsingMachine(usable))
         {
             this.formation.StartUsingMachine(primarySiegeWeapon as UsableMachine);
         }
     }
     if (this._behaviourState == BehaviorAssaultWalls.BehaviorState.MoveToGate)
     {
         CastleGate innerGate = this._teamAISiegeComponent.InnerGate;
         if (innerGate != null && !innerGate.IsGateOpen && !innerGate.IsDestroyed)
         {
             if (!this.formation.IsUsingMachine((UsableMachine)innerGate))
             {
                 this.formation.StartUsingMachine((UsableMachine)innerGate);
             }
         }
         else
         {
             CastleGate outerGate = this._teamAISiegeComponent.OuterGate;
             if (outerGate != null && !outerGate.IsGateOpen && (!outerGate.IsDestroyed && !this.formation.IsUsingMachine((UsableMachine)outerGate)))
             {
                 this.formation.StartUsingMachine((UsableMachine)outerGate);
             }
         }
     }
     else
     {
         if (this.formation.Detachments.Contains((IDetachment)this._teamAISiegeComponent.OuterGate))
         {
             this.formation.StopUsingMachine((UsableMachine)this._teamAISiegeComponent.OuterGate);
         }
         if (this.formation.Detachments.Contains((IDetachment)this._teamAISiegeComponent.InnerGate))
         {
             this.formation.StopUsingMachine((UsableMachine)this._teamAISiegeComponent.InnerGate);
         }
     }
     this.formation.MovementOrder    = this.CurrentOrder;
     this.formation.FacingOrder      = this.CurrentFacingOrder;
     this.formation.ArrangementOrder = this.CurrentArrangementOrder;
 }
Example #3
0
        protected internal override void TickOccasionally()
        {
            base.TickOccasionally();
            this.CalculateCurrentOrder();
            this.formation.MovementOrder = this.CurrentOrder;
            if (this._calculateAreGatesOutsideOpen)
            {
                return;
            }
            CastleGate castleGate = this._teamAISiegeDefender.InnerGate == null || this._teamAISiegeDefender.InnerGate.IsGateOpen ? this._teamAISiegeDefender.OuterGate : this._teamAISiegeDefender.InnerGate;

            if (this.formation.IsUsingMachine((UsableMachine)castleGate))
            {
                return;
            }
            this.formation.StartUsingMachine((UsableMachine)castleGate);
        }
        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;
        }
Example #5
0
        private void ResetOrderPositions()
        {
            this.behaviorSide = this.formation.AI.Side;
            this._innerGate   = (CastleGate)null;
            this._outerGate   = (CastleGate)null;
            this._laddersOnThisSide.Clear();
            int num1 = Mission.Current.ActiveMissionObjects.FindAllWithType <CastleGate>().Any <CastleGate>((Func <CastleGate, bool>)(cg => cg.DefenseSide == this.behaviorSide && cg.GameEntity.HasTag("outer_gate"))) ? 1 : 0;

            this._isDefendingWideGap = false;
            WorldFrame worldFrame1;
            WorldFrame worldFrame2;

            if (num1 != 0)
            {
                CastleGate outerGate = this._teamAISiegeDefender.OuterGate;
                this._innerGate          = this._teamAISiegeDefender.InnerGate;
                this._outerGate          = this._teamAISiegeDefender.OuterGate;
                worldFrame1              = outerGate.MiddleFrame;
                worldFrame2              = outerGate.DefenseWaitFrame;
                this._tacticalMiddlePos  = outerGate.MiddlePosition;
                this._tacticalWaitPos    = outerGate.WaitPosition;
                this._isDefendingWideGap = false;
            }
            else
            {
                WallSegment wallSegment = Mission.Current.ActiveMissionObjects.FindAllWithType <WallSegment>().Where <WallSegment>((Func <WallSegment, bool>)(ws => ws.DefenseSide == this.behaviorSide && ws.IsBreachedWall)).FirstOrDefault <WallSegment>();
                if (wallSegment != null)
                {
                    worldFrame1              = wallSegment.MiddleFrame;
                    worldFrame2              = wallSegment.DefenseWaitFrame;
                    this._tacticalMiddlePos  = wallSegment.MiddlePosition;
                    this._tacticalWaitPos    = wallSegment.WaitPosition;
                    this._isDefendingWideGap = false;
                }
                else
                {
                    IEnumerable <SiegeWeapon> source = Mission.Current.ActiveMissionObjects.FindAllWithType <SiegeWeapon>().Where <SiegeWeapon>((Func <SiegeWeapon, bool>)(sw =>
                    {
                        if (!(sw is IPrimarySiegeWeapon) || (sw as IPrimarySiegeWeapon).WeaponSide != this.behaviorSide)
                        {
                            return(false);
                        }
                        return(!sw.IsDestroyed || (sw as IPrimarySiegeWeapon).HasCompletedAction());
                    }));
                    if (!source.Any <SiegeWeapon>())
                    {
                        worldFrame1             = WorldFrame.Invalid;
                        worldFrame2             = WorldFrame.Invalid;
                        this._tacticalMiddlePos = (TacticalPosition)null;
                        this._tacticalWaitPos   = (TacticalPosition)null;
                    }
                    else
                    {
                        this._laddersOnThisSide = source.Where <SiegeWeapon>((Func <SiegeWeapon, bool>)(aw => aw is SiegeLadder)).Select <SiegeWeapon, SiegeLadder>((Func <SiegeWeapon, SiegeLadder>)(aw => aw as SiegeLadder)).ToList <SiegeLadder>();
                        ICastleKeyPosition targetCastlePosition = (source.FirstOrDefault <SiegeWeapon>() as IPrimarySiegeWeapon).TargetCastlePosition as ICastleKeyPosition;
                        worldFrame1             = targetCastlePosition.MiddleFrame;
                        worldFrame2             = targetCastlePosition.DefenseWaitFrame;
                        this._tacticalMiddlePos = targetCastlePosition.MiddlePosition;
                        this._tacticalWaitPos   = targetCastlePosition.WaitPosition;
                    }
                }
            }
            if (this._tacticalMiddlePos != null)
            {
                this._readyOrder       = MovementOrder.MovementOrderMove(this._tacticalMiddlePos.Position);
                this._readyFacingOrder = FacingOrder.FacingOrderLookAtDirection(this._tacticalMiddlePos.Direction);
            }
            else if (worldFrame1.Origin.IsValid)
            {
                double num2 = (double)worldFrame1.Rotation.f.Normalize();
                this._readyOrder       = MovementOrder.MovementOrderMove(worldFrame1.Origin);
                this._readyFacingOrder = FacingOrder.FacingOrderLookAtDirection(worldFrame1.Rotation.f.AsVec2);
            }
            else
            {
                this._readyOrder       = MovementOrder.MovementOrderStop;
                this._readyFacingOrder = FacingOrder.FacingOrderLookAtEnemy;
            }
            if (this._tacticalWaitPos != null)
            {
                this._waitOrder       = MovementOrder.MovementOrderMove(this._tacticalWaitPos.Position);
                this._waitFacingOrder = FacingOrder.FacingOrderLookAtDirection(this._tacticalWaitPos.Direction);
            }
            else if (worldFrame2.Origin.IsValid)
            {
                double num2 = (double)worldFrame2.Rotation.f.Normalize();
                this._waitOrder       = MovementOrder.MovementOrderMove(worldFrame2.Origin);
                this._waitFacingOrder = FacingOrder.FacingOrderLookAtDirection(worldFrame2.Rotation.f.AsVec2);
            }
            else
            {
                this._waitOrder       = MovementOrder.MovementOrderStop;
                this._waitFacingOrder = FacingOrder.FacingOrderLookAtEnemy;
            }
            this.CurrentOrder       = this._behaviourState == BehaviorDefendCastleKeyPosition.BehaviourState.Ready ? this._readyOrder : this._waitOrder;
            this.CurrentFacingOrder = this.formation.QuerySystem.ClosestEnemyFormation == null || !TeamAISiegeComponent.IsFormationInsideCastle(this.formation.QuerySystem.ClosestEnemyFormation.Formation, true) ? (this._behaviourState == BehaviorDefendCastleKeyPosition.BehaviourState.Ready ? this._readyFacingOrder : this._waitFacingOrder) : FacingOrder.FacingOrderLookAtEnemy;
        }