refactor: some restructuring

- move structs inside `sr_tools.rs` into individual file
- implement in-game equip handler (relic & lightcone)
This commit is contained in:
amizing25
2025-03-11 17:27:05 +07:00
parent fff8fc803e
commit d3af43fb06
18 changed files with 1170 additions and 737 deletions
+47
View File
@@ -0,0 +1,47 @@
use proto::ItemType;
pub mod avatar;
pub mod battle;
pub mod lightcone;
pub mod monster;
pub mod persistent;
pub mod relic;
pub mod scene;
pub use avatar::*;
pub use battle::*;
pub use lightcone::*;
pub use monster::*;
pub use persistent::*;
pub use scene::*;
pub fn get_item_unique_id(internal_uid: u32, item_type: ItemType) -> u32 {
if item_type == ItemType::ItemEquipment {
2000 + internal_uid // 2000.3500
} else {
1 + internal_uid // 1..2000
}
}
#[macro_export]
macro_rules! impl_from {
($from:ty, $to:ty, |$param:ident| $body:block) => {
impl From<$from> for $to {
fn from($param: $from) -> Self {
$body
}
}
impl From<&$from> for $to {
fn from($param: &$from) -> Self {
$body
}
}
impl From<&mut $from> for $to {
fn from($param: &mut $from) -> Self {
$body
}
}
};
}