Ejemplo n.º 1
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);
            }
            if (TroopController.IsEntityPhantom(target))
            {
                return(false);
            }
            if (shooterComp.OriginalShooterVO.NewTargetOnReload && !shooterComp.IsPotentialTargetNew(target.ID))
            {
                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);
        }
Ejemplo n.º 2
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 (TroopController.IsEntityPhantom(target))
            {
                return(false);
            }
            if (TroopController.IsEntityHealer(target))
            {
                return(false);
            }
            TroopComponent troopComp2 = smartEntity.TroopComp;

            return(troopComp2 == null || !TroopController.IsEntityHealer(smartEntity) || this.CanBeHealed(target, smartEntity));
        }
Ejemplo n.º 3
0
 private bool ShouldSeekAlternativeTarget(SmartEntity troopEntity)
 {
     if (troopEntity.TroopComp == null)
     {
         Service.Logger.Error("Non troop entity checking for alternative target in TargetingSystem");
         return(false);
     }
     return(troopEntity.DefenderComp == null && !TroopController.IsEntityHealer(troopEntity) && !TroopController.IsEntityPhantom(troopEntity));
 }