From 8d4db7e654b6872534a24141736f35a62ab15d0d Mon Sep 17 00:00:00 2001
From: Quaternions <krakow20@gmail.com>
Date: Fri, 2 Aug 2024 13:47:02 -0700
Subject: [PATCH] move physics types to common

---
 src/physics.rs | 58 ++++----------------------------------------------
 1 file changed, 4 insertions(+), 54 deletions(-)

diff --git a/src/physics.rs b/src/physics.rs
index 5e6d402..09f0ad0 100644
--- a/src/physics.rs
+++ b/src/physics.rs
@@ -13,6 +13,10 @@ use strafesnet_common::instruction::{self,InstructionEmitter,InstructionConsumer
 use strafesnet_common::integer::{self,Time,Planar64,Planar64Vec3,Planar64Mat3,Angle32,Ratio64Vec2};
 use gameplay::ModeState;
 
+//external influence
+//this is how you influence the physics from outside
+use strafesnet_common::physics::Instruction as PhysicsInputInstruction;
+
 //internal influence
 //when the physics asks itself what happens next, this is how it's represented
 #[derive(Debug)]
@@ -22,34 +26,6 @@ enum PhysicsInternalInstruction{
 	StrafeTick,
 	ReachWalkTargetVelocity,
 	// Water,
-	// Spawn(
-	// 	Option<SpawnId>,
-	// 	bool,//true = Trigger; false = teleport
-	// 	bool,//true = Force
-	// )
-}
-//external influence
-//this is how you influence the physics from outside
-#[derive(Debug)]
-pub enum PhysicsInputInstruction{
-	ReplaceMouse(MouseState,MouseState),
-	SetNextMouse(MouseState),
-	SetMoveRight(bool),
-	SetMoveUp(bool),
-	SetMoveBack(bool),
-	SetMoveLeft(bool),
-	SetMoveDown(bool),
-	SetMoveForward(bool),
-	SetJump(bool),
-	SetZoom(bool),
-	Restart,
-	Spawn(gameplay_modes::ModeId,StageId),
-	Idle,
-		//Idle: there were no input events, but the simulation is safe to advance to this timestep
-		//for interpolation / networking / playback reasons, most playback heads will always want
-		//to be 1 instruction ahead to generate the next state for interpolation.
-	PracticeFly,
-	SetSensitivity(Ratio64Vec2),
 }
 #[derive(Debug)]
 enum PhysicsInstruction{
@@ -78,32 +54,6 @@ impl std::ops::Neg for Body{
 	}
 }
 
-//hey dumbass just use a delta
-#[derive(Clone,Debug)]
-pub struct MouseState {
-	pub pos: glam::IVec2,
-	pub time:Time,
-}
-impl Default for MouseState{
-	fn default() -> Self {
-		Self {
-			time:Time::ZERO,
-			pos:glam::IVec2::ZERO,
-		}
-	}
-}
-impl MouseState {
-	pub fn lerp(&self,target:&MouseState,time:Time)->glam::IVec2 {
-		let m0=self.pos.as_i64vec2();
-		let m1=target.pos.as_i64vec2();
-		//these are deltas
-		let t1t=(target.time-time).nanos();
-		let tt0=(time-self.time).nanos();
-		let dt=(target.time-self.time).nanos();
-		((m0*t1t+m1*tt0)/dt).as_ivec2()
-	}
-}
-
 #[derive(Clone,Debug,Default)]
 pub struct InputState{
 	mouse:MouseState,