Skip to content

Commit

Permalink
v1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
XeoNovaDan committed Nov 30, 2018
1 parent 93d9f96 commit 03657e8
Show file tree
Hide file tree
Showing 21 changed files with 156 additions and 78 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<author>XeoNovaDan</author>
<url>https://ludeon.com/forums/index.php?topic=29503.0</url>
<targetVersion>1.0.2096</targetVersion>
<description>Current version: v1.1.2 (28th November 2018)\n\nAdds tools and the need to manage tools to RimWorld.\n* Colonists work much less efficiently in certain tasks without the relevant tools\n* Colonists can use tools from their inventory as well as their main hand\n* Acquire tools through production, purchase and plunder\n* Different materials affect tools in different ways\n* Tools will degrade over use</description>
<description>Current version: v1.1.3 (30th November 2018)\n\nAdds tools and the need to manage tools to RimWorld.\n* Colonists work much less efficiently in certain tasks without the relevant tools\n* Colonists can use tools from their inventory as well as their main hand\n* Acquire tools through production, purchase and plunder\n* Different materials affect tools in different ways\n* Tools will degrade over use</description>
</ModMetaData>
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Manifest>
<identifier>SurvivalTools</identifier>
<version>1.1.2</version>
<version>1.1.3</version>
<loadAfter>
<li>TurretExtensions</li>
<li>ExpandedWoodworkingVGP</li>
Expand Down
Binary file modified Assemblies/SurvivalTools.dll
Binary file not shown.
29 changes: 29 additions & 0 deletions Patches/Crystalloid/Patch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Patch>

<Operation Class="PatchOperationFindMod">
<mods>
<li>Crystalloid (Rewrite)</li>
<li>Crystalloid</li>
</mods>
<match Class="PatchOperationSequence">
<success>Always</success>
<operations>
<li Class="PatchOperationAddModExtension">
<xpath>Defs/ThingDef[defName="Crysteel"]</xpath>
<value>
<li Class="SurvivalTools.StuffPropsTool">
<toolStatFactors>
<TreeFellingSpeed>1.4</TreeFellingSpeed>
<PlantHarvestingSpeed>1.4</PlantHarvestingSpeed>
<DiggingSpeed>1.1</DiggingSpeed>
<MiningYieldDigging>0.9</MiningYieldDigging>
<ConstructionSpeed>1.1</ConstructionSpeed>
</toolStatFactors>
</li>
</value>
</li>
</operations>
</match>
</Operation>

</Patch>
91 changes: 91 additions & 0 deletions Patches/RimBees/Patch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<Patch>

<Operation Class="PatchOperationFindMod">
<mods>
<li>RimBees</li>
</mods>
<match Class="PatchOperationSequence">
<success>Always</success>
<operations>

<!-- While stat-wise for tool relevant stuff, beeswax is identical to steel, I'm making it more on par with wood since that's more logical -->
<li Class="PatchOperationAddModExtension">
<xpath>Defs/ThingDef[defName="RB_Beeswax"]</xpath>
<value>
<li Class="SurvivalTools.StuffPropsTool">
<toolStatFactors>
<TreeFellingSpeed>0.3</TreeFellingSpeed>
<PlantHarvestingSpeed>0.3</PlantHarvestingSpeed>
<DiggingSpeed>0.4</DiggingSpeed>
<MiningYieldDigging>0.7</MiningYieldDigging>
<ConstructionSpeed>0.4</ConstructionSpeed>
</toolStatFactors>
</li>
</value>
</li>

<li Class="PatchOperationAddModExtension">
<xpath>Defs/ThingDef[defName="RB_Brittlewax"]</xpath>
<value>
<li Class="SurvivalTools.StuffPropsTool">
<toolStatFactors>
<TreeFellingSpeed>0.25</TreeFellingSpeed>
<PlantHarvestingSpeed>0.25</PlantHarvestingSpeed>
<DiggingSpeed>0.3</DiggingSpeed>
<MiningYieldDigging>0.6</MiningYieldDigging>
<ConstructionSpeed>0.3</ConstructionSpeed>
</toolStatFactors>
</li>
</value>
</li>

