Updated comments in states code.

This commit is contained in:
Sam 2021-05-23 11:41:09 -05:00
parent 7828112486
commit 0961f00c7c
2 changed files with 6 additions and 1 deletions

View File

@ -82,7 +82,10 @@ impl CharacterBehavior for Data {
crit_chance,
crit_mult,
);
// Shoots all projectiles simultaneously
for i in 0..self.static_data.num_projectiles {
// Adds a slight spread to the projectiles. First projectile has no spread,
// and spread increases linearly with number of projectiles created.
let dir = Dir::from_unnormalized(data.inputs.look_dir.map(|x| {
let offset = (2.0 * thread_rng().gen::<f32>() - 1.0)
* self.static_data.projectile_spread
@ -90,6 +93,7 @@ impl CharacterBehavior for Data {
x + offset
}))
.unwrap_or(data.inputs.look_dir);
// Tells server to create and shoot the projectile
update.server_events.push_front(ServerEvent::Shoot {
entity: data.entity,
dir,

View File

@ -100,7 +100,6 @@ impl CharacterBehavior for Data {
);
update.server_events.push_front(ServerEvent::Shoot {
entity: data.entity,
// Provides slight variation to projectile direction
dir: data.inputs.look_dir,
body: self.static_data.projectile_body,
projectile,
@ -109,6 +108,7 @@ impl CharacterBehavior for Data {
object: None,
});
// Removes energy from character when arrow is fired
update.server_events.push_front(ServerEvent::EnergyChange {
entity: data.entity,
change: EnergyChange {
@ -117,6 +117,7 @@ impl CharacterBehavior for Data {
},
});
// Sets new speed of shoot. Scales based off of the number of projectiles fired.
let new_speed = 1.0
+ self.projectiles_fired as f32
/ (self.static_data.half_speed_at as f32