//! Game client state handling use crate::{ assets::Assets, graphics::{ entities::{Coordinates, NodeRndr}, Renderer, }, GameSettings, }; use ggez::{event::EventHandler, graphics, Context, GameResult}; use rst_core::data::{Node, Owner, Upgrade}; use std::sync::Arc; pub struct ClientState { assets: Assets, settings: GameSettings, // Game state node: NodeRndr, } impl ClientState { pub fn new(settings: GameSettings, assets: Assets) -> Self { Self { assets, settings, node: NodeRndr { loc: Coordinates(250.0, 250.0), inner: Arc::new(Node { id: 0, health: 100.into(), max_health: 100.into(), owner: Owner::Neutral, type_: Upgrade::Base, links: 0, link_states: vec![], buffer: vec![], }), }, } } pub fn assets(&self) -> &Assets { &self.assets } } impl EventHandler for ClientState { fn update(&mut self, _ctx: &mut Context) -> GameResult<()> { Ok(()) } fn draw(&mut self, ctx: &mut Context) -> GameResult<()> { graphics::clear(ctx, graphics::Color::from_rgb(15, 15, 15)); // Render the node self.node.draw(&self, ctx).unwrap(); graphics::present(ctx) } }