Skip to content

Commit

Permalink
3.0 (Headlights & Compass)
Browse files Browse the repository at this point in the history
- Option to make compass constantly active
- Option to make headlights on by default
  • Loading branch information
Tribow committed Nov 18, 2022
1 parent 5ca5172 commit 8813f77
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Distance.LittleThings/ConfigLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ public bool EnableQuarantineInArcade
get { return Get<bool>("EnableQuarantineInArcade"); }
set { Set("EnableQuarantineInArcade", value); }
}

public bool EnableHeadLights
{
get { return Get<bool>("EnableHeadLights"); }
set { Set("EnableHeadLights", value); }
}

public bool ActiveCompass
{
get { return Get<bool>("ActiveCompass"); }
set { Set("ActiveCompass", value); }
}
#endregion

internal Settings Config;
Expand All @@ -36,6 +48,8 @@ public void Awake()
//Setting Defaults
Get("EnableGPSInArcade", true);
Get("EnableQuarantineInArcade", true);
Get("EnableHeadLights", false);
Get("ActiveCompass", false);
//Save settings to Config.json
Save();
}
Expand Down
3 changes: 3 additions & 0 deletions Distance.LittleThings/Distance.LittleThings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigLogic.cs" />
<Compile Include="Harmony\Assembly-CSharp\CarScreenLogic\OnEventGo.cs" />
<Compile Include="Harmony\Assembly-CSharp\CarScreenLogic\UpdateBeforeRender.cs" />
<Compile Include="Harmony\Assembly-CSharp\GPSTrigger\Start.cs" />
<Compile Include="Harmony\Assembly-CSharp\LocalPlayerControlledCar\CheckInput.cs" />
<Compile Include="Harmony\Assembly-CSharp\LocalPlayerControlledCar\Start.cs" />
<Compile Include="Harmony\Assembly-CSharp\QuarantineTrigger\Start.cs" />
<Compile Include="Mod.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using HarmonyLib;

namespace Distance.LittleThings.Harmony
{
[HarmonyPatch(typeof(CarScreenLogic), "OnEventGo")]
internal class CarScreenLogic__OnEventGo
{
[HarmonyPrefix]
internal static bool DisablePlacementText(CarScreenLogic __instance)
{
if (Mod.Instance.Config.ActiveCompass)
{
//Literally just skip the method if active compass is on
__instance.ModeWidgetVisible_ = true;
return false;
}
else
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using HarmonyLib;

namespace Distance.LittleThings.Harmony
{
[HarmonyPatch(typeof(CarScreenLogic), "UpdateBeforeRender")]
internal class CarScreenLogic__UpdateBeforeRender
{
[HarmonyPostfix]
internal static void KeepCompassActive(CarScreenLogic __instance)
{
if(Mod.Instance.Config.ActiveCompass)
{
__instance.SetCurrentModeVisual(__instance.compass_);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Distance.LittleThings.Harmony
{
[HarmonyPatch(typeof(LocalPlayerControlledCar), "CheckInput")]
internal class CheckInput
internal class LocalPlayerControlledCar__CheckInput
{
[HarmonyPrefix]
internal static bool GPSCheck(LocalPlayerControlledCar __instance, InputStates inputStates, float dt)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using HarmonyLib;

namespace Distance.LittleThings.Harmony
{
[HarmonyPatch(typeof(LocalPlayerControlledCar), "Start")]
internal class LocalPlayerControlledCar__Start
{
[HarmonyPostfix]
internal static void HeadlightsCheck(LocalPlayerControlledCar __instance)
{
if (Mod.Instance.Config.EnableHeadLights)
{
//Hardcoded cause I'm cringe. Didn't feel like building menu values to manipulate
__instance.carLogic_.carVisuals_.SetHeadlightsValues(1f, 100f, 150f, .5f, false);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Distance.LittleThings.Harmony
{
[HarmonyPatch(typeof(QuarantineTrigger), "Start")]
internal class Start
internal class QuarantineTrigger__Start
{
[HarmonyPrefix]
internal static bool StartRewrite(QuarantineTrigger __instance)
Expand Down
10 changes: 10 additions & 0 deletions Distance.LittleThings/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ private void CreateSettingsMenu()
.WithGetter(() => Config.EnableQuarantineInArcade)
.WithSetter((x) => Config.EnableQuarantineInArcade = x)
.WithDescription("Toggles whether Quarantine zones will activate in arcade mode"),

new CheckBox(MenuDisplayMode.Both, "settings::headlights_enable", "ENABLE HEADLIGHTS")
.WithGetter(() => Config.EnableHeadLights)
.WithSetter((x) => Config.EnableHeadLights = x)
.WithDescription("Toggles whether head lights are always active on the car, just like the Beta days!"),

new CheckBox(MenuDisplayMode.Both, "settings::active_compass", "PERMANENT COMPASS")
.WithGetter(() => Config.ActiveCompass)
.WithSetter((x) => Config.ActiveCompass = x)
.WithDescription("The compass will always stay active on the carscreen and never change"),
};

Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "LITTLE THINGS", "Settings for the LittleThings mod");
Expand Down

0 comments on commit 8813f77

Please sign in to comment.