This commit is contained in:
Mister_Nebula 2022-03-21 16:47:24 +00:00 committed by JohnCorby
parent d19171a690
commit 2dc62cee8f
6 changed files with 36 additions and 37 deletions

View File

@ -120,7 +120,7 @@ public class QSBGuardAction : QSBGhostAction
_targetSearchNode = GetHighestPriorityNodeToSearch();
if (_targetSearchNode == null)
{
Debug.LogError("Failed to find any nodes to search! Did we exhaust our existing options?", _controller.AttachedObject);
Debug.LogError("Failed to find any nodes to search! Did we exhaust our existing options?", _controller);
Debug.Break();
}

View File

@ -30,7 +30,7 @@ public class QSBHuntAction : QSBGhostAction
_huntStartTime = 0f;
_huntFailed = false;
_huntFailTime = 0f;
_controller.AttachedObject.OnNodeMapChanged += new OWEvent.OWCallback(OnNodeMapChanged);
_controller.OnNodeMapChanged += new OWEvent.OWCallback(OnNodeMapChanged);
}
private void OnNodeMapChanged()

View File

@ -15,7 +15,7 @@ public abstract class QSBGhostAction
{
protected QSBGhostBrain _brain;
protected QSBGhostData _data => _brain._data;
protected QSBGhostController _controller => _brain._controller;
protected GhostController _controller => _brain.AttachedObject._controller;
protected QSBGhostSensors _sensors => _brain.AttachedObject._sensors.GetWorldObject<QSBGhostSensors>();
protected QSBGhostEffects _effects => _brain.AttachedObject._effects.GetWorldObject<QSBGhostEffects>();
protected Transform _transform;
@ -83,7 +83,7 @@ public abstract class QSBGhostAction
public virtual void Initialize(QSBGhostBrain brain)
{
_brain = brain;
this._transform = this._controller.AttachedObject.transform;
this._transform = this._controller.transform;
}
public void EnterAction()

View File

@ -56,7 +56,7 @@ public class QSBGhostData
}
}
public void FixedUpdate_Data(QSBGhostController controller, GhostSensors sensors)
public void FixedUpdate_Data(GhostController controller, GhostSensors sensors)
{
wasPlayerLocationKnown = isPlayerLocationKnown;
isPlayerLocationKnown = sensor.isPlayerVisible || sensor.isPlayerHeldLanternVisible || sensor.isIlluminatedByPlayer || sensor.inContactWithPlayer;
@ -67,7 +67,7 @@ public class QSBGhostData
var worldPosition = Locator.GetPlayerTransform().position - Locator.GetPlayerTransform().up;
var worldVelocity = Locator.GetPlayerBody().GetVelocity() - controller.GetNodeMap().GetOWRigidbody().GetVelocity();
playerLocation.Update(worldPosition, worldVelocity, controller.AttachedObject);
playerLocation.Update(worldPosition, worldVelocity, controller);
playerMinLanternRange = Locator.GetDreamWorldController().GetPlayerLantern().GetLanternController().GetMinRange();
if (isPlayerLocationKnown)
{
@ -83,7 +83,7 @@ public class QSBGhostData
firstUnknownSensor.CopyFromOther(sensor);
}
lastKnownPlayerLocation.Update(controller.AttachedObject);
lastKnownPlayerLocation.Update(controller);
timeSincePlayerLocationKnown += Time.deltaTime;
}

View File

