Esempio n. 1
0
        public void testArmor()
        {
            Faction newFaction = new Faction(0);
            ShipClassTN ts2 = new ShipClassTN("Test", newFaction);

            StarSystem System1 = SystemGen.CreateSol();

            SystemBody pl1 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            System1.Stars[0].Planets.Add(pl1);

            TaskGroupTN newTG = new TaskGroupTN("TG", newFaction, System1.Stars[0].Planets[0], System1);
            ShipTN ts = new ShipTN(ts2, 0, 0, newTG, newFaction, "Test Ship");

            ts2.ShipArmorDef = new ArmorDefTN("Duranium Armour");
            ts.ShipArmor = new ArmorTN(ts2.ShipArmorDef);

            ts2.ShipArmorDef.CalcArmor("Duranium Armor", 5, 38.0, 5);

            Console.WriteLine("ArmorPerHS: {0}", ts2.ShipArmorDef.armorPerHS);
            Console.WriteLine("Size: {0}", ts2.ShipArmorDef.size);
            Console.WriteLine("Cost: {0}", ts2.ShipArmorDef.cost);
            Console.WriteLine("Area: {0}", ts2.ShipArmorDef.area);
            Console.WriteLine("Depth: {0}", ts2.ShipArmorDef.depth);
            Console.WriteLine("Column Number: {0}", ts2.ShipArmorDef.cNum);

            Console.WriteLine("isDamaged: {0}", ts.ShipArmor.isDamaged);


            ts.ShipArmor.SetDamage(ts2.ShipArmorDef.cNum, ts2.ShipArmorDef.depth, 4, 1);
            for (int loop = 0; loop < ts2.ShipArmorDef.cNum; loop++)
            {
                Console.WriteLine("Column Value: {0}", ts.ShipArmor.armorColumns[loop]);
            }
            Console.WriteLine("Damage Key: {0}, Column Value: {1}", ts.ShipArmor.armorDamage.Min().Key, ts.ShipArmor.armorDamage.Min().Value);

            Console.WriteLine("isDamaged: {0}", ts.ShipArmor.isDamaged);

            ts.ShipArmor.RepairSingleBlock(ts2.ShipArmorDef.depth);

            Console.WriteLine("isDamaged: {0}", ts.ShipArmor.isDamaged);

            ts.ShipArmor.SetDamage(ts2.ShipArmorDef.cNum, ts2.ShipArmorDef.depth, 4, 1);
            for (int loop = 0; loop < ts2.ShipArmorDef.cNum; loop++)
            {
                Console.WriteLine("Column Value: {0}", ts.ShipArmor.armorColumns[loop]);
            }
            Console.WriteLine("Damage Key: {0}, Column Value: {1}", ts.ShipArmor.armorDamage.Min().Key, ts.ShipArmor.armorDamage.Min().Value);

            Console.WriteLine("isDamaged: {0}", ts.ShipArmor.isDamaged);

            ts.ShipArmor.RepairAllArmor();

            Console.WriteLine("isDamaged: {0}", ts.ShipArmor.isDamaged);

            Console.WriteLine("Cost: {0}, Area: {1},Size: {2}", ts.ShipArmor.armorDef.cost, ts.ShipArmor.armorDef.area, ts.ShipArmor.armorDef.size);
        }
        /// <summary>
        /// Constructor for TGViewModel. Initialization is to faction 0 task group 0.
        /// Later functionality will handle updating faction and taskgroup indices.
        /// </summary>
        public TaskGroupViewModel()
        {
            _CurrentFaction = GameState.Instance.Factions[0];
            Factions = GameState.Instance.Factions;

            if (GameState.Instance.Factions[0].TaskGroups.Count != 0)
                _CurrentTaskGroup = GameState.Instance.Factions[0].TaskGroups[0];

            TaskGroups = GameState.Instance.Factions[0].TaskGroups;
        }
        private void OnFactionChanged()
        {
            TaskGroups = GameState.Instance.Factions[_CurrentFaction.FactionID].TaskGroups;

            if (TaskGroups.Count != 0)
                _CurrentTaskGroup = TaskGroups[0];


            if (FactionChanged != null)
            {
                FactionChanged(this, new EventArgs());
            }
        }
Esempio n. 4
0
        public void testPSensor()
        {

            Faction newFaction = new Faction(0);

            StarSystem System1 = SystemGen.CreateSol();

            SystemBody pl1 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            System1.Stars[0].Planets.Add(pl1);

            TaskGroupTN newTG = new TaskGroupTN("TG", newFaction, System1.Stars[0].Planets[0], System1);

            ShipClassTN ts2 = new ShipClassTN("Test", newFaction);
            ShipTN ts = new ShipTN(ts2, 0, 0, newTG, newFaction, "Test Ship");

            PassiveSensorDefTN PSensorDefTest = new PassiveSensorDefTN("Thermal Sensor TH19-342", 19.0f, 18, PassiveSensorType.Thermal, 1.0f, 1);

            ts2.ShipPSensorDef = new BindingList<PassiveSensorDefTN>();
            ts2.ShipPSensorCount = new BindingList<ushort>();
            ts2.ShipPSensorDef.Add(PSensorDefTest);
            ts2.ShipPSensorCount.Add(1);

            PassiveSensorTN PSensorTest = new PassiveSensorTN(ts2.ShipPSensorDef[0]);

            ts.ShipPSensor = new BindingList<PassiveSensorTN>();
            ts.ShipPSensor.Add(PSensorTest);


            PassiveSensorDefTN tst3 = ts.ShipPSensor[0].pSensorDef;

            Console.WriteLine("Name: {0}", tst3.Name);
            Console.WriteLine("Size: {0}, HTK: {1}, Hardening: {2}", tst3.size, tst3.htk, tst3.hardening);
            Console.WriteLine("Rating: {0}, Range: {1}", tst3.rating, tst3.range);
            Console.WriteLine("IsMilitary: {0}", tst3.isMilitary);
            Console.WriteLine("Crew: {0}", tst3.crew);
            Console.WriteLine("Cost: {0}", tst3.cost);

            for (ushort loop = 80; loop < 120; loop++)
            {
                Console.WriteLine("Signature:{0} Detection Range in KM:{1}", loop, tst3.GetPassiveDetectionRange(loop));
            }
        }
Esempio n. 5
0
        public void testEngine()
        {

            Faction newFaction = new Faction(0);

            StarSystem System1 = SystemGen.CreateSol();

            SystemBody pl1 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            System1.Stars[0].Planets.Add(pl1);

            TaskGroupTN newTG = new TaskGroupTN("TG", newFaction, System1.Stars[0].Planets[0], System1);

            ShipClassTN ts2 = new ShipClassTN("Test", newFaction);
            ShipTN ts = new ShipTN(ts2, 0, 0, newTG, newFaction, "Test Ship");

            ts2.ShipEngineDef = new EngineDefTN("3137.6 EP Inertial Fusion Drive", 32, 2.65f, 0.6f, 0.75f, 2, 37, -1.0f);
            ts2.ShipEngineCount = 1;

            EngineTN temp = new EngineTN(ts2.ShipEngineDef);

            ts.ShipEngine = new BindingList<EngineTN>();
            ts.ShipEngine.Add(temp);

            EngineDefTN tst = ts.ShipEngine[0].engineDef;

            Console.WriteLine("Name: {0}", tst.Name);
            Console.WriteLine("EngineBase: {0}, PowerMod: {1}, FuelConMod: {2}, ThermalReduction: {3}, Size: {4},HyperMod: {5}",
                              tst.engineBase, tst.powerMod, tst.fuelConsumptionMod, tst.thermalReduction, tst.size, tst.hyperDriveMod);
            Console.WriteLine("EnginePower: {0}, FuelUsePerHour: {1}", tst.enginePower, tst.fuelUsePerHour);
            Console.WriteLine("EngineSize: {0}, EngineHTK: {1}", tst.size, tst.htk);
            Console.WriteLine("ThermalSignature: {0}, ExpRisk: {1}", tst.thermalSignature, tst.expRisk);
            Console.WriteLine("IsMilitary: {0}", tst.isMilitary);
            Console.WriteLine("Crew: {0}", tst.crew);
            Console.WriteLine("Cost: {0}", tst.cost);
        }
