-
Notifications
You must be signed in to change notification settings - Fork 5
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
16 changed files
with
148 additions
and
13 deletions.
There are no files selected for viewing
Binary file not shown.
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
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,111 @@ | ||
using AlmostThere; | ||
using AlmostThere.Storage; | ||
using HarmonyLib; | ||
using RimWorld; | ||
using RimWorld.Planet; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UnityEngine; | ||
using Verse; | ||
|
||
namespace SearchAndDestroy.Harmony | ||
{ | ||
[HarmonyPatch(typeof(Caravan), "get_NightResting")] | ||
class Caravan_get_NightResting | ||
{ | ||
private static float nHours = 5f; | ||
static bool Prefix(Caravan __instance) | ||
{ | ||
|
||
if(Base.Instance.GetExtendedDataStorage() is ExtendedDataStorage store) | ||
{ | ||
if (store.GetExtendedDataFor(__instance) is ExtendedCaravanData data) | ||
{ | ||
if (data.fullyIgnoreRest) | ||
{ | ||
return false; | ||
} | ||
if (data.almostThere) | ||
{ | ||
var estimatedTicks = (float)CaravanArrivalTimeEstimator.EstimatedTicksToArrive(__instance, allowCaching: false); | ||
var restTicksLeft = CaravanNightRestUtility.LeftRestTicksAt(__instance.Tile, Find.TickManager.TicksAbs); | ||
estimatedTicks -= restTicksLeft; | ||
if (estimatedTicks/GenDate.TicksPerHour < Base.almostThereHours.Value) | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
|
||
} | ||
} | ||
|
||
|
||
[HarmonyPatch(typeof(Caravan), "GetGizmos")] | ||
class Caravan_GetGizmos | ||
{ | ||
static void Postfix(Caravan __instance, ref IEnumerable<Gizmo> __result) | ||
{ | ||
var gizmoList = __result.ToList(); | ||
var store = Base.Instance.GetExtendedDataStorage(); | ||
var caravanData = store.GetExtendedDataFor(__instance); | ||
if(__instance.Faction == Faction.OfPlayer) | ||
{ | ||
if(caravanData != null) | ||
{ | ||
gizmoList.Add(CreateAlmostThereCommand(__instance, caravanData)); | ||
gizmoList.Add(CreateIgnoreRestCommand(__instance, caravanData)); | ||
gizmoList.Add(CreateForceRestCommand(__instance, caravanData)); | ||
} | ||
} | ||
__result = gizmoList; | ||
} | ||
|
||
private static Command_Toggle CreateIgnoreRestCommand(Caravan __instance, ExtendedCaravanData caravanData) | ||
{ | ||
Command_Toggle command_Toggle = new Command_Toggle(); | ||
command_Toggle.isActive = (() => caravanData.fullyIgnoreRest); | ||
command_Toggle.toggleAction = delegate | ||
{ | ||
caravanData.fullyIgnoreRest = !caravanData.fullyIgnoreRest; | ||
}; | ||
command_Toggle.defaultDesc = "AT_Command_DontRest_Description".Translate(); | ||
command_Toggle.icon = ContentFinder<Texture2D>.Get(("UI/" + "DontRest"), true); | ||
command_Toggle.defaultLabel = "AT_Command_DontRest_Label".Translate(); | ||
return command_Toggle; | ||
} | ||
private static Command_Toggle CreateAlmostThereCommand(Caravan __instance, ExtendedCaravanData caravanData) | ||
{ | ||
Command_Toggle command_Toggle = new Command_Toggle(); | ||
command_Toggle.isActive = (() => caravanData.almostThere); | ||
command_Toggle.toggleAction = delegate | ||
{ | ||
caravanData.almostThere = !caravanData.almostThere; | ||
}; | ||
command_Toggle.defaultDesc = "AT_Command_AlmostThere_Description".Translate(Base.almostThereHours.Value); | ||
command_Toggle.icon = ContentFinder<Texture2D>.Get(("UI/" + "AlmostThere"), true); | ||
command_Toggle.defaultLabel = "AT_Command_AlmostThere_Label".Translate(); | ||
return command_Toggle; | ||
} | ||
|
||
private static Command_Toggle CreateForceRestCommand(Caravan __instance, ExtendedCaravanData caravanData) | ||
{ | ||
Command_Toggle command_Toggle = new Command_Toggle(); | ||
command_Toggle.isActive = (() => caravanData.almostThere); | ||
command_Toggle.toggleAction = delegate | ||
{ | ||
caravanData.forceRest = !caravanData.forceRest; | ||
}; | ||
command_Toggle.defaultDesc = "AT_Command_ForceRest_Description".Translate(); | ||
command_Toggle.icon = ContentFinder<Texture2D>.Get(("UI/" + "ForceRest"), true); | ||
command_Toggle.defaultLabel = "AT_Command_ForceRest_Title".Translate(); | ||
return command_Toggle; | ||
} | ||
} | ||
|
||
} |
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
2 changes: 1 addition & 1 deletion
2
1.2/Source/AlmostThere/obj/Debug/AlmostThere.csproj.CoreCompileInputs.cache
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 +1 @@ | ||
d9a011d753278146b3f8a10166bf4579e51d1f2e | ||
aacb1f610ca57470c6fb8901f9e12f888f37f874 |
3 changes: 2 additions & 1 deletion
3
1.2/Source/AlmostThere/obj/Debug/AlmostThere.csproj.FileListAbsolute.txt
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,3 +1,4 @@ | ||
C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\AlmostThere\1.2\Source\AlmostThere\obj\Debug\AlmostThere.csprojAssemblyReference.cache | ||
C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\AlmostThere\1.2\Source\AlmostThere\obj\Debug\AlmostThere.csproj.CoreCompileInputs.cache | ||
C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\AlmostThere\1.2\Source\AlmostThere\obj\Debug\SearchAndDestroy.dll | ||
C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\AlmostThere\1.2\Assemblies\AlmostThere.dll | ||
C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\AlmostThere\1.2\Source\AlmostThere\obj\Debug\AlmostThere.dll |
Binary file modified
BIN
-59.5 KB
(0.69%)
1.2/Source/AlmostThere/obj/Debug/AlmostThere.csprojAssemblyReference.cache
Binary file not shown.
Binary file not shown.
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" ?> | ||
<LanguageData> | ||
<AT_AlmostThereHours_Title>Almost there hours</AT_AlmostThereHours_Title> | ||
<AT_AlmostThereHours_Description>Set how many hours away a target has to be for "Almost there" to trigger.</AT_AlmostThereHours_Description> | ||
<AT_Command_DontRest_Label>Never rest</AT_Command_DontRest_Label> | ||
<AT_Command_DontRest_Description>Turning this on will prevent the caravan from ever resting. Use at your own risk!</AT_Command_DontRest_Description> | ||
<AT_Command_AlmostThere_Label>Almost there!</AT_Command_AlmostThere_Label> | ||
<AT_Command_AlmostThere_Description>Cmon guys, we're almost there! With this enabled, your caravan won't rest when {0} hours away from its target.</AT_Command_AlmostThere_Description> | ||
<AT_Command_ForceRest_Title>Force rest</AT_Command_ForceRest_Title> | ||
<AT_Command_ForceRest_Description>Turning this on will force the caravan to rest. Turn it off to let them stop resting again.</AT_Command_ForceRest_Description> | ||
</LanguageData> |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.