merwaaan / bevy_spritesheet_animation

A Bevy plugin for animating sprites that are backed by spritesheets
MIT License
55 stars 4 forks source link

Allow running without bevy_render #19

Open mirsella opened 4 hours ago

mirsella commented 4 hours ago

hello

im building a 2d multiplayer game, and for example i wanted to use this plugin's event to deal damage to a target at a certain frame. my server would run in headless, without rendering or loading any texture, and so this plugin doesn't work currently without bevy_render because the 3d systems use Res<Assets<Image>>.

a feature flag, either no_bevy_render, or a 3d enabled by default, to enable 3d sprites support.

a step further if you think it's good, would be a runtime config on the SpritesheetAnimationPlugin to enable or not the 3d sprites support. this is useful, to support on the same binary, headless and full game rendering. (server headfull, and server headless without render) would be just a 3d: bool field, enabled by default with a Default impl on the struct.

of course, i would be happy to do the PR if you accept these features. They shouldn't change the default behavior of this crate, but only allow it to be more flexible.

thanks

merwaaan commented 3 hours ago

That's an interesting use case, the suggested changes all sound good to me.

As you mentionned, the default configuration should enable 3D sprites so that everything work out of the box for the most common use cases.

Don't hesitate to make a PR.

mirsella commented 2 hours ago

ill do a pr soon !

what method do you prefer ? the feature flag or plugin option ? the plugin option is more flexible:

this is useful, to support on the same binary headless and full game rendering

but is a breaking change since users now have to use SpritesheetAnimationPlugin::default() instead of just SpritesheetAnimationPlugin when adding the plugin. imo this is not a big deal and a lot of plugins does this, including bevy's own plugin.