From bf5a8801bc9c56782d4b0177946472e109356fb7 Mon Sep 17 00:00:00 2001 From: Jaxe Date: Wed, 5 Sep 2018 23:57:41 +0800 Subject: [PATCH] v1.0.8 - Updated to handle 0.19.2017 changes in translator method. Backwards compatible, should be no difference for older versions. --- About/ModSync.xml | 2 +- README.md | 2 +- Source/Data/Lang.cs | 2 +- Source/Mod.cs | 2 +- Source/Patch/Extensions.cs | 36 ------------------- ...RelationsUtility_TryDevelopBondRelation.cs | 10 +++--- 6 files changed, 10 insertions(+), 44 deletions(-) diff --git a/About/ModSync.xml b/About/ModSync.xml index dd96272..f4c3afa 100644 --- a/About/ModSync.xml +++ b/About/ModSync.xml @@ -3,7 +3,7 @@ 59f538ed-f86d-4506-a4a5-7e9faaa37508 Pawn Rules - v1.0.7 + v1.0.8 False Jaxe-Dev diff --git a/README.md b/README.md index caf347f..49f4bd3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Pawn Rules -![](https://img.shields.io/badge/Version-1.0.7-brightgreen.svg) +![](https://img.shields.io/badge/Version-1.0.8-brightgreen.svg) Built for **RimWorld B19**\ Powered by **Harmony**\ diff --git a/Source/Data/Lang.cs b/Source/Data/Lang.cs index 3b8c25f..16d963f 100644 --- a/Source/Data/Lang.cs +++ b/Source/Data/Lang.cs @@ -4,6 +4,6 @@ namespace PawnRules.Data { internal static class Lang { - public static string Get(string key, params object[] args) => (Mod.Id + "." + key).Translate(args); + public static string Get(string key, params object[] args) => string.Format((Mod.Id + "." + key).Translate(), args); } } diff --git a/Source/Mod.cs b/Source/Mod.cs index 9630263..77fd13e 100644 --- a/Source/Mod.cs +++ b/Source/Mod.cs @@ -7,7 +7,7 @@ internal class Mod : Verse.Mod public const string Id = "PawnRules"; public const string Name = "Pawn Rules"; public const string Author = "Jaxe"; - public const string Version = "1.0.7"; + public const string Version = "1.0.8"; public static ModContentPack ContentPack { get; private set; } diff --git a/Source/Patch/Extensions.cs b/Source/Patch/Extensions.cs index 64d10c5..0037ee1 100644 --- a/Source/Patch/Extensions.cs +++ b/Source/Patch/Extensions.cs @@ -105,41 +105,5 @@ public static Rect[] GetVGrid(this Rect self, float spacing, params float[] heig return rects; } - /* - public static Rect[] GetVGrid(this Rect self, float spacing, params float[] heights) - { - var unfixedCount = 0; - var currentY = self.y; - var fixedHeights = 0f; - var rects = new Rect[heights.Length]; - - foreach (var height in heights) - { - if (height > 0) { fixedHeights += height - (spacing * 2); } - else { unfixedCount++; } - } - - var unfixedHeight = unfixedCount > 0 ? (self.height - fixedHeights) / unfixedCount : 0; - - for (var index = 0; index < heights.Length; index++) - { - var height = heights[index]; - float newHeight; - if (height > 0) - { - newHeight = height; - rects[index] = new Rect(self.x, currentY, self.width, newHeight); - } - else - { - newHeight = unfixedHeight; - rects[index] = new Rect(self.x, currentY, self.width, newHeight); - } - currentY += newHeight + spacing; - } - - return rects; - } - */ } } diff --git a/Source/Patch/RimWorld_RelationsUtility_TryDevelopBondRelation.cs b/Source/Patch/RimWorld_RelationsUtility_TryDevelopBondRelation.cs index bc8f236..62bdc05 100644 --- a/Source/Patch/RimWorld_RelationsUtility_TryDevelopBondRelation.cs +++ b/Source/Patch/RimWorld_RelationsUtility_TryDevelopBondRelation.cs @@ -8,14 +8,16 @@ namespace PawnRules.Patch [HarmonyPatch(typeof(RelationsUtility), nameof(RelationsUtility.TryDevelopBondRelation))] internal static class RimWorld_RelationsUtility_TryDevelopBondRelation { - private static bool Prefix(Pawn humanlike, Pawn animal) + private static bool Prefix(ref bool __result, Pawn humanlike, Pawn animal) { if (!Registry.IsActive || (humanlike == null) || (animal == null) || !humanlike.CanHaveRules()) { return true; } var rules = Registry.GetRules(humanlike); - if (rules == null) { return true; } - var restrictions = rules.GetRestriction(RestrictionType.Bonding); - return (restrictions == null) || restrictions.IsVoid || restrictions.Allows(animal.def); + var restriction = rules?.GetRestriction(RestrictionType.Bonding); + if ((restriction == null) || restriction.IsVoid || restriction.Allows(animal.def)) { return true; } + + __result = false; + return false; } } }