public void PassInput(PlayerAction action)
 {
     if (action == PlayerAction.ESCAPE_SCREEN)
     {
         RogueUIPanel.ExitTopLevel();
     }
 }
    public override IEnumerator DetermineAction()
    {
        if (InputTracking.HasNextAction())
        {
            Player.player.view.CollectEntities(Map.current);
            PlayerAction action = InputTracking.PopNextAction();
            switch (action)
            {
            //Handle Movement code
            case PlayerAction.MOVE_UP:
                nextAction = new MoveAction(monster.location + Vector2Int.up);
                break;

            case PlayerAction.MOVE_DOWN:
                nextAction = new MoveAction(monster.location + Vector2Int.down);
                break;

            case PlayerAction.MOVE_LEFT:
                nextAction = new MoveAction(monster.location + Vector2Int.left);
                break;

            case PlayerAction.MOVE_RIGHT:
                nextAction = new MoveAction(monster.location + Vector2Int.right);
                break;

            case PlayerAction.MOVE_UP_LEFT:
                nextAction = new MoveAction(monster.location + new Vector2Int(-1, 1));
                break;

            case PlayerAction.MOVE_UP_RIGHT:
                nextAction = new MoveAction(monster.location + new Vector2Int(1, 1));
                break;

            case PlayerAction.MOVE_DOWN_LEFT:
                nextAction = new MoveAction(monster.location + new Vector2Int(-1, -1));
                break;

            case PlayerAction.MOVE_DOWN_RIGHT:
                nextAction = new MoveAction(monster.location + new Vector2Int(1, -1));
                break;

            case PlayerAction.WAIT:
                nextAction = new WaitAction();
                break;

            case PlayerAction.DROP_ITEMS:
                Debug.Log("Dropping items!");
                UIController.singleton.OpenInventoryDrop();
                yield return(new WaitUntil(() => !UIController.WindowsOpen));

                break;

            case PlayerAction.PICK_UP_ITEMS:
                //Intelligently pick up items, opening dialouge box if needed.
                PickupSmartDetection();

                //Check if dialouge box is opened; if so, freeze until transaction is done
                if (UIController.WindowsOpen)
                {
                    yield return(new WaitUntil(() => !UIController.WindowsOpen));
                }
                break;

            case PlayerAction.OPEN_INVENTORY:
                UIController.singleton.OpenInventoryInspect();
                yield return(new WaitUntil(() => !UIController.WindowsOpen));

                break;

            case PlayerAction.EQUIP:
                UIController.singleton.OpenEquipmentInspect();
                yield return(new WaitUntil(() => !UIController.WindowsOpen));

                break;

            case PlayerAction.UNEQUIP:
                UIController.singleton.OpenEquipmentUnequip();
                yield return(new WaitUntil(() => !UIController.WindowsOpen));

                break;

            case PlayerAction.APPLY:
                UIController.singleton.OpenInventoryApply();
                yield return(new WaitUntil(() => !UIController.WindowsOpen));

                break;

            case PlayerAction.CAST_SPELL:
                UIController.singleton.OpenAbilities();
                yield return(new WaitUntil(() => !UIController.WindowsOpen));

                break;

            case PlayerAction.FIRE:
                nextAction = new RangedAttackAction();
                break;

            case PlayerAction.ASCEND:
                if (AutoStairs(true))
                {
                    nextAction = new ChangeLevelAction(true);
                }
                else
                {
                    //TODO: Highlight path to nearest stair!
                    yield return(new WaitUntil(() => InputTracking.HasNextAction()));

                    PlayerAction newAction = InputTracking.PopNextAction();
                    if (newAction == PlayerAction.ASCEND)
                    {
                        PathToNearestStair(true);
                    }
                }
                break;

            case PlayerAction.DESCEND:
                if (AutoStairs(false))
                {
                    nextAction = new ChangeLevelAction(false);
                }
                else
                {
                    //TODO: Highlight path to nearest stair!
                    //TODO: This whole waiting and checking thing should be reworked
                    //as a variant of the FindNearest Action
                    yield return(new WaitUntil(() => InputTracking.HasNextAction()));

                    PlayerAction newAction = InputTracking.PopNextAction();
                    if (newAction == PlayerAction.DESCEND)
                    {
                        PathToNearestStair(false);
                    }
                }
                break;

            case PlayerAction.AUTO_ATTACK:
                nextAction = new AutoAttackAction();
                break;

            case PlayerAction.AUTO_EXPLORE:
                nextAction = new AutoExploreAction();
                break;

            //Handle potentially weird cases (Thanks, Nethack design philosophy!)
            case PlayerAction.ESCAPE_SCREEN:
                //TODO: Open up the pause menu screen here
                RogueUIPanel.ExitTopLevel();     //This really, really shouldn't do anything. Let it happen, though!
                break;

            case PlayerAction.ACCEPT:
            case PlayerAction.NONE:
                Debug.Log("Player read an input set to do nothing", this);
                break;

            default:
                Debug.LogError($"Player read an input that has no switch case: {action}");
                break;
            }
        }
    }