use bevy::prelude::*;
use bevy_ecs_tilemap::TilemapStage;
#[derive(Debug, Clone, PartialEq, Eq, Hash, StageLabel)]
pub struct TilesetMapStage;
#[derive(SystemLabel, Clone, Debug, Hash, Eq, PartialEq)]
pub enum TilesetMapLabel {
/// Labels the system that handles auto tile updates
UpdateAutoTiles,
/// Labels the system that handles auto tile removals
RemoveAutoTiles,
}
/// Plugin for setting up tilesets
#[derive(Default)]
pub struct TilesetMapPlugin;
impl Plugin for TilesetMapPlugin {
fn build(&self, app: &mut App) {
app.add_stage_before(TilemapStage, TilesetMapStage, SystemStage::parallel());
#[cfg(feature = "auto-tile")]
app.add_event::<crate::auto::RemoveAutoTileEvent>()
.add_system_set_to_stage(
TilesetMapStage,
SystemSet::new().with_system(
crate::auto::on_remove_auto_tile.label(TilesetMapLabel::RemoveAutoTiles),
),
)
.add_system_to_stage(
TilemapStage,
crate::auto::on_change_auto_tile
.label(TilesetMapLabel::UpdateAutoTiles)
.before(bevy_ecs_tilemap::TilemapLabel::UpdateChunkVisibility),
);
}
}``` I don't know how to update this, I've tried reading migration/updating it, brain hurty
#Update system_set stage thing to 0.10
79 messages Β· Page 1 of 1 (latest)
Why is it currently in its own stage?
I wish I could tell you
I'm updating https://github.com/MrGVSV/bevy_tileset_map
for bevy 0.10
Ping @maiden ginkgo then :p
Hm, I believe I added the stage so that changes to the tilemap would be applied before the tilemap stage runs. But it's been a while π
Also ping @barren aspen who was also working on updating this crate
Iβve since stopped working on it at least for now. I hop projects so much and lifes been hectic lmao
Haha no worries, just thought I'd get your insight if you had any
I think the main thing would be to ensure we apply_system_buffers before the tilemap stuff runs so we avoid visual flicker
What about? The sep stage?
Yeah
Then again bevy_ecs_tilemap has changed so much I'm not sure how much still applies
Right, so just stick it in the same set as the tile set plugin, see if anything breaks, and then add an apply_system_buffers in between them if needed
Was it due to autotiling?
Like so you donβt see the tiles before they update to the proper auto tiled ones
But yeah just try it in the same set as Alice said
Oh right! It's due to auto-tiling
Since basically we need to:
- Get the placed tile
- Calculate if neighbors need to be updated
- Update the map
And we want that all to happen before the next render
Otherwise, you render the placed tile, one frame of delay, and then the updated neighbors
Yeah that makes sense
I've basically worked out it all out as far as I can tell
I have like only like 5 errors now
the only thing that's really changed was the GPUAnimated
at least what I've encountered
most errors right now are talking about how it can't find Tile but I hope that's easy to fix
and how TilemapStage no longer exists in bevy_ecs_tilemap
Nice! Thanks for doing this. Both you and Vixeliz are real life savers!
I was dreading updating, especially this crate due to the bevy_ecs_tilemap changes
they also removed a trait alias but I just added that back in for ease of use
so, so far it's been pretty easy
I just don't know how the new bevy system stages work to convert them
wow Tile -> TileBundle
very easy
I haven't actually really gotten a chance to use the 0.10 changes yet, but I believe they've been replaced by system sets which are fairly similar
did something happen in 0.7 that just caused a wipeout of all of bevy_ecs_tilemap stuff
because a lot of things are just gone and I would have to rewrite the code to fix
IIRC @vapid crane tackled a rewrite around then
Prompted by changes to Bevy's rendering + accumulated tech debt
Rewrite addressed a lot of things to make the API more ergonomic. π Feel free to ping me if you have any questions.
Is there a replacement for MapTileError? I am just using bevy's asset Error rn which works (so far)
or maybe that's the intended solution
also MapQuery is gone is there a similar replacement for it?
I don't wish to rewrite all of the code if there is
same with LayerBuilder
I've briefly skimmed chunking example which was what I assume MapQuery was for based on it's docs and it seems very manual now
Everything is much more basic out of the box which gives users more control. For example the way its setup now is:
Tilemap > Tiles
If you want layers you add in your own struct to manage the layers:
MyTilemapLayers > Tilemap > Tiles
MapQuery doesn't exist
It is somewhat replaced by TileStorage
I might add in a tilemap layer struct in the future but it's pretty basic just:
const GROUND_LAYER: u32 = 0;
const TREE_LAYER: u32 = 1;
pub struct TilemapLayers {
layers: HashMap<u32, Entity>, // u32 is the layer id, Entity is the tilemap entity.
}
You can make that a bevy resource or a component and stick it on an entity.
Layers don't seem that hard I just didn't want to create new code for existing feature
MapQuery though seems like a pain to reimplement
which functions did you rely on specifically?
I did actually create a layer builder in my own game code. I don't mind sharing it here too.
notifying chunks
no need to notify chunks anymore
look at the accessing_tiles example, everything is much simpler with the TileStorage struct.
alright
I'll swap MapQuery for that
and convert all the code, and make my own layer struct
thank you
My layer builder implementation:
yay
What's the system param look like?
#[derive(SystemParam)]
pub struct TilePlacer<'w, 's> {
map_query: TileStorage,
tilesets: Tilesets<'w, 's>,
commands: Commands<'w, 's>,
/// Query used to get info about a tile
#[cfg(not(feature = "auto-tile"))]
#[allow(dead_code)]
query: Query<'w, 's, (&'static TileTextureIndex, Option<&'static AnimatedTile>)>,
/// Query used to get info about a tile
#[cfg(feature = "auto-tile")]
#[allow(dead_code)]
query: Query<
'w,
's,
(
&'static TileTextureIndex,
Option<&'static AnimatedTile>,
Option<&'static bevy_tileset::auto::AutoTileId>,
),
>,
/// Query used to get and send data for the [`RemoveAutoTileEvent`] event
#[cfg(feature = "auto-tile")]
#[allow(dead_code)]
auto_query: Query<
'w,
's,
(
&'static TilePos,
&'static TileParent,
&'static bevy_tileset::auto::AutoTileId,
),
With<Tile>,
>,
#[cfg(feature = "auto-tile")]
#[allow(dead_code)]
event_writer: EventWriter<'w, 's, crate::auto::RemoveAutoTileEvent>,
}
that's the code
TileStorage is a component on the tilemap entity. π map_query: Query<'w, 's, &'static TileStorage>,
alright thank you that worked, time to convert all of the code
Yeah I wont lie it sounds like quite the pain but I think the new API will make some stuff a lot cleaner. π
When I upgraded my game I cheated and started over fresh :p