@ -42,8 +42,8 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
public override void DisplayLines()
{
ControllerLines(_controller);
DataLines(_data, _controller);
ControllerLines(AttachedObject._controller);
DataLines(_data, AttachedObject._controller);
if (_currentAction != null)
{
@ -51,9 +51,9 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
}
}
private void ControllerLines(QSBGhostController controller)
private void ControllerLines(GhostController controller)
{
Popcron.Gizmos.Sphere(controller.AttachedObject.transform.position, 2f, Color.white);
Popcron.Gizmos.Sphere(controller.transform.position, 2f, Color.white);
if (controller._followNodePath)
{
@ -77,18 +77,17 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
}
}
private void DataLines(QSBGhostData data, QSBGhostController controller)
private void DataLines(QSBGhostData data, GhostController controller)
{
if (data.timeSincePlayerLocationKnown != float.PositiveInfinity)
{
Popcron.Gizmos.Line(controller.AttachedObject.transform.position, controller.LocalToWorldPosition(data.lastKnownPlayerLocation.localPosition), Color.magenta);
Popcron.Gizmos.Line(controller.transform.position, controller.LocalToWorldPosition(data.lastKnownPlayerLocation.localPosition), Color.magenta);
Popcron.Gizmos.Sphere(controller.LocalToWorldPosition(data.lastKnownPlayerLocation.localPosition), 1f, Color.magenta);
}
}
#endregion
internal QSBGhostController _controller;
internal QSBGhostData _data;
private List<QSBGhostAction> _actionLibrary = new();
private QSBGhostAction _currentAction;
@ -157,7 +156,7 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
public void Awake()
{
_controller = AttachedObject.GetComponent<GhostController>().GetWorldObject<QSBGhostController>();
AttachedObject._controller = AttachedObject.GetComponent<GhostController>();
AttachedObject._sensors = AttachedObject.GetComponent<GhostSensors>();
_data = new();
if (AttachedObject._data != null)
@ -169,13 +168,13 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
public void Start()
{
AttachedObject.enabled = false;
_controller.GetDreamLanternController().enabled = false;
_controller.Initialize(AttachedObject._nodeLayer, AttachedObject._effects.GetWorldObject<QSBGhostEffects>());
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._effects.GetWorldObject<QSBGhostEffects>().Initialize(_controller.GetNodeRoot(), _controller, _data);
AttachedObject._effects.GetWorldObject<QSBGhostEffects>().Initialize(AttachedObject._controller.GetNodeRoot(), AttachedObject._controller, _data);
AttachedObject._effects.OnCallForHelp += AttachedObject.OnCallForHelp;
_data.reducedFrights_allowChase = AttachedObject._reducedFrights_allowChase;
_controller.SetLanternConcealed(AttachedObject._startWithLanternConcealed, false);
AttachedObject._controller.SetLanternConcealed(AttachedObject._startWithLanternConcealed, false);
AttachedObject._intruderConfirmedBySelf = false;
AttachedObject._intruderConfirmPending = false;
AttachedObject._intruderConfirmTime = 0f;
@ -196,10 +195,10 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
public void OnDestroy()
{
AttachedObject._sensors.RemoveEventListeners();
_controller.AttachedObject.OnArriveAtPosition -= AttachedObject.OnArriveAtPosition;
_controller.AttachedObject.OnTraversePathNode -= AttachedObject.OnTraversePathNode;
_controller.AttachedObject.OnFaceNode -= AttachedObject.OnFaceNode;
_controller.AttachedObject.OnFinishFaceNodeList -= AttachedObject.OnFinishFaceNodeList;
AttachedObject._controller.OnArriveAtPosition -= AttachedObject.OnArriveAtPosition;
AttachedObject._controller.OnTraversePathNode -= AttachedObject.OnTraversePathNode;
AttachedObject._controller.OnFaceNode -= AttachedObject.OnFaceNode;
AttachedObject._controller.OnFinishFaceNodeList -= AttachedObject.OnFinishFaceNodeList;
AttachedObject._effects.OnCallForHelp -= AttachedObject.OnCallForHelp;
GlobalMessenger.RemoveListener("EnterDreamWorld", new Callback(AttachedObject.OnEnterDreamWorld));
GlobalMessenger.RemoveListener("ExitDreamWorld", new Callback(AttachedObject.OnExitDreamWorld));
@ -222,11 +221,11 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
}
_data.isAlive = false;
_controller.StopMoving();
_controller.StopFacing();
_controller.ExtinguishLantern();
_controller.GetCollider().GetComponent<OWCollider>().SetActivation(false);
_controller.GetGrabController().ReleasePlayer();
AttachedObject._controller.StopMoving();
AttachedObject._controller.StopFacing();
AttachedObject._controller.ExtinguishLantern();
AttachedObject._controller.GetCollider().GetComponent<OWCollider>().SetActivation(false);
AttachedObject._controller.GetGrabController().ReleasePlayer();
_pendingAction = null;
_currentAction = null;
_data.currentAction = GhostAction.Name.None;
@ -300,7 +299,7 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
AttachedObject._effects.PlayRespondToHelpCallAudio(reactDelay);
_data.reduceGuardUtility = true;
_data.lastKnownPlayerLocation.UpdateLocalPosition(playerLocalPosition, _controller.AttachedObject);
_data.lastKnownPlayerLocation.UpdateLocalPosition(playerLocalPosition, AttachedObject._controller);
_data.wasPlayerLocationKnown = true;
_data.timeSincePlayerLocationKnown = 0f;
return true;
@ -320,7 +319,7 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
if (informationTime > _data.timeLastSawPlayer)
{
_data.lastKnownPlayerLocation.UpdateLocalPosition(localPosition, _controller.AttachedObject);
_data.lastKnownPlayerLocation.UpdateLocalPosition(localPosition, AttachedObject._controller);
_data.wasPlayerLocationKnown = true;
_data.timeSincePlayerLocationKnown = 0f;
}
@ -332,9 +331,9 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
{
return;
}
_controller.FixedUpdate_Controller();
AttachedObject._controller.FixedUpdate_Controller();
AttachedObject._sensors.FixedUpdate_Sensors();
_data.FixedUpdate_Data(_controller, AttachedObject._sensors);
_data.FixedUpdate_Data(AttachedObject._controller, AttachedObject._sensors);
AttachedObject.FixedUpdate_ThreatAwareness();
if (_currentAction != null)
{
@ -348,7 +347,7 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
{
return;
}
_controller.Update_Controller();
AttachedObject._controller.Update_Controller();
AttachedObject._sensors.Update_Sensors();
AttachedObject._effects.Update_Effects();
var flag = false;
@ -525,13 +524,13 @@ public class QSBGhostBrain : WorldObject<GhostBrain>, IGhostObject
public void OnEnterDreamWorld()
{
AttachedObject.enabled = true;
_controller.GetDreamLanternController().enabled = true;
AttachedObject._controller.GetDreamLanternController().enabled = true;
}
public void OnExitDreamWorld()
{
AttachedObject.enabled = false;
_controller.GetDreamLanternController().enabled = false;
AttachedObject._controller.GetDreamLanternController().enabled = false;
ChangeAction(null);
_data.OnPlayerExitDreamWorld();
}

View File

@ -20,10 +20,10 @@ public class QSBGhostEffects : WorldObject<GhostEffects>, IGhostObject
private QSBGhostData _data;
public void Initialize(Transform nodeRoot, QSBGhostController controller, QSBGhostData data)
public void Initialize(Transform nodeRoot, GhostController controller, QSBGhostData data)
{
AttachedObject._animator = AttachedObject.GetComponent<Animator>();
AttachedObject._controller = controller.AttachedObject;
AttachedObject._controller = controller;
_data = data;
if (AttachedObject._feetAudioSourceFar != null)
{