mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-12 00:40:08 +00:00
sync prisoner emerging
This commit is contained in:
parent
7509dd5f3b
commit
a151ee7d56
23
QSB/EchoesOfTheEye/Prisoner/Messages/EmergeTriggerMessage.cs
Normal file
23
QSB/EchoesOfTheEye/Prisoner/Messages/EmergeTriggerMessage.cs
Normal file
@ -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<PrisonerDirector>().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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,50 @@ internal class QSBPrisonerBrain : WorldObject<PrisonerBrain>, IGhostObject
|
|||||||
public QSBGhostSensors Sensors => AttachedObject._sensors.GetWorldObject<QSBGhostSensors>();
|
public QSBGhostSensors Sensors => AttachedObject._sensors.GetWorldObject<QSBGhostSensors>();
|
||||||
public QSBGhostData Data;
|
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()
|
public void Start()
|
||||||
{
|
{
|
||||||
AttachedObject.enabled = false;
|
AttachedObject.enabled = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user