-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Changed preview image. - Fixed users not being able to force repair when right clicking a building. - Added a Repair designator: * Used to flag buildings that will not be automatically repaired due to the current Repair Threshold setting. * Flagged buildings will ignore the threshold. * The designator will be removed when the building's current HP reaches its Maximum HP. - Added a Repair keybinding to the Architect section of the keybindings menu. - Repair icon courtesy of mrofa (credits can be found in the Steam Workshop page or Ludeon forums thread). - Minor code consistency changes.
- Loading branch information
1 parent
9a7c735
commit b274d59
Showing
19 changed files
with
264 additions
and
59 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<DesignationDefs> | ||
|
||
<DesignationDef> | ||
<defName>RWP_ForcedRepair</defName> | ||
<texturePath>Designations/ForcedRepair</texturePath> | ||
<targetType>Thing</targetType> | ||
<removeIfBuildingDespawned>true</removeIfBuildingDespawned> | ||
</DesignationDef> | ||
|
||
</DesignationDefs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<KeyBindingDefs> | ||
|
||
<!-- Repair designator keybinding --> | ||
|
||
<KeyBindingDef ParentName="ArchitectBase"> | ||
<defName>DesignatorForcedRepair</defName> | ||
<label>Repair <b><color=orange>[Refactored Work Priorities]</color></b></label> | ||
<category>Architect</category> | ||
</KeyBindingDef> | ||
|
||
</KeyBindingDefs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Patch> | ||
|
||
<Operation Class="PatchOperationAdd"> | ||
<xpath>/Defs/DesignationCategoryDef[defName = "Orders"]/specialDesignatorClasses</xpath> | ||
<value> | ||
<li>RWP.Designator_ForcedRepair</li> | ||
</value> | ||
</Operation> | ||
|
||
</Patch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Patch> | ||
|
||
<!-- Replace Repair driverClass --> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/Defs/JobDef[defName = "Repair"]/driverClass</xpath> | ||
<value> | ||
<driverClass>RWP.JobDriver_RepairCustom</driverClass> | ||
</value> | ||
</Operation> | ||
|
||
</Patch> |
88 changes: 44 additions & 44 deletions
88
Patches/WorkGivers.xml → Patches/WorkGiverDefs/WorkGivers.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Patch> | ||
|
||
<!-- Remove feeding sick animals from doctors, given to handlers --> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/WorkGivers/WorkGiverDef[defName = "DoctorFeedAnimals"]/workType</xpath> | ||
<value> | ||
<workType>Handling</workType> | ||
</value> | ||
</Operation> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/WorkGivers/WorkGiverDef[defName = "DoctorFeedAnimals"]/priorityInType</xpath> | ||
<value> | ||
<priorityInType>110</priorityInType> | ||
</value> | ||
</Operation> | ||
|
||
<!-- Replace Repair giverClass --> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/WorkGivers/WorkGiverDef[defName = "Repair"]/giverClass</xpath> | ||
<value> | ||
<giverClass>RWP.WorkGiver_RepairCustom</giverClass> | ||
</value> | ||
</Operation> | ||
|
||
<!-- Prioritise roof removal over building roofs --> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/WorkGivers/WorkGiverDef[defName = "RemoveRoofs"]/priorityInType</xpath> | ||
<value> | ||
<priorityInType>70</priorityInType> | ||
</value> | ||
</Operation> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/WorkGivers/WorkGiverDef[defName = "BuildRoofs"]/priorityInType</xpath> | ||
<value> | ||
<priorityInType>60</priorityInType> | ||
</value> | ||
</Operation> | ||
|
||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Patch> | ||
|
||
<!-- Remove feeding sick animals from doctors, given to handlers --> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/WorkGivers/WorkGiverDef[defName = "DoctorFeedAnimals"]/workType</xpath> | ||
<value> | ||
<workType>Handling</workType> | ||
</value> | ||
</Operation> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/WorkGivers/WorkGiverDef[defName = "DoctorFeedAnimals"]/priorityInType</xpath> | ||
<value> | ||
<priorityInType>110</priorityInType> | ||
</value> | ||
</Operation> | ||
|
||
<!-- Replace Repair giverClass --> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/WorkGivers/WorkGiverDef[defName = "Repair"]/giverClass</xpath> | ||
<value> | ||
<giverClass>RWP.WorkGiver_RepairCustom</giverClass> | ||
</value> | ||
</Operation> | ||
|
||
<!-- Prioritise roof removal over building roofs --> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/WorkGivers/WorkGiverDef[defName = "RemoveRoofs"]/priorityInType</xpath> | ||
<value> | ||
<priorityInType>70</priorityInType> | ||
</value> | ||
</Operation> | ||
|
||
<Operation Class="PatchOperationReplace"> | ||
<xpath>/WorkGivers/WorkGiverDef[defName = "BuildRoofs"]/priorityInType</xpath> | ||
<value> | ||
<priorityInType>60</priorityInType> | ||
</value> | ||
</Operation> | ||
|
||
</Patch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using System.Linq; | ||
using RimWorld; | ||
using UnityEngine; | ||
using Verse; | ||
|
||
namespace RWP | ||
{ | ||
public class Designator_ForcedRepair : Designator | ||
{ | ||
public Designator_ForcedRepair() | ||
{ | ||
this.defaultLabel = "Designator_ForcedRepair".Translate(); | ||
this.defaultDesc = "Designator_ForcedRepairDesc".Translate(); | ||
this.icon = ContentFinder<Texture2D>.Get("Designations/ForcedRepair", true); | ||
this.soundDragSustain = SoundDefOf.DesignateDragStandard; | ||
this.soundDragChanged = SoundDefOf.DesignateDragStandardChanged; | ||
this.useMouseIcon = true; | ||
this.soundSucceeded = SoundDefOf.DesignateHaul; //??? | ||
this.hotKey = KeyBindingDef.Named("DesignatorForcedRepair"); | ||
} | ||
|
||
public override AcceptanceReport CanDesignateCell(IntVec3 c) | ||
{ | ||
if (!c.InBounds(base.Map)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (c.Fogged(base.Map)) | ||
{ | ||
return false; | ||
} | ||
|
||
var thingList = base.Map.thingGrid.ThingsAt(c); | ||
|
||
if (!(thingList.Any(t => CanDesignateThing(t).Accepted))) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public override void DesignateSingleCell(IntVec3 loc) | ||
{ | ||
foreach (Thing building in base.Map.thingGrid.ThingsAt(loc)) | ||
{ | ||
if (this.CanDesignateThing(building).Accepted) | ||
{ | ||
this.DesignateThing(building); | ||
} | ||
} | ||
} | ||
|
||
public override void DesignateThing(Thing t) | ||
{ | ||
base.Map.designationManager.AddDesignation(new Designation(t, Controller.DefOf_RWP_ForcedRepair)); | ||
} | ||
|
||
public override AcceptanceReport CanDesignateThing(Thing t) | ||
{ | ||
if (!(base.Map.listerBuildingsRepairable.RepairableBuildings(Faction.OfPlayer).Contains(t))) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!(t.HitPoints < t.MaxHitPoints)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (base.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null) | ||
{ | ||
return false; | ||
} | ||
|
||
if (base.Map.designationManager.DesignationOn(t, DesignationDefOf.Uninstall) != null) | ||
{ | ||
return false; | ||
} | ||
|
||
if (base.Map.designationManager.DesignationOn(t, Controller.DefOf_RWP_ForcedRepair) != null) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public override int DraggableDimensions | ||
{ | ||
get | ||
{ | ||
return 2; | ||
} | ||
} | ||
|
||
public override void SelectedUpdate() | ||
{ | ||
GenUI.RenderMouseoverBracket(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using RimWorld; | ||
using Verse; | ||
using Verse.AI; | ||
|
||
namespace RWP | ||
{ | ||
public class JobDriver_RepairCustom : JobDriver_Repair | ||
{ | ||
[DebuggerHidden] | ||
protected override IEnumerable<Toil> MakeNewToils() | ||
{ | ||
/* The final "repair" Toil ends the current job after it's done. | ||
This means that we have to somehow intervene with our designator removal. | ||
To do this we add a designator removal action to the cleanup FinishActions list. */ | ||
|
||
Action RemoveRepairDesignator = delegate | ||
{ | ||
Pawn pawn = this.GetActor(); | ||
Job job = pawn.jobs.curJob; | ||
|
||
if (job.targetA.Thing.HitPoints == job.targetA.Thing.MaxHitPoints) | ||
{ | ||
pawn.Map.designationManager.RemoveAllDesignationsOn(job.targetA.Thing, false); | ||
} | ||
}; | ||
|
||
this.AddFinishAction(RemoveRepairDesignator); | ||
|
||
foreach (Toil toil in base.MakeNewToils()) | ||
{ | ||
yield return toil; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
using RimWorld; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using RimWorld; | ||
using Verse; | ||
|
||
namespace RWP | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
using RimWorld; | ||
using System.Collections.Generic; | ||
using RimWorld; | ||
using Verse; | ||
|
||
namespace RWP | ||
|
Oops, something went wrong.