diff --git a/About/About.xml b/About/About.xml index 87afbd9b..d1c26552 100644 --- a/About/About.xml +++ b/About/About.xml @@ -4,7 +4,7 @@ jecrell https://discord.gg/AaVFA7V 0.19.0 - 1.1.0.5 + 1.1.0.6 (09-30-2018) Adds modding components to RimWorld: vehicles, spell casting, weapon slots, oversized weapons, and more! @@ -53,5 +53,13 @@ Additions by Swenzi Additions and transpilers by Erdelf Extensive hours of testing, debugging, and fixes by Xen. "Hey, should we make this into a public toolset for people to take advantage of all this cool stuff?" - Jecrell -"Hell yes - this is awesome stuff - people will love it!" - Xen +"Hell yes - this is awesome stuff - people will love it!" - Xen +=================== +Changelog +=================== +1.1.0.6 (09-30-2018) +=================== +Adds new BuildingExtension class to allow for bypasses to SpawningWipes. Perfect for adding furniture on top of existing tables. + + \ No newline at end of file diff --git a/About/Changelog.txt b/About/Changelog.txt new file mode 100644 index 00000000..1f82a32c --- /dev/null +++ b/About/Changelog.txt @@ -0,0 +1,4 @@ +1.1.0.6 (09-30-2018) +=================== +Adds new BuildingExtension class to allow for bypasses to SpawningWipes. Perfect for adding furniture on top of existing tables. + diff --git a/About/Version.txt b/About/Version.txt index a7c54abf..6d756186 100644 --- a/About/Version.txt +++ b/About/Version.txt @@ -1 +1 @@ -1.1.0.5 +1.1.0.6 diff --git a/Assemblies/0JecsTools.dll b/Assemblies/0JecsTools.dll index 1399ca04..043fb325 100644 Binary files a/Assemblies/0JecsTools.dll and b/Assemblies/0JecsTools.dll differ diff --git a/Assemblies/AbilityUserAI.dll b/Assemblies/AbilityUserAI.dll index b0957d8a..79adab65 100644 Binary files a/Assemblies/AbilityUserAI.dll and b/Assemblies/AbilityUserAI.dll differ diff --git a/Assemblies/CompInstalledPart.dll b/Assemblies/CompInstalledPart.dll index 82391db1..635b098d 100644 Binary files a/Assemblies/CompInstalledPart.dll and b/Assemblies/CompInstalledPart.dll differ diff --git a/Assemblies/CompSlotLoadable.dll b/Assemblies/CompSlotLoadable.dll index 8451c3a3..159c7fa2 100644 Binary files a/Assemblies/CompSlotLoadable.dll and b/Assemblies/CompSlotLoadable.dll differ diff --git a/Source/.idea/.idea.JecsTools/.idea/contentModel.xml b/Source/.idea/.idea.JecsTools/.idea/contentModel.xml index 09ebf7c5..d890a795 100644 --- a/Source/.idea/.idea.JecsTools/.idea/contentModel.xml +++ b/Source/.idea/.idea.JecsTools/.idea/contentModel.xml @@ -259,6 +259,7 @@ + diff --git a/Source/AllModdingComponents/JecsTools/BuildingExtension.cs b/Source/AllModdingComponents/JecsTools/BuildingExtension.cs new file mode 100644 index 00000000..d2120dcf --- /dev/null +++ b/Source/AllModdingComponents/JecsTools/BuildingExtension.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using Verse; +using Verse.AI; + +namespace JecsTools +{ + + public class BuildingExtension : DefModExtension + { + public List wipeCategories = new List(); + } +} \ No newline at end of file diff --git a/Source/AllModdingComponents/JecsTools/HarmonyPatches.cs b/Source/AllModdingComponents/JecsTools/HarmonyPatches.cs index b42b318b..c303c557 100644 --- a/Source/AllModdingComponents/JecsTools/HarmonyPatches.cs +++ b/Source/AllModdingComponents/JecsTools/HarmonyPatches.cs @@ -7,6 +7,7 @@ using RimWorld; using UnityEngine; using Verse; +using Verse.AI; using Verse.Sound; namespace JecsTools @@ -36,30 +37,141 @@ static HarmonyPatches() // nameof(PawnGroupKindWorker_Normal.MinPointsToGenerateAnything)), // new HarmonyMethod(type, nameof(MinPointsTest)), null); //------------ + + //Adds HediffCompProperties_DamageSoak checks to damage harmony.Patch(AccessTools.Method(typeof(Pawn_HealthTracker), nameof(Pawn_HealthTracker.PreApplyDamage)), new HarmonyMethod(type, nameof(PreApplyDamage_PrePatch)), null); + + //Applies cached armor damage and absorption harmony.Patch(AccessTools.Method(typeof(ArmorUtility), "ApplyArmor"), new HarmonyMethod(type, nameof(ApplyProperDamage)), null); + + //Applies damage soak motes harmony.Patch(AccessTools.Method(typeof(ArmorUtility), nameof(ArmorUtility.GetPostArmorDamage)), null, new HarmonyMethod(type, nameof(Post_GetPostArmorDamage))); + + //Allows for adding additional HediffSets when characters spawn using the StartWithHediff class. harmony.Patch( AccessTools.Method(typeof(PawnGenerator), "GeneratePawn", new[] {typeof(PawnGenerationRequest)}), null, new HarmonyMethod(type, nameof(Post_GeneratePawn))); + + //Checks apparel that uses the ApparelExtension harmony.Patch(AccessTools.Method(typeof(ApparelUtility), nameof(ApparelUtility.CanWearTogether)), null, new HarmonyMethod(type, nameof(Post_CanWearTogether))); + + //Handles special cases of faction disturbances harmony.Patch(AccessTools.Method(typeof(Faction), nameof(Faction.Notify_MemberDied)), new HarmonyMethod(type, nameof(Notify_MemberDied)), null); + + //Handles FactionSettings extension to allow for fun effects when factions arrive. harmony.Patch( AccessTools.Method(typeof(PawnGroupMakerUtility), nameof(PawnGroupMakerUtility.GeneratePawns)), null, new HarmonyMethod(type, nameof(GeneratePawns)), null); - //harmony.Patch(AccessTools.Method(AccessTools.TypeByName("PossibleApparelSet"), "IsNaked"), null, - // new HarmonyMethod(type, nameof(IsNaked)), null); + + //Handles cases where gendered apparel swaps out for individual genders. harmony.Patch( AccessTools.Method(typeof(PawnApparelGenerator), nameof(PawnApparelGenerator.GenerateStartingApparelFor)), null, new HarmonyMethod(type, nameof(GenerateStartingApparelFor_PostFix)), null); - //GUIPatches(harmony); + //BuildingExtension prevents some things from wiping other things when spawned. + harmony.Patch( + AccessTools.Method(typeof(GenSpawn), + nameof(GenSpawn.SpawningWipes)), null, + new HarmonyMethod(type, nameof(SpawningWipes_PostFix)), null); +// harmony.Patch( +// AccessTools.Method(typeof(GenConstruct), +// nameof(GenConstruct.HandleBlockingThingJob)), null, +// new HarmonyMethod(type, nameof(HandleBlockingThingJob_PostFix)), null); + harmony.Patch( + AccessTools.Method(typeof(GenConstruct), + nameof(GenConstruct.BlocksConstruction)), null, + new HarmonyMethod(type, nameof(BlocksConstruction_PostFix)), null); + } + + public static void BlocksConstruction_PostFix(Thing constructible, Thing t, ref bool __result) + { + ThingDef thingDef = constructible.def; + ThingDef thingDef2 = t.def; + if (thingDef == null || thingDef2 == null) + return; + if (thingDef.HasModExtension() || thingDef2.HasModExtension()) + { + BuildableDef buildableDef = GenConstruct.BuiltDefOf(thingDef); + BuildableDef buildableDef2 = GenConstruct.BuiltDefOf(thingDef2); + __result = ShouldWipe(buildableDef, buildableDef2, t.PositionHeld, t.MapHeld); + } + } + + public static void SpawningWipes_PostFix(BuildableDef newEntDef, BuildableDef oldEntDef, ref bool __result) + { + ThingDef thingDef = newEntDef as ThingDef; + ThingDef thingDef2 = oldEntDef as ThingDef; + if (thingDef == null || thingDef2 == null) + return; + if (thingDef.HasModExtension() || thingDef2.HasModExtension()) + { + BuildableDef buildableDef = GenConstruct.BuiltDefOf(thingDef); + BuildableDef buildableDef2 = GenConstruct.BuiltDefOf(thingDef2); + __result = ShouldWipe(buildableDef, buildableDef2, IntVec3.Invalid, null); + } + } + + private static bool ShouldWipe(BuildableDef newEntDef, BuildableDef oldEntDef, IntVec3 loc, Map map) + { + if (map == null || loc == null || !loc.IsValid) + { + var buildingExtensionA = newEntDef?.GetModExtension(); + var buildingExtensionB = oldEntDef?.GetModExtension(); + if (buildingExtensionB == null && buildingExtensionA == null) + { + //Log.Message("Both null"); + return true; + } + + //Log.Message("A: " + newEntDef.label); + //Log.Message("B: " + oldEntDef.label); + if (buildingExtensionA != null && buildingExtensionB == null && + buildingExtensionA.wipeCategories?.Count > 0) + { + //Log.Message("B null"); + + return false; + } + + if (buildingExtensionB != null && buildingExtensionA == null && + buildingExtensionB.wipeCategories?.Count > 0) + { + //Log.Message("A null"); + + return false; + } + + if (buildingExtensionA != null && buildingExtensionB != null && + buildingExtensionA.wipeCategories?.Count > 0 && + buildingExtensionB.wipeCategories?.Count > 0) + { + var hashes = new HashSet(); + foreach (var str in buildingExtensionA.wipeCategories) + hashes.Add(str); + foreach (var strB in buildingExtensionB.wipeCategories) + { + if (!hashes.Contains(strB)) continue; + //Log.Message("ShouldWipe"); + return true; + } + } + return true; + } + var locThings = loc.GetThingList(map); + for (var index = 0; index < locThings.Count; index++) + { + var thing = locThings[index]; + if (thing.def is ThingDef thingDef && ShouldWipe(newEntDef, GenConstruct.BuiltDefOf(thingDef), IntVec3.Invalid, null)) + return true; + } + + return true; } public static void MinPointsTest(PawnGroupKindWorker_Normal __instance, PawnGroupMaker groupMaker) diff --git a/Source/AllModdingComponents/JecsTools/JecsTools.csproj b/Source/AllModdingComponents/JecsTools/JecsTools.csproj index eca27304..e080af79 100644 --- a/Source/AllModdingComponents/JecsTools/JecsTools.csproj +++ b/Source/AllModdingComponents/JecsTools/JecsTools.csproj @@ -57,6 +57,7 @@ + diff --git a/updateinfo b/updateinfo index b370df86..b3c17550 100644 --- a/updateinfo +++ b/updateinfo @@ -4,9 +4,9 @@ JecsTools Update ==================== -Version: 1.1.0.3 -Updated: 09-17-2018 -Description: Neglected to include latest compiled fix. +Version: 1.1.0.5 +Updated: 09-22-2018 +Description: Added a max range check to make GetInRangeToil fire for pawns who target enemies outside of max range. ==================== Download now on... @@ -25,9 +25,9 @@ Discuss the mod on... [img width=260]https://raw.githubusercontent.com/jecrell/JecsTools/master/About/Preview.png[/img] [hr] [b]JecsTools -Version: 1.1.0.3 -Updated: 09-17-2018 -Description: [color=orange]Neglected to include latest compiled fix. [/color] +Version: 1.1.0.5 +Updated: 09-22-2018 +Description: [color=orange]Added a max range check to make GetInRangeToil fire for pawns who target enemies outside of max range.[/color] [hr] [b]Download now on...[/b] [url=https://www.patreon.com/posts/jecstools-for-0-21059900]Patreon[/url]