81 lines
2.0 KiB
C#
Raw Normal View History

2022-03-18 20:49:44 +00:00
using GhostEnums;
using QSB.EchoesOfTheEye.Ghosts;
2022-04-13 10:16:17 +01:00
using QSB.Utility;
2022-03-18 20:49:44 +00:00
/// <summary>
///
/// </summary>
public class QSBSentryAction : QSBGhostAction
{
private GhostNode _targetSentryNode;
private bool _spotlighting;
public override GhostAction.Name GetName()
{
return GhostAction.Name.Sentry;
}
public override float CalculateUtility()
{
if (_data.threatAwareness >= GhostData.ThreatAwareness.SomeoneIsInHere)
{
return 50f;
}
return -100f;
}
protected override void OnEnterAction()
{
2022-04-13 10:16:17 +01:00
DebugLog.DebugWrite($"ON ENTER ACTION");
2022-03-18 20:49:44 +00:00
_spotlighting = false;
_controller.SetLanternConcealed(true, true);
2022-04-14 12:38:34 +01:00
_effects.SetMovementStyle(GhostEffects.MovementStyle.Stalk);
2022-04-07 08:57:51 +01:00
var searchNodesOnLayer = _controller.AttachedObject.GetNodeMap().GetSearchNodesOnLayer(_controller.AttachedObject.GetNodeLayer());
2022-03-18 20:49:44 +00:00
_targetSentryNode = searchNodesOnLayer[0];
_controller.PathfindToNode(_targetSentryNode, MoveType.PATROL);
_controller.FaceVelocity();
}
public override bool Update_Action()
{
return true;
}
public override void FixedUpdate_Action()
{
2022-04-02 10:54:12 +01:00
if (_data.interestedPlayer == null)
{
return;
}
if (_data.interestedPlayer.isPlayerLocationKnown && !_spotlighting)
2022-03-18 20:49:44 +00:00
{
2022-04-13 10:16:17 +01:00
DebugLog.DebugWrite($"Spotlighting player...");
2022-03-18 20:49:44 +00:00
_spotlighting = true;
_controller.ChangeLanternFocus(1f, 2f);
}
if (_spotlighting)
{
2022-04-02 10:54:12 +01:00
if (_data.interestedPlayer.timeSincePlayerLocationKnown > 3f)
2022-03-18 20:49:44 +00:00
{
2022-04-13 10:16:17 +01:00
DebugLog.DebugWrite($"Give up on spotlighting player");
2022-03-18 20:49:44 +00:00
_spotlighting = false;
_controller.SetLanternConcealed(true, true);
_controller.FaceLocalPosition(_targetSentryNode.localPosition + _targetSentryNode.localForward * 10f, TurnSpeed.MEDIUM);
return;
}
2022-04-13 10:16:17 +01:00
DebugLog.DebugWrite($"Facing last known position...");
2022-04-02 10:54:12 +01:00
_controller.FaceLocalPosition(_data.interestedPlayer.lastKnownPlayerLocation.localPosition, TurnSpeed.FAST);
2022-03-18 20:49:44 +00:00
}
}
public override void OnArriveAtPosition()
{
_controller.FaceLocalPosition(_targetSentryNode.localPosition + _targetSentryNode.localForward * 10f, TurnSpeed.MEDIUM);
}
}