Exemplo n.º 1
0
        public bool RestartPathing(SmartEntity troopEntity, out bool found, bool ignoreWall)
        {
            ShooterComponent   shooterComp = troopEntity.ShooterComp;
            IShooterVO         shooterVO   = shooterComp.ShooterVO;
            TroopComponent     troopComp   = troopEntity.TroopComp;
            TeamComponent      teamComp    = troopEntity.TeamComp;
            ITroopDeployableVO troopType   = troopComp.TroopType;
            uint            maxAttackRange = this.GetMaxAttackRange(troopEntity, shooterComp.Target);
            PathTroopParams troopParams    = new PathTroopParams
            {
                TroopWidth            = troopEntity.SizeComp.Width,
                DPS                   = shooterVO.DPS,
                MinRange              = shooterVO.MinAttackRange,
                MaxRange              = maxAttackRange,
                MaxSpeed              = troopComp.SpeedVO.MaxSpeed,
                PathSearchWidth       = troopType.PathSearchWidth,
                IsMelee               = shooterComp.IsMelee,
                IsOverWall            = shooterVO.OverWalls,
                IsHealer              = troopType.IsHealer,
                SupportRange          = troopType.SupportFollowDistance,
                ProjectileType        = shooterVO.ProjectileType,
                CrushesWalls          = troopType.CrushesWalls,
                IsTargetShield        = GameUtils.IsEntityShieldGenerator(troopEntity.ShooterComp.Target),
                TargetInRangeModifier = troopType.TargetInRangeModifier
            };
            PathBoardParams boardParams = new PathBoardParams
            {
                IgnoreWall   = (teamComp.IsDefender() || ignoreWall),
                Destructible = teamComp.CanDestructBuildings()
            };

            return(this.StartPathing(troopEntity, shooterComp.Target, troopEntity.TransformComp, true, out found, -1, troopParams, boardParams, true, false));
        }
Exemplo n.º 2
0
        private void SpawnInfantry(ContractEventData contractData)
        {
            SmartEntity smartEntity = this.FindIdleStarport(contractData);

            if (smartEntity == null)
            {
                return;
            }
            Entity             entity             = contractData.Entity;
            TransformComponent transformComponent = entity.Get <TransformComponent>();
            BoardCell          boardCell          = null;
            IntPosition        boardPosition      = new IntPosition(transformComponent.X, transformComponent.Z);
            TroopTypeVO        troopTypeVO        = this.sdc.Get <TroopTypeVO>(contractData.Contract.ProductUid);

            Service.TroopController.FinalizeSafeBoardPosition(troopTypeVO, ref entity, ref boardPosition, ref boardCell, TeamType.Defender, TroopSpawnMode.Unleashed, true);
            SmartEntity        smartEntity2  = Service.EntityFactory.CreateTroopEntity(troopTypeVO, TeamType.Defender, boardPosition, entity, TroopSpawnMode.Unleashed, false, true);
            BoardItemComponent boardItemComp = smartEntity2.BoardItemComp;

            Service.BoardController.Board.AddChild(boardItemComp.BoardItem, boardCell.X, boardCell.Z, null, false);
            Service.EntityController.AddEntity(smartEntity2);
            TroopComponent troopComp      = smartEntity2.TroopComp;
            TeamComponent  teamComp       = smartEntity2.TeamComp;
            bool           flag           = false;
            PathingManager pathingManager = Service.PathingManager;

            pathingManager.StartPathing(smartEntity2, smartEntity, smartEntity2.TransformComp, false, out flag, 0, new PathTroopParams
            {
                TroopWidth            = smartEntity2.SizeComp.Width,
                DPS                   = 0,
                MinRange              = 0u,
                MaxRange              = 2u,
                MaxSpeed              = troopComp.SpeedVO.MaxSpeed,
                PathSearchWidth       = troopComp.TroopType.PathSearchWidth,
                IsMelee               = true,
                IsOverWall            = false,
                IsHealer              = false,
                CrushesWalls          = false,
                IsTargetShield        = false,
                TargetInRangeModifier = troopComp.TroopType.TargetInRangeModifier
            }, new PathBoardParams
            {
                IgnoreWall   = teamComp != null && teamComp.IsDefender(),
                Destructible = false
            }, false, true);
            if (!flag)
            {
                pathingManager.StartPathing(smartEntity2, smartEntity, smartEntity2.TransformComp, false, out flag, 0, new PathTroopParams
                {
                    TroopWidth            = smartEntity2.SizeComp.Width,
                    DPS                   = 0,
                    MinRange              = 0u,
                    MaxRange              = 2u,
                    MaxSpeed              = troopComp.SpeedVO.MaxSpeed,
                    PathSearchWidth       = troopComp.TroopType.PathSearchWidth,
                    IsMelee               = true,
                    IsOverWall            = false,
                    IsHealer              = false,
                    CrushesWalls          = false,
                    IsTargetShield        = false,
                    TargetInRangeModifier = troopComp.TroopType.TargetInRangeModifier
                }, new PathBoardParams
                {
                    IgnoreWall   = true,
                    Destructible = false
                }, false, true);
            }
            smartEntity2.StateComp.CurState = EntityState.Moving;
            bool showFullEffect = true;

            if (this.numTroopEffectsByStarport == null)
            {
                this.numTroopEffectsByStarport = new Dictionary <Entity, int>();
            }
            if (this.numTroopEffectsByStarport.ContainsKey(smartEntity))
            {
                Dictionary <Entity, int> dictionary;
                SmartEntity key;
                int         num;
                (dictionary = this.numTroopEffectsByStarport)[key = smartEntity] = (num = dictionary[key]) + 1;
                if (num >= 10)
                {
                    showFullEffect = false;
                }
            }
            else
            {
                this.numTroopEffectsByStarport.Add(smartEntity, 1);
            }
            if (this.troopEffectsByEntity == null)
            {
                this.troopEffectsByEntity = new Dictionary <Entity, TransportTroopEffect>();
            }
            this.troopEffectsByEntity.Add(smartEntity2, new TransportTroopEffect(smartEntity2, troopTypeVO, smartEntity, this.entityFader, new TransportTroopEffect.OnEffectFinished(this.OnTroopEffectFinished), showFullEffect));
        }
