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
Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 295 B

+14
View File
@@ -70,11 +70,14 @@ pub fn pig_drop_system(
time: Res<Time>, time: Res<Time>,
mut pigs: Query<(&mut PigDropTimer, &Transform)>, mut pigs: Query<(&mut PigDropTimer, &Transform)>,
mut tilemap: ResMut<tilemap::TileMap>, mut tilemap: ResMut<tilemap::TileMap>,
mut rng_q: Query<&mut Entropy<WyRand>, With<Global>>,
) { ) {
for (mut timer, transform) in &mut pigs { for (mut timer, transform) in &mut pigs {
timer.tick(time.delta()); timer.tick(time.delta());
if timer.just_finished() { if timer.just_finished() {
if let Ok(mut rng) = rng_q.single_mut() {
if rng.random_range(0..10) <= 5 {
// Example: pig drops raw meat // Example: pig drops raw meat
spawn_prefab( spawn_prefab(
&mut commands, &mut commands,
@@ -83,6 +86,17 @@ pub fn pig_drop_system(
transform.translation, transform.translation,
&mut tilemap, &mut tilemap,
); );
} else {
//example: pig drops a coin
spawn_prefab(
&mut commands,
&asset_server,
MiscPrefab::Coin,
transform.translation,
&mut tilemap,
);
}
}
} }
} }
} }
+2 -6
View File
@@ -6,7 +6,7 @@ use crate::{entities::item::Item, game};
#[derive(Resource, Default, Clone)] #[derive(Resource, Default, Clone)]
pub struct TileMap { pub struct TileMap {
pub floor_tiles: HashMap<IVec3, (i32, bool, bool, bool, i32, [u32; 8])>, //id, canStandIn, canStandOn, visiblyTransparent, astar_weight, visible_range pub floor_tiles: HashMap<IVec3, (i32, bool, bool, bool, i32, [u32; 8])>, //id, canStandIn, canStandOn, visiblyTransparent, astar_weight, visible_range
pub fixture_tiles: HashMap<IVec3, (i32, bool, bool, [u32; 8])>, // id, canStandIn, canStandOn, visible_range pub fixture_tiles: HashMap<IVec3, (i32, bool, bool, [u32; 8])>, // id, canStandIn, canStandOn, visible_range //TODO - consider moving alot of this into the fixtures components
pub item_tiles: HashMap<IVec3, Vec<u32>>, // Entity.id's of items on this tile pub item_tiles: HashMap<IVec3, Vec<u32>>, // Entity.id's of items on this tile
} }
@@ -25,6 +25,7 @@ impl Default for ItemRotationTimer {
} }
} }
// TODO - broken, doesnt work with the visibleGameEntity system
pub fn item_tile_management_system( pub fn item_tile_management_system(
time: Res<Time>, time: Res<Time>,
mut tilemap: ResMut<TileMap>, mut tilemap: ResMut<TileMap>,
@@ -32,11 +33,6 @@ pub fn item_tile_management_system(
z_index: Res<game::ZIndex>, z_index: Res<game::ZIndex>,
mut visibility_query: Query<&mut Visibility, With<Item>>, mut visibility_query: Query<&mut Visibility, With<Item>>,
) { ) {
println!(
"{} items accross {} tiles",
visibility_query.iter().count(),
tilemap.item_tiles.len()
);
rotation_timer.timer.tick(time.delta()); rotation_timer.timer.tick(time.delta());
let mut tiles_to_remove = Vec::new(); let mut tiles_to_remove = Vec::new();