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 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 void TestShipCreation() { ComponentDesigner engineDesigner;// = DefaultStartFactory.DefaultEngineDesign(_game, _faction); //_engineSD = NameLookup.GetTemplateSD(_game, "Alcubierre Warp Drive"); //engineDesigner = new ComponentDesigner(_engineSD, _faction.GetDataBlob<FactionTechDB>()); //engineDesigner.ComponentDesignAttributes["Size"].SetValueFromInput(5); //size = 25 power. //_engineComponentDesign = engineDesigner.CreateDesign(_faction); _engineComponentDesign = DefaultStartFactory.DefaultWarpDesign(_game, _faction); _shipClass = DefaultStartFactory.DefaultShipDesign(_game, _faction); _ship = ShipFactory.CreateShip(_shipClass, _faction, _sol, _starSystem, "Testship"); ComponentInstancesDB instancesdb = _ship.GetDataBlob <ComponentInstancesDB>(); instancesdb.TryGetComponentsByAttribute <WarpDriveAtb>(out var instances1); int origionalEngineNumber = instances1.Count; WarpAbilityDB warpAbility = _ship.GetDataBlob <WarpAbilityDB>(); ShipInfoDB shipInfo = _ship.GetDataBlob <ShipInfoDB>(); WarpDriveAtb warpAtb = _engineComponentDesign.GetAttribute <WarpDriveAtb>(); double warpPower = warpAtb.WarpPower; Assert.AreEqual(warpPower * origionalEngineNumber, warpAbility.TotalWarpPower, "Incorrect TotalEnginePower"); float tonnage1 = _ship.GetDataBlob <ShipInfoDB>().Tonnage; int expectedSpeed1 = ShipMovementProcessor.MaxSpeedCalc(warpAbility.TotalWarpPower, tonnage1); Assert.AreEqual(expectedSpeed1, warpAbility.MaxSpeed, "Incorrect Max Speed"); EntityManipulation.AddComponentToEntity(_ship, _engineComponentDesign); instancesdb.TryGetComponentsByAttribute <WarpDriveAtb>(out var instances2); int add2engineNumber = instances2.Count; Assert.AreEqual(origionalEngineNumber + 1, add2engineNumber); Assert.AreEqual(warpPower * add2engineNumber, warpAbility.TotalWarpPower, "Incorrect TotalEnginePower 2nd engine added"); float tonnage2 = _ship.GetDataBlob <ShipInfoDB>().Tonnage; int expectedSpeed2 = ShipMovementProcessor.MaxSpeedCalc(warpAbility.TotalWarpPower, tonnage2); Assert.AreEqual(expectedSpeed2, warpAbility.MaxSpeed, "Incorrect Max Speed 2nd engine"); var energydb = _ship.GetDataBlob <EnergyGenAbilityDB>(); var energyMax = energydb.EnergyStoreMax[energydb.EnergyType.ID]; energydb.EnergyStored[energydb.EnergyType.ID] = energyMax; Assert.IsTrue(energyMax >= warpAbility.BubbleCreationCost, "Ship does not store enough energy for a succesfull warp bubble creation"); Assert.AreEqual(warpAbility.CurrentVectorMS.Length(), 0); var posDB = _ship.GetDataBlob <PositionDB>(); var ralpos = posDB.RelativePosition_m; var targetPos = new Vector3(ralpos.X, ralpos.Y, ralpos.Z); targetPos.X += expectedSpeed2 * 60 * 60; //distance for an hours travel. WarpMoveCommand.CreateCommand( _game, _faction, _ship, _sol, targetPos, _ship.StarSysDateTime, new Vector3(0, 0, 0)); Assert.AreEqual(warpAbility.CurrentVectorMS.Length(), expectedSpeed2, 1.0E-15); // _game.GameLoop.Ticklength = TimeSpan.FromSeconds(1); //_game.GameLoop.TimeStep(); StaticRefLib.ProcessorManager.GetProcessor <WarpMovingDB>().ProcessEntity(_ship, 1); var ralposNow = posDB.RelativePosition_m; var distance = Math.Abs((ralpos - ralposNow).Length()); Assert.AreEqual(distance, expectedSpeed2, 1.0E-15); }