Example #1
0
        private void AddTurretTarget(ShooterComponent shooterComp, TurretShooterComponent turretShooterComp, SmartEntity target, int nearness, HashSet <ShooterComponent> resetReevaluateTargetSet)
        {
            if (!shooterComp.Searching && !shooterComp.ReevaluateTarget)
            {
                return;
            }
            if (shooterComp.ReevaluateTarget)
            {
                resetReevaluateTargetSet.Add(shooterComp);
            }
            TroopComponent troopComp = target.TroopComp;

            if (shooterComp.ShooterVO.Preference[(int)troopComp.TroopType.ArmorType] <= 0)
            {
                return;
            }
            int    num          = this.CalculateWeight(shooterComp, null, troopComp.TroopType.ArmorType, nearness);
            Entity turretTarget = this.shooterController.GetTurretTarget(shooterComp);

            if (turretTarget == null || num > turretShooterComp.TargetWeight)
            {
                turretShooterComp.TargetWeight = num;
                if (shooterComp.ReevaluateTarget && shooterComp.Target != target)
                {
                    shooterComp.AttackFSM.StopAttacking(false);
                }
                shooterComp.Target = target;
            }
        }
        private void HandleChampionDeployedEvent(object cookie)
        {
            SmartEntity    smartEntity = (SmartEntity)cookie;
            TroopComponent troopComp   = smartEntity.TroopComp;

            if (troopComp == null)
            {
                return;
            }
            TransformComponent transformComp = smartEntity.TransformComp;

            if (transformComp == null)
            {
                return;
            }
            ChampionDeployedAction championDeployedAction = new ChampionDeployedAction();

            championDeployedAction.Time     = this.GetActionTime();
            championDeployedAction.TroopUid = troopComp.TroopType.Uid;
            championDeployedAction.BoardX   = transformComp.CenterGridX();
            championDeployedAction.BoardZ   = transformComp.CenterGridZ();
            TeamComponent teamComp = smartEntity.TeamComp;

            championDeployedAction.TeamType = teamComp.TeamType;
            this.battleRecord.Add(championDeployedAction);
        }
Example #3
0
        private bool CheckTarget(SmartEntity shooter, SmartEntity target, ref int maxWeight)
        {
            if (shooter == null || target == null)
            {
                return(false);
            }
            TransformComponent transformComp = target.TransformComp;
            TroopComponent     troopComp     = target.TroopComp;

            if (transformComp == null || troopComp == null)
            {
                return(false);
            }
            ShooterComponent shooterComp = shooter.ShooterComp;

            if ((long)GameUtils.GetSquaredDistanceToTarget(shooterComp, target) < (long)((ulong)shooterComp.MinAttackRangeSquared))
            {
                return(false);
            }
            TransformComponent transformComp2 = shooter.TransformComp;
            int squaredDistance = GameUtils.SquaredDistance(transformComp2.CenterGridX(), transformComp2.CenterGridZ(), transformComp.CenterGridX(), transformComp.CenterGridZ());
            int targetNearness  = this.spatialIndexController.CalcNearness(squaredDistance);
            int num             = this.CalculateWeight(shooterComp, null, troopComp.TroopType.ArmorType, targetNearness);

            if (num > maxWeight)
            {
                maxWeight = num;
                return(true);
            }
            return(false);
        }
