summaryrefslogtreecommitdiff
path: root/dungeon/src/player_input.rs
blob: 7fe85c386a438d2cacc58f1c51216a33dc90ca47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use crate::pos::Direction;

/// Carries information on the player's inputs.
/// Allows the game to retrieve player input commands,
/// without tightly binding to a specific GUI or keybinds.
/// This way, game logic can focus on "what the inputs do"
/// as opposed to "what do the key presses mean".
#[derive(Copy, Clone, Default, Debug)]
pub struct PlayerInput {
	/// The direction that the player wants to move in.
	/// The creator is responsible for resolving to just one direction
	/// (eg if the player is holding multiple keys at once,
	///     or a joystick)
	pub direction: Option<Direction>,
	/// If the player is currently attempting to interact
	/// with some object, entity, etc.
	pub interact: bool,
	/// If the player wants to use an item
	pub use_item: bool,
	/// If the player is currently attempting to attack
	pub attack: bool,
	/// If the player is attempting to drop an item
	pub drop: bool,
	/// If the player is attempting to switch the active inv slot
	pub inv_slot: Option<usize>,
}