コード例 #1
0
        public static ShipFactory.ShipClass DefaultShipDesign(Game game, Entity faction)
        {
            if (_defaultShipClass != null)
            {
                return(_defaultShipClass);
            }
            _defaultShipClass            = new ShipFactory.ShipClass(faction.GetDataBlob <FactionInfoDB>());
            _defaultShipClass.DesignName = "Ob'enn dropship";
            List <(ComponentDesign, int)> components2 = new List <(ComponentDesign, int)>()
            {
                (ShipPassiveSensor(game, faction), 1),
                (DefaultSimpleLaser(game, faction), 2),
                (DefaultBFC(game, faction), 1),
                (ShipSmallCargo(game, faction), 1),
                (DefaultFuelTank(game, faction), 2),
                (DefaultWarpDesign(game, faction), 4),
                (DefaultBatteryBank(game, faction), 3),
                (DefaultFisionReactor(game, faction), 1),
                (DefaultThrusterDesign(game, faction), 3),
            };

            _defaultShipClass.Components = components2;
            _defaultShipClass.Armor      = ("Polyprop", 1175f, 3);

            _defaultShipClass.DamageProfileDB = new EntityDamageProfileDB(components2, _defaultShipClass.Armor);
            return(_defaultShipClass);
        }
コード例 #2
0
        public static ShipFactory.ShipClass GunShipDesign(Game game, Entity faction)
        {
            var shipdesign = new ShipFactory.ShipClass(faction.GetDataBlob <FactionInfoDB>());

            shipdesign.DesignName = "Sanctum Adroit GunShip";
            List <(ComponentDesign, int)> components2 = new List <(ComponentDesign, int)>()
            {
                (_sensor_50, 1),
                (_laser, 4),
                (_fireControl, 2),
                (_fuelTank_500, 2),
                (_warpDrive, 4),
                (_battery, 3),
                (_reactor, 1),
                (_thruster500, 4),
            };

            shipdesign.Components = components2;
            shipdesign.Armor      = ("Polyprop", 1175f, 3);

            shipdesign.DamageProfileDB = new EntityDamageProfileDB(components2, shipdesign.Armor);
            return(shipdesign);
        }
コード例 #3
0
        public static ShipFactory.ShipClass CargoShipDesign(Game game, Entity faction)
        {
            var shipdesign = new ShipFactory.ShipClass(faction.GetDataBlob <FactionInfoDB>());

            shipdesign.DesignName = "Cargo Courier";
            List <(ComponentDesign, int)> components2 = new List <(ComponentDesign, int)>()
            {
                (DefaultSimpleLaser(game, faction), 1),
                (DefaultBFC(game, faction), 1),
                (_sensor_50, 1),
                (DefaultFuelTank(game, faction), 2),
                (_cargoHold, 1),
                (_warpDrive, 4),
                (_battery, 3),
                (_reactor, 1),
                (_thruster500, 4),
            };

            shipdesign.Components = components2;
            shipdesign.Armor      = ("Polyprop", 1175f, 3);

            shipdesign.DamageProfileDB = new EntityDamageProfileDB(components2, shipdesign.Armor);
            return(shipdesign);
        }
