1use nightshade::prelude::*;
6
7pub fn set_morph_weight(world: &mut World, entity: Entity, index: u32, weight: f32) {
11 if let Some(weights) = world.get_mut::<nightshade::ecs::morph::components::MorphWeights>(entity)
12 {
13 weights.set_weight(index as usize, weight);
14 }
15}
16
17pub fn morph_weight(world: &World, entity: Entity, index: u32) -> f32 {
19 world
20 .get::<nightshade::ecs::morph::components::MorphWeights>(entity)
21 .map(|weights| weights.get_weight(index as usize))
22 .unwrap_or(0.0)
23}
24
25pub fn morph_target_count(world: &World, entity: Entity) -> usize {
27 world
28 .get::<nightshade::ecs::morph::components::MorphWeights>(entity)
29 .map(|weights| weights.weight_count())
30 .unwrap_or(0)
31}
32
33pub fn set_morph_weights(world: &mut World, entity: Entity, weights: &[f32]) {
35 if let Some(component) =
36 world.get_mut::<nightshade::ecs::morph::components::MorphWeights>(entity)
37 {
38 for (index, value) in weights.iter().enumerate() {
39 component.set_weight(index, *value);
40 }
41 }
42}