Switch to replicon (#80)

This commit is contained in:
PROMETHIA-27
2025-12-08 19:22:17 -05:00
committed by GitHub
parent 7a5d2e6914
commit ff52258ad2
55 changed files with 1212 additions and 2951 deletions

View File

@@ -1,6 +1,10 @@
use crate::{
GameState, cash::Cash, loading_assets::GameAssets, physics_layers::GameLayer,
protocol::TbMapIdCounter, utils::global_observer,
GameState,
cash::Cash,
loading_assets::GameAssets,
physics_layers::GameLayer,
protocol::{SkipReplicateColliders, TbMapIdCounter},
utils::global_observer,
};
use avian3d::{
parry::{na::SVector, shape::SharedShape},
@@ -124,18 +128,21 @@ impl EnemySpawn {
let mut this_transform = *this_transform;
this_transform.translation += Vec3::new(0., 1.5, 0.);
let position = Position::new(this_transform.translation);
let rotation = Rotation(this_transform.rotation);
let head = this.head.clone();
world.commands().entity(entity).insert((
this_transform,
position,
rotation,
Name::from(format!("enemy [{head}]")),
Visibility::default(),
RigidBody::Dynamic,
RigidBody::Kinematic,
Collider::capsule(0.6, 2.),
CollisionLayers::new(LayerMask(GameLayer::Npc.to_bits()), LayerMask::ALL),
LockedAxes::new().lock_rotation_z().lock_rotation_x(),
#[cfg(feature = "server")]
lightyear::prelude::Replicate::to_clients(lightyear::prelude::NetworkTarget::All),
));
}
}
@@ -159,6 +166,7 @@ impl CashSpawn {
Cash,
Collider::cuboid(2., 3.0, 2.),
CollisionLayers::new(GameLayer::CollectibleSensors, LayerMask::ALL),
RigidBody::Static,
CollisionEventsEnabled,
Sensor,
));
@@ -222,5 +230,8 @@ fn tb_component_setup<C: Component>(
) {
let id = world.resource_mut::<TbMapIdCounter>().alloc();
commands.entity(trigger.event().entity).insert_if_new(id);
commands
.entity(trigger.event().entity)
.insert_if_new(id)
.insert(SkipReplicateColliders);
}