Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Indy2222 committed Jul 21, 2023
1 parent 41afd6b commit 358e26c
Show file tree
Hide file tree
Showing 29 changed files with 408 additions and 524 deletions.
60 changes: 32 additions & 28 deletions crates/camera/src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ use std::f32::consts::FRAC_PI_2;
use bevy::prelude::*;
use de_conf::{CameraConf, Configuration};
use de_core::{
baseset::GameSet, cleanup::DespawnOnGameExit, events::ResendEventPlugin, gamestate::GameState,
projection::ToAltitude, state::AppState,
baseset::{Input, Movement, PreMovement},
cleanup::DespawnOnGameExit,
events::ResendEventPlugin,
gamestate::GameState,
projection::ToAltitude,
state::AppState,
};
use de_map::size::MapBounds;
use de_terrain::{TerrainCollider, MAX_ELEVATION};
Expand Down Expand Up @@ -48,14 +52,7 @@ impl Plugin for CameraPlugin {
.add_systems(OnEnter(AppState::InGame), setup)
.add_systems(OnExit(AppState::InGame), cleanup)
.add_systems(
GameSet::PreMovement,
update_focus
.run_if(in_state(GameState::Playing))
.run_if(on_event::<FocusInvalidatedEvent>())
.in_set(InternalCameraSet::UpdateFocus),
)
.add_systems(
GameSet::Input,
Input,
(
handle_horizontal_events
.run_if(in_state(GameState::Playing))
Expand All @@ -72,8 +69,12 @@ impl Plugin for CameraPlugin {
),
)
.add_systems(
GameSet::PreMovement,
PreMovement,
(
update_focus
.run_if(in_state(GameState::Playing))
.run_if(on_event::<FocusInvalidatedEvent>())
.in_set(InternalCameraSet::UpdateFocus),
process_move_focus_events
.run_if(in_state(GameState::Playing))
.in_set(InternalCameraSet::MoveFocus)
Expand All @@ -84,23 +85,26 @@ impl Plugin for CameraPlugin {
.after(InternalCameraSet::MoveFocus),
),
)
.add_system(GameSet::Movement(
zoom.run_if(in_state(GameState::Playing))
.in_set(InternalCameraSet::Zoom),
pivot
.run_if(in_state(GameState::Playing))
.run_if(
resource_exists_and_changed::<DesiredOffNadir>()
.or_else(resource_exists_and_changed::<DesiredAzimuth>()),
)
.in_set(InternalCameraSet::Pivot),
move_horizontaly
.run_if(in_state(GameState::Playing))
// Zooming changes camera focus point so do it
// after other types of camera movement.
.after(InternalCameraSet::Zoom)
.after(InternalCameraSet::Pivot),
));
.add_system(
Movement,
(
zoom.run_if(in_state(GameState::Playing))
.in_set(InternalCameraSet::Zoom),
pivot
.run_if(in_state(GameState::Playing))
.run_if(
resource_exists_and_changed::<DesiredOffNadir>()
.or_else(resource_exists_and_changed::<DesiredAzimuth>()),
)
.in_set(InternalCameraSet::Pivot),
move_horizontaly
.run_if(in_state(GameState::Playing))
// Zooming changes camera focus point so do it
// after other types of camera movement.
.after(InternalCameraSet::Zoom)
.after(InternalCameraSet::Pivot),
),
);
}
}

Expand Down
25 changes: 9 additions & 16 deletions crates/camera/src/distance.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use bevy::prelude::*;
use de_core::{
baseset::GameSet,
objects::{MovableSolid, StaticSolid},
state::AppState,
};
Expand All @@ -9,21 +8,15 @@ pub(crate) struct DistancePlugin;

impl Plugin for DistancePlugin {
fn build(&self, app: &mut App) {
app.add_system(
init::<MovableSolid>
.in_base_set(GameSet::PostUpdate)
.run_if(in_state(AppState::InGame)),
)
.add_system(
init::<StaticSolid>
.in_base_set(GameSet::PostUpdate)
.run_if(in_state(AppState::InGame)),
)
.add_system(
update
.in_base_set(GameSet::PostUpdate)
.run_if(in_state(AppState::InGame))
.in_set(DistanceSet::Update),
app.add_systems(
PostUPdate,
(
init::<MovableSolid>.run_if(in_state(AppState::InGame)),
init::<StaticSolid>.run_if(in_state(AppState::InGame)),
update
.run_if(in_state(AppState::InGame))
.in_set(DistanceSet::Update),
),
);
}
}
Expand Down
48 changes: 23 additions & 25 deletions crates/combat/src/attack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{cmp::Ordering, collections::BinaryHeap};

use bevy::prelude::*;
use de_behaviour::{ChaseSet, ChaseTarget, ChaseTargetEvent};
use de_core::{baseset::GameSet, gamestate::GameState, objects::ObjectType};
use de_core::{gamestate::GameState, objects::ObjectType};
use de_index::SpatialQuery;
use de_objects::{LaserCannon, SolidObjects};
use parry3d::query::Ray;
Expand All @@ -22,31 +22,29 @@ pub(crate) struct AttackPlugin;
impl Plugin for AttackPlugin {
fn build(&self, app: &mut App) {
app.add_event::<AttackEvent>()
.add_system(
attack
.in_base_set(GameSet::PreUpdate)
.run_if(in_state(GameState::Playing))
.in_set(AttackingSet::Attack)
.before(ChaseSet::ChaseTargetEvent),
.add_systems(
PreUpdate,
(
attack
.run_if(in_state(GameState::Playing))
.in_set(AttackingSet::Attack)
.before(ChaseSet::ChaseTargetEvent),
update_positions
.run_if(in_state(GameState::Playing))
.after(AttackingSet::Attack),
),
)
.add_system(
update_positions
.in_base_set(GameSet::PreUpdate)
.run_if(in_state(GameState::Playing))
.after(AttackingSet::Attack),
)
.add_system(
charge
.in_base_set(GameSet::Update)
.run_if(in_state(GameState::Playing))
.in_set(AttackingSet::Charge),
)
.add_system(
aim_and_fire
.in_base_set(GameSet::Update)
.run_if(in_state(GameState::Playing))
.after(AttackingSet::Charge)
.before(AttackingSet::Fire),
.add_systems(
Update,
(
charge
.run_if(in_state(GameState::Playing))
.in_set(AttackingSet::Charge),
aim_and_fire
.run_if(in_state(GameState::Playing))
.after(AttackingSet::Charge)
.before(AttackingSet::Fire),
),
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/combat/src/laser.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::prelude::*;
use de_core::{baseset::GameSet, gamestate::GameState};
use de_core::gamestate::GameState;
use de_objects::Health;
use de_signs::UpdateBarValueEvent;
use de_spawner::SpawnerSet;
Expand All @@ -11,9 +11,9 @@ pub(crate) struct LaserPlugin;

impl Plugin for LaserPlugin {
fn build(&self, app: &mut App) {
app.add_event::<LaserFireEvent>().add_system(
fire.in_base_set(GameSet::Update)
.run_if(in_state(GameState::Playing))
app.add_event::<LaserFireEvent>().add_systems(
Update,
fire.run_if(in_state(GameState::Playing))
.in_set(AttackingSet::Fire)
.before(SpawnerSet::Destroyer),
);
Expand Down
23 changes: 9 additions & 14 deletions crates/combat/src/trail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use bevy::{
},
},
};
use de_core::{
baseset::GameSet, cleanup::DespawnOnGameExit, gamestate::GameState, state::AppState,
};
use de_core::{cleanup::DespawnOnGameExit, gamestate::GameState, state::AppState};
use parry3d::query::Ray;

const TRAIL_LIFESPAN: Duration = Duration::from_millis(500);
Expand All @@ -25,17 +23,14 @@ impl Plugin for TrailPlugin {
fn build(&self, app: &mut App) {
app.add_plugin(MaterialPlugin::<TrailMaterial>::default())
.add_event::<TrailEvent>()
.add_system(setup.in_schedule(OnEnter(AppState::InGame)))
.add_system(cleanup.in_schedule(OnExit(AppState::InGame)))
.add_system(
spawn
.in_base_set(GameSet::PostUpdate)
.run_if(in_state(GameState::Playing)),
)
.add_system(
update
.in_base_set(GameSet::PostUpdate)
.run_if(in_state(GameState::Playing)),
.add_systems(OnEnter(AppState::InGame), setup)
.add_systems(OnExit(AppState::InGame), cleanup)
.add_systems(
PostUpdate,
(
spawn.run_if(in_state(GameState::Playing)),
update.run_if(in_state(GameState::Playing)),
),
);
}
}
Expand Down
54 changes: 19 additions & 35 deletions crates/construction/src/manufacturing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{collections::VecDeque, time::Duration};
use ahash::AHashMap;
use bevy::prelude::*;
use de_core::{
baseset::GameSet,
cleanup::DespawnOnGameExit,
gamestate::GameState,
gconfig::GameConfig,
Expand Down Expand Up @@ -32,41 +31,26 @@ impl Plugin for ManufacturingPlugin {
app.add_event::<EnqueueAssemblyEvent>()
.add_event::<ChangeDeliveryLocationEvent>()
.add_event::<DeliverEvent>()
.add_system(
configure
.in_base_set(GameSet::PostUpdate)
.run_if(in_state(AppState::InGame)),
.add_systems(
PreUpdate,
(
change_locations
.run_if(in_state(GameState::Playing))
.in_set(ManufacturingSet::ChangeLocations),
check_spawn_locations
.run_if(in_state(GameState::Playing))
.before(ManufacturingSet::Produce),
produce
.run_if(in_state(GameState::Playing))
.in_set(ManufacturingSet::Produce),
deliver
.run_if(in_state(GameState::Playing))
.after(ManufacturingSet::ChangeLocations)
.after(ManufacturingSet::Produce),
),
)
.add_system(
change_locations
.in_base_set(GameSet::PreUpdate)
.run_if(in_state(GameState::Playing))
.in_set(ManufacturingSet::ChangeLocations),
)
.add_system(
enqueue
.in_base_set(GameSet::Update)
.run_if(in_state(GameState::Playing)),
)
.add_system(
check_spawn_locations
.in_base_set(GameSet::PreUpdate)
.run_if(in_state(GameState::Playing))
.before(ManufacturingSet::Produce),
)
.add_system(
produce
.in_base_set(GameSet::PreUpdate)
.run_if(in_state(GameState::Playing))
.in_set(ManufacturingSet::Produce),
)
.add_system(
deliver
.in_base_set(GameSet::PreUpdate)
.run_if(in_state(GameState::Playing))
.after(ManufacturingSet::ChangeLocations)
.after(ManufacturingSet::Produce),
);
.add_systems(Update, enqueue.run_if(in_state(GameState::Playing)))
.add_systems(PostUpdate, configure.run_if(in_state(AppState::InGame)));
}
}

Expand Down
32 changes: 14 additions & 18 deletions crates/controller/src/commands/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bevy::prelude::*;
use de_behaviour::ChaseTargetEvent;
use de_combat::AttackEvent;
use de_construction::{AssemblyLine, ChangeDeliveryLocationEvent};
use de_core::{baseset::GameSet, gamestate::GameState, objects::MovableSolid};
use de_core::{baseset::Input, gamestate::GameState, objects::MovableSolid};
use de_pathing::{PathQueryProps, PathTarget, UpdateEntityPath};
use glam::Vec2;

Expand All @@ -15,23 +15,19 @@ impl Plugin for ExecutorPlugin {
app.add_event::<SendSelectedEvent>()
.add_event::<DeliveryLocationSelectedEvent>()
.add_event::<GroupAttackEvent>()
.add_system(
send_selected_system
.in_base_set(GameSet::Input)
.run_if(in_state(GameState::Playing))
.in_set(CommandsSet::SendSelected),
)
.add_system(
delivery_location_system
.in_base_set(GameSet::Input)
.run_if(in_state(GameState::Playing))
.in_set(CommandsSet::DeliveryLocation),
)
.add_system(
attack_system
.in_base_set(GameSet::Input)
.run_if(in_state(GameState::Playing))
.in_set(CommandsSet::Attack),
.add_systems(
Input,
(
send_selected_system
.run_if(in_state(GameState::Playing))
.in_set(CommandsSet::SendSelected),
delivery_location_system
.run_if(in_state(GameState::Playing))
.in_set(CommandsSet::DeliveryLocation),
attack_system
.run_if(in_state(GameState::Playing))
.in_set(CommandsSet::Attack),
),
);
}
}
Expand Down
Loading

0 comments on commit 358e26c

Please sign in to comment.