mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 04:25:00 +01:00
lööp
This commit is contained in:
parent
40e412c024
commit
98dd54f1f2
18 changed files with 196 additions and 1445 deletions
|
|
@ -1,7 +1,5 @@
|
|||
use clap::Parser;
|
||||
|
||||
use crate::{command::Cmd, math::WorldPos};
|
||||
|
||||
#[derive(Parser)]
|
||||
pub enum CmdLine {
|
||||
Quit,
|
||||
|
|
@ -11,7 +9,6 @@ pub enum CmdLine {
|
|||
Spawn,
|
||||
Give(Give),
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
pub struct Tp {
|
||||
x: u32,
|
||||
|
|
@ -22,40 +19,22 @@ pub struct Tp {
|
|||
}
|
||||
impl Tp {
|
||||
fn to_world_pos(&self) -> WorldPos {
|
||||
WorldPos {
|
||||
x: self.x,
|
||||
y: self.y,
|
||||
}
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
pub struct Give {
|
||||
name: String,
|
||||
}
|
||||
|
||||
pub enum Dispatch {
|
||||
Cmd(Cmd),
|
||||
ClearConsole,
|
||||
}
|
||||
|
||||
impl CmdLine {
|
||||
pub fn parse_cmdline(cmdline: &str) -> anyhow::Result<Self> {
|
||||
let words = std::iter::once(" ").chain(cmdline.split_whitespace());
|
||||
Ok(Self::try_parse_from(words)?)
|
||||
loop {}
|
||||
}
|
||||
|
||||
pub(crate) fn dispatch(self) -> Dispatch {
|
||||
match self {
|
||||
CmdLine::Quit => Dispatch::Cmd(Cmd::QuitApp),
|
||||
CmdLine::Freecam => Dispatch::Cmd(Cmd::ToggleFreecam),
|
||||
CmdLine::Clear => Dispatch::ClearConsole,
|
||||
CmdLine::Tp(tp) => Dispatch::Cmd(Cmd::TeleportPlayer {
|
||||
pos: tp.to_world_pos(),
|
||||
relative: tp.rel,
|
||||
}),
|
||||
CmdLine::Spawn => Dispatch::Cmd(Cmd::TeleportPlayerSpawn),
|
||||
CmdLine::Give(give) => Dispatch::Cmd(Cmd::GiveItemByName(give.name)),
|
||||
}
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue