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);
        }
示例#2
0
        public void TestRefinedMatsSave()
        {
            Dictionary <Guid, ProcessedMaterialSD> mats = new Dictionary <Guid, ProcessedMaterialSD>();

            ProcessedMaterialSD soriumFuel = new ProcessedMaterialSD();

            soriumFuel.Name             = "Sorium Fuel";
            soriumFuel.Description      = "Fuel for SpaceShips";
            soriumFuel.ID               = new Guid("33E6AC88-0235-4917-A7FF-35C8886AAD3A");
            soriumFuel.MineralsRequired = new Dictionary <Guid, int>();
            soriumFuel.MineralsRequired.Add(new Guid("08f15d35-ea1d-442f-a2e3-bde04c5c22e9"), 1);
            soriumFuel.Mass = 1;
            //soriumFuel.CargoType = CargoType.Fuel;
            soriumFuel.IndustryPointCosts = 10;
            soriumFuel.OutputAmount       = 1;
            mats.Add(soriumFuel.ID, soriumFuel);

            ProcessedMaterialSD DepleatedDuranuim = new ProcessedMaterialSD();

            DepleatedDuranuim.Name             = "Depleated Duranuim";
            DepleatedDuranuim.Description      = "A mix of Duranium and refined fuel to teset refinarys";
            DepleatedDuranuim.ID               = new Guid("6DA93677-EE08-4853-A8A5-0F46D93FE0EB");
            DepleatedDuranuim.MineralsRequired = new Dictionary <Guid, int>();
            DepleatedDuranuim.MineralsRequired.Add(new Guid("2dfc78ea-f8a4-4257-bc04-47279bf104ef"), 5);
            DepleatedDuranuim.MaterialsRequired = new Dictionary <Guid, int>();
            DepleatedDuranuim.MaterialsRequired.Add(new Guid("33E6AC88-0235-4917-A7FF-35C8886AAD3A"), 1);
            DepleatedDuranuim.Mass = 1;
            //DepleatedDuranuim.CargoType = CargoType.General;
            DepleatedDuranuim.IndustryPointCosts = 20;
            DepleatedDuranuim.OutputAmount       = 6;
            mats.Add(DepleatedDuranuim.ID, DepleatedDuranuim);

            StaticDataManager.ExportStaticData(mats, "ReinfedMaterialsDataExportTest.json");
        }
        public void TestEngineComponentFactory()
        {
            ComponentTemplateSD engine = EngineComponentSD();

            ComponentDesign design = GenericComponentFactory.StaticToDesign(engine, _faction.GetDataBlob <FactionTechDB>(), _game.StaticData);

            foreach (var ability in design.ComponentDesignAttributes)
            {
                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();
                }
            }

            design.ComponentDesignAttributes[0].SetValueFromInput(250);

            Entity engineEntity = GenericComponentFactory.DesignToDesignEntity(_game, _faction, design);

            Assert.AreEqual(250, engineEntity.GetDataBlob <ComponentInfoDB>().SizeInTons);

            Dictionary <Guid, ComponentTemplateSD> componentsDict = new Dictionary <Guid, ComponentTemplateSD>();

            componentsDict.Add(engine.ID, engine);
            StaticDataManager.ExportStaticData(componentsDict, "EngineComponentTest.json");
        }
示例#4
0
        void HandleGameSettings(NetIncomingMessage message)
        {
            DateTime hostDateTime = DateTime.FromBinary(message.ReadInt64());
            int      len          = message.ReadInt32();

            byte[] data = message.ReadBytes(len);


            Game              = new Game();
            _gameVM.Game      = Game;
            Game.OrderHandler = this;
            var mStream = new MemoryStream(data);

            StaticRefLib.GameSettings = SerializationManager.ImportGameSettings(mStream);
            mStream.Close();
            Game.GamePulse.GameGlobalDateTime = hostDateTime;
            //TODO: #CleanCode: the below should probilby be in refactored to somewhere else.
            //TODO: #Network: it should also maybe be able to request a dataset from the server if it hasn't got it localy.
            if (Game.Settings.DataSets != null)
            {
                foreach (string dataSet in Game.Settings.DataSets)
                {
                    StaticDataManager.LoadData(dataSet, Game);
                }
            }
            if (Game.StaticData.LoadedDataSets.Count == 0)
            {
                StaticDataManager.LoadData("Pulsar4x", Game);
            }
            mStream.Close();
        }
