1use gizmo_math::{Quat, Vec3};
7use std::sync::Mutex;
8#[derive(Debug, Clone)]
10pub enum ScriptCommand {
11 SetPosition(u32, Vec3),
13 SetRotation(u32, Quat),
14 SetScale(u32, Vec3),
15
16 SetVelocity(u32, Vec3),
18 SetAngularVelocity(u32, Vec3),
19
20 ApplyForce(u32, Vec3),
22 ApplyImpulse(u32, Vec3),
23 AddRigidBody {
24 id: u32,
25 mass: f32,
26 restitution: f32,
27 friction: f32,
28 use_gravity: bool,
29 },
30 AddBoxCollider {
31 id: u32,
32 hx: f32,
33 hy: f32,
34 hz: f32,
35 },
36 AddSphereCollider {
37 id: u32,
38 radius: f32,
39 },
40
41 SetVehicleEngineForce(u32, f32),
43 SetVehicleSteering(u32, f32),
44 SetVehicleBrake(u32, f32),
45
46 SpawnEntity {
48 name: String,
49 position: Vec3,
50 },
51 SpawnPrefab {
52 name: String,
53 prefab_type: String,
54 position: Vec3,
55 },
56 DestroyEntity(u32),
57
58 PlaySound(String),
60 PlaySound3D(String, Vec3),
61 StopSound(String),
62
63 LoadScene(String),
65 SaveScene(String),
66
67 ShowDialogue {
69 speaker: String,
70 text: String,
71 duration: f32,
72 },
73 HideDialogue,
74
75 TriggerCutscene(String), EndCutscene,
78
79 StartRace,
81 AddCheckpoint {
82 id: u32,
83 position: Vec3,
84 radius: f32,
85 },
86 ActivateCheckpoint(u32),
87 FinishRace {
88 winner_name: String,
89 },
90 ResetRace,
91
92 SetCameraTarget(u32), SetCameraFov(f32),
95 SetFightCamera {
97 p1_id: u32,
98 p2_id: u32,
99 height: f32, distance: f32, },
102
103SetEntityName(u32, String),
105PlayAnimation {
106 id: u32,
107 name: String,
108 blend: f32,
109 loop_anim: bool,
110 },
111 SetAnimationSpeed(u32, f32),
112
113
114 AddNavAgent(u32),
116 SetAiTarget(u32, Vec3),
117 ClearAiTarget(u32),
118
119 SetFighterMove {
121 id: u32,
122 name: String,
123 startup: u32,
124 active: u32,
125 recovery: u32,
126 damage: f32,
127 },
128 ApplyHitstop(u32, u32),
129 ApplyHitstun(u32, u32),
130}
131
132
133pub struct CommandQueue {
135 pub commands: Mutex<Vec<ScriptCommand>>,
136}
137
138impl CommandQueue {
139 pub fn new() -> Self {
140 Self {
141 commands: Mutex::new(Vec::new()),
142 }
143 }
144
145 pub fn push(&self, cmd: ScriptCommand) {
146 self.commands.lock().unwrap().push(cmd);
147 }
148
149 pub fn drain(&self) -> Vec<ScriptCommand> {
150 self.commands.lock().unwrap().drain(..).collect()
151 }
152
153 pub fn is_empty(&self) -> bool {
154 self.commands.lock().unwrap().is_empty()
155 }
156
157 pub fn len(&self) -> usize {
158 self.commands.lock().unwrap().len()
159 }
160}
161
162impl Default for CommandQueue {
163 fn default() -> Self {
164 Self::new()
165 }
166}