37 lines
792 B
Rust
37 lines
792 B
Rust
use godot::prelude::*;
|
|
|
|
use crate::game::{Game, opts::PrivateGameOptions};
|
|
|
|
#[derive(GodotClass)]
|
|
#[class(base=Resource, init, tool)]
|
|
pub struct TeamResource {
|
|
#[export]
|
|
pub name: GString,
|
|
#[export]
|
|
pub primary_color: Color,
|
|
#[export]
|
|
pub alt_color: Color,
|
|
|
|
base: Base<Resource>,
|
|
}
|
|
|
|
#[godot_api]
|
|
impl IResource for TeamResource {}
|
|
|
|
impl TeamResource {
|
|
pub fn color_from(&self, opts: &PrivateGameOptions) -> Color {
|
|
match opts.use_alternate_team_colors {
|
|
true => self.alt_color,
|
|
false => self.primary_color,
|
|
}
|
|
}
|
|
|
|
pub fn color(&self) -> Color {
|
|
if let Some(game) = Game::singleton() {
|
|
self.color_from(&game.bind().private_opts)
|
|
} else {
|
|
self.primary_color
|
|
}
|
|
}
|
|
}
|