Skip to content

Commit

Permalink
Repair Expansion
Browse files Browse the repository at this point in the history
Users may now set a custom value in the menu for repair threshold. If
the building's HP as a percentage is above this threshold, pawns will
not repair it.

E.g. wooden wall with 100/140 HP has ~71% HP and will only be repaired
if the threshold is >71.
  • Loading branch information
DingoDjango committed Dec 22, 2016
1 parent 17ac709 commit 65b3a0b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 4 deletions.
Binary file modified Assemblies/RefactoredWorkPriorities.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Defs/WorkGiverDefs/WorkGivers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<WorkGiverDef>
<defName>Repair</defName>
<label>repair damaged things</label>
<giverClass>WorkGiver_Repair</giverClass>
<giverClass>RWP.WorkGiver_RepairCustom</giverClass>
<workType>Repair</workType>
<priorityInType>50</priorityInType>
<verb>repair</verb>
Expand Down
3 changes: 3 additions & 0 deletions Languages/ChineseSimplified/Keyed/ChineseSimplified.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<RWP_setting_doctorTreatColonist_label>&lt;b&gt;[医生]&lt;/b&gt; 优先治疗居民</RWP_setting_doctorTreatColonist_label>
<RWP_setting_doctorTreatColonist_desc>医生会优先治疗居民然后是动物或者外来者。</RWP_setting_doctorTreatColonist_desc>

<RWP_setting_repairThresholdInt_label>&lt;b&gt;[Repair]&lt;/b&gt; Repair threshold percentage</RWP_setting_repairThresholdInt_label>
<RWP_setting_repairThresholdInt_desc>Determines the hit-points percentage for colonists to start repairing damaged things. Colonists will not repair things with HP above this percentage.</RWP_setting_repairThresholdInt_desc>

<RWP_setting_haulRottables_label>&lt;b&gt;[搬运工]&lt;/b&gt; 优先搬运易腐烂的物品</RWP_setting_haulRottables_label>
<RWP_setting_haulRottables_desc>搬运工会优先搬运易腐烂的物品(如玉米,食物,等等)然后是一般物品。</RWP_setting_haulRottables_desc>

Expand Down
3 changes: 3 additions & 0 deletions Languages/English/Keyed/English.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<RWP_setting_doctorTreatColonist_label>&lt;b&gt;[Doctor]&lt;/b&gt; Prioritise treating colonists</RWP_setting_doctorTreatColonist_label>
<RWP_setting_doctorTreatColonist_desc>Doctors will treat colonist injuries before treating animals or outsiders.</RWP_setting_doctorTreatColonist_desc>

<RWP_setting_repairThresholdInt_label>&lt;b&gt;[Repair]&lt;/b&gt; Repair threshold percentage</RWP_setting_repairThresholdInt_label>
<RWP_setting_repairThresholdInt_desc>Determines the hit-points percentage for colonists to start repairing damaged things. Colonists will not repair things with HP above this percentage.</RWP_setting_repairThresholdInt_desc>

<RWP_setting_haulRottables_label>&lt;b&gt;[Haul]&lt;/b&gt; Prioritise hauling rottables</RWP_setting_haulRottables_label>
<RWP_setting_haulRottables_desc>Haulers will haul rottable items (corn, meals etc.) before generic things.</RWP_setting_haulRottables_desc>

Expand Down
4 changes: 2 additions & 2 deletions Source/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("2.16.0.0")]
[assembly: AssemblyFileVersion("2.16.0.0")]
[assembly: AssemblyVersion("2.2.16.0")]
[assembly: AssemblyFileVersion("2.2.16.0")]
4 changes: 4 additions & 0 deletions Source/RWPMenu.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HugsLib;
using HugsLib.Settings;
using Verse;

namespace RWP
Expand Down Expand Up @@ -28,6 +29,9 @@ private void RWPDefs()
var prioritizeTreatingColonists = Settings.GetHandle<bool>("RWP_Doctor_PrioritizeTreatingColonists", "RWP_setting_doctorTreatColonist_label".Translate(), "RWP_setting_doctorTreatColonist_desc".Translate(), true);
WorkGiver_TendPrioritized.TendColonistsFirst = prioritizeTreatingColonists.Value;

var repairThresholdInt = Settings.GetHandle<int>("RWP_Repair_RepairThresholdInt", "RWP_setting_repairThresholdInt_label".Translate(), "RWP_setting_repairThresholdInt_desc".Translate(), 100, Validators.IntRangeValidator(0, 100));
WorkGiver_RepairCustom.RepairThreshold = repairThresholdInt.Value;

var haulRottables = Settings.GetHandle<bool>("HaulRottables", "RWP_setting_haulRottables_label".Translate(), "RWP_setting_haulRottables_desc".Translate(), true);
WorkGiver_HaulRottable.PrioritizeRottable = haulRottables.Value;

Expand Down
3 changes: 2 additions & 1 deletion Source/RefactoredWorkPriorities.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectGuid>{49AC7432-C172-4858-80B3-90BFBEB87E15}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RefactoredWorkPriorities</RootNamespace>
<RootNamespace>RWP</RootNamespace>
<AssemblyName>RefactoredWorkPriorities</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -51,6 +51,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="WorkGiver_RepairCustom.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RWPMenu.cs" />
<Compile Include="WorkGiver_HaulDeteriorating.cs" />
Expand Down
17 changes: 17 additions & 0 deletions Source/WorkGiver_RepairCustom.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using RimWorld;
using Verse;

namespace RWP
{
public class WorkGiver_RepairCustom : WorkGiver_Repair
{
public static int RepairThreshold = 100;

public override bool HasJobOnThing(Pawn pawn, Thing t)
{
int hitPointPercentage = 100 * t.HitPoints / t.MaxHitPoints;

return base.HasJobOnThing(pawn, t) && hitPointPercentage < RepairThreshold;
}
}
}

0 comments on commit 65b3a0b

Please sign in to comment.