Example #4
0
        private bool IsTroopValid(TroopComponent component)
        {
            if (component.Entity.Get <TeamComponent>().TeamType != this.teamMatchType)
            {
                return(false);
            }
            if (this.any)
            {
                return(true);
            }
            ITroopDeployableVO troopType = component.TroopType;

            if (troopType.Lvl >= this.level)
            {
                switch (this.matchType)
                {
                case ConditionMatchType.Uid:
                    return(troopType.Uid == this.unitMatchId);

                case ConditionMatchType.Id:
                    return(troopType.UpgradeGroup == this.unitMatchId);

                case ConditionMatchType.Type:
                    return(troopType.Type == StringUtils.ParseEnum <TroopType>(this.unitMatchId));
                }
            }
            return(false);
        }
        public void HandleTroopDeployedEvent(object cookie)
        {
            SmartEntity    smartEntity = (SmartEntity)cookie;
            TroopComponent troopComp   = smartEntity.TroopComp;

            if (troopComp == null)
            {
                return;
            }
            TransformComponent transformComp = smartEntity.TransformComp;

            if (transformComp == null)
            {
                return;
            }
            TroopPlacedAction troopPlacedAction = new TroopPlacedAction();

            troopPlacedAction.Time    = this.GetActionTime();
            troopPlacedAction.TroopId = troopComp.TroopType.Uid;
            troopPlacedAction.BoardX  = transformComp.CenterGridX();
            troopPlacedAction.BoardZ  = transformComp.CenterGridZ();
            TeamComponent teamComp = smartEntity.TeamComp;

            troopPlacedAction.TeamType = teamComp.TeamType;
            this.battleRecord.Add(troopPlacedAction);
        }
Example #6
0
        public bool IsHealable(SmartEntity target, object self)
        {
            if (target == null)
            {
                return(false);
            }
            SmartEntity smartEntity = (SmartEntity)self;

            if (target == smartEntity)
            {
                return(false);
            }
            TroopComponent  troopComp  = target.TroopComp;
            HealthComponent healthComp = target.HealthComp;
            TeamComponent   teamComp   = target.TeamComp;

            if (troopComp == null || healthComp == null || teamComp == null)
            {
                return(false);
            }
            if (target.TeamComp.TeamType != smartEntity.TeamComp.TeamType)
            {
                return(false);
            }
            if (troopComp.TroopType.IsHealer)
            {
                return(false);
            }
            TroopComponent troopComp2 = smartEntity.TroopComp;

            return(troopComp2 == null || !troopComp2.TroopType.IsHealer || this.CanBeHealed(target, smartEntity));
        }
Example #7
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));
        }
Example #8
0
        public void ReevaluateTarget(ShooterComponent shooterComp)
        {
            shooterComp.ReevaluateTarget = true;
            SmartEntity smartEntity = (SmartEntity)shooterComp.Entity;

            if (smartEntity.TurretShooterComp != null)
            {
                SmartEntity target       = shooterComp.Target;
                int         targetWeight = -1;
                if (target != null && !GameUtils.IsEntityDead(target))
                {
                    List <EntityElementPriorityPair> turretsInRangeOf = this.spatialIndexController.GetTurretsInRangeOf(target.TransformComp.CenterGridX(), target.TransformComp.CenterGridZ());
                    int i     = 0;
                    int count = turretsInRangeOf.Count;
                    while (i < count)
                    {
                        EntityElementPriorityPair entityElementPriorityPair = turretsInRangeOf[i];
                        if (smartEntity == entityElementPriorityPair.Element)
                        {
                            TroopComponent troopComp = target.TroopComp;
                            targetWeight = this.CalculateWeight(shooterComp, null, troopComp.TroopType.ArmorType, entityElementPriorityPair.Priority);
                            break;
                        }
                        i++;
                    }
                }
                smartEntity.TurretShooterComp.TargetWeight = targetWeight;
            }
        }
Example #9
0
        private void OnTargetingDone(SmartEntity entity)
        {
            TroopComponent troopComp = entity.ShooterComp.Target.TroopComp;

            if (troopComp != null)
            {
                troopComp.TargetCount++;
            }
        }
Example #10
0
        private bool ShouldSeekAlternativeTarget(SmartEntity troopEntity)
        {
            TroopComponent troopComp = troopEntity.TroopComp;

            if (troopComp == null)
            {
                Service.Get <StaRTSLogger>().Error("Non troop entity checking for alternative target in TargetingSystem");
                return(false);
            }
            return(troopEntity.DefenderComp == null && !troopComp.TroopType.IsHealer);
        }
