-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #577 from misternebula/dev
0.23.0
- Loading branch information
Showing
62 changed files
with
871 additions
and
589 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
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
37 changes: 37 additions & 0 deletions
37
QSB/EchoesOfTheEye/AlarmTotemSync/Messages/SetVisibleMessage.cs
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,37 @@ | ||
using QSB.EchoesOfTheEye.AlarmTotemSync.WorldObjects; | ||
using QSB.Messaging; | ||
|
||
namespace QSB.EchoesOfTheEye.AlarmTotemSync.Messages; | ||
|
||
public class SetVisibleMessage : QSBWorldObjectMessage<QSBAlarmTotem, bool> | ||
{ | ||
public SetVisibleMessage(bool visible) : base(visible) { } | ||
|
||
public override void OnReceiveRemote() | ||
{ | ||
if (WorldObject.AttachedObject._isPlayerVisible == Data) | ||
{ | ||
return; | ||
} | ||
|
||
WorldObject.AttachedObject._isPlayerVisible = Data; | ||
if (Data) | ||
{ | ||
Locator.GetAlarmSequenceController().IncreaseAlarmCounter(); | ||
WorldObject.AttachedObject._secondsConcealed = 0f; | ||
WorldObject.AttachedObject._simTotemMaterials[0] = WorldObject.AttachedObject._simAlarmMaterial; | ||
WorldObject.AttachedObject._simTotemRenderer.sharedMaterials = WorldObject.AttachedObject._simTotemMaterials; | ||
WorldObject.AttachedObject._simVisionConeRenderer.SetColor(WorldObject.AttachedObject._simAlarmColor); | ||
GlobalMessenger.FireEvent("AlarmTotemTriggered"); | ||
} | ||
else | ||
{ | ||
Locator.GetAlarmSequenceController().DecreaseAlarmCounter(); | ||
WorldObject.AttachedObject._secondsConcealed = 0f; | ||
WorldObject.AttachedObject._simTotemMaterials[0] = WorldObject.AttachedObject._origSimEyeMaterial; | ||
WorldObject.AttachedObject._simTotemRenderer.sharedMaterials = WorldObject.AttachedObject._simTotemMaterials; | ||
WorldObject.AttachedObject._simVisionConeRenderer.SetColor(WorldObject.AttachedObject._simVisionConeRenderer.GetOriginalColor()); | ||
WorldObject.AttachedObject._pulseLightController.FadeTo(0f, 0.5f); | ||
} | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
QSB/EchoesOfTheEye/AlarmTotemSync/Messages/TotemEnabledMessage.cs
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
QSB/EchoesOfTheEye/AlarmTotemSync/Messages/TotemVisibleForMessage.cs
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
QSB/EchoesOfTheEye/AlarmTotemSync/Messages/TotemVisibleMessage.cs
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
QSB/EchoesOfTheEye/AlarmTotemSync/Patches/AlarmSequenceControllerPatches.cs
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,93 @@ | ||
using HarmonyLib; | ||
using QSB.Patches; | ||
using UnityEngine; | ||
|
||
namespace QSB.EchoesOfTheEye.AlarmTotemSync.Patches; | ||
|
||
[HarmonyPatch(typeof(AlarmSequenceController))] | ||
public class AlarmSequenceControllerPatches : QSBPatch | ||
{ | ||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect; | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(AlarmSequenceController.IncreaseAlarmCounter))] | ||
private static bool IncreaseAlarmCounter(AlarmSequenceController __instance) | ||
{ | ||
__instance._alarmCounter++; | ||
if (__instance._alarmCounter == 1) | ||
{ | ||
__instance.PlayChimes(); | ||
} | ||
__instance.enabled = true; | ||
return false; | ||
} | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(AlarmSequenceController.DecreaseAlarmCounter))] | ||
private static bool DecreaseAlarmCounter(AlarmSequenceController __instance) | ||
{ | ||
__instance._alarmCounter--; | ||
if (__instance._alarmCounter < 0) | ||
{ | ||
__instance._alarmCounter = 0; | ||
Debug.LogError("Something went wrong, alarm counter should never drop below zero!"); | ||
} | ||
return false; | ||
} | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(AlarmSequenceController.StopChimes))] | ||
private static bool StopChimes(AlarmSequenceController __instance) | ||
{ | ||
__instance._playing = false; | ||
__instance._stopRequested = false; | ||
__instance._animationStarted = false; | ||
foreach (var alarmBell in AlarmTotemManager.AlarmBells) | ||
{ | ||
alarmBell.StopAnimation(); | ||
} | ||
return false; | ||
} | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(AlarmSequenceController.Update))] | ||
private static bool Update(AlarmSequenceController __instance) | ||
{ | ||
__instance.UpdateWakeFraction(); | ||
if (__instance._playing) | ||
{ | ||
__instance.UpdateChimes(); | ||
} | ||
__instance.UpdatePulse(); | ||
if (!__instance._playing && __instance._alarmCounter == 0 && __instance._pulse <= 0.01f) | ||
{ | ||
__instance._pulse = 0f; | ||
__instance._targetPulse = 0f; | ||
__instance.enabled = false; | ||
} | ||
return false; | ||
} | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(AlarmSequenceController.PlaySingleChime))] | ||
private static bool PlaySingleChime(AlarmSequenceController __instance) | ||
{ | ||
foreach (var alarmBell in AlarmTotemManager.AlarmBells) | ||
{ | ||
alarmBell.PlaySingleChime(__instance._chimeIndex); | ||
} | ||
if (!__instance._animationStarted && !__instance._dreamWorldController.IsInDream()) | ||
{ | ||
foreach (var alarmBell in AlarmTotemManager.AlarmBells) | ||
{ | ||
alarmBell.PlayAnimation(); | ||
} | ||
__instance._animationStarted = true; | ||
} | ||
if (__instance._dreamWorldController.IsInDream() && !__instance._dreamWorldController.IsExitingDream()) | ||
{ | ||
Locator.GetDreamWorldAudioController().PlaySingleAlarmChime(__instance._chimeIndex, __instance._volumeCurve.Evaluate(__instance._wakeFraction)); | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.