Mister_Nebula 6c8f84f79d aaaaaa
2022-04-07 10:50:54 -07:00

59 lines
1.3 KiB
C#

using GhostEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace QSB.EchoesOfTheEye.Ghosts.Actions;
public class QSBWaitAction : QSBGhostAction
{
public override GhostAction.Name GetName()
{
return GhostAction.Name.Wait;
}
public override float CalculateUtility()
{
if (_data.interestedPlayer == null)
{
return 0f;
}
if (PlayerState.IsGrabbedByGhost() && (_running || _data.interestedPlayer.timeSincePlayerLocationKnown < 4f))
{
return 666f;
}
return 0f;
}
protected override void OnEnterAction()
{
if (!PlayerState.IsGrabbedByGhost())
{
_controller.AttachedObject.StopMoving();
_controller.AttachedObject.StopFacing();
return;
}
_effects.AttachedObject.SetMovementStyle(GhostEffects.MovementStyle.Stalk);
_controller.AttachedObject.FacePlayer(TurnSpeed.MEDIUM);
if (_data.interestedPlayer.playerLocation.distanceXZ < 3f)
{
Vector3 toPositionXZ = _data.interestedPlayer.playerLocation.toPositionXZ;
_controller.MoveToLocalPosition(_controller.AttachedObject.GetLocalFeetPosition() - toPositionXZ * 3f, MoveType.SEARCH);
return;
}
_controller.AttachedObject.StopMoving();
}
public override bool Update_Action()
{
return true;
}
}