all systems updated to take parameters rather than world
This commit is contained in:
@@ -1,29 +1,45 @@
|
||||
use glam::Vec3;
|
||||
|
||||
use crate::components::camera::CameraComponent;
|
||||
use crate::components::FollowComponent;
|
||||
use crate::components::InputComponent;
|
||||
use crate::utility::input::InputState;
|
||||
use crate::world::World;
|
||||
use crate::world::Storage;
|
||||
|
||||
pub fn player_input_system(world: &mut World, input_state: &InputState)
|
||||
pub fn player_input_system(
|
||||
cameras: &Storage<CameraComponent>,
|
||||
follows: &Storage<FollowComponent>,
|
||||
player_tags: &Storage<()>,
|
||||
inputs: &mut Storage<InputComponent>,
|
||||
input_state: &InputState,
|
||||
)
|
||||
{
|
||||
if !world.camera_is_following()
|
||||
let camera_is_following = cameras
|
||||
.components
|
||||
.iter()
|
||||
.find(|(_, cam)| cam.is_active)
|
||||
.map(|(e, _)| follows.get(*e).is_some())
|
||||
.unwrap_or(false);
|
||||
|
||||
if !camera_is_following
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let Some((_, camera)) = world.active_camera()
|
||||
else
|
||||
let (_, camera) = match cameras.components.iter().find(|(_, cam)| cam.is_active)
|
||||
{
|
||||
return;
|
||||
Some((e, c)) => (*e, c),
|
||||
None => return,
|
||||
};
|
||||
|
||||
let forward = camera.get_forward_horizontal();
|
||||
let right = camera.get_right_horizontal();
|
||||
|
||||
let players = world.player_tags.all();
|
||||
let players = player_tags.all();
|
||||
|
||||
for player in players
|
||||
{
|
||||
world.inputs.with_mut(player, |input_component| {
|
||||
inputs.with_mut(player, |input_component| {
|
||||
let mut local_input = Vec3::ZERO;
|
||||
|
||||
if input_state.w
|
||||
|
||||
Reference in New Issue
Block a user