minor
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 295 B |
@@ -70,19 +70,33 @@ 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() {
|
||||||
// Example: pig drops raw meat
|
if let Ok(mut rng) = rng_q.single_mut() {
|
||||||
spawn_prefab(
|
if rng.random_range(0..10) <= 5 {
|
||||||
&mut commands,
|
// Example: pig drops raw meat
|
||||||
&asset_server,
|
spawn_prefab(
|
||||||
MiscPrefab::RawMeat,
|
&mut commands,
|
||||||
transform.translation,
|
&asset_server,
|
||||||
&mut tilemap,
|
MiscPrefab::RawMeat,
|
||||||
);
|
transform.translation,
|
||||||
|
&mut tilemap,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
//example: pig drops a coin
|
||||||
|
spawn_prefab(
|
||||||
|
&mut commands,
|
||||||
|
&asset_server,
|
||||||
|
MiscPrefab::Coin,
|
||||||
|
transform.translation,
|
||||||
|
&mut tilemap,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user