-
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
1 parent
21f1a39
commit a6a2b75
Showing
11 changed files
with
156 additions
and
17 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
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,66 @@ | ||
using System.Collections.Generic; | ||
using HarmonyLib; | ||
|
||
namespace ConfigurableWarning.Patches { | ||
[HarmonyPatch] | ||
internal class DivingBellPatch { | ||
[HarmonyPostfix] | ||
[HarmonyPatch(typeof(DivingBellDoor), nameof(DivingBellDoor.IsFullyClosed))] | ||
internal static void IsFullyClosed(DivingBellDoor __instance, ref bool __result) { | ||
__result = __result || !Plugin.State.requireDiveBellDoorClosed; | ||
} | ||
|
||
[HarmonyPostfix] | ||
[HarmonyPatch(typeof(DiveBellPlayerDetector), nameof(DiveBellPlayerDetector.CheckForPlayers))] | ||
internal static void CheckForPlayers(DiveBellPlayerDetector __instance, ref ICollection<Player> __result) { | ||
if (!Plugin.State.requireAllPlayersInDiveBell) { | ||
__result = PlayerHandler.instance.players; | ||
} | ||
} | ||
|
||
[HarmonyPostfix] | ||
[HarmonyPatch(typeof(DivingBell), nameof(DivingBell.Update))] | ||
internal static void Update(DivingBell __instance) { | ||
var recharging = __instance.onSurface && TimeOfDayHandler.TimeOfDay == TimeOfDay.Evening; | ||
|
||
if (recharging) { | ||
__instance.StateMachine.SwitchState<DivingBellRechargingState>(); | ||
return; | ||
} | ||
|
||
var allInside = true; | ||
var playersFoundInBell = __instance.playerDetector.CheckForPlayers(); | ||
var players = PlayerHandler.instance.players; | ||
|
||
foreach (Player player in players) { | ||
if (!playersFoundInBell.Contains(player)) { | ||
allInside = false; | ||
break; | ||
} | ||
} | ||
|
||
var notClosed = !__instance.door.IsFullyClosed() && Plugin.State.requireDiveBellDoorClosed; | ||
var notAllInside = !allInside && Plugin.State.requireAllPlayersInDiveBell; | ||
|
||
if (!notClosed) { | ||
__instance.opened = false; | ||
} | ||
|
||
if (__instance.onSurface) { | ||
if (notAllInside) { | ||
__instance.StateMachine.SwitchState<DivingBellNotReadyMissingPlayersState>(); | ||
} else if (notClosed) { | ||
__instance.StateMachine.SwitchState<DivingBellNotReadyDoorOpenState>(); | ||
} else { | ||
__instance.StateMachine.SwitchState<DivingBellReadyState>(); | ||
} | ||
} else { | ||
if (notClosed) { | ||
__instance.StateMachine.SwitchState<DivingBellNotReadyDoorOpenState>(); | ||
} else { | ||
__instance.StateMachine.SwitchState<DivingBellReadyState>(); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.100" | ||
"version": "8.0.204" | ||
} | ||
} |