static CustomHealthCardUtility() { //field_lastMaxIconsTotalWidth = Traverse.Create(typeof(HealthCardUtility)).Field<float>("lastMaxIconsTotalWidth"); //field_scrollViewHeight = Traverse.Create(typeof(HealthCardUtility)).Field<float>("scrollViewHeight"); //field_scrollPosition = Traverse.Create(typeof(HealthCardUtility)).Field<Vector2>("scrollPosition"); field_highlight = Traverse.Create(typeof(HealthCardUtility)).Field <bool>("highlight"); method_CanEntryBeClicked = Traverse.Create(typeof(HealthCardUtility)).Method("CanEntryBeClicked", new Type[] { typeof(IEnumerable <Hediff>), typeof(Pawn) }); method_EntryClicked = Traverse.Create(typeof(HealthCardUtility)).Method("EntryClicked", new Type[] { typeof(IEnumerable <Hediff>), typeof(Pawn) }); method_GetTooltip = Traverse.Create(typeof(HealthCardUtility)).Method("GetTooltip", new Type[] { typeof(IEnumerable <Hediff>), typeof(Pawn), typeof(BodyPartRecord) }); method_GetListPriority = Traverse.Create(typeof(HealthCardUtility)).Method("GetListPriority", new Type[] { typeof(BodyPartRecord) }); if (CompactHediffsMod.pawnmorpherLoaded) { method_pawnmorpher_Tooltip = Traverse.CreateWithType("Pawnmorph.PatchHealthCardUtilityDrawHediffRow")?.Method("Tooltip", new Type[] { typeof(IEnumerable <Hediff>) }); if (!method_pawnmorpher_Tooltip.MethodExists()) { method_pawnmorpher_Tooltip = null; } } if (CompactHediffsMod.eliteBionicsLoaded) { //for the record, Vectorial1024, this is really rather rude. method_eliteBionics_GetMaxHealth = Traverse.CreateWithType("EBF.VanillaExtender")?.Method("GetMaxHealth", new Type[] { typeof(BodyPartDef), typeof(Pawn), typeof(BodyPartRecord) }); if (!method_eliteBionics_GetMaxHealth.MethodExists()) { method_eliteBionics_GetMaxHealth = null; } } }
static void Postfix(GameMain __instance) { if (Input.GetKeyDown(KeyCode.Keypad3)) { if (__instance.gameMode == 3300) { Directory.CreateDirectory("data/raw"); int lang = __instance.gameSystemWork.gameSelect; Main.Log.LogDebug($"Dumping L{lang} data..."); DumpData("data/raw/scenarioInfoData.json", __instance.scenarioInfoData); DumpData("data/raw/charaData.json", __instance.unitManager.charaData); DumpData($"data/raw/eventData_{lang}.json", __instance.eventData); DumpData($"data/raw/eventMessageData_{lang}.json", Traverse.CreateWithType("StData").Field("eventMessageList").GetValue <EventMessageList>()); DumpData($"data/raw/scenarioUnitList_{lang}.json", __instance.scenarioUnitList); DumpData($"data/raw/classTree.json", __instance.unitManager.classTreeData); DumpData($"data/raw/classData.json", __instance.unitManager.classData); DumpData($"data/raw/itemData.json", __instance.unitManager.itemData); DumpData($"data/raw/weaponData.json", __instance.unitManager.weaponData); DumpData($"data/raw/skillData.json", __instance.unitManager.skillData); DumpData($"data/raw/magicData.json", __instance.unitManager.magicData); DumpData($"data/raw/levelUpPattern.json", __instance.unitManager.levelUpData); DumpData($"data/raw/impactAreaData.json", __instance.unitManager.impactAreaData); DumpData($"data/raw/unitAnimationList.json", __instance.unitManager.unitAnimeData); DumpData($"data/raw/bgmData.json", __instance.soundCTRL.bgmData); Main.Log.LogDebug("Done."); } else { Main.Log.LogDebug("Wait game mode 3300."); } } }
public static bool GetItemEnum(AvatarCustomizationCategory type, BodyTypes currentBodyType, ref IEnumerable<CustomizationItemDefinition> __result) { List<CharacterBodyDefinition> bodiesList = Traverse.CreateWithType("CharacterManager").Field("bodiesList").GetValue<List<CharacterBodyDefinition>>(); foreach (CharacterBodyDefinition item in bodiesList) { item.BodyType = currentBodyType; } List<CharacterHeadDefinition> headsList = Traverse.CreateWithType("CharacterManager").Field("headsList").GetValue<List<CharacterHeadDefinition>>(); foreach (CharacterHeadDefinition item in headsList) { item.BodyType = currentBodyType; } List<CharacterHairDefinition> hairList = Traverse.CreateWithType("CharacterManager").Field("hairList").GetValue<List<CharacterHairDefinition>>(); foreach (CharacterHairDefinition item in hairList) { item.BodyType = currentBodyType; } List<CharacterHeadDecoDefinition> glassesList = Traverse.CreateWithType("CharacterManager").Field("glassesList").GetValue<List<CharacterHeadDecoDefinition>>(); foreach (CharacterHeadDecoDefinition item in glassesList) { item.BodyType = currentBodyType; } return true; }
private static void LoadTextures() { BGMain = ContentFinder <Texture2D> .Get("Prophecy/Meta/BGMain", true); ProTitle = ContentFinder <Texture2D> .Get("Prophecy/Meta/ProTitle", true); try { Traverse.CreateWithType("UI_BackgroundMain").Field("BGPlanet").SetValue(BGMain); } catch { Log.Message("ProTBin.LoadTextures: Failed to Traverse BGPlanet"); } // Textures for PNC_Cards texPassionMinorIcon = ContentFinder <Texture2D> .Get("UI/Icons/PassionMinor", true); texPassionMajorIcon = ContentFinder <Texture2D> .Get("UI/Icons/PassionMajor", true); texSkillBarFill = SolidColorMaterials.NewSolidColorTexture(new Color(1f, 1f, 1f, 0.1f)); texSkillBarFillMinorPassion = BumpGradient(new Color(1f, 1f, 0f, .4f), new Color(1f, 1f, 1f, 0.1f)); texSkillBarFillMajorPassion = BumpGradient(new Color(1f, 0f, 0f, .4f), new Color(1f, 1f, 1f, 0.1f)); texWeaponsTab = ContentFinder <Texture2D> .Get("Prophecy/PreGame/WeaponsTab", true); texWeaponsTab.wrapMode = TextureWrapMode.Clamp; texFoodsTab = ContentFinder <Texture2D> .Get("Prophecy/PreGame/Tab_Foods", true); texFoodsTab.wrapMode = TextureWrapMode.Clamp; texApparelTab = ContentFinder <Texture2D> .Get("Prophecy/PreGame/Tab_Apparel", true); texApparelTab.wrapMode = TextureWrapMode.Clamp; texDrugsTab = ContentFinder <Texture2D> .Get("Prophecy/PreGame/Tab_Drugs", true); texDrugsTab.wrapMode = TextureWrapMode.Clamp; texResourcesTab = ContentFinder <Texture2D> .Get("Prophecy/PreGame/Tab_Resources", true); texResourcesTab.wrapMode = TextureWrapMode.Clamp; texItemsTab = ContentFinder <Texture2D> .Get("Prophecy/PreGame/Tab_Items", true); texItemsTab.wrapMode = TextureWrapMode.Clamp; texWeaponsTab_Hover = ContentFinder <Texture2D> .Get("Prophecy/PreGame/WeaponsTab_Hover", true); texWeaponsTab_Hover.wrapMode = TextureWrapMode.Clamp; texVellum = ContentFinder <Texture2D> .Get("Prophecy/PreGame/Vellum", true); texVellum.wrapMode = TextureWrapMode.Repeat; }
/// <summary> /// methodName = "CanWear", "CanEat" or "CanEquip" /// </summary> public static bool AlienFrameworkAllowsIt(ThingDef raceDef, ThingDef thingDef, string methodName) { var method = Traverse.CreateWithType("RaceRestrictionSettings").Method(methodName, thingDef, raceDef); if (!method.MethodExists()) { return(true); // Not using AlienFramework } return(method.GetValue <bool>()); }
public static void SkillExpPatch_AddExp(ref UnitPlayAbility __instance) { if (skillExpInBattle.Value) { Type t = Traverse.CreateWithType("UnitPlayAbilityEventArgs").GetValue <Type>(); object args = Traverse.Create(__instance).Field("args").GetValue(); WuxiaUnit attacker = t.GetField("Attacker").GetValue(args) as WuxiaUnit; SkillData skillData = t.GetField("UseSkill").GetValue(args) as SkillData; AddExpInBattle(attacker, skillData.Id); } }
public static string AddResource(UnityEngine.Object obj, string newAssetId, Type type) { string fallbackId = obj.GetType().Name; string assetId = string.Format("{0}:{1}{2}", newAssetId, fallbackId, AssetSuffix); var resourceType = Traverse.CreateWithType("Kingmaker.Blueprints.ResourcesLibrary+LoadedResource").GetValue <Type>(); object resource = Activator.CreateInstance(resourceType); Traverse.Create(resource).Field("Resource").SetValue(obj); Traverse.Create(resource).Field("RequestCounter").SetValue(1); var list = Traverse.Create(typeof(ResourcesLibrary)).Field("s_LoadedResources").GetValue <object>(); Traverse.Create(list).Method("Add", new object[] { assetId, resource }).GetValue(); return(assetId); }
private static void LoadTextures() { BGMain = ContentFinder <Texture2D> .Get("UI/HeroArt/TTABGPlanet", true); try { Traverse.CreateWithType("UI_BackgroundMain").Field("BGPlanet").SetValue(BGMain); } catch { if (debug) { Log.Message("Failed to Traverse BGPlanet"); } } }
// public static List <string> returnPlanetFactionLoadIds() { //List<Faction> finalList = new List<Faction>(); Type typ = FactionColonies.returnUnknownTypeFromName("SaveOurShip2.WorldSwitchUtility"); Type typ2 = FactionColonies.returnUnknownTypeFromName("SaveOurShip2.WorldFactionList"); var mainclass = Traverse.CreateWithType(typ.ToString()); var dict = mainclass.Property("PastWorldTracker").Field("WorldFactions").GetValue(); var planetfactiondict = Traverse.Create(dict); var unknownclass = planetfactiondict.Property("Item", new object[] { Find.World.info.name }).GetValue(); var factionlist = Traverse.Create(unknownclass); var list = factionlist.Field("myFactions").GetValue(); List <String> modifiedlist = (List <String>)list; return(modifiedlist); }
public static bool PreFSaveGame(string fileName) { try { Traverse traverse = Traverse.CreateWithType("GameDataSaveLoader").Field("lastSaveTick"); SafeSaver.Save(GenFilePaths.FilePathForSavedGame(fileName), "savegame", delegate { ScribeMetaHeaderUtility.WriteMetaHeader(); Game game = Current.Game; Scribe_Deep.Look <Game>(ref game, "Κgame", new object[0]); }); traverse.SetValue(Find.TickManager.TicksGame); } catch (Exception e) { Log.Message(string.Format("EXCEPTION! {0}.{1} \n\tMESSAGE: {2} \n\tException occurred calling {3} method", e.TargetSite.ReflectedType.Name, e.TargetSite.Name, e.Message)); } return(false); }
static FreeInputCEMod() { Regex validNameRegex_free = new Regex(".*"); try { Traverse.CreateWithType("RimWorld.Outfit").Field("ValidNameRegex").SetValue(validNameRegex_free); } catch (Exception e) { Log.Error(e.ToString()); } try { Traverse.CreateWithType("RimWorld.CharacterCardUtility").Field("ValidNameRegex").SetValue(validNameRegex_free); } catch (Exception e) { Log.Error(e.ToString()); } try { Traverse.CreateWithType("RimWorld.Dialog_ManageDrugPolicies").Field("ValidNameRegex").SetValue(validNameRegex_free); } catch (Exception e) { Log.Error(e.ToString()); } try { Traverse.CreateWithType("RimWorld.Dialog_ManageAreas").Field("validNameRegex").SetValue(validNameRegex_free); } catch (Exception e) { Log.Error(e.ToString()); } try { Traverse.CreateWithType("CombatExtended.Dialog_ManageLoadouts").Field("validNameRegex").SetValue(validNameRegex_free); } catch (Exception e) { Log.Message("FreeInputCE: Fix input for Extended loadout names skipped.\n" + e.ToString()); } //HardcoreSK CoreSK.dll (B18) //try //{ // Traverse.CreateWithType("StorageSearch.Dialog_ManageOutfits_Patch").Field("ValidNameRegex").SetValue(validNameRegex_free); //} //catch (Exception e) { Log.Message("FreeInputCE: Fix input for HardcoreSK outfit names skipped.\n" + e.ToString()); } }
public static void OnOpen() { try { if (fakeKingdomStash != null) { Game.Instance.UI.LootWindowController.OnButtonClose(); return; } fakeKingdomStash = new GameObject("FakeKingdomStash"); var loot = fakeKingdomStash.AddComponent <LootComponent>(); Traverse.Create(loot).Field("m_AddMapMarker").SetValue(false); loot.Data = new LootComponent.LootPersistentData(Enumerable.Empty <LootEntry>()) { AlreadyUnlocked = true, Enabled = true }; loot.LootContainerType = LootContainerType.PlayerChest; var kingdomLoot = fakeKingdomStash.AddComponent <KingdomLootComponent>(); kingdomLoot.OnAreaDidLoad(); var resourceType = Traverse.CreateWithType("Kingmaker.View.MapObjects.LootComponent+TriggerData").GetValue <Type>(); object triggerData = Activator.CreateInstance(resourceType); var actionsHolder = ScriptableObject.CreateInstance <ActionsHolder>(); actionsHolder.Actions.Actions = new GameAction[] { new DisposeFakeStash(fakeKingdomStash) }; Traverse.Create(triggerData).Field("Action").SetValue(actionsHolder); Traverse.Create(loot).Field("m_OnClosedTrigger").SetValue(triggerData); loot.Interact(Game.Instance.Player.MainCharacter.Value); } catch (Exception ex) { Main.Error(ex); } }
internal static void Init() { DetectMoreAccessories(); Harmony.CreateAndPatchAll(typeof(Hooks)); MakerAPI.InsideMakerChanged += MakerAPI_InsideMakerChanged; MakerAPI.MakerFinishedLoading += (sender, args) => OnSelectedMakerSlotChanged(sender, 0); NoMoreaccsFallback: if (MoreAccessoriesInstalled) { try { var patchesTraverse = Traverse.CreateWithType("MoreAccessoriesAI.Patches.ChaControl_Patches, MoreAccessories"); //GetCmpAccessory(ChaControl self, int slotNo) var mGca = patchesTraverse.Method("GetCmpAccessory", new Type[] { typeof(ChaControl), typeof(int) }); if (!mGca.MethodExists()) { throw new InvalidOperationException("Failed to find MoreAccessoriesAI.Patches.ChaControl_Patches.GetCmpAccessory"); } _getChaAccessoryCmp = (control, componentIndex) => mGca.GetValue <CmpAccessory>(control, componentIndex); _getChaAccessoryCmpIndex = (control, component) => { var idx = Array.IndexOf(control.cmpAccessory, component); if (idx >= 0) { return(idx); } // No better way than to iterate the entries until we get an out of range exception idx = 20; try { while (true) { if (_getChaAccessoryCmp(control, idx) == component) { return(idx); } idx++; } } catch (ArgumentOutOfRangeException) { return(-1); } }; //ChaFileAccessory.PartsInfo GetPartsInfo(ChaControl self, int slotNo) var mGpi = patchesTraverse.Method("GetPartsInfo", new Type[] { typeof(ChaControl), typeof(int) }); if (!mGpi.MethodExists()) { throw new InvalidOperationException("Failed to find MoreAccessoriesAI.Patches.ChaControl_Patches.GetPartsInfo"); } _getPartsInfo = i => mGpi.GetValue <ChaFileAccessory.PartsInfo>(MakerAPI.GetCharacterControl(), i); } catch (Exception e) { _moreAccessoriesType = null; KoikatuAPI.Logger.LogWarning("Failed to set up MoreAccessories integration!"); KoikatuAPI.Logger.LogDebug(e); goto NoMoreaccsFallback; } } else { _getChaAccessoryCmp = (control, i) => control.cmpAccessory[i]; _getChaAccessoryCmpIndex = (control, component) => Array.IndexOf(control.cmpAccessory, component); _getPartsInfo = i => MakerAPI.GetCharacterControl().nowCoordinate.accessory.parts[i]; } }
public static bool PreFMainMenuOnGUI() { VersionControl.DrawInfoInCorner(); // Calculate main menu frame float floFramePadding = 25f; float floFrameWidth = (UI.screenWidth - (UI.screenWidth / 1.62f)) / 1.62f; float floFrameHeight = (UI.screenHeight / 1.62f); float floFrameX = UI.screenWidth - (floFrameWidth + floFramePadding); float floFrameY = (UI.screenHeight - floFrameHeight) / 2f; float floAspect = (float)UI.screenWidth / (float)UI.screenHeight; if (floAspect > 2f) { floFrameWidth = floFrameHeight * .765f; floFrameX = UI.screenWidth - (floFrameWidth + floFramePadding); } if (floAspect < 1.25) { floFrameWidth = floFrameHeight * .477f; floFrameX = UI.screenWidth - (floFrameWidth + floFramePadding); } // Shape RimWorld Title. float floTexTitleWidth = floFrameWidth - (floFrameWidth / 1.62f); float floTexTitleHeight = (floTexTitleWidth / TitleSize.x) * TitleSize.y; // Draw Rimworld Title. Rect rectTexTitle = new Rect(floFrameX + (floFrameWidth * .05f), floFrameY, floTexTitleWidth, floTexTitleHeight); GUI.DrawTexture(rectTexTitle, TexTitle, ScaleMode.StretchToFill, true); // Shape Prophecy Title. float floProTitleWidth = floFrameWidth; float floProTitleHeight = (floProTitleWidth / ProTitleSize.x) * ProTitleSize.y; // Draw Prophecy Title. Rect rectProTitle = new Rect(floFrameX, (floFrameY + floTexTitleHeight) - floProTitleHeight * .1f, floProTitleWidth, floProTitleHeight); GUI.DrawTexture(rectProTitle, ProTBin.ProTitle, ScaleMode.StretchToFill, true); // Shape main page credit. if (UI.screenWidth > 1700f) { Text.Font = GameFont.Medium; } else { Text.Font = GameFont.Small; } Text.Anchor = TextAnchor.UpperLeft; string str = "MainPageCredit".Translate(); float floMPCWidth = floFrameWidth; float floMPCHeight = Text.CalcHeight(str, floMPCWidth); // Draw main page credit. Rect rectMPC = new Rect(floFrameX, rectProTitle.y + floProTitleHeight, floMPCWidth, floMPCHeight); Widgets.Label(rectMPC, str); // Revert GUI text size. Text.Font = GameFont.Small; // Shape main menu controls. float floMMCHeight = floFrameHeight - floMPCHeight - floProTitleHeight - floTexTitleHeight; // Draw main menu controls. Rect rectMMC = new Rect(floFrameX, rectMPC.y + (floMPCHeight * 2f), floFrameWidth, floMMCHeight); MainMenuDrawer.DoMainMenuControls(rectMMC, Traverse.CreateWithType("MainMenuDrawer").Field("anyMapFiles").GetValue <bool>()); // Shape Ludeon logo. GUI.color = new Color(1f, 1f, 1f, 0.5f); float ludeonLogoSize = (float)(UI.screenWidth - 8) - LudeonLogoSize.x; float ludeonLogoSize1 = LudeonLogoSize.x; Vector2 ludeonLogoSize2 = LudeonLogoSize; // Draw Ludeon logo. Rect rect4 = new Rect(ludeonLogoSize, 8f, ludeonLogoSize1, ludeonLogoSize2.y); GUI.DrawTexture(rect4, TexLudeonLogo, ScaleMode.StretchToFill, true); // Revert GUI text color GUI.color = Color.white; return(false); }
static ProTraverses() { travGenerateRandomOldAgeInjuries = Traverse.CreateWithType("AgeInjuryUtility").Method("GenerateRandomOldAgeInjuries", new Type[] { typeof(Pawn), typeof(PawnGenerationRequest) }, null); }
internal static void Init() { DetectMoreAccessories(); BepInEx.Harmony.HarmonyWrapper.PatchAll(typeof(Hooks)); MakerAPI.InsideMakerChanged += MakerAPI_InsideMakerChanged; MakerAPI.MakerFinishedLoading += (sender, args) => OnSelectedMakerSlotChanged(sender, 0); NoMoreaccsFallback: if (MoreAccessoriesInstalled) { try { var patchesTraverse = Traverse.CreateWithType("MoreAccessoriesAI.Patches.ChaControl_Patches, MoreAccessories"); //GetCmpAccessory(ChaControl self, int slotNo) var mGca = patchesTraverse.Method("GetCmpAccessory", new Type[] { typeof(ChaControl), typeof(int) }); if (!mGca.MethodExists()) { throw new InvalidOperationException("Failed to find MoreAccessoriesAI.Patches.ChaControl_Patches.GetCmpAccessory"); } _getChaAccessoryCmp = (control, componentIndex) => mGca.GetValue <CmpAccessory>(control, componentIndex); _getChaAccessoryCmpIndex = (control, component) => { var idx = Array.IndexOf(control.cmpAccessory, component); if (idx >= 0) { return(idx); } // No better way than to iterate the entries until we get an out of range exception idx = 20; try { while (true) { if (_getChaAccessoryCmp(control, idx) == component) { return(idx); } idx++; } } catch (ArgumentOutOfRangeException) { return(-1); } }; //ChaFileAccessory.PartsInfo GetPartsInfo(ChaControl self, int slotNo) var mGpi = patchesTraverse.Method("GetPartsInfo", new Type[] { typeof(ChaControl), typeof(int) }); if (!mGpi.MethodExists()) { throw new InvalidOperationException("Failed to find MoreAccessoriesAI.Patches.ChaControl_Patches.GetPartsInfo"); } _getPartsInfo = i => mGpi.GetValue <ChaFileAccessory.PartsInfo>(MakerAPI.GetCharacterControl(), i); } catch (Exception e) { _moreAccessoriesType = null; KoikatuAPI.Logger.LogWarning("Failed to set up MoreAccessories integration!"); KoikatuAPI.Logger.LogDebug(e); goto NoMoreaccsFallback; } } else { _getChaAccessoryCmp = (control, i) => control.cmpAccessory[i]; _getChaAccessoryCmpIndex = (control, component) => Array.IndexOf(control.cmpAccessory, component); _getPartsInfo = i => MakerAPI.GetCharacterControl().nowCoordinate.accessory.parts[i]; } if (KoikatuAPI.EnableDebugLogging) { SelectedMakerAccSlotChanged += (sender, args) => KoikatuAPI.Logger.LogMessage( $"SelectedMakerAccSlotChanged - id: {args.SlotIndex}, cvs: {args.CvsAccessory?.transform.name}, component: {args.AccessoryComponent?.name ?? "null"}"); /* todo#if KK AccessoriesCopied += (sender, args) => KoikatuAPI.Logger.LogMessage( * $"AccessoriesCopied - ids: {string.Join(", ", args.CopiedSlotIndexes.Select(x => x.ToString()).ToArray())}, src:{args.CopySource}, dst:{args.CopyDestination}"); #endif*/ AccessoryTransferred += (sender, args) => KoikatuAPI.Logger.LogMessage( $"AccessoryTransferred - srcId:{args.SourceSlotIndex}, dstId:{args.DestinationSlotIndex}"); } }