Skip to content

Commit

Permalink
Merge pull request #67 from emipa606/main
Browse files Browse the repository at this point in the history
Mechanoids should now stay in the charging station
  • Loading branch information
rheirman authored Jan 19, 2023
2 parents 4a56a82 + a5624b7 commit 83a7409
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 63 deletions.
Binary file modified 1.4/Assemblies/WhatTheHack.dll
Binary file not shown.
35 changes: 0 additions & 35 deletions Source/WhatTheHack/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace WhatTheHack;

// WhatTheHack.Extensions.IsMechanoidLike(RaceProperties RaceProps)
public static class Extensions
{
public static void RemoveRemoteControlLink(this Pawn pawn)
Expand Down Expand Up @@ -156,40 +155,6 @@ public static void RemoveAllLinks(this Pawn pawn)
pawn.RevertToFaction(pawnData.originalFaction);
}
}
/*
public static Building_HackingTable HackingTable(this Pawn pawn)
{
List<Thing> thingList = pawn.Position.GetThingList(pawn.Map);
Building_HackingTable hackingTable = null;
for (int i = 0; i < thingList.Count; i++)
{
hackingTable = (thingList[i] as Building_HackingTable);
if (hackingTable != null)
{
break;
}
}
if (hackingTable == null)
{
return null;
}
if(hackingTable.GetCurOccupant(0) == pawn)
{
return hackingTable;
}
return null;
}
*/
/*
public static bool OnHackingTable(this Pawn pawn)
{
if(pawn.HackingTable() != null)
{
return true;
}
return false;
}
*/

public static void FailOnPlatformNoLongerUsable(this Toil toil, TargetIndex bedIndex)
{
Expand Down
18 changes: 1 addition & 17 deletions Source/WhatTheHack/Harmony/Building_Bed_get_DrawColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,4 @@ private static void Postfix(Building_Bed __instance, ref Color __result)
__result = new Color(1f, 1f, 1f);
}
}
}

//[HarmonyPatch(typeof(CompAssignableToPawn), "CanAssignTo")]
//static class CompAssignableToPawn_CanAssignTo
//{
// static bool Prefix(CompAssignableToPawn __instance, Pawn pawn, ref AcceptanceReport __result)
// {
// if (pawn.IsHacked() && pawn.Faction == Faction.OfPlayer)
// {
// __result = AcceptanceReport.WasAccepted;
// return false;
// }
// return true;
// }
//}

//Patch is needed so mechanoids that are standing up can still have a "cur bed"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using HarmonyLib;
using RimWorld;
using Verse;

namespace WhatTheHack.Harmony;

[HarmonyPatch(typeof(JobGiver_GetEnergy), "ShouldAutoRecharge")]
internal static class JobGiver_GetEnergy_ShouldAutoRecharge
{
private static void Postfix(ref bool __result, Pawn pawn)
{
if (!__result)
{
return;
}

if (pawn.IsHacked())
{
__result = false;
}
}
}
13 changes: 13 additions & 0 deletions Source/WhatTheHack/Harmony/Need_MechEnergy_NeedInterval.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using HarmonyLib;
using RimWorld;

namespace WhatTheHack.Harmony;

[HarmonyPatch(typeof(Need_MechEnergy), "NeedInterval")]
internal static class Need_MechEnergy_NeedInterval
{
private static bool Prefix(Need_MechEnergy __instance)
{
return !__instance.pawn.IsHacked();
}
}
1 change: 1 addition & 0 deletions Source/WhatTheHack/Jobs/JobGiver_Mechanoid_Rest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ internal class JobGiver_Mechanoid_Rest : ThinkNode_JobGiver
public override Job TryGiveJob(Pawn pawn)
{
Job job = null;

if (pawn.IsActivated() && (pawn.ShouldRecharge() || pawn.ShouldBeMaintained()))
{
pawn.drafter.Drafted = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ public override bool Satisfied(Pawn pawn)
return true;
}

if (HealthAIUtility.ShouldHaveSurgeryDoneNow(pawn) && pawn.OnHackingTable())
{
return true;
}

return false;
return HealthAIUtility.ShouldHaveSurgeryDoneNow(pawn) && pawn.OnHackingTable();
}
}
10 changes: 5 additions & 5 deletions Source/WhatTheHack/WhatTheHack.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<Version>*</Version>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Krafs.Publicizer" Version="*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<Publicize Include="Assembly-CSharp" />
<PackageReference Include="Krafs.Publicizer" Version="*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<Publicize Include="Assembly-CSharp" />
</ItemGroup>
</Project>

0 comments on commit 83a7409

Please sign in to comment.