Example #11
0
        private void OnTargetingDone(SmartEntity entity)
        {
            TroopComponent troopComp = entity.ShooterComp.Target.TroopComp;

            if (troopComp != null)
            {
                TroopComponent expr_15     = troopComp;
                int            targetCount = expr_15.TargetCount;
                expr_15.TargetCount = targetCount + 1;
            }
        }
Example #12
0
        public bool CanBeHealed(SmartEntity target, SmartEntity healer)
        {
            if (target == null || healer == null)
            {
                return(false);
            }
            TroopComponent   troopComp   = target.TroopComp;
            ShooterComponent shooterComp = healer.ShooterComp;

            return(troopComp != null && shooterComp != null && shooterComp.ShooterVO.Preference[(int)troopComp.TroopType.ArmorType] > 0);
        }
Example #13
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.EntityKilled)
     {
         Entity         entity         = (Entity)cookie;
         TroopComponent troopComponent = entity.Get <TroopComponent>();
         if (troopComponent != null && this.IsTroopValid(troopComponent))
         {
             this.unitsKilled++;
             this.EvaluateAmount();
         }
     }
     return(EatResponse.NotEaten);
 }
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.TroopPlacedOnBoard && base.IsEventValidForBattleObjective())
     {
         SmartEntity    smartEntity    = (SmartEntity)cookie;
         TroopComponent troopComponent = smartEntity.Get <TroopComponent>();
         TeamComponent  teamComponent  = smartEntity.Get <TeamComponent>();
         if (teamComponent != null && teamComponent.TeamType == TeamType.Attacker && troopComponent != null && troopComponent.TroopType.TroopID == this.troopId)
         {
             this.parent.Progress(this, 1);
         }
     }
     return(EatResponse.NotEaten);
 }
Example #15
0
        private void AddEntityToRecheckVisualAfterLoadList(SmartEntity entity, Buff buff)
        {
            BuildingComponent buildingComp = entity.BuildingComp;
            TroopComponent    troopComp    = entity.TroopComp;
            BuffComponent     buffComp     = entity.BuffComp;

            if (buildingComp != null)
            {
                buffComp.RegisterForVisualReAddOnBuilding(buff);
            }
            else if (troopComp != null)
            {
                buffComp.RegisterForVisualReAddOnTroop(buff);
            }
        }
        public bool ActivateAbility(uint entityID)
        {
            if (!this.deployedTroops.ContainsKey(entityID))
            {
                return(false);
            }
            DeployedTroop deployedTroop = this.deployedTroops[entityID];
            SmartEntity   entity        = deployedTroop.Entity;

            if (entity.StateComp.CurState == EntityState.Dying)
            {
                return(false);
            }
            TroopComponent troopComp = entity.TroopComp;
            TroopAbilityVO abilityVO = troopComp.AbilityVO;

            if (abilityVO == null || (abilityVO.ClipCount == 0 && abilityVO.Duration == 0u))
            {
                return(false);
            }
            deployedTroop.Activated = true;
            troopComp.SetVOData(abilityVO, abilityVO);
            troopComp.IsAbilityModeActive     = true;
            troopComp.UpdateWallAttackerTroop = false;
            ShooterComponent shooterComp = entity.ShooterComp;

            if (shooterComp != null)
            {
                shooterComp.SetVOData(abilityVO);
            }
            this.ResetTargetAndSendEvent(entity, true);
            if (!deployedTroop.EffectsSetup)
            {
                this.SetupAbilityViewEffects(deployedTroop, abilityVO);
                deployedTroop.EffectsSetup = true;
            }
            this.ActivateAbilityViewEffects(deployedTroop, abilityVO);
            if (abilityVO.ClipCount > 0)
            {
                this.StartTrackingShooterClips(deployedTroop, abilityVO.ClipCount);
            }
            else
            {
                deployedTroop.AbilityTimer = Service.Get <SimTimerManager>().CreateSimTimer(abilityVO.Duration, false, new TimerDelegate(this.OnAbilityTimer), deployedTroop);
            }
            return(true);
        }
