diff options
author | metamuffin <metamuffin@disroot.org> | 2024-09-04 23:41:19 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-09-04 23:41:19 +0200 |
commit | e33e82e87e1e63aa4bc1e599171f61c5c1fa9f15 (patch) | |
tree | 91ffcf384db6b6905369b2337f2da0b3ff32d588 /server/src/interaction.rs | |
parent | b93beb93360257c1a2e1330dfb1a2f184c59b879 (diff) | |
download | hurrycurry-e33e82e87e1e63aa4bc1e599171f61c5c1fa9f15.tar hurrycurry-e33e82e87e1e63aa4bc1e599171f61c5c1fa9f15.tar.bz2 hurrycurry-e33e82e87e1e63aa4bc1e599171f61c5c1fa9f15.tar.zst |
player in progress packet
Diffstat (limited to 'server/src/interaction.rs')
-rw-r--r-- | server/src/interaction.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/server/src/interaction.rs b/server/src/interaction.rs index 4b8fbda5..db4e92a7 100644 --- a/server/src/interaction.rs +++ b/server/src/interaction.rs @@ -16,7 +16,7 @@ */ use hurrycurry_client_lib::{Involvement, Item}; -use hurrycurry_protocol::{Gamedata, ItemLocation, PacketC, Recipe, Score, TileIndex}; +use hurrycurry_protocol::{Gamedata, ItemLocation, PacketC, PlayerID, Recipe, Score, TileIndex}; use log::{info, warn}; use std::collections::VecDeque; @@ -24,6 +24,7 @@ pub fn interact( data: &Gamedata, edge: bool, tile: Option<TileIndex>, + player: Option<PlayerID>, this: &mut Option<Item>, this_loc: ItemLocation, other: &mut Option<Item>, @@ -54,6 +55,7 @@ pub fn interact( *other = outputs[0].map(|kind| Item { kind, active: None }); *this = outputs[1].map(|kind| Item { kind, active: None }); produce( + player, this_had_item, other_had_item, this, @@ -65,6 +67,7 @@ pub fn interact( ); } else { packet_out.push_back(PacketC::SetProgress { + player, item: this_loc, position: active.position, speed: active.speed, @@ -92,6 +95,7 @@ pub fn interact( if item.kind == *input && item.active.is_none() { info!("start active recipe {ri:?}"); item.active = Some(Involvement { + player, recipe: ri, speed: *speed, position: 0., @@ -109,6 +113,7 @@ pub fn interact( } else { info!("start active recipe {ri:?}"); item.active = Some(Involvement { + player, recipe: ri, speed: *speed, position: 0., @@ -122,6 +127,7 @@ pub fn interact( to: this_loc, }); packet_out.push_back(PacketC::SetProgress { + player, item: this_loc, position: 0., speed: *speed, @@ -153,6 +159,7 @@ pub fn interact( score.instant_recipes += 1; *score_changed = true; produce( + player, this_had_item, other_had_item, this, @@ -239,6 +246,7 @@ pub fn tick_slot( score.passive_recipes += 1; *score_changed = true; packet_out.push_back(PacketC::SetProgress { + player: None, warn: false, item: slot_loc, position: 1., @@ -257,6 +265,7 @@ pub fn tick_slot( if a.speed != prev_speed { packet_out.push_back(PacketC::SetProgress { + player: None, position: a.position, speed: a.speed, warn: a.warn, @@ -273,12 +282,14 @@ pub fn tick_slot( { if *input == item.kind { item.active = Some(Involvement { + player: None, recipe: ri, position: 0., warn: *warn, speed: *speed, }); packet_out.push_back(PacketC::SetProgress { + player: None, position: 0., speed: *speed, warn: *warn, @@ -294,6 +305,7 @@ pub fn tick_slot( } fn produce( + player: Option<PlayerID>, this_had_item: bool, other_had_item: bool, this: &Option<Item>, @@ -307,6 +319,7 @@ fn produce( *score_changed = true; if this_had_item { packet_out.push_back(PacketC::SetProgress { + player, item: this_loc, position: 1., speed: 0., |