Skip to content

Commit

Permalink
Sync decks of spawned actors
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Jul 27, 2024
1 parent 96a5f05 commit a185ac1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/game/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::game::actor::level::Level;
use crate::game::actor::movement::Movement;
use crate::game::actor::movement::MovementController;
use crate::game::actor::movement::OldMovementController;
use crate::game::audio::music::Beat;
use crate::game::card::deck::Deck;
use crate::game::combat::death::DespawnOnDeath;
use crate::game::combat::hit::Hurtbox;
Expand Down Expand Up @@ -106,7 +107,9 @@ pub struct Actor {
}

impl EntityCommand for Actor {
fn apply(self, id: Entity, world: &mut World) {
fn apply(mut self, id: Entity, world: &mut World) {
self.deck.active += world.resource::<Beat>().total as isize - 1;

world
.entity_mut(id)
.insert((
Expand Down
11 changes: 1 addition & 10 deletions src/game/card/deck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(super) fn plugin(app: &mut App) {
app.configure::<(Deck, IsDeckDisplay)>();
}

#[derive(Component, Reflect, Serialize, Deserialize, Clone)]
#[derive(Component, Reflect, Serialize, Deserialize, Clone, Default)]
#[reflect(Component)]
#[serde(default)]
pub struct Deck {
Expand All @@ -34,15 +34,6 @@ impl Configure for Deck {
}
}

impl Default for Deck {
fn default() -> Self {
Self {
card_keys: Vec::new(),
active: -1,
}
}
}

impl Deck {
pub fn new(card_keys: impl Into<Vec<String>>) -> Self {
Self {
Expand Down

0 comments on commit a185ac1

Please sign in to comment.