Exemplo n.º 3
0
        private bool UpdateNode(SmartEntity entity, TargetingController.OnTargetingDone onTroopTargetingDone, bool updateWallBreakingTroops)
        {
            if (entity.StateComp.CurState == EntityState.Disable)
            {
                return(false);
            }
            bool flag = false;

            if (updateWallBreakingTroops)
            {
                return(this.UpdateWallBreakingTroops(entity, onTroopTargetingDone));
            }
            if (!GameUtils.IsEligibleToFindTarget(entity.ShooterComp))
            {
                return(false);
            }
            ShooterComponent shooterComp = entity.ShooterComp;

            if (!shooterComp.Searching && !shooterComp.ReevaluateTarget)
            {
                return(false);
            }
            bool flag2;

            if (shooterComp.Searching)
            {
                if (shooterComp.TargetingDelayAmount > 0)
                {
                    ShooterComponent expr_5B = shooterComp;
                    int targetingDelayAmount = expr_5B.TargetingDelayAmount;
                    expr_5B.TargetingDelayAmount = targetingDelayAmount - 1;
                    return(false);
                }
                flag2 = this.FindTargetForTroopNode(entity, false);
            }
            else
            {
                flag2 = this.FindTargetForTroopNode(entity, true);
            }
            shooterComp.ReevaluateTarget = false;
            if (!flag2)
            {
                return(false);
            }
            if (!shooterComp.Searching)
            {
                shooterComp.AttackFSM.StopAttacking(true);
            }
            SmartEntity primaryTarget = this.shooterController.GetPrimaryTarget(entity.ShooterComp);

            if (primaryTarget.TransformComp == null)
            {
                return(false);
            }
            flag = false;
            TroopComponent     troopComp   = entity.TroopComp;
            TeamComponent      teamComp    = entity.TeamComp;
            ITroopDeployableVO troopType   = troopComp.TroopType;
            IShooterVO         shooterVO   = shooterComp.ShooterVO;
            uint            maxAttackRange = this.pathingManager.GetMaxAttackRange(entity, primaryTarget);
            PathTroopParams troopParams    = new PathTroopParams
            {
                TroopWidth            = entity.SizeComp.Width,
                DPS                   = shooterVO.DPS,
                MinRange              = shooterVO.MinAttackRange,
                MaxRange              = maxAttackRange,
                MaxSpeed              = troopComp.SpeedVO.MaxSpeed,
                PathSearchWidth       = troopType.PathSearchWidth,
                IsMelee               = shooterComp.IsMelee,
                IsOverWall            = shooterComp.ShooterVO.OverWalls,
                IsHealer              = troopType.IsHealer,
                SupportRange          = troopType.SupportFollowDistance,
                CrushesWalls          = troopType.CrushesWalls,
                ProjectileType        = shooterVO.ProjectileType,
                IsTargetShield        = GameUtils.IsEntityShieldGenerator(primaryTarget),
                TargetInRangeModifier = troopType.TargetInRangeModifier
            };
            PathBoardParams boardParams = new PathBoardParams
            {
                IgnoreWall   = (teamComp != null && teamComp.IsDefender()),
                Destructible = entity.TeamComp.CanDestructBuildings()
            };
            bool flag3 = this.pathingManager.StartPathing(entity, primaryTarget, entity.TransformComp, true, out flag, -1, troopParams, boardParams, false, false);

            if (!flag3)
            {
                onTroopTargetingDone(entity);
                this.shooterController.StopSearch(shooterComp);
                return(true);
            }
            if (!flag)
            {
                GameUtils.UpdateMinimumFrameCountForNextTargeting(shooterComp);
                return(false);
            }
            this.RandomizeTargetingDelay(shooterComp);
            onTroopTargetingDone(entity);
            this.shooterController.StopSearch(shooterComp);
            this.OnPathingComplete(entity, entity.SecondaryTargetsComp, entity.StateComp, shooterComp, primaryTarget);
            return(true);
        }