-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiplayer: Make non-local entity updates possible
- Loading branch information
Showing
5 changed files
with
72 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
#[cfg(feature = "bevy")] | ||
use bevy::ecs::entity::Entity; | ||
use bincode::{Decode, Encode}; | ||
use de_types::player::Player; | ||
|
||
/// Bevy ECS Entity derived identification of an entity. | ||
#[derive(Clone, Copy, Debug, Encode, Decode, Hash, PartialEq, Eq)] | ||
pub struct EntityNet(u32); | ||
pub struct EntityNet { | ||
player: Player, | ||
index: u32, | ||
} | ||
|
||
#[cfg(feature = "bevy")] | ||
impl From<Entity> for EntityNet { | ||
fn from(entity: Entity) -> Self { | ||
Self(entity.index()) | ||
impl EntityNet { | ||
/// # Arguments | ||
/// | ||
/// * `player` - the human player executing the entity simulating game | ||
/// instance. | ||
/// | ||
/// * `index` - locally unique index of the entity. | ||
pub fn new(player: Player, index: u32) -> Self { | ||
Self { player, index } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters