make player and client bound together

this cleansup and allows rejoining a running server
This commit is contained in:
2025-12-08 20:51:46 -05:00
parent ff52258ad2
commit 845cae4389
2 changed files with 11 additions and 2 deletions

View File

@@ -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((

View File

@@ -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);