Skip to content

Commit

Permalink
Merge pull request #262 from Aviuz/1.4.6
Browse files Browse the repository at this point in the history
version 1.4.6
  • Loading branch information
Hazzer authored Feb 19, 2023
2 parents 776b454 + 3197afc commit c49201b
Show file tree
Hide file tree
Showing 31 changed files with 963 additions and 637 deletions.
Binary file modified 1.4/Assemblies/PrisonLabor.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LanguageData>
<PrisonLabor_workAndBloodfeedOption.label>工作與供血</PrisonLabor_workAndBloodfeedOption.label> <PrisonLabor_workAndBloodfeedOption.description>強迫囚犯工作,血原需求者可無視囚犯心情直接對其進食。</PrisonLabor_workAndBloodfeedOption.description>

<PrisonLabor_workAndHemogenFarmOption.label>工作和血包</PrisonLabor_workAndHemogenFarmOption.label> <PrisonLabor_workAndHemogenFarmOption.description>強迫囚犯工作,以不造成死亡為原則,抽取血液。</PrisonLabor_workAndHemogenFarmOption.description>

<?xml version="1.0" encoding="utf-8"?>
<LanguageData>
<PrisonLabor_workAndBloodfeedOption.label>工作與供血</PrisonLabor_workAndBloodfeedOption.label> <PrisonLabor_workAndBloodfeedOption.description>強迫囚犯工作,血原需求者可無視囚犯心情直接對其進食。</PrisonLabor_workAndBloodfeedOption.description>

<PrisonLabor_workAndHemogenFarmOption.label>工作和血包</PrisonLabor_workAndHemogenFarmOption.label> <PrisonLabor_workAndHemogenFarmOption.description>強迫囚犯工作,以不造成死亡為原則,抽取血液。</PrisonLabor_workAndHemogenFarmOption.description>

</LanguageData>
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 modified 1.4/Quarry/Assemblies/PrisonLaborQuarryCompatibility.dll
Binary file not shown.
Binary file modified 1.4/Therapy/Assemblies/PrisonLaborTherapyCompatibility.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</modDependencies>

<description>
Version 1.4.5
Version 1.4.6

This mod force prisoners to work. To enable this feature prisoners must have "Force to work" option checked ("Prisoner" tab). Prison labor needs management that consist:
- Motivation - prisoners need to be motivated by presence of colonists. Wardens have new job - supervising prisoners. Low motivation can lead to revolts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,4 @@

<PrisonLabor_workOption.label>強迫工作</PrisonLabor_workOption.label>
<PrisonLabor_workAndRecruitOption.label>工作與招募</PrisonLabor_workAndRecruitOption.label>

<PrisonLabor_workAndBloodfeedOption.label>工作與供血</PrisonLabor_workAndBloodfeedOption.label>
<PrisonLabor_workAndBloodfeedOption.description>強迫囚犯工作,血原需求者可無視囚犯心情直接對其進食。</PrisonLabor_workAndBloodfeedOption.description>

<PrisonLabor_workAndHemogenFarmOption.label>工作和血包</PrisonLabor_workAndHemogenFarmOption.label>
<PrisonLabor_workAndHemogenFarmOption.description>強迫囚犯工作,以不造成死亡為原則,抽取血液。</PrisonLabor_workAndHemogenFarmOption.description>


</LanguageData>
1 change: 1 addition & 0 deletions LoadFolders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
<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>
<li IfModActive="derekbickley.ltocolonygroupsfinal">1.4/ColonyGroups</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.5-orange.svg?style=flat" alt="v1.4.5" />
<img src="https://img.shields.io/badge/version-1.4.6-orange.svg?style=flat" alt="v1.4.6" />
</a>
</p>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A77AE1EB-BA5D-4B3A-9D9B-A9580850FAAD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ColonyGroupsCompatibility</RootNamespace>
<AssemblyName>PrisonLaborColonyGroupsCompatibility</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\1.4\ColonyGroups\Assemblies\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.2.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Lib.Harmony.2.2.2\lib\net472\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\Gry\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="CompatUtils">
<HintPath>..\..\..\..\..\Gry\Steam\steamapps\workshop\content\294100\2345493945\1.4\Assemblies\CompatUtils.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="TacticalGroups">
<HintPath>..\..\..\..\..\Gry\Steam\steamapps\workshop\content\294100\2345493945\1.4\Assemblies\TacticalGroups.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="HarmonyInit.cs" />
<Compile Include="HarmonyPatches\MarkGroupAssigment_Patch.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\PrisonLabor.csproj">
<Project>{97750974-4cb6-4d31-84a1-a3aa77b1e2ee}</Project>
<Name>PrisonLabor</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Verse;

