This commit is contained in:
2025-09-14 19:04:34 +01:00
parent 4c4c985be3
commit 975ac20876
3 changed files with 24 additions and 14 deletions
+22 -8
View File
@@ -70,19 +70,33 @@ pub fn pig_drop_system(
time: Res<Time>,
mut pigs: Query<(&mut PigDropTimer, &Transform)>,
mut tilemap: ResMut<tilemap::TileMap>,
mut rng_q: Query<&mut Entropy<WyRand>, With<Global>>,
) {
for (mut timer, transform) in &mut pigs {
timer.tick(time.delta());
if timer.just_finished() {
// Example: pig drops raw meat
spawn_prefab(
&mut commands,
&asset_server,
MiscPrefab::RawMeat,
transform.translation,
&mut tilemap,
);
if let Ok(mut rng) = rng_q.single_mut() {
if rng.random_range(0..10) <= 5 {
// Example: pig drops raw meat
spawn_prefab(
&mut commands,
&asset_server,
MiscPrefab::RawMeat,
transform.translation,
&mut tilemap,
);
} else {
//example: pig drops a coin
spawn_prefab(
&mut commands,
&asset_server,
MiscPrefab::Coin,
transform.translation,
&mut tilemap,
);
}
}
}
}
}