Player Class Respond to Input

Need help - struggling with event driven input.

I have a simple RPG tile game and for the sake of simplicity, I have 3 class objects - Game1.cs, Map.cs and Player.cs

Map contains all of the tile information and some tiles are “items” that can be picked up by the player and stored in inventory.

The problem is that the Player.cs contains input update logic (Update(GameTime gt)) and then will check if they come across an item. If they do come to an item, I would like to have the game prompt them if they want to pick it up or not (basically yes/no).

I can easily change the state management to display the dialog box and wait for input but how do I (or you) handle updating the logic within the Player.cs?

I can somewhat do this with flags, etc but not without writing a lot of spaghetti code, I don’t know how to properly WAIT for the user to press Y or N and then continue.

I essentially need the game to STOP and wait for the user to select something BEFORE continuing the game loop but it is not working out for me.

My community friends, how do you handle displaying a question to the end user from a game object that is outside the Game class?

Much appreciated for any insight or point in the right direction.

Thank you!

Generally it seems like a bad idea to actually stop the game loop. Often there are still things you want to update like animation, sound effects, enemy behavior etc. I would do this with flags like you mention. To keep it clean I would have the dialog handled by a screen manager or something that sits above the game engine and has a collection of things to update. So you’d just push the dialog on top of that collection so it’s updated before the game engine and set a flag in the game engine to (partially) pause. Then I think I would handle the result of the dialog through events.
This way most of the dialog code can stay out of the main update function of your game and you don’t need to explicitly implement the dialog as a game state.

Thanks for the quick reply. I will play around with your suggestion and see where it takes me.