public void Init() { _game = new TestGame(); StaticDataManager.LoadData("Pulsar4x", _game.Game); // TODO: Figure out correct directory _entityManager = _game.Game.GlobalManager; // Initialize gas dictionary - haven't found a good way to look up gases without doing this _gasDictionary = new Dictionary <string, AtmosphericGasSD>(); foreach (WeightedValue <AtmosphericGasSD> atmos in _game.Game.StaticData.AtmosphericGases) { _gasDictionary.Add(atmos.Value.ChemicalSymbol, atmos.Value); } _planetsList = new List <Entity>(); _planetsList.Add(_game.Earth); _speciesList = new List <Entity>(); _speciesList.Add(_game.HumanSpecies); //_speciesList.Add(_game.GreyAlienSpecies); // Set up colonies // @todo: add more colonies, especially ones with multiple species in one colony ComponentTemplateSD infrastructureSD = _game.Game.StaticData.ComponentTemplates[new Guid("08b3e64c-912a-4cd0-90b0-6d0f1014e9bb")]; ComponentDesigner infrastructureDesigner = new ComponentDesigner(infrastructureSD, _game.HumanFaction.GetDataBlob <FactionTechDB>()); EntityManipulation.AddComponentToEntity(_game.EarthColony, infrastructureDesigner.CreateDesign(_game.HumanFaction)); ReCalcProcessor.ReCalcAbilities(_game.EarthColony); }
public void TestCargoComponentCreation() { ComponentTemplateSD cargo = GeneralCargo(); ComponentDesigner cargoDesigner = new ComponentDesigner(cargo, _faction.GetDataBlob <FactionTechDB>()); cargoDesigner.ComponentDesignAttributes["Size"].SetValue(); ComponentDesign cargoDesign = cargoDesigner.CreateDesign(_faction); bool hasAttribute = cargoDesign.TryGetAttribute <CargoStorageAtbDB>(out var attributeDB); Assert.IsTrue(hasAttribute); CargoTypeSD cargotype = _game.StaticData.CargoTypes[attributeDB.CargoTypeGuid]; Assert.AreEqual(100, attributeDB.StorageCapacity); Dictionary <Guid, ComponentTemplateSD> componentsDict = new Dictionary <Guid, ComponentTemplateSD>(); componentsDict.Add(cargo.ID, cargo); StaticDataManager.ExportStaticData(componentsDict, "CargoComponentTest.json"); }
public void TestEngineComponentFactory() { ComponentTemplateSD componentTemplateSD = EngineComponentSD(); ComponentDesigner designer = new ComponentDesigner(componentTemplateSD, _faction.GetDataBlob <FactionTechDB>()); foreach (var ability in designer.ComponentDesignAttributes.Values) { if (ability.GuiHint == GuiHint.GuiTechSelectionList) { List <Guid> selectionlist = ability.GuidDictionary.Keys.Cast <Guid>().ToList(); ability.SetValueFromGuidList(selectionlist[selectionlist.Count - 1]); } else if (ability.GuiHint == GuiHint.GuiSelectionMaxMin) { ability.SetMax(); ability.SetValueFromInput(ability.MaxValue); } else { ability.SetValue(); } } designer.ComponentDesignAttributes["Size"].SetValueFromInput(250); ComponentDesign engineDesign = designer.CreateDesign(_faction); Assert.AreEqual(250, engineDesign.Mass); Dictionary <Guid, ComponentTemplateSD> componentsDict = new Dictionary <Guid, ComponentTemplateSD>(); componentsDict.Add(componentTemplateSD.ID, componentTemplateSD); StaticDataManager.ExportStaticData(componentsDict, "EngineComponentTest.json"); }
public static ComponentDesign DefaultBatteryBank(Game game, Entity faction) { ComponentDesigner componentDesigner; ComponentTemplateSD template = game.StaticData.ComponentTemplates[new Guid("{1de23a8b-d44b-4e0f-bacd-5463a8eb939d}")]; componentDesigner = new ComponentDesigner(template, faction.GetDataBlob <FactionTechDB>()); componentDesigner.ComponentDesignAttributes["Mass"].SetValueFromInput(1000); componentDesigner.Name = "Battery900"; //return cargoInstalation.CreateDesign(faction); _battery = componentDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_battery.TechID); return(_battery); }
public static ComponentDesign DefaultFisionReactor(Game game, Entity faction) { ComponentDesigner componentDesigner; ComponentTemplateSD template = game.StaticData.ComponentTemplates[new Guid("{97cf75a1-5ca3-4037-8832-4d81a89f97fa}")]; componentDesigner = new ComponentDesigner(template, faction.GetDataBlob <FactionTechDB>()); componentDesigner.ComponentDesignAttributes["Mass"].SetValueFromInput(1000); componentDesigner.Name = "Reactor15k"; //return cargoInstalation.CreateDesign(faction); _reactor = componentDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_reactor.TechID); return(_reactor); }
public static ComponentDesign DefaultCargoInstalation(Game game, Entity faction) { ComponentDesigner componentDesigner; ComponentTemplateSD template = game.StaticData.ComponentTemplates[new Guid("{30cd60f8-1de3-4faa-acba-0933eb84c199}")]; componentDesigner = new ComponentDesigner(template, faction.GetDataBlob <FactionTechDB>()); componentDesigner.ComponentDesignAttributes["Warehouse Size"].SetValueFromInput(1000000); componentDesigner.Name = "CargoInstalation1"; //return cargoInstalation.CreateDesign(faction); _cargoInstalation = componentDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_cargoInstalation.TechID); return(_cargoInstalation); }
public static ComponentDesign DefaultCargoInstalation(Game game, Entity faction) { ComponentDesigner componentDesigner; ComponentTemplateSD template = game.StaticData.ComponentTemplates[new Guid("{B8239721-B60E-4C11-8E45-5F64F6BA5FA5}")]; componentDesigner = new ComponentDesigner(template, faction.GetDataBlob <FactionTechDB>()); componentDesigner.ComponentDesignAttributes["Warehouse Size"].SetValueFromInput(1000000); componentDesigner.Name = "CargoInstalation1"; //return cargoInstalation.CreateDesign(faction); _cargoInstalation = componentDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_cargoInstalation.TechID); return(_cargoInstalation); }
public static ComponentDesign ShipYard(Entity faction) { if (_shipYard != null) { return(_shipYard); } ComponentDesigner spacePortDesigner; ComponentTemplateSD spaceportSD = StaticRefLib.StaticData.ComponentTemplates[new Guid("0BD304FF-FDEA-493C-8979-15FE86B7123E")]; spacePortDesigner = new ComponentDesigner(spaceportSD, faction.GetDataBlob <FactionTechDB>()); spacePortDesigner.Name = "Ship Yard"; _shipYard = spacePortDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_shipYard.TechID); return(_shipYard); }
public static ComponentDesign DefaultMissileTube(Game game, Entity faction) { if (_missileTube != null) { return(_missileTube); } ComponentDesigner tubeDesigner; ComponentTemplateSD tubeSD = game.StaticData.ComponentTemplates[new Guid("978DFA9E-411E-4B4F-A618-85D642927503")]; tubeDesigner = new ComponentDesigner(tubeSD, faction.GetDataBlob <FactionTechDB>()); tubeDesigner.Name = "MissileTube 500"; _missileTube = tubeDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_missileTube.TechID); return(_missileTube); }
public static ComponentDesign LargeFuelTank(Game game, Entity faction) { if (_fuelTank_2500 != null) { return(_fuelTank_2500); } ComponentDesigner fuelTankDesigner; ComponentTemplateSD tankSD = game.StaticData.ComponentTemplates[new Guid("3528600E-3A1C-488C-BAE6-60251D1156AB")]; fuelTankDesigner = new ComponentDesigner(tankSD, faction.GetDataBlob <FactionTechDB>()); fuelTankDesigner.ComponentDesignAttributes["Tank Volume"].SetValueFromInput(2500); fuelTankDesigner.Name = "Tank-1200t"; _fuelTank_2500 = fuelTankDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_fuelTank_2500.TechID); return(_fuelTank_2500); }
public void TestMineInstalationFactory() { ComponentTemplateSD mine = MineInstallation(); ComponentDesigner mineDesigner = new ComponentDesigner(mine, _faction.GetDataBlob <FactionTechDB>()); mineDesigner.ComponentDesignAttributes["MiningAmount"].SetValue(); ComponentDesign mineDesign = mineDesigner.CreateDesign(_faction); Assert.AreEqual(10, mineDesign.GetAttribute <MineResourcesAtbDB>().ResourcesPerEconTick.Values.ElementAt(0)); Dictionary <Guid, ComponentTemplateSD> componentsDict = new Dictionary <Guid, ComponentTemplateSD>(); componentsDict.Add(mine.ID, mine); StaticDataManager.ExportStaticData(componentsDict, "MineComponentTest.json"); }
public static ComponentDesign DefaultFuelTank(Game game, Entity faction) { if (_fuelTank_500 != null) { return(_fuelTank_500); } ComponentDesigner fuelTankDesigner; ComponentTemplateSD tankSD = game.StaticData.ComponentTemplates[new Guid("E7AC4187-58E4-458B-9AEA-C3E07FC993CB")]; fuelTankDesigner = new ComponentDesigner(tankSD, faction.GetDataBlob <FactionTechDB>()); fuelTankDesigner.ComponentDesignAttributes["Tank Size"].SetValueFromInput(2500); fuelTankDesigner.Name = "Tank-500"; _fuelTank_500 = fuelTankDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_fuelTank_500.TechID); return(_fuelTank_500); }
public static ComponentDesign DefaultMissileSRB(Game game, Entity faction) { if (_missileSRB != null) { return(_missileSRB); } ComponentDesigner srbDesigner; ComponentTemplateSD srbSD = game.StaticData.ComponentTemplates[new Guid("9FDB2A15-4413-40A9-9229-19D05B3765FE")]; srbDesigner = new ComponentDesigner(srbSD, faction.GetDataBlob <FactionTechDB>()); srbDesigner.ComponentDesignAttributes["Engine Mass"].SetValueFromInput(10); srbDesigner.Name = "SRB 235"; _missileSRB = srbDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_missileSRB.TechID); return(_missileSRB); }
public static ComponentDesign ShipDefaultCargoHold(Game game, Entity faction) { if (_cargoHold != null) { return(_cargoHold); } ComponentDesigner cargoComponent; ComponentTemplateSD template = game.StaticData.ComponentTemplates[new Guid("{30cd60f8-1de3-4faa-acba-0933eb84c199}")]; cargoComponent = new ComponentDesigner(template, faction.GetDataBlob <FactionTechDB>()); cargoComponent.ComponentDesignAttributes["Warehouse Size"].SetValueFromInput(5000); //5t component cargoComponent.ComponentDesignAttributes["Cargo Transfer Rate"].SetValueFromInput(500); cargoComponent.ComponentDesignAttributes["Transfer Range"].SetValueFromInput(100); cargoComponent.Name = "CargoComponent5t"; _cargoHold = cargoComponent.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_cargoHold.TechID); return(_cargoHold); }
public static ComponentDesign ShipSmallOrdnanceStore(Game game, Entity faction) { if (_ordnanceStore != null) { return(_ordnanceStore); } ComponentDesigner cargoComponent; ComponentTemplateSD template = game.StaticData.ComponentTemplates[new Guid("{11564F56-D52C-4A16-8434-C9BB50D8EB95}")]; cargoComponent = new ComponentDesigner(template, faction.GetDataBlob <FactionTechDB>()); cargoComponent.ComponentDesignAttributes["Rack Size"].SetValueFromInput(2627); //5t component cargoComponent.ComponentDesignAttributes["Cargo Transfer Rate"].SetValueFromInput(100); cargoComponent.ComponentDesignAttributes["Transfer Range"].SetValueFromInput(100); cargoComponent.Name = "OrdinanceRack-2.5t"; _ordnanceStore = cargoComponent.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_ordnanceStore.TechID); return(_ordnanceStore); }
public static ComponentDesign ShipSmallCargo(Game game, Entity faction) { if (_cargoCompartment != null) { return(_cargoCompartment); } ComponentDesigner cargoComponent; ComponentTemplateSD template = game.StaticData.ComponentTemplates[new Guid("{B8239721-B60E-4C11-8E45-5F64F6BA5FA5}")]; cargoComponent = new ComponentDesigner(template, faction.GetDataBlob <FactionTechDB>()); cargoComponent.ComponentDesignAttributes["Warehouse Size"].SetValueFromInput(1000); //5t component cargoComponent.ComponentDesignAttributes["Cargo Transfer Rate"].SetValueFromInput(500); cargoComponent.ComponentDesignAttributes["Transfer Range"].SetValueFromInput(100); cargoComponent.Name = "CargoComponent1t"; _cargoCompartment = cargoComponent.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_cargoCompartment.TechID); return(_cargoCompartment); }
public static ComponentDesign DefaultSimpleLaser(Game game, Entity faction) { if (_laser != null) { return(_laser); } ComponentDesigner laserDesigner; ComponentTemplateSD laserSD = game.StaticData.ComponentTemplates[new Guid("8923f0e1-1143-4926-a0c8-66b6c7969425")]; laserDesigner = new ComponentDesigner(laserSD, faction.GetDataBlob <FactionTechDB>()); laserDesigner.ComponentDesignAttributes["Range"].SetValueFromInput(100); laserDesigner.ComponentDesignAttributes["Damage"].SetValueFromInput(5000); laserDesigner.ComponentDesignAttributes["ReloadRate"].SetValueFromInput(5); _laser = laserDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_laser.TechID); return(_laser); }
public void TestFactoryComponentCreation() { ComponentTemplateSD factory = Factory(); ComponentDesigner facDesigner = new ComponentDesigner(factory, _faction.GetDataBlob <FactionTechDB>()); facDesigner.ComponentDesignAttributes["Instalation Construction Points"].SetValue(); ComponentDesign facDesign = facDesigner.CreateDesign(_faction); ConstructionAtbDB attributeDB = facDesign.GetAttribute <ConstructionAtbDB>(); Assert.AreEqual(100, attributeDB.ConstructionPoints[ConstructionType.ShipComponents]); Dictionary <Guid, ComponentTemplateSD> componentsDict = new Dictionary <Guid, ComponentTemplateSD>(); componentsDict.Add(factory.ID, factory); StaticDataManager.ExportStaticData(componentsDict, "FactoryComponentTest.json"); }
public static ComponentDesign FacPassiveSensor(Game game, Entity faction) { ComponentDesigner sensorDesigner; ComponentTemplateSD template = NameLookup.GetTemplateSD(game, "PassiveSensor"); sensorDesigner = new ComponentDesigner(template, faction.GetDataBlob <FactionTechDB>()); sensorDesigner.ComponentDesignAttributes["Sensor Size"].SetValueFromInput(5000); //size sensorDesigner.ComponentDesignAttributes["Ideal Detection Wavelength"].SetValueFromInput(500); //best wavelength sensorDesigner.ComponentDesignAttributes["Detection Wavelength Width"].SetValueFromInput(1000); //wavelength detection width //[3] best detection magnatude. (Not settable) //[4] worst detection magnatude (not setta[ble) sensorDesigner.ComponentDesignAttributes["Resolution"].SetValueFromInput(5); //resolution sensorDesigner.ComponentDesignAttributes["Scan Time"].SetValueFromInput(3600); //Scan Time sensorDesigner.Name = "PassiveSensor-S500"; //return sensor.CreateDesign(faction); _sensorInstalation = sensorDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_sensorInstalation.TechID); return(_sensorInstalation); }
public static ComponentDesign DefaultBFC(Game game, Entity faction) { if (_fireControl != null) { return(_fireControl); } ComponentDesigner fireControlDesigner; ComponentTemplateSD bfcSD = game.StaticData.ComponentTemplates[new Guid("33fcd1f5-80ab-4bac-97be-dbcae19ab1a0")]; fireControlDesigner = new ComponentDesigner(bfcSD, faction.GetDataBlob <FactionTechDB>()); fireControlDesigner.ComponentDesignAttributes["Range"].SetValueFromInput(100); fireControlDesigner.ComponentDesignAttributes["Tracking Speed"].SetValueFromInput(5000); fireControlDesigner.ComponentDesignAttributes["Size vs Range"].SetValueFromInput(1); //return fireControlDesigner.CreateDesign(faction); _fireControl = fireControlDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_fireControl.TechID); return(_fireControl); }
public static ComponentDesign DefaultMissileSensors(Game game, Entity faction) { if (_missileSuite != null) { return(_missileSuite); } ComponentDesigner suiteDesigner; ComponentTemplateSD srbSD = game.StaticData.ComponentTemplates[new Guid("BBC29A72-C4D3-4389-94DE-36C3BE3B7B0E")]; suiteDesigner = new ComponentDesigner(srbSD, faction.GetDataBlob <FactionTechDB>()); suiteDesigner.ComponentDesignAttributes["Guidance Type"].SetValueFromInput(2); suiteDesigner.ComponentDesignAttributes["Antenna Size"].SetValueFromInput(10); suiteDesigner.ComponentDesignAttributes["Ideal Detection Wavelength"].SetValueFromInput(470); suiteDesigner.ComponentDesignAttributes["Detection Bandwidth"].SetValueFromInput(2); suiteDesigner.ComponentDesignAttributes["Resolution"].SetValueFromInput(1); suiteDesigner.Name = "Passive Yellow 1MP "; _missileSuite = suiteDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_missileSuite.TechID); return(_missileSuite); }
public static ComponentDesign DefaultWarpDesign(Game game, Entity faction) { if (_warpDrive != null) { return(_warpDrive); } ComponentDesigner engineDesigner; ComponentTemplateSD engineSD = game.StaticData.ComponentTemplates[new Guid("7d0b867f-e239-4b93-9b30-c6d4b769b5e4")]; engineDesigner = new ComponentDesigner(engineSD, faction.GetDataBlob <FactionTechDB>()); engineDesigner.ComponentDesignAttributes["Mass"].SetValueFromInput(1000); //size 500 = 2500 power engineDesigner.Name = "Alcuberi-White 500"; //engineDesignDB.ComponentDesignAbilities[1].SetValueFromInput _warpDrive = engineDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_warpDrive.TechID); return(_warpDrive); }
public static ComponentDesign F1ThrusterDesign(Game game, Entity faction) { if (_f1 != null) { return(_f1); } ComponentDesigner engineDesigner; ComponentTemplateSD engineSD = game.StaticData.ComponentTemplates[new Guid("b12f50f6-ac68-4a49-b147-281a9bb34b9b")]; engineDesigner = new ComponentDesigner(engineSD, faction.GetDataBlob <FactionTechDB>()); engineDesigner.ComponentDesignAttributes["Mass"].SetValueFromInput(18500); engineDesigner.Name = "F1"; //engineDesignDB.ComponentDesignAbilities[1].SetValueFromInput _f1 = engineDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_f1.TechID); return(_f1); }
public static ComponentDesign RaptorThrusterDesign(Game game, Entity faction) { if (_raptor != null) { return(_raptor); } ComponentDesigner engineDesigner; ComponentTemplateSD engineSD = game.StaticData.ComponentTemplates[new Guid("B03FE82F-EE70-4A9A-AC61-5A7D44A3364E")]; engineDesigner = new ComponentDesigner(engineSD, faction.GetDataBlob <FactionTechDB>()); engineDesigner.ComponentDesignAttributes["Mass"].SetValueFromInput(1500); engineDesigner.Name = "Raptor"; //engineDesignDB.ComponentDesignAbilities[1].SetValueFromInput _raptor = engineDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_raptor.TechID); return(_raptor); }
public static ComponentDesign DefaultFragPayload(Game game, Entity faction) { if (_payload != null) { return(_payload); } ComponentDesigner payloadDesigner; ComponentTemplateSD payloadSD = game.StaticData.ComponentTemplates[new Guid("DF9954A7-C5C5-4B49-965C-446B483DA2BE")]; payloadDesigner = new ComponentDesigner(payloadSD, faction.GetDataBlob <FactionTechDB>()); payloadDesigner.ComponentDesignAttributes["Trigger Type"].SetValueFromInput(2); payloadDesigner.ComponentDesignAttributes["Payload Type"].SetValueFromInput(0); payloadDesigner.ComponentDesignAttributes["Explosive Mass"].SetValueFromInput(2); payloadDesigner.ComponentDesignAttributes["Frag Mass"].SetValueFromInput(0.1); payloadDesigner.ComponentDesignAttributes["Frag Count"].SetValueFromInput(30); payloadDesigner.ComponentDesignAttributes["Frag Cone Angle"].SetValueFromInput(180); payloadDesigner.Name = "ProxFrag 5kg"; _payload = payloadDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_payload.TechID); return(_payload); }
public static ComponentDesign RS25ThrusterDesign(Game game, Entity faction) { if (_rs25 != null) { return(_rs25); } ComponentDesigner engineDesigner; ComponentTemplateSD engineSD = game.StaticData.ComponentTemplates[new Guid("A0F3E5BB-0AA6-41D0-9873-5A7AC9080B69")]; engineDesigner = new ComponentDesigner(engineSD, faction.GetDataBlob <FactionTechDB>()); engineDesigner.ComponentDesignAttributes["Mass"].SetValueFromInput(3527); engineDesigner.Name = "RS-25"; //engineDesignDB.ComponentDesignAbilities[1].SetValueFromInput _rs25 = engineDesigner.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_rs25.TechID); return(_rs25); }
public static ComponentDesign ShipPassiveSensor(Game game, Entity faction) { if (_sensor_50 != null) { return(_sensor_50); } ComponentDesigner sensor; ComponentTemplateSD template = NameLookup.GetTemplateSD(game, "PassiveSensor"); sensor = new ComponentDesigner(template, faction.GetDataBlob <FactionTechDB>()); sensor.ComponentDesignAttributes["Antenna Size"].SetValueFromInput(5.5); //size sensor.ComponentDesignAttributes["Ideal Detection Wavelength"].SetValueFromInput(479); //best wavelength sensor.ComponentDesignAttributes["Detection Bandwidth"].SetValueFromInput(200); //wavelength detection width //sensor.ComponentDesignAttributes[3].SetValueFromInput(10); //best detection magnatude. (Not settable) //[4] worst detection magnatude (not settable) sensor.ComponentDesignAttributes["Resolution"].SetValueFromInput(1); //resolution sensor.ComponentDesignAttributes["Scan Time"].SetValueFromInput(3600); //Scan Time sensor.Name = "PassiveSensor-S50"; _sensor_50 = sensor.CreateDesign(faction); faction.GetDataBlob <FactionTechDB>().IncrementLevel(_sensor_50.TechID); return(_sensor_50); }
internal override void Display() { if (IsActive && ImGui.Begin(_windowname, ref IsActive, _flags)) { GuiDesignUI(_componentDesigner); //Part design ImGui.Text("Name"); ImGui.InputText("", _nameInputBuffer, 32); if (ImGui.Button("Create Design")) { _componentDesigner.Name = ImGuiSDL2CSHelper.StringFromBytes(_nameInputBuffer); _componentDesigner.CreateDesign(_state.Faction); //we reset the designer here, so we don't end up trying to edit the precious design. var factionTech = _state.Faction.GetDataBlob <FactionTechDB>(); _componentDesigner = new ComponentDesigner(_designables[_designType], factionTech); } GuiCostText(_componentDesigner); //Print cost ImGui.End(); } }
internal void NewDesignButton() { if (ImGui.Button("Create Design") && _engineDesigner != null) { int version = 0; var strName = ImGuiSDL2CSHelper.StringFromBytes(_designName); foreach (var design in _currentDesigns) { if (design.Name == strName) { if (design.DesignVersion >= version) { version = design.DesignVersion + 1; } } } List <(ComponentDesign, int)> misslcomponents = new List <(ComponentDesign, int)>(); foreach (var kvp in _selectedComponentDesigns) { misslcomponents.Add((kvp.Key, kvp.Value)); } var atb = _engineDesigner.GetAttribute <NewtonionThrustAtb>(); double burnRate = atb.FuelBurnRate; double exaustVel = atb.ExhaustVelocity; double thrustNewtons = burnRate * exaustVel; _engineDesigner.Name = "MissileEngine" + _engineDesigner.MassValue + "," + thrustNewtons; var engineDesign = _engineDesigner.CreateDesign(_faction); misslcomponents.Add((engineDesign, 1)); OrdnanceDesign missileDesign = new OrdnanceDesign(_uiState.Faction.GetDataBlob <FactionInfoDB>(), strName, _fuelKG, misslcomponents); //missileDesign.DesignVersion = version; } }
public static Entity DefaultHumans(Game game, string name) { //USE THIS TO TEST CODE //TESTING STUFFF //return completeTest(game, name); // while(true){ //} //TESTING STUFF var log = StaticRefLib.EventLog; StarSystemFactory starfac = new StarSystemFactory(game); StarSystem solSys = starfac.CreateSol(game); //sol.ManagerSubpulses.Init(sol); Entity solStar = solSys.Entities[0]; Entity earth = solSys.Entities[3]; //should be fourth entity created //Entity factionEntity = FactionFactory.CreatePlayerFaction(game, owner, name); Entity factionEntity = FactionFactory.CreateFaction(game, name); Entity speciesEntity = SpeciesFactory.CreateSpeciesHuman(factionEntity, game.GlobalManager); Entity targetFaction = FactionFactory.CreateFaction(game, "OpFor"); var namedEntites = solSys.GetAllEntitiesWithDataBlob <NameDB>(); foreach (var entity in namedEntites) { var nameDB = entity.GetDataBlob <NameDB>(); nameDB.SetName(factionEntity.Guid, nameDB.DefaultName); } Entity colonyEntity = ColonyFactory.CreateColony(factionEntity, speciesEntity, earth); Entity marsColony = ColonyFactory.CreateColony(factionEntity, speciesEntity, NameLookup.GetFirstEntityWithName(solSys, "Mars")); ComponentTemplateSD mineSD = game.StaticData.ComponentTemplates[new Guid("f7084155-04c3-49e8-bf43-c7ef4befa550")]; ComponentDesigner mineDesigner = new ComponentDesigner(mineSD, factionEntity.GetDataBlob <FactionTechDB>()); ComponentDesign mineDesign = mineDesigner.CreateDesign(factionEntity); ComponentTemplateSD RefinerySD = game.StaticData.ComponentTemplates[new Guid("90592586-0BD6-4885-8526-7181E08556B5")]; ComponentDesigner refineryDesigner = new ComponentDesigner(RefinerySD, factionEntity.GetDataBlob <FactionTechDB>()); ComponentDesign refinaryDesign = refineryDesigner.CreateDesign(factionEntity); ComponentTemplateSD labSD = game.StaticData.ComponentTemplates[new Guid("c203b7cf-8b41-4664-8291-d20dfe1119ec")]; ComponentDesigner labDesigner = new ComponentDesigner(labSD, factionEntity.GetDataBlob <FactionTechDB>()); ComponentDesign labEntity = labDesigner.CreateDesign(factionEntity); ComponentTemplateSD facSD = game.StaticData.ComponentTemplates[new Guid("{07817639-E0C6-43CD-B3DC-24ED15EFB4BA}")]; ComponentDesigner facDesigner = new ComponentDesigner(facSD, factionEntity.GetDataBlob <FactionTechDB>()); ComponentDesign facEntity = facDesigner.CreateDesign(factionEntity); Scientist scientistEntity = CommanderFactory.CreateScientist(factionEntity, colonyEntity); colonyEntity.GetDataBlob <TeamsHousedDB>().AddTeam(scientistEntity); FactionTechDB factionTech = factionEntity.GetDataBlob <FactionTechDB>(); //TechProcessor.ApplyTech(factionTech, game.StaticData.Techs[new ID("35608fe6-0d65-4a5f-b452-78a3e5e6ce2c")]); //add conventional engine for testing. ResearchProcessor.CheckRequrements(factionTech); DefaultThrusterDesign(game, factionEntity); F1ThrusterDesign(game, factionEntity); RaptorThrusterDesign(game, factionEntity); RS25ThrusterDesign(game, factionEntity); DefaultWarpDesign(game, factionEntity); DefaultFuelTank(game, factionEntity); LargeFuelTank(game, factionEntity); DefaultCargoInstalation(game, factionEntity); DefaultSimpleLaser(game, factionEntity); DefaultBFC(game, factionEntity); ShipDefaultCargoHold(game, factionEntity); ShipSmallCargo(game, factionEntity); ShipPassiveSensor(game, factionEntity); FacPassiveSensor(game, factionEntity); DefaultFisionReactor(game, factionEntity); DefaultBatteryBank(game, factionEntity); DefaultFragPayload(game, factionEntity); DefaultMissileSRB(game, factionEntity); DefaultMissileSensors(game, factionEntity); DefaultMissileTube(game, factionEntity); MissileDesign250(game, factionEntity); ShipSmallOrdnanceStore(game, factionEntity); EntityManipulation.AddComponentToEntity(colonyEntity, mineDesign); EntityManipulation.AddComponentToEntity(colonyEntity, refinaryDesign); EntityManipulation.AddComponentToEntity(colonyEntity, labEntity); EntityManipulation.AddComponentToEntity(colonyEntity, facEntity); EntityManipulation.AddComponentToEntity(colonyEntity, _fuelTank_1000); EntityManipulation.AddComponentToEntity(colonyEntity, _cargoInstalation); EntityManipulation.AddComponentToEntity(marsColony, _cargoInstalation); EntityManipulation.AddComponentToEntity(colonyEntity, _sensorInstalation); EntityManipulation.AddComponentToEntity(colonyEntity, ShipYard(factionEntity)); EntityManipulation.AddComponentToEntity(colonyEntity, _ordnanceStore, 10); ReCalcProcessor.ReCalcAbilities(colonyEntity); var earthCargo = colonyEntity.GetDataBlob <VolumeStorageDB>(); colonyEntity.GetDataBlob <ColonyInfoDB>().Population[speciesEntity] = 9000000000; var rawSorium = NameLookup.GetMineralSD(game, "Sorium"); var iron = NameLookup.GetMineralSD(game, "Iron"); colonyEntity.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByMass(iron, 5000); var hydrocarbon = NameLookup.GetMineralSD(game, "Hydrocarbons"); colonyEntity.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByMass(hydrocarbon, 5000); var stainless = NameLookup.GetMaterialSD(game, "Stainless Steel"); colonyEntity.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByMass(iron, 1000); colonyEntity.GetDataBlob <VolumeStorageDB>().AddCargoByUnit(_missile, 100); colonyEntity.GetDataBlob <VolumeStorageDB>().AddCargoByUnit(_merlin, 5); factionEntity.GetDataBlob <FactionInfoDB>().KnownSystems.Add(solSys.Guid); //test systems //factionEntity.GetDataBlob<FactionInfoDB>().KnownSystems.Add(starfac.CreateEccTest(game).ID); //factionEntity.GetDataBlob<FactionInfoDB>().KnownSystems.Add(starfac.CreateLongitudeTest(game).ID); factionEntity.GetDataBlob <NameDB>().SetName(factionEntity.Guid, "UEF"); // Todo: handle this in CreateShip ShipDesign shipDesign = DefaultShipDesign(game, factionEntity); ShipDesign gunShipDesign = GunShipDesign(game, factionEntity); Entity gunShip0 = ShipFactory.CreateShip(gunShipDesign, factionEntity, earth, solSys, "Serial Peacemaker"); Entity ship2 = ShipFactory.CreateShip(shipDesign, factionEntity, earth, solSys, "Ensuing Calm"); Entity ship3 = ShipFactory.CreateShip(shipDesign, factionEntity, earth, solSys, "Touch-and-Go"); Entity gunShip1 = ShipFactory.CreateShip(gunShipDesign, factionEntity, earth, solSys, "Prevailing Stillness"); Entity courier = ShipFactory.CreateShip(CargoShipDesign(game, factionEntity), factionEntity, earth, solSys, "Planet Express Ship"); Entity starship = ShipFactory.CreateShip(SpaceXStarShip(game, factionEntity), factionEntity, earth, solSys, "SN10"); var fuel = NameLookup.GetMaterialSD(game, "Sorium Fuel"); var rp1 = NameLookup.GetMaterialSD(game, "LOX/Hydrocarbon"); var methalox = NameLookup.GetMaterialSD(game, "Methalox"); var hydrolox = NameLookup.GetMaterialSD(game, "Hydrolox"); earthCargo.AddCargoByUnit(rp1, 10000); earthCargo.AddCargoByUnit(methalox, 10000); earthCargo.AddCargoByUnit(hydrolox, 10000); gunShip0.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByVolume(rp1, 2000); gunShip1.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByVolume(rp1, 2000); ship2.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByVolume(rp1, 2000); ship3.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByVolume(rp1, 2000); var count = courier.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByVolume(hydrolox, 50000); starship.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByMass(methalox, 1200000); gunShip0.GetDataBlob <VolumeStorageDB>().AddCargoByUnit(MissileDesign250(game, factionEntity), 20); gunShip1.GetDataBlob <VolumeStorageDB>().AddCargoByUnit(MissileDesign250(game, factionEntity), 20); var elec = NameLookup.GetMaterialSD(game, "Electrical Energy"); gunShip0.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750; ship2.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750; ship3.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750; gunShip1.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750; courier.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750; Entity targetDrone0 = ShipFactory.CreateShip(TargetDrone(game, targetFaction), targetFaction, earth, (10 * Math.PI / 180), "Target Drone0"); Entity targetDrone1 = ShipFactory.CreateShip(TargetDrone(game, targetFaction), targetFaction, earth, (22.5 * Math.PI / 180), "Target Drone1"); Entity targetDrone2 = ShipFactory.CreateShip(TargetDrone(game, targetFaction), targetFaction, earth, (45 * Math.PI / 180), "Target Drone2"); targetDrone0.GetDataBlob <NameDB>().SetName(factionEntity.Guid, "TargetDrone0"); targetDrone1.GetDataBlob <NameDB>().SetName(factionEntity.Guid, "TargetDrone1"); targetDrone2.GetDataBlob <NameDB>().SetName(factionEntity.Guid, "TargetDrone2"); targetDrone1.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByVolume(rp1, 1000); targetDrone2.GetDataBlob <VolumeStorageDB>().AddRemoveCargoByVolume(rp1, 1000); NewtonionMovementProcessor.UpdateNewtonThrustAbilityDB(gunShip0); NewtonionMovementProcessor.UpdateNewtonThrustAbilityDB(ship2); NewtonionMovementProcessor.UpdateNewtonThrustAbilityDB(ship3); NewtonionMovementProcessor.UpdateNewtonThrustAbilityDB(gunShip1); NewtonionMovementProcessor.UpdateNewtonThrustAbilityDB(courier); NewtonionMovementProcessor.UpdateNewtonThrustAbilityDB(starship); double test_a = 0.5; //AU double test_e = 0; double test_i = 0; //° double test_loan = 0; //° double test_aop = 0; //° double test_M0 = 0; //° double test_bodyMass = ship2.GetDataBlob <MassVolumeDB>().MassDry; OrbitDB testOrbtdb_ship2 = OrbitDB.FromAsteroidFormat(solStar, solStar.GetDataBlob <MassVolumeDB>().MassDry, test_bodyMass, test_a, test_e, test_i, test_loan, test_aop, test_M0, StaticRefLib.CurrentDateTime); ship2.RemoveDataBlob <OrbitDB>(); ship2.SetDataBlob(testOrbtdb_ship2); ship2.GetDataBlob <PositionDB>().SetParent(solStar); StaticRefLib.ProcessorManager.RunProcessOnEntity <OrbitDB>(ship2, 0); test_a = 0.51; test_i = 180; test_aop = 0; OrbitDB testOrbtdb_ship3 = OrbitDB.FromAsteroidFormat(solStar, solStar.GetDataBlob <MassVolumeDB>().MassDry, test_bodyMass, test_a, test_e, test_i, test_loan, test_aop, test_M0, StaticRefLib.CurrentDateTime); ship3.RemoveDataBlob <OrbitDB>(); ship3.SetDataBlob(testOrbtdb_ship3); ship3.GetDataBlob <PositionDB>().SetParent(solStar); StaticRefLib.ProcessorManager.RunProcessOnEntity <OrbitDB>(ship3, 0); gunShip1.GetDataBlob <PositionDB>().RelativePosition_AU = new Vector3(8.52699302490434E-05, 0, 0); //give the gunship a hypobolic orbit to test: //var orbit = OrbitDB.FromVector(earth, gunShip, new Vector4(0, velInAU, 0, 0), game.CurrentDateTime); gunShip1.RemoveDataBlob <OrbitDB>(); var nmdb = new NewtonMoveDB(earth, new Vector3(0, -10000.0, 0)); gunShip1.SetDataBlob <NewtonMoveDB>(nmdb); solSys.SetDataBlob(gunShip0.ID, new TransitableDB()); solSys.SetDataBlob(ship2.ID, new TransitableDB()); solSys.SetDataBlob(gunShip1.ID, new TransitableDB()); solSys.SetDataBlob(courier.ID, new TransitableDB()); //Entity ship = ShipFactory.CreateShip(shipDesign, sol.SystemManager, factionEntity, position, sol, "Serial Peacemaker"); //ship.SetDataBlob(earth.GetDataBlob<PositionDB>()); //first ship reference PositionDB //Entity ship3 = ShipFactory.CreateShip(shipDesign, sol.SystemManager, factionEntity, position, sol, "Contiual Pacifier"); //ship3.SetDataBlob((OrbitDB)earth.GetDataBlob<OrbitDB>().Clone());//second ship clone earth OrbitDB //sol.SystemManager.SetDataBlob(ship.ID, new TransitableDB()); //Entity rock = AsteroidFactory.CreateAsteroid2(sol, earth, game.CurrentDateTime + TimeSpan.FromDays(365)); Entity rock = AsteroidFactory.CreateAsteroid(solSys, earth, StaticRefLib.CurrentDateTime + TimeSpan.FromDays(365)); var pow = solSys.GetAllEntitiesWithDataBlob <EnergyGenAbilityDB>(); foreach (var entityItem in pow) { StaticRefLib.ProcessorManager.GetInstanceProcessor(nameof(EnergyGenProcessor)).ProcessEntity(entityItem, StaticRefLib.CurrentDateTime); } var entitiesWithSensors = solSys.GetAllEntitiesWithDataBlob <SensorAbilityDB>(); foreach (var entityItem in entitiesWithSensors) { StaticRefLib.ProcessorManager.GetInstanceProcessor(nameof(SensorScan)).ProcessEntity(entityItem, StaticRefLib.CurrentDateTime); } return(factionEntity); }