<li Class="PatchOperationAddModExtension">
<xpath>Defs/ThingDef[defName="RB_RedBeeswax"]</xpath>
<value>
<li Class="SurvivalTools.StuffPropsTool">
<toolStatFactors>
<TreeFellingSpeed>0.4</TreeFellingSpeed>
<PlantHarvestingSpeed>0.4</PlantHarvestingSpeed>
<DiggingSpeed>0.5</DiggingSpeed>
<MiningYieldDigging>0.8</MiningYieldDigging>
<ConstructionSpeed>0.5</ConstructionSpeed>
</toolStatFactors>
</li>
</value>
</li>

<li Class="PatchOperationAddModExtension">
<xpath>Defs/ThingDef[defName="RB_WhiteBeeswax"]</xpath>
<value>
<li Class="SurvivalTools.StuffPropsTool">
<toolStatFactors>
<TreeFellingSpeed>0.35</TreeFellingSpeed>
<PlantHarvestingSpeed>0.35</PlantHarvestingSpeed>
<DiggingSpeed>0.45</DiggingSpeed>
<MiningYieldDigging>0.75</MiningYieldDigging>
<ConstructionSpeed>0.45</ConstructionSpeed>
</toolStatFactors>
</li>
</value>
</li>

<li Class="PatchOperationAddModExtension">
<xpath>Defs/ThingDef[defName="RB_BlackBeeswax"]</xpath>
<value>
<li Class="SurvivalTools.StuffPropsTool">
<toolStatFactors>
<TreeFellingSpeed>0.3</TreeFellingSpeed>
<PlantHarvestingSpeed>0.3</PlantHarvestingSpeed>
<DiggingSpeed>0.4</DiggingSpeed>
<MiningYieldDigging>0.7</MiningYieldDigging>
<ConstructionSpeed>0.4</ConstructionSpeed>
</toolStatFactors>
</li>
</value>
</li>

</operations>
</match>
</Operation>

</Patch>
Binary file modified Source/SurvivalTools/.vs/SurvivalTools/v15/.suo
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
76 changes: 18 additions & 58 deletions Source/SurvivalTools/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,70 +119,32 @@ static HarmonyPatches()
#region Modded JobDrivers

#region Fluffy Breakdowns
try
Type maintenanceDriver = GenTypes.GetTypeInAnyAssembly("Fluffy_Breakdowns.JobDriver_Maintenance");
if (maintenanceDriver != null && typeof(JobDriver).IsAssignableFrom(maintenanceDriver))
{
((Action)(() =>
{
if (ModCompatibilityCheck.FluffyBreakdowns)
{
Log.Message("Survival Tools :: Fluffy Breakdowns detected as active in load order. Patching...");

h.Patch(typeof(Fluffy_Breakdowns.JobDriver_Maintenance).GetNestedTypes(BindingFlags.NonPublic | BindingFlags.Instance).
MinBy(x => x.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Count()).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
.MaxBy(mi => mi.GetMethodBody()?.GetILAsByteArray().Length ?? -1),
transpiler: new HarmonyMethod(patchType, nameof(Transpile_JobDriver_Maintenance_MakeNewToils)));

}
}))();
}
catch (TypeLoadException)
{
Log.Message("Survival Tools :: Fluffy Breakdowns not detected as active in load order.");
Log.Message("Survival Tools :: Fluffy Breakdowns detected as active in load order. Patching...");
h.Patch(maintenanceDriver.GetNestedTypes(BindingFlags.NonPublic | BindingFlags.Instance).MinBy(x => x.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Count())
.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).MaxBy(mi => mi.GetMethodBody()?.GetILAsByteArray().Length ?? -1),
transpiler: new HarmonyMethod(patchType, nameof(Transpile_JobDriver_Maintenance_MakeNewToils)));
}
#endregion