示例#5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public XmlQueryStaticData(XmlWriterSettings defaultWriterSettings, IList<WhitespaceRule> whitespaceRules, StaticDataManager staticData)
        {
            Debug.Assert(defaultWriterSettings != null && staticData != null);
            _defaultWriterSettings = defaultWriterSettings;
            _whitespaceRules = whitespaceRules;
            _names = staticData.Names;
            _prefixMappingsList = staticData.PrefixMappingsList;
            _filters = staticData.NameFilters;
            _types = staticData.XmlTypes;
            _collations = staticData.Collations;
            _globalNames = staticData.GlobalNames;
            _earlyBound = staticData.EarlyBound;

#if DEBUG
            // Round-trip check
            byte[] data;
            Type[] ebTypes;
            this.GetObjectData(out data, out ebTypes);
            XmlQueryStaticData copy = new XmlQueryStaticData(data, ebTypes);

            _defaultWriterSettings = copy._defaultWriterSettings;
            _whitespaceRules = copy._whitespaceRules;
            _names = copy._names;
            _prefixMappingsList = copy._prefixMappingsList;
            _filters = copy._filters;
            _types = copy._types;
            _collations = copy._collations;
            _globalNames = copy._globalNames;
            _earlyBound = copy._earlyBound;
#endif
        }
示例#6
0
        public void Init()
        {
            NewGameSettings settings = new NewGameSettings();

            settings.MaxSystems = 5;

            _game = new Game(settings);
            StaticDataManager.LoadData("Pulsar4x", _game);
            _player  = _game.AddPlayer("Test Player");
            _faction = DefaultStartFactory.DefaultHumans(_game, _player, "Test Faction");

            _starSystem = _game.Systems.First <KeyValuePair <Guid, StarSystem> >().Value;
            _planets    = _starSystem.SystemManager.GetAllEntitiesWithDataBlob <SystemBodyInfoDB>();

            _earth = _planets.Where <Entity>(planet => planet.GetDataBlob <NameDB>().GetName(_faction) == "Earth").First <Entity>();

            _ship             = _starSystem.SystemManager.GetAllEntitiesWithDataBlob <ShipInfoDB>().First <Entity>();
            _shipPropulsionDB = _ship.GetDataBlob <PropulsionDB>();
            _target           = _ship.Clone(_starSystem.SystemManager);

            _systems = new List <StarSystem>();

            foreach (KeyValuePair <Guid, StarSystem> kvp in _game.Systems)
            {
                _systems.Add(kvp.Value);
            }
        }
示例#7
0
        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");
        }
示例#8
0
        public void TestLoadDefaultData()
        {
            Game game = new Game(new NewGameSettings { GameName = "Unit Test Game", StartDateTime = DateTime.Now, MaxSystems = 0 });
            var staticDataStore = game.StaticData;

            // store counts for later:
            int mineralsNum = staticDataStore.CargoGoods.GetMineralsList().Count;
            int techNum = staticDataStore.Techs.Count;
            int constructableObjectsNum = staticDataStore.CargoGoods.GetMaterialsList().Count;

            // check that data was loaded:
            Assert.IsNotEmpty(staticDataStore.CargoGoods.GetMineralsList());
            Assert.IsNotEmpty(staticDataStore.AtmosphericGases);
            Assert.IsNotEmpty(staticDataStore.CargoGoods.GetMaterialsList());
            Assert.IsNotEmpty(staticDataStore.CargoTypes);
            Assert.IsNotEmpty(staticDataStore.Techs);

            // now lets re-load the same data, to test that duplicates don't occure as required:
            StaticDataManager.LoadData("Pulsar4x", game);

            // now check that overwriting occured and that there were no duplicates:
            Assert.AreEqual(mineralsNum, staticDataStore.CargoGoods.GetMineralsList().Count);
            Assert.AreEqual(techNum, staticDataStore.Techs.Count);
            Assert.AreEqual(constructableObjectsNum, staticDataStore.CargoGoods.GetMaterialsList().Count);

            // now lets test some malformed data folders.
            StaticDataLoadException ex = Assert.Throws<StaticDataLoadException>(
            delegate { StaticDataManager.LoadData("MalformedData", game); });
            Assert.That(ex.Message, Is.EqualTo("Error while loading static data: Bad Json provided in directory: MalformedData"));


            // now ,lets try for a directory that does not exist.
            Assert.Throws<DirectoryNotFoundException>(
            delegate { StaticDataManager.LoadData("DoesNotExist", game); });
        }
