Exemplo n.º 1
0
 public IWeaponShipData GetCurrentWeaponBank(WeaponBank bank)
 {
     foreach (SectionShipData currentSection in this.GetCurrentSections())
     {
         foreach (WeaponBankShipData weaponBank in currentSection.WeaponBanks)
         {
             if (weaponBank.Bank == bank.LogicalBank)
             {
                 return((IWeaponShipData)weaponBank);
             }
         }
         if (bank.Module != null)
         {
             foreach (ModuleShipData module in currentSection.Modules)
             {
                 if (module.SelectedModule != null && bank.Module.Attachment == module.ModuleMount)
                 {
                     foreach (LogicalBank bank1 in module.SelectedModule.Module.Banks)
                     {
                         if (bank1 == bank.LogicalBank)
                         {
                             return((IWeaponShipData)module.SelectedModule);
                         }
                     }
                 }
             }
         }
     }
     return((IWeaponShipData)null);
 }
Exemplo n.º 2
0
 private void ThinkTrack()
 {
     if (this.m_Target == null)
     {
         this.m_State = VonNeumannChildStates.INITFLEE;
     }
     else
     {
         float   num1      = 0.0f;
         float   val2      = 0.0f;
         Vector3 vector3_1 = Vector3.Zero;
         if (this.m_Target is Ship)
         {
             Ship target = this.m_Target as Ship;
             vector3_1 = target.Position;
             num1      = target.ShipSphere.radius;
         }
         else if (this.m_Target is StellarBody)
         {
             StellarBody target = this.m_Target as StellarBody;
             vector3_1 = target.Parameters.Position;
             num1      = target.Parameters.Radius;
             val2      = 750f;
         }
         WeaponBank bankWithWeaponTrait = this.m_VonNeumannChild.GetWeaponBankWithWeaponTrait(WeaponEnums.WeaponTraits.Disintegrating);
         if (bankWithWeaponTrait != null)
         {
             this.m_ApproachRange = Math.Max(bankWithWeaponTrait.Weapon.RangeTable.Effective.Range, 100f);
             bankWithWeaponTrait.PostSetProp("DisableAllTurrets", true);
         }
         else
         {
             this.m_ApproachRange = Math.Max(100f, CombatAI.GetMinEffectiveWeaponRange(this.m_VonNeumannChild, false));
         }
         this.m_ApproachRange  = Math.Max(this.m_ApproachRange, val2);
         this.m_ApproachRange += num1;
         Vector3 vector3_2 = vector3_1;
         Vector3 vector3_3 = this.m_VonNeumannChild.Position - vector3_2;
         double  num2      = (double)vector3_3.Normalize();
         Vector3 targetPos = vector3_2 + vector3_3 * this.m_ApproachRange;
         Vector3 look      = vector3_3 * -1f;
         this.m_VonNeumannChild.Maneuvering.PostAddGoal(targetPos, look);
         float lengthSquared = (this.m_VonNeumannChild.Position - targetPos).LengthSquared;
         float num3          = this.m_ApproachRange + 200f;
         if ((double)lengthSquared >= (double)num3 * (double)num3)
         {
             return;
         }
         this.m_State = VonNeumannChildStates.INITCOLLECT;
     }
 }
        public TachyonCannonAttackControl(
            App game,
            CombatAI commanderAI,
            Ship ship,
            int weaponID,
            WeaponEnums.TurretClasses weaponType)
            : base(game, commanderAI, ship, weaponID, weaponType)
        {
            WeaponBank weaponBank = ship.WeaponBanks.FirstOrDefault <WeaponBank>((Func <WeaponBank, bool>)(x => x.Weapon.UniqueWeaponID == weaponID));

            if (weaponBank == null)
            {
                return;
            }
            this.m_MaxRange = weaponBank.Weapon.Range;
        }
Exemplo n.º 4
0
        public AttackPlanetControl(
            App game,
            CombatAI commanderAI,
            Ship ship,
            WeaponEnums.TurretClasses weaponType)
            : base(game, commanderAI, ship, weaponType)
        {
            this.m_TargetPlanet = (StellarBody)null;
            WeaponBank weaponBank = ship.WeaponBanks.FirstOrDefault <WeaponBank>((Func <WeaponBank, bool>)(x => x.TurretClass == weaponType));

            if (weaponBank == null)
            {
                return;
            }
            this.m_WeaponID = weaponBank.Weapon.UniqueWeaponID;
        }
