add CENTER_WORLD_ON_PLAYER constant

This commit is contained in:
yuni 2024-04-01 19:20:31 +02:00
parent b583970a88
commit 84747e1c3a

View file

@ -10,6 +10,8 @@ const ASTEROID_UPDATE_INTERVAL: f32 = 1.0; // seconds
const ASTEROID_SIZE: f32 = 100.0; const ASTEROID_SIZE: f32 = 100.0;
const STARS_MAX_MAGNITUDE: f32 = 5.5; const STARS_MAX_MAGNITUDE: f32 = 5.5;
const CENTER_WORLD_ON_PLAYER: bool = true;
const ASSET_ASTEROID1: &str = "models/asteroid.glb#Scene0"; const ASSET_ASTEROID1: &str = "models/asteroid.glb#Scene0";
const ASSET_ASTEROID2: &str = "models/asteroid2.glb#Scene0"; const ASSET_ASTEROID2: &str = "models/asteroid2.glb#Scene0";
pub fn asset_name_to_path(name: &str) -> &'static str { pub fn asset_name_to_path(name: &str) -> &'static str {
@ -42,14 +44,16 @@ impl Plugin for WorldPlugin {
Timer::from_seconds(ASTEROID_UPDATE_INTERVAL, TimerMode::Repeating))); Timer::from_seconds(ASTEROID_UPDATE_INTERVAL, TimerMode::Repeating)));
app.insert_resource(AsteroidDatabase(Vec::new())); app.insert_resource(AsteroidDatabase(Vec::new()));
// Disable bevy_xpbd's position->transform sync because we have a if CENTER_WORLD_ON_PLAYER {
// custom syncing function. // Disable bevy_xpbd's position->transform sync function
app.insert_resource(SyncConfig { app.insert_resource(SyncConfig {
position_to_transform: false, position_to_transform: false,
transform_to_position: false, transform_to_position: false,
}); });
// Add own position->transform sync function
app.add_systems(PreUpdate, position_to_transform); app.add_systems(PreUpdate, position_to_transform);
} }
}
} }
#[derive(Resource)] struct AsteroidUpdateTimer(Timer); #[derive(Resource)] struct AsteroidUpdateTimer(Timer);