#region Quarry
try
{
((Action)(() =>
{
if (ModCompatibilityCheck.Quarry)
{
Log.Message("Survival Tools :: Quarry detected as active in load order. Patching...");

h.Patch(AccessTools.Method(typeof(Quarry.JobDriver_MineQuarry), "Mine"),
postfix: new HarmonyMethod(patchType, nameof(Postfix_JobDriver_MineQuarry_Mine)));

h.Patch(AccessTools.Method(typeof(Quarry.JobDriver_MineQuarry), "ResetTicksToPickHit"),
transpiler: new HarmonyMethod(patchType, nameof(Transpile_JobDriver_MineQuarry_ResetTicksToPickHit)));

}
}))();
}
catch (TypeLoadException)
Type quarryDriver = GenTypes.GetTypeInAnyAssembly("Quarry.JobDriver_MineQuarry");
if (quarryDriver != null && typeof(JobDriver).IsAssignableFrom(quarryDriver))
{
Log.Message("Survival Tools :: Quarry not detected as active in load order.");
Log.Message("Survival Tools :: Quarry detected as active in load order. Patching...");
h.Patch(AccessTools.Method(quarryDriver, "Mine"), postfix: new HarmonyMethod(patchType, nameof(Postfix_JobDriver_MineQuarry_Mine)));
h.Patch(AccessTools.Method(quarryDriver, "ResetTicksToPickHit"), transpiler: new HarmonyMethod(patchType, nameof(Transpile_JobDriver_MineQuarry_ResetTicksToPickHit)));
}
#endregion

#region Turret Extensions
try
Type turretExtensionsDriver = GenTypes.GetTypeInAnyAssembly("TurretExtensions.JobDriver_UpgradeTurret");
if (turretExtensionsDriver != null && typeof(JobDriver).IsAssignableFrom(turretExtensionsDriver))
{
((Action)(() =>
{
if (ModCompatibilityCheck.TurretExtensions)
{
Log.Message("Survival Tools :: Turret Extensions detected as active in load order. Patching...");

h.Patch(AccessTools.Method(typeof(TurretExtensions.JobDriver_UpgradeTurret), "Upgrade"),
postfix: new HarmonyMethod(patchType, nameof(Postfix_JobDriver_UpgradeTurret_Upgrade)));

}
}))();
}
catch (TypeLoadException)
{
Log.Message("Survival Tools :: Turret Extensions not detected as active in load order.");
Log.Message("Survival Tools :: Turret Extensions detected as active in load order. Patching...");
h.Patch(AccessTools.Method(turretExtensionsDriver, "Upgrade"), postfix: new HarmonyMethod(patchType, nameof(Postfix_JobDriver_UpgradeTurret_Upgrade)));
}
#endregion