コード例 #4
0
        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);

            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 Guid("35608fe6-0d65-4a5f-b452-78a3e5e6ce2c")]); //add conventional engine for testing.
            ResearchProcessor.CheckRequrements(factionTech);

            DefaultThrusterDesign(game, factionEntity);
            DefaultWarpDesign(game, factionEntity);
            DefaultFuelTank(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);

            EntityManipulation.AddComponentToEntity(colonyEntity, mineDesign);
            EntityManipulation.AddComponentToEntity(colonyEntity, refinaryDesign);
            EntityManipulation.AddComponentToEntity(colonyEntity, labEntity);
            EntityManipulation.AddComponentToEntity(colonyEntity, facEntity);

            EntityManipulation.AddComponentToEntity(colonyEntity, _fuelTank_500);

            EntityManipulation.AddComponentToEntity(colonyEntity, _cargoInstalation);
            EntityManipulation.AddComponentToEntity(marsColony, _cargoInstalation);

            EntityManipulation.AddComponentToEntity(colonyEntity, _sensorInstalation);
            ReCalcProcessor.ReCalcAbilities(colonyEntity);


            colonyEntity.GetDataBlob <ColonyInfoDB>().Population[speciesEntity] = 9000000000;
            var rawSorium = NameLookup.GetMineralSD(game, "Sorium");

            StorageSpaceProcessor.AddCargo(colonyEntity.GetDataBlob <CargoStorageDB>(), rawSorium, 5000);


            factionEntity.GetDataBlob <FactionInfoDB>().KnownSystems.Add(solSys.Guid);



            //test systems
            //factionEntity.GetDataBlob<FactionInfoDB>().KnownSystems.Add(starfac.CreateEccTest(game).Guid);
            //factionEntity.GetDataBlob<FactionInfoDB>().KnownSystems.Add(starfac.CreateLongitudeTest(game).Guid);


            factionEntity.GetDataBlob <NameDB>().SetName(factionEntity.Guid, "UEF");


            // Todo: handle this in CreateShip
            ShipFactory.ShipClass shipClass    = DefaultShipDesign(game, factionEntity);
            ShipFactory.ShipClass gunShipClass = GunShipDesign(game, factionEntity);

            Entity ship1   = ShipFactory.CreateShip(shipClass, factionEntity, earth, solSys, "Serial Peacemaker");
            Entity ship2   = ShipFactory.CreateShip(shipClass, factionEntity, earth, solSys, "Ensuing Calm");
            Entity ship3   = ShipFactory.CreateShip(shipClass, factionEntity, earth, solSys, "Touch-and-Go");
            Entity gunShip = ShipFactory.CreateShip(gunShipClass, factionEntity, earth, solSys, "Prevailing Stillness");
            Entity courier = ShipFactory.CreateShip(CargoShipDesign(game, factionEntity), factionEntity, earth, solSys, "Planet Express Ship");
            var    fuel    = NameLookup.GetMaterialSD(game, "Sorium Fuel");
            var    rp1     = NameLookup.GetMaterialSD(game, "LOX/Hydrocarbon");

            StorageSpaceProcessor.AddCargo(ship1.GetDataBlob <CargoStorageDB>(), rp1, 15000);
            StorageSpaceProcessor.AddCargo(ship2.GetDataBlob <CargoStorageDB>(), rp1, 15000);
            StorageSpaceProcessor.AddCargo(ship3.GetDataBlob <CargoStorageDB>(), rp1, 15000);
            StorageSpaceProcessor.AddCargo(gunShip.GetDataBlob <CargoStorageDB>(), rp1, 15000);
            StorageSpaceProcessor.AddCargo(courier.GetDataBlob <CargoStorageDB>(), rp1, 15000);
            var elec = NameLookup.GetMaterialSD(game, "Electrical Energy");

            ship1.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID]   = 2750;
            ship2.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID]   = 2750;
            ship3.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID]   = 2750;
            gunShip.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750;
            courier.GetDataBlob <EnergyGenAbilityDB>().EnergyStored[elec.ID] = 2750;



            NewtonionMovementProcessor.CalcDeltaV(ship1);
            NewtonionMovementProcessor.CalcDeltaV(ship2);
            NewtonionMovementProcessor.CalcDeltaV(ship3);
            NewtonionMovementProcessor.CalcDeltaV(gunShip);
            NewtonionMovementProcessor.CalcDeltaV(courier);
            //StorageSpaceProcessor.AddCargo(ship1.GetDataBlob<CargoStorageDB>(), fuel, 200000000000);
            //StorageSpaceProcessor.AddCargo(ship2.GetDataBlob<CargoStorageDB>(), fuel, 200000000000);
            //StorageSpaceProcessor.AddCargo(ship3.GetDataBlob<CargoStorageDB>(), fuel, 200000000000);


            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>().Mass;
            OrbitDB testOrbtdb_ship2 = OrbitDB.FromAsteroidFormat(solStar, solStar.GetDataBlob <MassVolumeDB>().Mass, 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>().Mass, 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);


            gunShip.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);
            gunShip.RemoveDataBlob <OrbitDB>();
            var nmdb = new NewtonMoveDB(earth, new Vector3(0, -10000.0, 0));

            gunShip.SetDataBlob <NewtonMoveDB>(nmdb);



            solSys.SetDataBlob(ship1.ID, new TransitableDB());
            solSys.SetDataBlob(ship2.ID, new TransitableDB());
            solSys.SetDataBlob(gunShip.ID, new TransitableDB());
            solSys.SetDataBlob(courier.ID, new TransitableDB());

            //Entity ship = ShipFactory.CreateShip(shipClass, sol.SystemManager, factionEntity, position, sol, "Serial Peacemaker");
            //ship.SetDataBlob(earth.GetDataBlob<PositionDB>()); //first ship reference PositionDB

            //Entity ship3 = ShipFactory.CreateShip(shipClass, 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);
        }