Skip to content

Commit

Permalink
Merge pull request #259 from Aviuz/1.4.4
Browse files Browse the repository at this point in the history
1.4.4
  • Loading branch information
Hazzer authored Nov 22, 2022
2 parents a2696cb + 10d09d9 commit 8112131
Show file tree
Hide file tree
Showing 44 changed files with 574 additions and 894 deletions.
Binary file modified 1.4/Assemblies/PrisonLabor.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified 1.4/Kijin/Assemblies/PrisonLaborKijinCompatibility.dll
Binary file not shown.
Binary file not shown.
Binary file modified 1.4/Quarry/Assemblies/PrisonLaborQuarryCompatibility.dll
Binary file not shown.
Binary file modified 1.4/Therapy/Assemblies/PrisonLaborTherapyCompatibility.dll
Binary file not shown.
1 change: 1 addition & 0 deletions About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<li>orion.therapy</li>
<li>ogliss.thewhitecrayon.quarry</li>
<li>ssulunge.kijinrace2</li>
<li>ssulunge.kijinrace3</li>
<li>orion.cashregister</li>
<li>orion.hospitality</li>
<li>orion.gastronomy</li>
Expand Down
3 changes: 2 additions & 1 deletion LoadFolders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<li IfModActive="orion.hospitality">1.4/Hospitality</li>
<li IfModActive="hatti.cleaningarea">1.4/CleaningArea</li>
<li IfModActive="orion.cashregister">1.4/CashRegistry</li>
<li IfModActive="ssulunge.kijinrace2">1.4/Kijin</li>
<li IfModActive="ssulunge.kijinrace2">1.4/Kijin2</li>
<li IfModActive="ssulunge.kijinrace3">1.4/Kijin</li>
<li IfModActive="ogliss.thewhitecrayon.quarry">1.4/Quarry</li>
</v1.4>
</loadFolders>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</p>
<p align="center">
<a href="https://github.com/Aviuz/PrisonLabor/releases">
<img src="https://img.shields.io/badge/version-1.4.3-orange.svg?style=flat" alt="v1.4.3" />
<img src="https://img.shields.io/badge/version-1.4.4-orange.svg?style=flat" alt="v1.4.4" />
</a>
</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ static HarmonyInit()
try
{
harmony.PatchAll(Assembly.GetExecutingAssembly());
Log.Message("[PL] Kijin Race 2.0 patched");
Log.Message("[PL] Kijin Race 3.0 patched");
}
catch (Exception e)
{
Log.Error($"[PL] Patches for Kijin Race 2.0 failed: {e}");
Log.Error($"[PL] Patches for Kijin Race 3.0 failed: {e}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,39 @@
using Verse.AI;
using Verse;
using Verse.Noise;
using System.Reflection.Emit;
using PrisonLabor.HarmonyPatches;

namespace KijinCompatibility.HarmonyPatches
{
[HarmonyPatch]
class PrisonerHarvestResourcesPatch
[HarmonyPatch]
class PrisonerHarvestResourcesPatch
{
static MethodBase TargetMethod()
{
static MethodBase TargetMethod()
return AccessTools.Method("Kijin3.Kijin3PlantCollectedPatch:GetFirstPawnNotDeadOrDowned");
}

static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var codes = new List<CodeInstruction>(instructions);
for (int i = 0; i < codes.Count(); i++)
{
if (i > 0 && ShouldPatch(codes[i], codes[i - 1]))
{
return AccessTools.Method("Kijin2.Kijin2PlantCollectedPatch:GetFirstPawnNotDeadOrDowned");
yield return new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod(nameof(PrisonLaborUtility.GetPawnFaction)));
}
static Pawn Postfix(Pawn __result, IntVec3 c, Map map)
else
{
if (__result == null)
{
foreach (Thing thing in GridsUtility.GetThingList(c, map))
{
Pawn val = thing as Pawn;
if (val != null && !val.Dead && !val.Downed && val.IsPrisonerOfColony)
{
return val;
}
}
}
return __result;
yield return codes[i];
}
}
}

private static bool ShouldPatch(CodeInstruction actual, CodeInstruction prev)
{
return prev.opcode == OpCodes.Ldloc_2 && actual.opcode == OpCodes.Callvirt && actual.operand != null && actual.operand.ToString().Contains("RimWorld.Faction get_Faction()");
}

}
}
214 changes: 107 additions & 107 deletions Source/Core/MainButton_Window/CustomTabWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,112 +9,112 @@

