示例#1
0
        public void GetLoadout()
        {
            Loadout = UniverseDB.FindLoadout(Arch.Nickname);
            if (Loadout != null)
            {
                AI = new AI.SolarAI();
                var firstOrDefault = Loadout.Items.FirstOrDefault(item => item.arch.GetType() == typeof(PowerArchetype));
                if (firstOrDefault != null)
                {
                    PowerGen = new PowerSim(this, (PowerArchetype)firstOrDefault.arch, firstOrDefault);
                }
                else
                {
                    return;
                }

                firstOrDefault =
                    Loadout.Items.FirstOrDefault(item => item.arch.GetType() == typeof(ShieldGeneratorArchetype));
                if (firstOrDefault != null)
                {
                    ShieldSim = new ShieldGeneratorSim(this, (ShieldGeneratorArchetype)firstOrDefault.arch, PowerGen)
                    {
                        Power = PowerGen
                    };
                }
            }
        }
示例#2
0
        /// <summary>
        ///     This method checks the ship's equipment/cargo list and rebuilds
        ///     the simulations for the power generator, thrusters, etc.
        /// </summary>
        public void InitialiseEquipmentSimulation()
        {
            _armorDamageFactor = 1.0f;

            var shipArch = Arch as ShipArchetype;

// ReSharper disable once PossibleNullReferenceException
            _linearDrag          = shipArch.LinearDrag;
            _linearThrusterForce = 0.0f;
            _linearForce         = 0.0f;

            foreach (var item in Items.Values)
            {
                if (item.arch is ShieldGeneratorArchetype && item.mounted)
                {
                    var newShield = new ShieldGeneratorSim(this, (ShieldGeneratorArchetype)item.arch, Powergen);
                    if (Shield == null)
                    {
                        Shield = newShield;
                    }
                    else if (Shield.Health < newShield.Health)
                    {
                        Shield = newShield;
                    }
                    item.sim = newShield;
                }
                else if (item.arch is PowerArchetype && item.mounted)
                {
                    item.sim = new PowerSim(this, (PowerArchetype)item.arch, item);
                    if (Powergen == null)
                    {
                        Powergen = item.sim as PowerSim;
                    }
                }
                else if (item.arch is ThrusterArchetype && item.mounted)
                {
                    item.sim = new ThrusterSim(this, item);
                    var thruster = item.arch as ThrusterArchetype;
                    _linearThrusterForce += thruster.MaxForce;
                }
                else if (item.arch is GunArchetype && item.mounted)
                {
                    item.sim = new GunSim(this, item);
                }
                else if (item.arch is ArmorArchetype)
                {
                    // hit points scale has the effect of increasing the base hit points
                    // the damage factor is the inverse of this
                    var armorArch = item.arch as ArmorArchetype;
                    _armorDamageFactor += (1 / armorArch.HitPtsScale);
                }
                else if (item.arch is EngineArchetype && item.mounted)
                {
                    var engine = item.arch as EngineArchetype;
                    _linearForce += engine.MaxForce;
                    _linearDrag  += engine.LinearDrag;
                }
                else if (item.arch is ScannerArchetype && item.mounted)
                {
                    Scanner     = item.arch as ScannerArchetype;
                    BucketRange = Scanner.ScanRange;
                }
            }
        }