This repository has been archived by the owner on Sep 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from rodrigocam/bear-person
Add BearPerson implementation
- Loading branch information
Showing
9 changed files
with
134 additions
and
2 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
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
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,46 @@ | ||
use crate::*; | ||
|
||
/// Spawn a bear companion at a specific location | ||
pub fn bear_spawner_system( | ||
events: &Vec<SkillTriggerEvent<Skills>>, | ||
stat_def: &StatDefinitions<Stats>, | ||
teams: &mut Components<Team>, | ||
proximity_attacks: &mut Components<ProximityAttack>, | ||
simple_movements: &mut Components<SimpleMovement>, | ||
stats: &mut Components<StatSet<Stats>>, | ||
positions: &mut Components<Point>, | ||
entities: &mut Entities, | ||
companions: &mut Components<Companion>, | ||
sprites: &mut Components<Sprite>, | ||
sprite_indices: &mut Components<SpriteIndex>, | ||
) -> SystemResult { | ||
for ev in events.iter() { | ||
if ev.1 == Skills::BearSummon { | ||
let pos = positions.get(ev.0).unwrap().clone(); | ||
let team = teams.get_mut(ev.0).unwrap().clone(); | ||
|
||
let bear = entities.create(); | ||
positions.insert(bear, pos.clone()); | ||
companions.insert(ev.0, Companion::Bear(bear)); | ||
simple_movements.insert(bear, SimpleMovement); | ||
teams.insert(bear, team); | ||
stats.insert(bear, stat_def.to_statset()); | ||
proximity_attacks.insert(bear, ProximityAttack::new(CREEP_ATTACK_RADIUS)); | ||
let bg = if team == Team::Me { | ||
RGBA::named(GREEN) | ||
} else { | ||
RGBA::named(RED) | ||
}; | ||
sprites.insert( | ||
bear, | ||
Sprite { | ||
glyph: to_cp437('c'), | ||
fg: RGBA::named(YELLOW), | ||
bg, | ||
}, | ||
); | ||
sprite_indices.insert(bear, SpriteIndex(15)); | ||
} | ||
} | ||
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
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,37 @@ | ||
use crate::*; | ||
|
||
/// Increase the attack speed of both leader and companion in 5 points. | ||
pub fn savagery_system( | ||
effector_defs: &EffectorDefinitions<Stats, Effectors>, | ||
companions: &Components<Companion>, | ||
effectors: &mut Components<EffectorSet<Effectors>>, | ||
events: &mut Vec<SkillTriggerEvent<Skills>>, | ||
) -> SystemResult { | ||
for ev in events.iter() { | ||
if ev.1 == Skills::Savagery { | ||
let savagery_effector_def = effector_defs | ||
.defs | ||
.get(&Effectors::Savagery) | ||
.expect("Unknown effector key."); | ||
|
||
let savagery_effector = | ||
EffectorInstance::new(Effectors::Savagery, savagery_effector_def.duration); | ||
|
||
if let Some(c) = companions.get(ev.0) { | ||
match c { | ||
Companion::Bear(e) => { | ||
if effectors.get(*e).is_none() { | ||
effectors.insert(*e, EffectorSet::default()); | ||
} | ||
effectors | ||
.get_mut(*e) | ||
.unwrap() | ||
.effectors | ||
.push(savagery_effector); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} |