diff options
| author | diogo464 <[email protected]> | 2025-12-05 15:09:09 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-12-05 15:09:09 +0000 |
| commit | 9696489d5f1807a507214d6fcdecac4d47e0356d (patch) | |
| tree | 4896eb452c7e410cb1166a1dbd13bcea45861516 /src/entity_button.rs | |
| parent | 0c86da392af50c7588b087c3f72602e8368af65e (diff) | |
reworked entity storage
Diffstat (limited to 'src/entity_button.rs')
| -rw-r--r-- | src/entity_button.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/entity_button.rs b/src/entity_button.rs index baa89a4..35f787f 100644 --- a/src/entity_button.rs +++ b/src/entity_button.rs | |||
| @@ -36,6 +36,21 @@ impl<'a> Button<'a> { | |||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | pub async fn pressed(&mut self) { | 38 | pub async fn pressed(&mut self) { |
| 39 | self.0.wait_command().await; | 39 | loop { |
| 40 | self.0.wait_command().await; | ||
| 41 | let pressed = self.0.with_data(|data| { | ||
| 42 | let storage = data.storage.as_button_mut(); | ||
| 43 | if !storage.consumed && storage.timestamp.is_some() { | ||
| 44 | storage.consumed = true; | ||
| 45 | true | ||
| 46 | } else { | ||
| 47 | false | ||
| 48 | } | ||
| 49 | }); | ||
| 50 | |||
| 51 | if pressed { | ||
| 52 | break; | ||
| 53 | } | ||
| 54 | } | ||
| 40 | } | 55 | } |
| 41 | } | 56 | } |