Example #17
0
        private void AddHealthRegenerationWarBuff(SmartEntity entity, WarBuffVO warBuffVO)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            TroopComponent       troopComp            = entity.TroopComp;
            bool       flag     = false;
            BuffTypeVO buffType = null;

            if (troopComp != null)
            {
                buffType = staticDataController.Get <BuffTypeVO>(warBuffVO.TroopBuffUid);
                flag     = (troopComp.TroopType.Type == TroopType.Infantry);
            }
            if (flag)
            {
                this.TryAddBuffStack(entity, buffType, ArmorType.Infantry, BuffVisualPriority.SquadWars, entity);
            }
        }
Example #18
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id == EventId.TroopPlacedOnBoard)
     {
         if (this.IsEventValidForGoal())
         {
             SmartEntity    smartEntity    = (SmartEntity)cookie;
             TroopComponent troopComponent = smartEntity.Get <TroopComponent>();
             TeamComponent  teamComponent  = smartEntity.Get <TeamComponent>();
             SpawnComponent spawnComponent = smartEntity.Get <SpawnComponent>();
             if (teamComponent != null && teamComponent.TeamType == TeamType.Attacker && troopComponent != null && troopComponent.TroopType.TroopID == this.troopId && (spawnComponent == null || !spawnComponent.IsSummoned()))
             {
                 this.parent.Progress(this, 1);
             }
         }
     }
     return(EatResponse.NotEaten);
 }
Example #19
0
        private void AddVehicleDamageBuff(SmartEntity entity, WarBuffVO warBuffVO)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            TroopComponent       troopComp            = entity.TroopComp;
            bool       flag     = false;
            BuffTypeVO buffType = null;

            if (troopComp != null)
            {
                buffType = staticDataController.Get <BuffTypeVO>(warBuffVO.TroopBuffUid);
                TroopTypeVO troopTypeVO = (TroopTypeVO)troopComp.TroopType;
                flag = (troopTypeVO.Type == TroopType.Vehicle);
            }
            if (flag)
            {
                this.TryAddBuffStack(entity, buffType, ArmorType.Vehicle, BuffVisualPriority.SquadWars, entity);
            }
        }
Example #20
0
        private void AddInfantryDamageBuff(SmartEntity entity, WarBuffVO warBuffVO)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            TroopComponent       troopComp            = entity.TroopComp;
            BuffTypeVO           buffTypeVO           = null;

            if (troopComp != null)
            {
                TroopTypeVO troopTypeVO = (TroopTypeVO)troopComp.TroopType;
                if (troopTypeVO.Type == TroopType.Infantry)
                {
                    buffTypeVO = staticDataController.Get <BuffTypeVO>(warBuffVO.TroopBuffUid);
                }
            }
            if (buffTypeVO != null)
            {
                this.TryAddBuffStack(entity, buffTypeVO, ArmorType.Infantry, BuffVisualPriority.SquadWars, entity);
            }
        }
        private void DeactivateAbility(DeployedTroop deployedTroop)
        {
            if (deployedTroop == null)
            {
                Service.Get <StaRTSLogger>().Error("TroopAbilityConroller.DeactivateAbility: DeployedTroop Null");
                return;
            }
            deployedTroop.AbilityTimer = 0u;
            SmartEntity entity = deployedTroop.Entity;

            if (entity == null)
            {
                Service.Get <StaRTSLogger>().Error("TroopAbilityConroller.DeactivateAbility: SmartEntity troop = Null");
                return;
            }
            TroopComponent troopComp = entity.TroopComp;

            if (troopComp == null)
            {
                Service.Get <StaRTSLogger>().Error("TroopAbilityConroller.DeactivateAbility: troopComp = Null");
                return;
            }
            troopComp.SetVOData(troopComp.OriginalTroopShooterVO, troopComp.OriginalSpeedVO);
            troopComp.IsAbilityModeActive = false;
            ShooterComponent shooterComp = entity.ShooterComp;

            if (shooterComp != null)
            {
                shooterComp.SetVOData(shooterComp.OriginalShooterVO);
            }
            TroopAbilityVO abilityVO = troopComp.AbilityVO;

            if (abilityVO == null)
            {
                Service.Get <StaRTSLogger>().Error("TroopAbilityConroller.DeactivateAbility: TroopAbilityVO abilityVO = Null");
                return;
            }
            this.ResetTargetAndSendEvent(entity, false);
            this.DeactivateAbilityViewEffects(deployedTroop);
            this.StopTrackingShooterClips(deployedTroop);
            deployedTroop.Activated = false;
            this.StartCoolDown(deployedTroop, abilityVO);
        }
