public void AddRemoveNested() { var tags = new TagSet(); using (tags.Add("Order")) { using (tags.Add("Step1")) { Assert.Equal(2, tags.Count); using (tags.Add("Step2")) Assert.Equal(3, tags.Count); Assert.Equal(2, tags.Count); } } Assert.Equal(0, tags.Count); }
public void AddTag(Tag tag) { if (tags == null) { tags = new TagSet(); } tags.Add(tag); }
public void Run_dynamiccontent_performance() { var repository = new EFDynamicContentRepository(); var cache = new HttpCacheRepository(); var evaluator = new DynamicContentEvaluator(repository, null, cache); var service = new DynamicContentService(repository, evaluator); DynamicContentConfiguration.Instance.Cache.IsEnabled = true; var tags = new TagSet(); tags.Add("CategoryId", new Tag("VendorVirtual")); tags.Add("StoreId", new Tag("SampleStore")); tags.Add("CurrentUrl", new Tag("http://localhost/store")); var items = service.GetItems("HomeMain", DateTime.Now, tags); //items = service.GetItems("HomeMain", DateTime.Now, tags); }
public void AddBasic() { var list = new TagSet(); using (IDisposable tag = list.Add("Order")) Assert.Equal(1, list.Count); Assert.Equal(0, list.Count); }
public static void Postfix(ref List <TagSet_MDD> __result, TagSetType tagSetType, TagSet requiredTags, TagSet excludedTags) { try { //MAD: string overrideBlacklistedTag = ("ignoreTag-BLACKLISTED").ToLower(); if (!requiredTags.Contains(overrideBlacklistedTag)) { return; } //:DAM MetadataDatabase mdd = MetadataDatabase.Instance; TagSet tags = new TagSet(requiredTags); TagSet tagSet = new TagSet(excludedTags); if (!tagSet.Contains(Tags_MDDExtenstions.BLACKLISTED_TAG)) { tagSet.Add(Tags_MDDExtenstions.BLACKLISTED_TAG); } //MAD: if (tags.Contains(overrideBlacklistedTag)) { Logger.Debug($"[Tags_MDDExtenstions_GetTagSetWithRequiredTags_PREFIX] Request has ignoreTag-BLACKLISTED tag set. Removing BLACKLISTED tag"); tagSet.Remove(Tags_MDDExtenstions.BLACKLISTED_TAG); // Need to remove the custom tag too, otherwise the query below will include it as required -> no result -> fallback unit (cicada) tags.Remove(overrideBlacklistedTag); Logger.Info($"[SimGameState_ResolveCompleteContract_PREFIX] requiredTags: {String.Join(", ", tags.ToArray())}"); Logger.Info($"[SimGameState_ResolveCompleteContract_PREFIX] excludedTags: {String.Join(", ", tagSet.ToArray())}"); } //:DAM List <Tag_MDD> orCreateTagsInTagSet = mdd.GetOrCreateTagsInTagSet(tags); List <Tag_MDD> orCreateTagsInTagSet2 = mdd.GetOrCreateTagsInTagSet(tagSet); string text = "SELECT ts.* FROM TagSet ts "; string text2 = string.Empty; string text3 = string.Format("WHERE ts.TagSetTypeId = {0} ", (int)tagSetType); for (int i = 0; i < orCreateTagsInTagSet.Count; i++) { text2 += string.Format(Tags_MDDExtenstions.GTSWRT_RequiredInnerJoinFormat, i); text3 += string.Format(Tags_MDDExtenstions.GTSWRT_RequiredWhereClauseFormat, i, orCreateTagsInTagSet[i].Name); } for (int j = 0; j < orCreateTagsInTagSet2.Count; j++) { text2 += string.Format(Tags_MDDExtenstions.GTSWRT_ExcludedLeftJoinFormat, j, orCreateTagsInTagSet2[j].Name); text3 += string.Format(Tags_MDDExtenstions.GTSWRT_ExcludedWhereClauseFormat, j); } text = text + text2 + text3 + " COLLATE NOCASE "; __result = mdd.Query <TagSet_MDD>(text, null, null, true, null, null).ToList <TagSet_MDD>(); } catch (Exception e) { Logger.Error(e); } }
public static Vector3 GetC3NonCachedPos(AbstractActor attacker, ICombatant target) { try { if (attacker.EncounterTags.ContainsAny(Core.Settings._C3NetworkEncounterTags) == false) { return(Vector3.zero); } TagSet effectiveC3tags = new TagSet(); foreach (var tag in Core.Settings._C3NetworkEncounterTags) { if (attacker.EncounterTags.Contains(tag)) { effectiveC3tags.Add(tag); } } List <AbstractActor> allies = attacker.Combat.GetAllAlliesOf(attacker); AbstractActor closest = null; float closest_dist = 0f; foreach (AbstractActor ally in allies) { if (ally.IsDead) { continue; } if (ally.IsDeployDirector()) { continue; } if (ally.IsShutDown) { continue; } if (ally.EncounterTags.ContainsAny(effectiveC3tags) == false) { continue; } if (closest == null) { closest = ally; closest_dist = Vector3.Distance(target.CurrentPosition, ally.CurrentPosition); continue; } float dist = Vector3.Distance(target.CurrentPosition, ally.CurrentPosition); if (dist < closest_dist) { closest_dist = dist; closest = ally; } } if (closest != null) { Log.Debug?.TWL(0, "found C3 spotter for " + attacker.PilotableActorDef.ChassisID + " target: " + target.DisplayName + " spotter:" + closest.PilotableActorDef.ChassisID + " distance: " + closest_dist); } return(closest == null ? Vector3.zero: closest.CurrentPosition); } catch (Exception e) { Log.Error?.TWL(0, e.ToString(), true); return(Vector3.zero); } }
public void AddRemove() { var list = new TagSet(); using (list.Add("Order")) { Assert.Equal(1, list.Count); list.Remove("Order"); } Assert.Equal(0, list.Count); }
public static void AddTag(this MechComponent target, string tag) { TagSet tags = CustomCombatTagsHelper.prepareTags(target); if (tags == null) { return; } tags.Add(tag); CustomCombatTagsHelper.saveTags(target, tags); }
public TagSet GetMobTags() { if (mobkeys == null) { mobkeys = new TagSet(); foreach (string key in MobLookupTable.Keys) { mobkeys.Add(new Tag(key)); } } return(mobkeys); }
public IHttpActionResult GetDynamicContent(string store, string[] placeHolders, [FromUri] string[] tags, string language = "en-us") { var tagSet = new TagSet(); if (tags != null) { foreach (var tagArray in tags.Select(tag => tag.Split(new[] { ':' }))) { tagSet.Add(tagArray[0], tagArray[1]); } } // TODO: add tags ?tags={users:[id1,id2]} // TODO: add caching //Mutiple placeholders can be requested var groups = new List <webModel.DynamicContentItemGroup>(); foreach (var holder in placeHolders) { var group = new webModel.DynamicContentItemGroup(holder); var ctx = new DynamicContentEvaluationContext(store, holder, DateTime.Now, tagSet); var results = _contentEvaluator.EvaluateItems(ctx); if (results != null && results.Any()) { group.Items.AddRange(results.Select(x => x.ToWebModel())); groups.Add(group); } } var retVal = new webModel.ResponseCollection <webModel.DynamicContentItemGroup> { Items = groups, TotalCount = groups.Count() }; return(this.Ok(retVal)); //return this.StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult GetDynamicContent( string[] placeHolders, [FromUri] string[] tags, string language = "en-us") { var tagSet = new TagSet(); if (tags != null) { foreach (var tagArray in tags.Select(tag => tag.Split(new[] { ':' }))) { tagSet.Add(tagArray[0], tagArray[1]); } } // TODO: add tags ?tags={users:[id1,id2]} // TODO: add caching //Mutiple placeholders can be requested var groups = new List<webModel.DynamicContentItemGroup>(); foreach (var holder in placeHolders) { var group = new webModel.DynamicContentItemGroup(holder); var ctx = new DynamicContentEvaluationContext(holder, DateTime.Now, tagSet); var results = _contentEvaluator.EvaluateItems(ctx); if (results != null && results.Any()) { group.Items.AddRange(results.Select(x => x.ToWebModel())); groups.Add(group); } } var retVal = new webModel.ResponseCollection<webModel.DynamicContentItemGroup> { Items = groups, TotalCount = groups.Count() }; return this.Ok(retVal); //return this.StatusCode(HttpStatusCode.NoContent); }
static bool Prefix(UnitSpawnPointOverride __instance, ref LoadRequest request, MetadataDatabase mdd, string lanceName, int unitIndex) { if (UnityGameInstance.BattleTechGame.Simulation != null && Core.Settings.UpgradePilots) { try { DataManager dataManager = Traverse.Create(__instance).Field("dataManager").GetValue <DataManager>(); if (__instance.pilotDefId == UnitSpawnPointGameLogic.PilotDef_Tagged && __instance.selectedUnitType == UnitType.Mech && __instance.selectedUnitDefId != UnitSpawnPointGameLogic.MechDef_None && dataManager != null && __instance.pilotTagSet.IsEmpty && __instance.pilotExcludedTagSet.IsEmpty) { //Logger.Log($"Adding Exclusions to pilot: {__instance.pilotDefId}, for lance: {lanceName}, unit index: {unitIndex}, in Mech: {__instance.selectedUnitDefId}"); /* * Skill - Gunnery 8 Piloting 8 Guts 8 Tactics 8 * Gunnery 5 Gunner - Flanker Gladiator Striker * Piloting 5 Pilot Skirmisher - Brawler Scout * Guts 5 Defender Lancer Outrider - Vanguard * Tactics 5 Tactician Sharpshooter Recon Sentinel - */ // Add the Tags we want MechDef mechDef = dataManager.MechDefs.Get(__instance.selectedUnitDefId); TagSet excludeTags = new TagSet(); if (mechDef.Chassis.ChassisTags.Contains("mech_quirk_multitrac")) { // Excluding tier 2 skilled pilots that don't have Multi Target for Multi-Trac quirk excludeTags.Add("pilot_npc_outrider"); excludeTags.Add("pilot_npc_recon"); excludeTags.Add("pilot_npc_brawler"); excludeTags.Add("pilot_npc_sentinel"); excludeTags.Add("pilot_npc_scout"); excludeTags.Add("pilot_npc_vanguard"); } // Brawlers if (mechDef.MechTags.Contains("unit_role_brawler")) { // Excluding tier 2 pilots that have no or next to no survivability skills in brawlers excludeTags.Add("pilot_npc_sharpshooter"); excludeTags.Add("pilot_npc_skirmisher"); if (!mechDef.MechTags.Contains("unit_speed_high")) { // We aren't fast, get rid of shoot and move with no additional survivability excludeTags.Add("pilot_npc_striker"); } if (mechDef.MechTags.Contains("unit_speed_low") && !mechDef.MechTags.Contains("unit_jumpOK")) { // We are slow, can't jump and want to brawl, tactics 8 with Piloting 5 will not be enough for us to live on excludeTags.Add("pilot_npc_scout"); } } // Snipers if (mechDef.MechTags.Contains("unit_role_sniper")) { if (mechDef.MechTags.Contains("unit_speed_low") || (!mechDef.MechTags.Contains("unit_speed_high") && !mechDef.MechTags.Contains("unit_jumpOK"))) { // Excluding all piloting 8 if a sniper in medium speed or less mech excludeTags.Add("pilot_npc_flanker"); excludeTags.Add("pilot_npc_outrider"); excludeTags.Add("pilot_npc_recon"); } } // Scouts if (mechDef.MechTags.Contains("unit_role_scout")) { // Let's throw away Coolant Vent in scouts excludeTags.Add("pilot_npc_gladiator"); excludeTags.Add("pilot_npc_brawler"); excludeTags.Add("pilot_npc_sentinel"); if (mechDef.MechTags.Contains("unit_light") || mechDef.MechTags.Contains("unit_medium")) { // Excluding Gunnery 8 on light and medium scouts excludeTags.Add("pilot_npc_skirmisher"); excludeTags.Add("pilot_npc_lancer"); excludeTags.Add("pilot_npc_sharpshooter"); } } // Slow ass Mechs if (mechDef.MechTags.Contains("unit_speed_low")) { if (!mechDef.MechTags.Contains("unit_jumpOK")) { // Excluding non Outrider, piloting 8 in slow, non JJ Mechs // Leaving Outrider as a brawler might want it even if slow excludeTags.Add("pilot_npc_flanker"); excludeTags.Add("pilot_npc_recon"); } } // Fast fuckers if (mechDef.MechTags.Contains("unit_speed_high")) { if (mechDef.MechTags.Contains("unit_armor_low") && !mechDef.MechTags.Contains("unit_role_sniper")) { // We are protected by paper but fast, we are not a sniper, let's use certain combos if we have a tier 2 skill // Excluding Gunnery 8 excludeTags.Add("pilot_npc_skirmisher"); excludeTags.Add("pilot_npc_lancer"); excludeTags.Add("pilot_npc_sharpshooter"); // Excluding Gunnery 5 if we don't have Piloting 8 excludeTags.Add("pilot_npc_striker"); excludeTags.Add("pilot_npc_gladiator"); } if (!mechDef.MechTags.Contains("unit_armor_high")) { if (!mechDef.MechTags.Contains("unit_hot")) { // We aren't high armour, we are fast, and we aren't hot // Let's throw away Coolant Vent in non hot mechs to improve chances of more appropriate skills excludeTags.Add("pilot_npc_brawler"); excludeTags.Add("pilot_npc_sentinel"); } } } /* * Logger.Log($"Exclusions:"); * foreach (string anExclude in excludeTags) * { * Logger.Log(" " + anExclude); * }*/ // TagSet should remove duplicates so no need to do that __instance.pilotExcludedTagSet.AddRange(excludeTags); /*Logger.Log($"Final Exclusions:"); * foreach (string anExclude in __instance.pilotExcludedTagSet) * { * Logger.Log(" " + anExclude); * }*/ // Now do the same as the method would and don't call original method PilotDef_MDD pilotDef_MDD = UnitSpawnPointOverride.SelectTaggedPilotDef(mdd, __instance.pilotTagSet, __instance.pilotExcludedTagSet, lanceName, unitIndex); __instance.selectedPilotDefId = pilotDef_MDD.PilotDefID; request.AddBlindLoadRequest(BattleTechResourceType.PilotDef, __instance.selectedPilotDefId, new bool?(false)); return(false); } } catch (Exception e) { Logger.Error(e); } } return(true); }
private static PilotDef GenerateCrew(StarSystem starSystem, string callsign, PilotDef pilotDef) { Mod.Log.Debug?.Write($"Generating support crew with callsign: {callsign}"); // Generate the lifepath we'll use LifePath lifePath = LifePathHelper.GetRandomLifePath(); int initialAge = ModState.SimGameState.Constants.Pilot.MinimumPilotAge + ModState.SimGameState.NetworkRandom.Int(1, ModState.SimGameState.Constants.Pilot.StartingAgeRange + 1); int currentAge = Mod.Random.Next(initialAge, 70); Mod.Log.Debug?.Write($" - currentAge: {currentAge}"); Gender newGender = RandomGender(); Gender voiceGender = newGender; if (voiceGender == Gender.NonBinary) { voiceGender = ((!(ModState.SimGameState.NetworkRandom.Float() < 0.5f)) ? Gender.Female : Gender.Male); } string voice = RandomUnusedVoice(voiceGender); string newFirstName = ModState.CrewCreateState.NameGenerator.GetFirstName(newGender); string newLastName = ModState.CrewCreateState.NameGenerator.GetLastName(); Mod.Log.Debug?.Write($" - gender: {newGender} voiceGender: {voiceGender} firstName: {newFirstName} lastName: {newLastName}"); pilotDef.SetVoice(voice); StringBuilder lifepathDescParagraphs = new StringBuilder(); string backgroundTitle = new Text(lifePath.Description.Title).ToString(); string backgroundDesc = new Text(lifePath.Description.Description).ToString(); // DETAILS string is EXTREMELY picky, see HumanDescriptionDef.GetLocalizedDetails. There format must be followed *exactly* string formattedBackground = $"{Environment.NewLine}<b>{backgroundTitle}:</b> {backgroundDesc}"; Mod.Log.Debug?.Write($" - Background: {formattedBackground}"); lifepathDescParagraphs.Append(formattedBackground); // Add tags from the lifepath TagSet tagSet = new TagSet(); tagSet.AddRange(lifePath.RequiredTags); foreach (string tag in lifePath.RandomTags) { double tagRoll = Mod.Random.NextDouble(); if (tagRoll <= Mod.Config.HiringHall.LifePath.RandomTagChance) { tagSet.Add(tag); } } Mod.Log.Debug?.Write($" - Tags: {String.Join(", ", tagSet)}"); // Add tags to the background foreach (string tagId in tagSet) { Tag_MDD tagIfExists = MetadataDatabase.Instance.GetTagIfExists(tagId); if (tagIfExists != null) { TagDataStruct tagStruct = new TagDataStruct(tagId, tagIfExists.PlayerVisible, tagIfExists.Important, tagIfExists.Name, tagIfExists.FriendlyName, tagIfExists.Description); string formattedTag = $"<b><color=#ff8c00>{tagStruct.FriendlyName}:</b> <color=#ffffff>{tagStruct.DescriptionTag}"; lifepathDescParagraphs.Append(formattedTag); } } string id = GenerateID(); HumanDescriptionDef descriptionDef = new HumanDescriptionDef(id, callsign, newFirstName, newLastName, callsign, newGender, FactionEnumeration.GetNoFactionValue(), currentAge, lifepathDescParagraphs.ToString(), null); StatCollection statCollection = pilotDef.GetStats(); int spentXPPilot = GetSpentXPPilot(statCollection); List <string> alreadyAssignedPortraits = new List <string>(); if (ModState.SimGameState.Commander != null && ModState.SimGameState.Commander.pilotDef.PortraitSettings != null) { alreadyAssignedPortraits.Add(ModState.SimGameState.Commander.pilotDef.PortraitSettings.Description.Id); } foreach (Pilot activePilot in ModState.SimGameState.PilotRoster) { if (activePilot.pilotDef.PortraitSettings != null) { alreadyAssignedPortraits.Add(activePilot.pilotDef.PortraitSettings.Description.Id); } } PilotDef pilotDef2 = new PilotDef(descriptionDef, pilotDef.BaseGunnery, pilotDef.BasePiloting, pilotDef.BaseGuts, pilotDef.BaseTactics, 0, ModState.SimGameState.CombatConstants.PilotingConstants.DefaultMaxInjuries, lethalInjury: false, 0, voice, pilotDef.abilityDefNames, AIPersonality.Undefined, 0, tagSet, spentXPPilot, 0) { DataManager = ModState.SimGameState.DataManager, PortraitSettings = GetPortraitForGenderAndAge(voiceGender, currentAge, alreadyAssignedPortraits) }; ModState.SimGameState.pilotGenCallsignDiscardPile.Add(pilotDef2.Description.Callsign); return(pilotDef2); }
public static void ExportCurrentMechDefToJson(this MechLabPanel mechLabPanel, string mechDefId, string mechDefName) { try { MechDef mechDef = new MechDef(mechLabPanel.activeMechDef, null, true); MechDef baseMechDef = new MechDef(mechLabPanel.Sim.DataManager.MechDefs.Get(mechDef.Description.Id), null, false); MechComponentRef[] mechDefInventory = (MechComponentRef[])AccessTools.Field(typeof(MechDef), "inventory").GetValue(mechDef); // Remove fixed equipment as it will be ignored from dismounting et all MechComponentRef[] mechDefInventoryFiltered = mechDefInventory.Where(component => component.IsFixed != true).ToArray(); AccessTools.Field(typeof(MechDef), "inventory").SetValue(mechDef, mechDefInventoryFiltered); // Try to fix HardpointSlots the KISS way foreach (ChassisLocations chassisLocation in Enum.GetValues(typeof(ChassisLocations))) { MechComponentRef[] mechDefWeaponsAtLocation = mechDefInventoryFiltered .Where(component => component.MountedLocation == chassisLocation) .Where(component => component.ComponentDefType == ComponentType.Weapon) .ToArray(); for (int i = 0; i < mechDefWeaponsAtLocation.Length; i++) { new Traverse(mechDefWeaponsAtLocation[i]).Property("HardpointSlot").SetValue(i); Logger.Debug("[Extensions.ExportCurrentMechDefToJson] (" + chassisLocation + ") (" + mechDefWeaponsAtLocation[i].ComponentDefID + ") HardpointSlot: " + mechDefWeaponsAtLocation[i].HardpointSlot); } } // Tag MechDef according to threatLevel/equipment //string additionalTag = Utilities.TagMechDefAccordingToInventory(mechDefInventory); int threatLevel = Utilities.GetExtraThreatLevelFromMechDef(mechDef, true); string additionalTag = Utilities.GetMechTagForThreatLevel(threatLevel); Logger.Debug("[Extensions.ExportCurrentMechDefToJson] additionalTag: " + additionalTag); // Set some halfway correct value for part value int simGameMechPartCost = mechDef.SimGameMechPartCost > 0 ? mechDef.SimGameMechPartCost : (mechDef.BattleValue / 10); string baseDirectory = $"{ MadLabs.ModDirectory}"; string filePath = Path.Combine(Path.Combine(baseDirectory, "MechDefs"), $"{mechDefId}.json"); Directory.CreateDirectory(Directory.GetParent(filePath).FullName); using (StreamWriter streamWriter = new StreamWriter(filePath, false)) //using (JsonTextWriter jsonTextWriter = new JsonTextWriter(streamWriter) { Formatting = Formatting.Indented, Indentation = 4, IndentChar = ' ' }) { string mechDefJson = mechDef.ToJSON(); TagSet mechTags = new TagSet(baseMechDef.MechTags); mechTags.Add("unit_madlabs"); mechTags.Add(additionalTag); if (MadLabs.Settings.BlacklistExportedMechDefs) { mechTags.Add("BLACKLISTED"); } string mechTagsJson = mechTags.ToJSON(); // Fix MechDefJson JObject jMechDef = JObject.Parse(mechDefJson); JObject jBaseMechDefMechTagsJson = JObject.Parse(mechTagsJson); jMechDef.Property("Chassis").Remove(); jMechDef.Property("PaintTextureID").Remove(); jMechDef.Property("HeraldryID").Remove(); jMechDef.Property("simGameMechPartCost").Remove(); jMechDef.Property("prefabOverride").Remove(); jMechDef["MechTags"] = jBaseMechDefMechTagsJson; JObject jDescription = (JObject)jMechDef["Description"]; // Raise rarity? jDescription["Rarity"] = (int)(mechDef.Description.Rarity + 4); jDescription["Manufacturer"] = null; jDescription["Model"] = null; jDescription["Name"] = mechDefName; jDescription["Id"] = mechDefId; jMechDef.Property("ChassisID").AddAfterSelf(new JProperty("HeraldryID", null)); jMechDef.Property("Description").AddAfterSelf(new JProperty("simGameMechPartCost", simGameMechPartCost)); jMechDef["Version"] = 1; JArray jInventory = (JArray)jMechDef["inventory"]; foreach (JObject jComponent in jInventory) { jComponent["SimGameUID"] = null; jComponent.Property("IsFixed").Remove(); jComponent["prefabName"] = null; jComponent["hasPrefabName"] = false; } streamWriter.Write(jMechDef.ToString()); //jMechDef.WriteTo(jsonTextWriter); } } catch (Exception e) { Logger.Error(e); } }
public static void newmap() { JArray jarray = JArray.Parse(File.ReadAllText(@"C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\mods\OldData\systems.json")); string newdata = File.ReadAllText(@"C:\Program Files (x86)\Steam\steamapps\common\BATTLETECH\mods\OldData\planetstest.json"); JArray newdataArray = JArray.Parse(newdata); foreach (JObject system in jarray) { if (!((string)system["affiliation"]).Equals("Clans") && !((string)system["affiliation"]).Equals("Inhabited system") && !((string)system["affiliation"]).Equals("No record") && !((string)system["affiliation"]).Equals("Clan") && !((string)system["affiliation"]).Equals("New Delphi Compact") && !((string)system["affiliation"]).Equals("Alexandrian Covenant") && !((string)system["affiliation"]).Equals("Society of St.Andreas") && !((string)system["affiliation"]).Equals("Hidden system") && !((string)system["affiliation"]).Equals("Society of St. Andreas") && !((string)system["affiliation"]).Equals("Tortuga Dominions") && !((string)system["affiliation"]).Equals("Fiefdom of Randis") && !((string)system["name"]).Equals("New St. Andrews") && !((string)system["name"]).Equals("Mica I") && !((string)system["name"]).Equals("Mica V") && !((string)system["name"]).Equals("Novo Franklin") && !((string)system["name"]).Equals("New Vandenberg") && !((string)system["name"]).Equals("Mica VII")) { FakeVector3 vector = new FakeVector3(); vector.x = (float)system["x"]; vector.y = (float)system["y"]; vector.z = 0; Faction faction; string folder = ""; TagSet tags = new TagSet(); int maxspecials = 0; switch ((string)system["affiliation"]) { case "Lyran Commonwealth": maxspecials++; faction = Faction.Steiner; folder = "Steiner"; tags.Add("planet_civ_innersphere"); tags.Add("planet_faction_steiner"); break; case "Free Worlds League": maxspecials++; faction = Faction.Marik; folder = "Marik"; tags.Add("planet_civ_innersphere"); tags.Add("planet_faction_marik"); break; case "Draconis Combine": maxspecials++; faction = Faction.Kurita; folder = "Kurita"; tags.Add("planet_civ_innersphere"); tags.Add("planet_faction_kurita"); break; case "Federated Suns": maxspecials++; faction = Faction.Davion; folder = "Davion"; tags.Add("planet_civ_innersphere"); tags.Add("planet_faction_davion"); break; case "Capellan Confederation": maxspecials++; faction = Faction.Liao; folder = "Liao"; tags.Add("planet_civ_innersphere"); tags.Add("planet_faction_liao"); break; case "Aurigan Coalition": faction = Faction.AuriganRestoration; folder = "Aurigan"; tags.Add("planet_civ_periphery"); tags.Add("planet_faction_restoration"); break; case "ComStar": maxspecials++; faction = Faction.ComStar; folder = "ComStar"; tags.Add("planet_civ_innersphere"); break; case "Magistracy of Canopus": faction = Faction.MagistracyOfCanopus; folder = "Magistracy"; tags.Add("planet_civ_periphery"); tags.Add("planet_faction_magistracy"); break; case "Taurian Concordat": faction = Faction.TaurianConcordat; folder = "Taurian"; tags.Add("planet_civ_periphery"); tags.Add("planet_faction_taurian"); break; case "Outworlds Alliance": faction = Faction.Betrayers; folder = "Outworld"; tags.Add("planet_civ_periphery"); tags.Add("planet_faction_outworlds"); break; case "Marian Hegemony": faction = Faction.AuriganDirectorate; folder = "Hegemony"; tags.Add("planet_civ_periphery"); tags.Add("planet_faction_marian"); break; case "Oberon Confederation": faction = Faction.MagistracyCentrella; folder = "Oberon"; maxspecials++; tags.Add("planet_civ_periphery"); tags.Add("planet_other_pirate"); tags.Add("planet_other_blackmarket"); tags.Add("planet_faction_oberon"); break; case "Lothian League": faction = Faction.MajestyMetals; folder = "Lothian"; tags.Add("planet_civ_periphery"); tags.Add("planet_faction_lothian"); break; case "Circinus Federation": faction = Faction.Nautilus; folder = "Circinus"; maxspecials++; tags.Add("planet_civ_periphery"); tags.Add("planet_other_pirate"); tags.Add("planet_other_blackmarket"); tags.Add("planet_faction_circinus"); break; case "Illyrian Palatinate": faction = Faction.AuriganMercenaries; folder = "Illyrian"; tags.Add("planet_civ_periphery"); tags.Add("planet_faction_illyrian"); break; default: faction = Faction.Locals; folder = "Locals"; tags.Add("planet_civ_periphery"); break; } if (((string)system["name"]).Equals("Galatea")) { faction = Faction.MercenaryReviewBoard; folder = "MRB"; tags.Remove("planet_faction_steiner"); } string beginjson = File.ReadAllText("C:/Users/morph/Desktop/Neuer Ordner (4)/starsystemdef_Detroit.json"); string name = (string)system["name"]; StarSystemDef def = new StarSystemDef(); def.FromJSON(beginjson); bool fueling = false; string details = " "; List <Biome.BIOMESKIN> biomes = new List <Biome.BIOMESKIN>();; bool newdatafound = false; foreach (JObject newdataObject in newdataArray) { biomes = new List <Biome.BIOMESKIN>(); if (system["name"].Equals(newdataObject["Planet_Name"])) { newdatafound = true; if (!string.IsNullOrEmpty((string)newdataObject["Description"])) { details = ((string)newdataObject["Description"]).Replace("\t", "").Replace("\\", "").Replace("</P>", "").Replace("<P>", "").Replace("\r", "").Replace("\n", "").Replace("</p>", "").Replace("<p>", ""); if (details.Length > 255) { details = details.Substring(0, 255); } } if ((int)newdataObject["Industry"] != 0) { tags.Add("planet_industry_mining"); if ((int)newdataObject["Industry"] >= 100000000) { maxspecials++; tags.Add("planet_industry_rich"); } else { tags.Add("planet_industry_recreation"); } } else { tags.Add("planet_industry_agriculture"); tags.Add("planet_industry_aquaculture"); tags.Add("planet_industry_poor"); } if (!string.IsNullOrEmpty((string)newdataObject["comstar_facility"]) && !((string)newdataObject["comstar_facility"]).Equals("None")) { tags.Add("planet_industry_research"); tags.Add("planet_other_comstar"); tags.Add("planet_other_starleague"); maxspecials++; } if ((int)newdataObject["Capital_Planet"] == 1) { tags.Add("planet_other_capital"); maxspecials++; } if ((long)newdataObject["population"] > 1000000000) { tags.Add("planet_pop_large"); maxspecials++; maxspecials++; if ((long)newdataObject["population"] > 5000000000) { tags.Add("planet_other_megacity"); maxspecials++; } } else if ((int)newdataObject["population"] > 100000000) { tags.Add("planet_pop_medium"); maxspecials++; } else if ((int)newdataObject["population"] > 1000000) { tags.Add("planet_pop_small"); } else { tags.Add("planet_pop_none"); } if ((int)newdataObject["Charge_Station"] == 1) { fueling = true; } if ((int)newdataObject["Factory"] == 123) { tags.Add("planet_industry_manufacturing"); maxspecials++; maxspecials++; } if ((int)newdataObject["hiringhall"] == 1) { tags.Add("planet_other_hub"); } switch ((int)newdataObject["terrain_class_ID"]) { case 1: { tags.Add("planet_climate_terran"); tags.Add("planet_other_megaforest"); biomes.Add(Biome.BIOMESKIN.highlandsSpring); biomes.Add(Biome.BIOMESKIN.highlandsFall); biomes.Add(Biome.BIOMESKIN.lowlandsSpring); biomes.Add(Biome.BIOMESKIN.lowlandsFall); biomes.Add(Biome.BIOMESKIN.badlandsParched); break; } case 2: { tags.Add("planet_climate_lunar"); tags.Add("planet_other_moon"); biomes.Add(Biome.BIOMESKIN.martianVacuum); biomes.Add(Biome.BIOMESKIN.lunarVacuum); break; } case 3: { tags.Add("planet_climate_desert"); tags.Add("planet_other_storms"); biomes.Add(Biome.BIOMESKIN.desertParched); break; } case 4: { tags.Add("planet_climate_arid"); tags.Add("planet_other_mudflats"); tags.Add("planet_other_fungus"); biomes.Add(Biome.BIOMESKIN.lowlandsCoastal); biomes.Add(Biome.BIOMESKIN.badlandsParched); break; } case 5: { tags.Add("planet_climate_arctic"); biomes.Add(Biome.BIOMESKIN.polarFrozen); biomes.Add(Biome.BIOMESKIN.tundraFrozen); break; } case 6: { tags.Add("planet_climate_tropical"); biomes.Add(Biome.BIOMESKIN.lowlandsCoastal); biomes.Add(Biome.BIOMESKIN.lowlandsSpring); biomes.Add(Biome.BIOMESKIN.lowlandsFall); break; } case 7: { tags.Add("planet_climate_rocky"); biomes.Add(Biome.BIOMESKIN.highlandsSpring); biomes.Add(Biome.BIOMESKIN.highlandsFall); break; } case 8: { tags.Add("planet_climate_mars"); tags.Add("planet_other_volcanic"); biomes.Add(Biome.BIOMESKIN.martianVacuum); biomes.Add(Biome.BIOMESKIN.badlandsParched); break; } case 10: { tags.Add("planet_climate_terran"); tags.Add("planet_other_megaforest"); biomes.Add(Biome.BIOMESKIN.highlandsSpring); biomes.Add(Biome.BIOMESKIN.highlandsFall); biomes.Add(Biome.BIOMESKIN.lowlandsSpring); biomes.Add(Biome.BIOMESKIN.lowlandsFall); biomes.Add(Biome.BIOMESKIN.lowlandsCoastal); break; } case 18: { tags.Add("planet_climate_water"); biomes.Add(Biome.BIOMESKIN.lowlandsCoastal); biomes.Add(Biome.BIOMESKIN.highlandsSpring); break; } default: { tags.Add("planet_climate_terran"); biomes.Add(Biome.BIOMESKIN.highlandsSpring); biomes.Add(Biome.BIOMESKIN.highlandsFall); biomes.Add(Biome.BIOMESKIN.lowlandsSpring); biomes.Add(Biome.BIOMESKIN.lowlandsFall); biomes.Add(Biome.BIOMESKIN.desertParched); biomes.Add(Biome.BIOMESKIN.badlandsParched); biomes.Add(Biome.BIOMESKIN.lowlandsCoastal); biomes.Add(Biome.BIOMESKIN.lunarVacuum); biomes.Add(Biome.BIOMESKIN.martianVacuum); biomes.Add(Biome.BIOMESKIN.polarFrozen); biomes.Add(Biome.BIOMESKIN.tundraFrozen); break; } } break; } } if (newdatafound) { tags.Add("planet_size_medium"); } else { tags.Add("planet_climate_terran"); tags.Add("planet_size_medium"); biomes.Add(Biome.BIOMESKIN.highlandsSpring); biomes.Add(Biome.BIOMESKIN.highlandsFall); biomes.Add(Biome.BIOMESKIN.lowlandsSpring); biomes.Add(Biome.BIOMESKIN.lowlandsFall); biomes.Add(Biome.BIOMESKIN.desertParched); biomes.Add(Biome.BIOMESKIN.badlandsParched); biomes.Add(Biome.BIOMESKIN.lowlandsCoastal); biomes.Add(Biome.BIOMESKIN.lunarVacuum); biomes.Add(Biome.BIOMESKIN.martianVacuum); biomes.Add(Biome.BIOMESKIN.polarFrozen); biomes.Add(Biome.BIOMESKIN.tundraFrozen); } DescriptionDef desc = new DescriptionDef(("starsystemdef_" + system["name"]).Replace(" ", string.Empty).Replace("'", string.Empty), (string)system["name"], details, "", 0, 0, false, "", "", ""); StarSystemDef def2 = new StarSystemDef(desc, vector, tags, false, 7, faction, getAllies(faction), getEnemies(faction), def.SystemInfluence, def.TravelRequirements); foreach (JObject newdataObject in newdataArray) { if (system["name"].Equals(newdataObject["Planet_Name"])) { break; } } ReflectionHelper.InvokePrivateMethode(def2, "set_FuelingStation", new object[] { fueling }); ReflectionHelper.InvokePrivateMethode(def2, "set_Difficulty", new object[] { 5 }); ReflectionHelper.InvokePrivateMethode(def2, "set_StarType", new object[] { StarType.G }); ReflectionHelper.InvokePrivateMethode(def2, "set_JumpDistance", new object[] { 7 }); ReflectionHelper.InvokePrivateMethode(def2, "set_ShopMaxSpecials", new object[] { maxspecials }); ReflectionHelper.InvokePrivateMethode(def2, "set_SupportedBiomes", new object[] { biomes }); foreach (JObject newdataObject in newdataArray) { if (system["name"].Equals(newdataObject["Planet_Name"])) { ReflectionHelper.InvokePrivateMethode(def2, "set_StarType", new object[] { getStartype((string)newdataObject["SpecClass"]) }); if ((float)newdataObject["travel_time"] != 0f) { ReflectionHelper.InvokePrivateMethode(def2, "set_JumpDistance", new object[] { (int)newdataObject["travel_time"] }); } break; } } string json = def2.ToJSON(); JObject jsonObject = JObject.Parse(json); JObject descriptionjson = (JObject)jsonObject["Description"]; descriptionjson.Add("Id", "starsystemdef_" + ((string)system["name"]).Replace(" ", string.Empty).Replace("'", string.Empty)); descriptionjson.Add("Name", (string)system["name"]); descriptionjson.Add("Details", details); // string json = JsonConvert.SerializeObject(def2, new Newtonsoft.Json.Converters.StringEnumConverter()); string path = "C:/Program Files (x86)/Steam/steamapps/common/BATTLETECH/mods/OldData/" + folder + "/starsystemdef_" + ((string)system["name"]).Replace(" ", string.Empty).Replace("'", string.Empty) + ".json"; (new FileInfo(path)).Directory.Create(); File.WriteAllText(path, jsonObject.ToString()); } } }