diff options
| author | metamuffin <metamuffin@disroot.org> | 2024-08-13 12:48:31 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-08-13 16:03:38 +0200 | 
| commit | 16ff78180669411326d42ea32d4a9260c018236c (patch) | |
| tree | d7c6a7ab498bb1b4f9a3b3db99d54e8781216e05 /server/src/entity/item_portal.rs | |
| parent | 11ff74f034aeec58c06dbe15a3f1ee650ef18c9f (diff) | |
| download | hurrycurry-16ff78180669411326d42ea32d4a9260c018236c.tar hurrycurry-16ff78180669411326d42ea32d4a9260c018236c.tar.bz2 hurrycurry-16ff78180669411326d42ea32d4a9260c018236c.tar.zst | |
refactor server to use client-lib data model (breaks customers)
Diffstat (limited to 'server/src/entity/item_portal.rs')
| -rw-r--r-- | server/src/entity/item_portal.rs | 25 | 
1 files changed, 10 insertions, 15 deletions
| diff --git a/server/src/entity/item_portal.rs b/server/src/entity/item_portal.rs index f63ff274..be6acd06 100644 --- a/server/src/entity/item_portal.rs +++ b/server/src/entity/item_portal.rs @@ -15,11 +15,10 @@      along with this program.  If not, see <https://www.gnu.org/licenses/>.  */ -use super::EntityT; -use crate::game::{interact_effect, Game}; +use super::{EntityContext, EntityT}; +use crate::server::interact_effect;  use anyhow::{anyhow, Result}; -use hurrycurry_protocol::{glam::IVec2, ItemLocation, PacketC}; -use std::collections::VecDeque; +use hurrycurry_protocol::{glam::IVec2, ItemLocation};  #[derive(Debug, Default, Clone)]  pub struct ItemPortal { @@ -28,29 +27,25 @@ pub struct ItemPortal {  }  impl EntityT for ItemPortal { -    fn tick( -        &mut self, -        game: &mut Game, -        packet_out: &mut VecDeque<PacketC>, -        _dt: f32, -    ) -> Result<()> { -        let [from, to] = game +    fn tick(&mut self, c: EntityContext) -> Result<()> { +        let [from, to] = c +            .game              .tiles              .get_many_mut([&self.from, &self.to])              .ok_or(anyhow!("conveyor does ends in itself"))?;          if from.item.is_some() {              interact_effect( -                &game.data, +                &c.game.data,                  true,                  &mut to.item,                  ItemLocation::Tile(self.to),                  &mut from.item,                  ItemLocation::Tile(self.from),                  Some(to.kind), -                packet_out, -                &mut game.score, -                &mut game.score_changed, +                c.packet_out, +                &mut c.game.score, +                c.score_changed,                  true,              );          } | 
