Big update
This repository is no longer meant for just radarflow, thus it will be renamed. I have split the SDK from radarflow, allowing for simpler use with new projects. Other than that, radarflow is functionally the same. - Fixed bug in radarflow where the entity loop didn't include the last entity.
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use super::Vec3;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct PlayerData {
|
||||
pos: Vec3,
|
||||
yaw: f32,
|
||||
#[serde(rename = "playerType")]
|
||||
player_type: PlayerType,
|
||||
|
||||
#[serde(rename = "hasBomb")]
|
||||
has_bomb: bool
|
||||
}
|
||||
|
||||
impl PlayerData {
|
||||
pub fn new(pos: Vec3, yaw: f32, player_type: PlayerType, has_bomb: bool) -> PlayerData {
|
||||
PlayerData { pos, yaw, player_type, has_bomb }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct BombData {
|
||||
pos: Vec3,
|
||||
#[serde(rename = "isPlanted")]
|
||||
is_planted: bool
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl BombData {
|
||||
pub fn new(pos: Vec3, is_planted: bool) -> BombData {
|
||||
BombData { pos, is_planted }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum EntityData {
|
||||
Player(PlayerData),
|
||||
Bomb(BombData)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default, PartialEq)]
|
||||
pub enum PlayerType {
|
||||
#[default]
|
||||
Unknown,
|
||||
Spectator,
|
||||
Local,
|
||||
Enemy,
|
||||
Team
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct RadarData {
|
||||
ingame: bool,
|
||||
|
||||
#[serde(rename = "mapName")]
|
||||
map_name: String,
|
||||
|
||||
#[serde(rename(serialize = "entityData"))]
|
||||
player_data: Vec<EntityData>,
|
||||
|
||||
//#[serde(rename(serialize = "localYaw"))]
|
||||
//local_yaw: f32,
|
||||
}
|
||||
|
||||
impl RadarData {
|
||||
pub fn new(ingame: bool, map_name: String, player_data: Vec<EntityData>) -> RadarData {
|
||||
RadarData { ingame, map_name, player_data }
|
||||
}
|
||||
|
||||
/// Returns empty RadarData, it's also the same data that gets sent to clients when not ingame
|
||||
pub fn empty() -> RadarData {
|
||||
RadarData {
|
||||
ingame: false,
|
||||
map_name: String::new(),
|
||||
player_data: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
pub mod comms;
|
||||
|
||||
use clap::ValueEnum;
|
||||
pub use comms as communication;
|
||||
|
||||
mod vec3;
|
||||
pub use vec3::Vec3;
|
||||
|
||||
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Default)]
|
||||
pub enum Connector {
|
||||
#[default]
|
||||
Qemu,
|
||||
Kvm,
|
||||
Pcileech
|
||||
}
|
||||
|
||||
impl ToString for Connector {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
Connector::Qemu => String::from("qemu"),
|
||||
Connector::Kvm => String::from("kvm"),
|
||||
Connector::Pcileech => String::from("pcileech"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrapper because log::LevelFilter doesn't implement ValueEnum
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Default)]
|
||||
pub enum Loglevel {
|
||||
Error,
|
||||
#[default]
|
||||
Warn,
|
||||
Info,
|
||||
Debug,
|
||||
Trace,
|
||||
}
|
||||
|
||||
impl From<Loglevel> for log::LevelFilter {
|
||||
fn from(val: Loglevel) -> Self {
|
||||
match val {
|
||||
Loglevel::Error => log::LevelFilter::Error,
|
||||
Loglevel::Warn => log::LevelFilter::Warn,
|
||||
Loglevel::Info => log::LevelFilter::Info,
|
||||
Loglevel::Debug => log::LevelFilter::Debug,
|
||||
Loglevel::Trace => log::LevelFilter::Trace,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, serde::Deserialize)]
|
||||
#[repr(C)]
|
||||
pub struct Vec3 {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
pub z: f32
|
||||
}
|
||||
|
||||
unsafe impl dataview::Pod for Vec3 {}
|
||||
Reference in New Issue
Block a user