Skip to content

Commit

Permalink
Merge branch 'Lea-fish:main' into more_inventorys
Browse files Browse the repository at this point in the history
  • Loading branch information
cooltexture1 authored Mar 9, 2024
2 parents 2ffd6b6 + 2c5e7ec commit df08b9a
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 110 deletions.
11 changes: 5 additions & 6 deletions src/entity/block_entity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
pub mod sign;

use crate::ecs;
use crate::shared::Position;
use crate::world::block::Block;
use bevy_ecs::prelude::*;

pub fn add_systems(m: &mut ecs::Manager) {
sign::add_systems(m);
pub fn add_systems(sched: &mut Schedule) {
sign::add_systems(sched);
}

pub enum BlockEntityType {
Expand Down Expand Up @@ -38,12 +37,12 @@ impl BlockEntityType {
}
}

pub fn create_entity(&self, m: &mut ecs::Manager, pos: Position) -> Entity {
let mut e = m.world.spawn_empty();
pub fn create_entity(&self, cmds: &mut Commands, pos: Position) -> Entity {
let mut e = cmds.spawn_empty();
e.insert(pos);
let e = e.id();
match *self {
BlockEntityType::Sign => sign::init_entity(m, e),
BlockEntityType::Sign => sign::init_entity(cmds, e),
}
e
}
Expand Down
9 changes: 4 additions & 5 deletions src/entity/block_entity/sign.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ecs::{self, SystemExecStage};
use crate::ecs::SystemExecStage;
use crate::format::{self, Component};
use crate::render;
use crate::render::model::{self, FormatState};
Expand All @@ -9,8 +9,7 @@ use crate::world::block::Block;
use bevy_ecs::prelude::*;
use std::sync::Arc;

pub fn add_systems(m: &mut ecs::Manager) {
let mut sched = m.entity_schedule.write();
pub fn add_systems(sched: &mut Schedule) {
sched /*sync*/
.add_systems(
render_sign
Expand All @@ -24,8 +23,8 @@ pub fn add_systems(m: &mut ecs::Manager) {
);
}

pub fn init_entity(m: &mut ecs::Manager, e: Entity) {
m.world.get_entity_mut(e).unwrap().insert(SignInfo {
pub fn init_entity(cmds: &mut Commands, e: Entity) {
cmds.get_entity(e).unwrap().insert(SignInfo {
model: None,
lines: [
Component::new(format::ComponentType::new("", None)),
Expand Down
20 changes: 8 additions & 12 deletions src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,16 @@ srel!(28.0, 20.0, 4.0, 12.0), // East | 0 1 0 | 0 0 1 OR 1 0 1 | 0 0 1
[0.0, 0.0, 0.0, 1.0],
*/

pub fn add_systems(m: &mut Manager) {
m.schedule
.write()
.add_systems(systems::update_last_position.in_set(SystemExecStage::Normal));

player::add_systems(m);
let mut entity_sched = m.schedule.write();
entity_sched
pub fn add_systems(sched: &mut Schedule) {
sched.add_systems(systems::update_last_position.in_set(SystemExecStage::Normal));

player::add_systems(sched);
sched
.add_systems(systems::apply_velocity.in_set(SystemExecStage::Normal))
.add_systems(systems::apply_gravity.in_set(SystemExecStage::Normal))
.add_systems(systems::apply_digging.in_set(SystemExecStage::Normal));

entity_sched /*sync*/
sched /*sync*/
.add_systems(
systems::lerp_position
.in_set(SystemExecStage::Render)
Expand All @@ -84,9 +81,8 @@ pub fn add_systems(m: &mut Manager) {
.after(SystemExecStage::Normal),
);

drop(entity_sched);
block_entity::add_systems(m);
crate::particle::block_break_effect::add_systems(m);
block_entity::add_systems(sched);
crate::particle::block_break_effect::add_systems(sched);
}

/// Location of an entity in the world.
Expand Down
7 changes: 3 additions & 4 deletions src/entity/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ use std::hash::BuildHasherDefault;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

pub fn add_systems(m: &mut Manager) {
pub fn add_systems(sched: &mut Schedule) {
// TODO: Check sync/async usage!
m.schedule.write().add_systems(
sched.add_systems(
handle_movement
.in_set(SystemExecStage::Render)
.after(SystemExecStage::Normal),
);
// let sys = ParticleRenderer::new(m);
// m.add_render_system(sys);
let mut entity_sched = m.schedule.write();
entity_sched
sched
.add_systems(
update_render_players
.in_set(SystemExecStage::Render)
Expand Down
7 changes: 3 additions & 4 deletions src/particle/block_break_effect.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ecs::{Manager, SystemExecStage};
use crate::ecs::SystemExecStage;
use crate::render;
use crate::render::model::ModelHandle;
use crate::render::{model, Renderer};
Expand All @@ -7,11 +7,10 @@ use bevy_ecs::prelude::*;
use cgmath::{Decomposed, Matrix4, Quaternion, Rad, Rotation3, Vector3};
use std::sync::Arc;

pub fn add_systems(m: &mut Manager) {
pub fn add_systems(sched: &mut Schedule) {
// TODO: Check sync/async usage!
/*sync*/
m.entity_schedule
.write()
sched
.add_systems(
effect_added
.in_set(SystemExecStage::Render)
Expand Down
Loading

0 comments on commit df08b9a

Please sign in to comment.