Example #22
0
        private void ProcessGameObject(object asset, object cookie, bool isMissingAsset)
        {
            GameObject         gameObject       = asset as GameObject;
            EntityViewParams   entityViewParams = cookie as EntityViewParams;
            SmartEntity        entity           = entityViewParams.Entity;
            BuildingComponent  buildingComp     = entity.BuildingComp;
            TroopComponent     troopComp        = entity.TroopComp;
            TransportComponent transportComp    = entity.TransportComp;
            DroidComponent     droidComp        = entity.DroidComp;
            bool flag    = buildingComp != null;
            bool flag2   = troopComp != null;
            bool flag3   = transportComp != null;
            bool isDroid = droidComp != null;

            if (flag2)
            {
                gameObject.name = "Troop " + troopComp.TroopType.Uid + " #" + entity.ID.ToString();
            }
            else if (flag)
            {
                gameObject.name = "Building " + buildingComp.BuildingType.Uid + " #" + entity.ID.ToString();
            }
            else if (flag3)
            {
                gameObject.name                     = "Transport " + transportComp.TransportType.Uid + " #" + entity.ID.ToString();
                transportComp.GameObj               = gameObject;
                transportComp.ShadowGameObject      = gameObject.transform.Find("shadowMesh").gameObject;
                transportComp.ShadowMaterial        = UnityUtils.EnsureMaterialCopy(transportComp.ShadowGameObject.GetComponent <Renderer>());
                transportComp.ShadowMaterial.shader = Service.AssetManager.Shaders.GetShader("TransportShadow");
                return;
            }
            if (isMissingAsset)
            {
                gameObject.name += " MISSING";
            }
            bool createCollider = entityViewParams.CreateCollider;

            this.PrepareGameObject(entity, gameObject, createCollider);
            if (isMissingAsset || !this.LoadAddOns(entityViewParams))
            {
                this.SendAssetReadyEvent(flag, isMissingAsset, isDroid, entityViewParams);
            }
        }
Example #23
0
        protected bool IsTargetInRangeForAttack(SmartEntity troop, SmartEntity target, bool isLastTile)
        {
            if (target.ShieldBorderComp != null)
            {
                return(true);
            }
            if (this.WillCrushNearTarget(troop, target))
            {
                return(false);
            }
            if (isLastTile && GameUtils.IsEntityShieldGenerator(troop.ShooterComp.Target) && troop.ShooterComp.Target != target)
            {
                return(true);
            }
            ShooterComponent shooterComp = troop.ShooterComp;
            int            num           = GameUtils.GetSquaredDistanceToTarget(shooterComp, target);
            TroopComponent troopComp     = troop.TroopComp;
            uint           num2          = 0u;

            if (troopComp != null)
            {
                if (TroopController.IsEntityHealer(troop))
                {
                    num += (int)((shooterComp.MaxAttackRangeSquared - shooterComp.MinAttackRangeSquared) / 2u);
                }
                if (!shooterComp.IsMelee)
                {
                    num2 = Service.PathingManager.GetMaxAttackRange(troop, target);
                }
            }
            if (num2 != 0u)
            {
                if (!this.shooterController.InRange(num, shooterComp, num2))
                {
                    return(false);
                }
            }
            else if (!this.shooterController.InRange(num, shooterComp))
            {
                return(false);
            }
            return(true);
        }