示例#9
0
        /// <summary>
        /// 仅服务器使用
        /// </summary>
        /// <param name="path"></param>
        public static void LoadTable(string path)
        {
            mDataSet.Clear();
            DirectoryInfo parentdi = new DirectoryInfo(path);

            StaticDataManager.registerModel();
            var files = parentdi.GetFiles("*.txt");

            //List<RelationInfo> relations = new List<RelationInfo>();
            foreach (var file in files)
            {
                string name = System.IO.Path.GetFileNameWithoutExtension(file.Name);
                using (var reader = file.OpenText())
                {
                    string dataStr = reader.ReadToEnd();
                    try
                    {
                        if (StaticDataManager.Dic.ContainsKey(name))
                        {
                            IDataModel model = (IDataModel)StaticDataManager.Dic[name];
                            model.initData(dataStr);
                        }
                    }
                    catch (System.Exception e)
                    {
                    }
                }
            }

            //CreateRelation(relations, mDataSet);
        }
示例#10
0
        /// <summary>
        /// Loads the spaces for this zone
        /// </summary>
        /// <param name="zoneDef"></param>
        /// <returns></returns>
        private int LoadSpaces(ZoneDef zoneDef)
        {
            var count = 0;

            zoneDef.Spaces.OfType <DictionaryAtom>().ToList().ForEach(space =>
            {
                var id  = space.GetInt("ID");
                var def = StaticDataManager.GetStaticData(Globals.SystemTypes.Space.GetValue(),
                                                          id.ToString(CultureInfo.InvariantCulture));
                if (def.IsNull())
                {
                    throw new InvalidDataException($"Definition for Space {id} not found.");
                }

                var spaceDef = def.CastAs <SpaceDef>();
                if (spaceDef.IsNull())
                {
                    throw new InvalidDataException($"Definition file {id} was not a SpaceDef file.");
                }

                var obj = EntityManager.Create <Space>(id, spaceDef.Name, spaceDef);
                if (obj.IsNull())
                {
                    throw new InstantiationException("Space {0} could not be instantiated.", id);
                }

                _loadingSet.AddItem($"Space{obj.ID}");
                obj.OnInit(InitializationAtom);
                count++;
            });

            return(count);
        }
示例#11
0
        public void TestCargoType()
        {
            Dictionary <Guid, CargoTypeSD> cargoTypes = new Dictionary <Guid, CargoTypeSD>();
            CargoTypeSD cargoTypeGeneral = new CargoTypeSD()
            {
                ID          = new Guid("16B4C4F0-7292-4F4D-8FEA-22103C70B288"),
                Name        = "General",
                Description = "Storage for general cargo items"
            };

            cargoTypes.Add(cargoTypeGeneral.ID, cargoTypeGeneral);

            CargoTypeSD cargoTypeFuel = new CargoTypeSD()
            {
                ID          = new Guid("D8E8DA2D-8DC8-4A3F-B989-5F2E67C55E77"),
                Name        = "Fuel",
                Description = "Storage for fuel"
            };

            cargoTypes.Add(cargoTypeFuel.ID, cargoTypeFuel);

            CargoTypeSD cargoTypePopulation = new CargoTypeSD()
            {
                ID          = new Guid("9E52A3AF-66AF-4935-982D-26F3FEE775B0"),
                Name        = "Cryogenic Storage",
                Description = "Storage for frozen people"
            };

            cargoTypes.Add(cargoTypePopulation.ID, cargoTypePopulation);

            StaticDataManager.ExportStaticData(cargoTypes, "CargoTypeDataExportTest.json");
        }
 void Update()
 {
     // Debugging and testing code
     // TODO: remove once there are ui buttons for these in the test scene
     if (Input.GetKeyDown(KeyCode.S))
     {
         SavePlayerData();
     }
     if (Input.GetKeyDown(KeyCode.C))
     {
         TestChangePlayerData();
     }
     if (Input.GetKeyDown(KeyCode.D))
     {
         TestDeleteData();
     }
     if (Input.GetKeyDown(KeyCode.V))
     {
         TestLoadCSVData();
     }
     if (Input.GetKeyDown(KeyCode.Alpha4))
     {
         TestCurrencyChange();
     }
     if (Input.GetKeyDown(KeyCode.G))
     {
         StaticDataManager.SaveGameData(Application.dataPath);
     }
 }
