mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-30 12:32:55 +00:00
54 lines
1.0 KiB
C#
54 lines
1.0 KiB
C#
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
|
|
}
|
|
}
|