68 lines
1.6 KiB
Rust
68 lines
1.6 KiB
Rust
use lazy_static::lazy_static;
|
|
use rhai::{ImmutableString, INT};
|
|
use spin::Mutex;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Object {
|
|
name: String,
|
|
scripted: ScriptedBool,
|
|
}
|
|
// pub struct Weapon{}
|
|
|
|
#[derive(Debug)]
|
|
pub struct Weapon {
|
|
name: String,
|
|
delay: u64,
|
|
damage: u8,
|
|
scripted: ScriptedBool,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum ScriptedBool {
|
|
Scripted(String),
|
|
NotScripted,
|
|
}
|
|
|
|
lazy_static! {
|
|
static ref OBJECT_LIST: Mutex<Vec<Object>> = Mutex::new(vec![]);
|
|
static ref WEAPON_LIST: Mutex<Vec<Weapon>> = Mutex::new(vec![]);
|
|
static ref OBJECT_LIST3: Mutex<Vec<Object>> = Mutex::new(vec![]);
|
|
static ref OBJECT_LIST4: Mutex<Vec<Object>> = Mutex::new(vec![]);
|
|
}
|
|
|
|
pub fn register_mod(name: ImmutableString, description: ImmutableString) {
|
|
println!("{}", name);
|
|
println!("{}", description);
|
|
}
|
|
/// register an unscripted weapon
|
|
pub fn register_weapon(name: ImmutableString, delay: INT, damage: INT) {
|
|
let mut list = WEAPON_LIST.lock();
|
|
let weapon = Weapon {
|
|
name: name.to_string(),
|
|
scripted: ScriptedBool::NotScripted,
|
|
delay: 0,
|
|
damage: 0,
|
|
};
|
|
list.push(weapon);
|
|
println!("{:?}", list);
|
|
}
|
|
/// Register a generic object without a script element
|
|
pub fn register_object(name: ImmutableString) {
|
|
let mut list = OBJECT_LIST.lock();
|
|
let object = Object {
|
|
name: name.to_string(),
|
|
scripted: ScriptedBool::NotScripted,
|
|
};
|
|
list.push(object);
|
|
println!("{:?}", list);
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn register_scripted_object() {
|
|
todo!()
|
|
}
|
|
#[allow(dead_code)]
|
|
pub fn register_scripted_weapon() {
|
|
todo!()
|
|
}
|