From 6bbc718eba6f60010b8602298ca0a38841cefbf4 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Sat, 8 Mar 2025 23:25:51 +0100 Subject: [PATCH] work in progress platform --- assets/maps/map1.map | 9 -------- src/main.rs | 2 ++ src/platforms.rs | 51 ++++++++++++++++++++++++++++++++++++++++++++ src/tb_entities.rs | 2 +- 4 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 src/platforms.rs diff --git a/assets/maps/map1.map b/assets/maps/map1.map index bdb4968..902e4bf 100644 --- a/assets/maps/map1.map +++ b/assets/maps/map1.map @@ -860,13 +860,4 @@ ( 1792 5376 128 ) ( 1793 5376 128 ) ( 1792 5376 129 ) blue-metal [ -1 0 0 32 ] [ 0 0 -1 -32 ] 90 1 1 ( 1792 5312 128 ) ( 1792 5312 129 ) ( 1792 5313 128 ) blue-metal [ 0 1 0 -32 ] [ 0 0 -1 -32 ] 180 1 1 } -// brush 1 -{ -( 1776 5184 128 ) ( 1776 5185 128 ) ( 1776 5184 129 ) __TB_empty [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1 -( 1776 5120 128 ) ( 1776 5120 129 ) ( 1777 5120 128 ) __TB_empty [ 1 0 0 0 ] [ 0 0 -1 0 ] 270 1 1 -( 1776 5184 128 ) ( 1777 5184 128 ) ( 1776 5185 128 ) __TB_empty [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 -( 1792 5264 144 ) ( 1792 5265 144 ) ( 1793 5264 144 ) __TB_empty [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1 -( 1792 5376 144 ) ( 1793 5376 144 ) ( 1792 5376 145 ) __TB_empty [ -1 0 0 0 ] [ 0 0 -1 0 ] 270 1 1 -( 1792 5264 144 ) ( 1792 5264 145 ) ( 1792 5265 144 ) __TB_empty [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1 -} } diff --git a/src/main.rs b/src/main.rs index 3d6abc3..e8bb645 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ mod camera; mod cash; mod gates; mod heads_ui; +mod platforms; mod player; mod tb_entities; @@ -66,6 +67,7 @@ fn main() { app.add_plugins(player::plugin); app.add_plugins(heads_ui::plugin); app.add_plugins(gates::plugin); + app.add_plugins(platforms::plugin); app.insert_resource(AmbientLight { color: Color::WHITE, diff --git a/src/platforms.rs b/src/platforms.rs new file mode 100644 index 0000000..21f57d4 --- /dev/null +++ b/src/platforms.rs @@ -0,0 +1,51 @@ +use crate::tb_entities::Platform; +use bevy::{math::ops::sin, prelude::*}; +use bevy_trenchbroom::class::Target; + +#[derive(Component, Reflect, Default, Debug)] +#[reflect(Component)] +struct ActivePlatform { + pub start: Vec3, + pub target: Vec3, +} + +pub fn plugin(app: &mut App) { + app.register_type::(); + app.add_systems(Update, (init, move_active)); +} + +fn init( + mut commands: Commands, + uninit_platforms: Query< + (Entity, &Target, &Transform), + (Without, With), + >, + // targets: Query<(&PlatformTarget, &Transform)>, +) { + for (e, _target, transform) in uninit_platforms.iter() { + // let Some(target) = targets + // .iter() + // .find(|(t, _)| t.targetname == target.target.clone().unwrap_or_default()) + // .map(|(_, t)| *t) + // else { + // continue; + // }; + + let platform = ActivePlatform { + start: transform.translation, + target: transform.translation + Vec3::new(0., 20., 0.), + }; + + info!("platform: {:?}", platform); + + commands.entity(e).insert(platform); + } +} + +fn move_active(time: Res