private static void AddOrbs(On.RoR2.Orbs.OrbCatalog.orig_GenerateCatalog orig) { orbsAlreadyAdded = true; orig(); Type[] orbCat = typeof(RoR2.Orbs.OrbCatalog).GetFieldValue <Type[]>("indexToType"); Dictionary <Type, int> typeToIndex = typeof(RoR2.Orbs.OrbCatalog).GetFieldValue <Dictionary <Type, int> >("typeToIndex"); int origLength = orbCat.Length; int extraLength = OrbDefinitions.Count; Array.Resize <Type>(ref orbCat, origLength + extraLength); int temp; for (int i = 0; i < extraLength; i++) { temp = i + origLength; orbCat[temp] = OrbDefinitions[i]; typeToIndex.Add(OrbDefinitions[i], temp); } typeof(RoR2.Orbs.OrbCatalog).SetFieldValue <Type[]>("indexToType", orbCat); typeof(RoR2.Orbs.OrbCatalog).SetFieldValue <Dictionary <Type, Int32> >("typeToIndex", typeToIndex); }
private static void AddCustomOrbs(On.RoR2.Orbs.OrbCatalog.orig_GenerateCatalog orig) { orig(); Type[] orbCat = typeof(OrbCatalog).GetFieldValue <Type[]>("indexToType"); Dictionary <Type, Int32> typeToIndex = typeof(OrbCatalog).GetFieldValue <Dictionary <Type, Int32> >("typeToIndex"); Int32 origLength = orbCat.Length; Int32 extraLength = orbs.Count; Array.Resize <Type>(ref orbCat, origLength + extraLength); Int32 temp; for (Int32 i = 0; i < extraLength; i++) { temp = i + origLength; orbCat[temp] = orbs[i]; typeToIndex.Add(orbs[i], temp); } typeof(OrbCatalog).SetFieldValue <Type[]>("indexToType", orbCat); typeof(OrbCatalog).SetFieldValue <Dictionary <Type, Int32> >("typeToIndex", typeToIndex); }