Esempio n. 6
0
                /// <summary>
                /// Constructor for task.
                /// ABR = Normal shipbuilding rate x (1+(((Class Size / 100) - 1)/2)) 
                /// Scrap Formula is ((0.25 * ShipCost) / ABR) * Year = days involved.
                /// </summary>
                /// <param name="Ship">Ship to repair/refit/scrap. build will be handled elsewhere.</param>
                /// <param name="TargetTG">Target TG which the ship will be put back in to, or in the case of a scrap operation taken from.</param>
                /// <param name="PopulationBuildRate">What is the currently selected shipyard capable of building? population and faction should factor into this number.</param>
                /// <param name="ConstructOrRefitTarget">If a new ship is being built, or an old ship is being refitted, what target design are we interested in?</param>
                public ShipyardTask(ShipTN Ship, Constants.ShipyardInfo.Task TaskToPerform, TaskGroupTN TargetTG, int PopulationBuildRate, String TitleToUse, ShipClassTN ConstructOrRefitTarget=null)
                {
                    m_aiMinerialsCost = new decimal[(int)Constants.Minerals.MinerialNames.MinerialCount];

                    CurrentShip = Ship;
                    CurrentTask = TaskToPerform;
                    Progress = 0.0m;
                    Priority = 0;
                    Paused = false;
                    ConstructRefitTarget = ConstructOrRefitTarget;

                    ABR = 1;

                    AssignedTaskGroup = TargetTG;

                    if(AssignedTaskGroup != null)
                        AssignedTaskGroup.IsInShipyard = true;

                    Cost = 0.0m;

                    /// <summary>
                    /// This is only relevant for new ship construction.
                    /// </summary>
                    Title = TitleToUse;

                    switch (TaskToPerform)
                    {
                        case Constants.ShipyardInfo.Task.Construction:
                            ABR = (int)Math.Round(PopulationBuildRate * (1.0f + (((ConstructRefitTarget.SizeHS / 100.0f) - 1.0f) / 2.0f)));
                            Cost = ConstructRefitTarget.BuildPointCost;
                            for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++)
                            {
                                m_aiMinerialsCost[mineralIterator] = ConstructRefitTarget.minerialsCost[mineralIterator];
                            }        
                            break;
                        case Constants.ShipyardInfo.Task.Repair:
                            ABR = (int)Math.Round(PopulationBuildRate * (1.0f + (((Ship.ShipClass.SizeHS / 100.0f) - 1.0f) / 2.0f)));
                            /// <summary>
                            /// Repair will just cost money. Two reasons. 1st: Laziness. I'd have to get all the component costs as well.
                            /// 2nd:Ships require continuous resource outlays via routine maintenance, that should and will cover the actual cost of repairing the ship above and beyond the money required.
                            /// </summary>
                            for(int componentIterator = 0; componentIterator < Ship.DestroyedComponents.Count; componentIterator++)
                            {
                                ushort ID = Ship.DestroyedComponents[componentIterator];
                                ComponentTypeTN CType = Ship.DestroyedComponentsType[componentIterator];
                                Cost = Cost + Ship.GetDamagedComponentsRepairCost(ID,CType);
                            }

                            if(Ship.ShipArmor.isDamaged == true)
                            {
                                int totalDamage = 0;
                                int max = Ship.ShipArmor.armorDef.cNum * Ship.ShipArmor.armorDef.depth;
                                foreach (KeyValuePair<ushort, ushort> pair in Ship.ShipArmor.armorDamage)
                                {
                                    totalDamage = totalDamage + pair.Value;
                                }

                                float damageFraction = ((float)totalDamage / (float)max);

                                Cost = Cost + ((decimal)damageFraction * Ship.ShipArmor.armorDef.cost);
                            }

                            for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++)
                            {
                                m_aiMinerialsCost[mineralIterator] = 0.0m;
                            }
                               
                            break;
                        case Constants.ShipyardInfo.Task.Refit:
                            ABR = (int)Math.Round(PopulationBuildRate * (1.0f + (((ConstructRefitTarget.SizeHS / 100.0f) - 1.0f) / 2.0f)));
                            Cost = ConstructRefitTarget.BuildPointCost;
                            for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++)
                            {
                                m_aiMinerialsCost[mineralIterator] = ConstructRefitTarget.minerialsCost[mineralIterator];
                            }
                            break;
                        case Constants.ShipyardInfo.Task.Scrap:
                            ABR = (int)Math.Round(PopulationBuildRate * (1.0f + (((Ship.ShipClass.SizeHS / 100.0f) - 1.0f) / 2.0f)));
                            Cost = Ship.ShipClass.BuildPointCost * -0.25m;
                            for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++)
                            {
                                m_aiMinerialsCost[mineralIterator] = Ship.ShipClass.minerialsCost[mineralIterator] * -0.25m;
                            }
                            break;
                    }
                    /// <summary>
                    /// How long will this retool take?
                    /// </summary>
                    float DaysInYear = (float)Constants.TimeInSeconds.RealYear / (float)Constants.TimeInSeconds.Day; 
                    float YearsOfProduction = (float)Math.Abs(Cost) / (float)ABR;
                    DateTime EstTime = GameState.Instance.GameDateTime;
                    if (YearsOfProduction < Constants.Colony.TimerYearMax)
                    {
                        int TimeToBuild = (int)Math.Floor(YearsOfProduction * DaysInYear);
                        TimeSpan TS = new TimeSpan(TimeToBuild, 0, 0, 0);
                        EstTime = EstTime.Add(TS);
                    }
                    CompletionDate = EstTime;
                }
