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); }
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); }
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)); } }
/// <summary> /// Adds a ship to a taskgroup, will call sorting and sensor handling. /// </summary> /// <param name="shipDef">definition of the ship to be added.</param> public void AddShip(ShipClassTN shipDef, String Title) { ShipTN ship = new ShipTN(shipDef, Ships.Count, GameState.Instance.CurrentSecond, this, TaskGroupFaction, Title); Ships.Add(ship); /// <summary> /// Refuel and ReCrew this ship here? /// </summary> if (Ships.Count == 1) { MaxSpeed = ship.ShipClass.MaxSpeed; CurrentSpeed = MaxSpeed; } else { if (ship.ShipClass.MaxSpeed < MaxSpeed) { MaxSpeed = ship.ShipClass.MaxSpeed; CurrentSpeed = MaxSpeed; } } for (int loop = 0; loop < Ships.Count; loop++) { Ships[loop].SetSpeed(CurrentSpeed); } TotalCargoTonnage = TotalCargoTonnage + shipDef.TotalCargoCapacity; TotalCryoCapacity = TotalCryoCapacity + shipDef.SpareCryoBerths; UpdatePassiveSensors(ship); AddShipToSort(ship); /// <summary> /// Let the UI know it should re check this taskgroup's sensors. /// </summary> SensorUpdateAck++; }
/// <summary> /// Set the activity that this shipyard complex will undertake. /// </summary> /// <param name="NewActivity">New Activity to perform.</param> /// <param name="RetoolTarget">Retool target if any</param> /// <param name="CapLimit">Capacity Expansion Limit if any.</param> public void SetShipyardActivity(Faction CurrentFaction, Constants.ShipyardInfo.ShipyardActivity NewActivity, ShipClassTN RetoolTarget = null, int CapLimit = -1) { decimal[] mCost = new decimal[(int)Constants.Minerals.MinerialNames.MinerialCount]; float DaysInYear = (float)Constants.TimeInSeconds.RealYear / (float)Constants.TimeInSeconds.Day; /// <summary> /// These are declared here since each switch case is considered to be on the same level of scope and just putting them in the first case doesn't seem quite right. /// </summary> float YearsOfProduction = 0.0f; int TimeToBuild = 0; DateTime EstTime; TimeSpan TS; /// <summary> /// If an order for adding a set amount of tons is canceled while in progress, credit the tons that were built to the shipyard. /// </summary> if(CurrentActivity.Progress != 0.0m && CurrentActivity.Activity != Constants.ShipyardInfo.ShipyardActivity.NoActivity) { int TonsToAdd = 0; switch (CurrentActivity.Activity) { case Constants.ShipyardInfo.ShipyardActivity.Add500Tons: TonsToAdd = (int)Math.Round((float)CurrentActivity.Progress * 500.0f); break; case Constants.ShipyardInfo.ShipyardActivity.Add1000Tons: TonsToAdd = (int)Math.Round((float)CurrentActivity.Progress * 1000.0f); break; case Constants.ShipyardInfo.ShipyardActivity.Add2000Tons: TonsToAdd = (int)Math.Round((float)CurrentActivity.Progress * 2000.0f); break; case Constants.ShipyardInfo.ShipyardActivity.Add5000Tons: TonsToAdd = (int)Math.Round((float)CurrentActivity.Progress * 5000.0f); break; case Constants.ShipyardInfo.ShipyardActivity.Add10000Tons: TonsToAdd = (int)Math.Round((float)CurrentActivity.Progress * 10000.0f); break; } if (TonsToAdd != 0) { AddTonnage(CurrentFaction, Tonnage); } } switch (NewActivity) { case Constants.ShipyardInfo.ShipyardActivity.AddSlipway: decimal TotalSlipwayCost = 0.0m; for (int MineralIterator = 0; MineralIterator < Constants.Minerals.NO_OF_MINERIALS; MineralIterator++) { if (Constants.ShipyardInfo.MineralCostOfExpansion[MineralIterator] != 0) { int Adjustment = 1; if (ShipyardType == Constants.ShipyardInfo.SYType.Naval) Adjustment = 10; /// <summary> /// Formula for tonnage expansion. This also appears in the constants file for now. /// </summary> decimal value = Constants.ShipyardInfo.MineralCostOfExpansion[MineralIterator] * (Tonnage / Constants.ShipyardInfo.TonnageDenominator) * Slipways * Adjustment; mCost[MineralIterator] = value; TotalSlipwayCost = TotalSlipwayCost + value; } } YearsOfProduction = (float)TotalSlipwayCost / CalcAnnualSYProduction(); EstTime = GameState.Instance.GameDateTime; if (YearsOfProduction < Constants.Colony.TimerYearMax) { TimeToBuild = (int)Math.Floor(YearsOfProduction * DaysInYear); TS = new TimeSpan(TimeToBuild, 0, 0, 0); EstTime = EstTime.Add(TS); } CurrentActivity = new ShipyardActivity(NewActivity, TotalSlipwayCost, mCost, EstTime); break; case Constants.ShipyardInfo.ShipyardActivity.Add500Tons: SetExpansion(NewActivity, 500, mCost, DaysInYear); break; case Constants.ShipyardInfo.ShipyardActivity.Add1000Tons: SetExpansion(NewActivity, 1000, mCost, DaysInYear); break; case Constants.ShipyardInfo.ShipyardActivity.Add2000Tons: SetExpansion(NewActivity, 2000, mCost, DaysInYear); break; case Constants.ShipyardInfo.ShipyardActivity.Add5000Tons: SetExpansion(NewActivity, 5000, mCost, DaysInYear); break; case Constants.ShipyardInfo.ShipyardActivity.Add10000Tons: SetExpansion(NewActivity, 10000, mCost, DaysInYear); break; case Constants.ShipyardInfo.ShipyardActivity.Retool: /// <summary> /// One free retool. Hypothetically this shipyard was built with this shipclass in mind. /// </summary> if (AssignedClass == null && RetoolTarget != null) { AssignedClass = RetoolTarget; if (AssignedClass.IsLocked == false) AssignedClass.IsLocked = true; } /// <summary> /// Lengthy retool process as the shipyard converts to build the new vessel. /// </summary> else if(AssignedClass != null && RetoolTarget != null) { /// <summary> /// Caclulate the cost of this retool: /// </summary> decimal CostToRetool = 0.5m * RetoolTarget.BuildPointCost + ((0.25m * RetoolTarget.BuildPointCost) * Slipways); mCost[(int)Constants.Minerals.MinerialNames.Duranium] = CostToRetool / 2.0m; mCost[(int)Constants.Minerals.MinerialNames.Neutronium] = CostToRetool / 2.0m; /// <summary> /// How long will this retool take? /// </summary> YearsOfProduction = (float)CostToRetool / CalcAnnualSYProduction(); EstTime = GameState.Instance.GameDateTime; if (YearsOfProduction < Constants.Colony.TimerYearMax) { TimeToBuild = (int)Math.Floor(YearsOfProduction * DaysInYear); TS = new TimeSpan(TimeToBuild, 0, 0, 0); EstTime = EstTime.Add(TS); } CurrentActivity = new ShipyardActivity(NewActivity, CostToRetool, mCost, EstTime, RetoolTarget); if (RetoolTarget.IsLocked == false) RetoolTarget.IsLocked = true; } break; case Constants.ShipyardInfo.ShipyardActivity.CapExpansion: CurrentActivity = new ShipyardActivity(NewActivity); break; case Constants.ShipyardInfo.ShipyardActivity.CapExpansionUntilX: if (CapLimit > Tonnage) { SetExpansion(NewActivity, (CapLimit - Tonnage), mCost, DaysInYear); CurrentActivity.CapExpansionLimit = CapLimit; } break; } }
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; } }
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); } }
/// <summary> /// New ship class button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewButton_Click(object sender, EventArgs e) { ShipClassTN oNewShipClass = new ShipClassTN("New Class", VM.CurrentFaction); oNewShipClass.AddCrewQuarters(_CurrnetFaction.ComponentList.CrewQuarters[0], 1); oNewShipClass.AddFuelStorage(_CurrnetFaction.ComponentList.FuelStorage[0], 1); oNewShipClass.AddEngineeringSpaces(_CurrnetFaction.ComponentList.EngineeringSpaces[0], 1); oNewShipClass.AddOtherComponent(_CurrnetFaction.ComponentList.OtherComponents[0], 1); int ArmorTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.ArmourProtection]; #warning throw error here if this happens instead of just capping at 12? if (ArmorTech > 12) ArmorTech = 12; String Title = UIConstants.Armor.ArmorTypes[ArmorTech]; oNewShipClass.NewArmor(Title, (ushort)Constants.MagazineTN.MagArmor[ArmorTech], oNewShipClass.ShipArmorDef.depth); _CurrnetFaction.ShipDesigns.Add(oNewShipClass); m_oOptionsPanel.ClassComboBox.SelectedIndex = m_oOptionsPanel.ClassComboBox.Items.Count - 1; _CurrnetShipClass = _CurrnetFaction.ShipDesigns[m_oOptionsPanel.ClassComboBox.SelectedIndex]; UpdateDisplay(); }
public void AddNewShipDesign(String Title) { ShipClassTN Ship = new ShipClassTN(Title, this); ShipDesigns.Add(Ship); }
/// <summary> /// GetRefitCost determines how much a refit from this shipclass to CompareClass will cost. /// </summary> /// <param name="CompareClass">Shipclass to compare this one to. the refit target in other words.</param> /// <param name="RefitThreshold">Eligible class calculation imposes a threshold on the refit cost which allows me to short circuit GetRefitCost if it is exceeded. do not include this variable /// if you just want the refit cost.</param> /// <returns>Refit cost.</returns> public decimal GetRefitCost(ShipClassTN CompareClass, decimal RefitThreshold = -1.0m) { /// <summary> /// overhead is 1/4th the component difference cost in BP /// components taken out are free /// components put in are not. /// if armor is of a different type then update with the cost of the whole new armor /// 5 BP per 1 HS difference /// compare the costs. for a refit /// if the cost is 20% of the overall cost of the ship the class is eligible. /// </summary> decimal TotalRefitCost = 0.0m; float SizeDiff = SizeHS - CompareClass.SizeHS; SizeDiff = Math.Abs(SizeDiff); decimal SizeDiffCost = (decimal)SizeDiff * 5.0m; TotalRefitCost += SizeDiffCost; /// <summary> /// size differential alone invalidates the eligibility of this class. most classes should be different enough in size for this to catch most cases. /// </summary> if (TotalRefitCost > RefitThreshold) return TotalRefitCost; /// <summary> /// Armour test: if armorPerHS is different, then two different types of armour are being used here and therefore armour must be part of the refit cost. /// if Armour is radically different then this should also throw out eligibility. /// </summary> if (ShipArmorDef.armorPerHS != CompareClass.ShipArmorDef.armorPerHS) { TotalRefitCost = TotalRefitCost + CompareClass.ShipArmorDef.cost; if (TotalRefitCost > RefitThreshold) return TotalRefitCost; } /// <summary> /// Iterate through every component and determine which components must be added to the new class for a refit. If the cost goes above the refit threshold however, then /// this class is not an eligible class as far as the shipyard is concerned. /// </summary> for (int componentIterator = 0; componentIterator < CompareClass.ListOfComponentDefs.Count; componentIterator++) { ComponentDefTN TestComponent = CompareClass.ListOfComponentDefs[componentIterator]; int TestComponentCount = CompareClass.ListOfComponentDefsCount[componentIterator]; int index = ListOfComponentDefs.IndexOf(TestComponent); /// <summary> /// Both AssignedClass and CurrentClass have the same component definition if index is not -1. /// </summary> if (index != -1) { /// <summary> /// If the assignedClass has more components or an equal number of components then it is not necessary to add any of said component to the total refit cost. /// otherwise this must be done. /// </summary> if (ListOfComponentDefsCount[index] < TestComponentCount) { /// <summary> /// If CurrentClass has 3 of this component, and Assigned class has only 1, then 2 must be added via refit. /// </summary> decimal CurrentComponentCost = TestComponent.cost * (TestComponentCount - ListOfComponentDefsCount[index]); TotalRefitCost = TotalRefitCost + CurrentComponentCost; } } else { /// <summary> /// Every component of this component definition must be added. /// </summary> decimal CurrentComponentCost = TestComponent.cost * TestComponentCount; TotalRefitCost = TotalRefitCost + CurrentComponentCost; } /// <summary> /// Break out of this component iteration loop due to the refit cost being too great. /// </summary> if (TotalRefitCost > RefitThreshold) break; } return TotalRefitCost; }
private void ClassComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (m_oOptionsPanel.ClassComboBox.SelectedIndex != -1 && m_oOptionsPanel.ClassComboBox.SelectedIndex < _CurrnetFaction.ShipDesigns.Count) { _CurrnetShipClass = _CurrnetFaction.ShipDesigns[m_oOptionsPanel.ClassComboBox.SelectedIndex]; UpdateDisplay(); } //if (VM.CurrentShipClass != null) //{ // m_oClassPropertiesPanel.ClassPropertyGrid.SelectedObject = VM.CurrentShipClass; //} }
/// <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>(); }
/// <summary> /// New ship class button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewButton_Click(object sender, EventArgs e) { ShipClassTN oNewShipClass = new ShipClassTN("New Class", VM.CurrentFaction); oNewShipClass.AddCrewQuarters(_CurrnetFaction.ComponentList.CrewQuarters[0], 1); oNewShipClass.AddFuelStorage(_CurrnetFaction.ComponentList.FuelStorage[0], 1); oNewShipClass.AddEngineeringSpaces(_CurrnetFaction.ComponentList.EngineeringSpaces[0], 1); oNewShipClass.AddOtherComponent(_CurrnetFaction.ComponentList.OtherComponents[0], 1); int ArmorTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.ArmourProtection]; if (ArmorTech > 12) ArmorTech = 12; #warning more armor names to move to constants.UI #region Armor Tech names String Title = "N/A"; switch (ArmorTech) { case 0: Title = "Conventional"; break; case 1: Title = "Duranium"; break; case 2: Title = "High Density Duranium"; break; case 3: Title = "Composite"; break; case 4: Title = "Ceramic Composite"; break; case 5: Title = "Laminate Composite"; break; case 6: Title = "Compressed Carbon"; break; case 7: Title = "Biphased Carbide"; break; case 8: Title = "Crystaline Composite"; break; case 9: Title = "Superdense"; break; case 10: Title = "Bonded Superdense"; break; case 11: Title = "Coherent Superdense"; break; case 12: Title = "Collapsium"; break; } #endregion oNewShipClass.NewArmor(Title, (ushort)Constants.MagazineTN.MagArmor[ArmorTech], oNewShipClass.ShipArmorDef.depth); _CurrnetFaction.ShipDesigns.Add(oNewShipClass); m_oOptionsPanel.ClassComboBox.SelectedIndex = m_oOptionsPanel.ClassComboBox.Items.Count - 1; _CurrnetShipClass = _CurrnetFaction.ShipDesigns[m_oOptionsPanel.ClassComboBox.SelectedIndex]; UpdateDisplay(); }
public FastOOB() { m_oFastOOBPanel = new Panels.FastOOB_Panel(); VM = new ViewModels.FastOOBViewModel(); /// <summary> /// setup bindings: /// </summary> m_oFastOOBPanel.EmpireComboBox.Bind(c => c.DataSource, VM, d => d.Factions); m_oFastOOBPanel.EmpireComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentFaction, DataSourceUpdateMode.OnPropertyChanged); m_oFastOOBPanel.EmpireComboBox.DisplayMember = "Name"; VM.FactionChanged += (s, args) => CurrentFaction = VM.CurrentFaction; CurrentFaction = VM.CurrentFaction; m_oFastOOBPanel.EmpireComboBox.SelectedIndexChanged += (s, args) => m_oFastOOBPanel.EmpireComboBox.DataBindings["SelectedItem"].WriteValue(); m_oFastOOBPanel.EmpireComboBox.SelectedIndexChanged += new EventHandler(EmpireComboBox_SelectedIndexChanged); m_oFastOOBPanel.TaskGroupComboBox.Bind(c => c.DataSource, VM, d => d.TaskGroups); m_oFastOOBPanel.TaskGroupComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentTaskGroup, DataSourceUpdateMode.OnPropertyChanged); m_oFastOOBPanel.TaskGroupComboBox.DisplayMember = "Name"; VM.TaskGroupChanged += (s, args) => CurrentTaskGroup = VM.CurrentTaskGroup; CurrentTaskGroup = VM.CurrentTaskGroup; m_oFastOOBPanel.TaskGroupComboBox.SelectedIndexChanged += (s, args) => m_oFastOOBPanel.TaskGroupComboBox.DataBindings["SelectedItem"].WriteValue(); m_oFastOOBPanel.TaskGroupComboBox.SelectedIndexChanged += new EventHandler(TaskGroupComboBox_SelectedIndexChanged); m_oFastOOBPanel.ClassComboBox.Bind(c => c.DataSource, VM, d => d.ShipDesigns); m_oFastOOBPanel.ClassComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentShipClass, DataSourceUpdateMode.OnPropertyChanged); m_oFastOOBPanel.ClassComboBox.DisplayMember = "Name"; VM.ShipClassChanged += (s, args) => CurrentShipClass = VM.CurrentShipClass; CurrentShipClass = VM.CurrentShipClass; m_oFastOOBPanel.ClassComboBox.SelectedIndexChanged += (s, args) => m_oFastOOBPanel.ClassComboBox.DataBindings["SelectedItem"].WriteValue(); m_oFastOOBPanel.ClassComboBox.SelectedIndexChanged += new EventHandler(ClassComboBox_SelectedIndexChanged); m_oFastOOBPanel.AddButton.Click += new EventHandler(AddButton_Click); m_oFastOOBPanel.CloseButton.Click += new EventHandler(CloseButton_Click); m_oFastOOBPanel.NumberTextBox.TextChanged += new EventHandler(NumberTextBox_TextChanged); }
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)); } }
/// <summary> /// Now I want a list of the ships of a specific class that are in orbit. these will potentially be targets for repair, refit, or scrap operations. /// </summary> /// <param name="CurrentFaction">Economics handler selected faction.</param> /// <param name="CurrentPopulation">Population from the economics handler.</param> /// <param name="CurrentShipClass">Shipclass selected via the RepairRefitScrapClassComboBox</param> /// <param name="ShipsOfClassInOrbit">List of ships in the selected shipclass in orbit around CurrentPopulation.</param> private static void GetShipsOfClassInOrbit(Faction CurrentFaction, Population CurrentPopulation, ShipClassTN CurrentShipClass, ref BindingList<ShipTN> ShipsOfClassInOrbit) { ShipsOfClassInOrbit.Clear(); foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit) { if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction) { foreach (ShipTN CurrentShip in CurrentTaskGroup.Ships) { if (CurrentShip.ShipClass == CurrentShipClass) ShipsOfClassInOrbit.Add(CurrentShip); } } } }
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); }
/// <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; }
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); } }
/// <summary> /// Constructor for Activity. /// </summary> /// <param name="NewActivity">New activity for this shipyard.</param> /// <param name="Cost">Cost of the activity. This will depend on the shipyard, so can't be calculated here in all cases.</param> /// <param name="minCost">Mineral cost of activity.</param> /// <param name="CompDate">Estimated completion date.</param> /// <param name="RetoolTarget">Shipclass to retool this shipyard to.</param> /// <param name="CapLimit">Expand this shipard until CapLimit tons. if -1 then this should not be cap expansion until X tons</param> public ShipyardActivity(Constants.ShipyardInfo.ShipyardActivity NewActivity, decimal Cost, decimal [] minCost, DateTime CompDate, ShipClassTN RetoolTarget=null) { m_aiMinerialsCost = new decimal[(int)Constants.Minerals.MinerialNames.MinerialCount]; Activity = NewActivity; Progress = 0.0m; TargetOfRetool = null; CapExpansionLimit = -1; CostOfActivity = Cost; CompletionDate = CompDate; for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++) { m_aiMinerialsCost[mineralIterator] = minCost[mineralIterator]; } if (RetoolTarget != null && NewActivity == Constants.ShipyardInfo.ShipyardActivity.Retool) { TargetOfRetool = RetoolTarget; } Paused = false; }
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); }
/// <summary> /// Constructor for Missile Build Queue Items /// </summary> /// <param name="Definition"></param> public FighterBuildQueueItem(ShipClassTN Definition) : base() { numToBuild = 0.0f; buildCapacity = 0.0f; productionRate = 0.0f; costPerItem = Definition.BuildPointCost; m_ShipClassDef = Definition; }