This repository has been archived by the owner on Apr 18, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 747
Port amethyst_controls
to legion.
#2325
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
872e720
Convert amethyst_network to legion systems.
dkushner 2ac8538
Checkpoint controls port due to X11 issue.
dkushner 7ad06fd
Merge remote-tracking branch 'upstream/legion_v2' into feature/legion…
dkushner f96f2d9
Remove latent references to CallbackQueue.
dkushner 8def3fe
fix issue where input handler bindings were not passed to constructed…
dkushner daf0132
roll back changes to more closely match existing bundle/systems struc…
dkushner 6608f56
fix arc ball camera example
dkushner 1398da9
Merge remote-tracking branch 'upstream/legion_v2' into feature/legion…
dkushner d1790df
remove merge markers and apply formatting
dkushner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,61 @@ | ||
use amethyst_assets::PrefabData; | ||
use amethyst_core::ecs::prelude::{Component, Entity, HashMapStorage, NullStorage, WriteStorage}; | ||
use amethyst_core::ecs::prelude::*; | ||
use amethyst_error::Error; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Add this to a camera if you want it to be a fly camera. | ||
/// You need to add the FlyControlBundle or the required systems for it to work. | ||
#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] | ||
pub struct FlyControlTag; | ||
|
||
impl Component for FlyControlTag { | ||
type Storage = NullStorage<FlyControlTag>; | ||
} | ||
pub struct FlyControl; | ||
|
||
/// To add an arc ball behaviour, add this to a camera which already has the FlyControlTag added. | ||
#[derive(Debug, Clone)] | ||
pub struct ArcBallControlTag { | ||
pub struct ArcBallControl { | ||
/// The target entity which the camera will orbit | ||
pub target: Entity, | ||
/// The distance from the target entity that the camera should orbit at. | ||
pub distance: f32, | ||
} | ||
|
||
impl Component for ArcBallControlTag { | ||
// we can use HashMapStorage here because, according to the specs doc, this storage should be | ||
// use when the component is used with few entity, I think there will rarely more than one | ||
// camera | ||
type Storage = HashMapStorage<ArcBallControlTag>; | ||
} | ||
|
||
/// `PrefabData` for loading control tags on an `Entity` | ||
/// | ||
/// Will always load a `FlyControlTag` | ||
#[derive(Debug, Default, Clone, Deserialize, Serialize)] | ||
pub struct ControlTagPrefab { | ||
/// Place `ArcBallControlTag` on the `Entity` | ||
pub arc_ball: Option<(usize, f32)>, | ||
} | ||
|
||
impl<'a> PrefabData<'a> for ControlTagPrefab { | ||
type SystemData = ( | ||
WriteStorage<'a, FlyControlTag>, | ||
WriteStorage<'a, ArcBallControlTag>, | ||
); | ||
type Result = (); | ||
|
||
fn add_to_entity( | ||
&self, | ||
entity: Entity, | ||
system_data: &mut Self::SystemData, | ||
entities: &[Entity], | ||
_: &[Entity], | ||
) -> Result<(), Error> { | ||
system_data.0.insert(entity, FlyControlTag)?; | ||
if let Some((index, distance)) = self.arc_ball { | ||
system_data.1.insert( | ||
entity, | ||
ArcBallControlTag { | ||
target: entities[index], | ||
distance, | ||
}, | ||
)?; | ||
} | ||
Ok(()) | ||
impl ArcBallControl { | ||
pub fn new(target: Entity, distance: f32) -> Self { | ||
ArcBallControl { target, distance } | ||
} | ||
} | ||
|
||
// `PrefabData` for loading control tags on an `Entity` | ||
// | ||
// Will always load a `FlyControlTag` | ||
// #[derive(Debug, Default, Clone, Deserialize, Serialize)] | ||
// pub struct ControlTagPrefab { | ||
// /// Place `ArcBallControlTag` on the `Entity` | ||
// pub arc_ball: Option<(usize, f32)>, | ||
// } | ||
// | ||
// impl<'a> PrefabData<'a> for ControlTagPrefab { | ||
// type SystemData = ( | ||
// WriteStorage<'a, FlyControl>, | ||
// WriteStorage<'a, ArcBallControl>, | ||
// ); | ||
// type Result = (); | ||
// | ||
// fn add_to_entity( | ||
// &self, | ||
// entity: Entity, | ||
// system_data: &mut Self::SystemData, | ||
// entities: &[Entity], | ||
// _: &[Entity], | ||
// ) -> Result<(), Error> { | ||
// system_data.0.insert(entity, FlyControl)?; | ||
// if let Some((index, distance)) = self.arc_ball { | ||
// system_data.1.insert( | ||
// entity, | ||
// ArcBallControl { | ||
// target: entities[index], | ||
// distance, | ||
// }, | ||
// )?; | ||
// } | ||
// Ok(()) | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert the changes to this file before the merge happens :)