public void TestShipCreation() { ComponentDesign engineDesign; _engineSD = _game.StaticData.ComponentTemplates[new Guid("E76BD999-ECD7-4511-AD41-6D0C59CA97E6")]; engineDesign = GenericComponentFactory.StaticToDesign(_engineSD, _faction.GetDataBlob <FactionTechDB>(), _game.StaticData); engineDesign.ComponentDesignAbilities[0].SetValueFromInput(5); //size = 25 power. //engineDesignDB.ComponentDesignAbilities[1] _engineComponent = GenericComponentFactory.DesignToDesignEntity(_game, _faction, engineDesign); _shipClass = ShipFactory.CreateNewShipClass(_game, _faction, "Ob'enn dropship"); EntityManipulation.AddComponentToEntity(_shipClass, _engineComponent); EntityManipulation.AddComponentToEntity(_shipClass, _engineComponent); Vector4 pos = new Vector4(0, 0, 0, 0); _ship = ShipFactory.CreateShip(_shipClass, _starSystem.SystemManager, _faction, pos, _starSystem, "Serial Peacemaker"); PropulsionDB propulsion = _ship.GetDataBlob <PropulsionDB>(); ShipInfoDB shipInfo = _ship.GetDataBlob <ShipInfoDB>(); //Change in component cloning makes the next line's assumption untrue //Assert.True(_ship.GetDataBlob<ComponentInstancesDB>().SpecificInstances.ContainsKey(_engineComponent)); Assert.AreEqual(50, propulsion.TotalEnginePower); Assert.AreEqual(ShipMovementProcessor.MaxSpeedCalc(propulsion.TotalEnginePower, _ship.GetDataBlob <ShipInfoDB>().Tonnage), propulsion.MaximumSpeed); EntityManipulation.AddComponentToEntity(_ship, _engineComponent); Assert.AreEqual(75, propulsion.TotalEnginePower); Assert.AreEqual(ShipMovementProcessor.MaxSpeedCalc(propulsion.TotalEnginePower, _ship.GetDataBlob <ShipInfoDB>().Tonnage), propulsion.MaximumSpeed); }
public void TestShipCreation() { ComponentDesign engineDesign;// = DefaultStartFactory.DefaultEngineDesign(_game, _faction); _engineSD = NameLookup.GetTemplateSD(_game, "Engine"); engineDesign = GenericComponentFactory.StaticToDesign(_engineSD, _faction.GetDataBlob <FactionTechDB>(), _game.StaticData); engineDesign.ComponentDesignAttributes[0].SetValueFromInput(5); //size = 25 power. _engineComponentDesign = GenericComponentFactory.DesignToDesignEntity(_game, _faction, engineDesign); _shipClass = ShipFactory.CreateNewShipClass(_game, _faction, "Ob'enn dropship"); Assert.True(_shipClass.FactionOwner == _faction.Guid); EntityManipulation.AddComponentToEntity(_shipClass, _engineComponentDesign); EntityManipulation.AddComponentToEntity(_shipClass, _engineComponentDesign); Vector3 pos = new Vector3(0, 0, 0); int designEngineNumber = _shipClass.GetDataBlob <ComponentInstancesDB>().GetNumberOfComponentsOfDesign(_engineComponentDesign.Guid); Assert.AreEqual(2, designEngineNumber); _ship = ShipFactory.CreateShip(_shipClass, _starSystem, _faction, pos, _starSystem, "Serial Peacemaker"); Assert.AreEqual(designEngineNumber, _ship.GetDataBlob <ComponentInstancesDB>().GetNumberOfComponentsOfDesign(_engineComponentDesign.Guid), "Number of engine components not the same as design"); PropulsionAbilityDB propulsion = _ship.GetDataBlob <PropulsionAbilityDB>(); ShipInfoDB shipInfo = _ship.GetDataBlob <ShipInfoDB>(); Assert.AreEqual(500000, propulsion.TotalEnginePower, "Incorrect TotalEnginePower"); float tonnage1 = _ship.GetDataBlob <ShipInfoDB>().Tonnage; int expectedSpeed1 = ShipMovementProcessor.MaxSpeedCalc(propulsion.TotalEnginePower, tonnage1); Assert.AreEqual(expectedSpeed1, propulsion.MaximumSpeed_MS, "Incorrect Max Speed"); EntityManipulation.AddComponentToEntity(_ship, _engineComponentDesign); //add second engine Assert.AreEqual(750000, propulsion.TotalEnginePower, "Incorrect TotalEnginePower 2nd engine added"); float tonnage2 = _ship.GetDataBlob <ShipInfoDB>().Tonnage; int expectedSpeed2 = ShipMovementProcessor.MaxSpeedCalc(propulsion.TotalEnginePower, tonnage2); Assert.AreEqual(expectedSpeed2, propulsion.MaximumSpeed_MS, "Incorrect Max Speed 2nd engine"); }
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); }