-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
168 additions
and
21 deletions.
There are no files selected for viewing
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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<Manifest> | ||
<version>1.1.0</version> | ||
<manifestUri>https://raw.githubusercontent.com/Toby222/ClaimDoors/About/Manifest.xml</manifestUri> | ||
<downloadUri>https://github.com/Toby222/ClaimDoors/releases/v1.1.0</downloadUri> | ||
</Manifest> |
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Patch> | ||
<Operation Class="PatchOperationAdd"> | ||
<xpath>/Defs/DesignationCategoryDef[defName="Orders"]/specialDesignatorClasses</xpath> | ||
<value> | ||
<li>ClaimDoors.Designator_RemoveFog</li> | ||
<li>ClaimDoors.Designator_AddFog</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
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,39 @@ | ||
using HarmonyLib; | ||
using Verse; | ||
|
||
namespace ClaimDoors | ||
{ | ||
internal class ClaimDoorsMod : Mod | ||
{ | ||
public ClaimDoorsMod(ModContentPack content) : base(content) | ||
{ | ||
GetSettings<ClaimDoorsSettings>(); | ||
new Harmony("tobs.claimdoors.mod").PatchAll(); | ||
} | ||
|
||
public override string SettingsCategory() => "Claim Doors"; | ||
|
||
public override void DoSettingsWindowContents(UnityEngine.Rect inRect) | ||
{ | ||
Listing_Standard listingStandard = new Listing_Standard(); | ||
listingStandard.Begin(inRect); | ||
listingStandard.CheckboxLabeled("Enable Fog Tools", ref ClaimDoorsSettings.enableFogTool); | ||
listingStandard.End(); | ||
base.DoSettingsWindowContents(inRect); | ||
} | ||
} | ||
|
||
internal class ClaimDoorsSettings : ModSettings | ||
{ | ||
public static bool enableFogTool = true; | ||
|
||
/// <summary> | ||
/// The part that writes our settings to file. Note that saving is by ref. | ||
/// </summary> | ||
public override void ExposeData() | ||
{ | ||
Scribe_Values.Look(ref enableFogTool, nameof(enableFogTool)); | ||
base.ExposeData(); | ||
} | ||
} | ||
} |
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,16 @@ | ||
using RimWorld; | ||
using UnityEngine; | ||
using Verse; | ||
|
||
namespace ClaimDoors | ||
{ | ||
public class Designator_AddFog : Designator_Fog | ||
{ | ||
public Designator_AddFog() : base(DesignateMode.Add) | ||
{ | ||
defaultLabel = "Fog Map"; | ||
defaultDesc = "Cover the map with fog of war."; | ||
icon = ContentFinder<Texture2D>.Get("UI/Designators/Hide"); | ||
} | ||
} | ||
} |
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,62 @@ | ||
using HarmonyLib; | ||
using RimWorld; | ||
using Verse; | ||
|
||
namespace ClaimDoors | ||
{ | ||
public class Designator_Fog : Designator | ||
{ | ||
public override int DraggableDimensions => 2; | ||
|
||
public override AcceptanceReport CanDesignateCell(IntVec3 loc) => loc.InBounds(Map) && loc.Fogged(Map) == (mode == DesignateMode.Remove); | ||
|
||
private readonly DesignateMode mode; | ||
public override bool DragDrawMeasurements => true; | ||
public override bool Visible => ClaimDoorsSettings.enableFogTool; | ||
|
||
public Designator_Fog(DesignateMode mode) | ||
{ | ||
this.mode = mode; | ||
soundDragSustain = SoundDefOf.Designate_DragStandard; | ||
soundDragChanged = SoundDefOf.Designate_DragStandard_Changed; | ||
useMouseIcon = true; | ||
soundSucceeded = SoundDefOf.Designate_Claim; | ||
} | ||
|
||
public override void DesignateSingleCell(IntVec3 cell) | ||
{ | ||
if (CanDesignateCell(cell).Accepted) | ||
{ | ||
switch (mode) | ||
{ | ||
case DesignateMode.Add: | ||
FogWorker(cell); | ||
break; | ||
|
||
case DesignateMode.Remove: | ||
Traverse.Create(Map.fogGrid).Method("UnfogWorker", cell).GetValue(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public override void SelectedUpdate() | ||
{ | ||
GenUI.RenderMouseoverBracket(); | ||
} | ||
|
||
public override void RenderHighlight(System.Collections.Generic.List<IntVec3> dragCells) => DesignatorUtility.RenderHighlightOverSelectableCells(this, dragCells); | ||
|
||
private void FogWorker(IntVec3 c) | ||
{ | ||
Log.Message($"{c} - {Map.cellIndices.CellToIndex(c)} - {Map.fogGrid.fogGrid[Map.cellIndices.CellToIndex(c)]}"); | ||
int index = Map.cellIndices.CellToIndex(c); | ||
Map.fogGrid.fogGrid[index] = true; | ||
if (Current.ProgramState == ProgramState.Playing) | ||
{ | ||
Map.mapDrawer.MapMeshDirty(c, MapMeshFlag.Things | MapMeshFlag.FogOfWar); | ||
Map.roofGrid.Drawer.SetDirty(); | ||
} | ||
} | ||
} | ||
} |
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,16 @@ | ||
using RimWorld; | ||
using UnityEngine; | ||
using Verse; | ||
|
||
namespace ClaimDoors | ||
{ | ||
public class Designator_RemoveFog : Designator_Fog | ||
{ | ||
public Designator_RemoveFog() : base(DesignateMode.Remove) | ||
{ | ||
defaultLabel = "Unfog Map"; | ||
defaultDesc = "Remove fog of war from the map."; | ||
icon = ContentFinder<Texture2D>.Get("UI/Designators/Reveal"); | ||
} | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.