示例#1
0
 public void Dispose()
 {
     if (_items.Contains(Value))
     {
         _items.Remove(Value);
     }
 }
示例#2
0
 static bool Prefix(StarSystem __instance)
 {
     try {
         List <ShopDef> list = new List <ShopDef>();
         foreach (string id in __instance.Sim.DataManager.Shops.Keys)
         {
             ShopDef shopDef = __instance.Sim.DataManager.Shops.Get(id);
             if (shopDef.RequirementTags.Contains(Fields.ShopFileTag))
             {
                 TagSet filteredRequirements = new TagSet(shopDef.RequirementTags);
                 filteredRequirements.Remove(Fields.ShopFileTag);
                 if (SimGameState.MeetsTagRequirements(filteredRequirements, shopDef.ExclusionTags, __instance.Tags, null))
                 {
                     list.Add(shopDef);
                 }
                 else if (Helper.meetsNewReqs(__instance, filteredRequirements, shopDef.ExclusionTags, __instance.Tags))
                 {
                     list.Add(shopDef);
                 }
             }
         }
         AccessTools.Method(typeof(StarSystem), "set_Shop").Invoke(__instance, new object[] { new Shop(__instance, list) });
         return(false);
     }
     catch (Exception e) {
         Logger.LogError(e);
         return(false);
     }
 }
示例#3
0
        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 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 RemoveTag(this MechComponent target, string tag)
        {
            TagSet tags = CustomCombatTagsHelper.prepareTags(target);

            if (tags == null)
            {
                return;
            }
            tags.Remove(tag);
            CustomCombatTagsHelper.saveTags(target, tags);
        }
示例#6
0
        public void AddRemove()
        {
            var list = new TagSet();

            using (list.Add("Order")) {
                Assert.Equal(1, list.Count);

                list.Remove("Order");
            }

            Assert.Equal(0, list.Count);
        }
示例#7
0
            static void Prefix(ref TagSet companyTags)
            {
                var tempTagSet = new TagSet(companyTags);

                foreach (var tag in tempTagSet)
                {
                    if (tag.StartsWith("PilotQuirksSave") || tag.StartsWith("GalaxyAtWarSave"))
                    {
                        companyTags.Remove(tag);
                    }
                }
            }
示例#8
0
        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());
                }
            }
        }
 private void ShowStartingLocationChoices()
 {
     if ((UnityEngine.Object)titleText != (UnityEngine.Object)null)
     {
         titleText.text = "Choose Starting Location";
     }
     startNodes = worldGen.WorldLayout.GetStartNodes();
     startNodes.Shuffle();
     if (startNodes.Count > 0)
     {
         ChooseBaseLocation(startNodes[0]);
     }
     else
     {
         List <SubWorld> list = new List <SubWorld>();
         for (int i = 0; i < startNodes.Count; i++)
         {
             Tree tree = startNodes[i] as Tree;
             if (tree == null)
             {
                 tree = worldGen.GetOverworldForNode(startNodes[i] as Leaf);
                 if (tree == null)
                 {
                     continue;
                 }
             }
             SubWorld subWorldForNode = worldGen.GetSubWorldForNode(tree);
             if (subWorldForNode != null && !list.Contains(subWorldForNode))
             {
                 list.Add(subWorldForNode);
                 GameObject    gameObject = UnityEngine.Object.Instantiate(locationButtonPrefab);
                 RectTransform component  = gameObject.GetComponent <RectTransform>();
                 component.SetParent(chooseLocationPanel);
                 component.localScale = Vector3.one;
                 Text     componentInChildren = gameObject.GetComponentInChildren <Text>();
                 SubWorld subWorld            = null;
                 Tree     parent = startNodes[i].parent;
                 while (subWorld == null && parent != null)
                 {
                     subWorld = worldGen.GetSubWorldForNode(parent);
                     if (subWorld == null)
                     {
                         parent = parent.parent;
                     }
                 }
                 TagSet tagSet = new TagSet(startNodes[i].tags);
                 tagSet.Remove(WorldGenTags.Feature);
                 tagSet.Remove(WorldGenTags.StartLocation);
                 tagSet.Remove(WorldGenTags.IgnoreCaveOverride);
                 componentInChildren.text = tagSet.ToString();
                 int idx = i;
                 Button.ButtonClickedEvent buttonClickedEvent = new Button.ButtonClickedEvent();
                 buttonClickedEvent.AddListener(delegate
                 {
                     ChooseBaseLocation(startNodes[idx]);
                 });
                 Button component2 = gameObject.GetComponent <Button>();
                 component2.onClick = buttonClickedEvent;
             }
         }
     }
 }