-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
103 additions
and
40 deletions.
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,3 +1,9 @@ | ||
pub mod emoji; | ||
#[allow(unused_imports)] | ||
pub use self::emoji::*; | ||
pub mod orbital_child; | ||
#[allow(unused_imports)] | ||
pub use self::orbital_child::*; | ||
pub mod valency; | ||
#[allow(unused_imports)] | ||
pub use self::valency::*; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use bevy::prelude::*; | ||
use std::f32::consts::TAU; | ||
|
||
/// Arrange children in a circle around the parent | ||
pub fn orbital_child(index: usize, total: usize) -> Transform { | ||
let angle = TAU / total as f32 * index as f32; | ||
let pos = Vec3::new(f32::cos(angle), f32::sin(angle), 0.); | ||
Transform::from_translation(pos * 0.7).with_scale(CHILD_SCALE) | ||
} | ||
|
||
|
||
const CHILD_SCALE: Vec3 = Vec3 { | ||
x: 0.5, | ||
y: 0.5, | ||
z: 0.5, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::prelude::*; | ||
use bevy::prelude::*; | ||
|
||
|
||
#[derive(Default, Component, Reflect)] | ||
#[reflect(Default, Component)] | ||
pub struct ValencyRender; | ||
|
||
pub fn render_valency( | ||
mut commands: Commands, | ||
stat_map: Res<StatMap>, | ||
query: Populated< | ||
(Entity, &StatId, &StatValue), | ||
(Changed<StatValue>, With<StatProvider>), | ||
>, | ||
children: Query<&Children>, | ||
existing: Query<&ValencyRender>, | ||
) { | ||
for (entity, stat_id, value) in query.iter() { | ||
// 1. remove existing valency renders | ||
for child in children.iter_descendants(entity) { | ||
if existing.get(child).is_ok() { | ||
commands.entity(child).despawn_recursive(); | ||
} | ||
} | ||
let emoji = match value.is_sign_positive() { | ||
true => "2795", // ➕ | ||
false => "2796", // ➖ | ||
}; | ||
let range = *stat_map.get(stat_id).unwrap().total_range(); | ||
let frac = value.0.abs() / range; | ||
|
||
let num_emojis = match frac { | ||
f if f < 0.33 => 1, | ||
f if f < 0.66 => 2, | ||
_ => 3, | ||
}; | ||
|
||
commands.entity(entity).with_children(|parent| { | ||
for i in 0..num_emojis { | ||
parent.spawn((Emoji::new(emoji), orbital_child(i, num_emojis))); | ||
} | ||
}); | ||
} | ||
} |
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,8 +1,11 @@ | ||
use bevy::prelude::*; | ||
|
||
//// Superset of [`CollectableStat`], [`ZoneStat`] etc | ||
#[derive(Default, Component, Reflect)] | ||
#[reflect(Default, Component)] | ||
pub struct StatProvider; | ||
|
||
#[derive(Default, Component, Reflect)] | ||
#[reflect(Default, Component)] | ||
pub struct CollectableStat{ | ||
|
||
} | ||
#[require(StatProvider)] | ||
pub struct CollectableStat {} |
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,8 +1,9 @@ | ||
use bevy::prelude::*; | ||
|
||
use crate::prelude::*; | ||
|
||
#[derive(Default, Component, Reflect)] | ||
#[reflect(Default, Component)] | ||
#[require(StatProvider)] | ||
pub struct ZoneStat{ | ||
|
||
} |