Esempio n. 7
0
        /// <summary>
        /// ShipTN creates a ship of classDefinition in Index ShipIndex for the taskgroup ship list.
        /// </summary>
        /// <param name="ClassDefinition">Definition of the ship.</param>
        /// <param name="ShipIndex">Its index within the shiplist of the taskgroup.</param>
        /// <param name="CurrentTimeSlice">tick when this ship is created.</param>
        /// <param name="ShipTG">TG this ship belongs to.</param>
        /// <param name="ShipFact">Faction this ship belongs to.</param>
        /// <param name="Title">Name of the ship.</param>
        public ShipTN(ShipClassTN ClassDefinition, int ShipIndex, int CurrentTimeSlice, TaskGroupTN ShipTG, Faction ShipFact, String Title)
        {
            int index;
            Name = Title;

            /// <summary>
            /// create these or else anything that relies on a unique global id will break.
            /// </summary>
            Id = Guid.NewGuid();

            /// <summary>
            /// Set the class definition
            /// </summary>
            ShipClass = ClassDefinition;

            /// <summary>
            /// Inform the class that it has a new member.
            /// </summary>
            ClassDefinition.ShipsInClass.Add(this);

            /// <summary>
            /// Ships are standard crewed vessels for now.
            /// </summary>
            TypeOf = ShipType.Standard;

            /// <summary>
            /// Tell the Ship which TG it is a part of.
            /// </summary>
            ShipsTaskGroup = ShipTG;

            /// <summary>
            /// Likewise for Faction.
            /// </summary>
            ShipsFaction = ShipFact;

            /// <summary>
            /// Add this ship to the overall faction ship list.
            /// </summary>
            ShipsFaction.Ships.Add(this);

            /// <summary>
            /// Make sure to initialize this important variable that everything uses.
            /// </summary>
            ShipComponents = new BindingList<ComponentTN>();

            /// <summary>
            /// Initialize the list of Ship fire controls.
            /// </summary>
            ShipFireControls = new BindingList<ComponentTN>();

            /// <summary>
            /// Likewise the ListOfComponentDefs counterpart here is important.
            /// </summary>
            ComponentDefIndex = new BindingList<ushort>();
            for (int loop = 0; loop < ClassDefinition.ListOfComponentDefs.Count; loop++)
            {
                ComponentDefIndex.Add(0);
            }

            /// <summary>
            /// List of components that have been destroyed.
            /// </summary>
            DestroyedComponents = new BindingList<ushort>();

            DestroyedComponentsType = new BindingList<ComponentTypeTN>();

            /// <summary>
            /// How much damage can the ship take?
            /// </summary>
            ShipHTK = ShipClass.TotalHTK;

            /// <summary>
            /// When the destroyed components list is populated it can be selected from to put components here to be repaired.
            /// </summary>
            DamageControlQue = new BindingList<ushort>();

            /// <summary>
            /// Not yet set.
            /// </summary>
            DamageControlTarget = -1;


            /// <summary>
            /// All ships will have armor, and all ship defs should have armor before this point.
            /// </summary.
            ShipArmor = new ArmorTN(ClassDefinition.ShipArmorDef);

            /// <summary>
            /// Crew Quarters don't strictly have to be present, but will be in almost all designs.
            /// </summary>
            CrewQuarters = new BindingList<GeneralComponentTN>();
            AddComponents(CrewQuarters, ClassDefinition.CrewQuarters, ClassDefinition.CrewQuartersCount);

            /// <summary>
            /// Subtract crew from crew pool if ship is not conscript staffed Here:
            /// </summary>

            CurrentCrew = 0;
            SpareBerths = ShipClass.TotalCrewQuarters;
            CurrentCryoStorage = 0;
            CurrentDeployment = 0.0f;
            Morale = 100.0f;
            ShipGrade = 0.0f;
            TFTraining = 0.0f;

            /// <summary>
            ///Fuel Tanks don't have to be present, but will be in most designs.
            /// </summary>
            FuelTanks = new BindingList<GeneralComponentTN>();
            AddComponents(FuelTanks, ClassDefinition.FuelTanks, ClassDefinition.FuelTanksCount);
            CurrentFuel = 0.0f;
            CurrentFuelCapacity = ShipClass.TotalFuelCapacity;
            FuelCounter = 0;

            /// <summary>
            /// Engineering spaces must be on civ designs(atleast 1), but can be absent from military designs.
            /// </summary>
            EngineeringBays = new BindingList<GeneralComponentTN>();
            AddComponents(EngineeringBays, ClassDefinition.EngineeringBays, ClassDefinition.EngineeringBaysCount);
            CurrentDamageControlRating = ClassDefinition.MaxDamageControlRating;
            CurrentMSP = ShipClass.TotalMSPCapacity;
            CurrentMSPCapacity = ShipClass.TotalMSPCapacity;
            MaintenanceClock = 0.0f;

            /// <summary>
            /// All remaining components that are of a more specialized nature. These do not have to be present, except bridges on ships bigger than 1K tons.
            /// </summary>
            OtherComponents = new BindingList<GeneralComponentTN>();
            AddComponents(OtherComponents, ClassDefinition.OtherComponents, ClassDefinition.OtherComponentsCount);

            /// <summary>
            /// All mobile ships need engines, orbitals and PDCs don't however.
            /// </summary>
            ShipEngine = new BindingList<EngineTN>();
            index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipEngineDef);
            if (index != -1)
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;

            for (int loop = 0; loop < ClassDefinition.ShipEngineCount; loop++)
            {
                EngineTN Engine = new EngineTN(ClassDefinition.ShipEngineDef);
                Engine.componentIndex = ShipEngine.Count;
                ShipEngine.Add(Engine);
                ShipComponents.Add(Engine);
            }
            CurrentEnginePower = ClassDefinition.MaxEnginePower;
            CurrentMaxEnginePower = CurrentEnginePower;
            CurrentThermalSignature = ClassDefinition.MaxThermalSignature;
            CurrentMaxThermalSignature = CurrentThermalSignature;
            CurrentSpeed = ClassDefinition.MaxSpeed;
            CurrentMaxSpeed = CurrentSpeed;
            CurrentFuelUsePerHour = ClassDefinition.MaxFuelUsePerHour;
            CurrentMaxFuelUsePerHour = CurrentFuelUsePerHour;


            /// <summary>
            /// Usually only cargo ships and salvagers will have cargo holds.
            /// </summary>
            ShipCargo = new BindingList<CargoTN>();
            for (int loop = 0; loop < ClassDefinition.ShipCargoDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipCargoDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipCargoCount[loop]; loop2++)
                {
                    CargoTN cargo = new CargoTN(ClassDefinition.ShipCargoDef[loop]);
                    cargo.componentIndex = ShipCargo.Count;
                    ShipCargo.Add(cargo);
                    ShipComponents.Add(cargo);
                }
            }
            CurrentCargoTonnage = 0;
            CargoList = new Dictionary<Installation.InstallationType, CargoListEntryTN>();
            CargoComponentList = new Dictionary<ComponentDefTN, CargoListEntryTN>();

            /// <summary>
            /// While only colonyships will have the major bays, just about any craft can have an emergency cryo bay.
            /// </summary>
            ShipColony = new BindingList<ColonyTN>();
            for (int loop = 0; loop < ClassDefinition.ShipColonyDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipColonyDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipColonyCount[loop]; loop2++)
                {
                    ColonyTN colony = new ColonyTN(ClassDefinition.ShipColonyDef[loop]);
                    colony.componentIndex = ShipColony.Count;
                    ShipColony.Add(colony);
                    ShipComponents.Add(colony);
                }
            }
            CurrentCryoStorage = 0;

            /// <summary>
            /// Any ship with cargo holds, troop bays, cryo berths, or drop pods will benefit from a cargohandling system. though droppods benefit from the CHSes on other vessels as well.
            /// </summary>
            ShipCHS = new BindingList<CargoHandlingTN>();
            for (int loop = 0; loop < ClassDefinition.ShipCHSDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipCHSDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipCHSCount[loop]; loop2++)
                {
                    CargoHandlingTN CHS = new CargoHandlingTN(ClassDefinition.ShipCHSDef[loop]);
                    CHS.componentIndex = ShipCHS.Count;
                    ShipCHS.Add(CHS);
                    ShipComponents.Add(CHS);
                }
            }
            CurrentTractorMultiplier = ShipClass.TractorMultiplier;

            /// <summary>
            /// Every ship will have a passive sensor rating, but very few will have specialized passive sensors.
            /// </summary>
            ShipPSensor = new BindingList<PassiveSensorTN>();
            for (int loop = 0; loop < ClassDefinition.ShipPSensorDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipPSensorDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipPSensorCount[loop]; loop2++)
                {
                    PassiveSensorTN PSensor = new PassiveSensorTN(ClassDefinition.ShipPSensorDef[loop]);
                    PSensor.componentIndex = ShipPSensor.Count;
                    ShipPSensor.Add(PSensor);
                    ShipComponents.Add(PSensor);
                }
            }

            /// <summary>
            /// These two can and will change if the ship takes damage to its sensors.
            /// </summary>
            BestThermalRating = ClassDefinition.BestThermalRating;
            BestEMRating = ClassDefinition.BestEMRating;

            /// <summary>
            /// Active Sensors will be probably rarer than passive sensors, as they betray their location to any listener in range.
            /// And the listener may be far enough away that the active will not ping him.
            /// </summary>
            ShipASensor = new BindingList<ActiveSensorTN>();
            for (int loop = 0; loop < ClassDefinition.ShipASensorDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipASensorDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipASensorCount[loop]; loop2++)
                {
                    ActiveSensorTN ASensor = new ActiveSensorTN(ClassDefinition.ShipASensorDef[loop]);
                    ASensor.componentIndex = ShipASensor.Count;

                    int ASIndex = loop2 + 1;
                    ASensor.Name = ASensor.aSensorDef.Name + " #" + ASIndex.ToString();

                    ShipASensor.Add(ASensor);
                    ShipComponents.Add(ASensor);
                }
            }

            /// <summary>
            /// This won't change, but it should be here for convenience during sensor sweeps.
            /// </summary>
            TotalCrossSection = ClassDefinition.TotalCrossSection;
            CurrentEMSignature = 0;

            /// <summary>
            /// Detection Statistics initialization:
            /// </summary>
            ThermalList = new LinkedListNode<int>(ShipIndex);
            EMList = new LinkedListNode<int>(ShipIndex);
            ActiveList = new LinkedListNode<int>(ShipIndex);

            ThermalDetection = new BindingList<int>();
            EMDetection = new BindingList<int>();
            ActiveDetection = new BindingList<int>();

            for (int loop = 0; loop < Constants.Faction.FactionMax; loop++)
            {
                ThermalDetection.Add(CurrentTimeSlice);
                EMDetection.Add(CurrentTimeSlice);
                ActiveDetection.Add(CurrentTimeSlice);
            }

            ShipCommanded = false;

            ShipBFC = new BindingList<BeamFireControlTN>();
            for (int loop = 0; loop < ClassDefinition.ShipBFCDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipBFCDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipBFCCount[loop]; loop2++)
                {
                    BeamFireControlTN BFC = new BeamFireControlTN(ClassDefinition.ShipBFCDef[loop]);
                    BFC.componentIndex = ShipBFC.Count;

                    int BFCIndex = loop2 + 1;
                    BFC.Name = BFC.beamFireControlDef.Name + " #" + BFCIndex.ToString();

                    ShipBFC.Add(BFC);
                    ShipComponents.Add(BFC);
                    ShipFireControls.Add(BFC);
                }
            }

            ShipBeam = new BindingList<BeamTN>();
            for (int loop = 0; loop < ClassDefinition.ShipBeamDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipBeamDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipBeamCount[loop]; loop2++)
                {
                    BeamTN Beam = new BeamTN(ClassDefinition.ShipBeamDef[loop]);
                    Beam.componentIndex = ShipBeam.Count;

                    int BeamIndex = loop2 + 1;
                    Beam.Name = Beam.beamDef.Name + " #" + BeamIndex.ToString();

                    ShipBeam.Add(Beam);
                    ShipComponents.Add(Beam);
                }
            }

            ShipReactor = new BindingList<ReactorTN>();
            for (int loop = 0; loop < ClassDefinition.ShipReactorDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipReactorDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipReactorCount[loop]; loop2++)
                {
                    ReactorTN Reactor = new ReactorTN(ClassDefinition.ShipReactorDef[loop]);
                    Reactor.componentIndex = ShipReactor.Count;
                    ShipReactor.Add(Reactor);
                    ShipComponents.Add(Reactor);
                }
            }
            CurrentPowerGen = ClassDefinition.TotalPowerGeneration;

            ShipShield = new BindingList<ShieldTN>();
            index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipShieldDef);
            if (index != -1)
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;

            for (int loop = 0; loop < ClassDefinition.ShipShieldCount; loop++)
            {
                ShieldTN Shield = new ShieldTN(ClassDefinition.ShipShieldDef);
                Shield.componentIndex = ShipShield.Count;
                ShipShield.Add(Shield);
                ShipComponents.Add(Shield);
            }

            CurrentShieldPool = 0.0f;
            CurrentShieldPoolMax = ClassDefinition.TotalShieldPool;
            CurrentShieldGen = ClassDefinition.TotalShieldGenPerTick;
            CurrentShieldFuelUse = ClassDefinition.TotalShieldFuelCostPerTick;
            ShieldIsActive = false;


            ShipMLaunchers = new BindingList<MissileLauncherTN>();
            for (int loop = 0; loop < ClassDefinition.ShipMLaunchDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipMLaunchDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipMLaunchCount[loop]; loop2++)
                {
                    MissileLauncherTN Tube = new MissileLauncherTN(ClassDefinition.ShipMLaunchDef[loop]);
                    Tube.componentIndex = ShipMLaunchers.Count;

                    int TubeIndex = loop2 + 1;
                    Tube.Name = Tube.missileLauncherDef.Name + " #" + TubeIndex.ToString();

                    ShipMLaunchers.Add(Tube);
                    ShipComponents.Add(Tube);
                }
            }

            ShipMagazines = new BindingList<MagazineTN>();
            for (int loop = 0; loop < ClassDefinition.ShipMagazineDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipMagazineDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipMagazineCount[loop]; loop2++)
                {
                    MagazineTN Mag = new MagazineTN(ClassDefinition.ShipMagazineDef[loop]);
                    Mag.componentIndex = ShipMagazines.Count;
                    ShipMagazines.Add(Mag);
                    ShipComponents.Add(Mag);
                }
            }

            ShipMFC = new BindingList<MissileFireControlTN>();
            for (int loop = 0; loop < ClassDefinition.ShipMFCDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipMFCDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipMFCCount[loop]; loop2++)
                {
                    MissileFireControlTN MFC = new MissileFireControlTN(ClassDefinition.ShipMFCDef[loop]);
                    MFC.componentIndex = ShipMFC.Count;

                    int MFCIndex = loop2 + 1;
                    MFC.Name = MFC.mFCSensorDef.Name + " #" + MFCIndex.ToString();

                    ShipMFC.Add(MFC);
                    ShipComponents.Add(MFC);
                    ShipFireControls.Add(MFC);
                }
            }

            ShipOrdnance = new Dictionary<OrdnanceDefTN, int>();

            CurrentMagazineCapacity = 0;
            CurrentMagazineCapacityMax = ClassDefinition.TotalMagazineCapacity;
            CurrentLauncherMagCapacityMax = ClassDefinition.LauncherMagSpace;
            CurrentMagazineMagCapacityMax = ClassDefinition.MagazineMagSpace;

            ShipCIWS = new BindingList<CIWSTN>();
            for (int loop = 0; loop < ClassDefinition.ShipCIWSDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipCIWSDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipCIWSCount[loop]; loop2++)
                {
                    CIWSTN CIWS = new CIWSTN(ClassDefinition.ShipCIWSDef[loop]);
                    CIWS.componentIndex = ShipCIWS.Count;

                    int CIWSIndex = loop2 + 1;
                    CIWS.Name = CIWS.cIWSDef.Name + " #" + CIWSIndex.ToString();

                    ShipCIWS.Add(CIWS);
                    ShipComponents.Add(CIWS);
                }
            }
            ShipCIWSIndex = 0;

            ShipTurret = new BindingList<TurretTN>();
            for (int loop = 0; loop < ClassDefinition.ShipTurretDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipTurretDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipTurretCount[loop]; loop2++)
                {
                    TurretTN Turret = new TurretTN(ClassDefinition.ShipTurretDef[loop]);
                    Turret.componentIndex = ShipTurret.Count;

                    int TurretIndex = loop2 + 1;
                    Turret.Name = Turret.turretDef.Name + " #" + TurretIndex.ToString();

                    ShipTurret.Add(Turret);
                    ShipComponents.Add(Turret);
                }
            }

            ShipJumpEngine = new BindingList<JumpEngineTN>();
            for (int loop = 0; loop < ClassDefinition.ShipJumpEngineDef.Count; loop++)
            {
                index = ClassDefinition.ListOfComponentDefs.IndexOf(ClassDefinition.ShipJumpEngineDef[loop]);
                ComponentDefIndex[index] = (ushort)ShipComponents.Count;
                for (int loop2 = 0; loop2 < ClassDefinition.ShipJumpEngineCount[loop]; loop2++)
                {
                    JumpEngineTN JumpEngine = new JumpEngineTN(ClassDefinition.ShipJumpEngineDef[loop]);
                    JumpEngine.componentIndex = ShipJumpEngine.Count;

                    int JumpEngineIndex = loop2 + 1;
                    JumpEngine.Name = JumpEngine.jumpEngineDef.Name + " #" + JumpEngineIndex.ToString();

                    ShipJumpEngine.Add(JumpEngine);
                    ShipComponents.Add(JumpEngine);
                }
            }
            JumpSickness = 0;

            IsDestroyed = false;

            ShipsTargetting = new BindingList<ShipTN>();

            TaskGroupsOrdered = new BindingList<TaskGroupTN>();
        }
