Fix fighter material not removing the original material. (#92)
CI / build-and-test (push) Failing after 16s
CI / production-build (push) Successful in 12m10s

Reviewed-on: #92
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #92.
This commit is contained in:
2026-10-13 08:24:45 +00:00
committed by EIREXE
parent f53e67d8ad
commit 4fe1b24b1a
+27 -10
View File
@@ -1,10 +1,17 @@
use bevy::{gltf::GltfMaterialName, pbr::{ExtendedMaterial, MaterialExtension}, prelude::*, render::render_resource::AsBindGroup, shader::ShaderRef, world_serialization::WorldInstanceReady}; use bevy::{
gltf::GltfMaterialName,
pbr::{ExtendedMaterial, MaterialExtension},
prelude::*,
render::render_resource::AsBindGroup,
shader::ShaderRef,
world_serialization::WorldInstanceReady,
};
pub type FighterMaterial = ExtendedMaterial<StandardMaterial, FighterMaterialExtension>; pub type FighterMaterial = ExtendedMaterial<StandardMaterial, FighterMaterialExtension>;
#[derive(Component)] #[derive(Component)]
pub struct FighterMesh { pub struct FighterMesh {
pub fighter: Entity pub fighter: Entity,
} }
#[derive(Asset, AsBindGroup, Reflect, Debug, Clone, Default)] #[derive(Asset, AsBindGroup, Reflect, Debug, Clone, Default)]
@@ -64,12 +71,22 @@ pub fn bind_fighter_material(
continue; continue;
}; };
commands.entity(entity).insert((MeshMaterial3d(asset_materials.add(ExtendedMaterial { commands
base: StandardMaterial { .entity(entity)
// can be used in forward or deferred mode .remove::<MeshMaterial3d<StandardMaterial>>()
..original_material.clone() .insert((
}, MeshMaterial3d(asset_materials.add(ExtendedMaterial {
extension: FighterMaterialExtension::new(bevy::color::palettes::css::BLUE.into()) base: StandardMaterial {
})), FighterMesh { fighter: scene_ready.entity })); // can be used in forward or deferred mode
..original_material.clone()
},
extension: FighterMaterialExtension::new(
bevy::color::palettes::css::BLUE.into(),
),
})),
FighterMesh {
fighter: scene_ready.entity,
},
));
} }
} }