@@ 55,6 55,8 @@ pub struct DicePluginConfig {
pub override_face_positions: HashMap<DieVariant, HashMap<u8, u8>>,
/// Scale overrides, used to size the dice.
pub override_scales: HashMap<DieVariant, f32>,
+ /// Weight overrides, used to set die weights (mass).
+ pub override_weights: HashMap<DieVariant, f32>,
}
#[derive(Reflect, Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ 154,6 156,11 @@ fn throw_die(
None => Vec3::splat(1.0),
};
+ let mass = match r_config.override_weights.get(&trigger.variant) {
+ Some(mass) => Mass(*mass),
+ None => Mass(1.0),
+ };
+
let mut die = commands.spawn((
Visibility::Inherited,
// Place the mesh in a child to allow correcting the rotation.
@@ 175,6 182,7 @@ fn throw_die(
RigidBody::Dynamic,
Collider::convex_hull_from_mesh(mesh).unwrap(),
angular_velocity,
+ mass,
Die::new(trigger.id),
));
@@ 165,6 165,15 @@ fn setup(
(DieVariant::D12, 0.8),
(DieVariant::D20, 0.8),
]),
+ override_weights: HashMap::from([
+ (DieVariant::D4, 10.0),
+ (DieVariant::D6, 10.0),
+ (DieVariant::D8, 10.0),
+ (DieVariant::D10, 10.0),
+ (DieVariant::D10P, 10.0),
+ (DieVariant::D12, 10.0),
+ (DieVariant::D20, 10.0),
+ ]),
});
}