Esempio n. 8
0
        public void TGActiveTest()
        {
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);
            ActiveSensorDefTN ActDef1 = new ActiveSensorDefTN("Search 5M - 5000", 1.0f, 10, 5, 100, false, 1.0f, 1);
            ActiveSensorDefTN ActDef2 = new ActiveSensorDefTN("Search 500k - 1", 1.0f, 10, 5, 1, false, 1.0f, 1);
            ActiveSensorDefTN ActDef3 = new ActiveSensorDefTN("Search 2.2M - 1000", 1.0f, 10, 5, 20, false, 1.0f, 1);
            ActiveSensorDefTN ActDef4 = new ActiveSensorDefTN("Search 7M - 10000", 1.0f, 10, 5, 200, false, 1.0f, 1);

            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.0m, ComponentTypeTN.Fuel);
            GeneralComponentDefTN EBay = new GeneralComponentDefTN("Engineering Spaces", 1.0f, 5, 10.0m, ComponentTypeTN.Engineering);
            GeneralComponentDefTN Bridge = new GeneralComponentDefTN("Bridge", 1.0f, 5, 10.0m, ComponentTypeTN.Bridge);


            Faction FID = new Faction(0);
            StarSystem System = SystemGen.CreateSol();
            SystemBody planet = new SystemBody(System.Stars[0], SystemBody.PlanetType.Terrestrial);;
            System.Stars[0].Planets.Add(planet);

            TaskGroupTN TaskGroup1 = new TaskGroupTN("Taskforce 001", FID, planet, System);
            for (int loop = 0; loop < 4; loop++)
            {


                ShipClassTN test = new ShipClassTN("Ship", FID);
                test.AddCrewQuarters(CrewQ, 2);
                test.AddFuelStorage(FuelT, 2);
                test.AddEngineeringSpaces(EBay, 2);
                Console.WriteLine("Bridge isn't present: {0} {1}", test.OtherComponents.IndexOf(Bridge), test.HasBridge);
                test.AddOtherComponent(Bridge, 1);
                Console.WriteLine("Bridge is present: {0} {1}", test.OtherComponents.IndexOf(Bridge), test.HasBridge);

                switch (loop)
                {
                    case 0: test.AddActiveSensor(ActDef2, 2);
                        break;
                    case 1: test.AddActiveSensor(ActDef1, 2);
                        break;
                    case 2: test.AddActiveSensor(ActDef3, 2);
                        break;
                    case 3: test.AddActiveSensor(ActDef4, 2);
                        break;
                }

                TaskGroup1.AddShip(test, "Test Ship");

                TaskGroup1.SetActiveSensor(loop, 0, true);
                TaskGroup1.SetActiveSensor(loop, 1, true);
            }

            LinkedListNode<int> EM = TaskGroup1.EMSortList.First;
            for (int loop = 0; loop < 4; loop++)
            {
                Console.WriteLine("{0} {1}", TaskGroup1.Ships[loop].CurrentEMSignature, EM.Value);
                EM = EM.Next;
            }

            for (int loop = 0; loop < Constants.ShipTN.ResolutionMax; loop++)
            {
                Console.WriteLine("{0} | {1}", TaskGroup1.TaskGroupLookUpST[loop], loop);
            }

            TaskGroup1.SetActiveSensor(2, 0, false);
            TaskGroup1.SetActiveSensor(2, 1, false);

            Console.WriteLine("--------------------------------------------");

            EM = TaskGroup1.EMSortList.First;
            for (int loop = 0; loop < 4; loop++)
            {
                Console.WriteLine("{0} {1}", TaskGroup1.Ships[loop].CurrentEMSignature, EM.Value);
                EM = EM.Next;
            }

            for (int loop = 0; loop < Constants.ShipTN.ResolutionMax; loop++)
            {
                Console.WriteLine("{0} | {1}", TaskGroup1.TaskGroupLookUpST[loop], loop);
            }
        }
Esempio n. 9
0
        public void TGActiveSortThermalSortTest()
        {
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);

            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.0m, ComponentTypeTN.Fuel);
            GeneralComponentDefTN EBay = new GeneralComponentDefTN("Engineering Spaces", 1.0f, 5, 10.0m, ComponentTypeTN.Engineering);
            GeneralComponentDefTN Bridge = new GeneralComponentDefTN("Bridge", 1.0f, 5, 10.0m, ComponentTypeTN.Bridge);

            Faction FID = new Faction(0);
            StarSystem System = SystemGen.CreateSol();
            SystemBody planet = new SystemBody(System.Stars[0], SystemBody.PlanetType.Terrestrial);;
            System.Stars[0].Planets.Add(planet);

            TaskGroupTN TaskGroup1 = new TaskGroupTN("Taskforce 001", FID, planet, System);

            for (int loop = 0; loop < 5; loop++)
            {
                ShipClassTN test = new ShipClassTN("Ship", FID);
                test.AddCrewQuarters(CrewQ, 2);
                test.AddFuelStorage(FuelT, 2);
                test.AddEngineeringSpaces(EBay, 2);
                test.AddOtherComponent(Bridge, 1);

                int add = 0;
                switch (loop)
                {
                    case 0: add = 2; break;
                    case 1: add = 4; break;
                    case 2: add = 1; break;
                    case 3: add = 5; break;
                    case 4: add = 3; break;
                }
                test.AddEngine(EngDef, (byte)add);

                Console.WriteLine("Speed:{0}", test.MaxSpeed);

                TaskGroup1.AddShip(test,"Test Ship");
                Console.WriteLine("{0} {1}", TaskGroup1, TaskGroup1.Ships[loop].ShipsTaskGroup);
            }

            LinkedListNode<int> AS = TaskGroup1.ActiveSortList.First;
            LinkedListNode<int> ES = TaskGroup1.EMSortList.First;
            LinkedListNode<int> TS = TaskGroup1.ThermalSortList.First;
            for (int loop = 0; loop < 5; loop++)
            {
                Console.Write("AL:{0}, EL:{1}, TL:{2} || Ship{3} AL:{4}, EL:{5} TL:{6} |||", AS.Value, ES.Value, TS.Value, loop, TaskGroup1.Ships[loop].ActiveList.Value,
                                                                                             TaskGroup1.Ships[loop].EMList.Value, TaskGroup1.Ships[loop].ThermalList.Value);


                Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", TaskGroup1.Ships[loop].CurrentSpeed, TaskGroup1.Ships[loop].CurrentEnginePower, TaskGroup1.Ships[loop].CurrentThermalSignature, TaskGroup1.Ships[loop].ShipClass.MaxEnginePower,
                    TaskGroup1.Ships[loop].ShipClass.MaxThermalSignature, TaskGroup1.Ships[loop].CurrentFuelUsePerHour, TaskGroup1.Ships[loop].ShipClass.MaxFuelUsePerHour);

                AS = AS.Next;
                ES = ES.Next;
                TS = TS.Next;
            }

            TaskGroup1.Ships[4].CurrentThermalSignature = 500;
            TaskGroup1.SortShipBySignature(TaskGroup1.Ships[4].ThermalList, TaskGroup1.ThermalSortList, 0);

            Console.WriteLine("------------------------");

            AS = TaskGroup1.ActiveSortList.First;
            ES = TaskGroup1.EMSortList.First;
            TS = TaskGroup1.ThermalSortList.First;
            for (int loop = 0; loop < 5; loop++)
            {
                Console.Write("AL:{0}, EL:{1}, TL:{2} || Ship{3} AL:{4}, EL:{5} TL:{6} |||", AS.Value, ES.Value, TS.Value, loop, TaskGroup1.Ships[loop].ActiveList.Value,
                                                                                             TaskGroup1.Ships[loop].EMList.Value, TaskGroup1.Ships[loop].ThermalList.Value);


                Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", TaskGroup1.Ships[loop].CurrentSpeed, TaskGroup1.Ships[loop].CurrentEnginePower, TaskGroup1.Ships[loop].CurrentThermalSignature, TaskGroup1.Ships[loop].ShipClass.MaxEnginePower,
                    TaskGroup1.Ships[loop].ShipClass.MaxThermalSignature, TaskGroup1.Ships[loop].CurrentFuelUsePerHour, TaskGroup1.Ships[loop].ShipClass.MaxFuelUsePerHour);

                AS = AS.Next;
                ES = ES.Next;
                TS = TS.Next;
            }
        }
