Revert "Add mod gameplay APIs and zombie shooter example"

This reverts commit df0affd2e3.
This commit is contained in:
Ethanw05 committed 2026-09-08 20:10:20 -06:00
1 parent df0affd2e3
commit ae96db7c48
14 files changed
+9 -389

No files matched your search

-7
View File
@@ -16,13 +16,6 @@ struct BoneBinding {
parent_bone: Option<usize>,
}
impl AnimationStatus {
pub(crate) fn entity_for_bone(&self, bone: usize) -> Option<Entity> {
self.bindings
.iter()
.find(|binding| binding.bone == bone)
.map(|binding| binding.entity)
}
/// Prepare a hidden imported scene without disturbing the live bindings.
pub(crate) fn for_scene(
root: Entity,
+4 -99
View File
@@ -25,11 +25,6 @@ struct Owned {
entity: Entity,
mesh: Option<AssetId<Mesh>>,
material: Option<AssetId<StandardMaterial>>,
attachment: Option<usize>,
}
#[derive(Component)]
struct HeldAttachment {
bone: usize,
}
pub(crate) struct ModdingPlugin;
impl Plugin for ModdingPlugin {
@@ -96,12 +91,7 @@ impl Plugin for ModdingPlugin {
.after(crate::app::SimulationSet::Physics)
.run_if(crate::graphics_menu::gameplay_active),
)
.add_systems(
Update,
(attach_held, update)
.chain()
.after(crate::app::FrameSet::Animation),
);
.add_systems(Update, update.after(crate::app::FrameSet::Animation));
vehicles::install(app);
network::install(app);
menu::install(app);
@@ -220,22 +210,6 @@ fn update(world: &mut World) {
apply(world, &mut mods);
});
}
fn attach_held(
mut commands: Commands,
animation: Res<crate::animation::AnimationStatus>,
held: Query<(Entity, &HeldAttachment), Without<ChildOf>>,
) {
if !animation.ready {
return;
}
for (entity, attachment) in &held {
if let Some(parent) = animation.entity_for_bone(attachment.bone) {
commands
.entity(entity)
.insert((ChildOf(parent), Visibility::Inherited));
}
}
}
fn retire(world: &mut World, mods: &mut Mods, key: &(String, String)) {
if let Some(owned) = mods.owned.remove(key) {
world.despawn(owned.entity);
@@ -297,9 +271,7 @@ fn apply(world: &mut World, mods: &mut Mods) {
Command::Remove { key } => {
keys.remove(key);
}
Command::Overlay { key, .. }
| Command::Cube { key, .. }
| Command::HeldCube { key, .. } => {
Command::Overlay { key, .. } | Command::Cube { key, .. } => {
keys.insert(key.clone());
if keys.len() > 64 {
return Err("64 owned objects per mod maximum".into());
@@ -380,10 +352,7 @@ fn teleport_ready(world: &World) -> Result<(), String> {
}
fn apply_one(world: &mut World, mods: &mut Mods, id: &str, command: Command) -> Result<(), String> {
let key = match &command {
Command::Cube { key, .. }
| Command::HeldCube { key, .. }
| Command::Overlay { key, .. }
| Command::Remove { key } => {
Command::Cube { key, .. } | Command::Overlay { key, .. } | Command::Remove { key } => {
Some((id.to_owned(), key.clone()))
}
_ => None,
@@ -452,7 +421,6 @@ fn apply_one(world: &mut World, mods: &mut Mods, id: &str, command: Command) ->
entity,
mesh: None,
material: None,
attachment: None,
},
);
}
@@ -464,7 +432,7 @@ fn apply_one(world: &mut World, mods: &mut Mods, id: &str, command: Command) ->
} => {
let key = key.unwrap();
if let Some(owned) = mods.owned.get(&key) {
if owned.mesh.is_some() && owned.attachment.is_none() {
if owned.mesh.is_some() {
*world.get_mut::<Transform>(owned.entity).unwrap() =
Transform::from_translation(Vec3::from_array(position))
.with_scale(Vec3::from_array(size));
@@ -500,72 +468,9 @@ fn apply_one(world: &mut World, mods: &mut Mods, id: &str, command: Command) ->
.id(),
mesh: Some(mesh.id()),
material: Some(material.id()),
attachment: None,
};
mods.owned.insert(key, owned);
}
Command::HeldCube {
bone,
offset,
size,
color,
..
} => {
let key = key.unwrap();
let bone_index = world
.resource::<crate::physics::SkaterRuntime>()
.animation
.evaluator
.frames
.bone_names
.iter()
.position(|name| name.eq_ignore_ascii_case(&bone))
.ok_or_else(|| format!("Unknown held-cube bone {bone}"))?;
let transform = Transform::from_translation(Vec3::from_array(offset))
.with_scale(Vec3::from_array(size));
if let Some(owned) = mods.owned.get(&key) {
if owned.mesh.is_some() && owned.attachment == Some(bone_index) {
*world.get_mut::<Transform>(owned.entity).unwrap() = transform;
if let Some(material) = owned.material {
if let Some(m) = world
.resource_mut::<Assets<StandardMaterial>>()
.get_mut(material)
{
m.base_color = Color::srgb(color[0], color[1], color[2]);
}
}
return Ok(());
}
}
retire(world, mods, &key);
let mesh = world
.resource_mut::<Assets<Mesh>>()
.add(Cuboid::new(1., 1., 1.));
let material = world
.resource_mut::<Assets<StandardMaterial>>()
.add(StandardMaterial {
base_color: Color::srgb(color[0], color[1], color[2]),
..default()
});
let entity = world
.spawn((
Mesh3d(mesh.clone()),
MeshMaterial3d(material.clone()),
transform,
Visibility::Hidden,
HeldAttachment { bone: bone_index },
))
.id();
mods.owned.insert(
key,
Owned {
entity,
mesh: Some(mesh.id()),
material: Some(material.id()),
attachment: Some(bone_index),
},
);
}
Command::Teleport {
position,
heading,
-3
View File
@@ -7,9 +7,6 @@ sdk.scene = {}
function sdk.scene.cube(key,position,size,color)
submit{kind="cube",key=key,position=position,size=size,color=color}
end
function sdk.scene.held_cube(key,bone,offset,size,color)
submit{kind="held_cube",key=key,bone=bone,offset=offset,size=size,color=color}
end
function sdk.scene.remove(key) submit{kind="remove",key=key} end
sdk.player = {}
function sdk.player.read() return sdk.snapshot.player end
-26
View File
@@ -38,13 +38,6 @@ pub enum Command {
size: [f32; 3],
color: [f32; 3],
},
HeldCube {
key: String,
bone: String,
offset: [f32; 3],
size: [f32; 3],
color: [f32; 3],
},
Remove {
key: String,
},
@@ -81,25 +74,6 @@ impl Command {
.iter()
.all(|v| v.is_finite() && (0. ..=1.).contains(v))
}
Self::HeldCube {
key,
bone,
offset,
size,
color,
} => {
crate::schema::valid_id(key)
&& !bone.is_empty()
&& bone.len() <= 64
&& bone
.bytes()
.all(|b| b.is_ascii_alphanumeric() || b == b'_')
&& offset.iter().all(|v| v.is_finite() && v.abs() <= 10.)
&& size.iter().all(|v| v.is_finite() && *v > 0. && *v <= 10.)
&& color
.iter()
.all(|v| v.is_finite() && (0. ..=1.).contains(v))
}
Self::Remove { key } => crate::schema::valid_id(key),
Self::Teleport {
position, heading, ..
+1 -21
View File
@@ -104,26 +104,6 @@ fn libraries_are_restricted() {
);
}
#[test]
fn held_cube_command_is_typed_validated_and_queued() {
let f = Fixture::new(
"return {on_load=function() sdk.scene.held_cube('gun','RIGHTHAND',{0,-0.1,0.05},{0.1,0.3,0.1},{0.2,0.2,0.2}) end}",
);
let mut m = f.manager();
m.enable("example", true).unwrap();
assert!(matches!(
&m.commands[0].1,
Command::HeldCube { key, bone, .. } if key == "gun" && bone == "RIGHTHAND"
));
let f = Fixture::new(
"return {on_load=function() sdk.scene.held_cube('gun','RIGHT-HAND',{0,0,0},{0.1,0.3,0.1},{1,1,1}) end}",
);
let mut m = f.manager();
m.enable("example", true).unwrap();
assert!(!m.packages["example"].running());
assert!(m.commands.is_empty());
}
#[test]
fn immediate_settings_persist_and_validate() {
let f = Fixture::new(
"return {on_settings=function(e) sdk.log(tostring(sdk.settings.count)..':'..e.key) end}",
@@ -172,7 +152,7 @@ fn examples_load_and_run() {
m.scan(true);
assert!(m.diagnostics.is_empty(), "{:?}", m.diagnostics);
let ids: Vec<_> = m.packages.keys().cloned().collect();
assert_eq!(ids, vec!["community.mario-kart", "community.native-trainer", "community.zombie-shooter"]);
assert_eq!(ids, vec!["community.mario-kart", "community.native-trainer"]);
for id in ids {
m.enable(&id, true).unwrap();
for _ in 0..5 {