Skip to content

Commit

Permalink
Merge pull request #30 from Mehni/1.1
Browse files Browse the repository at this point in the history
Update to 1.1
  • Loading branch information
Mehni authored Mar 2, 2020
2 parents 649726c + 6c3ae9e commit ec64777
Show file tree
Hide file tree
Showing 35 changed files with 3,810 additions and 62 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,4 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs
/Assemblies/0Harmony.xml
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Binary file added 1.1/Assemblies/0Harmony.dll
Binary file not shown.
2,476 changes: 2,476 additions & 0 deletions 1.1/Assemblies/0Harmony.xml

Large diffs are not rendered by default.

Binary file added 1.1/Assemblies/IHoldMultipleThings.dll
Binary file not shown.
Binary file added 1.1/Assemblies/PickUpAndHaul.dll
Binary file not shown.
20 changes: 16 additions & 4 deletions About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@
<author>Mehni</author>
<supportedVersions>
<li>1.0</li>
<li>1.1</li>
</supportedVersions>
<packageId>Mehni.PickUpAndHaul</packageId>
<modDependenciesByVersion>
<v1.1>
<li>
<packageId>brrainz.harmony</packageId>
<displayName>Harmony</displayName>
<steamWorkshopUrl>steam://url/CommunityFilePage/2009463077</steamWorkshopUrl>
<downloadUrl>https://github.com/pardeike/HarmonyRimWorld/releases/latest</downloadUrl>
</li>
</v1.1>
</modDependenciesByVersion>
<url>https://ludeon.com/forums/index.php?topic=35832</url>
<description>"Greatest hauling mod ever" - Chicken Plucker

v.1.0.5
v1.1.0

Colonists will gather stuff in their inventory, then haul it all to a stockpile.

This hauling mod will greatly increase hauling efficiency, because pawns can now carry more than one gun or t-shirt. Those smart and intelligent colonists can use their inventory!

Works well in combination with Combat Extended, AllowTool's Haul Urgently, etc. No known conflicts.
Safe to add to existing games.

Safe to add to existing games. &lt;size=20&gt;Credits and thanks:&lt;/size&gt;
&lt;size=20&gt;Credits and thanks:&lt;/size&gt;
- AlexTD, for his direct contributions
- erdelf, Zorba, Why_is_that and Dingo for code and advice (yet again!)
- Chicken Plucker, for the preview image
Expand Down
9 changes: 6 additions & 3 deletions Source/IHoldMultipleThings/IHoldMultipleThings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IHoldMultipleThings</RootNamespace>
<AssemblyName>IHoldMultipleThings</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Assemblies\</OutputPath>
<OutputPath>..\..\v1.1\Assemblies\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Assemblies\</OutputPath>
<OutputPath>..\..\1.1\Assemblies\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
Expand Down
11 changes: 11 additions & 0 deletions Source/IHoldMultipleThingsv1.0/IHoldMultipleThings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Verse;

