-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the processing of traits to have an order.
- Loading branch information
Showing
4 changed files
with
74 additions
and
28 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,13 +1,15 @@ | ||
use crate::prelude::*; | ||
|
||
pub fn personality_nopersonality( | ||
mut entities: Query<(Entity, &mut Brain, &mut PhysicalBody, &Position)> | ||
pub fn nopersonality( | ||
entity: Entity, | ||
mut brain: Mut<Brain>, | ||
mut physical_body: Mut<PhysicalBody>, | ||
position: &Position, | ||
_: Option<&Nest> | ||
) { | ||
for (entity, mut brain, mut physical_body, position) in entities.iter_mut() { | ||
if brain.task != Some(Task::Personality) { continue; } | ||
if !brain.personality.is_empty() { continue; } | ||
|
||
brain.motivation = Some(Motivation::Meander); | ||
brain.task = None; | ||
} | ||
if brain.task != Some(Task::Personality) { return; } | ||
if !brain.personality.is_empty() { return; } | ||
|
||
brain.motivation = Some(Motivation::Meander); | ||
brain.task = None; | ||
} |
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,24 +1,24 @@ | ||
use crate::prelude::*; | ||
|
||
pub fn personality_territorial( | ||
mut entities: Query<(Entity, &mut Brain, &mut PhysicalBody, &Position, Option<&Nest>)> | ||
pub fn territorial( | ||
entity: Entity, | ||
mut brain: Mut<Brain>, | ||
mut physical_body: Mut<PhysicalBody>, | ||
position: &Position, | ||
nest: Option<&Nest>, | ||
potential_targets: &Vec<(Entity, Position)> | ||
) { | ||
let potential_targets = entities.iter() | ||
.map(|(entity, _, _, position, _)| (entity, *position)) // Clone the Position data | ||
.collect::<Vec<(Entity, Position)>>(); | ||
for (entity, mut brain, mut physical_body, position, nest) in entities.iter_mut() { | ||
if brain.task != Some(Task::Personality) { continue; } | ||
if !brain.personality.contains(&PersonalityTrait::Territorial) { continue; } | ||
// Anything to defend against? | ||
for (target_entity, target_position) in potential_targets.iter() { | ||
if entity == *target_entity { continue; } | ||
if target_position.distance(position) < 5 { | ||
physical_body.danger = Some(Danger { danger_type: DangerType::Attacked, danger_source: Some(*target_entity) }); | ||
brain.remotivate(); | ||
break; | ||
} | ||
if brain.task != Some(Task::Personality) { return; } | ||
if !brain.personality.contains(&PersonalityTrait::Territorial) { return; } | ||
// Anything to defend against? | ||
for (target_entity, target_position) in potential_targets.iter() { | ||
if entity == *target_entity { continue; } | ||
if target_position.distance(position) < 5 { | ||
physical_body.danger = Some(Danger { danger_type: DangerType::Attacked, danger_source: Some(*target_entity) }); | ||
brain.remotivate(); | ||
break; | ||
} | ||
brain.motivation = Some(Motivation::Meander); | ||
brain.task = None; | ||
} | ||
brain.motivation = Some(Motivation::Meander); | ||
brain.task = None; | ||
} |