Skip to content

Commit

Permalink
Finish upgrading
Browse files Browse the repository at this point in the history
  • Loading branch information
qhdwight committed Dec 21, 2023
1 parent ed543b8 commit 495b57d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 34 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 4 additions & 12 deletions src/qgame/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use bevy::{
};
use flagset::{flags, FlagSet};
use serde::{Deserialize, Serialize};
use thiserror::Error;

use crate::RonLoaderError;

flags! {
pub enum PlayerInputFlags: u32 {
Expand Down Expand Up @@ -152,20 +153,11 @@ pub fn player_input_system(
#[derive(Default)]
pub struct ConfigAssetLoader;

#[derive(Debug, Error)]
enum RonLoaderError {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
RonSpannedError(#[from] ron::error::SpannedError),
#[error(transparent)]
LoadDirectError(#[from] bevy::asset::LoadDirectError),
}

impl AssetLoader for ConfigAssetLoader {
type Asset = Config;
type Settings = ();
type Error = RonLoaderError;

fn load<'a>(
&'a self,
reader: &'a mut Reader,
Expand All @@ -181,6 +173,6 @@ impl AssetLoader for ConfigAssetLoader {
}

fn extensions(&self) -> &[&str] {
&["config.toml"]
&["config.ron"]
}
}
27 changes: 9 additions & 18 deletions src/qgame/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ use std::{
};

use bevy::{
asset::{AssetLoader, LoadContext},
asset::{
AssetLoader,
AsyncReadExt,
io::Reader,
LoadContext,
},
prelude::*,
reflect::TypePath,
utils::{BoxedFuture, HashMap},
};
use bevy::asset::AsyncReadExt;
use bevy::asset::io::Reader;
use bevy_rapier3d::prelude::*;
use serde::{Deserialize, Serialize};
use smartstring::alias::String;
use thiserror::Error;

use crate::{PlayerInput, PlayerInputFlags};
use crate::{PlayerInput, PlayerInputFlags, RonLoaderError};

const EQUIPPING_STATE: &str = "equipping";
const EQUIPPED_STATE: &str = "equipped";
Expand Down Expand Up @@ -107,20 +109,9 @@ impl Plugin for InventoryPlugin {
#[derive(Default)]
pub struct GunPropsAssetLoader;

#[derive(Debug, Error)]
enum RonLoaderError {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
RonSpannedError(#[from] ron::error::SpannedError),
#[error(transparent)]
LoadDirectError(#[from] bevy::asset::LoadDirectError),
}

impl AssetLoader for GunPropsAssetLoader {
type Asset = GunProps;
type Settings = ();

type Error = RonLoaderError;

fn load<'a>(
Expand All @@ -138,7 +129,7 @@ impl AssetLoader for GunPropsAssetLoader {
}

fn extensions(&self) -> &[&str] {
&["config.toml"]
&["config.ron"]
}
}

Expand Down Expand Up @@ -394,7 +385,7 @@ pub fn render_inventory_sys(
if let Ok(item) = item_query.get(*item_ent) {
let is_equipped = inv.equipped_slot == Some(item.inv_slot);
let mut transform = Transform::default();
let scene_handle = asset_server.load(format!("models/{}.glb#Scene0", item.name).as_str());
let scene_handle = asset_server.load(format!("models/{}.glb#Scene0", item.name));
if is_equipped {
transform = camera_query.single().mul_transform(Transform::from_xyz(0.4, -0.3, -1.0));
}
Expand Down
11 changes: 11 additions & 0 deletions src/qgame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use bevy::{
renderer::{RenderDevice, RenderQueue},
},
};
use thiserror::Error;

pub use controller::*;
pub use input::*;
Expand All @@ -23,6 +24,16 @@ mod inventory;
mod lookup;
mod voxel;

#[derive(Debug, Error)]
pub enum RonLoaderError {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
RonSpannedError(#[from] ron::error::SpannedError),
#[error(transparent)]
LoadDirectError(#[from] bevy::asset::LoadDirectError),
}

pub struct BufVec<T: Pod> {
read_only: bool,
buffer_capacity: usize,
Expand Down

0 comments on commit 495b57d

Please sign in to comment.