Skip to content

Commit 8e61489

Browse files
committed
Added option to disable spectating others
1 parent 4317338 commit 8e61489

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Mod for the game PEAK that enables passed out scouts to talk at a reduced volume
44

55
You can configure the amount of volume reduction and duration of quiet time in the configuration file.
66

7+
You can also disable spectating others while passed out in the configuration file (`AllowSpectate`). You will still spectate yourself while down, but will be unable to switch to other players.
8+
79
Created using the BepInEx Template for PEAK (https://github.com/PEAKModding/BepInExTemplate)
810

911
Thunderstore: https://thunderstore.io/c/peak/p/Lokno/PEAKSleepTalk/

src/PEAKSleepTalk/ConfigurationManager.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ public class ConfigurationManager
1010
private static ConfigEntry<float> _configReductionFactor = null!;
1111
private static ConfigEntry<bool> _configEnableQuietTime = null!;
1212
private static ConfigEntry<float> _configQuietTime = null!;
13+
private static ConfigEntry<bool> _configAllowSpectate = null!;
1314

1415
public static bool ReduceVolume => _configEnableReduceVolume.Value;
1516
public static float VolumeReductionFactor => Math.Clamp(_configReductionFactor.Value, 0.0f, 1.0f);
1617
public static bool EnableQuietTime => _configEnableQuietTime.Value;
1718
public static float QuietTimeDuration => _configQuietTime.Value;
19+
public static bool AllowSpectate => _configAllowSpectate.Value;
1820

1921
public static void LoadConfig(BaseUnityPlugin plugin)
2022
{
@@ -49,6 +51,14 @@ public static void LoadConfig(BaseUnityPlugin plugin)
4951
8.0f,
5052
"The time in seconds before unconscious players can speak again"
5153
);
54+
55+
_configAllowSpectate = plugin.Config.Bind<bool>
56+
(
57+
"General",
58+
"AllowSpectate",
59+
true,
60+
"Allow unconscious players to spectate others"
61+
);
5262
}
5363
}
5464
}

src/PEAKSleepTalk/EnableSleepTalkPatch.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,24 @@ private static void Postfix(CharacterVoiceHandler __instance, StoreData __state)
118118
__instance.audioLevel = __state.audioLevel;
119119
}
120120
}
121+
122+
[HarmonyPatch(typeof(MainCameraMovement))]
123+
public class PassedOutSpectatePatch
124+
{
125+
[HarmonyPatch(nameof(MainCameraMovement.HandleSpecSelection))]
126+
private static void Prefix(MainCameraMovement __instance, out float __state)
127+
{
128+
__state = __instance.sinceSwitch;
129+
if ((bool)Character.localCharacter && !Character.localCharacter.data.dead && !ConfigurationManager.AllowSpectate)
130+
{
131+
__instance.sinceSwitch = 0.0f;
132+
}
133+
}
134+
[HarmonyPatch(nameof(MainCameraMovement.HandleSpecSelection))]
135+
private static void Postfix(MainCameraMovement __instance, float __state)
136+
{
137+
__instance.sinceSwitch = __state;
138+
}
139+
}
121140
}
122141
}

src/PEAKSleepTalk/PEAKSleepTalk.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<!-- This is the display name of your mod. Example: BepInEx Template -->
99
<AssemblyTitle>PEAKSleepTalk</AssemblyTitle>
1010
<!-- This is the version number of your mod. -->
11-
<Version>0.2.1</Version>
11+
<Version>0.3.0</Version>
1212
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1313
</PropertyGroup>
1414

src/PEAKSleepTalk/thunderstore.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[config]
2-
schemaVersion = "0.2.1"
2+
schemaVersion = "0.3.0"
33

44
[general]
55
repository = "https://thunderstore.io"

0 commit comments

Comments
 (0)