mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'clientstates' of gitlab.com:veloren/veloren into clientstates
This commit is contained in:
commit
4e281e22b7
@ -47,6 +47,7 @@ pub enum SfxEvent {
|
||||
|
||||
pub enum LocalEvent {
|
||||
Jump(EcsEntity),
|
||||
Knockback(EcsEntity),
|
||||
WallLeap {
|
||||
entity: EcsEntity,
|
||||
wall_dir: Vec3<f32>,
|
||||
|
@ -351,6 +351,7 @@ impl State {
|
||||
let events = self.ecs.read_resource::<EventBus<LocalEvent>>().recv_all();
|
||||
for event in events {
|
||||
let mut velocities = self.ecs.write_storage::<comp::Vel>();
|
||||
let mut orientations = self.ecs.write_storage::<comp::Ori>();
|
||||
let mut controllers = self.ecs.write_storage::<comp::Controller>();
|
||||
match event {
|
||||
LocalEvent::Jump(entity) => {
|
||||
@ -358,6 +359,14 @@ impl State {
|
||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||
}
|
||||
},
|
||||
LocalEvent::Knockback(entity) => {
|
||||
if let Some(vel) = velocities.get_mut(entity) {
|
||||
if let Some(ori) = orientations.get_mut(entity) {
|
||||
vel.0 = -ori.0 * 10.0;
|
||||
vel.0.z = HUMANOID_JUMP_ACCEL;
|
||||
}
|
||||
}
|
||||
},
|
||||
LocalEvent::WallLeap { entity, wall_dir } => {
|
||||
if let (Some(vel), Some(_controller)) =
|
||||
(velocities.get_mut(entity), controllers.get_mut(entity))
|
||||
|
@ -41,7 +41,6 @@ impl CharacterBehavior for Data {
|
||||
if new_stage_time_active < self.buildup_duration {
|
||||
// If the player is pressing primary btn
|
||||
if data.inputs.primary.is_just_pressed() {
|
||||
println!("Failed");
|
||||
// They failed, go back to `Wielding`
|
||||
update.character = CharacterState::Wielding;
|
||||
}
|
||||
@ -61,7 +60,7 @@ impl CharacterBehavior for Data {
|
||||
else if !self.stage_exhausted {
|
||||
// Swing hits
|
||||
data.updater.insert(data.entity, Attacking {
|
||||
base_damage: self.base_damage,
|
||||
base_damage: self.base_damage * (self.stage as u32 + 1),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
});
|
||||
@ -84,7 +83,6 @@ impl CharacterBehavior for Data {
|
||||
{
|
||||
// Try to transition to next stage
|
||||
if data.inputs.primary.is_just_pressed() {
|
||||
println!("Transition");
|
||||
update.character = CharacterState::TimedCombo(Data {
|
||||
stage: self.stage + 1,
|
||||
buildup_duration: self.buildup_duration,
|
||||
@ -97,7 +95,6 @@ impl CharacterBehavior for Data {
|
||||
// Player didn't click this frame
|
||||
else {
|
||||
// Update state
|
||||
println!("Missed");
|
||||
update.character = CharacterState::TimedCombo(Data {
|
||||
stage: self.stage,
|
||||
buildup_duration: self.buildup_duration,
|
||||
@ -128,7 +125,6 @@ impl CharacterBehavior for Data {
|
||||
// Grant energy on successful hit
|
||||
if let Some(attack) = data.attacking {
|
||||
if attack.applied && attack.hit_count > 0 {
|
||||
println!("Hit");
|
||||
data.updater.remove::<Attacking>(data.entity);
|
||||
update.energy.change_by(100, EnergySource::HitEnemy);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user