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