refactoring - move type declarations

This commit is contained in:
2022-08-17 20:03:21 +02:00
parent 164f248066
commit 7fa8c25b54
3 changed files with 69 additions and 75 deletions

View File

@@ -6,24 +6,11 @@ use bevy_renet::renet::{
NETCODE_KEY_BYTES,
};
use bevy_rapier2d::geometry::Collider;
use bevy_rapier2d::prelude::*;
use serde::{Deserialize, Serialize};
pub const PRIVATE_KEY: &[u8; NETCODE_KEY_BYTES] = b"en grisars katt hund hemlis key."; // 32-bytes
pub const PROTOCOL_ID: u64 = 7;
#[derive(Debug, Component)]
pub struct Player {
pub id: u64,
}
#[derive(Debug, Component)]
pub struct PlayerId {
pub id: u64,
}
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize, Component)]
pub struct PlayerInput {
pub most_recent_tick: Option<u32>,
@@ -32,12 +19,6 @@ pub struct PlayerInput {
pub space: bool,
}
#[derive(Debug, Component)]
pub struct Jumper {
pub jump_impulse: f32,
pub is_jumping: bool,
}
#[derive(Debug, Serialize, Deserialize, Component)]
pub enum PlayerCommand {
BasicAttack { direction: Vec2 },
@@ -139,29 +120,3 @@ pub fn server_connection_config() -> RenetConnectionConfig {
..Default::default()
}
}
/// set up the level
pub fn setup_level(mut _commands: Commands) {
info!("bygger level...");
}
pub fn spawn_projectile(commands: &mut Commands, origin: Vec2, direction: Vec2) -> Entity {
commands
.spawn()
.insert_bundle(TransformBundle::from(Transform::from_xyz(
origin.x, origin.y, 0.,
)))
//.insert(Collider::ball(0.1))
.insert(RigidBody::Dynamic)
.insert(Velocity::linear(direction.normalize() * 130.))
//.insert(ActiveEvents::COLLISION_EVENTS)
.insert(Projectile {
duration: Timer::from_seconds(3.5, false),
})
.id()
}
#[derive(Debug, Component)]
pub struct Projectile {
pub duration: Timer,
}