namespace ColonyGroupsCompatibility
{
[StaticConstructorOnStartup]
public class HarmonyInit
{
static HarmonyInit()
{
var harmony = new Harmony("Harmony_PrisonLabor_ColonyGroups");
try
{
harmony.PatchAll(Assembly.GetExecutingAssembly());
Log.Message("[PL] ColonyGroups patched");
}
catch (Exception e)
{
Log.Error($"[PL] Patches for ColonyGroups failed: {e}");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using HarmonyLib;
using RimWorld;
using PrisonLabor.Core.BillAssignation;
using PrisonLabor.HarmonyPatches.Patches_GUI.GUI_Bill;
using TacticalGroups;
using System.Collections.Generic;
using Verse;
using PrisonLabor.Core.Other;
using System.Reflection;
using System.Reflection.Emit;
using System.Linq;
using static Verse.Widgets;
using System;

namespace ColonyGroupsCompatibility.HarmonyPatches
{
[HarmonyPatch(typeof(Patch_RestrictBillToPrisoner))]
public class ReturnLabel_Patch
{
[HarmonyPostfix]
[HarmonyPatch("GetDropLabel")]
public static string PostfixGetDropLabel(string __result, Dialog_BillConfig dialog)
{
Bill_Production bill = Traverse.Create(dialog).Field("bill").GetValue<Bill_Production>();
if (BillAssignationUtility.IsFor(bill) == GroupMode.ColonyGroups)
{
if (HarmonyPatches_GroupBills.BillsSelectedGroup.TryGetValue(bill, out PawnGroup group))
{
string label = "TG.AnyPawnOfGroup".Translate(group.curGroupName);
return label;
}
}
return __result;
}

}
[HarmonyPatch]
public class MarkGroupAssigment_Patch
{
static MethodBase TargetMethod()
{
return AccessTools.Method("TacticalGroups.HarmonyPatches_GroupBills:GeneratePawnRestrictionOptions");
}
public static IEnumerable<CodeInstruction> Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable<CodeInstruction> inst)
{
int bill = -1;
var codes = new List<CodeInstruction>(inst);
for (int i = 0; i < codes.Count(); i++)
{
yield return codes[i];
if (ShouldCopy(codes[i]))
{
bill = i;
}
if (ShouldPatch(codes[i]) && bill > -1)
{
DebugLogger.debug($"Changing delegate: {mBase.ReflectedType.Assembly.GetName().Name}.{mBase.ReflectedType.Name}.{mBase.Name}");
yield return new CodeInstruction(OpCodes.Ldloc_3, null);
//ldfld | TacticalGroups.HarmonyPatches_GroupBills+<>c__DisplayClass6_0 CS$<>8__locals1 | no labels
yield return codes[bill - 1];
//ldfld | RimWorld.Bill_Production ___bill | no labels
yield return codes[bill];
//ldloc.s | Verse.Widgets+DropdownMenuElement`1[Verse.Pawn] (8) | no labels
yield return codes[i - 1];
yield return new CodeInstruction(OpCodes.Call, typeof(MarkGroupAssigment_Patch).GetMethod(nameof(MarkGroupAssigment_Patch.UpdateAction)));
}
}
}

private static bool ShouldPatch(CodeInstruction actual)
{
return actual.opcode == OpCodes.Callvirt && actual.operand != null && actual.operand.ToString().Contains("Void Insert(Int32, DropdownMenuElement`1)");
}

private static bool ShouldCopy(CodeInstruction actual)
{
return actual.opcode == OpCodes.Ldfld && actual.operand != null && actual.operand.ToString().Contains("RimWorld.Bill_Production ___bill");
}
public static void UpdateAction(Bill_Production bill, DropdownMenuElement<Pawn> element)
{
Action notify = delegate
{
BillAssignationUtility.SetFor(bill, GroupMode.ColonyGroups);
DebugLogger.debug($"For {bill.Label} set {GroupMode.ColonyGroups}");
};
element.option.action += notify;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ColonyGroupsCompatibility")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ColonyGroupsCompatibility")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a77ae1eb-ba5d-4b3a-9d9b-a9580850faad")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Lib.Harmony" version="2.2.2" targetFramework="net472" requireReinstallation="true" />
</packages>
62 changes: 38 additions & 24 deletions Source/Core/BillAssignation/BillAssignationUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,48 @@

namespace PrisonLabor.Core.BillAssignation
{
public class BillAssignationUtility
public class BillAssignationUtility
{
private static readonly Dictionary<Bill, BillGroupData> Map = new Dictionary<Bill, BillGroupData>();

public static GroupMode IsFor(Bill key)
{
private static readonly Dictionary<Bill, BillGroupData> Map = new Dictionary<Bill, BillGroupData>();
if (!Map.ContainsKey(key))
{
Map[key] = new BillGroupData();
SetMechanitorIfNeeded(key);
}
return Map[key].Mode;
}

public static GroupMode IsFor(Bill key)
{
if (!Map.ContainsKey(key))
Map[key] = new BillGroupData();
return Map[key].Mode;
}
public static void SetFor(Bill key, GroupMode value)
{
if (!Map.ContainsKey(key))
Map[key] = new BillGroupData();
Map[key].Mode = value;
}

public static void SetFor(Bill key, GroupMode value)
{
if (!Map.ContainsKey(key))
Map[key] = new BillGroupData();
Map[key].Mode = value;
}
public static BillGroupData GetData(Bill key)
{
if (!Map.ContainsKey(key))
{
Map[key] = new BillGroupData();
SetMechanitorIfNeeded(key);
}
return Map[key];
}

public static BillGroupData GetData(Bill key)
{
if (!Map.ContainsKey(key))
Map[key] = new BillGroupData();
return Map[key];
}
private static void SetMechanitorIfNeeded(Bill key)
{
if (key.recipe.mechanitorOnlyRecipe)
{
Map[key].Mode = GroupMode.MechanitorOnly;
}
}

public static void Remove(Bill bill)
{
Map.Remove(bill);
}
public static void Remove(Bill bill)
{
Map.Remove(bill);
}
}
}
6 changes: 5 additions & 1 deletion Source/Core/BillAssignation/BillGroupData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ public enum GroupMode
PrisonersOnly,
ColonistsOnly,
SlavesOnly,
CaptiveOnly
HumansOnly,
MechsOnly,
MechanitorOnly,
CaptiveOnly,
ColonyGroups
}

public class BillGroupData : IExposable
Expand Down
Loading

0 comments on commit c49201b

Please sign in to comment.