From 03b62ed95d79250871e4e37228b43ec8ffd3280c Mon Sep 17 00:00:00 2001 From: Alex Tearse-Doyle Date: Sat, 10 Nov 2018 06:00:12 -0800 Subject: [PATCH] Making temporary tend spots selectable and cancelable, since apparently some people see them not get deleted. --- Defs/TempFieldTendingSpot.xml | 8 +++--- Languages/English/Keyed/AutoEnglish.xml | 1 + .../ThingDef/SampleThingDefInjected.xml | 2 +- Source/FieldTending.cs | 27 ++++++++++++++++++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Defs/TempFieldTendingSpot.xml b/Defs/TempFieldTendingSpot.xml index 81206c8..484334d 100644 --- a/Defs/TempFieldTendingSpot.xml +++ b/Defs/TempFieldTendingSpot.xml @@ -1,18 +1,17 @@  - TempSleepSpot - Automatically created by Smart Medicine to tend in the field (without slow-down effects). - Building_Bed + Automatically created by Smart Medicine to tend in the field. Removes itself when not used. + SmartMedicine.Building_TempTendSpot TempSleepSpot Graphic_Single FloorEmplacement - false + true 0 0.4 @@ -26,6 +25,7 @@ True false false + false diff --git a/Languages/English/Keyed/AutoEnglish.xml b/Languages/English/Keyed/AutoEnglish.xml index 9cc5f01..fc67c0e 100644 --- a/Languages/English/Keyed/AutoEnglish.xml +++ b/Languages/English/Keyed/AutoEnglish.xml @@ -40,5 +40,6 @@ Surgery uses best medicine available Surgery uses best Default care + Remove this (in case it lingers around after it's unused) \ No newline at end of file diff --git a/Languages/Sample/DefInjected/ThingDef/SampleThingDefInjected.xml b/Languages/Sample/DefInjected/ThingDef/SampleThingDefInjected.xml index f8dab1c..b0f9a04 100644 --- a/Languages/Sample/DefInjected/ThingDef/SampleThingDefInjected.xml +++ b/Languages/Sample/DefInjected/ThingDef/SampleThingDefInjected.xml @@ -2,6 +2,6 @@ temporary tending spot - Automatically created by Smart Medicine to tend in the field (without slow-down effects). + Automatically created by Smart Medicine to tend in the field. Removes itself when not used. \ No newline at end of file diff --git a/Source/FieldTending.cs b/Source/FieldTending.cs index 9a55582..6fa8651 100644 --- a/Source/FieldTending.cs +++ b/Source/FieldTending.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Reflection; using System.Reflection.Emit; using RimWorld; @@ -11,6 +12,29 @@ namespace SmartMedicine { + public class Building_TempTendSpot : Building_Bed + { + public override string GetInspectString() + { + return DescriptionDetailed.TrimEndNewlines(); + } + + public override IEnumerable GetGizmos() + { + foreach (Gizmo g in base.GetGizmos()) + yield return g; + + yield return new Command_Action() + { + defaultLabel = "DesignatorCancel".Translate(), + defaultDesc = "TD.RemoveTempTendDesc".Translate(), + icon = ContentFinder.Get("UI/Designators/Cancel", true), + hotKey = KeyBindingDefOf.Designator_Cancel, + action = () => this.Destroy() + }; + } + } + [HarmonyPatch(typeof(WorkGiver_Tend))] [HarmonyPatch("GoodLayingStatusForTend")] static class GoodLayingStatusForTend_Patch @@ -142,7 +166,8 @@ public static void Prefix(JobDriver_LayDown __instance) __instance.AddFinishAction(delegate () { if (__instance.Bed?.def == UseTempSleepSpot.TempSleepSpot) - __instance.Bed.Destroy(); + if(!__instance.Bed?.Destroyed ?? false) + __instance.Bed.Destroy(); }); } }