mirror of https://github.com/Leinnan/rpack.git
RpackAtlases system param
This commit is contained in:
parent
71908c659b
commit
d2dfeea6c2
|
|
@ -0,0 +1,17 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [0.1.1] - 2025-01-27
|
||||
|
||||
### Added
|
||||
|
||||
- `RpackAtlases` system param.
|
||||
|
||||
## [0.1.0] - 2025-01-14
|
||||
|
||||
- initial version
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "bevy_rpack"
|
||||
description = "Bevy plugin with rpack atlas support"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/Leinnan/rpack.git"
|
||||
homepage = "https://github.com/Leinnan/rpack"
|
||||
|
|
|
|||
|
|
@ -22,21 +22,21 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||
|
||||
fn on_loaded(
|
||||
mut ev_asset: EventReader<AssetEvent<RpackAtlasAsset>>,
|
||||
assets: Res<Assets<RpackAtlasAsset>>,
|
||||
atlases: RpackAtlases,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
for ev in ev_asset.read() {
|
||||
let AssetEvent::LoadedWithDependencies { id: _ } = ev else {
|
||||
if !matches!(ev, AssetEvent::LoadedWithDependencies { id: _ }) {
|
||||
continue;
|
||||
};
|
||||
}
|
||||
|
||||
if let Ok(sprite) = assets.try_make_sprite("agents/spaceAstronauts_005") {
|
||||
if let Ok(sprite) = atlases.try_make_sprite("agents/spaceAstronauts_005") {
|
||||
commands.spawn(Sprite {
|
||||
color: Color::linear_rgb(1.0, 0.0, 0.0),
|
||||
..sprite
|
||||
});
|
||||
};
|
||||
if let Ok(image_node) = assets.try_make_image_node("agents/spaceShips_006") {
|
||||
if let Ok(image_node) = atlases.try_make_image_node("agents/spaceShips_006") {
|
||||
commands.spawn(image_node);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ pub mod prelude {
|
|||
/// Provides easy access to `Rpack` asset-related functionality in a Bevy application.
|
||||
pub use super::plugin::{
|
||||
RpackAssetHelper, RpackAssetPlugin, RpackAtlasAsset, RpackAtlasAssetError,
|
||||
RpackAtlasAssetLoader, RpackAtlasError,
|
||||
RpackAtlasAssetLoader, RpackAtlasError, RpackAtlases,
|
||||
};
|
||||
/// Re-exports core types for working with texture atlases.
|
||||
pub use super::{AtlasAsset, AtlasFrame, SerializableRect};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use crate::{AtlasAsset, SerializableRect};
|
||||
use bevy::asset::{AssetLoader, AsyncReadExt};
|
||||
use bevy::ecs::system::SystemParam;
|
||||
use bevy::image::ImageSampler;
|
||||
use bevy::{prelude::*, utils::HashMap};
|
||||
use thiserror::Error;
|
||||
|
|
@ -38,6 +39,10 @@ impl From<SerializableRect> for URect {
|
|||
}
|
||||
}
|
||||
|
||||
/// SystemParam helper for accessing and creating components from `Rpack` atlas data.
|
||||
#[derive(SystemParam, DerefMut, Deref)]
|
||||
pub struct RpackAtlases<'w>(pub Res<'w, Assets<RpackAtlasAsset>>);
|
||||
|
||||
/// A helper trait for accessing and creating components from `Rpack` atlas data.
|
||||
#[allow(dead_code)]
|
||||
pub trait RpackAssetHelper {
|
||||
|
|
|
|||
|
|
@ -27,4 +27,4 @@ clap = { version = "4", features = ["derive"], optional = true }
|
|||
glob = { version = "0.3", optional = true }
|
||||
basis-universal = { version = "0.3.1", optional = true }
|
||||
image_dds = { version = "0.7", optional = true }
|
||||
anyhow = "1"
|
||||
anyhow = "1"
|
||||
|
|
|
|||
Loading…
Reference in New Issue