Example #24
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            Entity entity = null;

            if (id != EventId.TroopAcquiredFirstTarget)
            {
                if (id == EventId.SpecialAttackDeployed)
                {
                    SpecialAttack specialAttack = cookie as SpecialAttack;
                    TargetReticle fromPool      = this.GetFromPool(true);
                    fromPool.SetWorldTarget((float)specialAttack.TargetBoardX + 0.5f, (float)specialAttack.TargetBoardZ + 0.5f, specialAttack.VO.ReticleScale, specialAttack.VO.ReticleScale);
                    Service.ViewTimerManager.CreateViewTimer(specialAttack.VO.ReticleDuration, false, new TimerDelegate(this.DeactivateTargetReticle), fromPool);
                }
            }
            else
            {
                Entity        entity2       = cookie as Entity;
                TeamComponent teamComponent = entity2.Get <TeamComponent>();
                if (teamComponent != null && teamComponent.TeamType != TeamType.Attacker)
                {
                    return(EatResponse.NotEaten);
                }
                TroopComponent troopComponent = entity2.Get <TroopComponent>();
                if (troopComponent != null && troopComponent.TroopShooterVO.TargetSelf)
                {
                    return(EatResponse.NotEaten);
                }
                ShooterComponent shooterComponent = entity2.Get <ShooterComponent>();
                if (shooterComponent != null)
                {
                    entity = Service.ShooterController.GetPrimaryTarget(shooterComponent);
                }
                if (entity == null)
                {
                    return(EatResponse.NotEaten);
                }
                TargetReticle fromPool2 = this.GetFromPool(true);
                fromPool2.SetTarget(entity);
                Service.ViewTimerManager.CreateViewTimer(1.5f, false, new TimerDelegate(this.DeactivateTargetReticle), fromPool2);
            }
            return(EatResponse.NotEaten);
        }
Example #25
0
        private void ResetAttackFSM(SmartEntity troopEntity)
        {
            StaRTS.Utils.Diagnostics.Logger logger = Service.Logger;
            StateComponent stateComp = troopEntity.StateComp;

            if (stateComp == null)
            {
                logger.Error("ResetAttackFSM StateComp is null");
                return;
            }
            stateComp.Reset();
            TroopComponent troopComp = troopEntity.TroopComp;

            if (troopComp == null)
            {
                logger.Error("ResetAttackFSM TroopComp is null");
                return;
            }
            if (troopComp.TroopType == null)
            {
                logger.Error("ResetAttackFSM TroopVO is null");
                return;
            }
            ShooterComponent shooterComp = troopEntity.ShooterComp;

            if (shooterComp == null)
            {
                logger.Error("ResetAttackFSM ShooterComp is null");
                return;
            }
            TroopRole troopRole = shooterComp.ShooterVO.TroopRole;

            if (troopRole == TroopRole.None)
            {
                troopRole = shooterComp.OriginalShooterVO.TroopRole;
            }
            HealthType healthType = (troopRole != TroopRole.Healer) ? HealthType.Damaging : HealthType.Healing;

            shooterComp.Reset();
            shooterComp.AttackFSM = new AttackFSM(Service.BattleController, troopEntity, troopEntity.StateComp, shooterComp, troopEntity.TransformComp, healthType);
        }
        private bool CanAutoActivateAbility(uint entityID)
        {
            bool result = false;

            if (this.deployedTroops.ContainsKey(entityID))
            {
                SmartEntity      entity      = this.deployedTroops[entityID].Entity;
                ShooterComponent shooterComp = entity.ShooterComp;
                if (shooterComp != null)
                {
                    TroopComponent troopComp      = entity.TroopComp;
                    TroopAbilityVO troopAbilityVO = null;
                    if (troopComp != null)
                    {
                        troopAbilityVO = troopComp.AbilityVO;
                    }
                    result = ((troopAbilityVO != null && troopAbilityVO.RecastAbility) || shooterComp.AttackFSM.CanSwitchAbility());
                }
            }
            return(result);
        }
