Exemplo n.º 1
0
        private bool WillCrushNearTarget(SmartEntity troop, SmartEntity target)
        {
            if (!TroopController.CanEntityCrushWalls(troop))
            {
                return(false);
            }
            BuildingComponent buildingComp = target.BuildingComp;

            return(buildingComp != null && buildingComp.BuildingType.Type == BuildingType.Wall);
        }
Exemplo n.º 2
0
        private void TroopWandering(SmartEntity entity)
        {
            BoardController   boardController = Service.BoardController;
            DefenderComponent defenderComp    = entity.DefenderComp;

            if (defenderComp == null || defenderComp.Patrolling)
            {
                return;
            }
            TransformComponent transformComp = entity.TransformComp;

            if (transformComp == null)
            {
                return;
            }
            defenderComp.Patrolling = true;
            int       x         = transformComp.X;
            int       z         = transformComp.Z;
            BoardCell cellAt    = boardController.Board.GetCellAt(x, z);
            int       num       = defenderComp.PatrolLoc;
            int       num2      = (defenderComp.SpawnBuilding != null) ? 4 : 8;
            int       viewRange = (int)entity.ShooterComp.ShooterVO.ViewRange;

            for (int i = 0; i < num2; i++)
            {
                BoardCell boardCell;
                if (defenderComp.SpawnBuilding == null)
                {
                    num = (num + 1) % num2;
                    int x2 = defenderComp.SpawnX + viewRange * TargetingController.x_mul[num] / TargetingController.x_div[num] / 2;
                    int z2 = defenderComp.SpawnZ + viewRange * TargetingController.z_mul[num] / TargetingController.z_div[num] / 2;
                    boardCell = boardController.Board.GetClampedToBoardCellAt(x2, z2, entity.SizeComp.Width);
                }
                else
                {
                    boardCell = defenderComp.SpawnBuilding.FindNextPatrolPoint(entity.SizeComp.Width, ref num);
                }
                if (boardCell.IsWalkable())
                {
                    if (Service.PathingManager.StartPathingWorkerOrPatrol(entity, null, cellAt, boardCell, entity.SizeComp.Width, entity.TroopComp != null && TroopController.CanEntityCrushWalls(entity)))
                    {
                        Service.ShooterController.StartMoving(entity);
                        defenderComp.PatrolLoc = num;
                        Service.ShooterController.StopSearch(entity.ShooterComp);
                        return;
                    }
                }
            }
            entity.StateComp.CurState = EntityState.Idle;
        }
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)
                {
                    shooterComp.TargetingDelayAmount--;
                    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;
            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              = TroopController.IsEntityHealer(entity),
                SupportRange          = troopType.SupportFollowDistance,
                CrushesWalls          = TroopController.CanEntityCrushWalls(entity),
                ProjectileType        = shooterVO.ProjectileType,
                IsTargetShield        = GameUtils.IsEntityShieldGenerator(primaryTarget),
                TargetInRangeModifier = troopType.TargetInRangeModifier
            };
            PathBoardParams boardParams = new PathBoardParams
            {
                IgnoreWall   = TroopController.CanEntityIgnoreWalls(entity),
                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);
        }