Expand Down Expand Up @@ -271,8 +233,7 @@ public static void Postfix_InventoryTrackerTickRare(Pawn_InventoryTracker __inst
if (SurvivalToolsSettings.toolLimit)
{
Pawn pawn = __instance.pawn;
if (pawn.CanUseSurvivalTools() && pawn.GetHeldSurvivalTools().Count() > pawn.GetStatValue(ST_StatDefOf.SurvivalToolCarryCapacity) && !pawn.Drafted &&
!pawn.IsFormingCaravan() && !pawn.IsCaravanMember() && pawn.CurJobDef?.casualInterruptible != false && !pawn.IsBurning() && !(pawn.carryTracker?.CarriedThing is SurvivalTool))
if (pawn.CanUseSurvivalTools() && pawn.GetHeldSurvivalTools().Count() > pawn.GetStatValue(ST_StatDefOf.SurvivalToolCarryCapacity) && pawn.CanRemoveExcessSurvivalTools())
{
Thing tool = pawn.GetHeldSurvivalTools().Last();
Job job = pawn.DequipAndTryStoreSurvivalTool(tool);
Expand Down Expand Up @@ -391,7 +352,6 @@ public static void Postfix_SetFromPreset(ThingFilter __instance, StorageSettings
}
#endregion


#region Postfix_TakeToInventory
public static void Postfix_TakeToInventory(Toil __result, TargetIndex ind)
{
Expand Down Expand Up @@ -677,7 +637,7 @@ public static IEnumerable<CodeInstruction> Transpile_JobDriver_MineQuarry_ResetT
}
}

public static void Postfix_JobDriver_MineQuarry_Mine(Quarry.JobDriver_MineQuarry __instance, Toil __result)
public static void Postfix_JobDriver_MineQuarry_Mine(JobDriver __instance, Toil __result)
{
Action tickAction = __result.tickAction;
Pawn pawn = __instance.pawn;
Expand All @@ -691,7 +651,7 @@ public static void Postfix_JobDriver_MineQuarry_Mine(Quarry.JobDriver_MineQuarry
#endregion

#region Postfix_JobDriver_UpgradeTurret_Upgrade
public static void Postfix_JobDriver_UpgradeTurret_Upgrade(TurretExtensions.JobDriver_UpgradeTurret __instance, Toil __result)
public static void Postfix_JobDriver_UpgradeTurret_Upgrade(JobDriver __instance, Toil __result)
{
Action tickAction = __result.tickAction;
Pawn pawn = __instance.pawn;
Expand Down
4 changes: 1 addition & 3 deletions Source/SurvivalTools/ModCompatibilityCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public static class ModCompatibilityCheck
public static bool MendAndRecycle => ModsConfig.ActiveModsInLoadOrder.Any(m => m.Name == "MendAndRecycle");
public static bool OtherInventoryModsActive => CombatExtended || PickUpAndHaul;

public static bool FluffyBreakdowns => ModsConfig.ActiveModsInLoadOrder.Any(m => m.Name == "Fluffy Breakdowns");
public static bool Quarry => ModsConfig.ActiveModsInLoadOrder.Any(m => m.Name == "Quarry");
public static bool TurretExtensions => ModsConfig.ActiveModsInLoadOrder.Any(m => m.Name == "[XND] Turret Extensions");
public static bool DubsBadHygiene => ModsConfig.ActiveModsInLoadOrder.Any(m => m.Name == "Dubs Bad Hygiene");

}
}
4 changes: 2 additions & 2 deletions Source/SurvivalTools/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 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.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyVersion("1.1.3.0")]
[assembly: AssemblyFileVersion("1.1.3.0")]
12 changes: 12 additions & 0 deletions Source/SurvivalTools/SurvivalToolUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,17 @@ public static Job DequipAndTryStoreSurvivalTool(this Pawn pawn, Thing tool, bool
return new Job(ST_JobDefOf.DropSurvivalTool, tool);
}

public static bool CanRemoveExcessSurvivalTools(this Pawn pawn) =>
!pawn.Drafted && !pawn.IsWashing() && !pawn.IsFormingCaravan() && !pawn.IsCaravanMember() && pawn.CurJobDef?.casualInterruptible != false
&& !pawn.IsBurning() && !(pawn.carryTracker?.CarriedThing is SurvivalTool);

private static bool IsWashing(this Pawn pawn)
{
if (!ModCompatibilityCheck.DubsBadHygiene)
return false;
Log.Message(pawn.CurJobDef.ToStringSafe());
return pawn.health.hediffSet.HasHediff(DefDatabase<HediffDef>.GetNamed("Washing"));
}

}
}
12 changes: 0 additions & 12 deletions Source/SurvivalTools/SurvivalTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,12 @@
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Fluffy_Breakdowns">
<HintPath>references\Fluffy_Breakdowns.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Quarry">
<HintPath>references\Quarry.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" />
<Reference Include="TurretExtensions">
<HintPath>references\TurretExtensions.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
672d9854360edc6ccf4816143ea6ef7adcda233a
6d844cf5582bcd50986797db4c0e10c4b954850f
Binary file not shown.
Binary file modified Source/SurvivalTools/obj/Debug/SurvivalTools.dll
Binary file not shown.
Binary file not shown.
Binary file removed Source/SurvivalTools/references/Quarry.dll
Binary file not shown.
Binary file removed Source/SurvivalTools/references/TurretExtensions.dll
Binary file not shown.

0 comments on commit 03657e8

Please sign in to comment.