Example #27
0
        public void AddToDeathLog(SmartEntity entity, uint time)
        {
            string uid = "unknown";

            if (entity != null)
            {
                BuildingComponent buildingComp = entity.BuildingComp;
                if (buildingComp != null)
                {
                    uid = buildingComp.BuildingType.Uid;
                }
                else
                {
                    TroopComponent troopComp = entity.TroopComp;
                    if (troopComp != null)
                    {
                        uid = troopComp.TroopType.Uid;
                    }
                }
            }
            this.InternalAddToDeathLog(uid, time);
        }
Example #28
0
        private void FireAShot(int spawnBoardX, int spawnBoardZ, Vector3 startPos, Target target, GameObject gunLocator)
        {
            FactionType faction = FactionType.Invalid;

            if (this.Entity != null)
            {
                BuildingComponent buildingComp = this.Entity.BuildingComp;
                TroopComponent    troopComp    = this.Entity.TroopComp;
                if (buildingComp != null)
                {
                    faction = buildingComp.BuildingType.Faction;
                }
                else if (troopComp != null)
                {
                    faction = troopComp.TroopType.Faction;
                }
            }
            HealthFragment payload = new HealthFragment(this.Entity, this.healthType, this.ShooterComp.ShooterVO.Damage);

            Service.Get <ProjectileController>().SpawnProjectileForTarget(0u, spawnBoardX, spawnBoardZ, startPos, target, payload, this.ownerTeam, this.Entity, this.ShooterComp.ShooterVO.ProjectileType, true, this.Entity.BuffComp.Buffs, faction, gunLocator);
            Service.Get <EventManager>().SendEvent(EventId.EntityAttackedTarget, this.Entity);
            this.shooterController.DecreaseShotsRemainingInClip(this.ShooterComp);
        }
        private BuffTypeVO ShouldDeflectProjectile(ProjectileView view, float distSquared)
        {
            SmartEntity target = view.Bullet.Target;

            if (target == null || target.TroopComp == null || !target.TroopComp.IsAbilityModeActive)
            {
                return(null);
            }
            Bullet bullet = view.Bullet;

            if (bullet.IsDeflection)
            {
                return(null);
            }
            if (!bullet.ProjectileType.IsDeflectable)
            {
                return(null);
            }
            TroopComponent     troopComp = target.TroopComp;
            ITroopDeployableVO troopType = troopComp.TroopType;
            float num = (float)(troopType.SizeX + troopType.SizeY) * 0.5f;

            num += 1.33f;
            float num2 = num * 0.5f * 3f;

            if (distSquared > num2 * num2)
            {
                return(null);
            }
            string selfBuff = troopComp.AbilityVO.SelfBuff;

            if (string.IsNullOrEmpty(selfBuff))
            {
                return(null);
            }
            return(Service.Get <IDataController>().GetOptional <BuffTypeVO>(selfBuff));
        }
Example #30
0
        private void AddShieldRegenerationWarBuff(SmartEntity entity, WarBuffVO warBuffVO)
        {
            StaticDataController       staticDataController  = Service.StaticDataController;
            BuildingComponent          buildingComp          = entity.BuildingComp;
            ShieldGeneratorComponent   shieldGeneratorComp   = entity.ShieldGeneratorComp;
            TroopComponent             troopComp             = entity.TroopComp;
            TroopShieldHealthComponent troopShieldHealthComp = entity.TroopShieldHealthComp;
            BuffTypeVO buffType;

            if (buildingComp != null && shieldGeneratorComp != null)
            {
                buffType = staticDataController.Get <BuffTypeVO>(warBuffVO.BuildingBuffUid);
            }
            else
            {
                if (troopComp == null || troopShieldHealthComp == null)
                {
                    return;
                }
                buffType = staticDataController.Get <BuffTypeVO>(warBuffVO.TroopBuffUid);
            }
            this.TryAddBuffStack(entity, buffType, ArmorType.Shield, BuffVisualPriority.SquadWars, entity);
            entity.BuffComp.SetBuildingLoadedEvent(EventId.ShieldStarted, new VisualReadyDelegate(this.BuildingShieldStarted));
        }