fix some stuff???

This commit is contained in:
Mister_Nebula 2022-04-13 10:16:17 +01:00
parent 46e311f736
commit 362b9afc39
9 changed files with 162 additions and 15 deletions

View File

@ -16,7 +16,7 @@ internal class DreamLanternStateMessage : QSBMessage<(DreamLanternActionType Typ
if (heldItem is not QSBDreamLanternItem lantern)
{
DebugLog.ToConsole($"Error - Got DreamLanternStateMessage from player {From}, but they are not holding a QSBDreamLanternItem!");
DebugLog.ToConsole($"Error - Got DreamLanternStateMessage from player {From}, but they are not holding a QSBDreamLanternItem!", OWML.Common.MessageType.Error);
return;
}
@ -25,6 +25,7 @@ internal class DreamLanternStateMessage : QSBMessage<(DreamLanternActionType Typ
switch (Data.Type)
{
case DreamLanternActionType.CONCEAL:
DebugLog.DebugWrite($"CONCEAL {lantern.AttachedObject.name}");
controller.SetConcealed(Data.BoolValue);
break;
case DreamLanternActionType.FOCUS:

View File

@ -0,0 +1,48 @@
using System;
namespace QSB.EchoesOfTheEye.Ghosts.Actions;
public class QSBGhostActionStub : QSBGhostAction
{
public GhostAction.Name Name;
public override GhostAction.Name GetName()
{
return Name;
}
public override float CalculateUtility()
{
throw new NotImplementedException();
}
public override bool IsInterruptible()
{
throw new NotImplementedException();
}
protected override void OnEnterAction()
{
throw new NotImplementedException();
}
protected override void OnExitAction()
{
throw new NotImplementedException();
}
public override bool Update_Action()
{
throw new NotImplementedException();
}
public override void FixedUpdate_Action()
{
throw new NotImplementedException();
}
public override void OnArriveAtPosition()
{
throw new NotImplementedException();
}
}

View File

@ -1,4 +1,5 @@
using GhostEnums;
using QSB.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
@ -65,15 +66,23 @@ internal class QSBGrabAction : QSBGhostAction
{
return true;
}
if (_data.interestedPlayer.playerLocation.distanceXZ > 1.7f)
{
_controller.MoveToLocalPosition(_data.interestedPlayer.playerLocation.localPosition, MoveType.GRAB);
}
_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

@ -1,5 +1,6 @@
using GhostEnums;
using QSB.EchoesOfTheEye.Ghosts;
using QSB.Utility;
/// <summary>
///
@ -27,6 +28,7 @@ public class QSBSentryAction : QSBGhostAction
protected override void OnEnterAction()
{
DebugLog.DebugWrite($"ON ENTER ACTION");
_spotlighting = false;
_controller.SetLanternConcealed(true, true);
_effects.AttachedObject.SetMovementStyle(GhostEffects.MovementStyle.Stalk);
@ -50,6 +52,7 @@ public class QSBSentryAction : QSBGhostAction
if (_data.interestedPlayer.isPlayerLocationKnown && !_spotlighting)
{
DebugLog.DebugWrite($"Spotlighting player...");
_spotlighting = true;
_controller.ChangeLanternFocus(1f, 2f);
}
@ -58,12 +61,14 @@ public class QSBSentryAction : QSBGhostAction
{
if (_data.interestedPlayer.timeSincePlayerLocationKnown > 3f)
{
DebugLog.DebugWrite($"Give up on spotlighting player");
_spotlighting = false;
_controller.SetLanternConcealed(true, true);
_controller.FaceLocalPosition(_targetSentryNode.localPosition + _targetSentryNode.localForward * 10f, TurnSpeed.MEDIUM);
return;
}
DebugLog.DebugWrite($"Facing last known position...");
_controller.FaceLocalPosition(_data.interestedPlayer.lastKnownPlayerLocation.localPosition, TurnSpeed.FAST);
}
}

View File

@ -274,11 +274,6 @@ internal class GhostBrainPatches : QSBPatch
return true;
}
if (!QSBCore.IsHost)
{
return false;
}
__instance.GetWorldObject<QSBGhostBrain>().Update();
return false;
}

View File

@ -45,6 +45,11 @@ internal class GhostPartyPathDirectorPatches : QSBPatch
return true;
}
if (!QSBCore.IsHost)
{
return false;
}
if (__instance._connectedCampfireExtinguished)
{
return false;

View File

@ -1,12 +1,6 @@
using QSB.EchoesOfTheEye.Ghosts.Actions;
using QSB.EchoesOfTheEye.Ghosts.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace QSB.EchoesOfTheEye.Ghosts;
@ -24,6 +18,11 @@ public abstract class QSBGhostAction
public static QSBGhostAction CreateAction(GhostAction.Name name)
{
if (!QSBCore.IsHost)
{
return new QSBGhostActionStub { Name = name };
}
QSBGhostAction ghostAction;
switch (name)
{
@ -31,7 +30,7 @@ public abstract class QSBGhostAction
ghostAction = new QSBWaitAction();
break;
case GhostAction.Name.Sleep:
ghostAction = new QSBSleepAction();
ghostAction = new QSBSleepAction();
break;
case GhostAction.Name.Sleepwalk:
ghostAction = new QSBSleepwalkAction();
@ -93,12 +92,24 @@ public abstract class QSBGhostAction
{
this._running = true;
this._enterTime = Time.time;
if (!QSBCore.IsHost)
{
return;
}
this.OnEnterAction();
}
public void ExitAction()
{
this._running = false;
if (!QSBCore.IsHost)
{
return;
}
this.OnExitAction();
}

View File

@ -1,4 +1,5 @@
using Cysharp.Threading.Tasks;
using GhostEnums;
using QSB.EchoesOfTheEye.Ghosts.Messages;
using QSB.Messaging;
using QSB.Player;
@ -40,6 +41,14 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
$"\r\nCurrent action:{AttachedObject.GetCurrentActionName()}" +
$"\r\nIllumination meter:{_data.illuminatedByPlayerMeter}";
if (QSBCore.IsHost)
{
foreach (var action in _actionLibrary.OrderByDescending(x => x.CalculateUtility()))
{
label += $"\r\n{action.GetName()}:{action.CalculateUtility()}";
}
}
return label;
}
@ -336,11 +345,19 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
{
if (!AttachedObject.enabled)
{
DebugLog.DebugWrite($"attached object is not enabled!");
return;
}
AttachedObject._controller.FixedUpdate_Controller();
AttachedObject._sensors.FixedUpdate_Sensors();
_data.FixedUpdate_Data(AttachedObject._controller, AttachedObject._sensors);
if (!QSBCore.IsHost)
{
return;
}
AttachedObject.FixedUpdate_ThreatAwareness();
if (_currentAction != null)
{
@ -354,9 +371,16 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
{
return;
}
AttachedObject._controller.Update_Controller();
AttachedObject._sensors.Update_Sensors();
AttachedObject._effects.Update_Effects();
if (!QSBCore.IsHost)
{
return;
}
var flag = false;
if (_currentAction != null)
{
@ -384,8 +408,11 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
return;
}
if (!AttachedObject._intruderConfirmPending && (_data.threatAwareness > GhostData.ThreatAwareness.EverythingIsNormal || _data.players.Values.Any(x => x.playerLocation.distance < 20f) || _data.players.Values.Any(x => x.sensor.isPlayerIlluminatedByUs)) && (_data.players.Values.Any(x => x.sensor.isPlayerVisible) || _data.players.Values.Any(x => x.sensor.inContactWithPlayer)))
if (!AttachedObject._intruderConfirmPending
&& (_data.threatAwareness > GhostData.ThreatAwareness.EverythingIsNormal || _data.players.Values.Any(x => x.playerLocation.distance < 20f) || _data.players.Values.Any(x => x.sensor.isPlayerIlluminatedByUs))
&& (_data.players.Values.Any(x => x.sensor.isPlayerVisible) || _data.players.Values.Any(x => x.sensor.inContactWithPlayer)))
{
DebugLog.DebugWrite($"INTRUDER CONFIRMED BY SELF");
AttachedObject._intruderConfirmedBySelf = true;
AttachedObject._intruderConfirmPending = true;
var closestPlayer = _data.players.Values.MinBy(x => x.playerLocation.distance);
@ -498,6 +525,11 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
public void OnArriveAtPosition()
{
if (!QSBCore.IsHost)
{
return;
}
if (_currentAction != null)
{
_currentAction.OnArriveAtPosition();
@ -551,7 +583,7 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
{
AttachedObject.enabled = false;
AttachedObject._controller.GetDreamLanternController().enabled = false;
ChangeAction(null);
//ChangeAction(null);
_data.OnPlayerExitDreamWorld();
}
}

View File

@ -150,9 +150,18 @@ internal class DebugGUI : MonoBehaviour, IAddComponentOnStart
WriteLine(2, $"Visible : {player.Visible}");
WriteLine(2, $"Ready : {player.IsReady}");
WriteLine(2, $"Suited Up : {player.SuitedUp}");
WriteLine(2, $"InDreamWorld : {player.InDreamWorld}");
if (player.IsReady && QSBWorldSync.AllObjectsReady)
{
WriteLine(2, $"Illuminated : {player.LightSensor.IsIlluminated()}");
var singleLightSensor = player.LightSensor as SingleLightSensor;
foreach (var item in singleLightSensor._lightSources)
{
WriteLine(2, $"- {item.GetLightSourceType()}");
}
var networkTransform = player.TransformSync;
var referenceSector = networkTransform.ReferenceSector;
var referenceTransform = networkTransform.ReferenceTransform;
@ -223,6 +232,37 @@ internal class DebugGUI : MonoBehaviour, IAddComponentOnStart
#endregion
if (QSBWorldSync.AllObjectsReady)
{
var ghost = QSBWorldSync.GetWorldObjects<QSBGhostBrain>().First(x => x.AttachedObject._name == "Kamaji");
WriteLine(4, ghost.AttachedObject._name);
WriteLine(4, $"Action:{ghost.GetCurrentActionName()}");
WriteLine(4, $"Threat Awareness:{ghost.GetThreatAwareness()}");
var interestedPlayer = ghost._data.interestedPlayer;
WriteLine(4, $"InterestedPlayer:{(interestedPlayer == null ? "NULL" : interestedPlayer.player.PlayerId)}");
foreach (var player in ghost._data.players.Values)
{
WriteLine(4, $"{player.player.PlayerId}");
WriteLine(4, $"- isPlayerVisible:{player.sensor.isPlayerVisible}");
WriteLine(4, $"- isPlayerHeldLanternVisible:{player.sensor.isPlayerHeldLanternVisible}");
WriteLine(4, $"- isIlluminatedByPlayer:{player.sensor.isIlluminatedByPlayer}");
WriteLine(4, $"- isPlayerLocationKnown:{player.isPlayerLocationKnown}");
WriteLine(4, $"- timeSincePlayerLocationKnown:{player.timeSincePlayerLocationKnown}");
var lantern = player.player.AssignedSimulationLantern;
WriteLine(4, $"- IsHeldByPlayer:{lantern.AttachedObject.GetLanternController().IsHeldByPlayer()}");
WriteLine(4, $"- Concealed:{lantern.AttachedObject.GetLanternController().IsConcealed()}");
var position = player.player.Camera.transform.position;
WriteLine(4, $"- Camera in vision cone:{ghost.AttachedObject._sensors.CheckPointInVisionCone(position)}");
WriteLine(4, $"- CheckLineOccluded:{ghost.AttachedObject._sensors.CheckLineOccluded(ghost.AttachedObject._sensors._sightOrigin.position, position)}");
}
WriteLine(4, $"First check:{!ghost.AttachedObject._intruderConfirmPending}");
WriteLine(4, $"Second check:{ghost._data.threatAwareness > GhostData.ThreatAwareness.EverythingIsNormal || ghost._data.players.Values.Any(x => x.playerLocation.distance < 20f) || ghost._data.players.Values.Any(x => x.sensor.isPlayerIlluminatedByUs)}");
WriteLine(4, $"Third check:{ghost._data.players.Values.Any(x => x.sensor.isPlayerVisible) || ghost._data.players.Values.Any(x => x.sensor.inContactWithPlayer)}");
}
/*
#region Column4 - Quantum Object Possesion
foreach (var player in QSBPlayerManager.PlayerList)
@ -261,6 +301,7 @@ internal class DebugGUI : MonoBehaviour, IAddComponentOnStart
}
#endregion
*/
}
private static void DrawWorldObjectLabels()