Switch to replicon (#80)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user