namespace PrisonLabor.Core.MainButton_Window
{
public abstract class CustomTabWindow : Window
public abstract class CustomTabWindow : Window
{
private PawnTable table;

protected virtual float ExtraBottomSpace => 53f;

protected virtual float ExtraTopSpace => 0f;

protected abstract PawnTableDef PawnTableDef
{
get;
}

protected override float Margin => 6f;

public virtual Vector2 RequestedTabSize
{
get
{
if (table == null)
{
return Vector2.zero;
}
return new Vector2(table.Size.x + Margin * 2f, table.Size.y + ExtraTopSpace + ExtraBottomSpace + Margin * 2f);
}
}

public virtual MainTabWindowAnchor Anchor => MainTabWindowAnchor.Left;

public override Vector2 InitialSize
{
get
{
Vector2 requestedTabSize = RequestedTabSize;
if (requestedTabSize.y > (float)(UI.screenHeight - 35))
{
requestedTabSize.y = UI.screenHeight - 35;
}
if (requestedTabSize.x > (float)UI.screenWidth)
{
requestedTabSize.x = UI.screenWidth;
}
return requestedTabSize;
}
}
protected virtual IEnumerable<Pawn> Pawns => Find.CurrentMap.mapPawns.FreeColonists;

public override void PostOpen()
{
base.PostOpen();
if (table == null)
{
table = CreateTable();
}
SetDirty();
}

public override void DoWindowContents(Rect rect)
{
table.PawnTableOnGUI(new Vector2(rect.x, rect.y + ExtraTopSpace));
}

public void Notify_PawnsChanged()
{
SetDirty();
}

public override void Notify_ResolutionChanged()
{
table = CreateTable();
base.Notify_ResolutionChanged();
}

private PawnTable CreateTable()
{
return (PawnTable)Activator.CreateInstance(PawnTableDef.workerClass, PawnTableDef, (Func<IEnumerable<Pawn>>)(() => Pawns), UI.screenWidth - (int)(Margin * 2f), (int)((float)(UI.screenHeight - 35) - ExtraBottomSpace * 1.5f - ExtraTopSpace - Margin * 2f));
}

protected void SetDirty()
{
table.SetDirty();
SetInitialSizeAndPosition();
}
public CustomTabWindow()
{
layer = WindowLayer.GameUI;
soundAppear = null;
soundClose = SoundDefOf.TabClose;
doCloseButton = false;
doCloseX = false;
preventCameraMotion = false;
}

protected override void SetInitialSizeAndPosition()
{
private PawnTable table;

protected virtual float ExtraBottomSpace => 53f;

protected virtual float ExtraTopSpace => 0f;

protected abstract PawnTableDef PawnTableDef
{
get;
}

protected override float Margin => 6f;

public virtual Vector2 RequestedTabSize
{
get
{
if (table == null)
{
return Vector2.zero;
}
return new Vector2(table.Size.x + Margin * 2f, table.Size.y + ExtraBottomSpace + ExtraTopSpace + Margin * 2f);
}
}

public virtual MainTabWindowAnchor Anchor => MainTabWindowAnchor.Left;

public override Vector2 InitialSize
{
get
{
Vector2 requestedTabSize = RequestedTabSize;
if (requestedTabSize.y > (float)(UI.screenHeight - 35))
{
requestedTabSize.y = UI.screenHeight - 35;
}
if (requestedTabSize.x > (float)UI.screenWidth)
{
requestedTabSize.x = UI.screenWidth;
}
return requestedTabSize;
}
}
protected virtual IEnumerable<Pawn> Pawns => Find.CurrentMap.mapPawns.FreeColonists;

public override void PostOpen()
{
base.PostOpen();
if (table == null)
{
table = CreateTable();
}
SetDirty();
}

public override void DoWindowContents(Rect rect)
{
table.PawnTableOnGUI(new Vector2(rect.x, rect.y + ExtraTopSpace));
}

public void Notify_PawnsChanged()
{
SetDirty();
}

public override void Notify_ResolutionChanged()
{
table = CreateTable();
base.Notify_ResolutionChanged();
}

private PawnTable CreateTable()
{
return (PawnTable)Activator.CreateInstance(PawnTableDef.workerClass, PawnTableDef, (Func<IEnumerable<Pawn>>)(() => Pawns), UI.screenWidth - (int)(Margin * 2f), (int)((float)(UI.screenHeight - 35) - ExtraBottomSpace - ExtraTopSpace - Margin * 2f));
}

protected void SetDirty()
{
table.SetDirty();
SetInitialSizeAndPosition();
}
public CustomTabWindow()
{
layer = WindowLayer.GameUI;
soundAppear = null;
soundClose = SoundDefOf.TabClose;
doCloseButton = false;
doCloseX = false;
preventCameraMotion = false;
}

protected override void SetInitialSizeAndPosition()
{
base.SetInitialSizeAndPosition();
if (Anchor == MainTabWindowAnchor.Left)
{
windowRect.x = 0f;
}
else
{
windowRect.x = (float)UI.screenWidth - windowRect.width;
}
windowRect.y = (float)(UI.screenHeight - 35) - windowRect.height;
}

}
base.SetInitialSizeAndPosition();
if (Anchor == MainTabWindowAnchor.Left)
{
windowRect.x = 0f;
}
else
{
windowRect.x = (float)UI.screenWidth - windowRect.width;
}
windowRect.y = (float)(UI.screenHeight - 35) - windowRect.height;
}

}
}
Loading

0 comments on commit 8112131

Please sign in to comment.