Esempio n. 10
0
        /// <summary>
        /// TaskGroupEM Detection runs the EM detection routine on TaskGroupToTest from CurrentTaskGroup. This differs from Thermal in that we use the ship EM linked list as well as the faction EM
        /// Detection list.
        /// </summary>
        /// <param name="System">Current System this is taking place in.</param>
        /// <param name="CurrentTaskGroup">TaskGroup that is performing the sensor sweep.</param>
        /// <param name="TaskGroupToTest">TaskGroup being tested against.</param>
        /// <param name="dist">Distance between these two taskgroups.</param>
        /// <param name="detListIterator">Iterator for where the TaskGroupToTest is in the various detection lists and the system contact list.</param>
        /// <param name="DetShipList">If a ship is detected it must be put into this list for the detectedContactsList later on.</param>
        private void TaskGroupEMDetection(StarSystem System, TaskGroupTN CurrentTaskGroup, TaskGroupTN TaskGroupToTest, float dist, int detListIterator)
        {
            if (System.FactionDetectionLists[FactionID].EM[detListIterator] != GameState.Instance.CurrentSecond)
            {
                int sig = -1;
                int detection = -1;
                bool noDetection = false;
                bool allDetection = false;

                /// <summary>
                /// Get the best detection range for EM signatures in loop.
                /// </summary>
                int ShipID = TaskGroupToTest.EMSortList.Last();
                ShipTN scratch = TaskGroupToTest.Ships[ShipID];
                sig = scratch.CurrentEMSignature;

                /// <summary>
                /// Check to see if the taskgroup has an em sensor, and that said em sensor is not destroyed.
                /// otherwise use the default passive detection range.
                /// </summary>
                if (CurrentTaskGroup.BestEMCount > 0)
                {
                    detection = CurrentTaskGroup.BestEM.pSensorDef.GetPassiveDetectionRange(sig);
                }
                else
                {
                    detection = ComponentList.DefaultPassives.GetPassiveDetectionRange(sig);
                }

                bool det = LargeDetection(dist, detection);

                /// <summary>
                /// Good case, none of the ships are detected.
                /// </summary>
                if (det == false)
                {
                    noDetection = true;
                }

                /// <summary>
                /// Atleast the biggest ship is detected.
                /// </summary
                if (noDetection == false)
                {
                    ShipID = TaskGroupToTest.EMSortList.First();
                    scratch = TaskGroupToTest.Ships[ShipID];
                    sig = scratch.CurrentEMSignature;

                    /// <summary>
                    /// once again we must check here to make sure that the taskgroup does have a passive suite, or else use the default one.
                    /// </summary>
                    if (CurrentTaskGroup.BestEMCount > 0)
                    {
                        detection = CurrentTaskGroup.BestEM.pSensorDef.GetPassiveDetectionRange(sig);
                    }
                    else
                    {
                        detection = ComponentList.DefaultPassives.GetPassiveDetectionRange(sig);
                    }

                    det = LargeDetection(dist, detection);

                    /// <summary>
                    /// Best case, everything is detected.
                    /// </summary>
                    if (det == true)
                    {
                        allDetection = true;

                        for (int loop3 = 0; loop3 < TaskGroupToTest.Ships.Count; loop3++)
                        {
                            TaskGroupToTest.Ships[loop3].EMDetection[FactionID] = GameState.Instance.CurrentSecond;

                            if (DetShipList.Contains(TaskGroupToTest.Ships[loop3]) == false)
                            {
                                DetShipList.Add(TaskGroupToTest.Ships[loop3]);
                            }
                        }
                        System.FactionDetectionLists[FactionID].EM[detListIterator] = GameState.Instance.CurrentSecond;
                    }
                    else if (noDetection == false && allDetection == false)
                    {
                        /// <summary>
                        /// Worst case. some are detected, some aren't.
                        /// </summary>


                        for (int loop3 = 0; loop3 < TaskGroupToTest.Ships.Count; loop3++)
                        {
                            LinkedListNode<int> node = TaskGroupToTest.EMSortList.Last;
                            bool done = false;

                            while (!done)
                            {
                                scratch = TaskGroupToTest.Ships[node.Value];

                                if (scratch.EMDetection[FactionID] != GameState.Instance.CurrentSecond)
                                {
                                    sig = scratch.CurrentEMSignature;

                                    /// <summary>
                                    /// here is where EM detection differs from Thermal detection:
                                    /// If a ship has a signature of 0 by this point(and we didn't already hit noDetection above,
                                    /// it means that one ship is emitting a signature, but that no other ships are.
                                    /// Mark the group as totally detected, but not the ships, this serves to tell me that the ships are undetectable
                                    /// in this case.
                                    /// </summary>
                                    if (sig == 0)
                                    {
                                        /// <summary>
                                        /// The last signature we looked at was the ship emitting an EM sig, and this one is not.
                                        /// Mark the entire group as "spotted" because no other detection will occur.
                                        /// </summary>
                                        if (TaskGroupToTest.Ships[node.Next.Value].EMDetection[FactionID] == GameState.Instance.CurrentSecond)
                                        {
                                            System.FactionDetectionLists[FactionID].EM[detListIterator] = GameState.Instance.CurrentSecond;
                                        }
                                        break;
                                    }

                                    if (CurrentTaskGroup.BestEMCount > 0)
                                    {
                                        detection = CurrentTaskGroup.BestEM.pSensorDef.GetPassiveDetectionRange(sig);
                                    }
                                    else
                                    {
                                        detection = ComponentList.DefaultPassives.GetPassiveDetectionRange(sig);
                                    }

                                    det = LargeDetection(dist, detection);

                                    if (det == true)
                                    {
                                        scratch.EMDetection[FactionID] = GameState.Instance.CurrentSecond;

                                        if (DetShipList.Contains(scratch) == false)
                                        {
                                            DetShipList.Add(scratch);
                                        }
                                    }
                                    else
                                    {
                                        done = true;
                                        break;
                                    }
                                }
                                if (node == TaskGroupToTest.EMSortList.First)
                                {
                                    /// <summary>
                                    /// This should not happen.
                                    /// </summary>
                                    String ErrorMessage = string.Format("Partial EM detect for TGs looped through every ship. {0} {1} {2} {3}", dist, detection, noDetection, allDetection);

                                    MessageEntry NMsg = new MessageEntry(MessageEntry.MessageType.Error, CurrentTaskGroup.Contact.Position.System, CurrentTaskGroup.Contact,
                                                                         GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, ErrorMessage);
                                    MessageLog.Add(NMsg);
                                    done = true;
                                    break;
                                }
                                node = node.Previous;
                            }
                        }
                    }
                    /// <summary>
                    /// End else
                    /// </summary>
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// TaskGroupThermal Detection runs the thermal detection routine on TaskGroupToTest from CurrentTaskGroup
        /// </summary>
        /// <param name="System">Current System this is taking place in.</param>
        /// <param name="CurrentTaskGroup">TaskGroup that is performing the sensor sweep.</param>
        /// <param name="TaskGroupToTest">TaskGroup being tested against.</param>
        /// <param name="dist">Distance between these two taskgroups.</param>
        /// <param name="detListIterator">Iterator for where the TaskGroupToTest is in the various detection lists and the system contact list.</param>
        /// <param name="DetShipList">If a ship is detected it must be put into this list for the detectedContactsList later on.</param>
        private void TaskGroupThermalDetection(StarSystem System, TaskGroupTN CurrentTaskGroup, TaskGroupTN TaskGroupToTest, float dist, int detListIterator)
        {
            if (System.FactionDetectionLists[FactionID].Thermal[detListIterator] != GameState.Instance.CurrentSecond)
            {
                int sig = -1;
                int detection = -1;
                bool noDetection = false;
                bool allDetection = false;
                /// <summary>
                /// Get the best detection range for thermal signatures in loop.
                /// </summary>
                int ShipID = TaskGroupToTest.ThermalSortList.Last();
                ShipTN scratch = TaskGroupToTest.Ships[ShipID];
                sig = scratch.CurrentThermalSignature;

                /// <summary>
                /// Check to make sure the taskgroup has a thermal sensor available, otherwise use the default.
                /// </summary>
                if (CurrentTaskGroup.BestThermalCount != 0)
                {
                    detection = CurrentTaskGroup.BestThermal.pSensorDef.GetPassiveDetectionRange(sig);
                }
                else
                {
                    detection = ComponentList.DefaultPassives.GetPassiveDetectionRange(sig);
                }

                /// <summary>
                /// Test the biggest signature against the best sensor.
                /// </summary>
                bool det = LargeDetection(dist, detection);

                /// <summary>
                /// Good case, none of the ships are detected.
                /// </summary>
                if (det == false)
                {
                    noDetection = true;
                }

                /// <summary>
                /// Atleast the biggest ship is detected.
                /// </summary
                if (noDetection == false)
                {
                    ShipID = TaskGroupToTest.ThermalSortList.First();
                    scratch = TaskGroupToTest.Ships[ShipID];
                    sig = scratch.CurrentThermalSignature;

                    /// <summary>
                    /// Check to make sure the taskgroup has a thermal sensor available, otherwise use the default.
                    /// </summary>
                    if (CurrentTaskGroup.BestThermalCount != 0)
                    {
                        detection = CurrentTaskGroup.BestThermal.pSensorDef.GetPassiveDetectionRange(sig);
                    }
                    else
                    {
                        detection = ComponentList.DefaultPassives.GetPassiveDetectionRange(sig);
                    }

                    /// <summary>
                    /// Now for the smallest vs the best.
                    /// </summary>
                    det = LargeDetection(dist, detection);

                    /// <summary>
                    /// Best case, everything is detected.
                    /// </summary>
                    if (det == true)
                    {
                        allDetection = true;

                        for (int loop3 = 0; loop3 < TaskGroupToTest.Ships.Count; loop3++)
                        {
                            TaskGroupToTest.Ships[loop3].ThermalDetection[FactionID] = GameState.Instance.CurrentSecond;

                            if (DetShipList.Contains(TaskGroupToTest.Ships[loop3]) == false)
                            {
                                DetShipList.Add(TaskGroupToTest.Ships[loop3]);
                            }
                        }
                        System.FactionDetectionLists[FactionID].Thermal[detListIterator] = GameState.Instance.CurrentSecond;


                    }
                    else if (noDetection == false && allDetection == false)
                    {
                        /// <summary>
                        /// Worst case. some are detected, some aren't.
                        /// </summary>

                        for (int loop3 = 0; loop3 < TaskGroupToTest.Ships.Count; loop3++)
                        {
                            LinkedListNode<int> node = TaskGroupToTest.ThermalSortList.Last;
                            bool done = false;

                            while (!done)
                            {
                                scratch = TaskGroupToTest.Ships[node.Value];

                                if (scratch.ThermalDetection[FactionID] != GameState.Instance.CurrentSecond)
                                {
                                    sig = scratch.CurrentThermalSignature;
                                    if (CurrentTaskGroup.BestThermalCount != 0)
                                    {
                                        detection = CurrentTaskGroup.BestThermal.pSensorDef.GetPassiveDetectionRange(sig);
                                    }
                                    else
                                    {
                                        detection = ComponentList.DefaultPassives.GetPassiveDetectionRange(sig);
                                    }

                                    /// <summary>
                                    /// Test each ship until I get to one I don't see.
                                    /// </summary>
                                    det = LargeDetection(dist, detection);

                                    if (det == true)
                                    {
                                        scratch.ThermalDetection[FactionID] = GameState.Instance.CurrentSecond;

                                        if (DetShipList.Contains(scratch) == false)
                                        {
                                            DetShipList.Add(scratch);
                                        }
                                    }
                                    else
                                    {
                                        done = true;
                                        break;
                                    }
                                }
                                if (node == TaskGroupToTest.ThermalSortList.First)
                                {
                                    /// <summary>
                                    /// This should not happen.
                                    /// </summary>
                                    String ErrorMessage = string.Format("Partial Thermal detect for TGs looped through every ship. {0} {1} {2} {3}", dist, detection, noDetection, allDetection);
                                    MessageEntry NMsg = new MessageEntry(MessageEntry.MessageType.Error, TaskGroupToTest.Contact.Position.System, TaskGroupToTest.Contact,
                                                                         GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, ErrorMessage);
                                    MessageLog.Add(NMsg);
                                    done = true;
                                    break;
                                }
                                node = node.Previous;
                            }
                        }
                    }
                    /// <summary>
                    /// End else
                    /// </summary>
                }
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Adds a TG to the fleet intercept preempt list.
 /// </summary>
 /// <param name="TG">taskgroup to be added</param>
 public void AddFleetToPreemptList(TaskGroupTN TG)
 {
     FleetInterceptPreemptList.Add(TG);
 }
Esempio n. 13
0
        /// <summary>
        /// Determines if a TaskGroup has the ability to jump through this JumpPoint.
        /// Ensures a connection, and checks Gate, Gate Ownership, and JumpDrives.
        /// </summary>
        /// <param name="TransitTG">TG requesting Transit.</param>
        /// <param name="IsStandardTransit">True if StandardTransit, False if SquadronTransit</param>
        /// <returns>True if TG is capable of doing this jump.</returns>
        public bool CanJump(TaskGroupTN TransitTG, bool IsStandardTransit, out Dictionary<JumpEngineTN,ShipTN> usedJumpEngines)
        {
            usedJumpEngines = null;

            // Ensure we have a connection, if not create one.
            if (Connect == null)
            {
                CreateConnection();
            }

            if (IsGated && IsStandardTransit == true)
            {
                if (Constants.GameSettings.AllowHostileGateJump || AllowHostileJumps)
                {
                    // Gate/Game settings are not setup to allow blocking of hostiles.
                    return true;
                }
                if (GateOwner == null || GateOwner == TransitTG.TaskGroupFaction)
                {
                    // Nobody owns the gate, or we do, allow the jump.
                    ///< @todo Check if a friendly faction owns the gate, and allow.
                    return true;
                }
            }
            
            /// <summary>
            /// jump Transit code:
            /// </summary>
            int ComCount = 0;
            int MilCount = 0;
            float ComMaxHS = 0;
            float MilMaxHS = 0;
            int MilAccom = 0;
            int ComAccom = 0;
            

            /// <summary>
            /// For every ship:
            /// How many of each type of ship are there?
            /// What are the largest ship sizes in HS?
            /// Go through every jump engine
            /// Is this jump engine ready?
            /// Can this jump engine accomodate the other ships in the taskgroup?
            /// </summary>
            TransitTG.CountShips(out MilCount, out ComCount, out MilMaxHS, out ComMaxHS);

            /// <summary>
            /// if one ship can be accomodated all can be.
            /// </summary>
            if (IsStandardTransit == true)
            {
                if(MilCount > 1)
                    MilCount = 1;
                if(ComCount > 1)
                    ComCount = 1;
            }

            TransitTG.GetJDAccom(MilMaxHS, MilCount, ComMaxHS, ComCount, out MilAccom, out ComAccom, out usedJumpEngines);

            /// <summary>
            /// This jump can happen.
            /// </summary>
            if (MilAccom >= MilCount && ComAccom >= ComCount)
            {
                return true;
            }
            
            /// <summary>
            /// Something caused this jump to fail, will need to find out what for the faction messagelog though.
            /// </summary>
            return false;
        }
Esempio n. 14
0
        /// <summary>
        /// Constructor for TaskGroup related orders
        /// </summary>
        /// <param name="TypeOrder">Type</param>
        /// <param name="SecondaryOrder">Any secondary order specification such as installation type.</param>
        /// <param name="TertiaryOrder"> Any Tertiary order such as limits.</param>
        /// <param name="Delay">Delay in seconds before performing this order.</param>
        /// <param name="TaskGroupOrder">The TaskGroup in question.</param>
        public Order(Constants.ShipTN.OrderType TypeOrder, int SecondaryOrder, int TertiaryOrder, int Delay, TaskGroupTN TaskGroupOrder)
        {
            TypeOf = TypeOrder;
            Target = TaskGroupOrder.Contact;
            Secondary = SecondaryOrder;
            Tertiary = TertiaryOrder;
            TaskGroup = TaskGroupOrder;
            OrderDelay = Delay;

            OrderTimeRequirement = -1;

            Name = TypeOrder.ToString() + " " + TaskGroupOrder.Name.ToString();
        }
Esempio n. 15
0
        public void testASensor()
        {

            Faction newFaction = new Faction(0);

            StarSystem System1 = SystemGen.CreateSol();

            SystemBody pl1 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            System1.Stars[0].Planets.Add(pl1);

            TaskGroupTN newTG = new TaskGroupTN("TG", newFaction, System1.Stars[0].Planets[0], System1);

            ShipClassTN ts2 = new ShipClassTN("Test", newFaction);
            ShipTN ts = new ShipTN(ts2, 0, 0, newTG, newFaction, "Test Ship");

            ActiveSensorDefTN ASensorDefTest = new ActiveSensorDefTN("Active Search Sensor MR705-R185", 6.0f, 36, 24, 185, false, 1.0f, 1);

            ts2.ShipASensorDef = new BindingList<ActiveSensorDefTN>();
            ts2.ShipASensorCount = new BindingList<ushort>();
            ts2.ShipASensorDef.Add(ASensorDefTest);
            ts2.ShipASensorCount.Add(1);

            ActiveSensorTN ASensorTest = new ActiveSensorTN(ts2.ShipASensorDef[0]);

            ts.ShipASensor = new BindingList<ActiveSensorTN>();
            ts.ShipASensor.Add(ASensorTest);


            ActiveSensorDefTN tst3 = ts.ShipASensor[0].aSensorDef;

            Console.WriteLine("Name: {0}", tst3.Name);
            Console.WriteLine("Size: {0}, HTK: {1}, Hardening: {2}", tst3.size, tst3.htk, tst3.hardening);
            Console.WriteLine("GPS: {0}, Range: {1}", tst3.gps, tst3.maxRange);
            Console.WriteLine("IsMilitary: {0}", tst3.isMilitary);
            Console.WriteLine("Crew: {0}", tst3.crew);
            Console.WriteLine("Cost: {0}", tst3.cost);

            for (ushort loop = 80; loop < 120; loop++)
            {
                Console.WriteLine("Resolution:{0} Detection Range in KM:{1}", loop, tst3.GetActiveDetectionRange(loop, -1));
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Taskgroup active detection will handle the active detection sensor sweeps, Resolution represents the biggest difference for TG Active detection vs passive detection.
        /// There isn't simply a best active sensor, and the correct one has to be searched for. luckily that work is already done by the taskgroup itself.
        /// </summary>
        /// <param name="System">Current System.</param>
        /// <param name="CurrentTaskGroup">Scanning Taskgroup</param>
        /// <param name="TaskGroupToTest">Taskgroup to test if detected.</param>
        /// <param name="dist">Distance between the two taskgroups</param>
        /// <param name="detListIterator">location of the test taskgroup in the detection lists</param>
        private void TaskGroupActiveDetection(StarSystem System, TaskGroupTN CurrentTaskGroup, TaskGroupTN TaskGroupToTest, float dist, int detListIterator)
        {
            if (System.FactionDetectionLists[FactionID].Active[detListIterator] != GameState.Instance.CurrentSecond && CurrentTaskGroup.ActiveSensorQue.Count > 0)
            {
                int sig = -1;
                int detection = -1;
                bool noDetection = false;
                bool allDetection = false;

                /// <summary>
                /// Get the best detection range for thermal signatures in loop.
                /// </summary>
                int ShipID = TaskGroupToTest.ActiveSortList.Last();
                ShipTN scratch = TaskGroupToTest.Ships[ShipID];
                sig = scratch.TotalCrossSection - 1;

                if (sig > Constants.ShipTN.ResolutionMax - 1)
                    sig = Constants.ShipTN.ResolutionMax - 1;

                detection = CurrentTaskGroup.ActiveSensorQue[CurrentTaskGroup.TaskGroupLookUpST[sig]].aSensorDef.GetActiveDetectionRange(sig, -1);

                bool det = LargeDetection(dist, detection);

                /// <summary>
                /// Good case, none of the ships are detected.
                /// </summary>
                if (det == false)
                {
                    noDetection = true;
                }

                /// <summary>
                /// Atleast the biggest ship is detected.
                /// </summary
                if (noDetection == false)
                {
                    ShipID = TaskGroupToTest.ActiveSortList.First();
                    scratch = TaskGroupToTest.Ships[ShipID];
                    sig = scratch.TotalCrossSection - 1;

                    if (sig > Constants.ShipTN.ResolutionMax - 1)
                        sig = Constants.ShipTN.ResolutionMax - 1;

                    detection = CurrentTaskGroup.ActiveSensorQue[CurrentTaskGroup.TaskGroupLookUpST[sig]].aSensorDef.GetActiveDetectionRange(sig, -1);

                    det = LargeDetection(dist, detection);

                    /// <summary>
                    /// Best case, everything is detected.
                    /// </summary>
                    if (det == true)
                    {
                        allDetection = true;

                        for (int loop3 = 0; loop3 < TaskGroupToTest.Ships.Count; loop3++)
                        {
                            TaskGroupToTest.Ships[loop3].ActiveDetection[FactionID] = GameState.Instance.CurrentSecond;

                            if (DetShipList.Contains(TaskGroupToTest.Ships[loop3]) == false)
                            {
                                DetShipList.Add(TaskGroupToTest.Ships[loop3]);
                            }
                        }
                        /// <summary>
                        /// FactionSystemDetection entry. I hope to deprecate this at some point.
                        /// Be sure to erase the factionDetectionSystem entry first, to track down everywhere this overbloated thing is.
                        /// update, not happening. FactionDetectionList is too important.
                        /// </summary>
                        System.FactionDetectionLists[FactionID].Active[detListIterator] = GameState.Instance.CurrentSecond;
                    }
                    else if (noDetection == false && allDetection == false)
                    {
                        /// <summary>
                        /// Worst case. some are detected, some aren't.
                        /// </summary>


                        for (int loop3 = 0; loop3 < TaskGroupToTest.Ships.Count; loop3++)
                        {
                            LinkedListNode<int> node = TaskGroupToTest.ActiveSortList.Last;
                            bool done = false;

                            while (!done)
                            {
                                scratch = TaskGroupToTest.Ships[node.Value];

                                if (scratch.ActiveDetection[FactionID] != GameState.Instance.CurrentSecond)
                                {
                                    sig = scratch.TotalCrossSection - 1;

                                    if (sig > Constants.ShipTN.ResolutionMax - 1)
                                        sig = Constants.ShipTN.ResolutionMax - 1;

                                    detection = CurrentTaskGroup.ActiveSensorQue[CurrentTaskGroup.TaskGroupLookUpST[sig]].aSensorDef.GetActiveDetectionRange(sig, -1);

                                    det = LargeDetection(dist, detection);

                                    if (det == true)
                                    {
                                        scratch.ActiveDetection[FactionID] = GameState.Instance.CurrentSecond;

                                        if (DetShipList.Contains(scratch) == false)
                                        {
                                            DetShipList.Add(scratch);
                                        }
                                    }
                                    else
                                    {
                                        done = true;
                                        break;
                                    }
                                }
                                if (node == TaskGroupToTest.ActiveSortList.First)
                                {
                                    /// <summary>
                                    /// This should not happen.
                                    /// </summary>
                                    String ErrorMessage = string.Format("Partial Active detect for TGs looped through every ship. {0} {1} {2} {3}", dist, detection, noDetection, allDetection);

                                    MessageEntry NMsg = new MessageEntry(MessageEntry.MessageType.Error, CurrentTaskGroup.Contact.Position.System, CurrentTaskGroup.Contact,
                                                                         GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, ErrorMessage);
                                    MessageLog.Add(NMsg);
                                    done = true;
                                    break;
                                }
                                node = node.Previous;
                            }
                        }
                    }
                    /// <summary>
                    /// End else
                    /// </summary>
                }
            }
        }
Esempio n. 17
0
        public void testShip()
        {
            Faction newFaction = new Faction(0);

            /// <summary>
            /// These would go into a faction component list I think
            /// </summary>
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);
            ActiveSensorDefTN ActDef = new ActiveSensorDefTN("Search 5M - 5000", 1.0f, 10, 5, 100, false, 1.0f, 1);
            PassiveSensorDefTN ThPasDef = new PassiveSensorDefTN("Thermal Sensor TH1-5", 1.0f, 5, PassiveSensorType.Thermal, 1.0f, 1);
            PassiveSensorDefTN EMPasDef = new PassiveSensorDefTN("EM Sensor EM1-5", 1.0f, 5, PassiveSensorType.EM, 1.0f, 1);

            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.0m, ComponentTypeTN.Fuel);
            GeneralComponentDefTN EBay = new GeneralComponentDefTN("Engineering Spaces", 1.0f, 5, 10.0m, ComponentTypeTN.Engineering);
            GeneralComponentDefTN Bridge = new GeneralComponentDefTN("Bridge", 1.0f, 5, 10.0m, ComponentTypeTN.Bridge);

            ShipClassTN TestClass = new ShipClassTN("Test Ship Class", newFaction);

            TestClass.AddCrewQuarters(CrewQ, 2);
            TestClass.AddFuelStorage(FuelT, 2);
            TestClass.AddEngineeringSpaces(EBay, 2);
            TestClass.AddOtherComponent(Bridge, 1);

            TestClass.AddEngine(EngDef, 1);

            TestClass.AddPassiveSensor(ThPasDef, 1);
            TestClass.AddPassiveSensor(EMPasDef, 1);

            TestClass.AddActiveSensor(ActDef, 1);

            Console.WriteLine("Size: {0}, Crew: {1}, Cost: {2}, HTK: {3}, Tonnage: {4}", TestClass.SizeHS, TestClass.TotalRequiredCrew, TestClass.BuildPointCost, TestClass.TotalHTK, TestClass.SizeTons);

            Console.WriteLine("HS Accomodations/Required: {0}/{1}, Total Fuel Capacity: {2}, Total MSP: {3}, Engineering percentage: {4}, Has Bridge: {5}, Total Required Crew: {6}", TestClass.AccomHSAvailable, TestClass.AccomHSRequirement,
            TestClass.TotalFuelCapacity, TestClass.TotalMSPCapacity, (TestClass.EngineeringHS / TestClass.SizeHS), TestClass.HasBridge, TestClass.TotalRequiredCrew);

            Console.WriteLine("Armor Size: {0}, Cost: {1}", TestClass.ShipArmorDef.size, TestClass.ShipArmorDef.cost);

            Console.WriteLine("Ship Engine Power: {0}, Ship Thermal Signature: {1}, Ship Fuel Use Per Hour: {2}", TestClass.MaxEnginePower, TestClass.MaxThermalSignature, TestClass.MaxFuelUsePerHour);

            Console.WriteLine("Best TH: {0}, BestEM: {1}, Max EM Signature: {2}, Total Cross Section: {3}", TestClass.BestThermalRating, TestClass.BestEMRating, TestClass.MaxEMSignature, TestClass.TotalCrossSection);

            TestClass.AddCrewQuarters(CrewQ, -1);

            Console.WriteLine("Size: {0}, Crew: {1}, Cost: {2}, HTK: {3}, Tonnage: {4}", TestClass.SizeHS, TestClass.TotalRequiredCrew, TestClass.BuildPointCost, TestClass.TotalHTK, TestClass.SizeTons);

            Console.WriteLine("HS Accomodations/Required: {0}/{1}, Total Fuel Capacity: {2}, Total MSP: {3}, Engineering percentage: {4}, Has Bridge: {5}, Total Required Crew: {6}", TestClass.AccomHSAvailable, TestClass.AccomHSRequirement,
            TestClass.TotalFuelCapacity, TestClass.TotalMSPCapacity, (TestClass.EngineeringHS / TestClass.SizeHS), TestClass.HasBridge, TestClass.TotalRequiredCrew);

            Console.WriteLine("Armor Size: {0}, Cost: {1}", TestClass.ShipArmorDef.size, TestClass.ShipArmorDef.cost);

            Console.WriteLine("Ship Engine Power: {0}, Ship Thermal Signature: {1}, Ship Fuel Use Per Hour: {2}", TestClass.MaxEnginePower, TestClass.MaxThermalSignature, TestClass.MaxFuelUsePerHour);

            Console.WriteLine("Best TH: {0}, BestEM: {1}, Max EM Signature: {2}, Total Cross Section: {3}", TestClass.BestThermalRating, TestClass.BestEMRating, TestClass.MaxEMSignature, TestClass.TotalCrossSection);

            TestClass.AddCrewQuarters(CrewQ, -1);

            Console.WriteLine("Size: {0}, Crew: {1}, Cost: {2}, HTK: {3}, Tonnage: {4}", TestClass.SizeHS, TestClass.TotalRequiredCrew, TestClass.BuildPointCost, TestClass.TotalHTK, TestClass.SizeTons);

            Console.WriteLine("HS Accomodations/Required: {0}/{1}, Total Fuel Capacity: {2}, Total MSP: {3}, Engineering percentage: {4}, Has Bridge: {5}, Total Required Crew: {6}", TestClass.AccomHSAvailable, TestClass.AccomHSRequirement,
            TestClass.TotalFuelCapacity, TestClass.TotalMSPCapacity, (TestClass.EngineeringHS / TestClass.SizeHS), TestClass.HasBridge, TestClass.TotalRequiredCrew);

            Console.WriteLine("Armor Size: {0}, Cost: {1}", TestClass.ShipArmorDef.size, TestClass.ShipArmorDef.cost);

            Console.WriteLine("Ship Engine Power: {0}, Ship Thermal Signature: {1}, Ship Fuel Use Per Hour: {2}", TestClass.MaxEnginePower, TestClass.MaxThermalSignature, TestClass.MaxFuelUsePerHour);

            Console.WriteLine("Best TH: {0}, BestEM: {1}, Max EM Signature: {2}, Total Cross Section: {3}", TestClass.BestThermalRating, TestClass.BestEMRating, TestClass.MaxEMSignature, TestClass.TotalCrossSection);


            TestClass.AddCrewQuarters(CrewQ, 2);

            StarSystem System1 = SystemGen.CreateSol();

            SystemBody pl1 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            System1.Stars[0].Planets.Add(pl1);

            TaskGroupTN newTG = new TaskGroupTN("TG", newFaction, System1.Stars[0].Planets[0], System1);


            ShipTN testShip = new ShipTN(TestClass, 0, 0, newTG, newFaction, "Test Ship");

            testShip.CrewQuarters[0].isDestroyed = true;

            for (int loop = 0; loop < testShip.CrewQuarters.Count; loop++)
            {
                Console.WriteLine("Crew Quarters {0} isDestroyed:{1}", loop + 1, testShip.CrewQuarters[loop].isDestroyed);
            }

            testShip.CrewQuarters[0].isDestroyed = false;

            Console.WriteLine("Engine Power/Fuel Usage/Thermal Signature/Speed: {0}/{1}/{2}/{3}", testShip.CurrentEnginePower, testShip.CurrentFuelUsePerHour, testShip.CurrentThermalSignature,
                testShip.CurrentSpeed);

            testShip.SetSpeed(1000);

            Console.WriteLine("Engine Power/Fuel Usage/Thermal Signature/Speed: {0}/{1}/{2}/{3}", testShip.CurrentEnginePower, testShip.CurrentFuelUsePerHour, testShip.CurrentThermalSignature,
                testShip.CurrentSpeed);

            Console.WriteLine("Current Crew/Fuel/MSP: {0}/{1}/{2}", testShip.CurrentCrew, testShip.CurrentFuel, testShip.CurrentMSP);

            int CrewSource = 100000;
            float FuelSource = 100000.0f;
            int MSPSource = 100000;

            CrewSource = testShip.Recrew(CrewSource);
            FuelSource = testShip.Refuel(FuelSource);
            MSPSource = testShip.Resupply(MSPSource);

            Console.WriteLine("Current Crew/Fuel/MSP: {0}/{1}/{2} Source: {3}/{4}/{5}", testShip.CurrentCrew, testShip.CurrentFuel, testShip.CurrentMSP, CrewSource, FuelSource, MSPSource);

            Console.WriteLine("Current EM Signature: {0}", testShip.CurrentEMSignature);


            bool isActive = true;
            testShip.SetSensor(testShip.ShipASensor[0], isActive);

            Console.WriteLine("Current EM Signature: {0}", testShip.CurrentEMSignature);

            isActive = false;
            testShip.SetSpeed(1500);
            testShip.SetSensor(testShip.ShipASensor[0], isActive);

            Console.WriteLine("Engine Power/Fuel Usage/Thermal Signature/Speed: {0}/{1}/{2}/{3}", testShip.CurrentEnginePower, testShip.CurrentFuelUsePerHour, testShip.CurrentThermalSignature,
                testShip.CurrentSpeed);
            Console.WriteLine("Current EM Signature: {0}", testShip.CurrentEMSignature);


        }
Esempio n. 18
0
 /// <summary>
 /// Adds a new taskgroup to the taskgroups list at location StartBody in System StartSystem.
 /// </summary>
 /// <param name="Title">Name.</param>
 /// <param name="StartBody">Body with population that built the ship that will be put into the TG.</param>
 /// <param name="StartSystem">System in which the TG starts in.</param>
 public void AddNewTaskGroup(String Title, OrbitingEntity StartBody, StarSystem StartSystem)
 {
     TaskGroupTN TG = new TaskGroupTN(Title, this, StartBody, StartSystem);
     TaskGroups.Add(TG);
 }
Esempio n. 19
0
        public void TGPassivesTest()
        {
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);
            PassiveSensorDefTN ThPasDef1 = new PassiveSensorDefTN("Thermal Sensor TH1-5", 1.0f, 5, PassiveSensorType.Thermal, 1.0f, 1);
            PassiveSensorDefTN ThPasDef2 = new PassiveSensorDefTN("Thermal Sensor TH1-6", 1.0f, 6, PassiveSensorType.Thermal, 1.0f, 1);
            PassiveSensorDefTN ThPasDef3 = new PassiveSensorDefTN("Thermal Sensor TH1-8", 1.0f, 8, PassiveSensorType.Thermal, 1.0f, 1);
            PassiveSensorDefTN ThPasDef4 = new PassiveSensorDefTN("Thermal Sensor TH1-11", 1.0f, 11, PassiveSensorType.Thermal, 1.0f, 1);


            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.0m, ComponentTypeTN.Fuel);
            GeneralComponentDefTN EBay = new GeneralComponentDefTN("Engineering Spaces", 1.0f, 5, 10.0m, ComponentTypeTN.Engineering);
            GeneralComponentDefTN Bridge = new GeneralComponentDefTN("Bridge", 1.0f, 5, 10.0m, ComponentTypeTN.Bridge);

            Faction FID = new Faction(0);
            StarSystem System = SystemGen.CreateSol();
            SystemBody planet = new SystemBody(System.Stars[0], SystemBody.PlanetType.Terrestrial);;
            System.Stars[0].Planets.Add(planet);

            TaskGroupTN TaskGroup1 = new TaskGroupTN("Taskforce 001", FID, planet, System);
            for (int loop = 0; loop < 4; loop++)
            {


                ShipClassTN test = new ShipClassTN("Ship", FID);
                test.AddCrewQuarters(CrewQ, 2);
                test.AddFuelStorage(FuelT, 2);
                test.AddEngineeringSpaces(EBay, 2);
                test.AddOtherComponent(Bridge, 1);

                switch (loop)
                {
                    case 0: test.AddPassiveSensor(ThPasDef2, 5);
                        break;
                    case 1: test.AddPassiveSensor(ThPasDef1, 4);
                        break;
                    case 2: test.AddPassiveSensor(ThPasDef3, 7);
                        break;
                    case 3: test.AddPassiveSensor(ThPasDef4, 6);
                        break;
                }

                TaskGroup1.AddShip(test, "Test Ship");
                Console.WriteLine("Best Thermal:{0},{1}", TaskGroup1.BestThermal.pSensorDef.rating, TaskGroup1.BestThermalCount);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// creates a list of orders by creating a union and intersection of other lists.
        /// </summary>
        /// <param name="thisTG"></param>
        /// <param name="targetEntity"></param>
        /// <param name="previousOrders"></param>
        /// <returns></returns>
        private List<Constants.ShipTN.OrderType> legalOrders(TaskGroupTN thisTG, StarSystemEntity targetEntity, List<Order> previousOrders)
        {
            List<Constants.ShipTN.OrderType> thisTGLegalOrders = new List<Constants.ShipTN.OrderType>();
            List<Constants.ShipTN.OrderType> additionalOrders = new List<Constants.ShipTN.OrderType>();
            List<Constants.ShipTN.OrderType> targetEntityLegalOrders = targetEntity.LegalOrders(CurrentTaskGroup.TaskGroupFaction);

            if (!m_oTaskGroupPanel.OrderFilteringCheckBox.Checked)
            {
                thisTGLegalOrders = Enum.GetValues(typeof(Constants.ShipTN.OrderType)).Cast<Constants.ShipTN.OrderType>().ToList();
            }
            else
            {
                thisTGLegalOrders = thisTG.LegalOrdersTG();
                foreach (var order in previousOrders)
                {
                    additionalOrders = additionalOrders.Union(order.EnablesTypeOf()).ToList();
                }
                thisTGLegalOrders = thisTGLegalOrders.Union(additionalOrders).ToList();
            }

            //it still needs to do an intersect with the targetEntityLegalOrders, regardless of filtering.
            thisTGLegalOrders = thisTGLegalOrders.Intersect(targetEntityLegalOrders).ToList();

            return thisTGLegalOrders;
        }
Esempio n. 21
0
        public void TGOrdersTest()
        {
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);

            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.0m, ComponentTypeTN.Fuel);
            GeneralComponentDefTN EBay = new GeneralComponentDefTN("Engineering Spaces", 1.0f, 5, 10.0m, ComponentTypeTN.Engineering);
            GeneralComponentDefTN Bridge = new GeneralComponentDefTN("Bridge", 1.0f, 5, 10.0m, ComponentTypeTN.Bridge);


            Faction FID = new Faction(0); 
            StarSystem System = SystemGen.CreateSol();
            SystemBody planet = new SystemBody(System.Stars[0], SystemBody.PlanetType.Terrestrial);;
            System.Stars[0].Planets.Add(planet);


            Waypoint WP1 = new Waypoint("WP TG Orders", System, 0.1, 0.1, 0);

            planet.Position.X = 0.0;
            planet.Position.Y = 0.0;


            TaskGroupTN TaskGroup1 = new TaskGroupTN("Taskforce 001", FID, planet, System);

            ShipClassTN test = new ShipClassTN("Ship", FID);
            test.AddCrewQuarters(CrewQ, 2);
            test.AddFuelStorage(FuelT, 2);
            test.AddEngineeringSpaces(EBay, 2);
            test.AddOtherComponent(Bridge, 1);
            test.AddEngine(EngDef, 1);

            TaskGroup1.AddShip(test, "Test Ship");

            TaskGroup1.Ships[0].Refuel(200000.0f);

            Order TGOrder = new Order(Constants.ShipTN.OrderType.MoveTo, -1, -1, 0, WP1);

            TaskGroup1.IssueOrder(TGOrder);

            Console.WriteLine("Fuel Remaining:{0}", TaskGroup1.Ships[0].CurrentFuel);

            while (TaskGroup1.TaskGroupOrders.Count != 0)
            {
                TaskGroup1.FollowOrders(5);
                Console.WriteLine("{0} {1} | {2} {3}", Distance.ToKm(TaskGroup1.Contact.Position.X), Distance.ToKm(TaskGroup1.Contact.Position.Y), TaskGroup1.Contact.Position.X, TaskGroup1.Contact.Position.Y);
            }

            Console.WriteLine("Fuel Remaining:{0}", TaskGroup1.Ships[0].CurrentFuel);
        }
Esempio n. 22
0
        /// <summary>
        /// Given a ship in this taskgroup, transfer said ship to TaskGroupTo
        /// </summary>
        /// <param name="Ship">Ship present in this taskgroup that should be transfered</param>
        /// <param name="TaskGroupTo">Taskgroup that will receive this ship</param>
        public void TransferShipToTaskGroup(ShipTN Ship, TaskGroupTN TaskGroupTo)
        {
            /// <summary>
            /// This ship is not in the taskgroup so return immediately.
            /// </summary>
            if (Ships.Contains(Ship) == false)
                return;

            BindingList<int> activeSensorIndices = new BindingList<int>();
            for (int activeIterator = 0; activeIterator < Ship.ShipASensor.Count; activeIterator++)
            {
                /// <summary>
                /// This active sensor is both active and intact, so preserve its index, and set isActive to false(the sensor will be reactivated in its new TG.
                /// Destroyed sensors can keep their isActive state, as when they are repaired the repair function should handle reactivating them.
                /// </summary>
                if (Ship.ShipASensor[activeIterator].isActive == true && Ship.ShipASensor[activeIterator].isDestroyed == false)
                {
                    activeSensorIndices.Add(activeIterator);
                    Ship.ShipASensor[activeIterator].isActive = false;
                }
            }

            /// <summary>
            /// Move the ship between the two.
            /// </summary>
            RemoveShipFrom(Ship);
            TaskGroupTo.AddShipTo(Ship);

            /// <summary>
            /// reactivate any sensors that were active in the previous taskgroup.
            /// </summary>
            int ShipIndex = TaskGroupTo.Ships.IndexOf(Ship);
            foreach(int activeIndex in activeSensorIndices)
               TaskGroupTo.SetActiveSensor(ShipIndex, activeIndex, true);
        }