Skip to content

Commit

Permalink
Making temporary tend spots selectable and cancelable, since apparent…
Browse files Browse the repository at this point in the history
…ly some people see them not get deleted.
  • Loading branch information
alextd committed Nov 10, 2018
1 parent dc6ce1c commit 03b62ed
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Defs/TempFieldTendingSpot.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>


<ThingDef>
<defName>TempSleepSpot</defName>
<label>temporary tending spot</label>
<description>Automatically created by Smart Medicine to tend in the field (without slow-down effects).</description>
<thingClass>Building_Bed</thingClass>
<description>Automatically created by Smart Medicine to tend in the field. Removes itself when not used.</description>
<thingClass>SmartMedicine.Building_TempTendSpot</thingClass>
<graphicData>
<texPath>TempSleepSpot</texPath>
<graphicClass>Graphic_Single</graphicClass>
</graphicData>
<altitudeLayer>FloorEmplacement</altitudeLayer>
<selectable>false</selectable>
<selectable>true</selectable>
<statBases>
<WorkToBuild>0</WorkToBuild>
<Comfort>0.4</Comfort>
Expand All @@ -26,6 +25,7 @@
<bed_showSleeperBody>True</bed_showSleeperBody>
<canPlaceOverImpassablePlant>false</canPlaceOverImpassablePlant>
<ai_chillDestination>false</ai_chillDestination>
<claimable>false</claimable>
</building>
</ThingDef>

Expand Down
1 change: 1 addition & 0 deletions Languages/English/Keyed/AutoEnglish.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
<TD.DefaultSurgeryUnlimited>Surgery uses best medicine available</TD.DefaultSurgeryUnlimited>
<TD.PawnSettingSurgeryUnlimited>Surgery uses best</TD.PawnSettingSurgeryUnlimited>
<TD.DefaultCare>Default care</TD.DefaultCare>
<TD.RemoveTempTendDesc>Remove this (in case it lingers around after it's unused)</TD.RemoveTempTendDesc>

</LanguageData>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<LanguageData>

<TempSleepSpot.label>temporary tending spot</TempSleepSpot.label>
<TempSleepSpot.description>Automatically created by Smart Medicine to tend in the field (without slow-down effects).</TempSleepSpot.description>
<TempSleepSpot.description>Automatically created by Smart Medicine to tend in the field. Removes itself when not used.</TempSleepSpot.description>

</LanguageData>
27 changes: 26 additions & 1 deletion Source/FieldTending.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,6 +12,29 @@

namespace SmartMedicine
{
public class Building_TempTendSpot : Building_Bed
{
public override string GetInspectString()
{
return DescriptionDetailed.TrimEndNewlines();
}

public override IEnumerable<Gizmo> GetGizmos()
{
foreach (Gizmo g in base.GetGizmos())
yield return g;

yield return new Command_Action()
{
defaultLabel = "DesignatorCancel".Translate(),
defaultDesc = "TD.RemoveTempTendDesc".Translate(),
icon = ContentFinder<Texture2D>.Get("UI/Designators/Cancel", true),
hotKey = KeyBindingDefOf.Designator_Cancel,
action = () => this.Destroy()
};
}
}

[HarmonyPatch(typeof(WorkGiver_Tend))]
[HarmonyPatch("GoodLayingStatusForTend")]
static class GoodLayingStatusForTend_Patch
Expand Down Expand Up @@ -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();
});
}
}
Expand Down

0 comments on commit 03b62ed

Please sign in to comment.