make player and client bound together
this cleansup and allows rejoining a running server
This commit is contained in:
@@ -14,7 +14,7 @@ use shared::{
|
||||
hitpoints::{Hitpoints, Kill},
|
||||
npc::SpawnCharacter,
|
||||
player::{Player, PlayerBodyMesh},
|
||||
protocol::{PlaySound, PlayerId, events::ClientHeadChanged},
|
||||
protocol::{OwnedByClient, PlaySound, PlayerId, events::ClientHeadChanged},
|
||||
tb_entities::SpawnPoint,
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ pub fn plugin(app: &mut App) {
|
||||
|
||||
pub fn spawn(
|
||||
mut commands: Commands,
|
||||
_owner: Entity,
|
||||
owner: Entity,
|
||||
query: Query<&Transform, With<SpawnPoint>>,
|
||||
heads_db: Res<HeadsDatabase>,
|
||||
) -> Option<Entity> {
|
||||
@@ -58,6 +58,7 @@ pub fn spawn(
|
||||
UiActiveHeads::default(),
|
||||
Inputs::default(),
|
||||
Replicated,
|
||||
OwnedByClient(owner),
|
||||
))
|
||||
.with_children(|c| {
|
||||
c.spawn((
|
||||
|
||||
@@ -189,3 +189,11 @@ impl TbMapIdCounter {
|
||||
#[derive(Resource, Reflect, Default, Deref, DerefMut)]
|
||||
#[reflect(Resource)]
|
||||
pub struct TbMapEntityMapping(pub HashMap<u64, Entity>);
|
||||
|
||||
#[derive(Component)]
|
||||
#[relationship(relationship_target = ClientOwns)]
|
||||
pub struct OwnedByClient(pub Entity);
|
||||
|
||||
#[derive(Component)]
|
||||
#[relationship_target(relationship = OwnedByClient, linked_spawn)]
|
||||
pub struct ClientOwns(Entity);
|
||||
|
||||
Reference in New Issue
Block a user