示例#13
0
        public static void loadDatafromDirectory(string dir)
        {
            StaticDataManager.LoadFromDirectory(dir, Program.staticData);
            LoadedDataSets = Program.staticData.LoadedDataSets.Count;

            foreach (var installationKVP in Program.staticData.Installations)
            {
                InstallationData.Add(installationKVP.Key, new DataHolder(installationKVP.Value));
            }
            foreach (var componentKVP in Program.staticData.Components)
            {
                ComponentData.Add(componentKVP.Key, new DataHolder(componentKVP.Value));
            }
            foreach (var mineralSD in Program.staticData.Minerals)
            {
                MineralData.Add(mineralSD.ID, new DataHolder(mineralSD));
            }
            foreach (var techKVP in Program.staticData.Techs)
            {
                TechData.Add(techKVP.Key, new DataHolder(techKVP.Value));
            }
            //foreach (var refinedData in Program.staticData.RefinedMats)
            //{
            //    RefinedObjData.Add(refinedData.Key, new DataHolder(refinedData.Value));
            //}
            SysGen.Add(new Guid(), new DataHolder(Program.staticData.SystemGenSettings));
        }
示例#14
0
        public void TestIDLookup()
        {
            // Create an empty data store:
            Game game = new Game(new NewGameSettings { GameName = "Unit Test Game", StartDateTime = DateTime.Now, MaxSystems = 0 });
            var staticDataStore = game.StaticData;

            // test when the store is empty:
            object testNullObj = staticDataStore.FindDataObjectUsingID(Guid.NewGuid());
            Assert.IsNull(testNullObj);

            // Load the default static data to test against:
            StaticDataManager.LoadData("Pulsar4x", game);

            // test with a guid that is not in the store:
            object testObj = staticDataStore.FindDataObjectUsingID(Guid.Empty);  // empty guid should never be in the store.
            Assert.IsNull(testObj);

            // now lets test for values that are in the store:
            Guid testID = staticDataStore.CargoGoods.GetMinerals().FirstOrDefault().Key;
            testObj = staticDataStore.FindDataObjectUsingID(testID);
            Assert.IsNotNull(testObj);
            Assert.AreEqual(testID, ((MineralSD)testObj).ID);
            
            testObj = staticDataStore.FindDataObjectUsingID(testID);
            Assert.IsNotNull(testObj);

            testID = staticDataStore.Techs.First().Key;
            testObj = staticDataStore.FindDataObjectUsingID(testID);
            Assert.IsNotNull(testObj);
            Assert.AreEqual(testID, ((TechSD)testObj).ID);
        }
示例#15
0
        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");
        }
示例#16
0
 public static void SaveDataToDirectory(string dir)
 {
     StaticDataManager.ExportStaticData(Program.staticData.Installations, dir + "\\InstallationData.json");
     StaticDataManager.ExportStaticData(Program.staticData.Components, dir + "\\ComponentData.json");
     StaticDataManager.ExportStaticData(Program.staticData.Minerals, dir + "\\MineralData.json");
     StaticDataManager.ExportStaticData(Program.staticData.Techs, dir + "\\TechnologyData.json");
     StaticDataManager.ExportStaticData(Program.staticData.SystemGenSettings, dir + "\\SystemGenSettings.json");
 }
