54 lines
1.0 KiB
C#
Raw Normal View History

2022-03-18 20:49:44 +00:00
namespace QSB.EchoesOfTheEye.Ghosts.Actions;
public class QSBSleepAction : QSBGhostAction
{
private SleepAction.WakeState _state;
public override GhostAction.Name GetName()
=> GhostAction.Name.Sleep;
public override float CalculateUtility()
=> !_data.hasWokenUp
? 100f
: -100f;
public override bool IsInterruptible()
=> false;
protected override void OnEnterAction()
=> EnterSleepState();
protected override void OnExitAction() { }
public override bool Update_Action()
{
if (_state == SleepAction.WakeState.Sleeping)
{
if (_data.hasWokenUp || _data.sensor.isIlluminatedByPlayer)
{
_state = SleepAction.WakeState.Awake;
_effects.PlayDefaultAnimation();
}
}
else if (_state is not SleepAction.WakeState.WakingUp and SleepAction.WakeState.Awake)
{
return false;
}
return true;
}
private void EnterSleepState()
{
_controller.SetLanternConcealed(true, true);
_effects.PlaySleepAnimation();
_state = SleepAction.WakeState.Sleeping;
}
private enum WakeState
{
Sleeping,
Awake
}
}