Skip to content

Commit e4d8728

Browse files
committed
Added a couple config options
1 parent b29bf0e commit e4d8728

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

LethalCompanyTemplate/Patches.cs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ namespace Poltergeist
1414
[HarmonyPatch]
1515
public static class Patches
1616
{
17+
//Config things
18+
public static bool runBarebones = false;
19+
20+
//Other fields
1721
public static GrabbableObject ignoreObj = null;
1822

1923
/////////////////////////////// Needed to suppress certain base-game systems ///////////////////////////////
@@ -25,7 +29,7 @@ public static class Patches
2529
[HarmonyPatch(typeof(StartOfRound), nameof(StartOfRound.SetSpectateCameraToGameOverMode))]
2630
public static bool PreventSpectateFollow()
2731
{
28-
return false;
32+
return runBarebones;
2933
}
3034

3135
/**
@@ -37,7 +41,8 @@ public static bool PreventSpectateFollow()
3741
[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
3842
public static void OverrideSpectateCam(PlayerControllerB __instance)
3943
{
40-
__instance.playersManager.overrideSpectateCamera = true;
44+
if (!runBarebones)
45+
__instance.playersManager.overrideSpectateCamera = true;
4146
}
4247

4348
/**
@@ -70,6 +75,10 @@ public static bool SuppressDuplicateHonk(GrabbableObject __instance) {
7075
[HarmonyPatch(typeof(StartOfRound), nameof(StartOfRound.SwitchCamera))]
7176
public static void ManageCameraController(StartOfRound __instance, Camera newCamera)
7277
{
78+
//Cancel if in barebones mode
79+
if (runBarebones)
80+
return;
81+
7382
if (newCamera == __instance.spectateCamera)
7483
SpectatorCamController.instance.EnableCam();
7584
else
@@ -85,6 +94,10 @@ public static void ManageCameraController(StartOfRound __instance, Camera newCam
8594
[HarmonyPatch(typeof(StartOfRound), "Awake")]
8695
public static void MakeCamController(StartOfRound __instance)
8796
{
97+
//Cancel if in barebones mode
98+
if (runBarebones)
99+
return;
100+
88101
__instance.spectateCamera.gameObject.AddComponent<SpectatorCamController>();
89102
}
90103

@@ -99,8 +112,12 @@ public static void MakeCamController(StartOfRound __instance)
99112
[HarmonyPatch(typeof(InteractTrigger), "Start")]
100113
public static void AddGhostInteractor(InteractTrigger __instance)
101114
{
115+
//Cancel if in barebones mode
116+
if (runBarebones)
117+
return;
118+
102119
//If it's a door, add the interactible
103-
if(__instance.gameObject.GetComponent<DoorLock>() != null)
120+
if (__instance.gameObject.GetComponent<DoorLock>() != null)
104121
__instance.gameObject.AddComponent<GhostInteractible>();
105122

106123
//If it's the lightswitch, add one there too
@@ -117,7 +134,11 @@ public static void AddGhostInteractor(InteractTrigger __instance)
117134
[HarmonyPatch(typeof(NoisemakerProp), "Start")]
118135
public static void AddInteractorForHorns(NoisemakerProp __instance)
119136
{
120-
if(__instance.name.Contains("Airhorn") || __instance.name.Contains("Clownhorn"))
137+
//Cancel if in barebones mode
138+
if (runBarebones)
139+
return;
140+
141+
if (__instance.name.Contains("Airhorn") || __instance.name.Contains("Clownhorn"))
121142
{
122143
__instance.gameObject.AddComponent<GhostInteractible>();
123144
}
@@ -132,6 +153,10 @@ public static void AddInteractorForHorns(NoisemakerProp __instance)
132153
[HarmonyPatch(typeof(BoomboxItem), "Start")]
133154
public static void AddInteractorForBoombox(BoomboxItem __instance)
134155
{
156+
//Cancel if in barebones mode
157+
if (runBarebones)
158+
return;
159+
135160
__instance.gameObject.AddComponent<GhostInteractible>();
136161
}
137162

@@ -233,6 +258,7 @@ public static IEnumerable<CodeInstruction> AllowGroundHearing(IEnumerable<CodeIn
233258
return code;
234259
}
235260

261+
/*
236262
[HarmonyPostfix]
237263
[HarmonyPatch(typeof(GrabbableObject), "UseItemOnClient")]
238264
public static void PrintClientUse()
@@ -253,5 +279,6 @@ public static void PrintClientRpc()
253279
{
254280
Poltergeist.DebugLog("Client Rpc called for object");
255281
}
282+
*/
256283
}
257284
}

LethalCompanyTemplate/Poltergeist.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,22 @@ private void Awake()
1313
{
1414
instance = this;
1515

16+
//Handle the config
17+
Patches.runBarebones = Config.Bind<bool>("General",
18+
"RunBarebones",
19+
false,
20+
"If true, most mod functionality will be disabled, preserving the vanilla spectate behavior.\n" +
21+
"(Good for those who want to spectate normally, but don't want things to break if others are using the mod)").Value;
22+
SpectatorCamController.lightIntensity = Config.Bind<float>("General",
23+
"GhostLightIntensity",
24+
5,
25+
"The intensity of the global light when dead.\n" +
26+
"WARNING: This game has a lot of fog, so excessively high values can decrease visibility.").Value;
27+
1628
//Make the patches
1729
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
1830

19-
// Plugin startup logic
31+
// All done!
2032
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
2133
}
2234

LethalCompanyTemplate/SpectatorCamController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ namespace Poltergeist
1212
{
1313
public class SpectatorCamController : MonoBehaviour
1414
{
15+
//Config things
16+
public static float lightIntensity = 5;
17+
18+
//Other fields
1519
public static SpectatorCamController instance = null;
1620

1721
private float camMoveSpeed = 5f;
18-
private float lightIntensity = 5;
1922
private Light light = null;
2023

2124
private PlayerControllerB clientPlayer = null;

0 commit comments

Comments
 (0)