Rework of FFI, adding a value identifier, so we can keep knowledge of data even when data moves.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -2,7 +2,7 @@ use hashbrown::HashSet;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::StringKey;
|
||||
use crate::{StringKey, ValueIdentifiable, ValueIdentifier};
|
||||
|
||||
/// An item category defines which bag slot items are stored in.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
@@ -48,6 +48,8 @@ pub enum BattleItemCategory {
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
|
||||
pub struct Item {
|
||||
/// A unique identifier so we know what value this is.
|
||||
identifier: ValueIdentifier,
|
||||
/// The name of the item.
|
||||
name: StringKey,
|
||||
/// Which bag slot items are stored in.
|
||||
@@ -70,6 +72,7 @@ impl Item {
|
||||
flags: HashSet<StringKey>,
|
||||
) -> Item {
|
||||
Item {
|
||||
identifier: Default::default(),
|
||||
name: name.clone(),
|
||||
category,
|
||||
battle_category,
|
||||
@@ -104,3 +107,9 @@ impl Item {
|
||||
self.flags.contains(key)
|
||||
}
|
||||
}
|
||||
|
||||
impl ValueIdentifiable for Item {
|
||||
fn value_identifier(&self) -> ValueIdentifier {
|
||||
self.identifier
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user