示例#17
0
        public void Init()
        {
            var gameSettings = new NewGameSettings();

            gameSettings.MaxSystems = 10;
            _game = new Game(gameSettings);
            StaticDataManager.LoadData("Pulsar4x", _game);
            _entityManager = new EntityManager(_game);
        }
        public void TestSingleSystemSave()
        {
            _game = TestingUtilities.CreateTestUniverse(1);
            _smAuthToken = new AuthenticationToken(_game.SpaceMaster);

            StarSystemFactory starsysfac = new StarSystemFactory(_game);
            StarSystem sol  = starsysfac.CreateSol(_game);
            StaticDataManager.ExportStaticData(sol, "solsave.json");
        }
示例#19
0
 public NewGameOptionsVM()
 {
     CreatePlayerFaction = true;
     DefaultStart        = true;
     FactionName         = "United Earth Federation";
     FactionPassword     = "";
     GmPassword          = "";
     NumberOfSystems     = 50;
     AvailableModList    = new ObservableCollection <DataVersionInfo>(StaticDataManager.AvailableData());
     SelectedModList     = new ObservableCollection <DataVersionInfo>();
 }
示例#20
0
	private void GetStaticData()
	{
		staticDataManager = FindObjectOfType(typeof(StaticDataManager)) as StaticDataManager;
		projects = staticDataManager.projects;
		
		foreach(ProjectDescriptor project in projects)
		{
			GameObject imagesResources = Instantiate(project.imageResources.gameObject) as GameObject;
			imagesResources.transform.parent = transform;
		}
	}
    public T GetDataByDName <T>(string dName) where T : BaseStaticData
    {
        List <T> curDataList = StaticDataManager.GetDataList <T>();

        foreach (T dataItem in curDataList)
        {
            if (dataItem.displayName == dName)
            {
                return(dataItem);
            }
        }
        return(null);
    }
 /// <summary>
 /// Constructor.
 /// </summary>
 public XmlILCommand(ExecuteDelegate delExec, QilExpression qil, StaticDataManager staticData)
 {
     Debug.Assert(qil != null);
     this.delExec = delExec;
     this.defaultWriterSettings = qil.DefaultWriterSettings;
     this.wsRules            = qil.WhitespaceRules;
     this.names              = staticData.Names;
     this.prefixMappingsList = staticData.PrefixMappingsList;
     this.filters            = staticData.NameFilters;
     this.types              = staticData.XmlTypes;
     this.collations         = staticData.Collations;
     this.globalNames        = staticData.GlobalNames;
     this.earlyInfo          = staticData.EarlyBound;
 }
