public NameIcon(EntityState entityState, GlobalUIState state) : base(entityState.Entity.GetDataBlob <PositionDB>()) { _state = state; _entityGuid = entityState.Entity.Guid; StarSystem starsys = (StarSystem)entityState.Entity.Manager; _starSysGuid = starsys.Guid; _nameDB = entityState.Entity.GetDataBlob <NameDB>(); NameString = _nameDB.GetName(state.Faction); entityState.Name = NameString; entityState.NameIcon = this; _bodyType = entityState.BodyType; }
public void CreateNewFaction() { string factionName = "Terran"; Entity faction = FactionFactory.CreateFaction(_game, factionName); NameDB nameDB = faction.GetDataBlob <NameDB>(); Assert.IsTrue(nameDB.GetName(faction) == factionName); Entity factioncopy = faction.Clone(faction.Manager); Assert.IsTrue(faction.GetValueCompareHash() == factioncopy.GetValueCompareHash(), "Hashes don't match"); }
public IActionResult Edit(int id, Name objTemp) { try { bool updateFlag = NameDB.UpdateName(objTemp); return RedirectToAction("Index"); } catch (Exception) { return View(); } }
public static void NameDB_RealAwake(NameDB __instance) { if (!LanguageService.Languages.TryGetValue(__instance.language, out LanguageCode code)) { code = LanguageCode.English; } if (RogueFramework.IsDebugEnabled(DebugFlags.Names)) { RogueFramework.LogDebug($"Current language: {LanguageService.GetLanguageName(code)} ({(int)code})"); } LanguageService.NameDB = __instance; LanguageService.Current = code; }
public void GameImportExport() { // Nubmer of systems to generate for this test. Configurable. const int numSystems = 10; const bool generateSol = false; int totalSystems = generateSol ? numSystems + 1 : numSystems; // lets create a bad save game: // Check default nulls throw: Assert.Catch <ArgumentNullException>(() => SerializationManager.Export(null, File)); Assert.Catch <ArgumentException>(() => SerializationManager.Export(_game, (string)null)); Assert.Catch <ArgumentException>(() => SerializationManager.Export(_game, string.Empty)); Assert.Catch <ArgumentException>(() => SerializationManager.ImportGame((string)null)); Assert.Catch <ArgumentException>(() => SerializationManager.ImportGame(string.Empty)); Assert.Catch <ArgumentNullException>(() => SerializationManager.ImportGame((Stream)null)); _game = TestingUtilities.CreateTestUniverse(numSystems, _testTime, generateSol); // lets create a good saveGame SerializationManager.Export(_game, File); Assert.IsTrue(System.IO.File.Exists(Path.Combine(SerializationManager.GetWorkingDirectory(), File))); Console.WriteLine(Path.Combine(SerializationManager.GetWorkingDirectory(), File)); // now lets give ourselves a clean game: _game = null; //and load the saved data: _game = SerializationManager.ImportGame(File); _smAuthToken = new AuthenticationToken(_game.SpaceMaster); Assert.AreEqual(totalSystems, _game.GetSystems(_smAuthToken).Count); Assert.AreEqual(_testTime, StaticRefLib.CurrentDateTime); List <Entity> entities = _game.GlobalManager.GetAllEntitiesWithDataBlob <FactionInfoDB>(_smAuthToken); Assert.AreEqual(3, entities.Count); entities = _game.GlobalManager.GetAllEntitiesWithDataBlob <SpeciesDB>(_smAuthToken); Assert.AreEqual(2, entities.Count); // lets check the the refs were hocked back up: Entity species = _game.GlobalManager.GetFirstEntityWithDataBlob <SpeciesDB>(_smAuthToken); NameDB speciesName = species.GetDataBlob <NameDB>(); Assert.AreSame(speciesName.OwningEntity, species); // <?TODO: Expand this out to cover many more DBs, entities, and cases. }
public void CreateClassAndShip() { Entity faction = FactionFactory.CreateFaction(_game, "Terran"); StarSystem starSystem = new StarSystem(_game, "Sol", -1); string shipClassName = "M6 Corvette"; //X Universe ;3 string shipName = "USC Winterblossom"; //Still X Universe var requiredDataBlobs = new List <Type>() { typeof(ShipInfoDB), typeof(ArmorDB), typeof(BeamWeaponsDB), typeof(BuildCostDB), typeof(CargoStorageDB), typeof(CrewDB), typeof(DamageDB), typeof(HangerDB), typeof(IndustryDB), typeof(MaintenanceDB), typeof(MissileWeaponsDB), typeof(PowerDB), typeof(PropulsionDB), typeof(SensorProfileDB), typeof(SensorsDB), typeof(ShieldsDB), typeof(TractorDB), typeof(TroopTransportDB), typeof(NameDB) }; Entity shipClass = ShipFactory.CreateNewShipClass(_game, faction, shipClassName); ShipInfoDB shipClassInfo = shipClass.GetDataBlob <ShipInfoDB>(); NameDB shipClassNameDB = shipClass.GetDataBlob <NameDB>(); //Assert.IsTrue(HasAllRequiredDatablobs(shipClass, requiredDataBlobs), "ShipClass Entity doesn't contains all required datablobs"); Assert.IsTrue(shipClassInfo.ShipClassDefinition == Guid.Empty, "Ship Class ShipInfoDB must have empty ShipClassDefinition Guid"); Assert.IsTrue(shipClassNameDB.GetName(faction) == shipClassName); /////Ship///// Vector4 pos = new Vector4(0, 0, 0, 0); Entity ship = ShipFactory.CreateShip(shipClass, starSystem.SystemManager, faction, pos, starSystem, shipName); ShipInfoDB shipInfo = ship.GetDataBlob <ShipInfoDB>(); NameDB shipNameDB = ship.GetDataBlob <NameDB>(); //Assert.IsTrue(HasAllRequiredDatablobs(ship, requiredDataBlobs), "Ship Entity doesn't contains all required datablobs"); Assert.IsTrue(shipInfo.ShipClassDefinition == shipClass.Guid, "ShipClassDefinition guid must be same as ship class entity guid"); Assert.IsTrue(shipNameDB.GetName(faction) == shipName); }
public IActionResult Index() { // 1. *************RETRIEVE ALL NAMES DETAILS ****************** // GET: Names try { List<Name> myList = new List<Name>(); myList = NameDB.GetNames(); ModelState.Clear(); return View(myList); } catch (Exception ex) { return View(); } }
protected static void NameDB_GetName(NameDB __instance, string myName, string type, ref string __result) { foreach (CustomName name in RogueLibs.Instance.Names) { if (name.Id == myName && (name.Type == null || type == null || name.Type == type)) { int index = Array.IndexOf(RogueLibs.languages, __instance.language); if (index == -1) { index++; } __result = name.Translations[index] ?? name.Translations[0]; return; } } }
// Sets an entity to earth normal aside from the atmosphere private Entity setAtmosphere(AtmosphereDB atmosDB) { SystemBodyInfoDB earthBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true }; NameDB earthNameDB = new NameDB("Earth"); earthBodyDB.Gravity = 1.0; earthBodyDB.BaseTemperature = 20.0f; Entity resultPlanet = new Entity(_entityManager, new List <BaseDataBlob> { earthBodyDB, earthNameDB, atmosDB }); return(resultPlanet); }
public Annex(string id, string parent_id, string namedb, string SPF) { ID = id; PID = parent_id; NameDB = namedb.Replace("\"", "").Replace("\\", "").Replace("/", "").Replace("<", "").Replace(">", "").Replace("*", "").Replace("?", "").Replace(":", "").Replace("|", ""); int i = NameDB.LastIndexOf('.'); if (i > 0) { NameHF = SPF + "_" + PID + "_" + ID + NameDB.Substring(NameDB.LastIndexOf('.')); } else { NameHF = SPF + "_" + PID + "_" + ID; } }
public static Entity CreateShip(ShipDesign shipDesign, Entity ownerFaction, Vector3 position, Entity parent, StarSystem starsys, string shipName = null) { List <BaseDataBlob> dataBlobs = new List <BaseDataBlob>(); var shipinfo = new ShipInfoDB(); dataBlobs.Add(shipinfo); var mvdb = MassVolumeDB.NewFromMassAndVolume(shipDesign.Mass, shipDesign.Volume); dataBlobs.Add(mvdb); PositionDB posdb = new PositionDB(Distance.MToAU(position), starsys.Guid, parent); dataBlobs.Add(posdb); EntityDamageProfileDB damagedb = (EntityDamageProfileDB)shipDesign.DamageProfileDB.Clone(); dataBlobs.Add(damagedb); ComponentInstancesDB compInstances = new ComponentInstancesDB(); dataBlobs.Add(compInstances); OrderableDB ordable = new OrderableDB(); dataBlobs.Add(ordable); var ship = Entity.Create(starsys, ownerFaction.Guid, dataBlobs); //some DB's need tobe created after the entity. var namedb = new NameDB(ship.Guid.ToString()); namedb.SetName(ownerFaction.Guid, shipName); OrbitDB orbit = OrbitDB.FromPosition(parent, ship, starsys.ManagerSubpulses.StarSysDateTime); ship.SetDataBlob(namedb); ship.SetDataBlob(orbit); foreach (var item in shipDesign.Components) { EntityManipulation.AddComponentToEntity(ship, item.design, item.count); } if (ship.HasDataBlob <NewtonThrustAbilityDB>() && ship.HasDataBlob <CargoStorageDB>()) { NewtonionMovementProcessor.CalcDeltaV(ship); } return(ship); }
public void CreateNewFaction() { string factionName = "Terran"; var requiredDataBlobs = new List <Type>() { typeof(FactionInfoDB), typeof(FactionAbilitiesDB), typeof(NameDB), typeof(FactionTechDB) }; Entity faction = FactionFactory.CreateFaction(_game, factionName); NameDB nameDB = faction.GetDataBlob <NameDB>(); //FactionDB factionDB = faction.GetDataBlob<FactionDB>(); Entity factioncopy = faction.Clone(faction.Manager); //Assert.IsTrue(HasAllRequiredDatablobs(faction, requiredDataBlobs)); Assert.IsTrue(nameDB.GetName(faction) == factionName); }
public static void NameDB_GetName(NameDB __instance, string myName, ref string __result) { int count = 0; DoTheNumber(ref myName, ref count); // "english", "schinese", "german", "spanish", "brazilian", "russian", "french", "koreana" string language = __instance.language; if (myName == "ECTD-NoLimitNuggets") { __result = language == "russian" ? "[ECTD] Безлимитные наггетсы" : "[ECTD] No Limit Nuggets"; } else if (myName == "D_ECTD-NoLimitNuggets") { __result = language == "russian" ? "Если включен, позволяет вам набирать более 99 наггетсов. Если выключен, НЕ сбрасывает количество наггетсов." : "If enabled, allows you to get more than 99 nuggets. If disabled, does NOT reset the nuggets amount."; } }
public IActionResult Create(Name objModel) { try { if (ModelState.IsValid) { if (NameDB.AddName(objModel)) { ViewBag.Message = "Name has been successfully added."; ModelState.Clear(); } } return View(); } catch (Exception) { return View(); } }
public IActionResult ShowData() { // 1. *************RETRIEVE ALL NAMES DETAILS ****************** // GET: Names try { List<Name> myList = new List<Name>(); //Name tmp1 = new Name() { ID = 1, FirstName = "Dan", LastName = "Test" }; //Name tmp2 = new Name() { ID = 2, FirstName = "Tom", LastName = "Brady" }; //myList.Add(tmp1); //myList.Add(tmp2); myList = NameDB.GetNames(); ModelState.Clear(); return View(myList); } catch (Exception ex) { return View(); //throw; } }
public void testColonyToxicityCost() { SystemBodyInfoDB earthBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true }; NameDB earthNameDB = new NameDB("Earth"); double expectedCost; string gasSym; Dictionary <string, AtmosphericGasSD> lowToxicGases, highToxicGases, benignGases; AtmosphericGasSD oxygenGas; lowToxicGases = new Dictionary <string, AtmosphericGasSD>(); highToxicGases = new Dictionary <string, AtmosphericGasSD>(); benignGases = new Dictionary <string, AtmosphericGasSD>(); oxygenGas = new AtmosphericGasSD(); //Separate all the gases into the lists above foreach (KeyValuePair <string, AtmosphericGasSD> kvp in _gasDictionary) { gasSym = kvp.Key; if (gasSym == "H2" || gasSym == "CH4" || gasSym == "NH3" || gasSym == "CO" || gasSym == "NO" || gasSym == "H2S" || gasSym == "NO2" || gasSym == "SO2") { lowToxicGases.Add(gasSym, kvp.Value); } else if (gasSym == "Cl2" || gasSym == "F2" || gasSym == "Br2" || gasSym == "I2") { highToxicGases.Add(gasSym, kvp.Value); } else if (gasSym == "O") { oxygenGas = kvp.Value; } else { benignGases.Add(gasSym, kvp.Value); } } // @todo: set up two nested loops - one for list of species, one for list of gases // test a large number of different inputs AtmosphereDB weirdAtmosphereDB; Dictionary <AtmosphericGasSD, float> atmoGasses = new Dictionary <AtmosphericGasSD, float>(); // Test the "low" toxic gases (colony cost 2.0 minimum foreach (KeyValuePair <string, AtmosphericGasSD> kvp in lowToxicGases) { expectedCost = 2.0; gasSym = kvp.Key; atmoGasses.Clear(); atmoGasses.Add(_gasDictionary[gasSym], 0.1f); weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure? _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB); Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>())); } // Test the "high" toxic gases (colony cost 3.0 minimum) foreach (KeyValuePair <string, AtmosphericGasSD> kvp in highToxicGases) { expectedCost = 3.0; gasSym = kvp.Key; atmoGasses.Clear(); atmoGasses.Add(_gasDictionary[gasSym], 0.1f); weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure? _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB); Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>())); } // Test the "benign" toxic gases (no affect on colony cost, but no oxygen means 2.0) foreach (KeyValuePair <string, AtmosphericGasSD> kvp in lowToxicGases) { expectedCost = 2.0; gasSym = kvp.Key; atmoGasses.Clear(); atmoGasses.Add(_gasDictionary[gasSym], 0.1f); weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure? _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB); Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>())); } // test with atmposheres composed of two toxic gases that have the same colony cost foreach (KeyValuePair <string, AtmosphericGasSD> kvp1 in lowToxicGases) { foreach (KeyValuePair <string, AtmosphericGasSD> kvp2 in lowToxicGases) { expectedCost = 2.0; string gasSym1 = kvp1.Key; string gasSym2 = kvp2.Key; if (gasSym1 == gasSym2) { continue; } atmoGasses.Clear(); atmoGasses.Add(lowToxicGases[gasSym1], 0.1f); atmoGasses.Add(lowToxicGases[gasSym2], 0.1f); weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure? _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB); Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>())); } } // test with atmposheres composed of two toxic gases that have the same colony cost foreach (KeyValuePair <string, AtmosphericGasSD> kvp1 in highToxicGases) { foreach (KeyValuePair <string, AtmosphericGasSD> kvp2 in highToxicGases) { expectedCost = 3.0; string gasSym1 = kvp1.Key; string gasSym2 = kvp2.Key; if (gasSym1 == gasSym2) { continue; } atmoGasses.Clear(); atmoGasses.Add(highToxicGases[gasSym1], 0.1f); atmoGasses.Add(highToxicGases[gasSym2], 0.1f); weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure? _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB); Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>())); } } // test with atmospheres composed of two toxic gases that have different colony costs foreach (KeyValuePair <string, AtmosphericGasSD> kvp1 in lowToxicGases) { foreach (KeyValuePair <string, AtmosphericGasSD> kvp2 in highToxicGases) { expectedCost = 3.0; string gasSym1 = kvp1.Key; string gasSym2 = kvp2.Key; if (gasSym1 == gasSym2) { continue; } atmoGasses.Clear(); atmoGasses.Add(lowToxicGases[gasSym1], 0.1f); atmoGasses.Add(highToxicGases[gasSym2], 0.1f); weirdAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 0.3f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure? _weirdatmosPlanet = setAtmosphere(weirdAtmosphereDB); Assert.AreEqual(expectedCost, SpeciesProcessor.ColonyCost(_weirdatmosPlanet, _humanSpecies.GetDataBlob <SpeciesDB>())); } } //Toxic Gasses(CC = 2): Hydrogen(H2), Methane(CH4), Ammonia(NH3), Carbon Monoxide(CO), Nitrogen Monoxide(NO), Hydrogen Sulfide(H2S), Nitrogen Dioxide(NO2), Sulfur Dioxide(SO2) //Toxic Gasses(CC = 3): Chlorine(Cl2), Florine(F2), Bromine(Br2), and Iodine(I2) //Toxic Gasses at 30% or greater of atm: Oxygen(O2) * Assert.AreEqual(1.0, SpeciesProcessor.ColonyCost(_earthPlanet, _humanSpecies.GetDataBlob <SpeciesDB>())); }
public static Entity CreateShip(ShipDesign shipDesign, Entity ownerFaction, Vector3 position, Entity parent, StarSystem starsys, string shipName = null) { List <BaseDataBlob> dataBlobs = new List <BaseDataBlob>(); var shipinfo = new ShipInfoDB(); dataBlobs.Add(shipinfo); var mvdb = MassVolumeDB.NewFromMassAndVolume(shipDesign.MassPerUnit, shipDesign.VolumePerUnit); dataBlobs.Add(mvdb); PositionDB posdb = new PositionDB(Distance.MToAU(position), starsys.Guid, parent); dataBlobs.Add(posdb); EntityDamageProfileDB damagedb = (EntityDamageProfileDB)shipDesign.DamageProfileDB.Clone(); dataBlobs.Add(damagedb); ComponentInstancesDB compInstances = new ComponentInstancesDB(); dataBlobs.Add(compInstances); OrderableDB ordable = new OrderableDB(); dataBlobs.Add(ordable); var ship = Entity.Create(starsys, ownerFaction.Guid, dataBlobs); StaticDataStore staticdata = StaticRefLib.StaticData; ComponentDesigner fireControlDesigner; ComponentDesign integratedfireControl; ComponentTemplateSD bfcSD = staticdata.ComponentTemplates[new Guid("33fcd1f5-80ab-4bac-97be-dbcae19ab1a0")]; fireControlDesigner = new ComponentDesigner(bfcSD, ownerFaction.GetDataBlob <FactionTechDB>()); fireControlDesigner.Name = "Bridge Computer Systems"; fireControlDesigner.ComponentDesignAttributes["Range"].SetValueFromInput(0); fireControlDesigner.ComponentDesignAttributes["Tracking Speed"].SetValueFromInput(0); fireControlDesigner.ComponentDesignAttributes["Size vs Range"].SetValueFromInput(0); //return fireControlDesigner.CreateDesign(faction); integratedfireControl = fireControlDesigner.CreateDesign(ownerFaction); ownerFaction.GetDataBlob <FactionTechDB>().IncrementLevel(integratedfireControl.TechID); //some DB's need tobe created after the entity. var namedb = new NameDB(ship.Guid.ToString()); namedb.SetName(ownerFaction.Guid, shipName); OrbitDB orbit = OrbitDB.FromPosition(parent, ship, starsys.ManagerSubpulses.StarSysDateTime); ship.SetDataBlob(namedb); ship.SetDataBlob(orbit); EntityManipulation.AddComponentToEntity(ship, integratedfireControl, 1); foreach (var item in shipDesign.Components) { EntityManipulation.AddComponentToEntity(ship, item.design, item.count); } if (ship.HasDataBlob <NewtonThrustAbilityDB>()) { NewtonionMovementProcessor.UpdateNewtonThrustAbilityDB(ship); } return(ship); }
// 3. ************* EDIT NAME DETAILS ****************** // GET: Name/Edit/3 public IActionResult Edit(int id) { Name objTest = new Name(); objTest= NameDB.GetName(id); return View(objTest); }