Rename pending match to match config and add match state (#51)
Reviewed-on: #51 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #51.
This commit is contained in:
+18
-9
@@ -1,20 +1,29 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::{
|
||||
fighter::manifest::{FighterManifest, FighterManifestRegistry}, match_loading::{PendingMatch}, ui::{errors::UIErrors, fighter_info::FighterInfoUI},
|
||||
fighter::manifest::{FighterManifest, FighterManifestRegistry},
|
||||
match_loading::MatchConfig,
|
||||
ui::{errors::UIErrors, fighter_info::FighterInfoUI},
|
||||
};
|
||||
|
||||
#[derive(Component, FromTemplate)]
|
||||
pub struct BattleUI {
|
||||
}
|
||||
|
||||
pub fn spawn_battle_ui(mut commands: Commands, request: Res<PendingMatch>, fighter_registry: Res<FighterManifestRegistry>, manifests: Res<Assets<FighterManifest>>) -> Result {
|
||||
pub struct BattleUI {}
|
||||
|
||||
pub fn spawn_battle_ui(
|
||||
mut commands: Commands,
|
||||
config: Res<MatchConfig>,
|
||||
fighter_registry: Res<FighterManifestRegistry>,
|
||||
manifests: Res<Assets<FighterManifest>>,
|
||||
) -> Result {
|
||||
let mut fighter_uis = vec![];
|
||||
|
||||
for player in &request.players {
|
||||
let manifest = fighter_registry.get(player.fighter).ok_or_else(|| UIErrors::FighterManifestHandleNotFound(player.fighter))?;
|
||||
let manifest = manifests.get(manifest).ok_or_else(|| UIErrors::FighterManifestNotFound(player.fighter))?;
|
||||
for player in &config.players {
|
||||
let manifest = fighter_registry
|
||||
.get(player.fighter)
|
||||
.ok_or_else(|| UIErrors::FighterManifestHandleNotFound(player.fighter))?;
|
||||
let manifest = manifests
|
||||
.get(manifest)
|
||||
.ok_or_else(|| UIErrors::FighterManifestNotFound(player.fighter))?;
|
||||
|
||||
fighter_uis.push(FighterInfoUI::build(manifest, player));
|
||||
}
|
||||
@@ -54,4 +63,4 @@ pub fn cleanup_battle_ui(mut commands: Commands, battle_ui: Query<Entity, With<B
|
||||
for entity in battle_ui {
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user