Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        public void InformTurretsAboutTroop(List <EntityElementPriorityPair> turretsInRangeOf, SmartEntity entity, HashSet <ShooterComponent> resetReevaluateTargetSet)
        {
            int i     = 0;
            int count = turretsInRangeOf.Count;

            while (i < count)
            {
                EntityElementPriorityPair entityElementPriorityPair = turretsInRangeOf[i];
                SmartEntity     smartEntity = (SmartEntity)entityElementPriorityPair.Element;
                HealthComponent healthComp  = smartEntity.HealthComp;
                if (healthComp != null && !healthComp.IsDead())
                {
                    ShooterComponent shooterComp = smartEntity.ShooterComp;
                    if (shooterComp != null)
                    {
                        TurretShooterComponent turretShooterComp = smartEntity.TurretShooterComp;
                        if (turretShooterComp != null)
                        {
                            this.AddTurretTarget(shooterComp, turretShooterComp, entity, entityElementPriorityPair.Priority, resetReevaluateTargetSet);
                        }
                    }
                }
                i++;
            }
        }