Exemplo n.º 5
0
        public MineLayerControl(
            App game,
            CombatAI commanderAI,
            Ship ship,
            WeaponEnums.TurretClasses weaponType)
            : base(game, commanderAI, ship, weaponType)
        {
            this.m_ForceOn = false;
            WeaponBank weaponBank = ship.WeaponBanks.FirstOrDefault <WeaponBank>((Func <WeaponBank, bool>)(x => x.TurretClass == weaponType));

            if (weaponBank != null)
            {
                this.m_WeaponID = weaponBank.Weapon.UniqueWeaponID;
            }
            this.m_MaxPos = Vector3.Zero;
            this.m_MinPos = Vector3.Zero;
        }
Exemplo n.º 6
0
 public override void Initialize()
 {
     this.m_Planets = new List <StellarBody>();
     this.m_Moons   = new List <MoonData>();
     this.m_Stars   = new List <StarModel>();
     this.m_VictoryConditionsMet = false;
     this.m_SpaceBattle          = false;
     this.m_TrackUpdateRate      = 0;
     this.m_PlanetOffsetDist     = 0.0f;
     this.m_BeamBank             = this.m_SystemKiller.GetWeaponBankWithWeaponTrait(WeaponEnums.WeaponTraits.PlanetKilling);
     if (this.m_BeamBank == null)
     {
         return;
     }
     this.m_BeamBank.PostSetProp("RequestFireStateChange", true);
     this.m_BeamBank.PostSetProp("DisableAllTurrets", true);
 }
Exemplo n.º 7
0
        public PositionalAttackControl(
            App game,
            CombatAI commanderAI,
            Ship ship,
            int weaponID,
            WeaponEnums.TurretClasses weaponType)
            : base(game, commanderAI, ship, weaponType)
        {
            this.m_DetonatingWeapon = false;
            WeaponBank weaponBank = ship.WeaponBanks.FirstOrDefault <WeaponBank>((Func <WeaponBank, bool>)(x => x.Weapon.UniqueWeaponID == weaponID));

            if (weaponBank != null)
            {
                this.m_WeaponSpeed      = weaponBank.Weapon.Speed;
                this.m_WeaponID         = weaponBank.Weapon.UniqueWeaponID;
                this.m_DetonatingWeapon = ((IEnumerable <WeaponEnums.WeaponTraits>)weaponBank.Weapon.Traits).Contains <WeaponEnums.WeaponTraits>(WeaponEnums.WeaponTraits.Detonating);
            }
            this.m_TargetSet      = false;
            this.m_TargetPosition = Vector3.Zero;
            this.m_HoldShipDelay  = 0;
        }
Exemplo n.º 8
0
 public override void ObjectRemoved(IGameObject obj)
 {
     if (obj == this.m_CurrentTarget)
     {
         this.m_CurrentTarget = (IGameObject)null;
     }
     if (this.m_BeamBank == obj)
     {
         this.m_BeamBank = (WeaponBank)null;
     }
     if (obj is StellarBody)
     {
         StellarBody stellarBody = obj as StellarBody;
         this.m_Planets.Remove(stellarBody);
         List <MoonData> moonDataList = new List <MoonData>();
         foreach (MoonData moon in this.m_Moons)
         {
             if (moon.Moon == stellarBody)
             {
                 moonDataList.Add(moon);
             }
             else if (moon.ParentID == stellarBody.Parameters.OrbitalID)
             {
                 moonDataList.Add(moon);
             }
         }
         foreach (MoonData moonData in moonDataList)
         {
             this.m_Moons.Remove(moonData);
         }
     }
     if (!(obj is StarModel))
     {
         return;
     }
     this.m_Stars.Remove(obj as StarModel);
 }
Exemplo n.º 9
0
 public void AddWeaponGroupIcon(WeaponBank weaponBank)
 {
     this.PostSetProp(nameof(AddWeaponGroupIcon), weaponBank.GetObjectID());
 }