diff --git a/1.3/Assemblies/0MultiplayerAPI.dll b/1.3/Assemblies/0MultiplayerAPI.dll new file mode 100644 index 0000000..38b8a0e Binary files /dev/null and b/1.3/Assemblies/0MultiplayerAPI.dll differ diff --git a/1.3/Assemblies/AchtungMod.dll b/1.3/Assemblies/AchtungMod.dll new file mode 100644 index 0000000..98d0fae Binary files /dev/null and b/1.3/Assemblies/AchtungMod.dll differ diff --git a/About/About.xml b/About/About.xml index 518ec8a..221e414 100644 --- a/About/About.xml +++ b/About/About.xml @@ -6,6 +6,7 @@
  • 1.0
  • 1.1
  • 1.2
  • +
  • 1.3
  • diff --git a/About/Manifest.xml b/About/Manifest.xml index ea5fc0c..9e237cf 100644 --- a/About/Manifest.xml +++ b/About/Manifest.xml @@ -1,11 +1,12 @@  net.pardeike.rimworld.mod.achtung - 3.1.7.0 + 3.2.0.0
  • 1.0.0
  • 1.1.0
  • 1.2.0
  • +
  • 1.3.0
  • diff --git a/LoadFolders.xml b/LoadFolders.xml index b3acbd9..003cb97 100644 --- a/LoadFolders.xml +++ b/LoadFolders.xml @@ -7,4 +7,8 @@
  • /
  • 1.2
  • + +
  • /
  • +
  • 1.3
  • +
    \ No newline at end of file diff --git a/Source/Achtung.csproj b/Source/Achtung.csproj index 70c4a03..b946023 100644 --- a/Source/Achtung.csproj +++ b/Source/Achtung.csproj @@ -7,10 +7,10 @@ net472 8.0 x64 - ..\1.2\Assemblies\ + ..\1.3\Assemblies\ true false - 3.1.7.0 + 3.2.0.0 © July, 2016 @@ -23,15 +23,15 @@ true - RW12;TRACE;DEBUG + RW12;RW13;TRACE;DEBUG false portable true - - + + all @@ -75,7 +75,7 @@ if not errorlevel 1 ( ModBuilder XMLPut -file "$(SolutionDir)About\Manifest.xml" -xpath /Manifest/version -value "{{$(MSBuildProjectName)-version}}" ) if defined INSTALL_MOD ( - "%INSTALL_MOD%" "$(Configuration)" "$(SolutionDir)" "$(MSBuildProjectName)" "1.1 1.2 About Assemblies Languages Textures" "LoadFolders.xml" + "%INSTALL_MOD%" "$(Configuration)" "$(SolutionDir)" "$(MSBuildProjectName)" "1.1 1.2 1.3 About Assemblies Languages Textures" "LoadFolders.xml" ) Brrainz diff --git a/Source/Colonist.cs b/Source/Colonist.cs index 74b9f31..7aec1d8 100644 --- a/Source/Colonist.cs +++ b/Source/Colonist.cs @@ -30,7 +30,7 @@ public IntVec3 UpdateOrderPos(Vector3 pos) if (AchtungLoader.IsSameSpotInstalled) { - if (cell.Standable(pawn.Map) && pawn.CanReach(cell, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) + if (cell.Standable(pawn.Map) && ReachabilityUtility.CanReach(pawn, cell, PathEndMode.OnCell, Danger.Deadly)) { designation = cell.ToVector3Shifted(); designation.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn); @@ -58,4 +58,4 @@ public void OrderTo(Vector3 pos) } } } -} \ No newline at end of file +} diff --git a/Source/CrossPromotion.cs b/Source/CrossPromotion.cs index 8589d30..e7a3e1a 100644 --- a/Source/CrossPromotion.cs +++ b/Source/CrossPromotion.cs @@ -68,6 +68,7 @@ static void Page_ModsConfig_PostClose_Postfix() static void WorkshopItems_Notify_Subscribed_Postfix(PublishedFileId_t pfid) { var longID = pfid.m_PublishedFileId; + if (subscribingMods.Contains(longID) == false) return; _ = subscribingMods.Remove(longID); @@ -80,6 +81,7 @@ static void WorkshopItems_Notify_Subscribed_Postfix(PublishedFileId_t pfid) ModsConfig.SetActive(mod, true); ModsConfig.Save(); + Find.WindowStack.Add(new MiniDialog(mod.Name + " added")); }); } @@ -91,16 +93,20 @@ static void WorkshopItems_Notify_Subscribed_Postfix(PublishedFileId_t pfid) static IEnumerable Page_ModsConfig_DoWindowContents_Transpiler(IEnumerable instructions, ILGenerator generator) { var list = instructions.ToList(); + var beginGroupIndicies = list .Select((instr, idx) => new Pair(idx, instr)) .Where(pair => pair.Second.operand is MethodInfo mi && mi == m_BeginGroup) .Select(pair => pair.First).ToArray(); + var endGroupIndicies = list .Select((instr, idx) => new Pair(idx, instr)) .Where(pair => pair.Second.operand is MethodInfo mi && mi == m_EndGroup) .Select(pair => pair.First).ToArray(); + if (beginGroupIndicies.Length != 2 || endGroupIndicies.Length != 2) return instructions; + var iBegin = beginGroupIndicies[1] - 1; var iEnd = endGroupIndicies[0]; @@ -121,8 +127,7 @@ static IEnumerable Page_ModsConfig_DoWindowContents_Transpiler( internal static string ModPreviewPath(ulong modID) { var dir = Path.GetTempPath() + "BrrainzMods" + Path.DirectorySeparatorChar; - if (Directory.Exists(dir) == false) - _ = Directory.CreateDirectory(dir); + if (Directory.Exists(dir) == false) _ = Directory.CreateDirectory(dir); return dir + modID + "-preview.jpg"; } @@ -146,12 +151,15 @@ internal static Texture2D PreviewForMod(ulong modID) { if (previewTextures.TryGetValue(modID, out var texture)) return texture; + var path = ModPreviewPath(modID); if (File.Exists(path) == false) return null; + texture = new Texture2D(1, 1, TextureFormat.ARGB32, false); if (texture.LoadImage(SafeRead(path))) previewTextures[modID] = texture; + return texture; } @@ -189,51 +197,49 @@ public static void FetchPromotionMods() return; var rimworldID = SteamUtils.GetAppID(); - unchecked - { - var aID = new AccountID_t((uint)userID); - var itemQuery = SteamUGC.CreateQueryUserUGCRequest(aID, + var aID = new AccountID_t(unchecked((uint)userID)); + + var itemQuery = SteamUGC.CreateQueryUserUGCRequest(aID, EUserUGCList.k_EUserUGCList_Published, EUGCMatchingUGCType.k_EUGCMatchingUGCType_UsableInGame, - EUserUGCListSortOrder.k_EUserUGCListSortOrder_VoteScoreDesc, rimworldID, rimworldID, - 1); - _ = SteamUGC.SetReturnLongDescription(itemQuery, true); - _ = SteamUGC.SetRankedByTrendDays(itemQuery, 7); - AsyncUserModsQuery(itemQuery, (result, failure) => - { - for (uint i = 0; i < result.m_unNumResultsReturned; i++) - if (SteamUGC.GetQueryUGCResult(result.m_handle, i, out var mod)) - if (promotionMods.Any(m => m.m_nPublishedFileId.m_PublishedFileId == mod.m_nPublishedFileId.m_PublishedFileId) == false) - { - promotionMods.Add(mod); - var modID = mod.m_nPublishedFileId.m_PublishedFileId; + EUserUGCListSortOrder.k_EUserUGCListSortOrder_VoteScoreDesc, rimworldID, rimworldID, 1); - var path = ModPreviewPath(modID); - if (File.Exists(path) == false || new FileInfo(path).Length != mod.m_nPreviewFileSize) - { - AsyncDownloadQuery(mod.m_hPreviewFile, path, (result2, failure2) => - { - if (File.Exists(path)) - { - if (previewTextures.ContainsKey(modID)) - _ = previewTextures.Remove(modID); - } - }); - } + _ = SteamUGC.SetReturnLongDescription(itemQuery, true); + _ = SteamUGC.SetRankedByTrendDays(itemQuery, 7); - UpdateVotingStatus(modID, (result2, failure2) => + AsyncUserModsQuery(itemQuery, (result, failure) => + { + for (var i = (uint)0; i < result.m_unNumResultsReturned; i++) + if (SteamUGC.GetQueryUGCResult(result.m_handle, i, out var mod)) + if (promotionMods.Any(m => m.m_nPublishedFileId.m_PublishedFileId == mod.m_nPublishedFileId.m_PublishedFileId) == false) + { + promotionMods.Add(mod); + var modID = mod.m_nPublishedFileId.m_PublishedFileId; + + var path = ModPreviewPath(modID); + if (File.Exists(path) == false || new FileInfo(path).Length != mod.m_nPreviewFileSize) + { + AsyncDownloadQuery(mod.m_hPreviewFile, path, (result2, failure2) => { - allVoteStati[modID] = (result2.m_eResult == EResult.k_EResultOK) ? result2.m_bVotedUp : (bool?)null; + if (File.Exists(path)) + { + if (previewTextures.ContainsKey(modID)) + _ = previewTextures.Remove(modID); + } }); } - }); - } + + UpdateVotingStatus(modID, (result2, failure2) => + { + allVoteStati[modID] = (result2.m_eResult == EResult.k_EResultOK) ? result2.m_bVotedUp : (bool?)null; + }); + } + }); } } [StaticConstructorOnStartup] internal class PromotionLayout { - static readonly AccessTools.FieldRef ref_steamAuthor = AccessTools.FieldRefAccess("steamAuthor"); internal static bool Promotion(Rect mainRect, Page_ModsConfig page) { if (SteamManager.Initialized == false) @@ -241,7 +247,7 @@ internal static bool Promotion(Rect mainRect, Page_ModsConfig page) var mod = page.selectedMod; if (mod == null - || ref_steamAuthor(mod.GetWorkshopItemHook()).m_SteamID != CrossPromotion.userID + || mod.GetWorkshopItemHook().steamAuthor.m_SteamID != CrossPromotion.userID || CrossPromotion.promotionMods.Count == 0) return false; @@ -249,6 +255,7 @@ internal static bool Promotion(Rect mainRect, Page_ModsConfig page) var rightColumn = mainRect.width - leftColumn - 10f; GUI.BeginGroup(mainRect); + try { ContentPart(mainRect, leftColumn, mod, page); @@ -259,6 +266,7 @@ internal static bool Promotion(Rect mainRect, Page_ModsConfig page) GUI.EndGroup(); return false; } + GUI.EndGroup(); return true; } @@ -289,7 +297,8 @@ static void ContentPart(Rect mainRect, float leftColumn, ModMetaData mod, Page_M { CrossPromotion.allVoteStati[promoMod.m_nPublishedFileId.m_PublishedFileId] = (result2.m_eResult == EResult.k_EResultOK) ? result2.m_bVotedUp : (bool?)null; }); - }).Start(); + }) + .Start(); } var description = thisMod.m_rgchDescription; @@ -301,6 +310,7 @@ static void ContentPart(Rect mainRect, float leftColumn, ModMetaData mod, Page_M var imageRect = new Rect(0f, 0f, width, width * mod.PreviewImage.height / mod.PreviewImage.width); var textRect = new Rect(0f, 24f + 10f + imageRect.height, width, Text.CalcHeight(description, width)); var innerRect = new Rect(0f, 0f, width, imageRect.height + 20f + 8f + 10f + textRect.height); + Widgets.BeginScrollView(outRect, ref leftScroll, innerRect, true); GUI.DrawTexture(imageRect, mod.PreviewImage, ScaleMode.ScaleToFit); var widgetRow = new WidgetRow(imageRect.xMax, imageRect.yMax + 8f, UIDirection.LeftThenDown, width, 8f); @@ -308,14 +318,15 @@ static void ContentPart(Rect mainRect, float leftColumn, ModMetaData mod, Page_M { if (widgetRow.ButtonText("Unsubscribe".Translate(), null, true, true)) { - Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(mod.Name), delegate + Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(mod.Name), () => { mod.enabled = false; new Thread(() => { - _ = AccessTools.Method(typeof(Workshop), "Unsubscribe").Invoke(null, new object[] { mod }); - _ = AccessTools.Method(typeof(Page_ModsConfig), "Notify_SteamItemUnsubscribed").Invoke(page, new object[] { mainModID }); - }).Start(); + Workshop.Unsubscribe(mod); + page.Notify_SteamItemUnsubscribed(new PublishedFileId_t(mainModID)); + }) + .Start(); }, true, null)); } } @@ -328,10 +339,7 @@ static void ContentPart(Rect mainRect, float leftColumn, ModMetaData mod, Page_M { widgetRow = new WidgetRow(imageRect.xMin, imageRect.yMax + 8f, UIDirection.RightThenDown, width, 8f); if (widgetRow.ButtonText("Upload", null, true, true)) - Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmSteamWorkshopUpload".Translate(), delegate - { - _ = AccessTools.Method(typeof(Workshop), "Upload").Invoke(null, new object[] { mod }); - }, true, null)); + Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmSteamWorkshopUpload".Translate(), () => Workshop.Upload(mod), true, null)); } Widgets.Label(textRect, description); @@ -346,7 +354,7 @@ static void PromotionPart(Rect mainRect, float leftColumn, float rightColumn, Mo var headerHeight = 30f; var headerRect = new Rect(leftColumn + 10f, -4f, rightColumn - 20f, headerHeight); Text.Anchor = TextAnchor.UpperCenter; - Widgets.Label(headerRect, "Mods of " + mod.Author.Replace("Andreas Pardeike", "Brrainz") + ":".Truncate(headerRect.width, null)); + Widgets.Label(headerRect, "Mods of " + mod.AuthorsString.Replace("Andreas Pardeike", "Brrainz") + ":".Truncate(headerRect.width, null)); Text.Anchor = TextAnchor.UpperLeft; var outRect = new Rect(leftColumn + 10f, headerHeight - 4f, rightColumn, mainRect.height - (headerHeight - 4f)); @@ -366,6 +374,7 @@ static void PromotionPart(Rect mainRect, float leftColumn, float rightColumn, Mo if (height > 0) height += 10f; + var preview = CrossPromotion.PreviewForMod(promoMod.m_nPublishedFileId.m_PublishedFileId); if (preview != null) { @@ -424,7 +433,7 @@ void actionButtonAction() { if (isSubbed || isLocalFile) { - var orderedMods = (IEnumerable)AccessTools.Method(typeof(Page_ModsConfig), "ModsInListOrder").Invoke(page, Array.Empty()); + var orderedMods = page.ModsInListOrder(); page.selectedMod = orderedMods.FirstOrDefault(meta => meta.GetPublishedFileId().m_PublishedFileId == myModID); var modsBefore = orderedMods.ToList().FindIndex(m => m == page.selectedMod); if (modsBefore >= 0) @@ -435,7 +444,8 @@ void actionButtonAction() { CrossPromotion.subscribingMods.Add(myModID); _ = SteamUGC.SubscribeItem(new PublishedFileId_t(myModID)); - }).Start(); + }) + .Start(); } var infoWindow = new Dialog_MessageBox(description, "Close".Translate(), null, actionButton, actionButtonAction, null, false, null, null); Find.WindowStack.Add(infoWindow); @@ -507,4 +517,4 @@ internal MiniDialog(string text, string buttonAText = null, Action buttonAAction public override Vector2 InitialSize => new Vector2(320, 240); } -} \ No newline at end of file +} diff --git a/Source/ForcedFloatMenuOption.cs b/Source/ForcedFloatMenuOption.cs index 915d549..f60e4ea 100644 --- a/Source/ForcedFloatMenuOption.cs +++ b/Source/ForcedFloatMenuOption.cs @@ -13,7 +13,7 @@ public class ForcedMultiFloatMenuOption : ForcedFloatMenuOption { public List options; - public ForcedMultiFloatMenuOption(string label) : base(label, null, MenuOptionPriority.Default, null, null, 0f, null, null) { } + public ForcedMultiFloatMenuOption(string label) : base(label, null, MenuOptionPriority.Default, null, null, 0f, null, null, false, 0) { } public override bool ForceAction() { @@ -81,28 +81,22 @@ public static float ButtonWidth } } - public static FloatMenuOption CreateForcedMenuItem(string label, Action action, MenuOptionPriority priority, Action mouseoverGuiAction, Thing revalidateClickTarget, float extraPartWidth, Func extraPartOnGUI, WorldObject revalidateWorldClickTarget, Pawn pawn, IntVec3 clickCell, WorkGiver_Scanner workgiver) + public static FloatMenuOption CreateForcedMenuItem(string label, Action action, MenuOptionPriority priority, Action mouseoverGuiAction, Thing revalidateClickTarget, float extraPartWidth, Func extraPartOnGUI, WorldObject revalidateWorldClickTarget, bool playSelectionSound, int orderInPriority, Pawn pawn, Vector3 clickPos, WorkGiver_Scanner workgiver) { if (action == null) - return new FloatMenuOption(label, action, priority, mouseoverGuiAction, revalidateClickTarget, extraPartWidth, extraPartOnGUI, revalidateWorldClickTarget); + return new FloatMenuOption(label, action, priority, mouseoverGuiAction, revalidateClickTarget, extraPartWidth, extraPartOnGUI, revalidateWorldClickTarget, playSelectionSound, orderInPriority); - var option = new ForcedFloatMenuOption(label, action, priority, mouseoverGuiAction, revalidateClickTarget, extraPartWidth, extraPartOnGUI, revalidateWorldClickTarget) { }; + var option = new ForcedFloatMenuOption(label, action, priority, mouseoverGuiAction, revalidateClickTarget, extraPartWidth, extraPartOnGUI, revalidateWorldClickTarget, playSelectionSound, orderInPriority) { }; option.forcePawn = pawn; - option.forceCell = clickCell; + option.forceCell = IntVec3.FromVector3(clickPos); option.forceWorkgiver = workgiver; option.extraPartOnGUI = extraPartRect => option.RenderExtraPartOnGui(extraPartRect); return option; } - public static FloatMenuOption CreateForcedMenuItemNew(string label, Action action, MenuOptionPriority priority, Action mouseoverGuiAction, Thing revalidateClickTarget, float extraPartWidth, Func extraPartOnGUI, WorldObject revalidateWorldClickTarget, Pawn pawn, Vector3 clickPos, WorkGiver_Scanner workgiver) - { - var clickCell = IntVec3.FromVector3(clickPos); - return CreateForcedMenuItem(label, action, priority, mouseoverGuiAction, revalidateClickTarget, extraPartWidth, extraPartOnGUI, revalidateWorldClickTarget, pawn, clickCell, workgiver); - } - - public ForcedFloatMenuOption(string label, Action action, MenuOptionPriority priority, Action mouseoverGuiAction, Thing revalidateClickTarget, float extraPartWidth, Func extraPartOnGUI, WorldObject revalidateWorldClickTarget) - : base(label, action, priority, mouseoverGuiAction, revalidateClickTarget, extraPartWidth, extraPartOnGUI, revalidateWorldClickTarget) + public ForcedFloatMenuOption(string label, Action action, MenuOptionPriority priority, Action mouseoverGuiAction, Thing revalidateClickTarget, float extraPartWidth, Func extraPartOnGUI, WorldObject revalidateWorldClickTarget, bool playSelectionSound, int orderInPriority) + : base(label, action, priority, mouseoverGuiAction, revalidateClickTarget, extraPartWidth, extraPartOnGUI, revalidateWorldClickTarget, playSelectionSound, orderInPriority) { // somehow necessary or else 'extraPartWidth' will be 0 base.extraPartWidth = buttonSpace + ButtonWidth; diff --git a/Source/ForcedJob.cs b/Source/ForcedJob.cs index d5b24b1..9550276 100644 --- a/Source/ForcedJob.cs +++ b/Source/ForcedJob.cs @@ -144,7 +144,7 @@ public IEnumerable GetSortedTargets(HashSet planned) const int maxSquaredDistance = 200 * 200; var map = pawn.Map; - var pathGrid = map.pathGrid; + var pathGrid = map.pathing.For(pawn).pathGrid; var mapWidth = map.Size.x; return targets .Where(target => diff --git a/Source/JobDriver_CleanRoom.cs b/Source/JobDriver_CleanRoom.cs index b84e953..3c91e3d 100644 --- a/Source/JobDriver_CleanRoom.cs +++ b/Source/JobDriver_CleanRoom.cs @@ -74,10 +74,10 @@ public override bool TryMakePreToilReservations(bool errorOnFailed) private IEnumerable AllFilth(IntVec3? useCell = null) { room = ValidateRoom(room ?? RoomAt(useCell ?? TargetLocA)); - room = room ?? ValidateRoom(RoomAt(useCell ?? TargetLocA)); + room ??= ValidateRoom(RoomAt(useCell ?? TargetLocA)); if (room == null) return new List(); - var pathGrid = pawn.Map.pathGrid; + var pathGrid = pawn.Map.pathing.For(pawn).pathGrid; if (pathGrid == null) return new List(); @@ -102,7 +102,7 @@ private Room ValidateRoom(Room room) if (room.Dereferenced) return null; if (room.IsHuge) return null; if (room.RegionCount == 0) return null; - if (room.Group.AnyRoomTouchesMapEdge) return null; + if (room.TouchesMapEdge) return null; return room; } diff --git a/Source/Main.cs b/Source/Main.cs index 57c08cc..ea22b4e 100644 --- a/Source/Main.cs +++ b/Source/Main.cs @@ -77,7 +77,7 @@ public static void Postfix() }*/ [HarmonyPatch(typeof(World))] - [HarmonyPatch("FinalizeInit")] + [HarmonyPatch(nameof(World.FinalizeInit))] static class World_FinalizeInit_Patch { public static void Prefix() @@ -87,7 +87,7 @@ public static void Prefix() } [HarmonyPatch(typeof(Game))] - [HarmonyPatch("FinalizeInit")] + [HarmonyPatch(nameof(Game.FinalizeInit))] static class Game_FinalizeInit_Patch { public static void Postfix() @@ -177,7 +177,7 @@ public static IEnumerable Transpiler(IEnumerable inst.LoadsField(f_NotInHomeAreaTrans)); if (i > 0) @@ -195,7 +195,7 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable RadialDistinctThingsAround_Patch(IntVec3 center, Map map, float radius, bool useCenter, Pawn pawn) @@ -413,18 +413,10 @@ public static IEnumerable Transpiler(IEnumerable TargetMethods() - { - return Tools.GetLatestMethod( - typeof(FloatMenuMakerMap), - "AddJobGiverWorkOrders_NewTmp", - "AddJobGiverWorkOrders" - ); - } - public static void Prefix(Pawn pawn, out ForcedWork __state) { __state = ForcedWork.Instance; @@ -454,15 +446,14 @@ static bool IgnoreForbiddenHauling(WorkGiver_Scanner workgiver, Thing thing) public static IEnumerable Transpiler(IEnumerable instructions, MethodBase original) { - var createForcedMenuItemName = original.GetParameters().Types()[0] == typeof(Vector3) ? - nameof(ForcedFloatMenuOption.CreateForcedMenuItemNew) : - nameof(ForcedFloatMenuOption.CreateForcedMenuItem); - var m_GetPriority = AccessTools.Method(typeof(Pawn_WorkSettings), nameof(Pawn_WorkSettings.GetPriority)); - var c_FloatMenuOption = AccessTools.FirstConstructor(typeof(FloatMenuOption), c => c.GetParameters().Count() > 1); - var m_ForcedFloatMenuOption = AccessTools.Method(typeof(ForcedFloatMenuOption), createForcedMenuItemName); + var floatMenuOptionConstructorArgs = new[] { typeof(string), typeof(Action), typeof(MenuOptionPriority), typeof(Action), typeof(Thing), typeof(float), typeof(Func), typeof(WorldObject), typeof(bool), typeof(int) }; + var c_FloatMenuOption = AccessTools.Constructor(typeof(FloatMenuOption), floatMenuOptionConstructorArgs); + var m_CreateForcedMenuItem = SymbolExtensions.GetMethodInfo(() => ForcedFloatMenuOption.CreateForcedMenuItem(default, default, default, default, default, default, default, default, default, default, default, default, default)); var m_Accepts = SymbolExtensions.GetMethodInfo(() => new ThingRequest().Accepts(default)); var m_IgnoreForbiddenHauling = SymbolExtensions.GetMethodInfo(() => IgnoreForbiddenHauling(default, default)); + if (c_FloatMenuOption == null) + Log.Error($"Cannot find constructor for FloatMenuOption() with argument types {floatMenuOptionConstructorArgs.Join(t => t.Name)}"); var list = instructions.ToList(); @@ -514,7 +505,7 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instructions) { - var m_CleanupCurrentJob = AccessTools.Method(typeof(Pawn_JobTracker), "CleanupCurrentJob"); + var m_CleanupCurrentJob = AccessTools.Method(typeof(Pawn_JobTracker), nameof(Pawn_JobTracker.CleanupCurrentJob)); var m_ContinueJob = AccessTools.Method(typeof(ForcedJob), nameof(ForcedJob.ContinueJob)); - var f_pawn = AccessTools.Field(typeof(Pawn_JobTracker), "pawn"); - var f_curJob = AccessTools.Field(typeof(Pawn_JobTracker), "curJob"); + var f_pawn = AccessTools.Field(typeof(Pawn_JobTracker), nameof(Pawn_JobTracker.pawn)); + var f_curJob = AccessTools.Field(typeof(Pawn_JobTracker), nameof(Pawn_JobTracker.curJob)); if (m_CleanupCurrentJob == null) throw new Exception("Cannot find method Pawn_JobTracker.CleanupCurrentJob"); if (f_pawn == null) throw new Exception("Cannot find field Pawn_JobTracker.pawn"); @@ -557,16 +548,35 @@ public static IEnumerable Transpiler(IEnumerable Postfix(IEnumerable gizmos, Pawn ___pawn // ignore think tree when building uninterrupted // [HarmonyPatch(typeof(Pawn_JobTracker))] - [HarmonyPatch("ShouldStartJobFromThinkTree")] + [HarmonyPatch(nameof(Pawn_JobTracker.ShouldStartJobFromThinkTree))] static class Pawn_JobTracker_ShouldStartJobFromThinkTree_Patch { public static void Postfix(Pawn ___pawn, ref bool __result) @@ -697,7 +707,7 @@ public static void Postfix(Pawn ___pawn, ref bool __result) // handle events early // [HarmonyPatch(typeof(Selector))] - [HarmonyPatch("HandleMapClicks")] + [HarmonyPatch(nameof(Selector.HandleMapClicks))] static class Selector_HandleMapClicks_Patch { public static bool Prefix() @@ -739,14 +749,14 @@ static class Errors_To_Warnings_Patch { public static IEnumerable TargetMethods() { - yield return AccessTools.Method(typeof(ReservationManager), "LogCouldNotReserveError"); - yield return AccessTools.Method(typeof(JobUtility), "TryStartErrorRecoverJob"); + yield return AccessTools.Method(typeof(ReservationManager), nameof(ReservationManager.LogCouldNotReserveError)); + yield return AccessTools.Method(typeof(JobUtility), nameof(JobUtility.TryStartErrorRecoverJob)); } public static IEnumerable Transpiler(IEnumerable instructions) { - var fromMethod = SymbolExtensions.GetMethodInfo(() => Log.Error("", false)); - var toMethod = SymbolExtensions.GetMethodInfo(() => Log.Warning("", false)); + var fromMethod = SymbolExtensions.GetMethodInfo(() => Log.Error("")); + var toMethod = SymbolExtensions.GetMethodInfo(() => Log.Warning("")); return instructions.MethodReplacer(fromMethod, toMethod); } } @@ -769,7 +779,6 @@ public static void Postfix(Pawn __instance, ref string __result) // [HarmonyPatch(typeof(FloatMenuMakerMap))] [HarmonyPatch(nameof(FloatMenuMakerMap.ChoicesAtFor))] - [HarmonyPatch(new[] { typeof(Vector3), typeof(Pawn) })] [StaticConstructorOnStartup] static class FloatMenuMakerMap_ChoicesAtFor_Patch { diff --git a/Source/Tools.cs b/Source/Tools.cs index 2e15358..67e4d08 100644 --- a/Source/Tools.cs +++ b/Source/Tools.cs @@ -351,9 +351,10 @@ public static bool IsGoHereOption(FloatMenuOption option) return option.Label == goHereLabel; } - public static int IsEnclosed(Map map, int maxCount, IntVec3 pos, IntVec3 direction) + public static int IsEnclosed(Pawn pawn, int maxCount, IntVec3 pos, IntVec3 direction) { - var pathGrid = map.pathGrid; + var map = pawn.Map; + var pathGrid = map.pathing.For(pawn).pathGrid; var count = 0; (new FloodFiller(map)).FloodFill(pos + direction, cell => {