namespace IHoldMultipleThings
{
public interface IHoldMultipleThings
{
bool CapacityAt(Thing thing, IntVec3 storeCell, Map map, out int capacity);

bool StackableAt(Thing thing, IntVec3 storeCell, Map map);
}
}
53 changes: 53 additions & 0 deletions Source/IHoldMultipleThingsv1.0/IHoldMultipleThingsv10.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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>{0F7BA6C3-BF3C-42D5-9268-593B4AF8FC12}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IHoldMultipleThings</RootNamespace>
<AssemblyName>IHoldMultipleThings</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Assemblies\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Assemblies\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.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="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IHoldMultipleThings.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
36 changes: 36 additions & 0 deletions Source/IHoldMultipleThingsv1.0/Properties/AssemblyInfo.cs
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("IHoldMultipleThings")]
[assembly: AssemblyDescription("Pick Up and Haul interface for multi-stack solutions")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IHoldMultipleThings")]
[assembly: AssemblyCopyright("Copyright © Mehni 2019")]
[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("e1536a54-d289-41fa-9d0b-8a2f6812c7fa")]

// 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("0.1.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
12 changes: 10 additions & 2 deletions Source/PickUpAndHaul.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2020
# Visual Studio Version 16
VisualStudioVersion = 16.0.29025.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PickUpAndHaul", "PickUpAndHaul\PickUpAndHaul.csproj", "{CCF8350B-E3FD-4693-9209-681E9C089097}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IHoldMultipleThings", "IHoldMultipleThings\IHoldMultipleThings.csproj", "{E1536A54-D289-41FA-9D0B-8A2F6812C7FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PickUpAndHaulv10", "PickUpAndHaulv1.0\PickUpAndHaulv10.csproj", "{2480F13E-E9ED-44EC-A5DE-C821676904E7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IHoldMultipleThingsv10", "IHoldMultipleThingsv1.0\IHoldMultipleThingsv10.csproj", "{0F7BA6C3-BF3C-42D5-9268-593B4AF8FC12}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +25,10 @@ Global
{E1536A54-D289-41FA-9D0B-8A2F6812C7FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1536A54-D289-41FA-9D0B-8A2F6812C7FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1536A54-D289-41FA-9D0B-8A2F6812C7FA}.Release|Any CPU.Build.0 = Release|Any CPU
{2480F13E-E9ED-44EC-A5DE-C821676904E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2480F13E-E9ED-44EC-A5DE-C821676904E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F7BA6C3-BF3C-42D5-9268-593B4AF8FC12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F7BA6C3-BF3C-42D5-9268-593B4AF8FC12}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
7 changes: 1 addition & 6 deletions Source/PickUpAndHaul/DebugLog.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PickUpAndHaul
namespace PickUpAndHaul
{
static class Log
{
Expand Down
25 changes: 12 additions & 13 deletions Source/PickUpAndHaul/HarmonyPatches.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse;
using UnityEngine;
using Harmony;
using HarmonyLib;
using System.Reflection.Emit;
using System.Reflection;
using Verse.AI;
Expand All @@ -17,7 +16,10 @@ static class HarmonyPatches
{
static HarmonyPatches()
{
HarmonyInstance harmony = HarmonyInstance.Create(id: "mehni.rimworld.pickupandhaul.main");
var harmony = new Harmony("mehni.rimworld.pickupandhaul.main");
#if DEBUG
Harmony.DEBUG = true;
#endif

harmony.Patch(original: AccessTools.Method(typeof(FloatMenuMakerMap), "AddHumanlikeOrders"),
transpiler: new HarmonyMethod(typeof(HarmonyPatches), nameof(FloatMenuMakerMad_AddHumanlikeOrders_Transpiler)));
Expand All @@ -40,7 +42,7 @@ static HarmonyPatches()
harmony.Patch(original: AccessTools.Method(typeof(ITab_Pawn_Gear), "DrawThingRow"),
transpiler: new HarmonyMethod(typeof(HarmonyPatches), nameof(GearTabHighlightTranspiler)));

Verse.Log.Message("PickUpAndHaul v0.1.0.5¼ welcomes you to RimWorld with pointless logspam.", true);
Verse.Log.Message("PickUpAndHaul v0.1.1.0⅓ welcomes you to RimWorld with pointless logspam.", true);
}

private static bool Drop_Prefix(Pawn pawn, Thing thing)
Expand Down Expand Up @@ -101,15 +103,14 @@ public static void DropUnusedInventory_PostFix(Pawn pawn)

public static IEnumerable<CodeInstruction> FloatMenuMakerMad_AddHumanlikeOrders_Transpiler(IEnumerable<CodeInstruction> instructions)
{

MethodInfo playerHome = AccessTools.Property(typeof(Map), nameof(Map.IsPlayerHome)).GetGetMethod();
List<CodeInstruction> instructionList = instructions.ToList();

bool patched = false;

foreach (CodeInstruction instruction in instructionList)
{
if (!patched && instruction.operand == playerHome && !ModCompatibilityCheck.CombatExtendedIsActive)
if (!patched && instruction.Calls(playerHome) && !ModCompatibilityCheck.CombatExtendedIsActive)
{
instruction.opcode = OpCodes.Ldc_I4_0;
instruction.operand = null;
Expand All @@ -122,26 +123,24 @@ public static IEnumerable<CodeInstruction> FloatMenuMakerMad_AddHumanlikeOrders_

//ITab_Pawn_Gear
//private void DrawThingRow(ref float y, float width, Thing thing, bool inventory = false)
public static IEnumerable<CodeInstruction> GearTabHighlightTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator il, MethodBase mb)
public static IEnumerable<CodeInstruction> GearTabHighlightTranspiler(IEnumerable<CodeInstruction> instructions)
{
MethodInfo WidgetsButtonImageInfo = AccessTools.Method(typeof(Widgets), "ButtonImage", new Type[] { typeof(Rect), typeof(Texture2D) });
MethodInfo WidgetsButtonImageColorInfo = AccessTools.Method(typeof(Widgets), "ButtonImage", new Type[] { typeof(Rect), typeof(Texture2D), typeof(Color) });

MethodInfo SelPawnForGearInfo = AccessTools.Property(typeof(ITab_Pawn_Gear), "SelPawnForGear").GetGetMethod(true);

MethodInfo GetColorForHauledInfo = AccessTools.Method(typeof(HarmonyPatches), nameof(GetColorForHauled));

MethodInfo ColorWhite = AccessTools.Property(typeof(Color), nameof(Color.white)).GetGetMethod();

bool done = false;
foreach (CodeInstruction i in instructions)
{
//if (Widgets.ButtonImage(rect2, TexButton.Drop))
if (!done && i.opcode == OpCodes.Call && i.operand == WidgetsButtonImageInfo)
//// Color color = flag ? Color.grey : Color.white;
if (!done && i.Calls(ColorWhite))
{
yield return new CodeInstruction(OpCodes.Ldarg_0); //this
yield return new CodeInstruction(OpCodes.Call, SelPawnForGearInfo); //this.SelPawnForGearInfo
yield return new CodeInstruction(OpCodes.Ldarg_3); //thing
yield return new CodeInstruction(OpCodes.Call, GetColorForHauledInfo); //GetColorForHauledInfo(Pawn, Thing)
yield return new CodeInstruction(OpCodes.Call, WidgetsButtonImageColorInfo); //ButtonImage(rect, texture, color)
done = true;
}
else
Expand Down
2 changes: 1 addition & 1 deletion Source/PickUpAndHaul/JobDriver_HaulToInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected override IEnumerable<Toil> MakeNewToils()
Job curJob = actor.jobs.curJob;
LocalTargetInfo storeCell = curJob.targetB;

Job unloadJob = new Job(PickUpAndHaulJobDefOf.UnloadYourHauledInventory, storeCell);
Job unloadJob = JobMaker.MakeJob(PickUpAndHaulJobDefOf.UnloadYourHauledInventory, storeCell);
if (unloadJob.TryMakePreToilReservations(actor, false))
{
actor.jobs.jobQueue.EnqueueFirst(unloadJob, JobTag.Misc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ from straggler in pawn.inventory.innerContainer
}
return new ThingCount(thing, thing.stackCount);
}
return default(ThingCount);
return default;
}
}
}
7 changes: 2 additions & 5 deletions Source/PickUpAndHaul/PawnUnloadChecker.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using RimWorld;
using Verse;
using Verse.AI;
Expand All @@ -12,7 +9,7 @@ public class PawnUnloadChecker
{
public static void CheckIfPawnShouldUnloadInventory(Pawn pawn, bool forced = false)
{
Job job = new Job(PickUpAndHaulJobDefOf.UnloadYourHauledInventory, pawn);
Job job = JobMaker.MakeJob(PickUpAndHaulJobDefOf.UnloadYourHauledInventory, pawn);
CompHauledToInventory itemsTakenToInventory = pawn.TryGetComp<CompHauledToInventory>();

if (itemsTakenToInventory == null)
Expand Down
Loading

0 comments on commit ec64777

Please sign in to comment.