2022-03-19 20:09:55 +00:00
|
|
|
|
using QSB.Utility;
|
|
|
|
|
|
|
|
|
|
namespace QSB.EchoesOfTheEye.Ghosts.Actions;
|
2022-03-18 20:49:44 +00:00
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2022-04-02 09:54:12 +00:00
|
|
|
|
if (_data.hasWokenUp || _data.IsIlluminatedByAnyPlayer)
|
2022-03-18 20:49:44 +00:00
|
|
|
|
{
|
2022-03-19 20:22:08 +00:00
|
|
|
|
DebugLog.DebugWrite($"{_brain.AttachedObject._name} : Who dares awaken me?");
|
2022-03-18 20:49:44 +00:00
|
|
|
|
_state = SleepAction.WakeState.Awake;
|
2022-04-14 12:00:24 +00:00
|
|
|
|
_effects.PlayDefaultAnimation();
|
2022-03-18 20:49:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (_state is not SleepAction.WakeState.WakingUp and SleepAction.WakeState.Awake)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EnterSleepState()
|
|
|
|
|
{
|
|
|
|
|
_controller.SetLanternConcealed(true, true);
|
2022-04-14 12:00:24 +00:00
|
|
|
|
_effects.PlaySleepAnimation();
|
2022-03-18 20:49:44 +00:00
|
|
|
|
_state = SleepAction.WakeState.Sleeping;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private enum WakeState
|
|
|
|
|
{
|
|
|
|
|
Sleeping,
|
|
|
|
|
Awake
|
|
|
|
|
}
|
|
|
|
|
}
|