示例#23
0
 static int InitData(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         StaticDataManager obj = (StaticDataManager)ToLua.CheckObject <StaticDataManager>(L, 1);
         obj.InitData();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#24
0
    static int GetInstance(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 0);
            StaticDataManager o = Singleton <StaticDataManager> .GetInstance();

            ToLua.PushObject(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
示例#25
0
        public void TestMineInstalationFactory()
        {
            ComponentTemplateSD mine = MineInstallation();

            ComponentDesign mineDesign = GenericComponentFactory.StaticToDesign(mine, _faction.GetDataBlob <FactionTechDB>(), _game.StaticData);

            mineDesign.ComponentDesignAttributes[0].SetValue();
            Entity mineEntity = GenericComponentFactory.DesignToDesignEntity(_game, _faction, mineDesign);

            Assert.AreEqual(10, mineEntity.GetDataBlob <MineResourcesAtbDB>().ResourcesPerEconTick.Values.ElementAt(0));

            Dictionary <Guid, ComponentTemplateSD> componentsDict = new Dictionary <Guid, ComponentTemplateSD>();

            componentsDict.Add(mine.ID, mine);
            StaticDataManager.ExportStaticData(componentsDict, "MineComponentTest.json");
        }
示例#26
0
        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");
        }
示例#27
0
 static int GetSkillTable(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         StaticDataManager obj = (StaticDataManager)ToLua.CheckObject <StaticDataManager>(L, 1);
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         LuaInterface.LuaTable o = obj.GetSkillTable(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#28
0
        public void ExportComponents()
        {
            ComponentTemplateSD engine   = EngineComponentSD();
            ComponentTemplateSD mine     = MineInstallation();
            ComponentTemplateSD lab      = ResearchLab();
            ComponentTemplateSD refinery = Refinery();
            ComponentTemplateSD factory  = Factory();
            Dictionary <Guid, ComponentTemplateSD> componentsDict = new Dictionary <Guid, ComponentTemplateSD>();

            componentsDict.Add(engine.ID, engine);
            componentsDict.Add(mine.ID, mine);
            componentsDict.Add(lab.ID, lab);
            componentsDict.Add(refinery.ID, refinery);
            componentsDict.Add(factory.ID, factory);
            StaticDataManager.ExportStaticData(componentsDict, "ComponentData.json");
        }
示例#29
0
        public void TestFactoryComponentCreation()
        {
            ComponentTemplateSD factory = Factory();

            ComponentDesign facDesign = GenericComponentFactory.StaticToDesign(factory, _faction.GetDataBlob <FactionTechDB>(), _game.StaticData);

            facDesign.ComponentDesignAttributes[0].SetValue();
            Entity facDesignEntity = GenericComponentFactory.DesignToDesignEntity(_game, _faction, facDesign);

            ConstructionAtbDB attributeDB = facDesignEntity.GetDataBlob <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");
        }
示例#30
0
        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");
        }
示例#31
0
        public void TestOverwriteDefaultData()
        {
            Game game = new Game(new NewGameSettings { GameName = "Unit Test Game", StartDateTime = DateTime.Now, MaxSystems = 0 });
            StaticDataManager.LoadData("Pulsar4x", game);
            var staticDataStore = game.StaticData;

            // store counts for later:
            int mineralsNum = staticDataStore.CargoGoods.GetMineralsList().Count;
            Guid someGuid = new Guid("08f15d35-ea1d-442f-a2e3-bde04c5c22e9");
            string someName = staticDataStore.CargoGoods.GetMineral(someGuid).Name;
            
            StaticDataManager.LoadData("Other", game);
            staticDataStore = game.StaticData;
            
            // now check that overwriting occured and that there were no duplicates:
            Assert.AreEqual(mineralsNum, staticDataStore.CargoGoods.GetMineralsList().Count);
            //check the name has been overwritten
            Assert.AreNotEqual(someName, staticDataStore.CargoGoods.GetMineral(someGuid).Name);
        }
示例#32
0
        public void TestCargoComponentCreation()
        {
            ComponentTemplateSD cargo = GeneralCargo();

            ComponentDesign cargoDesign = GenericComponentFactory.StaticToDesign(cargo, _faction.GetDataBlob <FactionTechDB>(), _game.StaticData);

            cargoDesign.ComponentDesignAttributes[0].SetValue();
            Entity cargoEntity = GenericComponentFactory.DesignToDesignEntity(_game, _faction, cargoDesign);

            CargoStorageAtbDB attributeDB = cargoEntity.GetDataBlob <CargoStorageAtbDB>();


            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");
        }
示例#33
0
        /// <summary>
        /// Cache metadata used during code-generation phase.
        /// </summary>
        // SxS note: Using hardcoded "dump.il" is an SxS issue. Since we are doing this ONLY in debug builds 
        // and only for tracing purposes and MakeVersionSafeName does not seem to be able to handle file 
        // extensions correctly I decided to suppress the SxS message (as advised by SxS guys).
        public GenerateHelper(XmlILModule module, bool isDebug)
        {
            _isDebug = isDebug;
            _module = module;
            _staticData = new StaticDataManager();

#if DEBUG
            if (XmlILTrace.IsEnabled)
                XmlILTrace.PrepareTraceWriter("dump.il");
#endif
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public XmlILCommand(ExecuteDelegate delExec, QilExpression qil, StaticDataManager staticData) {
     Debug.Assert(qil != null);
     this.delExec = delExec;
     this.defaultWriterSettings = qil.DefaultWriterSettings;
     this.wsRules = qil.WhitespaceRules;
     this.names = staticData.Names;
     this.prefixMappingsList = staticData.PrefixMappingsList;
     this.filters = staticData.NameFilters;
     this.types = staticData.XmlTypes;
     this.collations = staticData.Collations;
     this.globalNames = staticData.GlobalNames;
     this.earlyInfo = staticData.EarlyBound;
 }