|
@@ -13,12 +13,12 @@ pub struct Player { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
#[derive(Copy, Clone, Debug)] |
|
|
pub struct Owned { |
|
|
|
|
|
|
|
|
pub struct PlayerOwned { |
|
|
owner: Entity, |
|
|
owner: Entity, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)] |
|
|
#[derive(Serialize, Deserialize)] |
|
|
pub struct OwnedData<M> { |
|
|
|
|
|
|
|
|
pub struct PlayerOwnedData<M> { |
|
|
pub owner: M, |
|
|
pub owner: M, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -46,7 +46,7 @@ impl Component for Player { |
|
|
type Storage = HashMapStorage<Self>; |
|
|
type Storage = HashMapStorage<Self>; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
impl Owned { |
|
|
|
|
|
|
|
|
impl PlayerOwned { |
|
|
pub fn new(owner: Entity) -> Self { |
|
|
pub fn new(owner: Entity) -> Self { |
|
|
Self { owner } |
|
|
Self { owner } |
|
|
} |
|
|
} |
|
@@ -56,15 +56,15 @@ impl Owned { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
impl Component for Owned { |
|
|
|
|
|
|
|
|
impl Component for PlayerOwned { |
|
|
type Storage = HashMapStorage<Self>; |
|
|
type Storage = HashMapStorage<Self>; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
impl<M> ConvertSaveload<M> for Owned |
|
|
|
|
|
|
|
|
impl<M> ConvertSaveload<M> for PlayerOwned |
|
|
where |
|
|
where |
|
|
for<'de> M: Marker + Serialize + Deserialize<'de>, |
|
|
for<'de> M: Marker + Serialize + Deserialize<'de>, |
|
|
{ |
|
|
{ |
|
|
type Data = OwnedData<M>; |
|
|
|
|
|
|
|
|
type Data = PlayerOwnedData<M>; |
|
|
type Error = NoError; |
|
|
type Error = NoError; |
|
|
|
|
|
|
|
|
fn convert_into<F>(&self, mut ids: F) -> Result<Self::Data, Self::Error> |
|
|
fn convert_into<F>(&self, mut ids: F) -> Result<Self::Data, Self::Error> |
|
@@ -73,7 +73,7 @@ where |
|
|
{ |
|
|
{ |
|
|
let owner = ids(self.owner).unwrap(); |
|
|
let owner = ids(self.owner).unwrap(); |
|
|
|
|
|
|
|
|
Ok(OwnedData { owner }) |
|
|
|
|
|
|
|
|
Ok(PlayerOwnedData { owner }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fn convert_from<F>(data: Self::Data, mut ids: F) -> Result<Self, Self::Error> |
|
|
fn convert_from<F>(data: Self::Data, mut ids: F) -> Result<Self, Self::Error> |
|
@@ -82,7 +82,7 @@ where |
|
|
{ |
|
|
{ |
|
|
let owner = ids(data.owner).unwrap(); |
|
|
let owner = ids(data.owner).unwrap(); |
|
|
|
|
|
|
|
|
Ok(Owned { owner }) |
|
|
|
|
|
|
|
|
Ok(PlayerOwned { owner }) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|