let ghosts attempt to grab clients

This commit is contained in:
Mister_Nebula 2022-05-01 17:03:00 +01:00
parent 10fb740342
commit 73352566e4
6 changed files with 39 additions and 11 deletions

View File

@ -75,13 +75,8 @@ internal class QSBGrabAction : QSBGhostAction
_controller.FaceLocalPosition(_data.interestedPlayer.playerLocation.localPosition, TurnSpeed.FASTEST);
if (_sensors.CanGrabPlayer(_data.interestedPlayer))
{
DebugLog.DebugWrite($"Grab player {_data.interestedPlayer.player.PlayerId}!");
GrabPlayer();
}
else
{
DebugLog.DebugWrite($"can't grab player {_data.interestedPlayer.player.PlayerId}");
}
return !_grabAnimComplete;
}

View File

@ -0,0 +1,20 @@
using QSB.EchoesOfTheEye.Ghosts.WorldObjects;
using QSB.Messaging;
using QSB.Player;
namespace QSB.EchoesOfTheEye.Ghosts.Messages;
internal class ContactTriggerMessage : QSBWorldObjectMessage<QSBGhostSensors, bool>
{
public ContactTriggerMessage(bool inContact) : base(inContact) { }
public override void OnReceiveRemote()
{
var player = QSBPlayerManager.GetPlayer(From);
if (WorldObject._data.players[player] != null && WorldObject._data.players[player].sensor != null)
{
WorldObject._data.players[player].sensor.inContactWithPlayer = Data;
}
}
}

View File

@ -66,7 +66,7 @@ internal class GhostSensorsPatches : QSBPatch
return true;
}
__instance.GetWorldObject<QSBGhostSensors>().OnEnterContactTrigger(hitObj);
DebugLog.ToConsole($"Error - {MethodBase.GetCurrentMethod().Name} not supported!", OWML.Common.MessageType.Error);
return false;
}
@ -79,7 +79,7 @@ internal class GhostSensorsPatches : QSBPatch
return true;
}
__instance.GetWorldObject<QSBGhostSensors>().OnExitContactTrigger(hitObj);
DebugLog.ToConsole($"Error - {MethodBase.GetCurrentMethod().Name} not supported!", OWML.Common.MessageType.Error);
return false;
}
}

View File

@ -188,7 +188,7 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
AttachedObject.enabled = false;
AttachedObject._controller.GetDreamLanternController().enabled = false;
AttachedObject._controller.GetWorldObject<QSBGhostController>().Initialize(AttachedObject._nodeLayer, AttachedObject._effects.GetWorldObject<QSBGhostEffects>());
AttachedObject._sensors.GetWorldObject<QSBGhostSensors>().Initialize(_data, AttachedObject._guardVolume);
AttachedObject._sensors.GetWorldObject<QSBGhostSensors>().Initialize(_data);
AttachedObject._effects.GetWorldObject<QSBGhostEffects>().Initialize(AttachedObject._controller.GetNodeRoot(), AttachedObject._controller.GetWorldObject<QSBGhostController>(), _data);
AttachedObject._effects.OnCallForHelp += AttachedObject.OnCallForHelp;
_data.reducedFrights_allowChase = AttachedObject._reducedFrights_allowChase;

View File

@ -22,11 +22,14 @@ public class QSBGhostSensors : WorldObject<GhostSensors>, IGhostObject
public QSBGhostData _data;
public void Initialize(QSBGhostData data, OWTriggerVolume guardVolume = null)
public void Initialize(QSBGhostData data)
{
_data = data;
AttachedObject._contactTrigger.OnEntry -= AttachedObject.OnEnterContactTrigger;
AttachedObject._contactTrigger.OnEntry += OnEnterContactTrigger;
AttachedObject._contactTrigger.OnExit -= AttachedObject.OnExitContactTrigger;
AttachedObject._contactTrigger.OnExit += OnExitContactTrigger;
AttachedObject._origEdgeCatcherSize = AttachedObject._contactEdgeCatcherShape.size;
AttachedObject._guardVolume = guardVolume;
}
public bool CanGrabPlayer(GhostPlayer player)
@ -117,6 +120,11 @@ public class QSBGhostSensors : WorldObject<GhostSensors>, IGhostObject
if (hitObj.CompareTag("PlayerDetector") && _data.localPlayer != null && _data.localPlayer.sensor != null)
{
_data.localPlayer.sensor.inContactWithPlayer = true;
if (!QSBCore.IsHost)
{
this.SendMessage(new ContactTriggerMessage(true));
}
}
}
@ -125,6 +133,11 @@ public class QSBGhostSensors : WorldObject<GhostSensors>, IGhostObject
if (hitObj.CompareTag("PlayerDetector") && _data.localPlayer != null && _data.localPlayer.sensor != null)
{
_data.localPlayer.sensor.inContactWithPlayer = false;
if (!QSBCore.IsHost)
{
this.SendMessage(new ContactTriggerMessage(false));
}
}
}
}

View File

@ -77,7 +77,7 @@ internal class QSBPrisonerBrain : WorldObject<PrisonerBrain>, IGhostObject
AttachedObject._controller.GetDreamLanternController().enabled = false;
Controller.Initialize(AttachedObject._nodeLayer, Effects);
Data = new QSBGhostData();
Sensors.Initialize(Data, null);
Sensors.Initialize(Data);
Effects.Initialize(AttachedObject._controller.GetNodeRoot(), Controller, Data);
}