diff --git a/QSB/EchoesOfTheEye/Prisoner/Messages/EmergeTriggerMessage.cs b/QSB/EchoesOfTheEye/Prisoner/Messages/EmergeTriggerMessage.cs new file mode 100644 index 00000000..afe69e61 --- /dev/null +++ b/QSB/EchoesOfTheEye/Prisoner/Messages/EmergeTriggerMessage.cs @@ -0,0 +1,23 @@ +using QSB.Messaging; +using QSB.WorldSync; +using System.Linq; + +namespace QSB.EchoesOfTheEye.Prisoner.Messages; + +internal class EmergeTriggerMessage : QSBMessage +{ + public override void OnReceiveRemote() + { + // hewwo + var director = QSBWorldSync.GetUnityObjects().First(); + director._darknessAwoken = true; + director._cellevator.OnPrisonerReveal(); + director._musicSource.SetLocalVolume(Locator.GetAudioManager().GetAudioEntry(director._musicSource.audioLibraryClip).volume); + director._musicSource.Play(); + + if (QSBCore.IsHost) + { + director._prisonerBrain.BeginBehavior(PrisonerBehavior.Emerge); + } + } +} diff --git a/QSB/EchoesOfTheEye/Prisoner/Patches/PrisonerDirectorPatches.cs b/QSB/EchoesOfTheEye/Prisoner/Patches/PrisonerDirectorPatches.cs new file mode 100644 index 00000000..6dd1667d --- /dev/null +++ b/QSB/EchoesOfTheEye/Prisoner/Patches/PrisonerDirectorPatches.cs @@ -0,0 +1,40 @@ +using HarmonyLib; +using QSB.EchoesOfTheEye.Prisoner.Messages; +using QSB.Messaging; +using QSB.Patches; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace QSB.EchoesOfTheEye.Prisoner.Patches; + +[HarmonyPatch(typeof(PrisonerDirector))] +public class PrisonerDirectorPatches : QSBPatch +{ + public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect; + + [HarmonyPrefix] + [HarmonyPatch(nameof(PrisonerDirector.OnEnterEmergeTrigger))] + public static bool OnEnterEmergeTrigger(PrisonerDirector __instance, GameObject hitObj) + { + if (__instance._darknessAwoken) + { + return false; + } + + if (hitObj.CompareTag("PlayerDetector")) + { + __instance._darknessAwoken = true; + __instance._prisonerBrain.BeginBehavior(PrisonerBehavior.Emerge, 0f); + __instance._cellevator.OnPrisonerReveal(); + __instance._musicSource.SetLocalVolume(Locator.GetAudioManager().GetAudioEntry(__instance._musicSource.audioLibraryClip).volume); + __instance._musicSource.Play(); + new EmergeTriggerMessage().Send(); + } + + return false; + } +} diff --git a/QSB/EchoesOfTheEye/Prisoner/WorldObjects/QSBPrisonerBrain.cs b/QSB/EchoesOfTheEye/Prisoner/WorldObjects/QSBPrisonerBrain.cs index ae362a33..e270d60a 100644 --- a/QSB/EchoesOfTheEye/Prisoner/WorldObjects/QSBPrisonerBrain.cs +++ b/QSB/EchoesOfTheEye/Prisoner/WorldObjects/QSBPrisonerBrain.cs @@ -27,6 +27,50 @@ internal class QSBPrisonerBrain : WorldObject, IGhostObject public QSBGhostSensors Sensors => AttachedObject._sensors.GetWorldObject(); public QSBGhostData Data; + public override void DisplayLines() + { + ControllerLines(Controller); + DataLines(Data, Controller); + } + + private void ControllerLines(QSBGhostController controller) + { + Popcron.Gizmos.Sphere(controller.AttachedObject.transform.position, 2f, Color.white); + + if (controller.AttachedObject._followNodePath) + { + for (var i = controller.AttachedObject._nodePath.Count - 1; i >= 0; i--) + { + Popcron.Gizmos.Sphere(controller.AttachedObject.LocalToWorldPosition(controller.AttachedObject._nodePath[i].localPosition), 0.25f, Color.cyan, 3); + + var hasVisited = controller.AttachedObject._pathIndex < i; + var color = hasVisited ? Color.white : Color.cyan; + + if (i != 0) + { + Popcron.Gizmos.Line(controller.AttachedObject.LocalToWorldPosition(controller.AttachedObject._nodePath[i].localPosition), controller.AttachedObject.LocalToWorldPosition(controller.AttachedObject._nodePath[i - 1].localPosition), color); + } + } + + if (controller.AttachedObject._hasFinalPathPosition) + { + Popcron.Gizmos.Sphere(controller.AttachedObject.LocalToWorldPosition(controller.AttachedObject._finalPathPosition), 0.3f, Color.red, 8); + } + } + } + + private void DataLines(QSBGhostData data, QSBGhostController controller) + { + foreach (var player in data.players.Values) + { + if (player.timeSincePlayerLocationKnown != float.PositiveInfinity) + { + Popcron.Gizmos.Line(controller.AttachedObject.transform.position, controller.AttachedObject.LocalToWorldPosition(player.lastKnownPlayerLocation.localPosition), Color.magenta); + Popcron.Gizmos.Sphere(controller.AttachedObject.LocalToWorldPosition(player.lastKnownPlayerLocation.localPosition), 1f, Color.magenta); + } + } + } + public void Start() { AttachedObject.enabled = false;