From e074c7ce1d782011975997ce8667776c82fea05a Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Fri, 20 Dec 2019 05:30:37 -0800 Subject: [PATCH 001/326] begin impl state handle traits --- common/src/comp/character_state.rs | 136 +++++- common/src/comp/controller.rs | 15 - common/src/sys/character_state.rs | 401 ++++++++++++++++++ common/src/sys/controller.rs | 657 +---------------------------- common/src/sys/mod.rs | 5 +- common/src/sys/movement.rs | 4 + 6 files changed, 556 insertions(+), 662 deletions(-) create mode 100644 common/src/sys/character_state.rs diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 1ac19ae950..86588381ce 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,12 +1,142 @@ +use crate::comp::{Body, CharacterState, Controller, ControllerInputs, PhysicsState}; use specs::{Component, FlaggedStorage, HashMapStorage}; +use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System}; +use sphynx::{Uid, UidAllocator}; //use specs_idvs::IDVStorage; +use self::{ActionState::*, MovementState::*}; use std::time::Duration; +pub trait State { + fn handle( + &self, + character: &CharacterState, + inputs: &ControllerInputs, + body: &Body, + physics: &PhysicsState, + ) -> CharacterState; +} + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct RunData; +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct StandData; + +impl State for StandData { + fn handle( + &self, + character: &CharacterState, + inputs: &ControllerInputs, + body: &Body, + physics: &PhysicsState, + ) -> CharacterState { + let mut new_move: MovementState = if inputs.move_dir.magnitude_squared() > 0.0 { + MovementState::Run(RunData) + } else { + MovementState::Stand(StandData) + }; + + // Try to sit + if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { + return CharacterState { + movement: Sit, + action: Idle, + }; + } + + // Try to climb + if let (true, Some(_wall_dir)) = ( + inputs.climb.is_pressed() | inputs.climb_down.is_pressed() && body.is_humanoid(), + physics.on_wall, + ) { + return CharacterState { + movement: Climb, + action: Idle, + }; + } + + // Try to swim + if !physics.on_ground && physics.in_fluid { + return CharacterState { + action: character.action, + movement: Swim, + }; + } + + // While on ground ... + if physics.on_ground { + // Try to jump + if inputs.jump.is_pressed() && !inputs.jump.is_held_down() { + return CharacterState { + action: character.action, + movement: Jump, + }; + } + + // Try to charge + if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { + return CharacterState { + action: Charge { + time_left: Duration::from_millis(250), + }, + movement: Run(RunData), + }; + } + + // Try to roll + if inputs.roll.is_pressed() && body.is_humanoid() { + return CharacterState { + action: Roll { + time_left: Duration::from_millis(600), + was_wielding: character.action.is_wield(), + }, + movement: Run(RunData), + }; + } + } + // While not on ground ... + else { + // Try to glide + if physics.on_wall == None + && inputs.glide.is_pressed() + && !inputs.glide.is_held_down() + && body.is_humanoid() + { + character.movement = Glide; + continue; + } + character.movement = Fall; + } + + // Tool Actions + if inputs.toggle_wield.is_just_pressed() { + match action_state { + Wield { .. } | Attack { .. } => { + // Prevent instantaneous reequipping by checking + // for done wielding + if character.action.is_action_finished() { + character.action = Idle; + } + continue; + } + Idle => { + character.action = try_wield(stats); + continue; + } + Charge { .. } | Roll { .. } | Block { .. } => {} + } + } + if inputs.primary.is_pressed() { + // TODO: PrimaryStart + } else if inputs.secondary.is_pressed() { + // TODO: SecondaryStart + } + } +} #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum MovementState { - Stand, + Stand(Stand), Sit, - Run, + Run(Run), Jump, Fall, Glide, @@ -35,7 +165,7 @@ pub enum ActionState { Charge { time_left: Duration, }, - //Carry, + // Handle(CharacterAction), } impl ActionState { diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 34ac6859bc..1bfc01dcad 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -154,21 +154,6 @@ impl ControllerInputs { self.toggle_wield.tick(dt); self.charge.tick(dt); } - /// Updates `inputs.move_dir`. - pub fn update_move_dir(&mut self) { - self.move_dir = if self.move_dir.magnitude_squared() > 1.0 { - // Cap move_dir to 1 - self.move_dir.normalized() - } else { - self.move_dir - }; - } - /// Updates `inputs.look_dir` - pub fn update_look_dir(&mut self) { - self.look_dir - .try_normalized() - .unwrap_or(self.move_dir.into()); - } } impl Controller { diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs new file mode 100644 index 0000000000..d5373c4390 --- /dev/null +++ b/common/src/sys/character_state.rs @@ -0,0 +1,401 @@ +use super::movement::ROLL_DURATION; +use crate::{ + comp::{ + self, item, projectile, ActionState, ActionState::*, Body, CharacterState, ControlEvent, + Controller, ControllerInputs, HealthChange, HealthSource, ItemKind, Mounting, + MovementState, MovementState::*, PhysicsState, Projectile, Stats, Vel, + }, + event::{Emitter, EventBus, LocalEvent, ServerEvent}, + state::DeltaTime, +}; +use specs::{ + saveload::{Marker, MarkerAllocator}, + Entities, Entity, Join, Read, ReadStorage, System, WriteStorage, +}; +use sphynx::{Uid, UidAllocator}; +use std::time::Duration; +use vek::*; + +/// # Character State System +/// #### Updates then detemrines next Character States based on ControllerInputs +pub struct Sys; + +impl<'a> System<'a> for Sys { + type SystemData = ( + Entities<'a>, + Read<'a, UidAllocator>, + Read<'a, EventBus>, + Read<'a, EventBus>, + Read<'a, DeltaTime>, + WriteStorage<'a, CharacterState>, + ReadStorage<'a, Controller>, + ReadStorage<'a, Stats>, + ReadStorage<'a, Body>, + ReadStorage<'a, Vel>, + ReadStorage<'a, PhysicsState>, + ReadStorage<'a, Uid>, + ReadStorage<'a, Mounting>, + ); + fn run( + &mut self, + ( + entities, + uid_allocator, + server_bus, + local_bus, + dt, + mut character_states, + controllers, + stats, + bodies, + velocities, + physics_states, + uids, + mountings, + ): Self::SystemData, + ) { + let mut server_emitter = server_bus.emitter(); + let mut local_emitter = local_bus.emitter(); + for (entity, uid, mut character, controller, stats, body, vel, physics, mount) in ( + &entities, + &uids, + &mut character_states, + &controllers, + &stats, + &bodies, + &velocities, + &physics_states, + mountings.maybe(), + ) + .join() + { + let inputs = &controller.inputs; + + // Returns a Wield action, or Idle if nothing to wield + let try_wield = |stats: &Stats| -> ActionState { + // Get weapon to wield + if let Some(ItemKind::Tool { kind, .. }) = + stats.equipment.main.as_ref().map(|i| &i.kind) + { + let wield_duration = kind.wield_duration(); + Wield { + time_left: wield_duration, + } + } else { + Idle + } + }; + + let get_state_from_move_dir = |move_dir: &Vec2| -> MovementState { + if move_dir.magnitude_squared() > 0.0 { + Run(_) + } else { + Stand(_) + } + }; + + // Being dead overrides all other states + if stats.is_dead { + // Only options: click respawn + // prevent instant-respawns (i.e. player was holding attack) + // by disallowing while input is held down + if inputs.respawn.is_pressed() && !inputs.respawn.is_held_down() { + server_emitter.emit(ServerEvent::Respawn(entity)); + } + // Or do nothing + continue; + } + // If mounted, character state is controlled by mount + if mount.is_some() { + character.movement = Sit; + continue; + } + + // Update Action States + match character.action { + Attack { + ref mut time_left, .. + } => { + *time_left = time_left + .checked_sub(Duration::from_secs_f32(dt.0)) + .unwrap_or_default(); + } + Roll { + ref mut time_left, .. + } => { + *time_left = time_left + .checked_sub(Duration::from_secs_f32(dt.0)) + .unwrap_or_default(); + } + Charge { ref mut time_left } => { + *time_left = time_left + .checked_sub(Duration::from_secs_f32(dt.0)) + .unwrap_or_default(); + } + Wield { ref mut time_left } => { + *time_left = time_left + .checked_sub(Duration::from_secs_f32(dt.0)) + .unwrap_or_default(); + } + Block { + ref mut time_active, + } => { + *time_active = time_active + .checked_add(Duration::from_secs_f32(dt.0)) + .unwrap_or_default(); + } + Idle => {} + } + + // Determine new states + match (character.action, character.movement) { + // Jumping, one frame state that calls jump server event + (_, Jump) => { + character.movement = Fall; + local_emitter.emit(LocalEvent::Jump(entity)); + } + // Charging + Any Movement, prioritizes finishing charge + // over movement states + (Charge { time_left }, _) => { + if let Some(uid_b) = physics.touch_entity { + server_emitter.emit(ServerEvent::Damage { + uid: uid_b, + change: HealthChange { + amount: -20, + cause: HealthSource::Attack { by: *uid }, + }, + }); + + character.action = try_wield(stats); + } else if time_left == Duration::default() || vel.0.magnitude_squared() < 10.0 { + character.action = try_wield(stats); + } + } + // Rolling + Any Movement, prioritizes finishing charge + // over movement states + ( + Roll { + time_left, + was_wielding, + }, + _, + ) => { + if time_left == Duration::default() { + if was_wielding { + character.action = try_wield(stats); + } else { + character.action = Idle; + } + } + } + // Any Action + Falling + (action_state, Fall) => { + // character.movement = get_state_from_move_dir(&inputs.move_dir); + if inputs.glide.is_pressed() && !inputs.glide.is_held_down() { + character.movement = Glide; + continue; + } + // Reset to Falling while not standing on ground, + // otherwise keep the state given above + if !physics.on_ground { + if physics.in_fluid { + character.movement = Swim; + } else { + character.movement = Fall; + } + } else { + character.movement = Stand(comp::character_state::Stand); + continue; + } + + match action_state { + // Unwield if buttons pressed + Wield { .. } | Attack { .. } => { + if inputs.toggle_wield.is_just_pressed() { + character.action = Idle; + } + } + // Try to wield if any of buttons pressed + Idle => { + if inputs.primary.is_pressed() || inputs.secondary.is_pressed() { + character.action = try_wield(stats); + } + } + // Cancel blocks + Block { .. } => { + character.action = try_wield(stats); + } + // Don't change action + Charge { .. } | Roll { .. } => {} + } + } + // Any Action + Swimming + (_, Swim) => { + character.movement = get_state_from_move_dir(&inputs.move_dir); + + if !physics.on_ground && physics.in_fluid { + character.movement = Swim; + } + if inputs.primary.is_pressed() { + // TODO: PrimaryStart + } else if inputs.secondary.is_pressed() { + // TODO: SecondaryStart + } + } + // // Blocking, restricted look_dir compared to other states + // (Block { .. }, Stand) | (Block { .. }, Run) => { + // character.movement = get_state_from_move_dir(&inputs.move_dir); + + // if !inputs.secondary.is_pressed() { + // character.action = try_wield(stats); + // } else { + // // TODO: SecondaryStart + // } + + // if !physics.on_ground && physics.in_fluid { + // character.movement = Swim; + // } + // } + // // Standing and Running states, typical states :shrug: + // (action_state, Run) | (action_state, Stand) => { + // character.movement = get_state_from_move_dir(&inputs.move_dir); + // // Try to sit + // if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { + // character.movement = Sit; + // continue; + // } + + // // Try to climb + // if let (true, Some(_wall_dir)) = ( + // inputs.climb.is_pressed() | inputs.climb_down.is_pressed() + // && body.is_humanoid(), + // physics.on_wall, + // ) { + // character.movement = Climb; + // continue; + // } + + // // Try to swim + // if !physics.on_ground && physics.in_fluid { + // character.movement = Swim; + // continue; + // } + + // // While on ground ... + // if physics.on_ground { + // // Try to jump + // if inputs.jump.is_pressed() && !inputs.jump.is_held_down() { + // character.movement = Jump; + // continue; + // } + + // // Try to charge + // if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { + // character.action = Charge { + // time_left: Duration::from_millis(250), + // }; + // continue; + // } + + // // Try to roll + // if character.movement == Run + // && inputs.roll.is_pressed() + // && body.is_humanoid() + // { + // character.action = Roll { + // time_left: ROLL_DURATION, + // was_wielding: character.action.is_wield(), + // }; + // continue; + // } + // } + // // While not on ground ... + // else { + // // Try to glide + // if physics.on_wall == None + // && inputs.glide.is_pressed() + // && !inputs.glide.is_held_down() + // && body.is_humanoid() + // { + // character.movement = Glide; + // continue; + // } + // character.movement = Fall; + // } + + // // Tool Actions + // if inputs.toggle_wield.is_just_pressed() { + // match action_state { + // Wield { .. } | Attack { .. } => { + // // Prevent instantaneous reequipping by checking + // // for done wielding + // if character.action.is_action_finished() { + // character.action = Idle; + // } + // continue; + // } + // Idle => { + // character.action = try_wield(stats); + // continue; + // } + // Charge { .. } | Roll { .. } | Block { .. } => {} + // } + // } + // if inputs.primary.is_pressed() { + // // TODO: PrimaryStart + // } else if inputs.secondary.is_pressed() { + // // TODO: SecondaryStart + // } + // } + // Sitting + (_, Sit) => { + character.action = Idle; + character.movement = get_state_from_move_dir(&inputs.move_dir); + + // character.movement will be Stand after updating when + // no movement has occurred + if character.movement == Stand(_) { + character.movement = Sit; + } + if inputs.jump.is_pressed() && !inputs.jump.is_held_down() { + character.movement = Jump; + continue; + } + if !physics.on_ground { + character.movement = Fall; + } + } + // Any Action + Gliding, shouldnt care about action, + // because should be Idle + (_, Glide) => { + character.action = Idle; + + if !inputs.glide.is_pressed() { + character.movement = Fall; + } else if let Some(_wall_dir) = physics.on_wall { + character.movement = Fall; + } + + if physics.on_ground { + character.movement = Stand(Stand) + } + } + // Any Action + Climbing, shouldnt care about action, + // because should be Idle + (_, Climb) => { + character.action = Idle; + if let None = physics.on_wall { + if inputs.jump.is_pressed() { + character.movement = Jump; + } else { + character.movement = Fall; + } + } + if physics.on_ground { + character.movement = Stand(Stand); + } + } + }; + } + } +} diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index 3894d1b325..7548d322df 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -17,226 +17,9 @@ use std::time::Duration; use vek::*; /// # Controller System -/// #### Responsible for validating controller inputs and setting new Character States -/// ---- -/// -/// **Writes:** -/// `CharacterState`, `ControllerInputs` -/// -/// **Reads:** -/// `Stats`, `Vel`, `PhysicsState`, `Uid`, `Mounting` -/// -/// _TODO: Join ActionStates and MovementStates into one and have a handle() trait / fn?_ -/// _TODO: Move weapon action to trait fn?_ +/// #### Responsible for validating and updating controller inputs pub struct Sys; -impl Sys { - /// Assumes `input.primary` has been pressed - /// handles primary actions. ie. equipping, mainhand weapon attacks. - /// - /// Returns the `ActionState` that occurred - fn handle_primary( - inputs: &mut ControllerInputs, - character: &mut CharacterState, - stats: &Stats, - entity: Entity, - uid: &Uid, - server_emitter: &mut Emitter<'_, ServerEvent>, - local_emitter: &mut Emitter<'_, LocalEvent>, - ) -> ActionState { - match stats.equipment.main.as_ref().map(|i| &i.kind) { - // Character is wielding something - Some(ItemKind::Tool { kind, power, .. }) => { - let attack_duration = kind.attack_duration(); - let wield_duration = kind.wield_duration(); - - // Since primary input was pressed, set - // action to new Wield, in case of - // instant primary actions - if character.action == Idle { - character.action = Wield { - time_left: wield_duration, - }; - } - - match kind { - item::Tool::Bow if character.action.is_action_finished() => { - // Immediately end the wield - server_emitter.emit(ServerEvent::Shoot { - entity, - dir: inputs.look_dir, - body: comp::Body::Object(comp::object::Body::Arrow), - light: None, - gravity: Some(comp::Gravity(0.3)), - projectile: Projectile { - owner: *uid, - hit_ground: vec![projectile::Effect::Stick], - hit_wall: vec![projectile::Effect::Stick], - hit_entity: vec![ - projectile::Effect::Damage(HealthChange { - amount: -(*power as i32), - cause: HealthSource::Attack { by: *uid }, - }), - projectile::Effect::Vanish, - ], - time_left: Duration::from_secs(15), - }, - }); - Attack { - time_left: attack_duration, - applied: false, // We don't want to do a melee attack - } - //character.action - } - item::Tool::Debug(item::Debug::Boost) => { - local_emitter.emit(LocalEvent::Boost { - entity, - vel: inputs.look_dir * 7.0, - }); - character.action - } - - item::Tool::Debug(item::Debug::Possess) - if character.action.is_action_finished() => - { - server_emitter.emit(ServerEvent::Shoot { - entity, - gravity: Some(comp::Gravity(0.1)), - dir: inputs.look_dir, - body: comp::Body::Object(comp::object::Body::ArrowSnake), - light: Some(comp::LightEmitter { - col: (0.0, 1.0, 0.3).into(), - ..Default::default() - }), - projectile: Projectile { - owner: *uid, - hit_ground: vec![projectile::Effect::Stick], - hit_wall: vec![projectile::Effect::Stick], - hit_entity: vec![ - projectile::Effect::Stick, - projectile::Effect::Possess, - ], - time_left: Duration::from_secs(10), - }, - }); - - character.action - } - // All other weapons - _ if character.action.is_action_finished() => Attack { - time_left: attack_duration, - applied: false, - }, - _ => { - // Return the new Wield action - character.action - } - } - } - // Without a weapon - None => { - // Attack - if !character.action.is_attack() { - Attack { - time_left: Duration::from_millis(100), - applied: false, - } - } else { - character.action - } - } - _ => character.action, - } - } - - /// Assumes `input.seconday` has been pressed - /// handles seconday actions. ie. blocking, althand weapons - /// - /// Returns the `ActionState` that occurred - fn handle_secondary( - inputs: &mut ControllerInputs, - character: &mut CharacterState, - stats: &Stats, - entity: Entity, - uid: &Uid, - server_emitter: &mut Emitter<'_, ServerEvent>, - local_emitter: &mut Emitter<'_, LocalEvent>, - ) -> ActionState { - match stats.equipment.main.as_ref().map(|i| &i.kind) { - // Character is wielding something - Some(ItemKind::Tool { kind, power, .. }) => { - let attack_duration = kind.attack_duration(); - let wield_duration = kind.wield_duration(); - - // Since primary input was pressed, set - // action to new Wield, in case of - // instant primary actions - if character.action == Idle { - character.action = Wield { - time_left: wield_duration, - }; - } - - match kind { - // Magical Bolt - item::Tool::Staff - if character.movement == Stand && character.action.is_action_finished() => - { - server_emitter.emit(ServerEvent::Shoot { - entity, - dir: inputs.look_dir, - body: comp::Body::Object(comp::object::Body::BoltFire), - gravity: Some(comp::Gravity(0.0)), - light: Some(comp::LightEmitter { - col: (0.72, 0.11, 0.11).into(), - strength: 10.0, - offset: Vec3::new(0.0, -5.0, 2.0), - }), - projectile: Projectile { - owner: *uid, - hit_ground: vec![projectile::Effect::Vanish], - hit_wall: vec![projectile::Effect::Vanish], - hit_entity: vec![ - projectile::Effect::Damage(HealthChange { - amount: -(*power as i32), - cause: HealthSource::Attack { by: *uid }, - }), - projectile::Effect::Vanish, - ], - time_left: Duration::from_secs(5), - }, - }); - // TODO: Don't play melee animation - Attack { - time_left: attack_duration, - applied: true, // We don't want to do a melee attack - } - } - - // Go upward - item::Tool::Debug(item::Debug::Boost) => { - local_emitter.emit(LocalEvent::Boost { - entity, - vel: Vec3::new(0.0, 0.0, 7.0), - }); - - character.action - } - - // All other weapons block - _ if character.action.is_action_finished() => Block { - time_active: Duration::from_secs(0), - }, - - _ => character.action, - } - } - - _ => character.action, - } - } -} - impl<'a> System<'a> for Sys { type SystemData = ( Entities<'a>, @@ -245,442 +28,30 @@ impl<'a> System<'a> for Sys { Read<'a, EventBus>, Read<'a, DeltaTime>, WriteStorage<'a, Controller>, - WriteStorage<'a, CharacterState>, - ReadStorage<'a, Stats>, - ReadStorage<'a, Body>, - ReadStorage<'a, Vel>, - ReadStorage<'a, PhysicsState>, ReadStorage<'a, Uid>, - ReadStorage<'a, Mounting>, ); fn run( &mut self, - ( - entities, - uid_allocator, - server_bus, - local_bus, - dt, - mut controllers, - mut character_states, - stats, - bodies, - velocities, - physics_states, - uids, - mountings, - ): Self::SystemData, + (entities, uid_allocator, server_bus, local_bus, dt, mut controllers, uids): Self::SystemData, ) { let mut server_emitter = server_bus.emitter(); let mut local_emitter = local_bus.emitter(); - for (entity, uid, controller, mut character, stats, body, vel, physics, mount) in ( - &entities, - &uids, - &mut controllers, - &mut character_states, - &stats, - &bodies, - &velocities, - &physics_states, - mountings.maybe(), - ) - .join() - { + for (entity, uid, controller) in (&entities, &uids, &mut controllers).join() { let inputs = &mut controller.inputs; - // --------------------------------------- - // Common actions for multiple states as closure fn's for convenience - // Returns a Wield action, or Idle if nothing to wield - let try_wield = |stats: &Stats| -> ActionState { - // Get weapon to wield - if let Some(ItemKind::Tool { kind, .. }) = - stats.equipment.main.as_ref().map(|i| &i.kind) - { - let wield_duration = kind.wield_duration(); - Wield { - time_left: wield_duration, - } - } else { - Idle - } + // Update `inputs.move_dir`. + inputs.move_dir = if inputs.move_dir.magnitude_squared() > 1.0 { + // Cap move_dir to 1 + inputs.move_dir.normalized() + } else { + inputs.move_dir }; - let get_state_from_move_dir = |move_dir: &Vec2| -> MovementState { - if move_dir.magnitude_squared() > 0.0 { - Run - } else { - Stand - } - }; - - // End common actions - // --------------------------------------- - - // Being dead overrides all other states - if stats.is_dead { - // Only options: click respawn - // prevent instant-respawns (i.e. player was holding attack) - // by disallowing while input is held down - if inputs.respawn.is_pressed() && !inputs.respawn.is_held_down() { - server_emitter.emit(ServerEvent::Respawn(entity)); - } - // Or do nothing - continue; - } - // If mounted, character state is controlled by mount - if mount.is_some() { - character.movement = Sit; - continue; - } - - inputs.update_look_dir(); - inputs.update_move_dir(); - - match (character.action, character.movement) { - // Jumping, one frame state that calls jump server event - (_, Jump) => { - character.movement = Fall; - local_emitter.emit(LocalEvent::Jump(entity)); - } - // Charging + Any Movement, prioritizes finishing charge - // over movement states - (Charge { time_left }, _) => { - inputs.update_move_dir(); - if time_left == Duration::default() || vel.0.magnitude_squared() < 10.0 { - character.action = try_wield(stats); - } else { - character.action = Charge { - time_left: time_left - .checked_sub(Duration::from_secs_f32(dt.0)) - .unwrap_or_default(), - }; - } - if let Some(uid_b) = physics.touch_entity { - server_emitter.emit(ServerEvent::Damage { - uid: uid_b, - change: HealthChange { - amount: -20, - cause: HealthSource::Attack { by: *uid }, - }, - }); - - character.action = try_wield(stats); - } - } - // Rolling + Any Movement, prioritizes finishing charge - // over movement states - ( - Roll { - time_left, - was_wielding, - }, - _, - ) => { - if time_left == Duration::default() { - if was_wielding { - character.action = try_wield(stats); - } else { - character.action = Idle; - } - } else { - character.action = Roll { - time_left: time_left - .checked_sub(Duration::from_secs_f32(dt.0)) - .unwrap_or_default(), - was_wielding, - } - } - } - // Any Action + Falling - (action_state, Fall) => { - character.movement = get_state_from_move_dir(&inputs.move_dir); - if inputs.glide.is_pressed() { - character.movement = Glide; - continue; - } - // Try to climb - if let (true, Some(_wall_dir)) = ( - inputs.climb.is_pressed() | inputs.climb_down.is_pressed() - && body.is_humanoid(), - physics.on_wall, - ) { - character.movement = Climb; - continue; - } - // Reset to Falling while not standing on ground, - // otherwise keep the state given above - if !physics.on_ground { - if physics.in_fluid { - character.movement = Swim; - } else { - character.movement = Fall; - } - } else { - character.movement = Stand; - continue; - } - - match action_state { - // Unwield if buttons pressed - Wield { .. } | Attack { .. } => { - if inputs.toggle_wield.is_just_pressed() { - character.action = Idle; - } - } - // Try to wield if any of buttons pressed - Idle => { - if inputs.primary.is_pressed() || inputs.secondary.is_pressed() { - character.action = try_wield(stats); - continue; - } - } - // Cancel blocks - Block { .. } => { - character.action = try_wield(stats); - continue; - } - // Don't change action - Charge { .. } | Roll { .. } => {} - } - if inputs.primary.is_pressed() { - character.action = Self::handle_primary( - inputs, - character, - stats, - entity, - uid, - &mut server_emitter, - &mut local_emitter, - ); - } else if inputs.secondary.is_pressed() { - character.action = Self::handle_secondary( - inputs, - character, - stats, - entity, - uid, - &mut server_emitter, - &mut local_emitter, - ); - } - } - // Any Action + Swimming - (_action_state, Swim) => { - character.movement = get_state_from_move_dir(&inputs.move_dir); - - if !physics.on_ground && physics.in_fluid { - character.movement = Swim; - } - if inputs.primary.is_pressed() { - character.action = Self::handle_primary( - inputs, - character, - stats, - entity, - uid, - &mut server_emitter, - &mut local_emitter, - ); - } else if inputs.secondary.is_pressed() { - character.action = Self::handle_secondary( - inputs, - character, - stats, - entity, - uid, - &mut server_emitter, - &mut local_emitter, - ); - } - } - // Blocking, restricted look_dir compared to other states - (Block { .. }, Stand) | (Block { .. }, Run) => { - character.movement = get_state_from_move_dir(&inputs.move_dir); - - if !inputs.secondary.is_pressed() { - character.action = try_wield(stats); - } else { - character.action = Self::handle_secondary( - inputs, - character, - stats, - entity, - uid, - &mut server_emitter, - &mut local_emitter, - ); - } - - if !physics.on_ground { - if physics.in_fluid { - character.movement = Swim; - } else { - character.movement = Fall; - } - } - } - // Standing and Running states, typical states :shrug: - (action_state, Run) | (action_state, Stand) => { - character.movement = get_state_from_move_dir(&inputs.move_dir); - // Try to sit - if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { - character.movement = Sit; - continue; - } - - // Try to climb - if let (true, Some(_wall_dir)) = ( - inputs.climb.is_pressed() | inputs.climb_down.is_pressed() - && body.is_humanoid(), - physics.on_wall, - ) { - character.movement = Climb; - continue; - } - - // Try to swim - if !physics.on_ground { - if physics.in_fluid { - character.movement = Swim; - } else { - character.movement = Fall; - } - } - - // While on ground ... - if physics.on_ground { - // Try to jump - if inputs.jump.is_pressed() { - character.movement = Jump; - continue; - } - - // Try to charge - if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { - character.action = Charge { - time_left: Duration::from_millis(250), - }; - continue; - } - - // Try to roll - if character.movement == Run - && inputs.roll.is_pressed() - && body.is_humanoid() - { - character.action = Roll { - time_left: ROLL_DURATION, - was_wielding: character.action.is_wield(), - }; - continue; - } - } - // While not on ground ... - else { - // Try to glide - if physics.on_wall == None - && inputs.glide.is_pressed() - && body.is_humanoid() - { - character.movement = Glide; - continue; - } - } - - // Tool Actions - if inputs.toggle_wield.is_just_pressed() { - match action_state { - Wield { .. } | Attack { .. } => { - // Prevent instantaneous reequipping by checking - // for done wielding - if character.action.is_action_finished() { - character.action = Idle; - } - continue; - } - Idle => { - character.action = try_wield(stats); - continue; - } - Charge { .. } | Roll { .. } | Block { .. } => {} - } - } - if inputs.primary.is_pressed() { - character.action = Self::handle_primary( - inputs, - character, - stats, - entity, - uid, - &mut server_emitter, - &mut local_emitter, - ); - } else if inputs.secondary.is_pressed() { - character.action = Self::handle_secondary( - inputs, - character, - stats, - entity, - uid, - &mut server_emitter, - &mut local_emitter, - ); - } - } - // Sitting - (_, Sit) => { - character.action = Idle; - character.movement = get_state_from_move_dir(&inputs.move_dir); - - // character.movement will be Stand after updating when - // no movement has occurred - if character.movement == Stand { - character.movement = Sit; - } - if inputs.jump.is_pressed() { - character.movement = Jump; - continue; - } - if !physics.on_ground { - character.movement = Fall; - } - } - // Any Action + Gliding, shouldnt care about action, - // because should be Idle - (_, Glide) => { - character.action = Idle; - - if !inputs.glide.is_pressed() { - character.movement = Fall; - } else if let Some(_wall_dir) = physics.on_wall { - character.movement = Climb; - } - - if physics.on_ground { - character.movement = Stand - } - } - // Any Action + Climbing, shouldnt care about action, - // because should be Idle - (_, Climb) => { - character.action = Idle; - if let None = physics.on_wall { - if inputs.jump.is_pressed() { - character.movement = Jump; - } else { - character.movement = Fall; - } - } - if physics.on_ground { - character.movement = Stand; - } - } // In case of adding new states - // (_, _) => { - // println!("UNKNOWN STATE"); - // character.action = Idle; - // character.movement = Fall; - // } - }; + // Update `inputs.look_dir` + inputs + .look_dir + .try_normalized() + .unwrap_or(inputs.move_dir.into()); // Process other controller events for event in controller.events.drain(..) { diff --git a/common/src/sys/mod.rs b/common/src/sys/mod.rs index f9f154c82d..b490c19354 100644 --- a/common/src/sys/mod.rs +++ b/common/src/sys/mod.rs @@ -1,4 +1,5 @@ pub mod agent; +pub mod character_state; mod cleanup; pub mod combat; pub mod controller; @@ -12,6 +13,7 @@ use specs::DispatcherBuilder; // System names const AGENT_SYS: &str = "agent_sys"; +const CHARACTER_STATE_SYS: &str = "character_state_sys"; const CONTROLLER_SYS: &str = "controller_sys"; const PHYS_SYS: &str = "phys_sys"; const MOVEMENT_SYS: &str = "movement_sys"; @@ -23,7 +25,8 @@ const CLEANUP_SYS: &str = "cleanup_sys"; pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) { dispatch_builder.add(agent::Sys, AGENT_SYS, &[]); dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS]); - dispatch_builder.add(movement::Sys, MOVEMENT_SYS, &[]); + dispatch_builder.add(character_state::Sys, CHARACTER_STATE_SYS, &[CONTROLLER_SYS]); + dispatch_builder.add(movement::Sys, MOVEMENT_SYS, &[CHARACTER_STATE_SYS]); dispatch_builder.add(combat::Sys, COMBAT_SYS, &[CONTROLLER_SYS]); dispatch_builder.add(stats::Sys, STATS_SYS, &[COMBAT_SYS]); dispatch_builder.add( diff --git a/common/src/sys/movement.rs b/common/src/sys/movement.rs index 6bd3b797ee..531acc9da0 100644 --- a/common/src/sys/movement.rs +++ b/common/src/sys/movement.rs @@ -105,6 +105,10 @@ impl<'a> System<'a> for Sys { ) .join() { + if character.movement == Run || character.movement == Stand { + continue; + } + if stats.is_dead { continue; } From e40eb2ba20bd00fa6d8c5e2713b6f7ff6ce51541 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Fri, 20 Dec 2019 08:50:54 -0800 Subject: [PATCH 002/326] Finish Stand handle() (untested) --- common/src/comp/character_state.rs | 58 ++++++++++++++++++++++++------ common/src/sys/character_state.rs | 19 ++++++---- 2 files changed, 59 insertions(+), 18 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 86588381ce..192af702ef 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,4 +1,6 @@ -use crate::comp::{Body, CharacterState, Controller, ControllerInputs, PhysicsState}; +use crate::comp::{ + Body, CharacterState, Controller, ControllerInputs, ItemKind, PhysicsState, Stats, +}; use specs::{Component, FlaggedStorage, HashMapStorage}; use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System}; use sphynx::{Uid, UidAllocator}; @@ -10,6 +12,7 @@ pub trait State { &self, character: &CharacterState, inputs: &ControllerInputs, + stats: &Stats, body: &Body, physics: &PhysicsState, ) -> CharacterState; @@ -25,6 +28,7 @@ impl State for StandData { &self, character: &CharacterState, inputs: &ControllerInputs, + stats: &Stats, body: &Body, physics: &PhysicsState, ) -> CharacterState { @@ -100,26 +104,45 @@ impl State for StandData { && !inputs.glide.is_held_down() && body.is_humanoid() { - character.movement = Glide; - continue; + return CharacterState { + action: Idle, + movement: Glide, + }; } - character.movement = Fall; + return CharacterState { + action: character.action, + movement: Fall, + }; } // Tool Actions if inputs.toggle_wield.is_just_pressed() { - match action_state { + match character.action { Wield { .. } | Attack { .. } => { // Prevent instantaneous reequipping by checking // for done wielding if character.action.is_action_finished() { - character.action = Idle; + return CharacterState { + action: Idle, + movement: character.movement, + }; } - continue; } Idle => { - character.action = try_wield(stats); - continue; + return CharacterState { + // Try to wield if an item is equipped in main hand + action: if let Some(ItemKind::Tool { kind, .. }) = + stats.equipment.main.as_ref().map(|i| &i.kind) + { + let wield_duration = kind.wield_duration(); + Wield { + time_left: wield_duration, + } + } else { + Idle + }, + movement: character.movement, + }; } Charge { .. } | Roll { .. } | Block { .. } => {} } @@ -129,14 +152,27 @@ impl State for StandData { } else if inputs.secondary.is_pressed() { // TODO: SecondaryStart } + + if inputs.move_dir.magnitude_squared() > 0.0 { + return CharacterState { + action: character.action, + movement: Run(RunData), + }; + } else { + return CharacterState { + action: character.action, + movement: Stand(StandData), + }; + } + return character; } } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum MovementState { - Stand(Stand), + Stand(StandData), Sit, - Run(Run), + Run(RunData), Jump, Fall, Glide, diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index d5373c4390..c6fb92407e 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,9 +1,14 @@ use super::movement::ROLL_DURATION; use crate::{ comp::{ - self, item, projectile, ActionState, ActionState::*, Body, CharacterState, ControlEvent, - Controller, ControllerInputs, HealthChange, HealthSource, ItemKind, Mounting, - MovementState, MovementState::*, PhysicsState, Projectile, Stats, Vel, + self, item, projectile, ActionState, + ActionState::*, + Body, CharacterState, + CharacterState::{RunData, StandData}, + ControlEvent, Controller, ControllerInputs, HealthChange, HealthSource, ItemKind, Mounting, + MovementState, + MovementState::*, + PhysicsState, Projectile, Stats, Vel, }, event::{Emitter, EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -88,9 +93,9 @@ impl<'a> System<'a> for Sys { let get_state_from_move_dir = |move_dir: &Vec2| -> MovementState { if move_dir.magnitude_squared() > 0.0 { - Run(_) + Run(RunData) } else { - Stand(_) + Stand(StandData) } }; @@ -204,7 +209,7 @@ impl<'a> System<'a> for Sys { character.movement = Fall; } } else { - character.movement = Stand(comp::character_state::Stand); + character.movement = Stand(StandData); continue; } @@ -354,7 +359,7 @@ impl<'a> System<'a> for Sys { // character.movement will be Stand after updating when // no movement has occurred - if character.movement == Stand(_) { + if character.movement == Stand(StandData) { character.movement = Sit; } if inputs.jump.is_pressed() && !inputs.jump.is_held_down() { From 1ab09220b0c5dc73ce6e39084ede7baced497557 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sat, 21 Dec 2019 07:57:15 -0800 Subject: [PATCH 003/326] Rudimentary Stand State handle() move --- common/src/comp/character_state.rs | 159 +----------------- common/src/comp/mod.rs | 2 +- common/src/sys/character_state.rs | 232 ++++++++++++++++++++++++-- common/src/sys/movement.rs | 7 +- voxygen/src/audio/sfx/event_mapper.rs | 2 +- voxygen/src/scene/figure/mod.rs | 54 +++--- 6 files changed, 253 insertions(+), 203 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 192af702ef..1df20ddde1 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,173 +1,16 @@ -use crate::comp::{ - Body, CharacterState, Controller, ControllerInputs, ItemKind, PhysicsState, Stats, -}; +use crate::comp::{Body, Controller, ControllerInputs, ItemKind, PhysicsState, Stats}; use specs::{Component, FlaggedStorage, HashMapStorage}; use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System}; use sphynx::{Uid, UidAllocator}; //use specs_idvs::IDVStorage; use self::{ActionState::*, MovementState::*}; use std::time::Duration; -pub trait State { - fn handle( - &self, - character: &CharacterState, - inputs: &ControllerInputs, - stats: &Stats, - body: &Body, - physics: &PhysicsState, - ) -> CharacterState; -} #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct RunData; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct StandData; -impl State for StandData { - fn handle( - &self, - character: &CharacterState, - inputs: &ControllerInputs, - stats: &Stats, - body: &Body, - physics: &PhysicsState, - ) -> CharacterState { - let mut new_move: MovementState = if inputs.move_dir.magnitude_squared() > 0.0 { - MovementState::Run(RunData) - } else { - MovementState::Stand(StandData) - }; - - // Try to sit - if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { - return CharacterState { - movement: Sit, - action: Idle, - }; - } - - // Try to climb - if let (true, Some(_wall_dir)) = ( - inputs.climb.is_pressed() | inputs.climb_down.is_pressed() && body.is_humanoid(), - physics.on_wall, - ) { - return CharacterState { - movement: Climb, - action: Idle, - }; - } - - // Try to swim - if !physics.on_ground && physics.in_fluid { - return CharacterState { - action: character.action, - movement: Swim, - }; - } - - // While on ground ... - if physics.on_ground { - // Try to jump - if inputs.jump.is_pressed() && !inputs.jump.is_held_down() { - return CharacterState { - action: character.action, - movement: Jump, - }; - } - - // Try to charge - if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { - return CharacterState { - action: Charge { - time_left: Duration::from_millis(250), - }, - movement: Run(RunData), - }; - } - - // Try to roll - if inputs.roll.is_pressed() && body.is_humanoid() { - return CharacterState { - action: Roll { - time_left: Duration::from_millis(600), - was_wielding: character.action.is_wield(), - }, - movement: Run(RunData), - }; - } - } - // While not on ground ... - else { - // Try to glide - if physics.on_wall == None - && inputs.glide.is_pressed() - && !inputs.glide.is_held_down() - && body.is_humanoid() - { - return CharacterState { - action: Idle, - movement: Glide, - }; - } - return CharacterState { - action: character.action, - movement: Fall, - }; - } - - // Tool Actions - if inputs.toggle_wield.is_just_pressed() { - match character.action { - Wield { .. } | Attack { .. } => { - // Prevent instantaneous reequipping by checking - // for done wielding - if character.action.is_action_finished() { - return CharacterState { - action: Idle, - movement: character.movement, - }; - } - } - Idle => { - return CharacterState { - // Try to wield if an item is equipped in main hand - action: if let Some(ItemKind::Tool { kind, .. }) = - stats.equipment.main.as_ref().map(|i| &i.kind) - { - let wield_duration = kind.wield_duration(); - Wield { - time_left: wield_duration, - } - } else { - Idle - }, - movement: character.movement, - }; - } - Charge { .. } | Roll { .. } | Block { .. } => {} - } - } - if inputs.primary.is_pressed() { - // TODO: PrimaryStart - } else if inputs.secondary.is_pressed() { - // TODO: SecondaryStart - } - - if inputs.move_dir.magnitude_squared() > 0.0 { - return CharacterState { - action: character.action, - movement: Run(RunData), - }; - } else { - return CharacterState { - action: character.action, - movement: Stand(StandData), - }; - } - return character; - } -} - #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum MovementState { Stand(StandData), diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 42f8e6e161..a119bf10a6 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -20,7 +20,7 @@ pub use body::{ biped_large, bird_medium, bird_small, dragon, fish_medium, fish_small, humanoid, object, quadruped_medium, quadruped_small, Body, }; -pub use character_state::{ActionState, CharacterState, MovementState}; +pub use character_state::{ActionState, CharacterState, MovementState, RunData, StandData}; pub use controller::{ ControlEvent, Controller, ControllerInputs, Input, InputState, InventoryManip, MountState, Mounting, diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index c6fb92407e..8a26c82e5b 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,14 +1,12 @@ use super::movement::ROLL_DURATION; +const HUMANOID_ACCEL: f32 = 50.0; +const HUMANOID_SPEED: f32 = 120.0; use crate::{ comp::{ - self, item, projectile, ActionState, - ActionState::*, - Body, CharacterState, - CharacterState::{RunData, StandData}, - ControlEvent, Controller, ControllerInputs, HealthChange, HealthSource, ItemKind, Mounting, - MovementState, - MovementState::*, - PhysicsState, Projectile, Stats, Vel, + self, item, projectile, ActionState, ActionState::*, Body, CharacterState, ControlEvent, + Controller, ControllerInputs, HealthChange, HealthSource, ItemKind, Mounting, + MovementState, MovementState::*, Ori, PhysicsState, Pos, Projectile, RunData, StandData, + Stats, Vel, }, event::{Emitter, EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -33,10 +31,12 @@ impl<'a> System<'a> for Sys { Read<'a, EventBus>, Read<'a, DeltaTime>, WriteStorage<'a, CharacterState>, + WriteStorage<'a, Pos>, + WriteStorage<'a, Vel>, + WriteStorage<'a, Ori>, ReadStorage<'a, Controller>, ReadStorage<'a, Stats>, ReadStorage<'a, Body>, - ReadStorage<'a, Vel>, ReadStorage<'a, PhysicsState>, ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, @@ -50,10 +50,12 @@ impl<'a> System<'a> for Sys { local_bus, dt, mut character_states, + mut positions, + mut velocities, + mut orientations, controllers, stats, bodies, - velocities, physics_states, uids, mountings, @@ -61,14 +63,28 @@ impl<'a> System<'a> for Sys { ) { let mut server_emitter = server_bus.emitter(); let mut local_emitter = local_bus.emitter(); - for (entity, uid, mut character, controller, stats, body, vel, physics, mount) in ( + for ( + entity, + uid, + mut character, + mut pos, + mut vel, + mut ori, + controller, + stats, + body, + physics, + mount, + ) in ( &entities, &uids, &mut character_states, + &mut positions, + &mut velocities, + &mut orientations, &controllers, &stats, &bodies, - &velocities, &physics_states, mountings.maybe(), ) @@ -382,7 +398,7 @@ impl<'a> System<'a> for Sys { } if physics.on_ground { - character.movement = Stand(Stand) + character.movement = Stand(StandData) } } // Any Action + Climbing, shouldnt care about action, @@ -397,9 +413,197 @@ impl<'a> System<'a> for Sys { } } if physics.on_ground { - character.movement = Stand(Stand); + character.movement = Stand(StandData); } } + (_, Stand(data)) => { + let mut new_char = + data.handle(character, pos, vel, ori, &dt, inputs, stats, body, physics); + println!("{:?}", new_char); + character = &mut new_char; + } + (_, _) => { + character.movement = Stand(StandData); + } + }; + } + } +} + +pub trait State { + fn handle( + &self, + character: &CharacterState, + pos: &mut Pos, + vel: &mut Vel, + ori: &mut Ori, + dt: &DeltaTime, + inputs: &ControllerInputs, + stats: &Stats, + body: &Body, + physics: &PhysicsState, + ) -> CharacterState; +} + +impl State for StandData { + fn handle( + &self, + character: &CharacterState, + pos: &mut Pos, + vel: &mut Vel, + ori: &mut Ori, + dt: &DeltaTime, + inputs: &ControllerInputs, + stats: &Stats, + body: &Body, + physics: &PhysicsState, + ) -> CharacterState { + // Move player according to move_dir + vel.0 += Vec2::broadcast(dt.0) + * inputs.move_dir + * if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { + HUMANOID_ACCEL + } else { + 0.0 + }; + + // Set direction based on move direction when on the ground + let ori_dir = if character.action.is_attack() || character.action.is_block() { + Vec2::from(inputs.look_dir).normalized() + } else { + Vec2::from(vel.0) + }; + + if ori_dir.magnitude_squared() > 0.0001 + && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 + { + ori.0 = vek::ops::Slerp::slerp(ori.0, ori_dir.into(), 9.0 * dt.0); + } + + // Try to sit + if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { + return CharacterState { + movement: Sit, + action: Idle, + }; + } + + // Try to climb + if let (true, Some(_wall_dir)) = ( + inputs.climb.is_pressed() | inputs.climb_down.is_pressed() && body.is_humanoid(), + physics.on_wall, + ) { + return CharacterState { + movement: Climb, + action: Idle, + }; + } + + // Try to swim + if !physics.on_ground && physics.in_fluid { + return CharacterState { + action: character.action, + movement: Swim, + }; + } + + // While on ground ... + if physics.on_ground { + // Try to jump + if inputs.jump.is_pressed() && !inputs.jump.is_held_down() { + return CharacterState { + action: character.action, + movement: Jump, + }; + } + + // Try to charge + if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { + return CharacterState { + action: Charge { + time_left: Duration::from_millis(250), + }, + movement: Run(RunData), + }; + } + + // Try to roll + if inputs.roll.is_pressed() && body.is_humanoid() { + return CharacterState { + action: Roll { + time_left: Duration::from_millis(600), + was_wielding: character.action.is_wield(), + }, + movement: Run(RunData), + }; + } + } + // While not on ground ... + else { + // Try to glide + if physics.on_wall == None + && inputs.glide.is_pressed() + && !inputs.glide.is_held_down() + && body.is_humanoid() + { + return CharacterState { + action: Idle, + movement: Glide, + }; + } + return CharacterState { + action: character.action, + movement: Fall, + }; + } + + // Tool Actions + if inputs.toggle_wield.is_just_pressed() { + match character.action { + Wield { .. } | Attack { .. } => { + // Prevent instantaneous reequipping by checking + // for done wielding + if character.action.is_action_finished() { + return CharacterState { + action: Idle, + movement: character.movement, + }; + } + } + Idle => { + return CharacterState { + // Try to wield if an item is equipped in main hand + action: if let Some(ItemKind::Tool { kind, .. }) = + stats.equipment.main.as_ref().map(|i| &i.kind) + { + let wield_duration = kind.wield_duration(); + Wield { + time_left: wield_duration, + } + } else { + Idle + }, + movement: character.movement, + }; + } + Charge { .. } | Roll { .. } | Block { .. } => {} + } + } + if inputs.primary.is_pressed() { + // TODO: PrimaryStart + } else if inputs.secondary.is_pressed() { + // TODO: SecondaryStart + } + + if inputs.move_dir.magnitude_squared() > 0.0 { + return CharacterState { + action: character.action, + movement: Run(RunData), + }; + } else { + return CharacterState { + action: character.action, + movement: Stand(StandData), }; } } diff --git a/common/src/sys/movement.rs b/common/src/sys/movement.rs index 531acc9da0..bcbb29436b 100644 --- a/common/src/sys/movement.rs +++ b/common/src/sys/movement.rs @@ -1,7 +1,8 @@ use super::phys::GRAVITY; use crate::{ comp::{ - CharacterState, Controller, Mounting, MovementState::*, Ori, PhysicsState, Pos, Stats, Vel, + CharacterState, Controller, Mounting, MovementState::*, Ori, PhysicsState, Pos, RunData, + StandData, Stats, Vel, }, event::{EventBus, ServerEvent}, state::DeltaTime, @@ -105,7 +106,7 @@ impl<'a> System<'a> for Sys { ) .join() { - if character.movement == Run || character.movement == Stand { + if character.movement == Run(RunData) || character.movement == Stand(StandData) { continue; } @@ -145,7 +146,7 @@ impl<'a> System<'a> for Sys { vel.0 += Vec2::broadcast(dt.0) * inputs.move_dir * match (physics.on_ground, &character.movement) { - (true, Run) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => { + (true, Run(_)) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => { HUMANOID_ACCEL } (false, Climb) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => { diff --git a/voxygen/src/audio/sfx/event_mapper.rs b/voxygen/src/audio/sfx/event_mapper.rs index 8524f04fc8..2873f2d590 100644 --- a/voxygen/src/audio/sfx/event_mapper.rs +++ b/voxygen/src/audio/sfx/event_mapper.rs @@ -162,7 +162,7 @@ impl SfxEventMapper { (_, ActionState::Roll { .. }, ..) => SfxEvent::Roll, (MovementState::Climb, ..) => SfxEvent::Climb, (MovementState::Swim, ..) => SfxEvent::Swim, - (MovementState::Run, ..) => SfxEvent::Run, + (MovementState::Run(_), ..) => SfxEvent::Run, (MovementState::Fall, _, previous_event, _) => { if previous_event != SfxEvent::Glide { SfxEvent::Fall diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index ddecd67043..7c7319f74e 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -197,14 +197,14 @@ impl FigureMgr { } let target_base = match &character.movement { - Stand => anim::character::StandAnimation::update_skeleton( + Stand(_) => anim::character::StandAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, time), state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::character::RunAnimation::update_skeleton( + Run(_) => anim::character::RunAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0, ori.0, state.last_ori, time), state.movement_time, @@ -248,14 +248,16 @@ impl FigureMgr { ), }; let target_bones = match (&character.movement, &character.action) { - (Stand, Wield { .. }) => anim::character::CidleAnimation::update_skeleton( - &target_base, - (active_tool_kind, time), - state.action_time, - &mut action_animation_rate, - skeleton_attr, - ), - (Stand, Block { .. }) => { + (Stand(_), Wield { .. }) => { + anim::character::CidleAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.action_time, + &mut action_animation_rate, + skeleton_attr, + ) + } + (Stand(_), Block { .. }) => { anim::character::BlockIdleAnimation::update_skeleton( &target_base, (active_tool_kind, time), @@ -333,14 +335,14 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::quadruped_small::IdleAnimation::update_skeleton( + Stand(_) => anim::quadruped_small::IdleAnimation::update_skeleton( &QuadrupedSmallSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::quadruped_small::RunAnimation::update_skeleton( + Run(_) => anim::quadruped_small::RunAnimation::update_skeleton( &QuadrupedSmallSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -390,14 +392,14 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::quadruped_medium::IdleAnimation::update_skeleton( + Stand(_) => anim::quadruped_medium::IdleAnimation::update_skeleton( &QuadrupedMediumSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::quadruped_medium::RunAnimation::update_skeleton( + Run(_) => anim::quadruped_medium::RunAnimation::update_skeleton( &QuadrupedMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -445,14 +447,14 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::bird_medium::IdleAnimation::update_skeleton( + Stand(_) => anim::bird_medium::IdleAnimation::update_skeleton( &BirdMediumSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::bird_medium::RunAnimation::update_skeleton( + Run(_) => anim::bird_medium::RunAnimation::update_skeleton( &BirdMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -500,14 +502,14 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::fish_medium::IdleAnimation::update_skeleton( + Stand(_) => anim::fish_medium::IdleAnimation::update_skeleton( &FishMediumSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::fish_medium::RunAnimation::update_skeleton( + Run(_) => anim::fish_medium::RunAnimation::update_skeleton( &FishMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -555,14 +557,14 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::dragon::IdleAnimation::update_skeleton( + Stand(_) => anim::dragon::IdleAnimation::update_skeleton( &DragonSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::dragon::RunAnimation::update_skeleton( + Run(_) => anim::dragon::RunAnimation::update_skeleton( &DragonSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -610,14 +612,14 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::bird_small::IdleAnimation::update_skeleton( + Stand(_) => anim::bird_small::IdleAnimation::update_skeleton( &BirdSmallSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::bird_small::RunAnimation::update_skeleton( + Run(_) => anim::bird_small::RunAnimation::update_skeleton( &BirdSmallSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -665,14 +667,14 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::fish_small::IdleAnimation::update_skeleton( + Stand(_) => anim::fish_small::IdleAnimation::update_skeleton( &FishSmallSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::fish_small::RunAnimation::update_skeleton( + Run(_) => anim::fish_small::RunAnimation::update_skeleton( &FishSmallSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -720,14 +722,14 @@ impl FigureMgr { } let target_base = match character.movement { - Stand => anim::biped_large::IdleAnimation::update_skeleton( + Stand(_) => anim::biped_large::IdleAnimation::update_skeleton( &BipedLargeSkeleton::new(), time, state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Run => anim::biped_large::RunAnimation::update_skeleton( + Run(_) => anim::biped_large::RunAnimation::update_skeleton( &BipedLargeSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, From c2ceabea0e2c2e382ab391cc9f9f778462e368bf Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sun, 22 Dec 2019 08:08:48 -0800 Subject: [PATCH 004/326] finish movment states handle() fn logic --- .DS_Store | Bin 0 -> 6148 bytes common/src/comp/character_state.rs | 26 +- common/src/comp/mod.rs | 5 +- common/src/sys/agent.rs | 7 +- common/src/sys/character_state.rs | 1043 ++++++++++++++++++------- common/src/sys/movement.rs | 232 +++--- voxygen/src/audio/sfx/event_mapper.rs | 8 +- voxygen/src/scene/figure/mod.rs | 26 +- 8 files changed, 930 insertions(+), 417 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8cda30a1a4792f56e6be97fda60289fc9c97c759 GIT binary patch literal 6148 zcmeHKyH3L}6g`GgN|AsK#*8c=F|&j|gevincaS^ve!>5#;9oUf%wdSE;QLnMD=`ch$97Q?FF%-SOn* zKR52#Vzotsp$-ZJ1%d)!3dr{%ViAlj<_7hrgOxr45G(A~#b{p7ITA!4rLD?%Fe9p2}SAIIew(wp<;uf4hjSXd Self { Self { - movement: MovementState::Jump, + movement: MovementState::Fall(FallData), action: ActionState::Idle, } } diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index a119bf10a6..1f2e894539 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -20,7 +20,10 @@ pub use body::{ biped_large, bird_medium, bird_small, dragon, fish_medium, fish_small, humanoid, object, quadruped_medium, quadruped_small, Body, }; -pub use character_state::{ActionState, CharacterState, MovementState, RunData, StandData}; +pub use character_state::{ + ActionState, CharacterState, ClimbData, FallData, GlideData, JumpData, MovementState, RunData, + SitData, StandData, SwimData, +}; pub use controller::{ ControlEvent, Controller, ControllerInputs, Input, InputState, InventoryManip, MountState, Mounting, diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index c2bcbe1c2a..f0df4a9e0d 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -1,6 +1,6 @@ use crate::comp::{ - Agent, CharacterState, Controller, ControllerInputs, MountState, MovementState::Glide, Pos, - Stats, + Agent, CharacterState, Controller, ControllerInputs, GlideData, MountState, + MovementState::Glide, Pos, Stats, }; use crate::pathfinding::WorldPath; use crate::terrain::TerrainGrid; @@ -163,7 +163,8 @@ impl<'a> System<'a> for Sys { inputs.roll.set_state(true); } - if target_character.movement == Glide && target_pos.0.z > pos.0.z + 5.0 + if target_character.movement == Glide(GlideData) + && target_pos.0.z > pos.0.z + 5.0 { inputs.glide.set_state(true); inputs.jump.set_state(true); diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 8a26c82e5b..716ddacf46 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,12 +1,30 @@ use super::movement::ROLL_DURATION; +use super::phys::GRAVITY; + const HUMANOID_ACCEL: f32 = 50.0; const HUMANOID_SPEED: f32 = 120.0; +const HUMANOID_AIR_ACCEL: f32 = 10.0; +const HUMANOID_AIR_SPEED: f32 = 100.0; +const HUMANOID_WATER_ACCEL: f32 = 70.0; +const HUMANOID_WATER_SPEED: f32 = 120.0; +const HUMANOID_CLIMB_ACCEL: f32 = 5.0; +const ROLL_SPEED: f32 = 17.0; +const CHARGE_SPEED: f32 = 20.0; +const GLIDE_ACCEL: f32 = 15.0; +const GLIDE_SPEED: f32 = 45.0; +const BLOCK_ACCEL: f32 = 30.0; +const BLOCK_SPEED: f32 = 75.0; +// Gravity is 9.81 * 4, so this makes gravity equal to .15 +const GLIDE_ANTIGRAV: f32 = GRAVITY * 0.96; +const CLIMB_SPEED: f32 = 5.0; + +pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; use crate::{ comp::{ - self, item, projectile, ActionState, ActionState::*, Body, CharacterState, ControlEvent, - Controller, ControllerInputs, HealthChange, HealthSource, ItemKind, Mounting, - MovementState, MovementState::*, Ori, PhysicsState, Pos, Projectile, RunData, StandData, - Stats, Vel, + self, item, projectile, ActionState, ActionState::*, Body, CharacterState, ClimbData, + ControlEvent, Controller, ControllerInputs, FallData, GlideData, HealthChange, + HealthSource, ItemKind, JumpData, Mounting, MovementState, MovementState::*, Ori, + PhysicsState, Pos, Projectile, RunData, SitData, StandData, Stats, SwimData, Vel, }, event::{Emitter, EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -19,6 +37,8 @@ use sphynx::{Uid, UidAllocator}; use std::time::Duration; use vek::*; +struct CharacterStateData(); + /// # Character State System /// #### Updates then detemrines next Character States based on ControllerInputs pub struct Sys; @@ -61,8 +81,6 @@ impl<'a> System<'a> for Sys { mountings, ): Self::SystemData, ) { - let mut server_emitter = server_bus.emitter(); - let mut local_emitter = local_bus.emitter(); for ( entity, uid, @@ -91,7 +109,7 @@ impl<'a> System<'a> for Sys { .join() { let inputs = &controller.inputs; - + // println!("{:?}", character); // Returns a Wield action, or Idle if nothing to wield let try_wield = |stats: &Stats| -> ActionState { // Get weapon to wield @@ -121,14 +139,15 @@ impl<'a> System<'a> for Sys { // prevent instant-respawns (i.e. player was holding attack) // by disallowing while input is held down if inputs.respawn.is_pressed() && !inputs.respawn.is_held_down() { - server_emitter.emit(ServerEvent::Respawn(entity)); + server_bus.emitter().emit(ServerEvent::Respawn(entity)); } // Or do nothing continue; } // If mounted, character state is controlled by mount + // TODO: Make mounting a state if mount.is_some() { - character.movement = Sit; + character.movement = Sit(SitData); continue; } @@ -168,263 +187,153 @@ impl<'a> System<'a> for Sys { Idle => {} } - // Determine new states - match (character.action, character.movement) { - // Jumping, one frame state that calls jump server event - (_, Jump) => { - character.movement = Fall; - local_emitter.emit(LocalEvent::Jump(entity)); - } - // Charging + Any Movement, prioritizes finishing charge - // over movement states - (Charge { time_left }, _) => { - if let Some(uid_b) = physics.touch_entity { - server_emitter.emit(ServerEvent::Damage { - uid: uid_b, - change: HealthChange { - amount: -20, - cause: HealthSource::Attack { by: *uid }, - }, - }); + // Determine new state + *character = match character.movement { + Stand(data) => data.handle( + &entity, + character, + pos, + vel, + ori, + &dt, + inputs, + stats, + body, + physics, + &server_bus, + &local_bus, + ), + Run(data) => data.handle( + &entity, + character, + pos, + vel, + ori, + &dt, + inputs, + stats, + body, + physics, + &server_bus, + &local_bus, + ), + Jump(data) => data.handle( + &entity, + character, + pos, + vel, + ori, + &dt, + inputs, + stats, + body, + physics, + &server_bus, + &local_bus, + ), + Climb(data) => data.handle( + &entity, + character, + pos, + vel, + ori, + &dt, + inputs, + stats, + body, + physics, + &server_bus, + &local_bus, + ), + Glide(data) => data.handle( + &entity, + character, + pos, + vel, + ori, + &dt, + inputs, + stats, + body, + physics, + &server_bus, + &local_bus, + ), + Swim(data) => data.handle( + &entity, + character, + pos, + vel, + ori, + &dt, + inputs, + stats, + body, + physics, + &server_bus, + &local_bus, + ), + Fall(data) => data.handle( + &entity, + character, + pos, + vel, + ori, + &dt, + inputs, + stats, + body, + physics, + &server_bus, + &local_bus, + ), + Sit(data) => data.handle( + &entity, + character, + pos, + vel, + ori, + &dt, + inputs, + stats, + body, + physics, + &server_bus, + &local_bus, + ), // Charging + Any Movement, prioritizes finishing charge + // over movement states + // (Charge { time_left }, _) => { + // if let Some(uid_b) = physics.touch_entity { + // server_emitter.emit(ServerEvent::Damage { + // uid: uid_b, + // change: HealthChange { + // amount: -20, + // cause: HealthSource::Attack { by: *uid }, + // }, + // }); - character.action = try_wield(stats); - } else if time_left == Duration::default() || vel.0.magnitude_squared() < 10.0 { - character.action = try_wield(stats); - } - } - // Rolling + Any Movement, prioritizes finishing charge - // over movement states - ( - Roll { - time_left, - was_wielding, - }, - _, - ) => { - if time_left == Duration::default() { - if was_wielding { - character.action = try_wield(stats); - } else { - character.action = Idle; - } - } - } - // Any Action + Falling - (action_state, Fall) => { - // character.movement = get_state_from_move_dir(&inputs.move_dir); - if inputs.glide.is_pressed() && !inputs.glide.is_held_down() { - character.movement = Glide; - continue; - } - // Reset to Falling while not standing on ground, - // otherwise keep the state given above - if !physics.on_ground { - if physics.in_fluid { - character.movement = Swim; - } else { - character.movement = Fall; - } - } else { - character.movement = Stand(StandData); - continue; - } - - match action_state { - // Unwield if buttons pressed - Wield { .. } | Attack { .. } => { - if inputs.toggle_wield.is_just_pressed() { - character.action = Idle; - } - } - // Try to wield if any of buttons pressed - Idle => { - if inputs.primary.is_pressed() || inputs.secondary.is_pressed() { - character.action = try_wield(stats); - } - } - // Cancel blocks - Block { .. } => { - character.action = try_wield(stats); - } - // Don't change action - Charge { .. } | Roll { .. } => {} - } - } - // Any Action + Swimming - (_, Swim) => { - character.movement = get_state_from_move_dir(&inputs.move_dir); - - if !physics.on_ground && physics.in_fluid { - character.movement = Swim; - } - if inputs.primary.is_pressed() { - // TODO: PrimaryStart - } else if inputs.secondary.is_pressed() { - // TODO: SecondaryStart - } - } - // // Blocking, restricted look_dir compared to other states - // (Block { .. }, Stand) | (Block { .. }, Run) => { - // character.movement = get_state_from_move_dir(&inputs.move_dir); - - // if !inputs.secondary.is_pressed() { - // character.action = try_wield(stats); - // } else { - // // TODO: SecondaryStart - // } - - // if !physics.on_ground && physics.in_fluid { - // character.movement = Swim; - // } - // } - // // Standing and Running states, typical states :shrug: - // (action_state, Run) | (action_state, Stand) => { - // character.movement = get_state_from_move_dir(&inputs.move_dir); - // // Try to sit - // if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { - // character.movement = Sit; - // continue; - // } - - // // Try to climb - // if let (true, Some(_wall_dir)) = ( - // inputs.climb.is_pressed() | inputs.climb_down.is_pressed() - // && body.is_humanoid(), - // physics.on_wall, - // ) { - // character.movement = Climb; - // continue; - // } - - // // Try to swim - // if !physics.on_ground && physics.in_fluid { - // character.movement = Swim; - // continue; - // } - - // // While on ground ... - // if physics.on_ground { - // // Try to jump - // if inputs.jump.is_pressed() && !inputs.jump.is_held_down() { - // character.movement = Jump; - // continue; - // } - - // // Try to charge - // if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { - // character.action = Charge { - // time_left: Duration::from_millis(250), - // }; - // continue; - // } - - // // Try to roll - // if character.movement == Run - // && inputs.roll.is_pressed() - // && body.is_humanoid() - // { - // character.action = Roll { - // time_left: ROLL_DURATION, - // was_wielding: character.action.is_wield(), - // }; - // continue; - // } - // } - // // While not on ground ... - // else { - // // Try to glide - // if physics.on_wall == None - // && inputs.glide.is_pressed() - // && !inputs.glide.is_held_down() - // && body.is_humanoid() - // { - // character.movement = Glide; - // continue; - // } - // character.movement = Fall; - // } - - // // Tool Actions - // if inputs.toggle_wield.is_just_pressed() { - // match action_state { - // Wield { .. } | Attack { .. } => { - // // Prevent instantaneous reequipping by checking - // // for done wielding - // if character.action.is_action_finished() { - // character.action = Idle; - // } - // continue; - // } - // Idle => { - // character.action = try_wield(stats); - // continue; - // } - // Charge { .. } | Roll { .. } | Block { .. } => {} - // } - // } - // if inputs.primary.is_pressed() { - // // TODO: PrimaryStart - // } else if inputs.secondary.is_pressed() { - // // TODO: SecondaryStart - // } - // } - // Sitting - (_, Sit) => { - character.action = Idle; - character.movement = get_state_from_move_dir(&inputs.move_dir); - - // character.movement will be Stand after updating when - // no movement has occurred - if character.movement == Stand(StandData) { - character.movement = Sit; - } - if inputs.jump.is_pressed() && !inputs.jump.is_held_down() { - character.movement = Jump; - continue; - } - if !physics.on_ground { - character.movement = Fall; - } - } - // Any Action + Gliding, shouldnt care about action, - // because should be Idle - (_, Glide) => { - character.action = Idle; - - if !inputs.glide.is_pressed() { - character.movement = Fall; - } else if let Some(_wall_dir) = physics.on_wall { - character.movement = Fall; - } - - if physics.on_ground { - character.movement = Stand(StandData) - } - } - // Any Action + Climbing, shouldnt care about action, - // because should be Idle - (_, Climb) => { - character.action = Idle; - if let None = physics.on_wall { - if inputs.jump.is_pressed() { - character.movement = Jump; - } else { - character.movement = Fall; - } - } - if physics.on_ground { - character.movement = Stand(StandData); - } - } - (_, Stand(data)) => { - let mut new_char = - data.handle(character, pos, vel, ori, &dt, inputs, stats, body, physics); - println!("{:?}", new_char); - character = &mut new_char; - } - (_, _) => { - character.movement = Stand(StandData); - } + // character.action = try_wield(stats); + // } else if time_left == Duration::default() || vel.0.magnitude_squared() < 10.0 { + // character.action = try_wield(stats); + // } + // } + // Rolling + Any Movement, prioritizes finishing charge + // over movement states + // ( + // Roll { + // time_left, + // was_wielding, + // }, + // _, + // ) => { + // if time_left == Duration::default() { + // if was_wielding { + // character.action = try_wield(stats); + // } else { + // character.action = Idle; + // } + // } + // } }; } } @@ -433,6 +342,7 @@ impl<'a> System<'a> for Sys { pub trait State { fn handle( &self, + entity: &Entity, character: &CharacterState, pos: &mut Pos, vel: &mut Vel, @@ -442,14 +352,17 @@ pub trait State { stats: &Stats, body: &Body, physics: &PhysicsState, + server_bus: &EventBus, + local_bus: &EventBus, ) -> CharacterState; } -impl State for StandData { +impl State for RunData { fn handle( &self, + _entity: &Entity, character: &CharacterState, - pos: &mut Pos, + _pos: &mut Pos, vel: &mut Vel, ori: &mut Ori, dt: &DeltaTime, @@ -457,6 +370,8 @@ impl State for StandData { stats: &Stats, body: &Body, physics: &PhysicsState, + _server_bus: &EventBus, + _local_bus: &EventBus, ) -> CharacterState { // Move player according to move_dir vel.0 += Vec2::broadcast(dt.0) @@ -483,7 +398,7 @@ impl State for StandData { // Try to sit if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { return CharacterState { - movement: Sit, + movement: Sit(SitData), action: Idle, }; } @@ -494,7 +409,7 @@ impl State for StandData { physics.on_wall, ) { return CharacterState { - movement: Climb, + movement: Climb(ClimbData), action: Idle, }; } @@ -503,7 +418,7 @@ impl State for StandData { if !physics.on_ground && physics.in_fluid { return CharacterState { action: character.action, - movement: Swim, + movement: Swim(SwimData), }; } @@ -513,7 +428,7 @@ impl State for StandData { if inputs.jump.is_pressed() && !inputs.jump.is_held_down() { return CharacterState { action: character.action, - movement: Jump, + movement: Jump(JumpData), }; } @@ -548,12 +463,12 @@ impl State for StandData { { return CharacterState { action: Idle, - movement: Glide, + movement: Glide(GlideData), }; } return CharacterState { action: character.action, - movement: Fall, + movement: Fall(FallData), }; } @@ -608,3 +523,585 @@ impl State for StandData { } } } + +impl State for StandData { + fn handle( + &self, + _entity: &Entity, + character: &CharacterState, + _pos: &mut Pos, + _vel: &mut Vel, + _ori: &mut Ori, + _dt: &DeltaTime, + inputs: &ControllerInputs, + stats: &Stats, + body: &Body, + physics: &PhysicsState, + _server_bus: &EventBus, + _local_bus: &EventBus, + ) -> CharacterState { + // Try to sit + if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { + return CharacterState { + movement: Sit(SitData), + action: Idle, + }; + } + + // Try to climb + if let (true, Some(_wall_dir)) = ( + inputs.climb.is_pressed() | inputs.climb_down.is_pressed() && body.is_humanoid(), + physics.on_wall, + ) { + return CharacterState { + movement: Climb(ClimbData), + action: Idle, + }; + } + + // Try to swim + if !physics.on_ground && physics.in_fluid { + return CharacterState { + action: character.action, + movement: Swim(SwimData), + }; + } + + // While on ground ... + if physics.on_ground { + // Try to jump + if inputs.jump.is_pressed() { + return CharacterState { + action: character.action, + movement: Jump(JumpData), + }; + } + + // Try to charge + if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { + return CharacterState { + action: Charge { + time_left: Duration::from_millis(250), + }, + movement: Run(RunData), + }; + } + + // Try to roll + if inputs.roll.is_pressed() && body.is_humanoid() { + return CharacterState { + action: Roll { + time_left: Duration::from_millis(600), + was_wielding: character.action.is_wield(), + }, + movement: Run(RunData), + }; + } + } + // While not on ground ... + else { + // Try to glide + if physics.on_wall == None + && inputs.glide.is_pressed() + && !inputs.glide.is_held_down() + && body.is_humanoid() + { + return CharacterState { + action: Idle, + movement: Glide(GlideData), + }; + } + return CharacterState { + action: character.action, + movement: Fall(FallData), + }; + } + + // Tool Actions + if inputs.toggle_wield.is_just_pressed() { + match character.action { + Wield { .. } | Attack { .. } => { + // Prevent instantaneous reequipping by checking + // for done wielding + if character.action.is_action_finished() { + return CharacterState { + action: Idle, + movement: character.movement, + }; + } + } + Idle => { + return CharacterState { + // Try to wield if an item is equipped in main hand + action: if let Some(ItemKind::Tool { kind, .. }) = + stats.equipment.main.as_ref().map(|i| &i.kind) + { + let wield_duration = kind.wield_duration(); + Wield { + time_left: wield_duration, + } + } else { + Idle + }, + movement: character.movement, + }; + } + Charge { .. } | Roll { .. } | Block { .. } => {} + } + } + if inputs.primary.is_pressed() { + // TODO: PrimaryStart + } else if inputs.secondary.is_pressed() { + // TODO: SecondaryStart + } + + if inputs.move_dir.magnitude_squared() > 0.0 { + return CharacterState { + action: character.action, + movement: Run(RunData), + }; + } else { + return CharacterState { + action: character.action, + movement: Stand(StandData), + }; + } + } +} + +impl State for SitData { + fn handle( + &self, + _entity: &Entity, + _character: &CharacterState, + _pos: &mut Pos, + _vel: &mut Vel, + _ori: &mut Ori, + _dt: &DeltaTime, + inputs: &ControllerInputs, + _stats: &Stats, + _body: &Body, + physics: &PhysicsState, + _server_bus: &EventBus, + _local_bus: &EventBus, + ) -> CharacterState { + // Falling + // Idk, maybe the ground disappears, + // suddenly maybe a water spell appears. + // Can't hurt to be safe :shrug: + if !physics.on_ground { + if physics.in_fluid { + return CharacterState { + action: Idle, + movement: Swim(SwimData), + }; + } else { + return CharacterState { + action: Idle, + movement: Fall(FallData), + }; + } + } + // Jumping + if inputs.jump.is_pressed() { + return CharacterState { + action: Idle, + movement: Jump(JumpData), + }; + } + + // Moving + if inputs.move_dir.magnitude_squared() > 0.0 { + return CharacterState { + action: Idle, + movement: Run(RunData), + }; + } + + // Standing back up (unsitting) + if inputs.sit.is_just_pressed() { + return CharacterState { + action: Idle, + movement: Stand(StandData), + }; + } + + // no movement has occurred + return CharacterState { + action: Idle, + movement: Sit(SitData), + }; + } +} + +impl State for JumpData { + fn handle( + &self, + entity: &Entity, + character: &CharacterState, + _pos: &mut Pos, + _vel: &mut Vel, + _ori: &mut Ori, + _dt: &DeltaTime, + _inputs: &ControllerInputs, + _stats: &Stats, + _body: &Body, + _physics: &PhysicsState, + _server_bus: &EventBus, + local_bus: &EventBus, + ) -> CharacterState { + local_bus.emitter().emit(LocalEvent::Jump(*entity)); + + return CharacterState { + action: character.action, + movement: Fall(FallData), + }; + } +} + +impl State for FallData { + fn handle( + &self, + _entity: &Entity, + character: &CharacterState, + _pos: &mut Pos, + vel: &mut Vel, + ori: &mut Ori, + dt: &DeltaTime, + inputs: &ControllerInputs, + stats: &Stats, + _body: &Body, + physics: &PhysicsState, + _server_bus: &EventBus, + _local_bus: &EventBus, + ) -> CharacterState { + // Move player according to move_dir + vel.0 += Vec2::broadcast(dt.0) + * inputs.move_dir + * if vel.0.magnitude_squared() < HUMANOID_AIR_SPEED.powf(2.0) { + HUMANOID_AIR_ACCEL + } else { + 0.0 + }; + + // Set direction based on move direction when on the ground + let ori_dir = if character.action.is_attack() || character.action.is_block() { + Vec2::from(inputs.look_dir).normalized() + } else { + Vec2::from(vel.0) + }; + + if ori_dir.magnitude_squared() > 0.0001 + && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 + { + ori.0 = vek::ops::Slerp::slerp(ori.0, ori_dir.into(), 2.0 * dt.0); + } + + let mut new_action = character.action; + + // Update actions + match character.action { + // Unwield if buttons pressed + Wield { .. } | Attack { .. } => { + if inputs.toggle_wield.is_just_pressed() { + new_action = Idle; + } + } + // Try to wield if any of buttons pressed + Idle => { + if inputs.primary.is_pressed() || inputs.secondary.is_pressed() { + new_action = if let Some(ItemKind::Tool { kind, .. }) = + stats.equipment.main.as_ref().map(|i| &i.kind) + { + let wield_duration = kind.wield_duration(); + Wield { + time_left: wield_duration, + } + } else { + Idle + } + }; + } + // Cancel blocks + Block { .. } => { + new_action = if let Some(ItemKind::Tool { kind, .. }) = + stats.equipment.main.as_ref().map(|i| &i.kind) + { + let wield_duration = kind.wield_duration(); + Wield { + time_left: wield_duration, + } + } else { + Idle + }; + } + // Don't change action + Charge { .. } | Roll { .. } => {} + }; + + // Gliding + if inputs.glide.is_pressed() && !inputs.glide.is_held_down() { + return CharacterState { + action: Idle, + movement: Glide(GlideData), + }; + } + + // Reset to Falling while not standing on ground, + // otherwise keep the state given above + if !physics.on_ground { + if physics.in_fluid { + return CharacterState { + action: new_action, + movement: Swim(SwimData), + }; + } else { + return CharacterState { + action: new_action, + movement: Fall(FallData), + }; + } + } + // On ground + else { + // Return to running or standing based on move inputs + return CharacterState { + action: new_action, + movement: if inputs.move_dir.magnitude_squared() > 0.0 { + Run(RunData) + } else { + Stand(StandData) + }, + }; + } + } +} +impl State for GlideData { + fn handle( + &self, + _entity: &Entity, + _character: &CharacterState, + _pos: &mut Pos, + vel: &mut Vel, + ori: &mut Ori, + dt: &DeltaTime, + inputs: &ControllerInputs, + _stats: &Stats, + _body: &Body, + physics: &PhysicsState, + _server_bus: &EventBus, + _local_bus: &EventBus, + ) -> CharacterState { + // Move player according to move_dir + vel.0 += Vec2::broadcast(dt.0) + * inputs.move_dir + * if vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) { + GLIDE_ACCEL + } else { + 0.0 + }; + + let ori_dir = Vec2::from(vel.0); + + if ori_dir.magnitude_squared() > 0.0001 + && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 + { + ori.0 = vek::ops::Slerp::slerp(ori.0, ori_dir.into(), 2.0 * dt.0); + } + + // Apply Glide lift + if Vec2::::from(vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) && vel.0.z < 0.0 { + let lift = GLIDE_ANTIGRAV + vel.0.z.abs().powf(2.0) * 0.15; + vel.0.z += dt.0 + * lift + * (Vec2::::from(vel.0).magnitude() * 0.075) + .min(1.0) + .max(0.2); + } + + if !inputs.glide.is_pressed() { + return CharacterState { + action: Idle, + movement: Fall(FallData), + }; + } else if let Some(_wall_dir) = physics.on_wall { + return CharacterState { + action: Idle, + movement: Climb(ClimbData), + }; + } + + if physics.on_ground { + return CharacterState { + action: Idle, + movement: Stand(StandData), + }; + } + + return CharacterState { + action: Idle, + movement: Glide(GlideData), + }; + } +} +impl State for ClimbData { + fn handle( + &self, + _entity: &Entity, + character: &CharacterState, + _pos: &mut Pos, + vel: &mut Vel, + ori: &mut Ori, + dt: &DeltaTime, + inputs: &ControllerInputs, + _stats: &Stats, + _body: &Body, + physics: &PhysicsState, + _server_bus: &EventBus, + _local_bus: &EventBus, + ) -> CharacterState { + // Move player according to move_dir + vel.0 += Vec2::broadcast(dt.0) + * inputs.move_dir + * if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { + HUMANOID_CLIMB_ACCEL + } else { + 0.0 + }; + + // Set direction based on move direction when on the ground + let ori_dir = if let Some(wall_dir) = physics.on_wall { + if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { + Vec2::from(wall_dir).normalized() + } else { + Vec2::from(vel.0) + } + } else { + Vec2::from(vel.0) + }; + + if ori_dir.magnitude_squared() > 0.0001 + && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 + { + ori.0 = vek::ops::Slerp::slerp( + ori.0, + ori_dir.into(), + if physics.on_ground { 9.0 } else { 2.0 } * dt.0, + ); + } + + // Apply Vertical Climbing Movement + if let (true, Some(_wall_dir)) = ( + (inputs.climb.is_pressed() | inputs.climb_down.is_pressed()) && vel.0.z <= CLIMB_SPEED, + physics.on_wall, + ) { + if inputs.climb_down.is_pressed() && !inputs.climb.is_pressed() { + vel.0 -= dt.0 * vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); + } else if inputs.climb.is_pressed() && !inputs.climb_down.is_pressed() { + vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); + } else { + vel.0.z = vel.0.z + dt.0 * GRAVITY * 1.5; + vel.0 = Lerp::lerp( + vel.0, + Vec3::zero(), + 30.0 * dt.0 / (1.0 - vel.0.z.min(0.0) * 5.0), + ); + } + } + + if let None = physics.on_wall { + if inputs.jump.is_pressed() { + return CharacterState { + action: Idle, + movement: Jump(JumpData), + }; + } else { + return CharacterState { + action: Idle, + movement: Fall(FallData), + }; + } + } + if physics.on_ground { + return CharacterState { + action: Idle, + movement: Stand(StandData), + }; + } + + return *character; + } +} +impl State for SwimData { + fn handle( + &self, + _entity: &Entity, + character: &CharacterState, + _pos: &mut Pos, + vel: &mut Vel, + ori: &mut Ori, + dt: &DeltaTime, + inputs: &ControllerInputs, + _stats: &Stats, + _body: &Body, + physics: &PhysicsState, + _server_bus: &EventBus, + _local_bus: &EventBus, + ) -> CharacterState { + // Update velocity + vel.0 += Vec2::broadcast(dt.0) + * inputs.move_dir + * if vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) { + HUMANOID_WATER_ACCEL + } else { + 0.0 + }; + + // Set direction based on move direction when on the ground + let ori_dir = if character.action.is_attack() || character.action.is_block() { + Vec2::from(inputs.look_dir).normalized() + } else { + Vec2::from(vel.0) + }; + + if ori_dir.magnitude_squared() > 0.0001 + && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 + { + ori.0 = vek::ops::Slerp::slerp( + ori.0, + ori_dir.into(), + if physics.on_ground { 9.0 } else { 2.0 } * dt.0, + ); + } + + if inputs.jump.is_pressed() { + vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); + } + + if inputs.primary.is_pressed() { + // TODO: PrimaryStart + } else if inputs.secondary.is_pressed() { + // TODO: SecondaryStart + } + + // Not on ground + if !physics.on_ground { + return CharacterState { + action: character.action, + movement: Swim(SwimData), + }; + } + // On ground + else { + // Return to running or standing based on move inputs + return CharacterState { + action: character.action, + movement: if inputs.move_dir.magnitude_squared() > 0.0 { + Run(RunData) + } else { + Stand(StandData) + }, + }; + } + } +} diff --git a/common/src/sys/movement.rs b/common/src/sys/movement.rs index bcbb29436b..c3693dd828 100644 --- a/common/src/sys/movement.rs +++ b/common/src/sys/movement.rs @@ -106,131 +106,131 @@ impl<'a> System<'a> for Sys { ) .join() { - if character.movement == Run(RunData) || character.movement == Stand(StandData) { - continue; - } + // if character.movement == Run(RunData) || character.movement == Stand(StandData) { + // continue; + // } - if stats.is_dead { - continue; - } + // if stats.is_dead { + // continue; + // } - if mount.is_some() { - continue; - } + // if mount.is_some() { + // continue; + // } - let inputs = &controller.inputs; + // let inputs = &controller.inputs; - if character.action.is_roll() { - vel.0 = Vec3::new(0.0, 0.0, vel.0.z) - + (vel.0 * Vec3::new(1.0, 1.0, 0.0) - + 1.5 * inputs.move_dir.try_normalized().unwrap_or_default()) - .try_normalized() - .unwrap_or_default() - * ROLL_SPEED; - } else if character.action.is_charge() { - vel.0 = Vec3::new(0.0, 0.0, vel.0.z) - + (vel.0 * Vec3::new(1.0, 1.0, 0.0) - + 1.5 * inputs.move_dir.try_normalized().unwrap_or_default()) - .try_normalized() - .unwrap_or_default() - * CHARGE_SPEED; - } else if character.action.is_block() { - vel.0 += Vec2::broadcast(dt.0) - * inputs.move_dir - * match physics.on_ground { - true if vel.0.magnitude_squared() < BLOCK_SPEED.powf(2.0) => BLOCK_ACCEL, - _ => 0.0, - } - } else { - // Move player according to move_dir - vel.0 += Vec2::broadcast(dt.0) - * inputs.move_dir - * match (physics.on_ground, &character.movement) { - (true, Run(_)) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => { - HUMANOID_ACCEL - } - (false, Climb) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => { - HUMANOID_CLIMB_ACCEL - } - (false, Glide) if vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) => { - GLIDE_ACCEL - } - (false, Fall) | (false, Jump) - if vel.0.magnitude_squared() < HUMANOID_AIR_SPEED.powf(2.0) => - { - HUMANOID_AIR_ACCEL - } - (false, Swim) - if vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) => - { - HUMANOID_WATER_ACCEL - } - _ => 0.0, - }; - } + // if character.action.is_roll() { + // vel.0 = Vec3::new(0.0, 0.0, vel.0.z) + // + (vel.0 * Vec3::new(1.0, 1.0, 0.0) + // + 1.5 * inputs.move_dir.try_normalized().unwrap_or_default()) + // .try_normalized() + // .unwrap_or_default() + // * ROLL_SPEED; + // } else if character.action.is_charge() { + // vel.0 = Vec3::new(0.0, 0.0, vel.0.z) + // + (vel.0 * Vec3::new(1.0, 1.0, 0.0) + // + 1.5 * inputs.move_dir.try_normalized().unwrap_or_default()) + // .try_normalized() + // .unwrap_or_default() + // * CHARGE_SPEED; + // } else if character.action.is_block() { + // vel.0 += Vec2::broadcast(dt.0) + // * inputs.move_dir + // * match physics.on_ground { + // true if vel.0.magnitude_squared() < BLOCK_SPEED.powf(2.0) => BLOCK_ACCEL, + // _ => 0.0, + // } + // } else { + // // Move player according to move_dir + // vel.0 += Vec2::broadcast(dt.0) + // * inputs.move_dir + // * match (physics.on_ground, &character.movement) { + // (true, Run(_)) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => { + // HUMANOID_ACCEL + // } + // (false, Climb) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => { + // HUMANOID_CLIMB_ACCEL + // } + // (false, Glide) if vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) => { + // GLIDE_ACCEL + // } + // (false, Fall) | (false, Jump) + // if vel.0.magnitude_squared() < HUMANOID_AIR_SPEED.powf(2.0) => + // { + // HUMANOID_AIR_ACCEL + // } + // (false, Swim) + // if vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) => + // { + // HUMANOID_WATER_ACCEL + // } + // _ => 0.0, + // }; + // } - // Set direction based on move direction when on the ground - let ori_dir = if - //character.action.is_wield() || - character.action.is_attack() || character.action.is_block() { - Vec2::from(inputs.look_dir).normalized() - } else if let (Climb, Some(wall_dir)) = (character.movement, physics.on_wall) { - if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { - Vec2::from(wall_dir).normalized() - } else { - Vec2::from(vel.0) - } - } else { - Vec2::from(vel.0) - }; + // // Set direction based on move direction when on the ground + // let ori_dir = if + // //character.action.is_wield() || + // character.action.is_attack() || character.action.is_block() { + // Vec2::from(inputs.look_dir).normalized() + // } else if let (Climb, Some(wall_dir)) = (character.movement, physics.on_wall) { + // if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { + // Vec2::from(wall_dir).normalized() + // } else { + // Vec2::from(vel.0) + // } + // } else { + // Vec2::from(vel.0) + // }; - if ori_dir.magnitude_squared() > 0.0001 - && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - ori.0 = vek::ops::Slerp::slerp( - ori.0, - ori_dir.into(), - if physics.on_ground { 9.0 } else { 2.0 } * dt.0, - ); - } + // if ori_dir.magnitude_squared() > 0.0001 + // && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + // > 0.001 + // { + // ori.0 = vek::ops::Slerp::slerp( + // ori.0, + // ori_dir.into(), + // if physics.on_ground { 9.0 } else { 2.0 } * dt.0, + // ); + // } - // Glide - if character.movement == Glide - && Vec2::::from(vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) - && vel.0.z < 0.0 - { - let lift = GLIDE_ANTIGRAV + vel.0.z.abs().powf(2.0) * 0.15; - vel.0.z += dt.0 - * lift - * (Vec2::::from(vel.0).magnitude() * 0.075) - .min(1.0) - .max(0.2); - } + // // Glide + // if character.movement == Glide + // && Vec2::::from(vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) + // && vel.0.z < 0.0 + // { + // let lift = GLIDE_ANTIGRAV + vel.0.z.abs().powf(2.0) * 0.15; + // vel.0.z += dt.0 + // * lift + // * (Vec2::::from(vel.0).magnitude() * 0.075) + // .min(1.0) + // .max(0.2); + // } - // Climb - if let (true, Some(_wall_dir)) = ( - (inputs.climb.is_pressed() | inputs.climb_down.is_pressed()) - && vel.0.z <= CLIMB_SPEED, - physics.on_wall, - ) { - if inputs.climb_down.is_pressed() && !inputs.climb.is_pressed() { - vel.0 -= dt.0 * vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); - } else if inputs.climb.is_pressed() && !inputs.climb_down.is_pressed() { - vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); - } else { - vel.0.z = vel.0.z + dt.0 * GRAVITY * 1.5; - vel.0 = Lerp::lerp( - vel.0, - Vec3::zero(), - 30.0 * dt.0 / (1.0 - vel.0.z.min(0.0) * 5.0), - ); - } - } + // // Climb + // if let (true, Some(_wall_dir)) = ( + // (inputs.climb.is_pressed() | inputs.climb_down.is_pressed()) + // && vel.0.z <= CLIMB_SPEED, + // physics.on_wall, + // ) { + // if inputs.climb_down.is_pressed() && !inputs.climb.is_pressed() { + // vel.0 -= dt.0 * vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); + // } else if inputs.climb.is_pressed() && !inputs.climb_down.is_pressed() { + // vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); + // } else { + // vel.0.z = vel.0.z + dt.0 * GRAVITY * 1.5; + // vel.0 = Lerp::lerp( + // vel.0, + // Vec3::zero(), + // 30.0 * dt.0 / (1.0 - vel.0.z.min(0.0) * 5.0), + // ); + // } + // } - if character.movement == Swim && inputs.jump.is_pressed() { - vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); - } + // if character.movement == Swim && inputs.jump.is_pressed() { + // vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); + // } } } } diff --git a/voxygen/src/audio/sfx/event_mapper.rs b/voxygen/src/audio/sfx/event_mapper.rs index 2873f2d590..af68a96313 100644 --- a/voxygen/src/audio/sfx/event_mapper.rs +++ b/voxygen/src/audio/sfx/event_mapper.rs @@ -160,17 +160,17 @@ impl SfxEventMapper { stats, ) { (_, ActionState::Roll { .. }, ..) => SfxEvent::Roll, - (MovementState::Climb, ..) => SfxEvent::Climb, - (MovementState::Swim, ..) => SfxEvent::Swim, + (MovementState::Climb(_), ..) => SfxEvent::Climb, + (MovementState::Swim(_), ..) => SfxEvent::Swim, (MovementState::Run(_), ..) => SfxEvent::Run, - (MovementState::Fall, _, previous_event, _) => { + (MovementState::Fall(_), _, previous_event, _) => { if previous_event != SfxEvent::Glide { SfxEvent::Fall } else { SfxEvent::GliderClose } } - (MovementState::Glide, _, previous_event, ..) => { + (MovementState::Glide(_), _, previous_event, ..) => { if previous_event != SfxEvent::GliderOpen && previous_event != SfxEvent::Glide { SfxEvent::GliderOpen } else { diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 7c7319f74e..80f52b69fc 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -211,35 +211,35 @@ impl FigureMgr { &mut movement_animation_rate, skeleton_attr, ), - Jump | Fall => anim::character::JumpAnimation::update_skeleton( + Jump(_) | Fall(_) => anim::character::JumpAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, time), state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Glide => anim::character::GlidingAnimation::update_skeleton( + Glide(_) => anim::character::GlidingAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0, ori.0, state.last_ori, time), state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Swim => anim::character::SwimAnimation::update_skeleton( + Swim(_) => anim::character::SwimAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0.magnitude(), ori.0.magnitude(), time), state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Climb => anim::character::ClimbAnimation::update_skeleton( + Climb(_) => anim::character::ClimbAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0, ori.0, time), state.movement_time, &mut movement_animation_rate, skeleton_attr, ), - Sit => anim::character::SitAnimation::update_skeleton( + Sit(_) => anim::character::SitAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, time), state.movement_time, @@ -349,7 +349,7 @@ impl FigureMgr { &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::quadruped_small::JumpAnimation::update_skeleton( + Jump(_) => anim::quadruped_small::JumpAnimation::update_skeleton( &QuadrupedSmallSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -406,7 +406,7 @@ impl FigureMgr { &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::quadruped_medium::JumpAnimation::update_skeleton( + Jump(_) => anim::quadruped_medium::JumpAnimation::update_skeleton( &QuadrupedMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -461,7 +461,7 @@ impl FigureMgr { &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::bird_medium::JumpAnimation::update_skeleton( + Jump(_) => anim::bird_medium::JumpAnimation::update_skeleton( &BirdMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -516,7 +516,7 @@ impl FigureMgr { &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::fish_medium::JumpAnimation::update_skeleton( + Jump(_) => anim::fish_medium::JumpAnimation::update_skeleton( &FishMediumSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -571,7 +571,7 @@ impl FigureMgr { &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::dragon::JumpAnimation::update_skeleton( + Jump(_) => anim::dragon::JumpAnimation::update_skeleton( &DragonSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -626,7 +626,7 @@ impl FigureMgr { &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::bird_small::JumpAnimation::update_skeleton( + Jump(_) => anim::bird_small::JumpAnimation::update_skeleton( &BirdSmallSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -681,7 +681,7 @@ impl FigureMgr { &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::fish_small::JumpAnimation::update_skeleton( + Jump(_) => anim::fish_small::JumpAnimation::update_skeleton( &FishSmallSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, @@ -736,7 +736,7 @@ impl FigureMgr { &mut movement_animation_rate, skeleton_attr, ), - Jump => anim::biped_large::JumpAnimation::update_skeleton( + Jump(_) => anim::biped_large::JumpAnimation::update_skeleton( &BipedLargeSkeleton::new(), (vel.0.magnitude(), time), state.movement_time, From 8e0317e03dc0c10aebdd460dd3978161ce683a1a Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Thu, 26 Dec 2019 06:43:59 -0800 Subject: [PATCH 005/326] refactor states to handle update logic --- common/src/comp/character_state.rs | 222 +++-- common/src/comp/mod.rs | 6 +- common/src/comp/states/basic_attack.rs | 19 + common/src/comp/states/basic_block.rs | 19 + common/src/comp/states/charge_attack.rs | 86 ++ common/src/comp/states/climb.rs | 100 +++ common/src/comp/states/fall.rs | 89 ++ common/src/comp/states/glide.rs | 87 ++ common/src/comp/states/jump.rs | 28 + common/src/comp/states/mod.rs | 104 +++ common/src/comp/states/roll.rs | 19 + common/src/comp/states/run.rs | 139 +++ common/src/comp/states/sit.rs | 76 ++ common/src/comp/states/stand.rs | 120 +++ common/src/comp/states/swim.rs | 85 ++ common/src/comp/states/wield.rs | 51 ++ common/src/msg/ecs_packet.rs | 6 + common/src/state.rs | 3 + common/src/sys/agent.rs | 6 +- common/src/sys/character_state.rs | 1071 ++--------------------- common/src/sys/combat.rs | 212 ++--- common/src/sys/controller.rs | 13 +- common/src/sys/mod.rs | 5 +- common/src/sys/movement.rs | 6 +- voxygen/src/audio/sfx/event_mapper.rs | 68 +- voxygen/src/scene/figure/cache.rs | 18 +- voxygen/src/scene/figure/mod.rs | 252 +++--- voxygen/src/scene/mod.rs | 2 +- voxygen/src/session.rs | 6 +- 29 files changed, 1525 insertions(+), 1393 deletions(-) create mode 100644 common/src/comp/states/basic_attack.rs create mode 100644 common/src/comp/states/basic_block.rs create mode 100644 common/src/comp/states/charge_attack.rs create mode 100644 common/src/comp/states/climb.rs create mode 100644 common/src/comp/states/fall.rs create mode 100644 common/src/comp/states/glide.rs create mode 100644 common/src/comp/states/jump.rs create mode 100644 common/src/comp/states/mod.rs create mode 100644 common/src/comp/states/roll.rs create mode 100644 common/src/comp/states/run.rs create mode 100644 common/src/comp/states/sit.rs create mode 100644 common/src/comp/states/stand.rs create mode 100644 common/src/comp/states/swim.rs create mode 100644 common/src/comp/states/wield.rs diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 91f336c3a4..5b6cc3ba49 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,109 +1,121 @@ -use crate::comp::{Body, Controller, ControllerInputs, ItemKind, PhysicsState, Stats}; -use specs::{Component, FlaggedStorage, HashMapStorage}; -use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System}; -use sphynx::{Uid, UidAllocator}; -//use specs_idvs::IDVStorage; -use self::{ActionState::*, MovementState::*}; +use self::ActionState::*; +use super::states::*; +use crate::{ + comp::{Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel}, + event::{EventBus, LocalEvent, ServerEvent}, + state::DeltaTime, +}; +use specs::LazyUpdate; +use specs::{Component, Entity, FlaggedStorage, HashMapStorage, NullStorage}; +use sphynx::Uid; use std::time::Duration; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct RunData; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct StandData; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct SitData; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct JumpData; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct FallData; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct GlideData; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct SwimData; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct ClimbData; +pub struct ECSStateData<'a> { + pub entity: &'a Entity, + pub uid: &'a Uid, + pub character: &'a CharacterState, + pub pos: &'a Pos, + pub vel: &'a Vel, + pub ori: &'a Ori, + pub dt: &'a DeltaTime, + pub inputs: &'a ControllerInputs, + pub stats: &'a Stats, + pub body: &'a Body, + pub physics: &'a PhysicsState, + pub updater: &'a LazyUpdate, + pub server_bus: &'a EventBus, + pub local_bus: &'a EventBus, +} + +pub struct ECSStateUpdate { + pub character: CharacterState, + pub pos: Pos, + pub vel: Vel, + pub ori: Ori, +} #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum MovementState { - Stand(StandData), - Run(RunData), - Sit(SitData), - Jump(JumpData), - Fall(FallData), - Glide(GlideData), - Swim(SwimData), - Climb(ClimbData), +pub enum MoveState { + Stand(StandHandler), + Run(RunHandler), + Sit(SitHandler), + Jump(JumpHandler), + Fall(FallHandler), + Glide(GlideHandler), + Swim(SwimHandler), + Climb(ClimbHandler), } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum ActionState { Idle, - Wield { - time_left: Duration, - }, - Attack { - time_left: Duration, - applied: bool, - }, - Block { - time_active: Duration, - }, - Roll { - time_left: Duration, - // Whether character was wielding before they started roll - was_wielding: bool, - }, - Charge { - time_left: Duration, - }, - // Handle(CharacterAction), + Wield(WieldHandler), + Attack(AttackKind), + Block(BlockKind), + Dodge(DodgeKind), + // Interact, +} + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub enum AttackKind { + BasicAttack(BasicAttackHandler), + Charge(ChargeAttackHandler), +} + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub enum BlockKind { + BasicBlock(BasicBlockHandler), +} + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub enum DodgeKind { + Roll(RollHandler), } impl ActionState { - pub fn is_wield(&self) -> bool { - if let Self::Wield { .. } = self { - true - } else { - false - } - } - - pub fn is_action_finished(&self) -> bool { + pub fn is_equip_finished(&self) -> bool { match self { - Self::Wield { time_left } - | Self::Attack { time_left, .. } - | Self::Roll { time_left, .. } - | Self::Charge { time_left } => *time_left == Duration::default(), - Self::Idle | Self::Block { .. } => false, + Wield(WieldHandler { equip_delay }) => *equip_delay == Duration::default(), + _ => true, + } + } + pub fn get_delay(&self) -> Duration { + match self { + Wield(WieldHandler { equip_delay }) => *equip_delay, + _ => Duration::default(), } } - pub fn is_attack(&self) -> bool { - if let Self::Attack { .. } = self { + pub fn is_attacking(&self) -> bool { + match self { + Block(_) => true, + _ => false, + } + } + + pub fn is_blocking(&self) -> bool { + match self { + Attack(_) => true, + _ => false, + } + } + + pub fn is_dodging(&self) -> bool { + match self { + Dodge(_) => true, + _ => false, + } + } + + pub fn is_wielding(&self) -> bool { + if let Wield(_) = self { true } else { false } } - - pub fn is_block(&self) -> bool { - if let Self::Block { .. } = self { - true - } else { - false - } - } - - pub fn is_roll(&self) -> bool { - if let Self::Roll { .. } = self { - true - } else { - false - } - } - - pub fn is_charge(&self) -> bool { - if let Self::Charge { .. } = self { + pub fn is_idling(&self) -> bool { + if let Idle = self { true } else { false @@ -113,29 +125,29 @@ impl ActionState { #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct CharacterState { - pub movement: MovementState, - pub action: ActionState, + pub move_state: MoveState, + pub action_state: ActionState, } impl CharacterState { - pub fn is_same_movement(&self, other: &Self) -> bool { - // Check if enum item is the same without looking at the inner data - std::mem::discriminant(&self.movement) == std::mem::discriminant(&other.movement) + pub fn is_same_move_state(&self, other: &Self) -> bool { + // Check if state is the same without looking at the inner data + std::mem::discriminant(&self.move_state) == std::mem::discriminant(&other.move_state) } - pub fn is_same_action(&self, other: &Self) -> bool { - // Check if enum item is the same without looking at the inner data - std::mem::discriminant(&self.action) == std::mem::discriminant(&other.action) + pub fn is_same_action_state(&self, other: &Self) -> bool { + // Check if state is the same without looking at the inner data + std::mem::discriminant(&self.action_state) == std::mem::discriminant(&other.action_state) } pub fn is_same_state(&self, other: &Self) -> bool { - self.is_same_movement(other) && self.is_same_action(other) + self.is_same_move_state(other) && self.is_same_action_state(other) } } impl Default for CharacterState { fn default() -> Self { Self { - movement: MovementState::Fall(FallData), - action: ActionState::Idle, + move_state: MoveState::Fall(FallHandler), + action_state: ActionState::Idle, } } } @@ -143,3 +155,21 @@ impl Default for CharacterState { impl Component for CharacterState { type Storage = FlaggedStorage>; } + +#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct OverrideState; +impl Component for OverrideState { + type Storage = FlaggedStorage>; +} + +#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct OverrideAction; +impl Component for OverrideAction { + type Storage = FlaggedStorage>; +} + +#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct OverrideMove; +impl Component for OverrideMove { + type Storage = FlaggedStorage>; +} diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 1f2e894539..2acf89e6b5 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -10,6 +10,7 @@ mod location; mod phys; mod player; pub mod projectile; +mod states; mod stats; mod visual; @@ -21,8 +22,8 @@ pub use body::{ quadruped_medium, quadruped_small, Body, }; pub use character_state::{ - ActionState, CharacterState, ClimbData, FallData, GlideData, JumpData, MovementState, RunData, - SitData, StandData, SwimData, + ActionState, AttackKind, BlockKind, CharacterState, DodgeKind, ECSStateData, ECSStateUpdate, + MoveState, OverrideAction, OverrideMove, OverrideState, }; pub use controller::{ ControlEvent, Controller, ControllerInputs, Input, InputState, InventoryManip, MountState, @@ -35,5 +36,6 @@ pub use location::Waypoint; pub use phys::{ForceUpdate, Gravity, Mass, Ori, PhysicsState, Pos, Scale, Sticky, Vel}; pub use player::Player; pub use projectile::Projectile; +pub use states::*; pub use stats::{Equipment, Exp, HealthChange, HealthSource, Level, Stats}; pub use visual::LightEmitter; diff --git a/common/src/comp/states/basic_attack.rs b/common/src/comp/states/basic_attack.rs new file mode 100644 index 0000000000..56dd8872d2 --- /dev/null +++ b/common/src/comp/states/basic_attack.rs @@ -0,0 +1,19 @@ +use super::{ECSStateData, ECSStateUpdate, StateHandle}; +use std::time::Duration; + +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct BasicAttackHandler { + /// How long the state has until exitting + remaining_duration: Duration, +} + +impl StateHandle for BasicAttackHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + return ECSStateUpdate { + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + character: *ecs_data.character, + }; + } +} diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs new file mode 100644 index 0000000000..038d30be14 --- /dev/null +++ b/common/src/comp/states/basic_block.rs @@ -0,0 +1,19 @@ +use super::{ECSStateData, ECSStateUpdate, StateHandle}; +use std::time::Duration; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct BasicBlockHandler { + /// How long the blocking state has been active + active_duration: Duration, +} + +impl StateHandle for BasicBlockHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + return ECSStateUpdate { + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + character: *ecs_data.character, + }; + } +} diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs new file mode 100644 index 0000000000..8caec5b33e --- /dev/null +++ b/common/src/comp/states/charge_attack.rs @@ -0,0 +1,86 @@ +use super::{ + CharacterState, ECSStateData, ECSStateUpdate, MoveState::Run, RunHandler, Stand, StandHandler, + StateHandle, WieldHandler, +}; +use crate::comp::{ + ActionState::{Attack, Idle, Wield}, + AttackKind::Charge, + HealthChange, HealthSource, + ItemKind::Tool, +}; +use crate::event::ServerEvent; +use std::time::Duration; + +use super::TEMP_EQUIP_DELAY; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct ChargeAttackHandler { + /// How long the state has until exitting + pub remaining_duration: Duration, +} + +impl StateHandle for ChargeAttackHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + let mut update = ECSStateUpdate { + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + character: *ecs_data.character, + }; + + if let Some(uid_b) = ecs_data.physics.touch_entity { + ecs_data.server_bus.emitter().emit(ServerEvent::Damage { + uid: uid_b, + change: HealthChange { + amount: -20, + cause: HealthSource::Attack { by: *ecs_data.uid }, + }, + }); + + update.character = CharacterState { + move_state: Stand(StandHandler), + action_state: if let Some(Tool { .. }) = + ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) + { + Wield(WieldHandler { + equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), + }) + } else { + Idle + }, + }; + + return update; + } + + if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 + { + update.character = CharacterState { + move_state: Stand(StandHandler), + action_state: if let Some(Tool { .. }) = + ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) + { + Wield(WieldHandler { + equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), + }) + } else { + Idle + }, + }; + + return update; + } + + update.character = CharacterState { + move_state: Run(RunHandler), + action_state: Attack(Charge(ChargeAttackHandler { + remaining_duration: self + .remaining_duration + .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) + .unwrap_or_default(), + })), + }; + + return update; + } +} diff --git a/common/src/comp/states/climb.rs b/common/src/comp/states/climb.rs new file mode 100644 index 0000000000..cc915f60dd --- /dev/null +++ b/common/src/comp/states/climb.rs @@ -0,0 +1,100 @@ +use super::{ + ActionState::*, CharacterState, ECSStateData, ECSStateUpdate, FallHandler, JumpHandler, + MoveState::*, StandHandler, StateHandle, +}; +use super::{CLIMB_SPEED, HUMANOID_CLIMB_ACCEL, HUMANOID_SPEED}; +use crate::sys::phys::GRAVITY; +use vek::vec::{Vec2, Vec3}; +use vek::Lerp; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct ClimbHandler; + +impl StateHandle for ClimbHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + let mut update = ECSStateUpdate { + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + character: *ecs_data.character, + }; + + // Move player according to move_dir + update.vel.0 += Vec2::broadcast(ecs_data.dt.0) + * ecs_data.inputs.move_dir + * if update.vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { + HUMANOID_CLIMB_ACCEL + } else { + 0.0 + }; + + // Set direction based on move direction when on the ground + let ori_dir = if let Some(wall_dir) = ecs_data.physics.on_wall { + if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { + Vec2::from(wall_dir).normalized() + } else { + Vec2::from(update.vel.0) + } + } else { + Vec2::from(update.vel.0) + }; + + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = vek::ops::Slerp::slerp( + update.ori.0, + ori_dir.into(), + if ecs_data.physics.on_ground { 9.0 } else { 2.0 } * ecs_data.dt.0, + ); + } + + // Apply Vertical Climbing Movement + if let (true, Some(_wall_dir)) = ( + (ecs_data.inputs.climb.is_pressed() | ecs_data.inputs.climb_down.is_pressed()) + && update.vel.0.z <= CLIMB_SPEED, + ecs_data.physics.on_wall, + ) { + if ecs_data.inputs.climb_down.is_pressed() && !ecs_data.inputs.climb.is_pressed() { + update.vel.0 -= + ecs_data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); + } else if ecs_data.inputs.climb.is_pressed() && !ecs_data.inputs.climb_down.is_pressed() + { + update.vel.0.z = (update.vel.0.z + ecs_data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); + } else { + update.vel.0.z = update.vel.0.z + ecs_data.dt.0 * GRAVITY * 1.5; + update.vel.0 = Lerp::lerp( + update.vel.0, + Vec3::zero(), + 30.0 * ecs_data.dt.0 / (1.0 - update.vel.0.z.min(0.0) * 5.0), + ); + } + } + + if let None = ecs_data.physics.on_wall { + if ecs_data.inputs.jump.is_pressed() { + update.character = CharacterState { + action_state: Idle, + move_state: Jump(JumpHandler), + }; + return update; + } else { + update.character = CharacterState { + action_state: Idle, + move_state: Fall(FallHandler), + }; + return update; + } + } + if ecs_data.physics.on_ground { + update.character = CharacterState { + action_state: Idle, + move_state: Stand(StandHandler), + }; + return update; + } + + return update; + } +} diff --git a/common/src/comp/states/fall.rs b/common/src/comp/states/fall.rs new file mode 100644 index 0000000000..8a5c30dcc1 --- /dev/null +++ b/common/src/comp/states/fall.rs @@ -0,0 +1,89 @@ +use super::{ + ActionState::*, CharacterState, ECSStateData, ECSStateUpdate, GlideHandler, MoveState::*, + RunHandler, StandHandler, StateHandle, SwimHandler, +}; +use super::{HUMANOID_AIR_ACCEL, HUMANOID_AIR_SPEED}; +use vek::{Vec2, Vec3}; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct FallHandler; + +impl StateHandle for FallHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + let mut update = ECSStateUpdate { + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + character: *ecs_data.character, + }; + + // Move player according to movement direction vector + update.vel.0 += Vec2::broadcast(ecs_data.dt.0) + * ecs_data.inputs.move_dir + * if update.vel.0.magnitude_squared() < HUMANOID_AIR_SPEED.powf(2.0) { + HUMANOID_AIR_ACCEL + } else { + 0.0 + }; + + // Set orientation vector based on direction of movement when on the ground + let ori_dir = if update.character.action_state.is_attacking() + || update.character.action_state.is_blocking() + { + Vec2::from(ecs_data.inputs.look_dir).normalized() + } else { + Vec2::from(update.vel.0) + }; + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = + vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 2.0 * ecs_data.dt.0); + } + + // Check gliding + if ecs_data.inputs.glide.is_pressed() && !ecs_data.inputs.glide.is_held_down() { + update.character = CharacterState { + action_state: Idle, + move_state: Glide(GlideHandler), + }; + + return update; + } + + // Not on ground, go to swim or fall + if !ecs_data.physics.on_ground { + // Check if in fluid to go to swimming or back to falling + if ecs_data.physics.in_fluid { + update.character = CharacterState { + action_state: update.character.action_state, + move_state: Swim(SwimHandler), + }; + + return update; + } else { + update.character = CharacterState { + action_state: update.character.action_state, + move_state: Fall(FallHandler), + }; + + return update; + } + } + // On ground + else { + // Return to running or standing based on move inputs + update.character = CharacterState { + action_state: update.character.action_state, + move_state: if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { + Run(RunHandler) + } else { + Stand(StandHandler) + }, + }; + + return update; + } + } +} diff --git a/common/src/comp/states/glide.rs b/common/src/comp/states/glide.rs new file mode 100644 index 0000000000..8511d4c469 --- /dev/null +++ b/common/src/comp/states/glide.rs @@ -0,0 +1,87 @@ +use super::{ + ActionState::*, CharacterState, ClimbHandler, ECSStateData, ECSStateUpdate, FallHandler, + MoveState::*, StandHandler, StateHandle, +}; +use super::{GLIDE_ACCEL, GLIDE_ANTIGRAV, GLIDE_SPEED}; +use vek::{Vec2, Vec3}; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct GlideHandler; + +impl StateHandle for GlideHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + let mut update = ECSStateUpdate { + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + character: *ecs_data.character, + }; + + // Move player according to movement direction vector + update.vel.0 += Vec2::broadcast(ecs_data.dt.0) + * ecs_data.inputs.move_dir + * if ecs_data.vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) { + GLIDE_ACCEL + } else { + 0.0 + }; + + // Determine orientation vector from movement direction vector + let ori_dir = Vec2::from(update.vel.0); + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = + vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 2.0 * ecs_data.dt.0); + } + + // Apply Glide lift + if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) + && update.vel.0.z < 0.0 + { + let lift = GLIDE_ANTIGRAV + update.vel.0.z.abs().powf(2.0) * 0.15; + update.vel.0.z += ecs_data.dt.0 + * lift + * (Vec2::::from(update.vel.0).magnitude() * 0.075) + .min(1.0) + .max(0.2); + } + + // If glide button isn't held + if !ecs_data.inputs.glide.is_pressed() { + update.character = CharacterState { + action_state: Idle, + move_state: Fall(FallHandler), + }; + + return update; + } + // If there is a wall in front of character go to climb + else if let Some(_wall_dir) = ecs_data.physics.on_wall { + update.character = CharacterState { + action_state: Idle, + move_state: Climb(ClimbHandler), + }; + + return update; + } + // If on ground go to stand + if ecs_data.physics.on_ground { + update.character = CharacterState { + action_state: Idle, + move_state: Stand(StandHandler), + }; + + return update; + } + + // Otherwise keep gliding + update.character = CharacterState { + action_state: Idle, + move_state: Glide(GlideHandler), + }; + + return update; + } +} diff --git a/common/src/comp/states/jump.rs b/common/src/comp/states/jump.rs new file mode 100644 index 0000000000..0f48e33c92 --- /dev/null +++ b/common/src/comp/states/jump.rs @@ -0,0 +1,28 @@ +use super::{CharacterState, ECSStateData, ECSStateUpdate, FallHandler, MoveState::*, StateHandle}; +use crate::event::LocalEvent; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct JumpHandler; + +impl StateHandle for JumpHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + let mut update = ECSStateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + }; + + ecs_data + .local_bus + .emitter() + .emit(LocalEvent::Jump(*ecs_data.entity)); + + update.character = CharacterState { + action_state: ecs_data.character.action_state, + move_state: Fall(FallHandler), + }; + + return update; + } +} diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs new file mode 100644 index 0000000000..77e32be07a --- /dev/null +++ b/common/src/comp/states/mod.rs @@ -0,0 +1,104 @@ +// Module declarations +mod basic_attack; +mod basic_block; +mod charge_attack; +mod climb; +mod fall; +mod glide; +mod jump; +mod roll; +mod run; +mod sit; +mod stand; +mod swim; +mod wield; + +// Reexports +pub use basic_attack::*; +pub use basic_block::*; +pub use charge_attack::*; +pub use climb::*; +pub use fall::*; +pub use glide::*; +pub use jump::*; +pub use roll::*; +pub use run::*; +pub use sit::*; +pub use stand::*; +pub use swim::*; +pub use wield::*; + +// TODO: Attach these to racial components and/or ecs resources +pub const HUMANOID_ACCEL: f32 = 50.0; +pub const HUMANOID_SPEED: f32 = 120.0; +pub const HUMANOID_AIR_ACCEL: f32 = 10.0; +pub const HUMANOID_AIR_SPEED: f32 = 100.0; +pub const HUMANOID_WATER_ACCEL: f32 = 70.0; +pub const HUMANOID_WATER_SPEED: f32 = 120.0; +pub const HUMANOID_CLIMB_ACCEL: f32 = 5.0; +pub const ROLL_SPEED: f32 = 17.0; +pub const CHARGE_SPEED: f32 = 20.0; +pub const GLIDE_ACCEL: f32 = 15.0; +pub const GLIDE_SPEED: f32 = 45.0; +pub const BLOCK_ACCEL: f32 = 30.0; +pub const BLOCK_SPEED: f32 = 75.0; +pub const TEMP_EQUIP_DELAY: u64 = 100; +// Gravity is 9.81 * 4, so this makes gravity equal to .15 +pub const GLIDE_ANTIGRAV: f32 = crate::sys::phys::GRAVITY * 0.96; +pub const CLIMB_SPEED: f32 = 5.0; +pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; + +// Public interface, wires character states to their handlers. +use super::{ + ActionState, ActionState::*, AttackKind::*, BlockKind::*, CharacterState, DodgeKind::*, + ECSStateData, ECSStateUpdate, MoveState, MoveState::*, +}; + +pub trait StateHandle { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate; +} + +impl StateHandle for ActionState { + /// Passes handle to variant or subvariant handlers + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + match self { + Attack(kind) => match kind { + BasicAttack(handler) => handler.handle(ecs_data), + Charge(handler) => handler.handle(ecs_data), + }, + Block(kind) => match kind { + BasicBlock(handler) => handler.handle(ecs_data), + }, + Dodge(kind) => match kind { + Roll(handler) => handler.handle(ecs_data), + }, + Wield(handler) => handler.handle(ecs_data), + Idle => ECSStateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + }, + // All states should be explicitly handled + // Do not use default match: _ => {}, + } + } +} + +impl StateHandle for MoveState { + /// Passes handle to variant handlers + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + match self { + Stand(handler) => handler.handle(&ecs_data), + Run(handler) => handler.handle(&ecs_data), + Jump(handler) => handler.handle(&ecs_data), + Climb(handler) => handler.handle(&ecs_data), + Glide(handler) => handler.handle(&ecs_data), + Swim(handler) => handler.handle(&ecs_data), + Fall(handler) => handler.handle(&ecs_data), + Sit(handler) => handler.handle(&ecs_data), + // All states should be explicitly handled + // Do not use default match: _ => {}, + } + } +} diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs new file mode 100644 index 0000000000..2759a10653 --- /dev/null +++ b/common/src/comp/states/roll.rs @@ -0,0 +1,19 @@ +use super::{ECSStateData, ECSStateUpdate, StateHandle}; +use std::time::Duration; + +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct RollHandler { + /// How long the state has until exitting + remaining_duration: Duration, +} + +impl StateHandle for RollHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + ECSStateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + } + } +} diff --git a/common/src/comp/states/run.rs b/common/src/comp/states/run.rs new file mode 100644 index 0000000000..80ee1f0c5d --- /dev/null +++ b/common/src/comp/states/run.rs @@ -0,0 +1,139 @@ +use super::{ + ActionState::*, CharacterState, ClimbHandler, ECSStateData, ECSStateUpdate, FallHandler, + GlideHandler, JumpHandler, MoveState::*, SitHandler, StandHandler, StateHandle, SwimHandler, +}; +use super::{HUMANOID_ACCEL, HUMANOID_SPEED}; +use vek::vec::{Vec2, Vec3}; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct RunHandler; + +impl StateHandle for RunHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + let mut update = ECSStateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + }; + + // Move player according to move_dir + update.vel.0 += Vec2::broadcast(ecs_data.dt.0) + * ecs_data.inputs.move_dir + * if update.vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { + HUMANOID_ACCEL + } else { + 0.0 + }; + + // Set direction based on move direction when on the ground + let ori_dir = if update.character.action_state.is_attacking() + || update.character.action_state.is_blocking() + { + Vec2::from(ecs_data.inputs.look_dir).normalized() + } else { + Vec2::from(update.vel.0) + }; + + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = + vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 9.0 * ecs_data.dt.0); + } + + // Try to sit + if ecs_data.inputs.sit.is_pressed() + && ecs_data.physics.on_ground + && ecs_data.body.is_humanoid() + { + update.character = CharacterState { + action_state: Idle, + move_state: Sit(SitHandler), + }; + + return update; + } + + // Try to climb + if let (true, Some(_wall_dir)) = ( + ecs_data.inputs.climb.is_pressed() | ecs_data.inputs.climb_down.is_pressed() + && ecs_data.body.is_humanoid(), + ecs_data.physics.on_wall, + ) { + update.character = CharacterState { + action_state: Idle, + move_state: Climb(ClimbHandler), + }; + + return update; + } + + // Try to swim + if !ecs_data.physics.on_ground && ecs_data.physics.in_fluid { + update.character = CharacterState { + action_state: ecs_data.character.action_state, + move_state: Swim(SwimHandler), + }; + + return update; + } + + // While on ground ... + if ecs_data.physics.on_ground { + // Try to jump + if ecs_data.inputs.jump.is_pressed() && !ecs_data.inputs.jump.is_held_down() { + update.character = CharacterState { + action_state: ecs_data.character.action_state, + move_state: Jump(JumpHandler), + }; + + return update; + } + + // Try to dodge + if ecs_data.inputs.roll.is_pressed() && ecs_data.body.is_humanoid() { + // updater.insert(entity, DodgeStart); + } + } + // While not on ground ... + else { + // Try to glide + if ecs_data.physics.on_wall == None + && ecs_data.inputs.glide.is_pressed() + && !ecs_data.inputs.glide.is_held_down() + && ecs_data.body.is_humanoid() + { + update.character = CharacterState { + action_state: Idle, + move_state: Glide(GlideHandler), + }; + + return update; + } + update.character = CharacterState { + action_state: ecs_data.character.action_state, + move_state: Fall(FallHandler), + }; + + return update; + } + + if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { + update.character = CharacterState { + action_state: ecs_data.character.action_state, + move_state: Run(RunHandler), + }; + + return update; + } else { + update.character = CharacterState { + action_state: ecs_data.character.action_state, + move_state: Stand(StandHandler), + }; + + return update; + } + } +} diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs new file mode 100644 index 0000000000..5634b1fb21 --- /dev/null +++ b/common/src/comp/states/sit.rs @@ -0,0 +1,76 @@ +use super::{ + ActionState::*, CharacterState, ECSStateData, ECSStateUpdate, FallHandler, JumpHandler, + MoveState::*, RunHandler, StandHandler, StateHandle, SwimHandler, +}; +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct SitHandler; + +impl StateHandle for SitHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + let mut update = ECSStateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + }; + + // Falling + // Idk, maybe the ground disappears, + // suddenly maybe a water spell appears. + // Can't hurt to be safe :shrug: + if !ecs_data.physics.on_ground { + if ecs_data.physics.in_fluid { + update.character = CharacterState { + action_state: Idle, + move_state: Swim(SwimHandler), + }; + + return update; + } else { + update.character = CharacterState { + action_state: Idle, + move_state: Fall(FallHandler), + }; + + return update; + } + } + // Jumping + if ecs_data.inputs.jump.is_pressed() { + update.character = CharacterState { + action_state: Idle, + move_state: Jump(JumpHandler), + }; + + return update; + } + + // Moving + if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { + update.character = CharacterState { + action_state: Idle, + move_state: Run(RunHandler), + }; + + return update; + } + + // Standing back up (unsitting) + if ecs_data.inputs.sit.is_just_pressed() { + update.character = CharacterState { + action_state: Idle, + move_state: Stand(StandHandler), + }; + + return update; + } + + // no move_state has occurred + update.character = CharacterState { + action_state: Idle, + move_state: Sit(SitHandler), + }; + + return update; + } +} diff --git a/common/src/comp/states/stand.rs b/common/src/comp/states/stand.rs new file mode 100644 index 0000000000..fb42b04f12 --- /dev/null +++ b/common/src/comp/states/stand.rs @@ -0,0 +1,120 @@ +use super::{ + ActionState::*, CharacterState, ClimbHandler, ECSStateData, ECSStateUpdate, FallHandler, + GlideHandler, JumpHandler, MoveState::*, RunHandler, SitHandler, StateHandle, SwimHandler, +}; +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct StandHandler; + +impl StateHandle for StandHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + let mut update = ECSStateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + }; + + // Try to sit + if ecs_data.inputs.sit.is_pressed() + && ecs_data.physics.on_ground + && ecs_data.body.is_humanoid() + { + update.character = CharacterState { + move_state: Sit(SitHandler), + action_state: update.character.action_state, + }; + + return update; + } + + // Try to climb + if let (true, Some(_wall_dir)) = ( + ecs_data.inputs.climb.is_pressed() | ecs_data.inputs.climb_down.is_pressed() + && ecs_data.body.is_humanoid(), + ecs_data.physics.on_wall, + ) { + update.character = CharacterState { + action_state: update.character.action_state, + move_state: Climb(ClimbHandler), + }; + + return update; + } + + // Try to swim + if !ecs_data.physics.on_ground && ecs_data.physics.in_fluid { + update.character = CharacterState { + action_state: update.character.action_state, + move_state: Swim(SwimHandler), + }; + + return update; + } + + // While on ground ... + if ecs_data.physics.on_ground { + // Try to jump + if ecs_data.inputs.jump.is_pressed() { + update.character = CharacterState { + action_state: update.character.action_state, + move_state: Jump(JumpHandler), + }; + + return update; + } + + // // Try to charge + // if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { + // } + + // Try to roll + if ecs_data.inputs.roll.is_pressed() && ecs_data.body.is_humanoid() { + // updater.insert(entity, DodgeStart); + } + } + // While not on ground ... + else { + // Try to glide + if ecs_data.physics.on_wall == None + && ecs_data.inputs.glide.is_pressed() + && !ecs_data.inputs.glide.is_held_down() + && ecs_data.body.is_humanoid() + { + update.character = CharacterState { + action_state: Idle, + move_state: Glide(GlideHandler), + }; + + return update; + } + update.character = CharacterState { + action_state: update.character.action_state, + move_state: Fall(FallHandler), + }; + + return update; + } + + if ecs_data.inputs.primary.is_pressed() { + // updater.insert(entity, PrimaryStart); + } else if ecs_data.inputs.secondary.is_pressed() { + // updater.insert(entity, SecondaryStart); + } + + if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { + update.character = CharacterState { + action_state: update.character.action_state, + move_state: Run(RunHandler), + }; + + return update; + } else { + update.character = CharacterState { + action_state: update.character.action_state, + move_state: Stand(StandHandler), + }; + + return update; + } + } +} diff --git a/common/src/comp/states/swim.rs b/common/src/comp/states/swim.rs new file mode 100644 index 0000000000..2a864c0a38 --- /dev/null +++ b/common/src/comp/states/swim.rs @@ -0,0 +1,85 @@ +use super::{ + CharacterState, ECSStateData, ECSStateUpdate, MoveState::*, RunHandler, StandHandler, + StateHandle, +}; +use super::{HUMANOID_WATER_ACCEL, HUMANOID_WATER_SPEED}; +use crate::sys::phys::GRAVITY; +use vek::{Vec2, Vec3}; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct SwimHandler; + +impl StateHandle for SwimHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + let mut update = ECSStateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + }; + + // Update velocity + update.vel.0 += Vec2::broadcast(ecs_data.dt.0) + * ecs_data.inputs.move_dir + * if update.vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) { + HUMANOID_WATER_ACCEL + } else { + 0.0 + }; + + // Set direction based on move direction when on the ground + let ori_dir = if update.character.action_state.is_attacking() + || update.character.action_state.is_blocking() + { + Vec2::from(ecs_data.inputs.look_dir).normalized() + } else { + Vec2::from(update.vel.0) + }; + + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = vek::ops::Slerp::slerp( + update.ori.0, + ori_dir.into(), + if ecs_data.physics.on_ground { 9.0 } else { 2.0 } * ecs_data.dt.0, + ); + } + + if ecs_data.inputs.jump.is_pressed() { + update.vel.0.z = + (update.vel.0.z + ecs_data.dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); + } + + if ecs_data.inputs.primary.is_pressed() { + // TODO: PrimaryStart + } else if ecs_data.inputs.secondary.is_pressed() { + // TODO: SecondaryStart + } + + // Not on ground + if !ecs_data.physics.on_ground { + update.character = CharacterState { + action_state: ecs_data.character.action_state, + move_state: Swim(SwimHandler), + }; + + return update; + } + // On ground + else { + // Return to running or standing based on move inputs + update.character = CharacterState { + action_state: ecs_data.character.action_state, + move_state: if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { + Run(RunHandler) + } else { + Stand(StandHandler) + }, + }; + + return update; + } + } +} diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs new file mode 100644 index 0000000000..a0e55ee56f --- /dev/null +++ b/common/src/comp/states/wield.rs @@ -0,0 +1,51 @@ +use super::{ActionState::*, CharacterState, ECSStateData, ECSStateUpdate, StateHandle}; +use std::time::Duration; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct WieldHandler { + /// How long before a new action can be performed + /// after equipping + pub equip_delay: Duration, +} + +impl StateHandle for WieldHandler { + fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + let mut update = ECSStateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + }; + + // Toggling Weapons + if ecs_data.inputs.toggle_wield.is_pressed() + && ecs_data.character.action_state.is_equip_finished() + { + update.character = CharacterState { + action_state: Idle, + move_state: ecs_data.character.move_state, + }; + + return update; + } + + if ecs_data.inputs.primary.is_pressed() { + // TODO: PrimaryStart + } else if ecs_data.inputs.secondary.is_pressed() { + // TODO: SecondaryStart + } + + // Update wield delay + update.character = CharacterState { + action_state: Wield(WieldHandler { + equip_delay: self + .equip_delay + .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) + .unwrap_or_default(), + }), + move_state: ecs_data.character.move_state, + }; + + return update; + } +} diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index 70f24e228c..7f4a4f792b 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -33,6 +33,9 @@ sphynx::sum_type! { Projectile(comp::Projectile), Gravity(comp::Gravity), Sticky(comp::Sticky), + OverrideAction(comp::OverrideAction), + OverrideMove(comp::OverrideMove), + OverrideState(comp::OverrideState), } } // Automatically derive From for EcsCompPhantom @@ -56,6 +59,9 @@ sphynx::sum_type! { Projectile(PhantomData), Gravity(PhantomData), Sticky(PhantomData), + OverrideAction(PhantomData), + OverrideMove(PhantomData), + OverrideState(PhantomData), } } impl sphynx::CompPacket for EcsCompPacket { diff --git a/common/src/state.rs b/common/src/state.rs index 9a3b5cd9ee..b3aa25af8e 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -136,6 +136,9 @@ impl State { ecs.register_synced::(); ecs.register_synced::(); ecs.register_synced::(); + ecs.register_synced::(); + ecs.register_synced::(); + ecs.register_synced::(); // Register components send from clients -> server ecs.register::(); diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index f0df4a9e0d..a99e904b71 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -1,6 +1,6 @@ use crate::comp::{ - Agent, CharacterState, Controller, ControllerInputs, GlideData, MountState, - MovementState::Glide, Pos, Stats, + Agent, CharacterState, Controller, ControllerInputs, GlideHandler, MountState, + MoveState::Glide, Pos, SitHandler, Stats, }; use crate::pathfinding::WorldPath; use crate::terrain::TerrainGrid; @@ -163,7 +163,7 @@ impl<'a> System<'a> for Sys { inputs.roll.set_state(true); } - if target_character.movement == Glide(GlideData) + if target_character.move_state == Glide(GlideHandler) && target_pos.0.z > pos.0.z + 5.0 { inputs.glide.set_state(true); diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 716ddacf46..ab1c754aaf 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,45 +1,17 @@ -use super::movement::ROLL_DURATION; -use super::phys::GRAVITY; - -const HUMANOID_ACCEL: f32 = 50.0; -const HUMANOID_SPEED: f32 = 120.0; -const HUMANOID_AIR_ACCEL: f32 = 10.0; -const HUMANOID_AIR_SPEED: f32 = 100.0; -const HUMANOID_WATER_ACCEL: f32 = 70.0; -const HUMANOID_WATER_SPEED: f32 = 120.0; -const HUMANOID_CLIMB_ACCEL: f32 = 5.0; -const ROLL_SPEED: f32 = 17.0; -const CHARGE_SPEED: f32 = 20.0; -const GLIDE_ACCEL: f32 = 15.0; -const GLIDE_SPEED: f32 = 45.0; -const BLOCK_ACCEL: f32 = 30.0; -const BLOCK_SPEED: f32 = 75.0; -// Gravity is 9.81 * 4, so this makes gravity equal to .15 -const GLIDE_ANTIGRAV: f32 = GRAVITY * 0.96; -const CLIMB_SPEED: f32 = 5.0; - -pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; use crate::{ comp::{ - self, item, projectile, ActionState, ActionState::*, Body, CharacterState, ClimbData, - ControlEvent, Controller, ControllerInputs, FallData, GlideData, HealthChange, - HealthSource, ItemKind, JumpData, Mounting, MovementState, MovementState::*, Ori, - PhysicsState, Pos, Projectile, RunData, SitData, StandData, Stats, SwimData, Vel, + Body, CharacterState, Controller, ControllerInputs, ECSStateData, Mounting, MoveState::*, + Ori, OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, SitHandler, + StateHandle, Stats, Vel, }, - event::{Emitter, EventBus, LocalEvent, ServerEvent}, + event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, }; -use specs::{ - saveload::{Marker, MarkerAllocator}, - Entities, Entity, Join, Read, ReadStorage, System, WriteStorage, -}; + +use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; use sphynx::{Uid, UidAllocator}; -use std::time::Duration; -use vek::*; -struct CharacterStateData(); - -/// # Character State System +/// # Character StateHandle System /// #### Updates then detemrines next Character States based on ControllerInputs pub struct Sys; @@ -50,6 +22,7 @@ impl<'a> System<'a> for Sys { Read<'a, EventBus>, Read<'a, EventBus>, Read<'a, DeltaTime>, + Read<'a, LazyUpdate>, WriteStorage<'a, CharacterState>, WriteStorage<'a, Pos>, WriteStorage<'a, Vel>, @@ -60,6 +33,9 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, PhysicsState>, ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, + ReadStorage<'a, OverrideState>, + ReadStorage<'a, OverrideMove>, + ReadStorage<'a, OverrideAction>, ); fn run( &mut self, @@ -69,6 +45,7 @@ impl<'a> System<'a> for Sys { server_bus, local_bus, dt, + updater, mut character_states, mut positions, mut velocities, @@ -79,6 +56,9 @@ impl<'a> System<'a> for Sys { physics_states, uids, mountings, + state_overrides, + move_overrides, + action_overrides, ): Self::SystemData, ) { for ( @@ -92,7 +72,10 @@ impl<'a> System<'a> for Sys { stats, body, physics, - mount, + maybe_mount, + maybe_move_override, + maybe_action_override, + (), ) in ( &entities, &uids, @@ -105,33 +88,13 @@ impl<'a> System<'a> for Sys { &bodies, &physics_states, mountings.maybe(), + move_overrides.maybe(), + action_overrides.maybe(), + !&state_overrides, ) .join() { let inputs = &controller.inputs; - // println!("{:?}", character); - // Returns a Wield action, or Idle if nothing to wield - let try_wield = |stats: &Stats| -> ActionState { - // Get weapon to wield - if let Some(ItemKind::Tool { kind, .. }) = - stats.equipment.main.as_ref().map(|i| &i.kind) - { - let wield_duration = kind.wield_duration(); - Wield { - time_left: wield_duration, - } - } else { - Idle - } - }; - - let get_state_from_move_dir = |move_dir: &Vec2| -> MovementState { - if move_dir.magnitude_squared() > 0.0 { - Run(RunData) - } else { - Stand(StandData) - } - }; // Being dead overrides all other states if stats.is_dead { @@ -145,963 +108,79 @@ impl<'a> System<'a> for Sys { continue; } // If mounted, character state is controlled by mount - // TODO: Make mounting a state - if mount.is_some() { - character.movement = Sit(SitData); + // TODO: Make mounting a stater + if maybe_mount.is_some() { + character.move_state = Sit(SitHandler); continue; } - // Update Action States - match character.action { - Attack { - ref mut time_left, .. - } => { - *time_left = time_left - .checked_sub(Duration::from_secs_f32(dt.0)) - .unwrap_or_default(); - } - Roll { - ref mut time_left, .. - } => { - *time_left = time_left - .checked_sub(Duration::from_secs_f32(dt.0)) - .unwrap_or_default(); - } - Charge { ref mut time_left } => { - *time_left = time_left - .checked_sub(Duration::from_secs_f32(dt.0)) - .unwrap_or_default(); - } - Wield { ref mut time_left } => { - *time_left = time_left - .checked_sub(Duration::from_secs_f32(dt.0)) - .unwrap_or_default(); - } - Block { - ref mut time_active, - } => { - *time_active = time_active - .checked_add(Duration::from_secs_f32(dt.0)) - .unwrap_or_default(); - } - Idle => {} - } - - // Determine new state - *character = match character.movement { - Stand(data) => data.handle( - &entity, + // Determine new move state if can move + if !maybe_move_override.is_some() { + let state_update = character.move_state.handle(&ECSStateData { + entity: &entity, + uid, character, pos, vel, ori, - &dt, + dt: &dt, inputs, stats, body, physics, - &server_bus, - &local_bus, - ), - Run(data) => data.handle( - &entity, + updater: &updater, + server_bus: &server_bus, + local_bus: &local_bus, + }); + + *character = state_update.character; + *pos = state_update.pos; + *vel = state_update.vel; + *ori = state_update.ori; + } + + // Determine new action if can_act + if !maybe_action_override.is_some() { + let state_update = character.action_state.handle(&ECSStateData { + entity: &entity, + uid, character, pos, vel, ori, - &dt, + dt: &dt, inputs, stats, body, physics, - &server_bus, - &local_bus, - ), - Jump(data) => data.handle( - &entity, - character, - pos, - vel, - ori, - &dt, - inputs, - stats, - body, - physics, - &server_bus, - &local_bus, - ), - Climb(data) => data.handle( - &entity, - character, - pos, - vel, - ori, - &dt, - inputs, - stats, - body, - physics, - &server_bus, - &local_bus, - ), - Glide(data) => data.handle( - &entity, - character, - pos, - vel, - ori, - &dt, - inputs, - stats, - body, - physics, - &server_bus, - &local_bus, - ), - Swim(data) => data.handle( - &entity, - character, - pos, - vel, - ori, - &dt, - inputs, - stats, - body, - physics, - &server_bus, - &local_bus, - ), - Fall(data) => data.handle( - &entity, - character, - pos, - vel, - ori, - &dt, - inputs, - stats, - body, - physics, - &server_bus, - &local_bus, - ), - Sit(data) => data.handle( - &entity, - character, - pos, - vel, - ori, - &dt, - inputs, - stats, - body, - physics, - &server_bus, - &local_bus, - ), // Charging + Any Movement, prioritizes finishing charge - // over movement states - // (Charge { time_left }, _) => { - // if let Some(uid_b) = physics.touch_entity { - // server_emitter.emit(ServerEvent::Damage { - // uid: uid_b, - // change: HealthChange { - // amount: -20, - // cause: HealthSource::Attack { by: *uid }, - // }, - // }); + updater: &updater, + server_bus: &server_bus, + local_bus: &local_bus, + }); - // character.action = try_wield(stats); - // } else if time_left == Duration::default() || vel.0.magnitude_squared() < 10.0 { - // character.action = try_wield(stats); - // } - // } - // Rolling + Any Movement, prioritizes finishing charge - // over movement states - // ( - // Roll { - // time_left, - // was_wielding, - // }, - // _, - // ) => { - // if time_left == Duration::default() { - // if was_wielding { - // character.action = try_wield(stats); - // } else { - // character.action = Idle; - // } - // } - // } - }; - } - } -} - -pub trait State { - fn handle( - &self, - entity: &Entity, - character: &CharacterState, - pos: &mut Pos, - vel: &mut Vel, - ori: &mut Ori, - dt: &DeltaTime, - inputs: &ControllerInputs, - stats: &Stats, - body: &Body, - physics: &PhysicsState, - server_bus: &EventBus, - local_bus: &EventBus, - ) -> CharacterState; -} - -impl State for RunData { - fn handle( - &self, - _entity: &Entity, - character: &CharacterState, - _pos: &mut Pos, - vel: &mut Vel, - ori: &mut Ori, - dt: &DeltaTime, - inputs: &ControllerInputs, - stats: &Stats, - body: &Body, - physics: &PhysicsState, - _server_bus: &EventBus, - _local_bus: &EventBus, - ) -> CharacterState { - // Move player according to move_dir - vel.0 += Vec2::broadcast(dt.0) - * inputs.move_dir - * if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { - HUMANOID_ACCEL - } else { - 0.0 - }; - - // Set direction based on move direction when on the ground - let ori_dir = if character.action.is_attack() || character.action.is_block() { - Vec2::from(inputs.look_dir).normalized() - } else { - Vec2::from(vel.0) - }; - - if ori_dir.magnitude_squared() > 0.0001 - && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 - { - ori.0 = vek::ops::Slerp::slerp(ori.0, ori_dir.into(), 9.0 * dt.0); - } - - // Try to sit - if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { - return CharacterState { - movement: Sit(SitData), - action: Idle, - }; - } - - // Try to climb - if let (true, Some(_wall_dir)) = ( - inputs.climb.is_pressed() | inputs.climb_down.is_pressed() && body.is_humanoid(), - physics.on_wall, - ) { - return CharacterState { - movement: Climb(ClimbData), - action: Idle, - }; - } - - // Try to swim - if !physics.on_ground && physics.in_fluid { - return CharacterState { - action: character.action, - movement: Swim(SwimData), - }; - } - - // While on ground ... - if physics.on_ground { - // Try to jump - if inputs.jump.is_pressed() && !inputs.jump.is_held_down() { - return CharacterState { - action: character.action, - movement: Jump(JumpData), - }; - } - - // Try to charge - if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { - return CharacterState { - action: Charge { - time_left: Duration::from_millis(250), - }, - movement: Run(RunData), - }; - } - - // Try to roll - if inputs.roll.is_pressed() && body.is_humanoid() { - return CharacterState { - action: Roll { - time_left: Duration::from_millis(600), - was_wielding: character.action.is_wield(), - }, - movement: Run(RunData), - }; - } - } - // While not on ground ... - else { - // Try to glide - if physics.on_wall == None - && inputs.glide.is_pressed() - && !inputs.glide.is_held_down() - && body.is_humanoid() - { - return CharacterState { - action: Idle, - movement: Glide(GlideData), - }; - } - return CharacterState { - action: character.action, - movement: Fall(FallData), - }; - } - - // Tool Actions - if inputs.toggle_wield.is_just_pressed() { - match character.action { - Wield { .. } | Attack { .. } => { - // Prevent instantaneous reequipping by checking - // for done wielding - if character.action.is_action_finished() { - return CharacterState { - action: Idle, - movement: character.movement, - }; - } - } - Idle => { - return CharacterState { - // Try to wield if an item is equipped in main hand - action: if let Some(ItemKind::Tool { kind, .. }) = - stats.equipment.main.as_ref().map(|i| &i.kind) - { - let wield_duration = kind.wield_duration(); - Wield { - time_left: wield_duration, - } - } else { - Idle - }, - movement: character.movement, - }; - } - Charge { .. } | Roll { .. } | Block { .. } => {} - } - } - if inputs.primary.is_pressed() { - // TODO: PrimaryStart - } else if inputs.secondary.is_pressed() { - // TODO: SecondaryStart - } - - if inputs.move_dir.magnitude_squared() > 0.0 { - return CharacterState { - action: character.action, - movement: Run(RunData), - }; - } else { - return CharacterState { - action: character.action, - movement: Stand(StandData), - }; - } - } -} - -impl State for StandData { - fn handle( - &self, - _entity: &Entity, - character: &CharacterState, - _pos: &mut Pos, - _vel: &mut Vel, - _ori: &mut Ori, - _dt: &DeltaTime, - inputs: &ControllerInputs, - stats: &Stats, - body: &Body, - physics: &PhysicsState, - _server_bus: &EventBus, - _local_bus: &EventBus, - ) -> CharacterState { - // Try to sit - if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { - return CharacterState { - movement: Sit(SitData), - action: Idle, - }; - } - - // Try to climb - if let (true, Some(_wall_dir)) = ( - inputs.climb.is_pressed() | inputs.climb_down.is_pressed() && body.is_humanoid(), - physics.on_wall, - ) { - return CharacterState { - movement: Climb(ClimbData), - action: Idle, - }; - } - - // Try to swim - if !physics.on_ground && physics.in_fluid { - return CharacterState { - action: character.action, - movement: Swim(SwimData), - }; - } - - // While on ground ... - if physics.on_ground { - // Try to jump - if inputs.jump.is_pressed() { - return CharacterState { - action: character.action, - movement: Jump(JumpData), - }; - } - - // Try to charge - if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { - return CharacterState { - action: Charge { - time_left: Duration::from_millis(250), - }, - movement: Run(RunData), - }; - } - - // Try to roll - if inputs.roll.is_pressed() && body.is_humanoid() { - return CharacterState { - action: Roll { - time_left: Duration::from_millis(600), - was_wielding: character.action.is_wield(), - }, - movement: Run(RunData), - }; - } - } - // While not on ground ... - else { - // Try to glide - if physics.on_wall == None - && inputs.glide.is_pressed() - && !inputs.glide.is_held_down() - && body.is_humanoid() - { - return CharacterState { - action: Idle, - movement: Glide(GlideData), - }; - } - return CharacterState { - action: character.action, - movement: Fall(FallData), - }; - } - - // Tool Actions - if inputs.toggle_wield.is_just_pressed() { - match character.action { - Wield { .. } | Attack { .. } => { - // Prevent instantaneous reequipping by checking - // for done wielding - if character.action.is_action_finished() { - return CharacterState { - action: Idle, - movement: character.movement, - }; - } - } - Idle => { - return CharacterState { - // Try to wield if an item is equipped in main hand - action: if let Some(ItemKind::Tool { kind, .. }) = - stats.equipment.main.as_ref().map(|i| &i.kind) - { - let wield_duration = kind.wield_duration(); - Wield { - time_left: wield_duration, - } - } else { - Idle - }, - movement: character.movement, - }; - } - Charge { .. } | Roll { .. } | Block { .. } => {} - } - } - if inputs.primary.is_pressed() { - // TODO: PrimaryStart - } else if inputs.secondary.is_pressed() { - // TODO: SecondaryStart - } - - if inputs.move_dir.magnitude_squared() > 0.0 { - return CharacterState { - action: character.action, - movement: Run(RunData), - }; - } else { - return CharacterState { - action: character.action, - movement: Stand(StandData), - }; - } - } -} - -impl State for SitData { - fn handle( - &self, - _entity: &Entity, - _character: &CharacterState, - _pos: &mut Pos, - _vel: &mut Vel, - _ori: &mut Ori, - _dt: &DeltaTime, - inputs: &ControllerInputs, - _stats: &Stats, - _body: &Body, - physics: &PhysicsState, - _server_bus: &EventBus, - _local_bus: &EventBus, - ) -> CharacterState { - // Falling - // Idk, maybe the ground disappears, - // suddenly maybe a water spell appears. - // Can't hurt to be safe :shrug: - if !physics.on_ground { - if physics.in_fluid { - return CharacterState { - action: Idle, - movement: Swim(SwimData), - }; - } else { - return CharacterState { - action: Idle, - movement: Fall(FallData), - }; - } - } - // Jumping - if inputs.jump.is_pressed() { - return CharacterState { - action: Idle, - movement: Jump(JumpData), - }; - } - - // Moving - if inputs.move_dir.magnitude_squared() > 0.0 { - return CharacterState { - action: Idle, - movement: Run(RunData), - }; - } - - // Standing back up (unsitting) - if inputs.sit.is_just_pressed() { - return CharacterState { - action: Idle, - movement: Stand(StandData), - }; - } - - // no movement has occurred - return CharacterState { - action: Idle, - movement: Sit(SitData), - }; - } -} - -impl State for JumpData { - fn handle( - &self, - entity: &Entity, - character: &CharacterState, - _pos: &mut Pos, - _vel: &mut Vel, - _ori: &mut Ori, - _dt: &DeltaTime, - _inputs: &ControllerInputs, - _stats: &Stats, - _body: &Body, - _physics: &PhysicsState, - _server_bus: &EventBus, - local_bus: &EventBus, - ) -> CharacterState { - local_bus.emitter().emit(LocalEvent::Jump(*entity)); - - return CharacterState { - action: character.action, - movement: Fall(FallData), - }; - } -} - -impl State for FallData { - fn handle( - &self, - _entity: &Entity, - character: &CharacterState, - _pos: &mut Pos, - vel: &mut Vel, - ori: &mut Ori, - dt: &DeltaTime, - inputs: &ControllerInputs, - stats: &Stats, - _body: &Body, - physics: &PhysicsState, - _server_bus: &EventBus, - _local_bus: &EventBus, - ) -> CharacterState { - // Move player according to move_dir - vel.0 += Vec2::broadcast(dt.0) - * inputs.move_dir - * if vel.0.magnitude_squared() < HUMANOID_AIR_SPEED.powf(2.0) { - HUMANOID_AIR_ACCEL - } else { - 0.0 - }; - - // Set direction based on move direction when on the ground - let ori_dir = if character.action.is_attack() || character.action.is_block() { - Vec2::from(inputs.look_dir).normalized() - } else { - Vec2::from(vel.0) - }; - - if ori_dir.magnitude_squared() > 0.0001 - && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 - { - ori.0 = vek::ops::Slerp::slerp(ori.0, ori_dir.into(), 2.0 * dt.0); - } - - let mut new_action = character.action; - - // Update actions - match character.action { - // Unwield if buttons pressed - Wield { .. } | Attack { .. } => { - if inputs.toggle_wield.is_just_pressed() { - new_action = Idle; - } - } - // Try to wield if any of buttons pressed - Idle => { - if inputs.primary.is_pressed() || inputs.secondary.is_pressed() { - new_action = if let Some(ItemKind::Tool { kind, .. }) = - stats.equipment.main.as_ref().map(|i| &i.kind) - { - let wield_duration = kind.wield_duration(); - Wield { - time_left: wield_duration, - } - } else { - Idle - } - }; - } - // Cancel blocks - Block { .. } => { - new_action = if let Some(ItemKind::Tool { kind, .. }) = - stats.equipment.main.as_ref().map(|i| &i.kind) - { - let wield_duration = kind.wield_duration(); - Wield { - time_left: wield_duration, - } - } else { - Idle - }; - } - // Don't change action - Charge { .. } | Roll { .. } => {} - }; - - // Gliding - if inputs.glide.is_pressed() && !inputs.glide.is_held_down() { - return CharacterState { - action: Idle, - movement: Glide(GlideData), - }; - } - - // Reset to Falling while not standing on ground, - // otherwise keep the state given above - if !physics.on_ground { - if physics.in_fluid { - return CharacterState { - action: new_action, - movement: Swim(SwimData), - }; - } else { - return CharacterState { - action: new_action, - movement: Fall(FallData), - }; - } - } - // On ground - else { - // Return to running or standing based on move inputs - return CharacterState { - action: new_action, - movement: if inputs.move_dir.magnitude_squared() > 0.0 { - Run(RunData) - } else { - Stand(StandData) - }, - }; - } - } -} -impl State for GlideData { - fn handle( - &self, - _entity: &Entity, - _character: &CharacterState, - _pos: &mut Pos, - vel: &mut Vel, - ori: &mut Ori, - dt: &DeltaTime, - inputs: &ControllerInputs, - _stats: &Stats, - _body: &Body, - physics: &PhysicsState, - _server_bus: &EventBus, - _local_bus: &EventBus, - ) -> CharacterState { - // Move player according to move_dir - vel.0 += Vec2::broadcast(dt.0) - * inputs.move_dir - * if vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) { - GLIDE_ACCEL - } else { - 0.0 - }; - - let ori_dir = Vec2::from(vel.0); - - if ori_dir.magnitude_squared() > 0.0001 - && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 - { - ori.0 = vek::ops::Slerp::slerp(ori.0, ori_dir.into(), 2.0 * dt.0); - } - - // Apply Glide lift - if Vec2::::from(vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) && vel.0.z < 0.0 { - let lift = GLIDE_ANTIGRAV + vel.0.z.abs().powf(2.0) * 0.15; - vel.0.z += dt.0 - * lift - * (Vec2::::from(vel.0).magnitude() * 0.075) - .min(1.0) - .max(0.2); - } - - if !inputs.glide.is_pressed() { - return CharacterState { - action: Idle, - movement: Fall(FallData), - }; - } else if let Some(_wall_dir) = physics.on_wall { - return CharacterState { - action: Idle, - movement: Climb(ClimbData), - }; - } - - if physics.on_ground { - return CharacterState { - action: Idle, - movement: Stand(StandData), - }; - } - - return CharacterState { - action: Idle, - movement: Glide(GlideData), - }; - } -} -impl State for ClimbData { - fn handle( - &self, - _entity: &Entity, - character: &CharacterState, - _pos: &mut Pos, - vel: &mut Vel, - ori: &mut Ori, - dt: &DeltaTime, - inputs: &ControllerInputs, - _stats: &Stats, - _body: &Body, - physics: &PhysicsState, - _server_bus: &EventBus, - _local_bus: &EventBus, - ) -> CharacterState { - // Move player according to move_dir - vel.0 += Vec2::broadcast(dt.0) - * inputs.move_dir - * if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { - HUMANOID_CLIMB_ACCEL - } else { - 0.0 - }; - - // Set direction based on move direction when on the ground - let ori_dir = if let Some(wall_dir) = physics.on_wall { - if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { - Vec2::from(wall_dir).normalized() - } else { - Vec2::from(vel.0) - } - } else { - Vec2::from(vel.0) - }; - - if ori_dir.magnitude_squared() > 0.0001 - && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 - { - ori.0 = vek::ops::Slerp::slerp( - ori.0, - ori_dir.into(), - if physics.on_ground { 9.0 } else { 2.0 } * dt.0, - ); - } - - // Apply Vertical Climbing Movement - if let (true, Some(_wall_dir)) = ( - (inputs.climb.is_pressed() | inputs.climb_down.is_pressed()) && vel.0.z <= CLIMB_SPEED, - physics.on_wall, - ) { - if inputs.climb_down.is_pressed() && !inputs.climb.is_pressed() { - vel.0 -= dt.0 * vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); - } else if inputs.climb.is_pressed() && !inputs.climb_down.is_pressed() { - vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); - } else { - vel.0.z = vel.0.z + dt.0 * GRAVITY * 1.5; - vel.0 = Lerp::lerp( - vel.0, - Vec3::zero(), - 30.0 * dt.0 / (1.0 - vel.0.z.min(0.0) * 5.0), - ); - } - } - - if let None = physics.on_wall { - if inputs.jump.is_pressed() { - return CharacterState { - action: Idle, - movement: Jump(JumpData), - }; - } else { - return CharacterState { - action: Idle, - movement: Fall(FallData), - }; - } - } - if physics.on_ground { - return CharacterState { - action: Idle, - movement: Stand(StandData), - }; - } - - return *character; - } -} -impl State for SwimData { - fn handle( - &self, - _entity: &Entity, - character: &CharacterState, - _pos: &mut Pos, - vel: &mut Vel, - ori: &mut Ori, - dt: &DeltaTime, - inputs: &ControllerInputs, - _stats: &Stats, - _body: &Body, - physics: &PhysicsState, - _server_bus: &EventBus, - _local_bus: &EventBus, - ) -> CharacterState { - // Update velocity - vel.0 += Vec2::broadcast(dt.0) - * inputs.move_dir - * if vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) { - HUMANOID_WATER_ACCEL - } else { - 0.0 - }; - - // Set direction based on move direction when on the ground - let ori_dir = if character.action.is_attack() || character.action.is_block() { - Vec2::from(inputs.look_dir).normalized() - } else { - Vec2::from(vel.0) - }; - - if ori_dir.magnitude_squared() > 0.0001 - && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 - { - ori.0 = vek::ops::Slerp::slerp( - ori.0, - ori_dir.into(), - if physics.on_ground { 9.0 } else { 2.0 } * dt.0, - ); - } - - if inputs.jump.is_pressed() { - vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); - } - - if inputs.primary.is_pressed() { - // TODO: PrimaryStart - } else if inputs.secondary.is_pressed() { - // TODO: SecondaryStart - } - - // Not on ground - if !physics.on_ground { - return CharacterState { - action: character.action, - movement: Swim(SwimData), - }; - } - // On ground - else { - // Return to running or standing based on move inputs - return CharacterState { - action: character.action, - movement: if inputs.move_dir.magnitude_squared() > 0.0 { - Run(RunData) - } else { - Stand(StandData) - }, - }; + *character = state_update.character; + *pos = state_update.pos; + *vel = state_update.vel; + *ori = state_update.ori; + } + + // Rolling + Any Movement, prioritizes finishing charge + // over move_state states + // ( + // Roll { + // time_left, + // was_wielding, + // }, + // _, + // ) => { + // if time_left == Duration::default() { + // if was_wielding { + // character.action = try_wield(stats); + // } else { + // character.action = Idle; + // } + // } + // } } } } diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 6a23de568f..156067b531 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -46,119 +46,119 @@ impl<'a> System<'a> for Sys { stats, ): Self::SystemData, ) { - let mut server_emitter = server_bus.emitter(); - let mut _local_emitter = local_bus.emitter(); + // let mut server_emitter = server_bus.emitter(); + // let mut _local_emitter = local_bus.emitter(); - // Attacks - for (entity, uid, pos, ori, _, stat) in ( - &entities, - &uids, - &positions, - &orientations, - &controllers, - &stats, - ) - .join() - { - let recover_duration = if let Some(Item { - kind: ItemKind::Tool { kind, .. }, - .. - }) = stat.equipment.main - { - kind.attack_recover_duration() - } else { - Duration::from_secs(1) - }; + // // Attacks + // for (entity, uid, pos, ori, _, stat) in ( + // &entities, + // &uids, + // &positions, + // &orientations, + // &controllers, + // &stats, + // ) + // .join() + // { + // let recover_duration = if let Some(Item { + // kind: ItemKind::Tool { kind, .. }, + // .. + // }) = stat.equipment.main + // { + // kind.attack_recover_duration() + // } else { + // Duration::from_secs(1) + // }; - let (deal_damage, should_end) = if let Some(Attack { time_left, applied }) = - &mut character_states.get_mut(entity).map(|c| &mut c.action) - { - *time_left = time_left - .checked_sub(Duration::from_secs_f32(dt.0)) - .unwrap_or_default(); - if !*applied && recover_duration > *time_left { - *applied = true; - (true, false) - } else if *time_left == Duration::default() { - (false, true) - } else { - (false, false) - } - } else { - (false, false) - }; + // let (deal_damage, should_end) = if let Some(Attack { time_left, applied }) = + // &mut character_states.get_mut(entity).map(|c| &mut c.action) + // { + // *time_left = time_left + // .checked_sub(Duration::from_secs_f32(dt.0)) + // .unwrap_or_default(); + // if !*applied && recover_duration > *time_left { + // *applied = true; + // (true, false) + // } else if *time_left == Duration::default() { + // (false, true) + // } else { + // (false, false) + // } + // } else { + // (false, false) + // }; - if deal_damage { - if let Some(Attack { .. }) = &character_states.get(entity).map(|c| c.action) { - // Go through all other entities - for (b, uid_b, pos_b, ori_b, character_b, stat_b) in ( - &entities, - &uids, - &positions, - &orientations, - &character_states, - &stats, - ) - .join() - { - // 2D versions - let pos2 = Vec2::from(pos.0); - let pos_b2: Vec2 = Vec2::from(pos_b.0); - let ori2 = Vec2::from(ori.0); + // if deal_damage { + // if let Some(Attack { .. }) = &character_states.get(entity).map(|c| c.action) { + // // Go through all other entities + // for (b, uid_b, pos_b, ori_b, character_b, stat_b) in ( + // &entities, + // &uids, + // &positions, + // &orientations, + // &character_states, + // &stats, + // ) + // .join() + // { + // // 2D versions + // let pos2 = Vec2::from(pos.0); + // let pos_b2: Vec2 = Vec2::from(pos_b.0); + // let ori2 = Vec2::from(ori.0); - // Check if it is a hit - if entity != b - && !stat_b.is_dead - && pos.0.distance_squared(pos_b.0) < ATTACK_RANGE.powi(2) - // TODO: Use size instead of 1.0 - && ori2.angle_between(pos_b2 - pos2) < (2.0 / pos2.distance(pos_b2)).atan() - { - // Weapon gives base damage - let mut dmg = if let Some(ItemKind::Tool { power, .. }) = - stat.equipment.main.as_ref().map(|i| &i.kind) - { - *power as i32 - } else { - 1 - }; + // // Check if it is a hit + // if entity != b + // && !stat_b.is_dead + // && pos.0.distance_squared(pos_b.0) < ATTACK_RANGE.powi(2) + // // TODO: Use size instead of 1.0 + // && ori2.angle_between(pos_b2 - pos2) < (2.0 / pos2.distance(pos_b2)).atan() + // { + // // Weapon gives base damage + // let mut dmg = if let Some(ItemKind::Tool { power, .. }) = + // stat.equipment.main.as_ref().map(|i| &i.kind) + // { + // *power as i32 + // } else { + // 1 + // }; - // Block - if character_b.action.is_block() - && ori_b.0.angle_between(pos.0 - pos_b.0).to_degrees() - < BLOCK_ANGLE / 2.0 - { - dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as i32 - } + // // Block + // if character_b.action.is_block() + // && ori_b.0.angle_between(pos.0 - pos_b.0).to_degrees() + // < BLOCK_ANGLE / 2.0 + // { + // dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as i32 + // } - server_emitter.emit(ServerEvent::Damage { - uid: *uid_b, - change: HealthChange { - amount: -dmg, - cause: HealthSource::Attack { by: *uid }, - }, - }); - } - } - } - } + // server_emitter.emit(ServerEvent::Damage { + // uid: *uid_b, + // change: HealthChange { + // amount: -dmg, + // cause: HealthSource::Attack { by: *uid }, + // }, + // }); + // } + // } + // } + // } - if should_end { - if let Some(character) = &mut character_states.get_mut(entity) { - character.action = Wield { - time_left: Duration::default(), - }; - } - } + // if should_end { + // if let Some(character) = &mut character_states.get_mut(entity) { + // character.action = Wield { + // time_left: Duration::default(), + // }; + // } + // } - if let Some(Wield { time_left }) = - &mut character_states.get_mut(entity).map(|c| &mut c.action) - { - if *time_left != Duration::default() { - *time_left = time_left - .checked_sub(Duration::from_secs_f32(dt.0)) - .unwrap_or_default(); - } - } - } + // if let Some(Wield { time_left }) = + // &mut character_states.get_mut(entity).map(|c| &mut c.action) + // { + // if *time_left != Duration::default() { + // *time_left = time_left + // .checked_sub(Duration::from_secs_f32(dt.0)) + // .unwrap_or_default(); + // } + // } + // } } } diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index 7548d322df..2af37f4fb8 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -1,20 +1,13 @@ -use super::movement::ROLL_DURATION; use crate::{ - comp::{ - self, item, projectile, ActionState, ActionState::*, Body, CharacterState, ControlEvent, - Controller, ControllerInputs, HealthChange, HealthSource, ItemKind, Mounting, - MovementState, MovementState::*, PhysicsState, Projectile, Stats, Vel, - }, - event::{Emitter, EventBus, LocalEvent, ServerEvent}, + comp::{ControlEvent, Controller}, + event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, }; use specs::{ saveload::{Marker, MarkerAllocator}, - Entities, Entity, Join, Read, ReadStorage, System, WriteStorage, + Entities, Join, Read, ReadStorage, System, WriteStorage, }; use sphynx::{Uid, UidAllocator}; -use std::time::Duration; -use vek::*; /// # Controller System /// #### Responsible for validating and updating controller inputs diff --git a/common/src/sys/mod.rs b/common/src/sys/mod.rs index b490c19354..948596139a 100644 --- a/common/src/sys/mod.rs +++ b/common/src/sys/mod.rs @@ -3,7 +3,6 @@ pub mod character_state; mod cleanup; pub mod combat; pub mod controller; -pub mod movement; pub mod phys; mod projectile; mod stats; @@ -16,7 +15,6 @@ const AGENT_SYS: &str = "agent_sys"; const CHARACTER_STATE_SYS: &str = "character_state_sys"; const CONTROLLER_SYS: &str = "controller_sys"; const PHYS_SYS: &str = "phys_sys"; -const MOVEMENT_SYS: &str = "movement_sys"; const PROJECTILE_SYS: &str = "projectile_sys"; const COMBAT_SYS: &str = "combat_sys"; const STATS_SYS: &str = "stats_sys"; @@ -26,13 +24,12 @@ pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) { dispatch_builder.add(agent::Sys, AGENT_SYS, &[]); dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS]); dispatch_builder.add(character_state::Sys, CHARACTER_STATE_SYS, &[CONTROLLER_SYS]); - dispatch_builder.add(movement::Sys, MOVEMENT_SYS, &[CHARACTER_STATE_SYS]); dispatch_builder.add(combat::Sys, COMBAT_SYS, &[CONTROLLER_SYS]); dispatch_builder.add(stats::Sys, STATS_SYS, &[COMBAT_SYS]); dispatch_builder.add( phys::Sys, PHYS_SYS, - &[CONTROLLER_SYS, MOVEMENT_SYS, COMBAT_SYS, STATS_SYS], + &[CONTROLLER_SYS, COMBAT_SYS, STATS_SYS], ); dispatch_builder.add(projectile::Sys, PROJECTILE_SYS, &[PHYS_SYS]); dispatch_builder.add(cleanup::Sys, CLEANUP_SYS, &[PHYS_SYS]); diff --git a/common/src/sys/movement.rs b/common/src/sys/movement.rs index c3693dd828..7a64a996f4 100644 --- a/common/src/sys/movement.rs +++ b/common/src/sys/movement.rs @@ -1,8 +1,8 @@ use super::phys::GRAVITY; use crate::{ comp::{ - CharacterState, Controller, Mounting, MovementState::*, Ori, PhysicsState, Pos, RunData, - StandData, Stats, Vel, + CharacterState, Controller, Mounting, MoveState::*, Ori, PhysicsState, Pos, RunHandler, + StandHandler, Stats, Vel, }, event::{EventBus, ServerEvent}, state::DeltaTime, @@ -106,7 +106,7 @@ impl<'a> System<'a> for Sys { ) .join() { - // if character.movement == Run(RunData) || character.movement == Stand(StandData) { + // if character.movement == Run(RunHandler) || character.movement == Stand(StandHandler) { // continue; // } diff --git a/voxygen/src/audio/sfx/event_mapper.rs b/voxygen/src/audio/sfx/event_mapper.rs index af68a96313..3a3eefcd68 100644 --- a/voxygen/src/audio/sfx/event_mapper.rs +++ b/voxygen/src/audio/sfx/event_mapper.rs @@ -4,7 +4,11 @@ use crate::audio::sfx::{SfxTriggerItem, SfxTriggers}; use client::Client; use common::{ - comp::{ActionState, Body, CharacterState, ItemKind, MovementState, Pos, Stats}, + comp::{ + ActionState, AttackKind::*, BasicAttackHandler, Body, CharacterState, DodgeKind::*, + FallHandler, GlideHandler, ItemKind, MoveState, Pos, RollHandler, RunHandler, StandHandler, + Stats, + }, event::{EventBus, SfxEvent, SfxEventItem}, }; use hashbrown::HashMap; @@ -125,7 +129,7 @@ impl SfxEventMapper { } } - /// Voxygen has an existing list of character states via `MovementState::*` and `ActionState::*` + /// Voxygen has an existing list of character states via `MoveState::*` and `ActionState::*` /// however that list does not provide enough resolution to target specific entity events, such /// as opening or closing the glider. These methods translate those entity states with some additional /// data into more specific `SfxEvent`'s which we attach sounds to @@ -135,8 +139,8 @@ impl SfxEventMapper { stats: &Stats, ) -> SfxEvent { match ( - current_event.movement, - current_event.action, + current_event.move_state, + current_event.action_state, previous_event, stats, ) { @@ -154,23 +158,23 @@ impl SfxEventMapper { stats: &Stats, ) -> SfxEvent { match ( - current_event.movement, - current_event.action, + current_event.move_state, + current_event.action_state, previous_event, stats, ) { - (_, ActionState::Roll { .. }, ..) => SfxEvent::Roll, - (MovementState::Climb(_), ..) => SfxEvent::Climb, - (MovementState::Swim(_), ..) => SfxEvent::Swim, - (MovementState::Run(_), ..) => SfxEvent::Run, - (MovementState::Fall(_), _, previous_event, _) => { + (_, ActionState::Dodge(_), ..) => SfxEvent::Roll, + (MoveState::Climb(_), ..) => SfxEvent::Climb, + (MoveState::Swim(_), ..) => SfxEvent::Swim, + (MoveState::Run(_), ..) => SfxEvent::Run, + (MoveState::Fall(_), _, previous_event, _) => { if previous_event != SfxEvent::Glide { SfxEvent::Fall } else { SfxEvent::GliderClose } } - (MovementState::Glide(_), _, previous_event, ..) => { + (MoveState::Glide(_), _, previous_event, ..) => { if previous_event != SfxEvent::GliderOpen && previous_event != SfxEvent::Glide { SfxEvent::GliderOpen } else { @@ -193,7 +197,7 @@ mod tests { use super::*; use common::{ assets, - comp::{item::Tool, ActionState, MovementState, Stats}, + comp::{item::Tool, ActionState, MoveState, Stats}, event::SfxEvent, }; use std::time::{Duration, Instant}; @@ -273,8 +277,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - movement: MovementState::Stand, - action: ActionState::Idle, + move_state: MoveState::Stand(StandHandler), + action_state: ActionState::Idle, }, SfxEvent::Idle, &stats, @@ -289,8 +293,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - movement: MovementState::Run, - action: ActionState::Idle, + move_state: MoveState::Run(RunHandler), + action_state: ActionState::Idle, }, SfxEvent::Idle, &stats, @@ -305,11 +309,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - action: ActionState::Roll { - time_left: Duration::new(1, 0), - was_wielding: false, - }, - movement: MovementState::Run, + action_state: ActionState::Dodge(Roll(RollHandler::default())), + move_state: MoveState::Run(RunHandler), }, SfxEvent::Run, &stats, @@ -324,8 +325,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - movement: MovementState::Fall, - action: ActionState::Idle, + move_state: MoveState::Fall(FallHandler), + action_state: ActionState::Idle, }, SfxEvent::Idle, &stats, @@ -340,8 +341,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - movement: MovementState::Glide, - action: ActionState::Idle, + move_state: MoveState::Glide(GlideHandler), + action_state: ActionState::Idle, }, SfxEvent::Jump, &stats, @@ -356,8 +357,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - movement: MovementState::Glide, - action: ActionState::Idle, + move_state: MoveState::Glide(GlideHandler), + action_state: ActionState::Idle, }, SfxEvent::Glide, &stats, @@ -372,8 +373,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - movement: MovementState::Fall, - action: ActionState::Idle, + move_state: MoveState::Fall(FallHandler), + action_state: ActionState::Idle, }, SfxEvent::Glide, &stats, @@ -393,11 +394,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - movement: MovementState::Stand, - action: ActionState::Attack { - time_left: Duration::new(1, 0), - applied: true, - }, + move_state: MoveState::Stand(StandHandler), + action_state: ActionState::Attack(BasicAttack(BasicAttackHandler::default())), }, SfxEvent::Idle, &stats, diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 54fe68a2d5..797dead31d 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -6,7 +6,7 @@ use crate::{ }; use common::{ assets::watch::ReloadIndicator, - comp::{ActionState, Body, CharacterState, Equipment, MovementState}, + comp::{ActionState, Body, CharacterState, Equipment, MoveState}, }; use hashbrown::HashMap; use std::mem::{discriminant, Discriminant}; @@ -24,15 +24,15 @@ enum FigureKey { #[derive(PartialEq, Eq, Hash, Clone)] struct CharacterStateCacheKey { - movement: Discriminant, + move_state: Discriminant, action: Discriminant, } impl From<&CharacterState> for CharacterStateCacheKey { fn from(cs: &CharacterState) -> Self { Self { - movement: discriminant(&cs.movement), - action: discriminant(&cs.action), + move_state: discriminant(&cs.move_state), + action: discriminant(&cs.action_state), } } } @@ -132,7 +132,7 @@ impl FigureModelCache { }, if camera_mode == CameraMode::FirstPerson && character_state - .map(|cs| cs.action.is_roll()) + .map(|cs| cs.action_state.is_dodging()) .unwrap_or_default() { None @@ -140,7 +140,7 @@ impl FigureModelCache { Some(humanoid_armor_hand_spec.mesh_left_hand(&body)) }, if character_state - .map(|cs| cs.action.is_roll()) + .map(|cs| cs.action_state.is_dodging()) .unwrap_or_default() { None @@ -162,9 +162,9 @@ impl FigureModelCache { if camera_mode != CameraMode::FirstPerson || character_state .map(|cs| { - cs.action.is_attack() - || cs.action.is_block() - || cs.action.is_wield() + cs.action_state.is_attacking() + || cs.action_state.is_blocking() + || cs.action_state.is_wielding() }) .unwrap_or_default() { diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 80f52b69fc..13e01db904 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -18,8 +18,8 @@ use crate::{ use client::Client; use common::{ comp::{ - ActionState::*, Body, CharacterState, ItemKind, Last, MovementState::*, Ori, Pos, Scale, - Stats, Vel, + ActionState::*, AttackKind::*, Body, CharacterState, ItemKind, Last, MoveState::*, Ori, + Pos, Scale, Stats, Vel, }, terrain::TerrainChunk, vol::RectRasterableVol, @@ -160,7 +160,7 @@ impl FigureMgr { ) .1; - let mut movement_animation_rate = 1.0; + let mut move_state_animation_rate = 1.0; let mut action_animation_rate = 1.0; let vel = ecs @@ -189,65 +189,65 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_movement(&last_character.0) { - state.movement_time = 0.0; + if !character.is_same_move_state(&last_character.0) { + state.move_state_time = 0.0; } - if !character.is_same_action(&last_character.0) { + if !character.is_same_action_state(&last_character.0) { state.action_time = 0.0; } - let target_base = match &character.movement { + let target_base = match &character.move_state { Stand(_) => anim::character::StandAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Run(_) => anim::character::RunAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0, ori.0, state.last_ori, time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Jump(_) | Fall(_) => anim::character::JumpAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Glide(_) => anim::character::GlidingAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0, ori.0, state.last_ori, time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Swim(_) => anim::character::SwimAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0.magnitude(), ori.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Climb(_) => anim::character::ClimbAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0, ori.0, time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Sit(_) => anim::character::SitAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), }; - let target_bones = match (&character.movement, &character.action) { + let target_bones = match (&character.move_state, &character.action_state) { (Stand(_), Wield { .. }) => { anim::character::CidleAnimation::update_skeleton( &target_base, @@ -266,35 +266,37 @@ impl FigureMgr { skeleton_attr, ) } - (_, Attack { .. }) => anim::character::AttackAnimation::update_skeleton( - &target_base, - (active_tool_kind, time), - state.action_time, - &mut action_animation_rate, - skeleton_attr, - ), - (_, Wield { .. }) => anim::character::WieldAnimation::update_skeleton( + (_, Attack(kind)) => match kind { + Charge(_) => anim::character::ChargeAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.action_time, + &mut action_animation_rate, + skeleton_attr, + ), + BasicAttack(_) => anim::character::AttackAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.action_time, + &mut action_animation_rate, + skeleton_attr, + ), + }, + (_, Wield(_)) => anim::character::WieldAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.action_time, &mut action_animation_rate, skeleton_attr, ), - (_, Roll { .. }) => anim::character::RollAnimation::update_skeleton( + (_, Dodge(_)) => anim::character::RollAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.action_time, &mut action_animation_rate, skeleton_attr, ), - (_, Block { .. }) => anim::character::BlockAnimation::update_skeleton( - &target_base, - (active_tool_kind, time), - state.action_time, - &mut action_animation_rate, - skeleton_attr, - ), - (_, Charge { .. }) => anim::character::ChargeAnimation::update_skeleton( + (_, Block(_)) => anim::character::BlockAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.action_time, @@ -313,7 +315,7 @@ impl FigureMgr { scale, col, dt, - movement_animation_rate, + move_state_animation_rate, action_animation_rate, ); } @@ -330,30 +332,30 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_movement(&last_character.0) { - state.movement_time = 0.0; + if !character.is_same_move_state(&last_character.0) { + state.move_state_time = 0.0; } - let target_base = match character.movement { + let target_base = match character.move_state { Stand(_) => anim::quadruped_small::IdleAnimation::update_skeleton( &QuadrupedSmallSkeleton::new(), time, - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Run(_) => anim::quadruped_small::RunAnimation::update_skeleton( &QuadrupedSmallSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Jump(_) => anim::quadruped_small::JumpAnimation::update_skeleton( &QuadrupedSmallSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), @@ -370,7 +372,7 @@ impl FigureMgr { scale, col, dt, - movement_animation_rate, + move_state_animation_rate, action_animation_rate, ); } @@ -387,30 +389,30 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_movement(&last_character.0) { - state.movement_time = 0.0; + if !character.is_same_move_state(&last_character.0) { + state.move_state_time = 0.0; } - let target_base = match character.movement { + let target_base = match character.move_state { Stand(_) => anim::quadruped_medium::IdleAnimation::update_skeleton( &QuadrupedMediumSkeleton::new(), time, - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Run(_) => anim::quadruped_medium::RunAnimation::update_skeleton( &QuadrupedMediumSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Jump(_) => anim::quadruped_medium::JumpAnimation::update_skeleton( &QuadrupedMediumSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), @@ -427,7 +429,7 @@ impl FigureMgr { scale, col, dt, - movement_animation_rate, + move_state_animation_rate, action_animation_rate, ); } @@ -442,30 +444,30 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_movement(&last_character.0) { - state.movement_time = 0.0; + if !character.is_same_move_state(&last_character.0) { + state.move_state_time = 0.0; } - let target_base = match character.movement { + let target_base = match character.move_state { Stand(_) => anim::bird_medium::IdleAnimation::update_skeleton( &BirdMediumSkeleton::new(), time, - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Run(_) => anim::bird_medium::RunAnimation::update_skeleton( &BirdMediumSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Jump(_) => anim::bird_medium::JumpAnimation::update_skeleton( &BirdMediumSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), @@ -482,7 +484,7 @@ impl FigureMgr { scale, col, dt, - movement_animation_rate, + move_state_animation_rate, action_animation_rate, ); } @@ -497,30 +499,30 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_movement(&last_character.0) { - state.movement_time = 0.0; + if !character.is_same_move_state(&last_character.0) { + state.move_state_time = 0.0; } - let target_base = match character.movement { + let target_base = match character.move_state { Stand(_) => anim::fish_medium::IdleAnimation::update_skeleton( &FishMediumSkeleton::new(), time, - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Run(_) => anim::fish_medium::RunAnimation::update_skeleton( &FishMediumSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Jump(_) => anim::fish_medium::JumpAnimation::update_skeleton( &FishMediumSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), @@ -537,7 +539,7 @@ impl FigureMgr { scale, col, dt, - movement_animation_rate, + move_state_animation_rate, action_animation_rate, ); } @@ -552,30 +554,30 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_movement(&last_character.0) { - state.movement_time = 0.0; + if !character.is_same_move_state(&last_character.0) { + state.move_state_time = 0.0; } - let target_base = match character.movement { + let target_base = match character.move_state { Stand(_) => anim::dragon::IdleAnimation::update_skeleton( &DragonSkeleton::new(), time, - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Run(_) => anim::dragon::RunAnimation::update_skeleton( &DragonSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Jump(_) => anim::dragon::JumpAnimation::update_skeleton( &DragonSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), @@ -592,7 +594,7 @@ impl FigureMgr { scale, col, dt, - movement_animation_rate, + move_state_animation_rate, action_animation_rate, ); } @@ -607,30 +609,30 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_movement(&last_character.0) { - state.movement_time = 0.0; + if !character.is_same_move_state(&last_character.0) { + state.move_state_time = 0.0; } - let target_base = match character.movement { + let target_base = match character.move_state { Stand(_) => anim::bird_small::IdleAnimation::update_skeleton( &BirdSmallSkeleton::new(), time, - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Run(_) => anim::bird_small::RunAnimation::update_skeleton( &BirdSmallSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Jump(_) => anim::bird_small::JumpAnimation::update_skeleton( &BirdSmallSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), @@ -647,7 +649,7 @@ impl FigureMgr { scale, col, dt, - movement_animation_rate, + move_state_animation_rate, action_animation_rate, ); } @@ -662,30 +664,30 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_movement(&last_character.0) { - state.movement_time = 0.0; + if !character.is_same_move_state(&last_character.0) { + state.move_state_time = 0.0; } - let target_base = match character.movement { + let target_base = match character.move_state { Stand(_) => anim::fish_small::IdleAnimation::update_skeleton( &FishSmallSkeleton::new(), time, - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Run(_) => anim::fish_small::RunAnimation::update_skeleton( &FishSmallSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Jump(_) => anim::fish_small::JumpAnimation::update_skeleton( &FishSmallSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), @@ -702,7 +704,7 @@ impl FigureMgr { scale, col, dt, - movement_animation_rate, + move_state_animation_rate, action_animation_rate, ); } @@ -717,30 +719,30 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_movement(&last_character.0) { - state.movement_time = 0.0; + if !character.is_same_move_state(&last_character.0) { + state.move_state_time = 0.0; } - let target_base = match character.movement { + let target_base = match character.move_state { Stand(_) => anim::biped_large::IdleAnimation::update_skeleton( &BipedLargeSkeleton::new(), time, - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Run(_) => anim::biped_large::RunAnimation::update_skeleton( &BipedLargeSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), Jump(_) => anim::biped_large::JumpAnimation::update_skeleton( &BipedLargeSkeleton::new(), (vel.0.magnitude(), time), - state.movement_time, - &mut movement_animation_rate, + state.move_state_time, + &mut move_state_animation_rate, skeleton_attr, ), @@ -757,7 +759,7 @@ impl FigureMgr { scale, col, dt, - movement_animation_rate, + move_state_animation_rate, action_animation_rate, ); } @@ -776,7 +778,7 @@ impl FigureMgr { scale, col, dt, - movement_animation_rate, + move_state_animation_rate, action_animation_rate, ); } @@ -919,7 +921,7 @@ impl FigureMgr { pub struct FigureState { bone_consts: Consts, locals: Consts, - movement_time: f64, + move_state_time: f64, action_time: f64, skeleton: S, pos: Vec3, @@ -934,7 +936,7 @@ impl FigureState { .create_consts(&skeleton.compute_matrices()) .unwrap(), locals: renderer.create_consts(&[FigureLocals::default()]).unwrap(), - movement_time: 0.0, + move_state_time: 0.0, action_time: 0.0, skeleton, pos: Vec3::zero(), @@ -952,7 +954,7 @@ impl FigureState { scale: f32, col: Rgba, dt: f32, - movement_rate: f32, + move_state_rate: f32, action_rate: f32, ) { self.last_ori = Lerp::lerp(self.last_ori, ori, 15.0 * dt); @@ -966,7 +968,7 @@ impl FigureState { self.ori = ori; } - self.movement_time += (dt * movement_rate) as f64; + self.move_state_time += (dt * move_state_rate) as f64; self.action_time += (dt * action_rate) as f64; let mat = Mat4::::identity() diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index a98e30c436..be4ad36102 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -160,7 +160,7 @@ impl Scene { .ecs() .read_storage::() .get(client.entity()) - .map_or(false, |cs| cs.action.is_roll()); + .map_or(false, |cs| cs.action_state.is_dodging()); let player_scale = match client .state() diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 6d7151d65f..52cc3efbbe 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -202,9 +202,9 @@ impl PlayState for SessionState { .read_storage::() .get(client.entity()) .map(|cs| { - cs.action.is_wield() - || cs.action.is_block() - || cs.action.is_attack() + cs.action_state.is_wielding() + || cs.action_state.is_blocking() + || cs.action_state.is_attacking() }) .unwrap_or(false) { From 06053faed08800d0d4a45f5e71a7417bfd15c027 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Thu, 26 Dec 2019 10:01:19 -0800 Subject: [PATCH 006/326] Add state disables, cleanup imports --- common/src/comp/character_state.rs | 9 ++- common/src/comp/mod.rs | 4 +- common/src/comp/states/basic_attack.rs | 39 +++++++++- common/src/comp/states/basic_block.rs | 40 ++++++++++- common/src/comp/states/charge_attack.rs | 94 +++++++++++++++---------- common/src/comp/states/climb.rs | 41 ++++++----- common/src/comp/states/fall.rs | 37 ++++------ common/src/comp/states/glide.rs | 36 ++++------ common/src/comp/states/jump.rs | 11 ++- common/src/comp/states/mod.rs | 12 ++-- common/src/comp/states/roll.rs | 55 +++++++++++++-- common/src/comp/states/run.rs | 53 ++++---------- common/src/comp/states/sit.rs | 52 ++++++-------- common/src/comp/states/stand.rs | 64 ++++------------- common/src/comp/states/swim.rs | 29 +++----- common/src/comp/states/wield.rs | 50 ++++++------- common/src/sys/agent.rs | 2 +- common/src/sys/character_state.rs | 42 ++++------- common/src/sys/controller.rs | 5 +- 19 files changed, 341 insertions(+), 334 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 5b6cc3ba49..b0e57ac12c 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -10,7 +10,7 @@ use specs::{Component, Entity, FlaggedStorage, HashMapStorage, NullStorage}; use sphynx::Uid; use std::time::Duration; -pub struct ECSStateData<'a> { +pub struct EcsCharacterState<'a> { pub entity: &'a Entity, pub uid: &'a Uid, pub character: &'a CharacterState, @@ -27,7 +27,7 @@ pub struct ECSStateData<'a> { pub local_bus: &'a EventBus, } -pub struct ECSStateUpdate { +pub struct EcsStateUpdate { pub character: CharacterState, pub pos: Pos, pub vel: Vel, @@ -127,6 +127,8 @@ impl ActionState { pub struct CharacterState { pub move_state: MoveState, pub action_state: ActionState, + pub action_disabled: bool, + pub move_disabled: bool, } impl CharacterState { @@ -134,6 +136,7 @@ impl CharacterState { // Check if state is the same without looking at the inner data std::mem::discriminant(&self.move_state) == std::mem::discriminant(&other.move_state) } + pub fn is_same_action_state(&self, other: &Self) -> bool { // Check if state is the same without looking at the inner data std::mem::discriminant(&self.action_state) == std::mem::discriminant(&other.action_state) @@ -148,6 +151,8 @@ impl Default for CharacterState { Self { move_state: MoveState::Fall(FallHandler), action_state: ActionState::Idle, + action_disabled: false, + move_disabled: false, } } } diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 2acf89e6b5..e1bca6cde3 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -22,8 +22,8 @@ pub use body::{ quadruped_medium, quadruped_small, Body, }; pub use character_state::{ - ActionState, AttackKind, BlockKind, CharacterState, DodgeKind, ECSStateData, ECSStateUpdate, - MoveState, OverrideAction, OverrideMove, OverrideState, + ActionState, AttackKind, BlockKind, CharacterState, DodgeKind, EcsCharacterState, + EcsStateUpdate, MoveState, OverrideAction, OverrideMove, OverrideState, }; pub use controller::{ ControlEvent, Controller, ControllerInputs, Input, InputState, InventoryManip, MountState, diff --git a/common/src/comp/states/basic_attack.rs b/common/src/comp/states/basic_attack.rs index 56dd8872d2..366e177b88 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/comp/states/basic_attack.rs @@ -1,4 +1,11 @@ -use super::{ECSStateData, ECSStateUpdate, StateHandle}; +use super::TEMP_EQUIP_DELAY; +use crate::comp::{ + ActionState::{Attack, Idle, Wield}, + AttackKind::BasicAttack, + EcsCharacterState, EcsStateUpdate, + ItemKind::Tool, + StateHandle, WieldHandler, +}; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -8,12 +15,38 @@ pub struct BasicAttackHandler { } impl StateHandle for BasicAttackHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - return ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, character: *ecs_data.character, }; + + // Check if attack duration has expired + if self.remaining_duration == Duration::default() { + // If so, go back to wielding or idling + update.character.action_state = if let Some(Tool { .. }) = + ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) + { + Wield(WieldHandler { + equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), + }) + } else { + Idle + }; + + return update; + } + + // Otherwise, tick down remaining_duration, and keep rolling + update.character.action_state = Attack(BasicAttack(BasicAttackHandler { + remaining_duration: self + .remaining_duration + .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) + .unwrap_or_default(), + })); + + return update; } } diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs index 038d30be14..30d5ff4fe2 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/comp/states/basic_block.rs @@ -1,5 +1,12 @@ -use super::{ECSStateData, ECSStateUpdate, StateHandle}; +use super::{BLOCK_ACCEL, BLOCK_SPEED, TEMP_EQUIP_DELAY}; +use crate::comp::{ + ActionState::{Idle, Wield}, + EcsCharacterState, EcsStateUpdate, + ItemKind::Tool, + StateHandle, WieldHandler, +}; use std::time::Duration; +use vek::Vec2; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct BasicBlockHandler { @@ -8,12 +15,39 @@ pub struct BasicBlockHandler { } impl StateHandle for BasicBlockHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - return ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, character: *ecs_data.character, }; + + // TODO: Apply simple move speed debuff instead + + // Update movement + update.vel.0 += Vec2::broadcast(ecs_data.dt.0) + * ecs_data.inputs.move_dir + * match ecs_data.physics.on_ground { + true if update.vel.0.magnitude_squared() < BLOCK_SPEED.powf(2.0) => BLOCK_ACCEL, + _ => 0.0, + }; + + if !ecs_data.inputs.secondary.is_pressed() { + update.character.action_state = if let Some(Tool { .. }) = + ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) + { + Wield(WieldHandler { + equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), + }) + } else { + Idle + }; + + update.character.move_disabled = false; + return update; + } + + return update; } } diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs index 8caec5b33e..d80ffad2e5 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/comp/states/charge_attack.rs @@ -1,17 +1,16 @@ -use super::{ - CharacterState, ECSStateData, ECSStateUpdate, MoveState::Run, RunHandler, Stand, StandHandler, - StateHandle, WieldHandler, -}; use crate::comp::{ ActionState::{Attack, Idle, Wield}, AttackKind::Charge, - HealthChange, HealthSource, + EcsCharacterState, EcsStateUpdate, HealthChange, HealthSource, ItemKind::Tool, + MoveState::Run, + RunHandler, StateHandle, WieldHandler, }; use crate::event::ServerEvent; use std::time::Duration; +use vek::Vec3; -use super::TEMP_EQUIP_DELAY; +use super::{CHARGE_SPEED, TEMP_EQUIP_DELAY}; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct ChargeAttackHandler { @@ -20,15 +19,36 @@ pub struct ChargeAttackHandler { } impl StateHandle for ChargeAttackHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - let mut update = ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, character: *ecs_data.character, }; + // Prevent move state handling, handled here + // ecs_data.updater.insert(*ecs_data.entity, OverrideMove); + update.character.action_disabled = true; + + update.character.move_state = Run(RunHandler); + + // Move player + update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) + + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) + + 1.5 + * ecs_data + .inputs + .move_dir + .try_normalized() + .unwrap_or_default()) + .try_normalized() + .unwrap_or_default() + * CHARGE_SPEED; + + // Check if hitting another entity if let Some(uid_b) = ecs_data.physics.touch_entity { + // Send Damage event ecs_data.server_bus.emitter().emit(ServerEvent::Damage { uid: uid_b, change: HealthChange { @@ -37,49 +57,45 @@ impl StateHandle for ChargeAttackHandler { }, }); - update.character = CharacterState { - move_state: Stand(StandHandler), - action_state: if let Some(Tool { .. }) = - ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) - { - Wield(WieldHandler { - equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), - }) - } else { - Idle - }, + // Go back to wielding + update.character.action_state = if let Some(Tool { .. }) = + ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) + { + Wield(WieldHandler { + equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), + }) + } else { + Idle }; + update.character.move_disabled = false; return update; } + // Check if charge timed out or can't keep moving forward if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 { - update.character = CharacterState { - move_state: Stand(StandHandler), - action_state: if let Some(Tool { .. }) = - ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) - { - Wield(WieldHandler { - equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), - }) - } else { - Idle - }, + update.character.action_state = if let Some(Tool { .. }) = + ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) + { + Wield(WieldHandler { + equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), + }) + } else { + Idle }; + update.character.move_disabled = false; return update; } - update.character = CharacterState { - move_state: Run(RunHandler), - action_state: Attack(Charge(ChargeAttackHandler { - remaining_duration: self - .remaining_duration - .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) - .unwrap_or_default(), - })), - }; + // Tick remaining-duration and keep charging + update.character.action_state = Attack(Charge(ChargeAttackHandler { + remaining_duration: self + .remaining_duration + .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) + .unwrap_or_default(), + })); return update; } diff --git a/common/src/comp/states/climb.rs b/common/src/comp/states/climb.rs index cc915f60dd..e7ad8d55c9 100644 --- a/common/src/comp/states/climb.rs +++ b/common/src/comp/states/climb.rs @@ -1,6 +1,6 @@ use super::{ - ActionState::*, CharacterState, ECSStateData, ECSStateUpdate, FallHandler, JumpHandler, - MoveState::*, StandHandler, StateHandle, + ActionState::*, EcsCharacterState, EcsStateUpdate, FallHandler, JumpHandler, MoveState::*, + StandHandler, StateHandle, }; use super::{CLIMB_SPEED, HUMANOID_CLIMB_ACCEL, HUMANOID_SPEED}; use crate::sys::phys::GRAVITY; @@ -11,15 +11,19 @@ use vek::Lerp; pub struct ClimbHandler; impl StateHandle for ClimbHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - let mut update = ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, character: *ecs_data.character, }; - // Move player according to move_dir + // Disable actions in this state + update.character.action_state = Idle; + update.character.action_disabled = true; + + // Move player update.vel.0 += Vec2::broadcast(ecs_data.dt.0) * ecs_data.inputs.move_dir * if update.vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { @@ -28,7 +32,7 @@ impl StateHandle for ClimbHandler { 0.0 }; - // Set direction based on move direction when on the ground + // Set orientation direction based on wall direction let ori_dir = if let Some(wall_dir) = ecs_data.physics.on_wall { if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { Vec2::from(wall_dir).normalized() @@ -72,26 +76,27 @@ impl StateHandle for ClimbHandler { } } + // If no wall is infront of character ... if let None = ecs_data.physics.on_wall { if ecs_data.inputs.jump.is_pressed() { - update.character = CharacterState { - action_state: Idle, - move_state: Jump(JumpHandler), - }; + // They've climbed atop something, give them a boost + update.character.move_state = Jump(JumpHandler); + update.character.action_disabled = false; + return update; } else { - update.character = CharacterState { - action_state: Idle, - move_state: Fall(FallHandler), - }; + // Just fall off + update.character.move_state = Fall(FallHandler); + update.character.action_disabled = false; + return update; } } + + // Remove climb state on ground, otherwise character will get stuck if ecs_data.physics.on_ground { - update.character = CharacterState { - action_state: Idle, - move_state: Stand(StandHandler), - }; + update.character.move_state = Stand(StandHandler); + update.character.action_disabled = false; return update; } diff --git a/common/src/comp/states/fall.rs b/common/src/comp/states/fall.rs index 8a5c30dcc1..c140bea677 100644 --- a/common/src/comp/states/fall.rs +++ b/common/src/comp/states/fall.rs @@ -1,6 +1,6 @@ use super::{ - ActionState::*, CharacterState, ECSStateData, ECSStateUpdate, GlideHandler, MoveState::*, - RunHandler, StandHandler, StateHandle, SwimHandler, + EcsCharacterState, EcsStateUpdate, GlideHandler, MoveState::*, RunHandler, StandHandler, + StateHandle, SwimHandler, }; use super::{HUMANOID_AIR_ACCEL, HUMANOID_AIR_SPEED}; use vek::{Vec2, Vec3}; @@ -9,8 +9,8 @@ use vek::{Vec2, Vec3}; pub struct FallHandler; impl StateHandle for FallHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - let mut update = ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, @@ -34,6 +34,7 @@ impl StateHandle for FallHandler { } else { Vec2::from(update.vel.0) }; + if ori_dir.magnitude_squared() > 0.0001 && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 @@ -43,11 +44,8 @@ impl StateHandle for FallHandler { } // Check gliding - if ecs_data.inputs.glide.is_pressed() && !ecs_data.inputs.glide.is_held_down() { - update.character = CharacterState { - action_state: Idle, - move_state: Glide(GlideHandler), - }; + if ecs_data.inputs.glide.is_pressed() { + update.character.move_state = Glide(GlideHandler); return update; } @@ -56,17 +54,11 @@ impl StateHandle for FallHandler { if !ecs_data.physics.on_ground { // Check if in fluid to go to swimming or back to falling if ecs_data.physics.in_fluid { - update.character = CharacterState { - action_state: update.character.action_state, - move_state: Swim(SwimHandler), - }; + update.character.move_state = Swim(SwimHandler); return update; } else { - update.character = CharacterState { - action_state: update.character.action_state, - move_state: Fall(FallHandler), - }; + update.character.move_state = Fall(FallHandler); return update; } @@ -74,13 +66,10 @@ impl StateHandle for FallHandler { // On ground else { // Return to running or standing based on move inputs - update.character = CharacterState { - action_state: update.character.action_state, - move_state: if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - Run(RunHandler) - } else { - Stand(StandHandler) - }, + update.character.move_state = if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { + Run(RunHandler) + } else { + Stand(StandHandler) }; return update; diff --git a/common/src/comp/states/glide.rs b/common/src/comp/states/glide.rs index 8511d4c469..d709ced47e 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/comp/states/glide.rs @@ -1,6 +1,6 @@ use super::{ - ActionState::*, CharacterState, ClimbHandler, ECSStateData, ECSStateUpdate, FallHandler, - MoveState::*, StandHandler, StateHandle, + ActionState::*, ClimbHandler, EcsCharacterState, EcsStateUpdate, FallHandler, MoveState::*, + StandHandler, StateHandle, }; use super::{GLIDE_ACCEL, GLIDE_ANTIGRAV, GLIDE_SPEED}; use vek::{Vec2, Vec3}; @@ -9,14 +9,20 @@ use vek::{Vec2, Vec3}; pub struct GlideHandler; impl StateHandle for GlideHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - let mut update = ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, character: *ecs_data.character, }; + // Prevent action in this state, set here + update.character.action_disabled = true; + + update.character.action_state = Idle; + update.character.move_state = Glide(GlideHandler); + // Move player according to movement direction vector update.vel.0 += Vec2::broadcast(ecs_data.dt.0) * ecs_data.inputs.move_dir @@ -36,7 +42,7 @@ impl StateHandle for GlideHandler { vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 2.0 * ecs_data.dt.0); } - // Apply Glide lift + // Apply Glide antigrav lift if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) && update.vel.0.z < 0.0 { @@ -50,38 +56,24 @@ impl StateHandle for GlideHandler { // If glide button isn't held if !ecs_data.inputs.glide.is_pressed() { - update.character = CharacterState { - action_state: Idle, - move_state: Fall(FallHandler), - }; + update.character.move_state = Fall(FallHandler); return update; } // If there is a wall in front of character go to climb else if let Some(_wall_dir) = ecs_data.physics.on_wall { - update.character = CharacterState { - action_state: Idle, - move_state: Climb(ClimbHandler), - }; + update.character.move_state = Climb(ClimbHandler); return update; } // If on ground go to stand if ecs_data.physics.on_ground { - update.character = CharacterState { - action_state: Idle, - move_state: Stand(StandHandler), - }; + update.character.move_state = Stand(StandHandler); return update; } // Otherwise keep gliding - update.character = CharacterState { - action_state: Idle, - move_state: Glide(GlideHandler), - }; - return update; } } diff --git a/common/src/comp/states/jump.rs b/common/src/comp/states/jump.rs index 0f48e33c92..5794ee78c1 100644 --- a/common/src/comp/states/jump.rs +++ b/common/src/comp/states/jump.rs @@ -1,12 +1,12 @@ -use super::{CharacterState, ECSStateData, ECSStateUpdate, FallHandler, MoveState::*, StateHandle}; +use super::{EcsCharacterState, EcsStateUpdate, FallHandler, MoveState::*, StateHandle}; use crate::event::LocalEvent; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct JumpHandler; impl StateHandle for JumpHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - let mut update = ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -18,10 +18,7 @@ impl StateHandle for JumpHandler { .emitter() .emit(LocalEvent::Jump(*ecs_data.entity)); - update.character = CharacterState { - action_state: ecs_data.character.action_state, - move_state: Fall(FallHandler), - }; + update.character.move_state = Fall(FallHandler); return update; } diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index 77e32be07a..dff9ec53ae 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -50,17 +50,17 @@ pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; // Public interface, wires character states to their handlers. use super::{ - ActionState, ActionState::*, AttackKind::*, BlockKind::*, CharacterState, DodgeKind::*, - ECSStateData, ECSStateUpdate, MoveState, MoveState::*, + ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsCharacterState, + EcsStateUpdate, MoveState, MoveState::*, }; pub trait StateHandle { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate; + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate; } impl StateHandle for ActionState { /// Passes handle to variant or subvariant handlers - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { match self { Attack(kind) => match kind { BasicAttack(handler) => handler.handle(ecs_data), @@ -73,7 +73,7 @@ impl StateHandle for ActionState { Roll(handler) => handler.handle(ecs_data), }, Wield(handler) => handler.handle(ecs_data), - Idle => ECSStateUpdate { + Idle => EcsStateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -87,7 +87,7 @@ impl StateHandle for ActionState { impl StateHandle for MoveState { /// Passes handle to variant handlers - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { match self { Stand(handler) => handler.handle(&ecs_data), Run(handler) => handler.handle(&ecs_data), diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index 2759a10653..fb7285759e 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -1,6 +1,10 @@ -use super::{ECSStateData, ECSStateUpdate, StateHandle}; +use super::{ROLL_SPEED, TEMP_EQUIP_DELAY}; +use crate::comp::{ + ActionState::*, DodgeKind::*, EcsCharacterState, EcsStateUpdate, ItemKind::Tool, OverrideMove, + StateHandle, WieldHandler, +}; use std::time::Duration; - +use vek::Vec3; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct RollHandler { /// How long the state has until exitting @@ -8,12 +12,55 @@ pub struct RollHandler { } impl StateHandle for RollHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + }; + + // Prevent move state handling, handled here + ecs_data.updater.insert(*ecs_data.entity, OverrideMove); + + // Update velocity + update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) + + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) + + 1.5 + * ecs_data + .inputs + .move_dir + .try_normalized() + .unwrap_or_default()) + .try_normalized() + .unwrap_or_default() + * ROLL_SPEED; + + // Check if roll duration has expired + if self.remaining_duration == Duration::default() { + // If so, go back to wielding or idling + update.character.action_state = if let Some(Tool { .. }) = + ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) + { + Wield(WieldHandler { + equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), + }) + } else { + Idle + }; + + ecs_data.updater.remove::(*ecs_data.entity); + return update; } + + // Otherwise, tick down remaining_duration, and keep rolling + update.character.action_state = Dodge(Roll(RollHandler { + remaining_duration: self + .remaining_duration + .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) + .unwrap_or_default(), + })); + + return update; } } diff --git a/common/src/comp/states/run.rs b/common/src/comp/states/run.rs index 80ee1f0c5d..c6ef09d711 100644 --- a/common/src/comp/states/run.rs +++ b/common/src/comp/states/run.rs @@ -1,6 +1,6 @@ use super::{ - ActionState::*, CharacterState, ClimbHandler, ECSStateData, ECSStateUpdate, FallHandler, - GlideHandler, JumpHandler, MoveState::*, SitHandler, StandHandler, StateHandle, SwimHandler, + ClimbHandler, EcsCharacterState, EcsStateUpdate, FallHandler, GlideHandler, JumpHandler, + MoveState::*, SitHandler, StandHandler, StateHandle, SwimHandler, }; use super::{HUMANOID_ACCEL, HUMANOID_SPEED}; use vek::vec::{Vec2, Vec3}; @@ -9,8 +9,8 @@ use vek::vec::{Vec2, Vec3}; pub struct RunHandler; impl StateHandle for RunHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - let mut update = ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -48,10 +48,7 @@ impl StateHandle for RunHandler { && ecs_data.physics.on_ground && ecs_data.body.is_humanoid() { - update.character = CharacterState { - action_state: Idle, - move_state: Sit(SitHandler), - }; + update.character.move_state = Sit(SitHandler); return update; } @@ -62,20 +59,14 @@ impl StateHandle for RunHandler { && ecs_data.body.is_humanoid(), ecs_data.physics.on_wall, ) { - update.character = CharacterState { - action_state: Idle, - move_state: Climb(ClimbHandler), - }; + update.character.move_state = Climb(ClimbHandler); return update; } // Try to swim if !ecs_data.physics.on_ground && ecs_data.physics.in_fluid { - update.character = CharacterState { - action_state: ecs_data.character.action_state, - move_state: Swim(SwimHandler), - }; + update.character.move_state = Swim(SwimHandler); return update; } @@ -84,18 +75,10 @@ impl StateHandle for RunHandler { if ecs_data.physics.on_ground { // Try to jump if ecs_data.inputs.jump.is_pressed() && !ecs_data.inputs.jump.is_held_down() { - update.character = CharacterState { - action_state: ecs_data.character.action_state, - move_state: Jump(JumpHandler), - }; + update.character.move_state = Jump(JumpHandler); return update; } - - // Try to dodge - if ecs_data.inputs.roll.is_pressed() && ecs_data.body.is_humanoid() { - // updater.insert(entity, DodgeStart); - } } // While not on ground ... else { @@ -105,33 +88,21 @@ impl StateHandle for RunHandler { && !ecs_data.inputs.glide.is_held_down() && ecs_data.body.is_humanoid() { - update.character = CharacterState { - action_state: Idle, - move_state: Glide(GlideHandler), - }; + update.character.move_state = Glide(GlideHandler); return update; } - update.character = CharacterState { - action_state: ecs_data.character.action_state, - move_state: Fall(FallHandler), - }; + update.character.move_state = Fall(FallHandler); return update; } if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - update.character = CharacterState { - action_state: ecs_data.character.action_state, - move_state: Run(RunHandler), - }; + update.character.move_state = Run(RunHandler); return update; } else { - update.character = CharacterState { - action_state: ecs_data.character.action_state, - move_state: Stand(StandHandler), - }; + update.character.move_state = Stand(StandHandler); return update; } diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs index 5634b1fb21..046acc405e 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/comp/states/sit.rs @@ -1,76 +1,66 @@ -use super::{ - ActionState::*, CharacterState, ECSStateData, ECSStateUpdate, FallHandler, JumpHandler, - MoveState::*, RunHandler, StandHandler, StateHandle, SwimHandler, +use crate::comp::{ + ActionState::*, EcsCharacterState, EcsStateUpdate, FallHandler, JumpHandler, MoveState::*, + RunHandler, StandHandler, StateHandle, SwimHandler, }; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct SitHandler; impl StateHandle for SitHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - let mut update = ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, }; + // Prevent action state handling + update.character.action_disabled = true; + update.character.action_state = Idle; + update.character.move_state = Sit(SitHandler); + // Falling // Idk, maybe the ground disappears, // suddenly maybe a water spell appears. // Can't hurt to be safe :shrug: if !ecs_data.physics.on_ground { if ecs_data.physics.in_fluid { - update.character = CharacterState { - action_state: Idle, - move_state: Swim(SwimHandler), - }; + update.character.move_state = Swim(SwimHandler); + update.character.action_disabled = false; return update; } else { - update.character = CharacterState { - action_state: Idle, - move_state: Fall(FallHandler), - }; + update.character.move_state = Fall(FallHandler); + update.character.action_disabled = false; return update; } } // Jumping if ecs_data.inputs.jump.is_pressed() { - update.character = CharacterState { - action_state: Idle, - move_state: Jump(JumpHandler), - }; + update.character.move_state = Jump(JumpHandler); + update.character.action_disabled = false; return update; } // Moving if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - update.character = CharacterState { - action_state: Idle, - move_state: Run(RunHandler), - }; + update.character.move_state = Run(RunHandler); + update.character.action_disabled = false; return update; } // Standing back up (unsitting) if ecs_data.inputs.sit.is_just_pressed() { - update.character = CharacterState { - action_state: Idle, - move_state: Stand(StandHandler), - }; + update.character.move_state = Stand(StandHandler); + update.character.action_disabled = false; return update; } - // no move_state has occurred - update.character = CharacterState { - action_state: Idle, - move_state: Sit(SitHandler), - }; - + // No move has occurred, keep sitting return update; } } diff --git a/common/src/comp/states/stand.rs b/common/src/comp/states/stand.rs index fb42b04f12..b4d1402052 100644 --- a/common/src/comp/states/stand.rs +++ b/common/src/comp/states/stand.rs @@ -1,13 +1,13 @@ use super::{ - ActionState::*, CharacterState, ClimbHandler, ECSStateData, ECSStateUpdate, FallHandler, - GlideHandler, JumpHandler, MoveState::*, RunHandler, SitHandler, StateHandle, SwimHandler, + ClimbHandler, EcsCharacterState, EcsStateUpdate, FallHandler, GlideHandler, JumpHandler, + MoveState::*, RunHandler, SitHandler, StateHandle, SwimHandler, }; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct StandHandler; impl StateHandle for StandHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - let mut update = ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -19,10 +19,7 @@ impl StateHandle for StandHandler { && ecs_data.physics.on_ground && ecs_data.body.is_humanoid() { - update.character = CharacterState { - move_state: Sit(SitHandler), - action_state: update.character.action_state, - }; + update.character.move_state = Sit(SitHandler); return update; } @@ -33,20 +30,14 @@ impl StateHandle for StandHandler { && ecs_data.body.is_humanoid(), ecs_data.physics.on_wall, ) { - update.character = CharacterState { - action_state: update.character.action_state, - move_state: Climb(ClimbHandler), - }; + update.character.move_state = Climb(ClimbHandler); return update; } // Try to swim if !ecs_data.physics.on_ground && ecs_data.physics.in_fluid { - update.character = CharacterState { - action_state: update.character.action_state, - move_state: Swim(SwimHandler), - }; + update.character.move_state = Swim(SwimHandler); return update; } @@ -55,64 +46,33 @@ impl StateHandle for StandHandler { if ecs_data.physics.on_ground { // Try to jump if ecs_data.inputs.jump.is_pressed() { - update.character = CharacterState { - action_state: update.character.action_state, - move_state: Jump(JumpHandler), - }; + update.character.move_state = Jump(JumpHandler); return update; } - - // // Try to charge - // if inputs.charge.is_pressed() && !inputs.charge.is_held_down() { - // } - - // Try to roll - if ecs_data.inputs.roll.is_pressed() && ecs_data.body.is_humanoid() { - // updater.insert(entity, DodgeStart); - } } // While not on ground ... else { // Try to glide if ecs_data.physics.on_wall == None && ecs_data.inputs.glide.is_pressed() - && !ecs_data.inputs.glide.is_held_down() && ecs_data.body.is_humanoid() { - update.character = CharacterState { - action_state: Idle, - move_state: Glide(GlideHandler), - }; + update.character.move_state = Glide(GlideHandler); return update; } - update.character = CharacterState { - action_state: update.character.action_state, - move_state: Fall(FallHandler), - }; + update.character.move_state = Fall(FallHandler); return update; } - if ecs_data.inputs.primary.is_pressed() { - // updater.insert(entity, PrimaryStart); - } else if ecs_data.inputs.secondary.is_pressed() { - // updater.insert(entity, SecondaryStart); - } - if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - update.character = CharacterState { - action_state: update.character.action_state, - move_state: Run(RunHandler), - }; + update.character.move_state = Run(RunHandler); return update; } else { - update.character = CharacterState { - action_state: update.character.action_state, - move_state: Stand(StandHandler), - }; + update.character.move_state = Stand(StandHandler); return update; } diff --git a/common/src/comp/states/swim.rs b/common/src/comp/states/swim.rs index 2a864c0a38..4595e5f78d 100644 --- a/common/src/comp/states/swim.rs +++ b/common/src/comp/states/swim.rs @@ -1,6 +1,5 @@ use super::{ - CharacterState, ECSStateData, ECSStateUpdate, MoveState::*, RunHandler, StandHandler, - StateHandle, + EcsCharacterState, EcsStateUpdate, MoveState::*, RunHandler, StandHandler, StateHandle, }; use super::{HUMANOID_WATER_ACCEL, HUMANOID_WATER_SPEED}; use crate::sys::phys::GRAVITY; @@ -10,8 +9,8 @@ use vek::{Vec2, Vec3}; pub struct SwimHandler; impl StateHandle for SwimHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - let mut update = ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -52,31 +51,19 @@ impl StateHandle for SwimHandler { (update.vel.0.z + ecs_data.dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); } - if ecs_data.inputs.primary.is_pressed() { - // TODO: PrimaryStart - } else if ecs_data.inputs.secondary.is_pressed() { - // TODO: SecondaryStart - } - // Not on ground if !ecs_data.physics.on_ground { - update.character = CharacterState { - action_state: ecs_data.character.action_state, - move_state: Swim(SwimHandler), - }; + update.character.move_state = Swim(SwimHandler); return update; } // On ground else { // Return to running or standing based on move inputs - update.character = CharacterState { - action_state: ecs_data.character.action_state, - move_state: if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - Run(RunHandler) - } else { - Stand(StandHandler) - }, + update.character.move_state = if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { + Run(RunHandler) + } else { + Stand(StandHandler) }; return update; diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index a0e55ee56f..ebc5b64a29 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -1,4 +1,4 @@ -use super::{ActionState::*, CharacterState, ECSStateData, ECSStateUpdate, StateHandle}; +use super::{ActionState::*, EcsCharacterState, EcsStateUpdate, StateHandle}; use std::time::Duration; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -9,42 +9,42 @@ pub struct WieldHandler { } impl StateHandle for WieldHandler { - fn handle(&self, ecs_data: &ECSStateData) -> ECSStateUpdate { - let mut update = ECSStateUpdate { + fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + let mut update = EcsStateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, }; - // Toggling Weapons - if ecs_data.inputs.toggle_wield.is_pressed() - && ecs_data.character.action_state.is_equip_finished() - { - update.character = CharacterState { - action_state: Idle, - move_state: ecs_data.character.move_state, - }; + // Only act once equip_delay has expired + if self.equip_delay == Duration::default() { + // Toggle Weapons + if ecs_data.inputs.toggle_wield.is_pressed() + && ecs_data.character.action_state.is_equip_finished() + { + update.character.action_state = Idle; - return update; + return update; + } + + // Try weapon actions + if ecs_data.inputs.primary.is_pressed() { + // TODO: PrimaryStart + } else if ecs_data.inputs.secondary.is_pressed() { + // TODO: SecondaryStart + } } - - if ecs_data.inputs.primary.is_pressed() { - // TODO: PrimaryStart - } else if ecs_data.inputs.secondary.is_pressed() { - // TODO: SecondaryStart - } - - // Update wield delay - update.character = CharacterState { - action_state: Wield(WieldHandler { + // Equip delay hasn't expired yet + else { + // Update wield delay + update.character.action_state = Wield(WieldHandler { equip_delay: self .equip_delay .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) .unwrap_or_default(), - }), - move_state: ecs_data.character.move_state, - }; + }); + } return update; } diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index a99e904b71..bf14498cc4 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -1,6 +1,6 @@ use crate::comp::{ Agent, CharacterState, Controller, ControllerInputs, GlideHandler, MountState, - MoveState::Glide, Pos, SitHandler, Stats, + MoveState::Glide, Pos, Stats, }; use crate::pathfinding::WorldPath; use crate::terrain::TerrainGrid; diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index ab1c754aaf..65138ce500 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,8 +1,8 @@ use crate::{ comp::{ - Body, CharacterState, Controller, ControllerInputs, ECSStateData, Mounting, MoveState::*, - Ori, OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, SitHandler, - StateHandle, Stats, Vel, + Body, CharacterState, Controller, EcsCharacterState, Mounting, MoveState::*, Ori, + OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, SitHandler, StateHandle, + Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -41,7 +41,7 @@ impl<'a> System<'a> for Sys { &mut self, ( entities, - uid_allocator, + _uid_allocator, server_bus, local_bus, dt, @@ -65,9 +65,9 @@ impl<'a> System<'a> for Sys { entity, uid, mut character, - mut pos, - mut vel, - mut ori, + pos, + vel, + ori, controller, stats, body, @@ -108,15 +108,15 @@ impl<'a> System<'a> for Sys { continue; } // If mounted, character state is controlled by mount - // TODO: Make mounting a stater + // TODO: Make mounting a state if maybe_mount.is_some() { character.move_state = Sit(SitHandler); continue; } // Determine new move state if can move - if !maybe_move_override.is_some() { - let state_update = character.move_state.handle(&ECSStateData { + if !maybe_move_override.is_some() && !character.move_disabled { + let state_update = character.move_state.handle(&EcsCharacterState { entity: &entity, uid, character, @@ -140,8 +140,8 @@ impl<'a> System<'a> for Sys { } // Determine new action if can_act - if !maybe_action_override.is_some() { - let state_update = character.action_state.handle(&ECSStateData { + if !maybe_action_override.is_some() && !character.action_disabled { + let state_update = character.action_state.handle(&EcsCharacterState { entity: &entity, uid, character, @@ -163,24 +163,6 @@ impl<'a> System<'a> for Sys { *vel = state_update.vel; *ori = state_update.ori; } - - // Rolling + Any Movement, prioritizes finishing charge - // over move_state states - // ( - // Roll { - // time_left, - // was_wielding, - // }, - // _, - // ) => { - // if time_left == Duration::default() { - // if was_wielding { - // character.action = try_wield(stats); - // } else { - // character.action = Idle; - // } - // } - // } } } } diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index 2af37f4fb8..627649a022 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -25,11 +25,10 @@ impl<'a> System<'a> for Sys { ); fn run( &mut self, - (entities, uid_allocator, server_bus, local_bus, dt, mut controllers, uids): Self::SystemData, + (entities, uid_allocator, server_bus, _local_bus, _dt, mut controllers, uids): Self::SystemData, ) { let mut server_emitter = server_bus.emitter(); - let mut local_emitter = local_bus.emitter(); - for (entity, uid, controller) in (&entities, &uids, &mut controllers).join() { + for (entity, _uid, controller) in (&entities, &uids, &mut controllers).join() { let inputs = &mut controller.inputs; // Update `inputs.move_dir`. From ca4449725829425f04de0b81bd8057084fdf7db7 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sat, 28 Dec 2019 08:10:39 -0800 Subject: [PATCH 007/326] Add movement_utils --- common/src/comp/character_state.rs | 80 ++++++++++++++++------ common/src/comp/mod.rs | 4 +- common/src/comp/states/basic_attack.rs | 29 +++----- common/src/comp/states/basic_block.rs | 30 +++------ common/src/comp/states/charge_attack.rs | 48 ++++--------- common/src/comp/states/climb.rs | 20 +++--- common/src/comp/states/fall.rs | 51 +++++--------- common/src/comp/states/glide.rs | 36 +++++----- common/src/comp/states/idle.rs | 35 ++++++++++ common/src/comp/states/jump.rs | 14 ++-- common/src/comp/states/mod.rs | 45 ++++++------- common/src/comp/states/roll.rs | 37 ++++------ common/src/comp/states/run.rs | 79 +++++++--------------- common/src/comp/states/sit.rs | 53 ++++++--------- common/src/comp/states/stand.rs | 79 +++++++--------------- common/src/comp/states/swim.rs | 21 +++--- common/src/comp/states/wield.rs | 20 +++--- common/src/sys/agent.rs | 6 +- common/src/sys/character_state.rs | 10 +-- common/src/sys/movement.rs | 6 +- common/src/util/mod.rs | 19 ++++++ common/src/util/movement_utils.rs | 89 +++++++++++++++++++++++++ voxygen/src/audio/sfx/event_mapper.rs | 54 +++++++++------ 23 files changed, 454 insertions(+), 411 deletions(-) create mode 100644 common/src/comp/states/idle.rs create mode 100644 common/src/util/movement_utils.rs diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index b0e57ac12c..5f1896e4e3 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -10,7 +10,7 @@ use specs::{Component, Entity, FlaggedStorage, HashMapStorage, NullStorage}; use sphynx::Uid; use std::time::Duration; -pub struct EcsCharacterState<'a> { +pub struct EcsStateData<'a> { pub entity: &'a Entity, pub uid: &'a Uid, pub character: &'a CharacterState, @@ -27,7 +27,7 @@ pub struct EcsCharacterState<'a> { pub local_bus: &'a EventBus, } -pub struct EcsStateUpdate { +pub struct StateUpdate { pub character: CharacterState, pub pos: Pos, pub vel: Vel, @@ -36,52 +36,52 @@ pub struct EcsStateUpdate { #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum MoveState { - Stand(StandHandler), - Run(RunHandler), - Sit(SitHandler), - Jump(JumpHandler), - Fall(FallHandler), - Glide(GlideHandler), - Swim(SwimHandler), - Climb(ClimbHandler), + Stand(StandState), + Run(RunState), + Sit(SitState), + Jump(JumpState), + Fall(FallState), + Glide(GlideState), + Swim(SwimState), + Climb(ClimbState), } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum ActionState { - Idle, - Wield(WieldHandler), + Idle(IdleState), + Wield(WieldState), Attack(AttackKind), Block(BlockKind), Dodge(DodgeKind), - // Interact, + // Interact?, } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum AttackKind { - BasicAttack(BasicAttackHandler), - Charge(ChargeAttackHandler), + BasicAttack(BasicAttackState), + Charge(ChargeAttackState), } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum BlockKind { - BasicBlock(BasicBlockHandler), + BasicBlock(BasicBlockState), } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum DodgeKind { - Roll(RollHandler), + Roll(RollState), } impl ActionState { pub fn is_equip_finished(&self) -> bool { match self { - Wield(WieldHandler { equip_delay }) => *equip_delay == Duration::default(), + Wield(WieldState { equip_delay }) => *equip_delay == Duration::default(), _ => true, } } pub fn get_delay(&self) -> Duration { match self { - Wield(WieldHandler { equip_delay }) => *equip_delay, + Wield(WieldState { equip_delay }) => *equip_delay, _ => Duration::default(), } } @@ -115,7 +115,7 @@ impl ActionState { } } pub fn is_idling(&self) -> bool { - if let Idle = self { + if let Idle(_) = self { true } else { false @@ -125,22 +125,40 @@ impl ActionState { #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct CharacterState { + /// __How the character is currently moving, e.g. Running, Standing, Falling.__ + /// + /// _Primarily `handle()`s updating `Pos`, `Vel`, `Ori`, and lower body animations. + /// Can be overidden by `ActionState`s using `move_disabled` flag. Example: `ChargeAttackState`_ pub move_state: MoveState, + + /// __How the character is currently acting, e.g. Wielding, Attacking, Dodging.__ + /// + /// _Primarily `handle()`s how character interacts with world, and upper body animations. + /// Can be overidden by `MoveState`s using `action_disabled` flag. Example: `GlideState`_ pub action_state: ActionState, + + /// Used by `move_state` to disable `action_state` `handle()` calls. pub action_disabled: bool, + + /// Used by `action_state` to disable `move_state` `handle()` calls. pub move_disabled: bool, } impl CharacterState { + /// __Compares `move_state`s for shallow equality (does not check internal struct equality)__ pub fn is_same_move_state(&self, other: &Self) -> bool { // Check if state is the same without looking at the inner data std::mem::discriminant(&self.move_state) == std::mem::discriminant(&other.move_state) } + /// __Compares `action_state`s for shallow equality (does not check internal struct equality)__ pub fn is_same_action_state(&self, other: &Self) -> bool { // Check if state is the same without looking at the inner data std::mem::discriminant(&self.action_state) == std::mem::discriminant(&other.action_state) } + + /// __Compares both `move_state`s and `action_state`a for shallow equality + /// (does not check internal struct equality)__ pub fn is_same_state(&self, other: &Self) -> bool { self.is_same_move_state(other) && self.is_same_action_state(other) } @@ -149,8 +167,8 @@ impl CharacterState { impl Default for CharacterState { fn default() -> Self { Self { - move_state: MoveState::Fall(FallHandler), - action_state: ActionState::Idle, + move_state: MoveState::Fall(FallState), + action_state: ActionState::Idle(IdleState), action_disabled: false, move_disabled: false, } @@ -178,3 +196,21 @@ pub struct OverrideMove; impl Component for OverrideMove { type Storage = FlaggedStorage>; } + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub enum StartAction { + Primary, + Secondary, + Tertiary, + Four, + Five, +} +impl Default for StartAction { + fn default() -> Self { + Self::Primary + } +} + +impl Component for StartAction { + type Storage = FlaggedStorage>; +} diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index e1bca6cde3..cc446bd6b6 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -22,8 +22,8 @@ pub use body::{ quadruped_medium, quadruped_small, Body, }; pub use character_state::{ - ActionState, AttackKind, BlockKind, CharacterState, DodgeKind, EcsCharacterState, - EcsStateUpdate, MoveState, OverrideAction, OverrideMove, OverrideState, + ActionState, AttackKind, BlockKind, CharacterState, DodgeKind, EcsStateData, MoveState, + OverrideAction, OverrideMove, OverrideState, StateUpdate, }; pub use controller::{ ControlEvent, Controller, ControllerInputs, Input, InputState, InventoryManip, MountState, diff --git a/common/src/comp/states/basic_attack.rs b/common/src/comp/states/basic_attack.rs index 366e177b88..14ec2e2e30 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/comp/states/basic_attack.rs @@ -1,22 +1,18 @@ -use super::TEMP_EQUIP_DELAY; use crate::comp::{ - ActionState::{Attack, Idle, Wield}, - AttackKind::BasicAttack, - EcsCharacterState, EcsStateUpdate, - ItemKind::Tool, - StateHandle, WieldHandler, + ActionState::Attack, AttackKind::BasicAttack, EcsStateData, StateHandle, StateUpdate, }; +use crate::util::movement_utils::*; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct BasicAttackHandler { +pub struct BasicAttackState { /// How long the state has until exitting remaining_duration: Duration, } -impl StateHandle for BasicAttackHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for BasicAttackState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, @@ -26,21 +22,12 @@ impl StateHandle for BasicAttackHandler { // Check if attack duration has expired if self.remaining_duration == Duration::default() { // If so, go back to wielding or idling - update.character.action_state = if let Some(Tool { .. }) = - ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) - { - Wield(WieldHandler { - equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), - }) - } else { - Idle - }; - + update.character.action_state = attempt_wield(ecs_data.stats); return update; } // Otherwise, tick down remaining_duration, and keep rolling - update.character.action_state = Attack(BasicAttack(BasicAttackHandler { + update.character.action_state = Attack(BasicAttack(BasicAttackState { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs index 30d5ff4fe2..1ae98a683e 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/comp/states/basic_block.rs @@ -1,22 +1,18 @@ -use super::{BLOCK_ACCEL, BLOCK_SPEED, TEMP_EQUIP_DELAY}; -use crate::comp::{ - ActionState::{Idle, Wield}, - EcsCharacterState, EcsStateUpdate, - ItemKind::Tool, - StateHandle, WieldHandler, -}; +use super::{BLOCK_ACCEL, BLOCK_SPEED}; +use crate::comp::{EcsStateData, StateHandle, StateUpdate}; +use crate::util::movement_utils::*; use std::time::Duration; use vek::Vec2; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct BasicBlockHandler { +pub struct BasicBlockState { /// How long the blocking state has been active active_duration: Duration, } -impl StateHandle for BasicBlockHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for BasicBlockState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, @@ -24,6 +20,7 @@ impl StateHandle for BasicBlockHandler { }; // TODO: Apply simple move speed debuff instead + update.character.move_disabled = true; // Update movement update.vel.0 += Vec2::broadcast(ecs_data.dt.0) @@ -34,16 +31,7 @@ impl StateHandle for BasicBlockHandler { }; if !ecs_data.inputs.secondary.is_pressed() { - update.character.action_state = if let Some(Tool { .. }) = - ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) - { - Wield(WieldHandler { - equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), - }) - } else { - Idle - }; - + update.character.action_state = attempt_wield(ecs_data.stats); update.character.move_disabled = false; return update; } diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs index d80ffad2e5..fbfb9e93ef 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/comp/states/charge_attack.rs @@ -1,26 +1,23 @@ use crate::comp::{ - ActionState::{Attack, Idle, Wield}, - AttackKind::Charge, - EcsCharacterState, EcsStateUpdate, HealthChange, HealthSource, - ItemKind::Tool, - MoveState::Run, - RunHandler, StateHandle, WieldHandler, + ActionState::Attack, AttackKind::Charge, EcsStateData, HealthChange, HealthSource, + MoveState::Run, RunState, StateHandle, StateUpdate, }; use crate::event::ServerEvent; +use crate::util::movement_utils::*; use std::time::Duration; use vek::Vec3; -use super::{CHARGE_SPEED, TEMP_EQUIP_DELAY}; +use super::CHARGE_SPEED; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct ChargeAttackHandler { +pub struct ChargeAttackState { /// How long the state has until exitting pub remaining_duration: Duration, } -impl StateHandle for ChargeAttackHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for ChargeAttackState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, @@ -30,8 +27,7 @@ impl StateHandle for ChargeAttackHandler { // Prevent move state handling, handled here // ecs_data.updater.insert(*ecs_data.entity, OverrideMove); update.character.action_disabled = true; - - update.character.move_state = Run(RunHandler); + update.character.move_state = Run(RunState); // Move player update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) @@ -57,17 +53,8 @@ impl StateHandle for ChargeAttackHandler { }, }); - // Go back to wielding - update.character.action_state = if let Some(Tool { .. }) = - ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) - { - Wield(WieldHandler { - equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), - }) - } else { - Idle - }; - + // Go back to wielding or idling + update.character.action_state = attempt_wield(ecs_data.stats); update.character.move_disabled = false; return update; } @@ -75,22 +62,13 @@ impl StateHandle for ChargeAttackHandler { // Check if charge timed out or can't keep moving forward if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 { - update.character.action_state = if let Some(Tool { .. }) = - ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) - { - Wield(WieldHandler { - equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), - }) - } else { - Idle - }; - + update.character.action_state = attempt_wield(ecs_data.stats); update.character.move_disabled = false; return update; } // Tick remaining-duration and keep charging - update.character.action_state = Attack(Charge(ChargeAttackHandler { + update.character.action_state = Attack(Charge(ChargeAttackState { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) diff --git a/common/src/comp/states/climb.rs b/common/src/comp/states/climb.rs index e7ad8d55c9..6f13212c9c 100644 --- a/common/src/comp/states/climb.rs +++ b/common/src/comp/states/climb.rs @@ -1,6 +1,6 @@ use super::{ - ActionState::*, EcsCharacterState, EcsStateUpdate, FallHandler, JumpHandler, MoveState::*, - StandHandler, StateHandle, + ActionState::*, EcsStateData, FallState, IdleState, JumpState, MoveState::*, StandState, + StateHandle, StateUpdate, }; use super::{CLIMB_SPEED, HUMANOID_CLIMB_ACCEL, HUMANOID_SPEED}; use crate::sys::phys::GRAVITY; @@ -8,11 +8,11 @@ use vek::vec::{Vec2, Vec3}; use vek::Lerp; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct ClimbHandler; +pub struct ClimbState; -impl StateHandle for ClimbHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for ClimbState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, @@ -20,7 +20,7 @@ impl StateHandle for ClimbHandler { }; // Disable actions in this state - update.character.action_state = Idle; + update.character.action_state = Idle(IdleState); update.character.action_disabled = true; // Move player @@ -80,13 +80,13 @@ impl StateHandle for ClimbHandler { if let None = ecs_data.physics.on_wall { if ecs_data.inputs.jump.is_pressed() { // They've climbed atop something, give them a boost - update.character.move_state = Jump(JumpHandler); + update.character.move_state = Jump(JumpState); update.character.action_disabled = false; return update; } else { // Just fall off - update.character.move_state = Fall(FallHandler); + update.character.move_state = Fall(FallState); update.character.action_disabled = false; return update; @@ -95,7 +95,7 @@ impl StateHandle for ClimbHandler { // Remove climb state on ground, otherwise character will get stuck if ecs_data.physics.on_ground { - update.character.move_state = Stand(StandHandler); + update.character.move_state = Stand(StandState); update.character.action_disabled = false; return update; } diff --git a/common/src/comp/states/fall.rs b/common/src/comp/states/fall.rs index c140bea677..78b68cc7f7 100644 --- a/common/src/comp/states/fall.rs +++ b/common/src/comp/states/fall.rs @@ -1,16 +1,15 @@ -use super::{ - EcsCharacterState, EcsStateUpdate, GlideHandler, MoveState::*, RunHandler, StandHandler, - StateHandle, SwimHandler, -}; use super::{HUMANOID_AIR_ACCEL, HUMANOID_AIR_SPEED}; +use crate::comp::{ClimbState, EcsStateData, GlideState, MoveState::*, StateHandle, StateUpdate}; + +use crate::util::movement_utils::*; use vek::{Vec2, Vec3}; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct FallHandler; +pub struct FallState; -impl StateHandle for FallHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for FallState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, @@ -43,36 +42,22 @@ impl StateHandle for FallHandler { vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 2.0 * ecs_data.dt.0); } + // Check to start climbing + if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { + update.character.move_state = Climb(ClimbState); + return update; + } + // Check gliding if ecs_data.inputs.glide.is_pressed() { - update.character.move_state = Glide(GlideHandler); - + update.character.move_state = Glide(GlideState); return update; } - // Not on ground, go to swim or fall - if !ecs_data.physics.on_ground { - // Check if in fluid to go to swimming or back to falling - if ecs_data.physics.in_fluid { - update.character.move_state = Swim(SwimHandler); + // Else update based on groundedness + update.character.move_state = + determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); - return update; - } else { - update.character.move_state = Fall(FallHandler); - - return update; - } - } - // On ground - else { - // Return to running or standing based on move inputs - update.character.move_state = if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - Run(RunHandler) - } else { - Stand(StandHandler) - }; - - return update; - } + return update; } } diff --git a/common/src/comp/states/glide.rs b/common/src/comp/states/glide.rs index d709ced47e..f84ca53d5d 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/comp/states/glide.rs @@ -1,16 +1,16 @@ -use super::{ - ActionState::*, ClimbHandler, EcsCharacterState, EcsStateUpdate, FallHandler, MoveState::*, - StandHandler, StateHandle, -}; use super::{GLIDE_ACCEL, GLIDE_ANTIGRAV, GLIDE_SPEED}; +use crate::comp::{ + ActionState::*, ClimbState, EcsStateData, FallState, IdleState, MoveState::*, StandState, + StateHandle, StateUpdate, +}; use vek::{Vec2, Vec3}; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct GlideHandler; +pub struct GlideState; -impl StateHandle for GlideHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for GlideState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, @@ -20,8 +20,9 @@ impl StateHandle for GlideHandler { // Prevent action in this state, set here update.character.action_disabled = true; - update.character.action_state = Idle; - update.character.move_state = Glide(GlideHandler); + // Defaults for this state + update.character.action_state = Idle(IdleState); + update.character.move_state = Glide(GlideState); // Move player according to movement direction vector update.vel.0 += Vec2::broadcast(ecs_data.dt.0) @@ -54,22 +55,21 @@ impl StateHandle for GlideHandler { .max(0.2); } - // If glide button isn't held + // If glide button isn't held, start falling if !ecs_data.inputs.glide.is_pressed() { - update.character.move_state = Fall(FallHandler); - + update.character.move_state = Fall(FallState); return update; } + // If there is a wall in front of character go to climb - else if let Some(_wall_dir) = ecs_data.physics.on_wall { - update.character.move_state = Climb(ClimbHandler); - + if let Some(_wall_dir) = ecs_data.physics.on_wall { + update.character.move_state = Climb(ClimbState); return update; } + // If on ground go to stand if ecs_data.physics.on_ground { - update.character.move_state = Stand(StandHandler); - + update.character.move_state = Stand(StandState); return update; } diff --git a/common/src/comp/states/idle.rs b/common/src/comp/states/idle.rs new file mode 100644 index 0000000000..9f1c4aa352 --- /dev/null +++ b/common/src/comp/states/idle.rs @@ -0,0 +1,35 @@ +use super::TEMP_EQUIP_DELAY; +use crate::comp::{ + ActionState::Wield, EcsStateData, ItemKind::Tool, StateHandle, StateUpdate, WieldState, +}; +use std::time::Duration; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct IdleState; + +impl StateHandle for IdleState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + }; + + // Try to wield + if ecs_data.inputs.toggle_wield.is_pressed() + || ecs_data.inputs.primary.is_pressed() + || ecs_data.inputs.secondary.is_pressed() + { + if let Some(Tool { .. }) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + update.character.action_state = Wield(WieldState { + equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), + }) + } + + // else unarmed stuff? + } + + return update; + } +} diff --git a/common/src/comp/states/jump.rs b/common/src/comp/states/jump.rs index 5794ee78c1..e3af3f9253 100644 --- a/common/src/comp/states/jump.rs +++ b/common/src/comp/states/jump.rs @@ -1,12 +1,12 @@ -use super::{EcsCharacterState, EcsStateUpdate, FallHandler, MoveState::*, StateHandle}; +use super::{EcsStateData, FallState, MoveState::*, StateHandle, StateUpdate}; use crate::event::LocalEvent; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct JumpHandler; +pub struct JumpState; -impl StateHandle for JumpHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for JumpState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -18,8 +18,8 @@ impl StateHandle for JumpHandler { .emitter() .emit(LocalEvent::Jump(*ecs_data.entity)); - update.character.move_state = Fall(FallHandler); - + // Immediately go to falling state after jump impulse + update.character.move_state = Fall(FallState); return update; } } diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index dff9ec53ae..e26e30df80 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -5,6 +5,7 @@ mod charge_attack; mod climb; mod fall; mod glide; +mod idle; mod jump; mod roll; mod run; @@ -20,6 +21,7 @@ pub use charge_attack::*; pub use climb::*; pub use fall::*; pub use glide::*; +pub use idle::*; pub use jump::*; pub use roll::*; pub use run::*; @@ -50,35 +52,30 @@ pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; // Public interface, wires character states to their handlers. use super::{ - ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsCharacterState, - EcsStateUpdate, MoveState, MoveState::*, + ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData, + MoveState, MoveState::*, StateUpdate, }; pub trait StateHandle { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate; + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate; } impl StateHandle for ActionState { /// Passes handle to variant or subvariant handlers - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { match self { Attack(kind) => match kind { - BasicAttack(handler) => handler.handle(ecs_data), - Charge(handler) => handler.handle(ecs_data), + BasicAttack(state) => state.handle(ecs_data), + Charge(state) => state.handle(ecs_data), }, Block(kind) => match kind { - BasicBlock(handler) => handler.handle(ecs_data), + BasicBlock(state) => state.handle(ecs_data), }, Dodge(kind) => match kind { - Roll(handler) => handler.handle(ecs_data), - }, - Wield(handler) => handler.handle(ecs_data), - Idle => EcsStateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, + Roll(state) => state.handle(ecs_data), }, + Wield(state) => state.handle(ecs_data), + Idle(state) => state.handle(ecs_data), // All states should be explicitly handled // Do not use default match: _ => {}, } @@ -87,16 +84,16 @@ impl StateHandle for ActionState { impl StateHandle for MoveState { /// Passes handle to variant handlers - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { match self { - Stand(handler) => handler.handle(&ecs_data), - Run(handler) => handler.handle(&ecs_data), - Jump(handler) => handler.handle(&ecs_data), - Climb(handler) => handler.handle(&ecs_data), - Glide(handler) => handler.handle(&ecs_data), - Swim(handler) => handler.handle(&ecs_data), - Fall(handler) => handler.handle(&ecs_data), - Sit(handler) => handler.handle(&ecs_data), + Stand(state) => state.handle(&ecs_data), + Run(state) => state.handle(&ecs_data), + Jump(state) => state.handle(&ecs_data), + Climb(state) => state.handle(&ecs_data), + Glide(state) => state.handle(&ecs_data), + Swim(state) => state.handle(&ecs_data), + Fall(state) => state.handle(&ecs_data), + Sit(state) => state.handle(&ecs_data), // All states should be explicitly handled // Do not use default match: _ => {}, } diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index fb7285759e..accae700c7 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -1,19 +1,18 @@ -use super::{ROLL_SPEED, TEMP_EQUIP_DELAY}; -use crate::comp::{ - ActionState::*, DodgeKind::*, EcsCharacterState, EcsStateUpdate, ItemKind::Tool, OverrideMove, - StateHandle, WieldHandler, -}; +use super::ROLL_SPEED; +use crate::comp::{ActionState::*, DodgeKind::*, EcsStateData, StateHandle, StateUpdate}; +use crate::util::movement_utils::*; use std::time::Duration; use vek::Vec3; + #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct RollHandler { +pub struct RollState { /// How long the state has until exitting remaining_duration: Duration, } -impl StateHandle for RollHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for RollState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -21,7 +20,7 @@ impl StateHandle for RollHandler { }; // Prevent move state handling, handled here - ecs_data.updater.insert(*ecs_data.entity, OverrideMove); + update.character.move_disabled = true; // Update velocity update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) @@ -39,28 +38,20 @@ impl StateHandle for RollHandler { // Check if roll duration has expired if self.remaining_duration == Duration::default() { // If so, go back to wielding or idling - update.character.action_state = if let Some(Tool { .. }) = - ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) - { - Wield(WieldHandler { - equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), - }) - } else { - Idle - }; - - ecs_data.updater.remove::(*ecs_data.entity); + update.character.action_state = attempt_wield(ecs_data.stats); + update.character.move_disabled = false; return update; } - // Otherwise, tick down remaining_duration, and keep rolling - update.character.action_state = Dodge(Roll(RollHandler { + // Otherwise, tick down remaining_duration + update.character.action_state = Dodge(Roll(RollState { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) .unwrap_or_default(), })); + // Keep rolling return update; } } diff --git a/common/src/comp/states/run.rs b/common/src/comp/states/run.rs index c6ef09d711..bc59b7f472 100644 --- a/common/src/comp/states/run.rs +++ b/common/src/comp/states/run.rs @@ -1,16 +1,17 @@ -use super::{ - ClimbHandler, EcsCharacterState, EcsStateUpdate, FallHandler, GlideHandler, JumpHandler, - MoveState::*, SitHandler, StandHandler, StateHandle, SwimHandler, -}; use super::{HUMANOID_ACCEL, HUMANOID_SPEED}; +use crate::comp::{ + ClimbState, EcsStateData, GlideState, JumpState, MoveState::*, SitState, StateHandle, + StateUpdate, +}; +use crate::util::movement_utils::*; use vek::vec::{Vec2, Vec3}; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct RunHandler; +pub struct RunState; -impl StateHandle for RunHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for RunState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -44,67 +45,33 @@ impl StateHandle for RunHandler { } // Try to sit - if ecs_data.inputs.sit.is_pressed() - && ecs_data.physics.on_ground - && ecs_data.body.is_humanoid() - { - update.character.move_state = Sit(SitHandler); - + if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { + update.character.move_state = Sit(SitState); return update; } // Try to climb - if let (true, Some(_wall_dir)) = ( - ecs_data.inputs.climb.is_pressed() | ecs_data.inputs.climb_down.is_pressed() - && ecs_data.body.is_humanoid(), - ecs_data.physics.on_wall, - ) { - update.character.move_state = Climb(ClimbHandler); - + if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { + update.character.move_state = Climb(ClimbState); return update; } - // Try to swim - if !ecs_data.physics.on_ground && ecs_data.physics.in_fluid { - update.character.move_state = Swim(SwimHandler); - + // Try to jump + if can_jump(ecs_data.physics, ecs_data.inputs) { + update.character.move_state = Jump(JumpState); return update; } - // While on ground ... - if ecs_data.physics.on_ground { - // Try to jump - if ecs_data.inputs.jump.is_pressed() && !ecs_data.inputs.jump.is_held_down() { - update.character.move_state = Jump(JumpHandler); - - return update; - } - } - // While not on ground ... - else { - // Try to glide - if ecs_data.physics.on_wall == None - && ecs_data.inputs.glide.is_pressed() - && !ecs_data.inputs.glide.is_held_down() - && ecs_data.body.is_humanoid() - { - update.character.move_state = Glide(GlideHandler); - - return update; - } - update.character.move_state = Fall(FallHandler); - + // Try to glide + if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { + update.character.move_state = Glide(GlideState); return update; } - if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - update.character.move_state = Run(RunHandler); + // Update based on groundedness + update.character.move_state = + determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); - return update; - } else { - update.character.move_state = Stand(StandHandler); - - return update; - } + return update; } } diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs index 046acc405e..33de69af82 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/comp/states/sit.rs @@ -1,13 +1,15 @@ use crate::comp::{ - ActionState::*, EcsCharacterState, EcsStateUpdate, FallHandler, JumpHandler, MoveState::*, - RunHandler, StandHandler, StateHandle, SwimHandler, + ActionState::*, EcsStateData, IdleState, JumpState, MoveState::*, RunState, StandState, + StateHandle, StateUpdate, }; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct SitHandler; +use crate::util::movement_utils::*; -impl StateHandle for SitHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct SitState; + +impl StateHandle for SitState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -16,46 +18,35 @@ impl StateHandle for SitHandler { // Prevent action state handling update.character.action_disabled = true; - update.character.action_state = Idle; - update.character.move_state = Sit(SitHandler); + update.character.action_state = Idle(IdleState); + update.character.move_state = Sit(SitState); - // Falling - // Idk, maybe the ground disappears, + // Try to Fall + // ... maybe the ground disappears, // suddenly maybe a water spell appears. // Can't hurt to be safe :shrug: if !ecs_data.physics.on_ground { - if ecs_data.physics.in_fluid { - update.character.move_state = Swim(SwimHandler); - - update.character.action_disabled = false; - return update; - } else { - update.character.move_state = Fall(FallHandler); - - update.character.action_disabled = false; - return update; - } + update.character.move_state = determine_fall_or_swim(ecs_data.physics); + update.character.move_disabled = false; + return update; } - // Jumping + // Try to jump if ecs_data.inputs.jump.is_pressed() { - update.character.move_state = Jump(JumpHandler); - + update.character.move_state = Jump(JumpState); update.character.action_disabled = false; return update; } - // Moving + // Try to Run if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - update.character.move_state = Run(RunHandler); - + update.character.move_state = Run(RunState); update.character.action_disabled = false; return update; } - // Standing back up (unsitting) + // Try to Stand if ecs_data.inputs.sit.is_just_pressed() { - update.character.move_state = Stand(StandHandler); - + update.character.move_state = Stand(StandState); update.character.action_disabled = false; return update; } diff --git a/common/src/comp/states/stand.rs b/common/src/comp/states/stand.rs index b4d1402052..dc16d73af2 100644 --- a/common/src/comp/states/stand.rs +++ b/common/src/comp/states/stand.rs @@ -1,13 +1,15 @@ -use super::{ - ClimbHandler, EcsCharacterState, EcsStateUpdate, FallHandler, GlideHandler, JumpHandler, - MoveState::*, RunHandler, SitHandler, StateHandle, SwimHandler, +use crate::comp::{ + ClimbState, EcsStateData, GlideState, JumpState, MoveState::*, SitState, StateHandle, + StateUpdate, }; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct StandHandler; +use crate::util::movement_utils::*; -impl StateHandle for StandHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct StandState; + +impl StateHandle for StandState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -15,66 +17,33 @@ impl StateHandle for StandHandler { }; // Try to sit - if ecs_data.inputs.sit.is_pressed() - && ecs_data.physics.on_ground - && ecs_data.body.is_humanoid() - { - update.character.move_state = Sit(SitHandler); - + if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { + update.character.move_state = Sit(SitState); return update; } // Try to climb - if let (true, Some(_wall_dir)) = ( - ecs_data.inputs.climb.is_pressed() | ecs_data.inputs.climb_down.is_pressed() - && ecs_data.body.is_humanoid(), - ecs_data.physics.on_wall, - ) { - update.character.move_state = Climb(ClimbHandler); - + if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { + update.character.move_state = Climb(ClimbState); return update; } - // Try to swim - if !ecs_data.physics.on_ground && ecs_data.physics.in_fluid { - update.character.move_state = Swim(SwimHandler); - + // Try to jump + if can_jump(ecs_data.physics, ecs_data.inputs) { + update.character.move_state = Jump(JumpState); return update; } - // While on ground ... - if ecs_data.physics.on_ground { - // Try to jump - if ecs_data.inputs.jump.is_pressed() { - update.character.move_state = Jump(JumpHandler); - - return update; - } - } - // While not on ground ... - else { - // Try to glide - if ecs_data.physics.on_wall == None - && ecs_data.inputs.glide.is_pressed() - && ecs_data.body.is_humanoid() - { - update.character.move_state = Glide(GlideHandler); - - return update; - } - update.character.move_state = Fall(FallHandler); - + // Check gliding + if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { + update.character.move_state = Glide(GlideState); return update; } - if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - update.character.move_state = Run(RunHandler); + // Else update based on groundedness + update.character.move_state = + determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); - return update; - } else { - update.character.move_state = Stand(StandHandler); - - return update; - } + return update; } } diff --git a/common/src/comp/states/swim.rs b/common/src/comp/states/swim.rs index 4595e5f78d..ffaf1b2673 100644 --- a/common/src/comp/states/swim.rs +++ b/common/src/comp/states/swim.rs @@ -1,16 +1,14 @@ -use super::{ - EcsCharacterState, EcsStateUpdate, MoveState::*, RunHandler, StandHandler, StateHandle, -}; use super::{HUMANOID_WATER_ACCEL, HUMANOID_WATER_SPEED}; +use crate::comp::{EcsStateData, MoveState::*, RunState, StandState, StateHandle, StateUpdate}; use crate::sys::phys::GRAVITY; use vek::{Vec2, Vec3}; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct SwimHandler; +pub struct SwimState; -impl StateHandle for SwimHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for SwimState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -46,24 +44,23 @@ impl StateHandle for SwimHandler { ); } - if ecs_data.inputs.jump.is_pressed() { + if ecs_data.inputs.jump.is_pressed() && !ecs_data.inputs.jump.is_held_down() { update.vel.0.z = (update.vel.0.z + ecs_data.dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); } // Not on ground if !ecs_data.physics.on_ground { - update.character.move_state = Swim(SwimHandler); - + update.character.move_state = Swim(SwimState); return update; } // On ground else { // Return to running or standing based on move inputs update.character.move_state = if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - Run(RunHandler) + Run(RunState) } else { - Stand(StandHandler) + Stand(StandState) }; return update; diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index ebc5b64a29..2f1422c37f 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -1,16 +1,16 @@ -use super::{ActionState::*, EcsCharacterState, EcsStateUpdate, StateHandle}; +use crate::comp::{ActionState::*, EcsStateData, IdleState, StateHandle, StateUpdate}; use std::time::Duration; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct WieldHandler { +pub struct WieldState { /// How long before a new action can be performed /// after equipping pub equip_delay: Duration, } -impl StateHandle for WieldHandler { - fn handle(&self, ecs_data: &EcsCharacterState) -> EcsStateUpdate { - let mut update = EcsStateUpdate { +impl StateHandle for WieldState { + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -23,8 +23,7 @@ impl StateHandle for WieldHandler { if ecs_data.inputs.toggle_wield.is_pressed() && ecs_data.character.action_state.is_equip_finished() { - update.character.action_state = Idle; - + update.character.action_state = Idle(IdleState); return update; } @@ -34,11 +33,10 @@ impl StateHandle for WieldHandler { } else if ecs_data.inputs.secondary.is_pressed() { // TODO: SecondaryStart } - } - // Equip delay hasn't expired yet - else { + } else { + // Equip delay hasn't expired yet // Update wield delay - update.character.action_state = Wield(WieldHandler { + update.character.action_state = Wield(WieldState { equip_delay: self .equip_delay .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index bf14498cc4..52b1f1e149 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -1,6 +1,6 @@ use crate::comp::{ - Agent, CharacterState, Controller, ControllerInputs, GlideHandler, MountState, - MoveState::Glide, Pos, Stats, + Agent, CharacterState, Controller, ControllerInputs, GlideState, MountState, MoveState::Glide, + Pos, Stats, }; use crate::pathfinding::WorldPath; use crate::terrain::TerrainGrid; @@ -163,7 +163,7 @@ impl<'a> System<'a> for Sys { inputs.roll.set_state(true); } - if target_character.move_state == Glide(GlideHandler) + if target_character.move_state == Glide(GlideState) && target_pos.0.z > pos.0.z + 5.0 { inputs.glide.set_state(true); diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 65138ce500..9bf8c48241 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - Body, CharacterState, Controller, EcsCharacterState, Mounting, MoveState::*, Ori, - OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, SitHandler, StateHandle, + Body, CharacterState, Controller, EcsStateData, Mounting, MoveState::*, Ori, + OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, SitState, StateHandle, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, @@ -110,13 +110,13 @@ impl<'a> System<'a> for Sys { // If mounted, character state is controlled by mount // TODO: Make mounting a state if maybe_mount.is_some() { - character.move_state = Sit(SitHandler); + character.move_state = Sit(SitState); continue; } // Determine new move state if can move if !maybe_move_override.is_some() && !character.move_disabled { - let state_update = character.move_state.handle(&EcsCharacterState { + let state_update = character.move_state.handle(&EcsStateData { entity: &entity, uid, character, @@ -141,7 +141,7 @@ impl<'a> System<'a> for Sys { // Determine new action if can_act if !maybe_action_override.is_some() && !character.action_disabled { - let state_update = character.action_state.handle(&EcsCharacterState { + let state_update = character.action_state.handle(&EcsStateData { entity: &entity, uid, character, diff --git a/common/src/sys/movement.rs b/common/src/sys/movement.rs index 7a64a996f4..9b8da17f1b 100644 --- a/common/src/sys/movement.rs +++ b/common/src/sys/movement.rs @@ -1,8 +1,8 @@ use super::phys::GRAVITY; use crate::{ comp::{ - CharacterState, Controller, Mounting, MoveState::*, Ori, PhysicsState, Pos, RunHandler, - StandHandler, Stats, Vel, + CharacterState, Controller, Mounting, MoveState::*, Ori, PhysicsState, Pos, RunState, + StandState, Stats, Vel, }, event::{EventBus, ServerEvent}, state::DeltaTime, @@ -106,7 +106,7 @@ impl<'a> System<'a> for Sys { ) .join() { - // if character.movement == Run(RunHandler) || character.movement == Stand(StandHandler) { + // if character.movement == Run(RunState) || character.movement == Stand(StandState) { // continue; // } diff --git a/common/src/util/mod.rs b/common/src/util/mod.rs index 7ccb111fd9..37ce1a120a 100644 --- a/common/src/util/mod.rs +++ b/common/src/util/mod.rs @@ -7,6 +7,9 @@ lazy_static::lazy_static! { use vek::{Mat3, Rgb, Rgba, Vec3}; +pub mod movement_utils; + +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. /// This is a fast approximation of powf. This should only be used when minor accuracy loss is acceptable. #[inline(always)] #[allow(unsafe_code)] @@ -40,6 +43,7 @@ mod approx_powf_tests { } } +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. #[inline(always)] pub fn srgb_to_linear(col: Rgb) -> Rgb { #[inline(always)] @@ -52,6 +56,8 @@ pub fn srgb_to_linear(col: Rgb) -> Rgb { } col.map(to_linear) } + +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. #[inline(always)] pub fn linear_to_srgb(col: Rgb) -> Rgb { #[inline(always)] @@ -64,15 +70,20 @@ pub fn linear_to_srgb(col: Rgb) -> Rgb { } col.map(to_srgb) } + +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. #[inline(always)] pub fn srgba_to_linear(col: Rgba) -> Rgba { Rgba::from_translucent(srgb_to_linear(Rgb::from(col)), col.a) } + +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. #[inline(always)] pub fn linear_to_srgba(col: Rgba) -> Rgba { Rgba::from_translucent(linear_to_srgb(Rgb::from(col)), col.a) } +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. /// Convert rgb to hsv. Expects rgb to be [0, 1]. #[inline(always)] pub fn rgb_to_hsv(rgb: Rgb) -> Vec3 { @@ -104,6 +115,8 @@ pub fn rgb_to_hsv(rgb: Rgb) -> Vec3 { Vec3::new(h, s, v) } + +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. /// Convert hsv to rgb. Expects h [0, 360], s [0, 1], v [0, 1] #[inline(always)] pub fn hsv_to_rgb(hsv: Vec3) -> Rgb { @@ -129,6 +142,8 @@ pub fn hsv_to_rgb(hsv: Vec3) -> Rgb { Rgb::new(r + m, g + m, b + m) } + +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. /// Convert linear rgb to CIExyY #[inline(always)] pub fn rgb_to_xyy(rgb: Rgb) -> Vec3 { @@ -140,6 +155,8 @@ pub fn rgb_to_xyy(rgb: Rgb) -> Vec3 { let sum = xyz.sum(); Vec3::new(xyz.x / sum, xyz.y / sum, xyz.y) } + +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. /// Convert to CIExyY to linear rgb #[inline(always)] pub fn xyy_to_rgb(xyy: Vec3) -> Rgb { @@ -156,6 +173,7 @@ pub fn xyy_to_rgb(xyy: Vec3) -> Rgb { ) } +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. // TO-DO: speed this up #[inline(always)] pub fn saturate_srgb(col: Rgb, value: f32) -> Rgb { @@ -164,6 +182,7 @@ pub fn saturate_srgb(col: Rgb, value: f32) -> Rgb { linear_to_srgb(hsv_to_rgb(hsv).map(|e| e.min(1.0).max(0.0))) } +/// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. /// Preserves the luma of one color while changing its chromaticty to match the other #[inline(always)] pub fn chromify_srgb(luma: Rgb, chroma: Rgb) -> Rgb { diff --git a/common/src/util/movement_utils.rs b/common/src/util/movement_utils.rs new file mode 100644 index 0000000000..38d8cb7903 --- /dev/null +++ b/common/src/util/movement_utils.rs @@ -0,0 +1,89 @@ +use crate::comp::TEMP_EQUIP_DELAY; +use crate::comp::{ + ActionState, ActionState::*, Body, ControllerInputs, FallState, IdleState, ItemKind::Tool, + MoveState, MoveState::*, PhysicsState, RunState, StandState, Stats, SwimState, WieldState, +}; +use std::time::Duration; + +/// __Returns a `MoveState` based on `in_fluid` condition__ +pub fn determine_fall_or_swim(physics: &PhysicsState) -> MoveState { + // Check if in fluid to go to swimming or back to falling + if physics.in_fluid { + Swim(SwimState) + } else { + Fall(FallState) + } +} +/// __Returns a `MoveState` based on `move_dir` magnitude__ +pub fn determine_stand_or_run(inputs: &ControllerInputs) -> MoveState { + // Return to running or standing based on move inputs + if inputs.move_dir.magnitude_squared() > 0.0 { + Run(RunState) + } else { + Stand(StandState) + } +} + +/// __Returns a `MoveState` based on `on_ground` state.__ +/// +/// _`FallState`, or `SwimState` if not `on_ground`, +/// `StandState` or `RunState` if is `on_ground`_ +pub fn determine_move_from_grounded_state( + physics: &PhysicsState, + inputs: &ControllerInputs, +) -> MoveState { + // Not on ground, go to swim or fall + if !physics.on_ground { + determine_fall_or_swim(physics) + } + // On ground + else { + determine_stand_or_run(inputs) + } +} + +/// __Returns an ActionState based on whether character has a weapon equipped.__ +pub fn attempt_wield(stats: &Stats) -> ActionState { + if let Some(Tool { .. }) = stats.equipment.main.as_ref().map(|i| &i.kind) { + Wield(WieldState { + equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), + }) + } else { + Idle(IdleState) + } +} + +pub fn can_climb(physics: &PhysicsState, inputs: &ControllerInputs, body: &Body) -> bool { + if let (true, Some(_wall_dir)) = ( + inputs.climb.is_pressed() | inputs.climb_down.is_pressed() && body.is_humanoid(), + physics.on_wall, + ) { + true + } else { + false + } +} + +pub fn can_glide(physics: &PhysicsState, inputs: &ControllerInputs, body: &Body) -> bool { + if inputs.glide.is_pressed() && body.is_humanoid() && physics.on_wall == None { + true + } else { + false + } +} + +pub fn can_sit(physics: &PhysicsState, inputs: &ControllerInputs, body: &Body) -> bool { + if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { + true + } else { + false + } +} + +pub fn can_jump(physics: &PhysicsState, inputs: &ControllerInputs) -> bool { + if physics.on_ground && inputs.jump.is_pressed() { + true + } else { + false + } +} diff --git a/voxygen/src/audio/sfx/event_mapper.rs b/voxygen/src/audio/sfx/event_mapper.rs index 3a3eefcd68..311b8fbb1a 100644 --- a/voxygen/src/audio/sfx/event_mapper.rs +++ b/voxygen/src/audio/sfx/event_mapper.rs @@ -5,9 +5,9 @@ use crate::audio::sfx::{SfxTriggerItem, SfxTriggers}; use client::Client; use common::{ comp::{ - ActionState, AttackKind::*, BasicAttackHandler, Body, CharacterState, DodgeKind::*, - FallHandler, GlideHandler, ItemKind, MoveState, Pos, RollHandler, RunHandler, StandHandler, - Stats, + ActionState, AttackKind::*, BasicAttackState, Body, CharacterState, DodgeKind::*, + FallState, GlideState, IdleState, ItemKind, MoveState, Pos, RollState, RunState, + StandState, Stats, }, event::{EventBus, SfxEvent, SfxEventItem}, }; @@ -277,8 +277,10 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Stand(StandHandler), - action_state: ActionState::Idle, + move_state: MoveState::Stand(StandState), + action_state: ActionState::Idle(IdleState), + action_disabled: false, + move_disabled: false, }, SfxEvent::Idle, &stats, @@ -293,8 +295,10 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Run(RunHandler), - action_state: ActionState::Idle, + move_state: MoveState::Run(RunState), + action_state: ActionState::Idle(IdleState), + action_disabled: false, + move_disabled: false, }, SfxEvent::Idle, &stats, @@ -309,8 +313,10 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - action_state: ActionState::Dodge(Roll(RollHandler::default())), - move_state: MoveState::Run(RunHandler), + action_state: ActionState::Dodge(Roll(RollState::default())), + move_state: MoveState::Run(RunState), + action_disabled: false, + move_disabled: true, }, SfxEvent::Run, &stats, @@ -325,8 +331,10 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Fall(FallHandler), - action_state: ActionState::Idle, + move_state: MoveState::Fall(FallState), + action_state: ActionState::Idle(IdleState), + action_disabled: false, + move_disabled: false, }, SfxEvent::Idle, &stats, @@ -341,8 +349,10 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Glide(GlideHandler), - action_state: ActionState::Idle, + move_state: MoveState::Glide(GlideState), + action_state: ActionState::Idle(IdleState), + action_disabled: true, + move_disabled: false, }, SfxEvent::Jump, &stats, @@ -357,8 +367,10 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Glide(GlideHandler), - action_state: ActionState::Idle, + move_state: MoveState::Glide(GlideState), + action_state: ActionState::Idle(IdleState), + action_disabled: true, + move_disabled: false, }, SfxEvent::Glide, &stats, @@ -373,8 +385,10 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Fall(FallHandler), - action_state: ActionState::Idle, + move_state: MoveState::Fall(FallState), + action_state: ActionState::Idle(IdleState), + move_disabled: false, + action_disabled: false, }, SfxEvent::Glide, &stats, @@ -394,8 +408,10 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Stand(StandHandler), - action_state: ActionState::Attack(BasicAttack(BasicAttackHandler::default())), + move_state: MoveState::Stand(StandState), + action_state: ActionState::Attack(BasicAttack(BasicAttackState::default())), + move_disabled: false, + action_disabled: false, }, SfxEvent::Idle, &stats, From 7a4cdfb7a47c29cb0496a778d2f0bdfba4461489 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sun, 29 Dec 2019 08:36:59 -0800 Subject: [PATCH 008/326] Documentation comments --- common/src/comp/character_state.rs | 23 +--- common/src/comp/states/idle.rs | 5 +- common/src/comp/states/mod.rs | 18 ++- common/src/comp/states/wield.rs | 2 +- common/src/sys/character_state.rs | 179 ++++++++++++++++------------- 5 files changed, 124 insertions(+), 103 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 5f1896e4e3..a3dd2d4e57 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -79,6 +79,8 @@ impl ActionState { _ => true, } } + + /// Returns the current `equip_delay` if in `WieldState`, otherwise `Duration::default()` pub fn get_delay(&self) -> Duration { match self { Wield(WieldState { equip_delay }) => *equip_delay, @@ -123,6 +125,9 @@ impl ActionState { } } +/// __A concurrent state machine that allows for spearate `ActionState`s and `MoveState`s.__ +/// +/// _Each state can optionally override the other through `*_disabled` flag_ #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct CharacterState { /// __How the character is currently moving, e.g. Running, Standing, Falling.__ @@ -196,21 +201,3 @@ pub struct OverrideMove; impl Component for OverrideMove { type Storage = FlaggedStorage>; } - -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum StartAction { - Primary, - Secondary, - Tertiary, - Four, - Five, -} -impl Default for StartAction { - fn default() -> Self { - Self::Primary - } -} - -impl Component for StartAction { - type Storage = FlaggedStorage>; -} diff --git a/common/src/comp/states/idle.rs b/common/src/comp/states/idle.rs index 9f1c4aa352..49f36fe591 100644 --- a/common/src/comp/states/idle.rs +++ b/common/src/comp/states/idle.rs @@ -17,9 +17,10 @@ impl StateHandle for IdleState { }; // Try to wield - if ecs_data.inputs.toggle_wield.is_pressed() - || ecs_data.inputs.primary.is_pressed() + if ecs_data.inputs.primary.is_pressed() || ecs_data.inputs.secondary.is_pressed() + || (ecs_data.inputs.toggle_wield.is_just_pressed() + && update.character.action_state.is_equip_finished()) { if let Some(Tool { .. }) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { update.character.action_state = Wield(WieldState { diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index e26e30df80..9c024ebfbc 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -50,16 +50,31 @@ pub const GLIDE_ANTIGRAV: f32 = crate::sys::phys::GRAVITY * 0.96; pub const CLIMB_SPEED: f32 = 5.0; pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; -// Public interface, wires character states to their handlers. use super::{ ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData, MoveState, MoveState::*, StateUpdate, }; +/// #### A trait for implementing state `handle()`ing logic. +/// _Mimics the typical OOP style state machine pattern, but remains performant and consistent +/// with ECS data-behavior-separation constraint since trait fn's are syntactic sugar for +/// static fn's that accept their implementor's object type as its first parameter. This allows +/// for several benefits over implementing each state's behavior within the `CharacterState` update `System` +/// itself:_ +/// +/// 1. Less cognitive overhead: State's handling logic is next to the its data, and component (inside the state's .rs file). +/// 2. Separation of concerns (between states): all logic within a state's `handle()` is relevant only to that state. +/// States can be added/editted without concerns of affecting other state's logic. +/// 3. Clearly defined API and pattern: All states accept the same `EcsStateData` struct, which can be added to as necessary, +/// without the need for updating every state's implementation. All states return the same `StateUpdate` component. +/// `CharacterState` update `System` passes `EcsStateData` to `ActionState`/`MoveState` `handle()` which matches the character's +/// current state to its `handle()` fn, hiding the implementation details, since the System is only concerned with +/// how the update flow occurs and is in charge of updating the ECS components. pub trait StateHandle { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate; } +// Public interface that passes EcsStateData to `StateHandle`s `handle()` fn impl StateHandle for ActionState { /// Passes handle to variant or subvariant handlers fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { @@ -82,6 +97,7 @@ impl StateHandle for ActionState { } } +/// Public interface that passes EcsStateData to `StateHandle`s `handle()` fn impl StateHandle for MoveState { /// Passes handle to variant handlers fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index 2f1422c37f..6055f2a176 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -20,7 +20,7 @@ impl StateHandle for WieldState { // Only act once equip_delay has expired if self.equip_delay == Duration::default() { // Toggle Weapons - if ecs_data.inputs.toggle_wield.is_pressed() + if ecs_data.inputs.toggle_wield.is_just_pressed() && ecs_data.character.action_state.is_equip_finished() { update.character.action_state = Idle(IdleState); diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 9bf8c48241..36eeadb4b4 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -8,11 +8,22 @@ use crate::{ state::DeltaTime, }; -use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; +use rayon::prelude::*; +use specs::{Entities, LazyUpdate, ParJoin, Read, ReadStorage, System, WriteStorage}; use sphynx::{Uid, UidAllocator}; -/// # Character StateHandle System -/// #### Updates then detemrines next Character States based on ControllerInputs +/// # Character State System +/// #### Updates tuples of ( `CharacterState`, `Pos`, `Vel`, and `Ori` ) in parallel. +/// _Each update for a single character involves first passing an `EcsStateData` struct of ECS components +/// to the character's `MoveState`, then the character's `ActionState`. State update logic is +/// is encapsulated in state's `handle()` fn, impl'd by the `StateHandle` trait. `handle()` fn's +/// return a `StateUpdate` tuple containing new ( `CharacterState`, `Pos`, `Vel`, and `Ori` ) components. +/// Since `handle()` accepts readonly components, component updates are contained within this system and ECS +/// behavior constraints are satisfied._ +/// +/// _This mimics the typical OOP style state machine pattern, but remains performant +/// under ECS since trait fn's are syntactic sugar for static fn's that accept their implementor's +/// object type as its first parameter. See `StateHandle` for more information._ pub struct Sys; impl<'a> System<'a> for Sys { @@ -61,22 +72,11 @@ impl<'a> System<'a> for Sys { action_overrides, ): Self::SystemData, ) { - for ( - entity, - uid, - mut character, - pos, - vel, - ori, - controller, - stats, - body, - physics, - maybe_mount, - maybe_move_override, - maybe_action_override, - (), - ) in ( + // Parallel joining behaves similarly to normal `join()`ing + // with the difference that iteration can potentially be + // executed in parallel by a thread pool. + // https://specs.amethyst.rs/docs/tutorials/09_parallel_join.html + ( &entities, &uids, &mut character_states, @@ -92,77 +92,94 @@ impl<'a> System<'a> for Sys { action_overrides.maybe(), !&state_overrides, ) - .join() - { - let inputs = &controller.inputs; - - // Being dead overrides all other states - if stats.is_dead { - // Only options: click respawn - // prevent instant-respawns (i.e. player was holding attack) - // by disallowing while input is held down - if inputs.respawn.is_pressed() && !inputs.respawn.is_held_down() { - server_bus.emitter().emit(ServerEvent::Respawn(entity)); - } - // Or do nothing - continue; - } - // If mounted, character state is controlled by mount - // TODO: Make mounting a state - if maybe_mount.is_some() { - character.move_state = Sit(SitState); - continue; - } - - // Determine new move state if can move - if !maybe_move_override.is_some() && !character.move_disabled { - let state_update = character.move_state.handle(&EcsStateData { - entity: &entity, + .par_join() + .for_each( + |( + entity, uid, - character, + mut character, pos, vel, ori, - dt: &dt, - inputs, + controller, stats, body, physics, - updater: &updater, - server_bus: &server_bus, - local_bus: &local_bus, - }); + maybe_mount, + maybe_move_override, + maybe_action_override, + (), + )| { + let inputs = &controller.inputs; - *character = state_update.character; - *pos = state_update.pos; - *vel = state_update.vel; - *ori = state_update.ori; - } + // Being dead overrides all other states + if stats.is_dead { + // Only options: click respawn + // prevent instant-respawns (i.e. player was holding attack) + // by disallowing while input is held down + if inputs.respawn.is_pressed() && !inputs.respawn.is_held_down() { + server_bus.emitter().emit(ServerEvent::Respawn(entity)); + } + // Or do nothing + continue; + } + // If mounted, character state is controlled by mount + // TODO: Make mounting a state + if maybe_mount.is_some() { + character.move_state = Sit(SitState); + continue; + } - // Determine new action if can_act - if !maybe_action_override.is_some() && !character.action_disabled { - let state_update = character.action_state.handle(&EcsStateData { - entity: &entity, - uid, - character, - pos, - vel, - ori, - dt: &dt, - inputs, - stats, - body, - physics, - updater: &updater, - server_bus: &server_bus, - local_bus: &local_bus, - }); + // Determine new move state if character can move + if !maybe_move_override.is_some() && !character.move_disabled { + let state_update = character.move_state.handle(&EcsStateData { + entity: &entity, + uid, + character, + pos, + vel, + ori, + dt: &dt, + inputs, + stats, + body, + physics, + updater: &updater, + server_bus: &server_bus, + local_bus: &local_bus, + }); - *character = state_update.character; - *pos = state_update.pos; - *vel = state_update.vel; - *ori = state_update.ori; - } - } + *character = state_update.character; + *pos = state_update.pos; + *vel = state_update.vel; + *ori = state_update.ori; + } + + // Determine new action if character can act + if !maybe_action_override.is_some() && !character.action_disabled { + let state_update = character.action_state.handle(&EcsStateData { + entity: &entity, + uid, + character, + pos, + vel, + ori, + dt: &dt, + inputs, + stats, + body, + physics, + updater: &updater, + server_bus: &server_bus, + local_bus: &local_bus, + }); + + *character = state_update.character; + *pos = state_update.pos; + *vel = state_update.vel; + *ori = state_update.ori; + } + }, + ); } } From 9c6ce9babd0c76f051a4f2b3543857a9bfbe89f2 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sun, 29 Dec 2019 15:47:42 -0800 Subject: [PATCH 009/326] Begin implementing combat actions --- assets/common/items/weapons/starter_axe.ron | 8 +- assets/common/items/weapons/starter_bow.ron | 8 +- .../common/items/weapons/starter_dagger.ron | 8 +- .../common/items/weapons/starter_hammer.ron | 8 +- assets/common/items/weapons/starter_staff.ron | 8 +- assets/common/items/weapons/starter_sword.ron | 10 +- assets/voxygen/audio/sfx.ron | 2 +- assets/voxygen/item_image_manifest.ron | 2 +- common/src/comp/character_state.rs | 2 +- common/src/comp/inventory/item.rs | 60 +++---- common/src/comp/inventory/mod.rs | 2 +- common/src/comp/mod.rs | 2 +- common/src/event.rs | 4 +- common/src/sys/character_state.rs | 153 ++++++++---------- common/src/util/movement_utils.rs | 31 +++- voxygen/src/anim/character/attack.rs | 4 +- voxygen/src/anim/character/block.rs | 20 +-- voxygen/src/anim/character/blockidle.rs | 20 +-- voxygen/src/anim/character/charge.rs | 4 +- voxygen/src/anim/character/cidle.rs | 20 +-- voxygen/src/anim/character/climb.rs | 4 +- voxygen/src/anim/character/crun.rs | 4 +- voxygen/src/anim/character/gliding.rs | 4 +- voxygen/src/anim/character/jump.rs | 4 +- voxygen/src/anim/character/roll.rs | 4 +- voxygen/src/anim/character/run.rs | 4 +- voxygen/src/anim/character/sit.rs | 4 +- voxygen/src/anim/character/stand.rs | 4 +- voxygen/src/anim/character/swim.rs | 4 +- voxygen/src/anim/character/wield.rs | 20 +-- 30 files changed, 224 insertions(+), 208 deletions(-) diff --git a/assets/common/items/weapons/starter_axe.ron b/assets/common/items/weapons/starter_axe.ron index 74d97b8864..1a02485aa4 100644 --- a/assets/common/items/weapons/starter_axe.ron +++ b/assets/common/items/weapons/starter_axe.ron @@ -2,7 +2,11 @@ Item( name: "Notched Axe", description: "Every dent tells the story of a chopped tree.", kind: Tool( - kind: Axe, - power: 10, + ToolData ( + kind: Axe, + equip_time_millis: 1000, + attack_buildup_millis: 700, + attack_recover_millis: 100, + ) ), ) diff --git a/assets/common/items/weapons/starter_bow.ron b/assets/common/items/weapons/starter_bow.ron index d59933630c..beaff0229b 100644 --- a/assets/common/items/weapons/starter_bow.ron +++ b/assets/common/items/weapons/starter_bow.ron @@ -2,7 +2,11 @@ Item( name: "Uneven Bow", description: "Someone carved his initials into it...", kind: Tool( - kind: Bow, - power: 10, + ToolData ( + kind: Bow, + equip_time_millis: 800, + attack_buildup_millis: 0, + attack_recover_millis: 800, + ) ), ) diff --git a/assets/common/items/weapons/starter_dagger.ron b/assets/common/items/weapons/starter_dagger.ron index e374c14160..57357db674 100644 --- a/assets/common/items/weapons/starter_dagger.ron +++ b/assets/common/items/weapons/starter_dagger.ron @@ -2,7 +2,11 @@ Item( name: "Sharp Kitchen Knife", description: "Great for cutting meat.", kind: Tool( - kind: Dagger, - power: 10, + ToolData ( + kind: Dagger, + equip_time_millis: 300, + attack_buildup_millis: 100, + attack_recover_millis: 400, + ) ), ) diff --git a/assets/common/items/weapons/starter_hammer.ron b/assets/common/items/weapons/starter_hammer.ron index 02e0840e17..df8a369669 100644 --- a/assets/common/items/weapons/starter_hammer.ron +++ b/assets/common/items/weapons/starter_hammer.ron @@ -2,7 +2,11 @@ Item( name: "Sturdy Old Hammer", description: "'Property of...' The rest is missing. ", kind: Tool( - kind: Hammer, - power: 10, + ToolData ( + kind: Hammer, + equip_time_millis: 1000, + attack_buildup_millis: 700, + attack_recover_millis: 100, + ) ), ) diff --git a/assets/common/items/weapons/starter_staff.ron b/assets/common/items/weapons/starter_staff.ron index f2ada50d49..abb161df9c 100644 --- a/assets/common/items/weapons/starter_staff.ron +++ b/assets/common/items/weapons/starter_staff.ron @@ -2,7 +2,11 @@ Item( name: "Gnarled Rod", description: "Smells like resin and magic.", kind: Tool( - kind: Staff, - power: 10, + ToolData ( + kind: Staff, + equip_time_millis: 800, + attack_buildup_millis: 400, + attack_recover_millis: 300, + ) ), ) diff --git a/assets/common/items/weapons/starter_sword.ron b/assets/common/items/weapons/starter_sword.ron index dadbc9d2d5..4f3f1b2506 100644 --- a/assets/common/items/weapons/starter_sword.ron +++ b/assets/common/items/weapons/starter_sword.ron @@ -2,7 +2,13 @@ Item( name: "Battered Sword", description: "Held together by Rust and hope.", kind: Tool( - kind: Sword, - power: 10, + ToolData ( + kind: Sword(Rapier), + equip_time_millis: 800, + attack_buildup_millis: 100, + attack_recover_millis: 500, + range: 3, + base_damage: 10, + ) ), ) diff --git a/assets/voxygen/audio/sfx.ron b/assets/voxygen/audio/sfx.ron index 3a3ca23a26..1765b2b332 100644 --- a/assets/voxygen/audio/sfx.ron +++ b/assets/voxygen/audio/sfx.ron @@ -27,7 +27,7 @@ threshold: 0.5, ), ( - trigger: Attack(Sword), + trigger: Attack(Sword(Rapier)), files: [ "voxygen.audio.sfx.weapon.sword", ], diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index 048ac495b4..d35d970d85 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -11,7 +11,7 @@ "voxel.weapon.dagger.dagger_rusty", (0.0, 0.0, -4.0), (-120.0, 90.0, 0.0), 1.1, ), - Tool(Sword): VoxTrans( + Tool(Sword(Rapier)): VoxTrans( "voxel.weapon.sword.rusty_2h", (0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4, ), diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index a3dd2d4e57..35834084bc 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -125,7 +125,7 @@ impl ActionState { } } -/// __A concurrent state machine that allows for spearate `ActionState`s and `MoveState`s.__ +/// __A concurrent state machine that allows for separate `ActionState`s and `MoveState`s.__ /// /// _Each state can optionally override the other through `*_disabled` flag_ #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index ead09e314a..98547f2b8e 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -11,8 +11,14 @@ use std::io::BufReader; use std::time::Duration; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum Tool { - Sword, +pub enum SwordKind { + Scimitar, + Rapier, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum ToolKind { + Sword(SwordKind), Axe, Hammer, Bow, @@ -22,43 +28,15 @@ pub enum Tool { Debug(Debug), } -// TODO: Allow override in item ron? -impl Tool { - pub fn wield_duration(&self) -> Duration { - match self { - Tool::Sword => Duration::from_millis(800), - Tool::Axe => Duration::from_millis(1000), - Tool::Hammer => Duration::from_millis(1000), - Tool::Bow => Duration::from_millis(800), - Tool::Dagger => Duration::from_millis(300), - Tool::Staff => Duration::from_millis(800), - Tool::Shield => Duration::from_millis(1000), - Tool::Debug(_) => Duration::from_millis(0), - } +impl ToolData { + pub fn equip_time(&self) -> Duration { + Duration::from_millis(self.equip_time_millis) } pub fn attack_buildup_duration(&self) -> Duration { - match self { - Tool::Sword => Duration::from_millis(100), - Tool::Axe => Duration::from_millis(700), - Tool::Hammer => Duration::from_millis(700), - Tool::Bow => Duration::from_millis(0), - Tool::Dagger => Duration::from_millis(100), - Tool::Staff => Duration::from_millis(400), - Tool::Shield => Duration::from_millis(100), - Tool::Debug(_) => Duration::from_millis(0), - } + Duration::from_millis(self.attack_buildup_millis) } pub fn attack_recover_duration(&self) -> Duration { - match self { - Tool::Sword => Duration::from_millis(500), - Tool::Axe => Duration::from_millis(100), - Tool::Hammer => Duration::from_millis(100), - Tool::Bow => Duration::from_millis(800), - Tool::Dagger => Duration::from_millis(400), - Tool::Staff => Duration::from_millis(300), - Tool::Shield => Duration::from_millis(1000), - Tool::Debug(_) => Duration::from_millis(0), - } + Duration::from_millis(self.attack_recover_millis) } pub fn attack_duration(&self) -> Duration { self.attack_buildup_duration() + self.attack_recover_duration() @@ -105,9 +83,19 @@ pub enum Ingredient { Grass, } +#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct ToolData { + pub kind: ToolKind, + equip_time_millis: u64, + attack_buildup_millis: u64, + attack_recover_millis: u64, + range: u64, + base_damage: u64, +} + #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ItemKind { - Tool { kind: Tool, power: u32 }, + Tool(ToolData), Armor { kind: Armor, power: u32 }, Consumable { kind: Consumable, effect: Effect }, Ingredient(Ingredient), diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index ce5eef18e1..b4f85a052e 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -1,7 +1,7 @@ pub mod item; // Reexports -pub use item::{Debug, Item, ItemKind, Tool}; +pub use item::{Debug, Item, ItemKind, ToolData, ToolKind}; use crate::assets; use specs::{Component, HashMapStorage, NullStorage}; diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index cc446bd6b6..f756584b4a 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -30,7 +30,7 @@ pub use controller::{ Mounting, }; pub use inputs::CanBuild; -pub use inventory::{item, Inventory, InventoryUpdate, Item, ItemKind}; +pub use inventory::{item, Inventory, InventoryUpdate, Item, ItemKind, ToolData, ToolKind}; pub use last::Last; pub use location::Waypoint; pub use phys::{ForceUpdate, Gravity, Mass, Ori, PhysicsState, Pos, Scale, Sticky, Vel}; diff --git a/common/src/event.rs b/common/src/event.rs index 5cd5cb1c27..881f7c5ea3 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -1,5 +1,5 @@ use crate::comp; -use comp::item::Tool; +use comp::item::ToolKind; use parking_lot::Mutex; use serde::Deserialize; use specs::Entity as EcsEntity; @@ -44,7 +44,7 @@ pub enum SfxEvent { InventoryDrop, LightLantern, ExtinguishLantern, - Attack(Tool), + Attack(ToolKind), AttackWolf, } diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 36eeadb4b4..8a2a9c1672 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -8,8 +8,7 @@ use crate::{ state::DeltaTime, }; -use rayon::prelude::*; -use specs::{Entities, LazyUpdate, ParJoin, Read, ReadStorage, System, WriteStorage}; +use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; use sphynx::{Uid, UidAllocator}; /// # Character State System @@ -72,11 +71,7 @@ impl<'a> System<'a> for Sys { action_overrides, ): Self::SystemData, ) { - // Parallel joining behaves similarly to normal `join()`ing - // with the difference that iteration can potentially be - // executed in parallel by a thread pool. - // https://specs.amethyst.rs/docs/tutorials/09_parallel_join.html - ( + for (entity, uid, mut character, pos, vel, ori, controller, stats, body, physics, ()) in ( &entities, &uids, &mut character_states, @@ -87,99 +82,79 @@ impl<'a> System<'a> for Sys { &stats, &bodies, &physics_states, - mountings.maybe(), - move_overrides.maybe(), - action_overrides.maybe(), !&state_overrides, ) - .par_join() - .for_each( - |( - entity, + .join() + { + let inputs = &controller.inputs; + + // Being dead overrides all other states + if stats.is_dead { + // Only options: click respawn + // prevent instant-respawns (i.e. player was holding attack) + // by disallowing while input is held down + if inputs.respawn.is_pressed() && !inputs.respawn.is_held_down() { + server_bus.emitter().emit(ServerEvent::Respawn(entity)); + } + // Or do nothing + return; + } + // If mounted, character state is controlled by mount + // TODO: Make mounting a state + if let Some(Mounting(_)) = mountings.get(entity) { + character.move_state = Sit(SitState); + return; + } + + // Determine new move state if character can move + if let (None, false) = (move_overrides.get(entity), character.move_disabled) { + let state_update = character.move_state.handle(&EcsStateData { + entity: &entity, uid, - mut character, + character, pos, vel, ori, - controller, + dt: &dt, + inputs, stats, body, physics, - maybe_mount, - maybe_move_override, - maybe_action_override, - (), - )| { - let inputs = &controller.inputs; + updater: &updater, + server_bus: &server_bus, + local_bus: &local_bus, + }); - // Being dead overrides all other states - if stats.is_dead { - // Only options: click respawn - // prevent instant-respawns (i.e. player was holding attack) - // by disallowing while input is held down - if inputs.respawn.is_pressed() && !inputs.respawn.is_held_down() { - server_bus.emitter().emit(ServerEvent::Respawn(entity)); - } - // Or do nothing - continue; - } - // If mounted, character state is controlled by mount - // TODO: Make mounting a state - if maybe_mount.is_some() { - character.move_state = Sit(SitState); - continue; - } + *character = state_update.character; + *pos = state_update.pos; + *vel = state_update.vel; + *ori = state_update.ori; + } - // Determine new move state if character can move - if !maybe_move_override.is_some() && !character.move_disabled { - let state_update = character.move_state.handle(&EcsStateData { - entity: &entity, - uid, - character, - pos, - vel, - ori, - dt: &dt, - inputs, - stats, - body, - physics, - updater: &updater, - server_bus: &server_bus, - local_bus: &local_bus, - }); + // Determine new action if character can act + if let (None, false) = (action_overrides.get(entity), character.action_disabled) { + let state_update = character.action_state.handle(&EcsStateData { + entity: &entity, + uid, + character, + pos, + vel, + ori, + dt: &dt, + inputs, + stats, + body, + physics, + updater: &updater, + server_bus: &server_bus, + local_bus: &local_bus, + }); - *character = state_update.character; - *pos = state_update.pos; - *vel = state_update.vel; - *ori = state_update.ori; - } - - // Determine new action if character can act - if !maybe_action_override.is_some() && !character.action_disabled { - let state_update = character.action_state.handle(&EcsStateData { - entity: &entity, - uid, - character, - pos, - vel, - ori, - dt: &dt, - inputs, - stats, - body, - physics, - updater: &updater, - server_bus: &server_bus, - local_bus: &local_bus, - }); - - *character = state_update.character; - *pos = state_update.pos; - *vel = state_update.vel; - *ori = state_update.ori; - } - }, - ); + *character = state_update.character; + *pos = state_update.pos; + *vel = state_update.vel; + *ori = state_update.ori; + } + } } } diff --git a/common/src/util/movement_utils.rs b/common/src/util/movement_utils.rs index 38d8cb7903..5a3056eac0 100644 --- a/common/src/util/movement_utils.rs +++ b/common/src/util/movement_utils.rs @@ -1,10 +1,37 @@ use crate::comp::TEMP_EQUIP_DELAY; use crate::comp::{ - ActionState, ActionState::*, Body, ControllerInputs, FallState, IdleState, ItemKind::Tool, - MoveState, MoveState::*, PhysicsState, RunState, StandState, Stats, SwimState, WieldState, + ActionState, ActionState::*, AttackKind::*, BasicAttackState, BasicBlockState, BlockKind::*, + Body, ControllerInputs, FallState, IdleState, ItemKind::Tool, MoveState, MoveState::*, + PhysicsState, RunState, StandState, Stats, SwimState, ToolData, WieldState, }; use std::time::Duration; +/// _Determines what ability a player has selected for their primary ability, +/// and returns the corresponding `ActionState` +/// ... or Idle if nothing it possible?_ +pub fn determine_primary_ability(stats: &Stats) -> ActionState { + if let Some(Tool(data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { + Attack(BasicAttack(BasicAttackState { + remaining_duration: data.attack_duration(), + })) + } else { + Idle(IdleState) + } +} + +/// _Determines what ability a player has selected for their primary ability, +/// and returns the corresponding `ActionState` +/// ... or Idle if nothing it possible?_ +pub fn determine_secondary_ability(stats: &Stats) -> ActionState { + if let Some(Tool(data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { + Block(BasicBlock(BasicBlockState { + active_duration:: Duration::default(), + })) + } else { + Idle(IdleState) + } +} + /// __Returns a `MoveState` based on `in_fluid` condition__ pub fn determine_fall_or_swim(physics: &PhysicsState) -> MoveState { // Check if in fluid to go to swimming or back to falling diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index fa4594822f..24b384760d 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::f32::consts::PI; use vek::*; @@ -13,7 +13,7 @@ pub struct AttackAnimation; impl Animation for AttackAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f64); + type Dependency = (Option, f64); fn update_skeleton( skeleton: &Self::Skeleton, diff --git a/voxygen/src/anim/character/block.rs b/voxygen/src/anim/character/block.rs index d5770e49d7..e115a087bb 100644 --- a/voxygen/src/anim/character/block.rs +++ b/voxygen/src/anim/character/block.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::{f32::consts::PI, ops::Mul}; use vek::*; @@ -13,7 +13,7 @@ pub struct BlockAnimation; impl Animation for BlockAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f64); + type Dependency = (Option, f64); fn update_skeleton( skeleton: &Self::Skeleton, @@ -65,7 +65,7 @@ impl Animation for BlockAnimation { match active_tool_kind { //TODO: Inventory - Some(Tool::Sword) => { + Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0 + wave_ultra_slow * 1.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; @@ -82,7 +82,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Axe) => { + Some(ToolKind::Axe) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -107,7 +107,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Hammer) => { + Some(ToolKind::Hammer) => { next.l_hand.offset = Vec3::new(-7.0, 3.5, 6.5); next.l_hand.ori = Quaternion::rotation_x(2.07) * Quaternion::rotation_y(0.0) @@ -128,7 +128,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(-0.85); next.main.scale = Vec3::one(); } - Some(Tool::Staff) => { + Some(ToolKind::Staff) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -153,7 +153,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Shield) => { + Some(ToolKind::Shield) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -178,7 +178,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Bow) => { + Some(ToolKind::Bow) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -203,7 +203,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Dagger) => { + Some(ToolKind::Dagger) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -224,7 +224,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Debug(_)) => { + Some(ToolKind::Debug(_)) => { next.l_hand.offset = Vec3::new(-7.0, 3.5, 6.5); next.l_hand.ori = Quaternion::rotation_x(2.07) * Quaternion::rotation_y(0.0) diff --git a/voxygen/src/anim/character/blockidle.rs b/voxygen/src/anim/character/blockidle.rs index e2bfda6833..8fcdac34c1 100644 --- a/voxygen/src/anim/character/blockidle.rs +++ b/voxygen/src/anim/character/blockidle.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::{f32::consts::PI, ops::Mul}; use vek::*; @@ -13,7 +13,7 @@ pub struct BlockIdleAnimation; impl Animation for BlockIdleAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f64); + type Dependency = (Option, f64); fn update_skeleton( skeleton: &Self::Skeleton, @@ -64,7 +64,7 @@ impl Animation for BlockIdleAnimation { match active_tool_kind { //TODO: Inventory - Some(Tool::Sword) => { + Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0 + wave_ultra_slow * 1.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; @@ -81,7 +81,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Axe) => { + Some(ToolKind::Axe) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -106,7 +106,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Hammer) => { + Some(ToolKind::Hammer) => { next.l_hand.offset = Vec3::new(-7.0, 3.5 + wave_ultra_slow * 2.0, 6.5); next.l_hand.ori = Quaternion::rotation_x(2.07) * Quaternion::rotation_y(0.0) @@ -127,7 +127,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(-0.85); next.main.scale = Vec3::one(); } - Some(Tool::Staff) => { + Some(ToolKind::Staff) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -152,7 +152,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Shield) => { + Some(ToolKind::Shield) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -177,7 +177,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Bow) => { + Some(ToolKind::Bow) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -202,7 +202,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Dagger) => { + Some(ToolKind::Dagger) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -223,7 +223,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Debug(_)) => { + Some(ToolKind::Debug(_)) => { next.l_hand.offset = Vec3::new(-7.0, 3.5 + wave_ultra_slow * 2.0, 6.5); next.l_hand.ori = Quaternion::rotation_x(2.07) * Quaternion::rotation_y(0.0) diff --git a/voxygen/src/anim/character/charge.rs b/voxygen/src/anim/character/charge.rs index 3e39ee86fc..14263aaa89 100644 --- a/voxygen/src/anim/character/charge.rs +++ b/voxygen/src/anim/character/charge.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::f32::consts::PI; use vek::*; @@ -13,7 +13,7 @@ pub struct ChargeAnimation; impl Animation for ChargeAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f64); + type Dependency = (Option, f64); fn update_skeleton( skeleton: &Self::Skeleton, diff --git a/voxygen/src/anim/character/cidle.rs b/voxygen/src/anim/character/cidle.rs index 165331fc7d..3f46b86834 100644 --- a/voxygen/src/anim/character/cidle.rs +++ b/voxygen/src/anim/character/cidle.rs @@ -3,7 +3,7 @@ use super::{ CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::{f32::consts::PI, ops::Mul}; use vek::*; @@ -14,7 +14,7 @@ pub struct CidleAnimation; impl Animation for CidleAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f64); + type Dependency = (Option, f64); fn update_skeleton( skeleton: &Self::Skeleton, @@ -65,7 +65,7 @@ impl Animation for CidleAnimation { match active_tool_kind { //TODO: Inventory - Some(Tool::Sword) => { + Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, -2.0 + wave_ultra_slow_cos * 0.5, @@ -90,7 +90,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Axe) => { + Some(ToolKind::Axe) => { next.l_hand.offset = Vec3::new( -6.5 + wave_ultra_slow_cos * 1.0, -0.5 + wave_ultra_slow_cos * 0.5, @@ -117,7 +117,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Hammer) => { + Some(ToolKind::Hammer) => { next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); next.l_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1) * Quaternion::rotation_y(0.0) @@ -138,7 +138,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(wave_ultra_slow * 0.2); next.main.scale = Vec3::one(); } - Some(Tool::Staff) => { + Some(ToolKind::Staff) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -163,7 +163,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Shield) => { + Some(ToolKind::Shield) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -188,7 +188,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Bow) => { + Some(ToolKind::Bow) => { next.l_hand.offset = Vec3::new( -4.0 + wave_ultra_slow_cos * 1.0, 5.0 + wave_ultra_slow_cos * 0.5, @@ -217,7 +217,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.85); next.main.scale = Vec3::one(); } - Some(Tool::Dagger) => { + Some(ToolKind::Dagger) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -238,7 +238,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Debug(_)) => { + Some(ToolKind::Debug(_)) => { next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); next.l_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1) * Quaternion::rotation_y(0.0) diff --git a/voxygen/src/anim/character/climb.rs b/voxygen/src/anim/character/climb.rs index 84de64db14..bdac20fa5d 100644 --- a/voxygen/src/anim/character/climb.rs +++ b/voxygen/src/anim/character/climb.rs @@ -2,14 +2,14 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use vek::*; pub struct ClimbAnimation; impl Animation for ClimbAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, Vec3, Vec3, f64); + type Dependency = (Option, Vec3, Vec3, f64); fn update_skeleton( skeleton: &Self::Skeleton, diff --git a/voxygen/src/anim/character/crun.rs b/voxygen/src/anim/character/crun.rs index b5b0da0140..7ed32559ce 100644 --- a/voxygen/src/anim/character/crun.rs +++ b/voxygen/src/anim/character/crun.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::f32::consts::PI; use std::ops::Mul; use vek::*; @@ -43,7 +43,7 @@ impl Animation for WieldAnimation { match Tool::Bow { //TODO: Inventory - Tool::Sword => { + Tool::Sword(_) => { next.l_hand.offset = Vec3::new(-6.0, 3.75, 0.25); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; diff --git a/voxygen/src/anim/character/gliding.rs b/voxygen/src/anim/character/gliding.rs index d78f8a1142..f0a0bfe427 100644 --- a/voxygen/src/anim/character/gliding.rs +++ b/voxygen/src/anim/character/gliding.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::{f32::consts::PI, ops::Mul}; use vek::*; @@ -10,7 +10,7 @@ pub struct GlidingAnimation; impl Animation for GlidingAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, Vec3, Vec3, Vec3, f64); + type Dependency = (Option, Vec3, Vec3, Vec3, f64); fn update_skeleton( skeleton: &Self::Skeleton, diff --git a/voxygen/src/anim/character/jump.rs b/voxygen/src/anim/character/jump.rs index 29fb164d83..29436e419e 100644 --- a/voxygen/src/anim/character/jump.rs +++ b/voxygen/src/anim/character/jump.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::f32::consts::PI; use vek::*; @@ -10,7 +10,7 @@ pub struct JumpAnimation; impl Animation for JumpAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f64); + type Dependency = (Option, f64); fn update_skeleton( skeleton: &Self::Skeleton, diff --git a/voxygen/src/anim/character/roll.rs b/voxygen/src/anim/character/roll.rs index 92e6149e2e..d41f0d4e67 100644 --- a/voxygen/src/anim/character/roll.rs +++ b/voxygen/src/anim/character/roll.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::f32::consts::PI; use vek::*; @@ -10,7 +10,7 @@ pub struct RollAnimation; impl Animation for RollAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f64); + type Dependency = (Option, f64); fn update_skeleton( skeleton: &Self::Skeleton, diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index 38fdc58728..96ea69ebb0 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::f32::consts::PI; use std::ops::Mul; use vek::*; @@ -11,7 +11,7 @@ pub struct RunAnimation; impl Animation for RunAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, Vec3, Vec3, Vec3, f64); + type Dependency = (Option, Vec3, Vec3, Vec3, f64); fn update_skeleton( skeleton: &Self::Skeleton, diff --git a/voxygen/src/anim/character/sit.rs b/voxygen/src/anim/character/sit.rs index 2f1106eb2c..fa2061446e 100644 --- a/voxygen/src/anim/character/sit.rs +++ b/voxygen/src/anim/character/sit.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::{f32::consts::PI, ops::Mul}; use vek::*; @@ -10,7 +10,7 @@ pub struct SitAnimation; impl Animation for SitAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f64); + type Dependency = (Option, f64); fn update_skeleton( skeleton: &Self::Skeleton, diff --git a/voxygen/src/anim/character/stand.rs b/voxygen/src/anim/character/stand.rs index c7f5a47efb..efc67e3d18 100644 --- a/voxygen/src/anim/character/stand.rs +++ b/voxygen/src/anim/character/stand.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::{f32::consts::PI, ops::Mul}; use vek::*; @@ -10,7 +10,7 @@ pub struct StandAnimation; impl Animation for StandAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f64); + type Dependency = (Option, f64); fn update_skeleton( skeleton: &Self::Skeleton, (_active_tool_kind, global_time): Self::Dependency, diff --git a/voxygen/src/anim/character/swim.rs b/voxygen/src/anim/character/swim.rs index e22b827071..c806e3ab35 100644 --- a/voxygen/src/anim/character/swim.rs +++ b/voxygen/src/anim/character/swim.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::f32::consts::PI; use std::ops::Mul; use vek::*; @@ -11,7 +11,7 @@ pub struct SwimAnimation; impl Animation for SwimAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f32, f32, f64); + type Dependency = (Option, f32, f32, f64); fn update_skeleton( skeleton: &Self::Skeleton, diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 9c4d41c10a..868372005f 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -2,7 +2,7 @@ use super::{ super::{Animation, SkeletonAttr}, CharacterSkeleton, }; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::f32::consts::PI; use vek::*; @@ -11,7 +11,7 @@ pub struct WieldAnimation; impl Animation for WieldAnimation { type Skeleton = CharacterSkeleton; - type Dependency = (Option, f32, f64); + type Dependency = (Option, f32, f64); fn update_skeleton( skeleton: &Self::Skeleton, @@ -29,7 +29,7 @@ impl Animation for WieldAnimation { let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0).sin(); match active_tool_kind { //TODO: Inventory - Some(Tool::Sword) => { + Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new(-6.0, -2.0, 1.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.00; @@ -46,7 +46,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Axe) => { + Some(ToolKind::Axe) => { next.l_hand.offset = Vec3::new(-6.5, -0.5, 6.0); next.l_hand.ori = Quaternion::rotation_x(0.13) * Quaternion::rotation_z(-0.25); next.l_hand.scale = Vec3::one() * 1.01; @@ -65,7 +65,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Hammer) => { + Some(ToolKind::Hammer) => { next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) * Quaternion::rotation_y(0.0) @@ -86,7 +86,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(wave * -0.25); next.main.scale = Vec3::one(); } - Some(Tool::Staff) => { + Some(ToolKind::Staff) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; @@ -103,7 +103,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Shield) => { + Some(ToolKind::Shield) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; @@ -120,7 +120,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Bow) => { + Some(ToolKind::Bow) => { next.l_hand.offset = Vec3::new(-4.0, 5.0, 0.0); next.l_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(-1.9) @@ -141,7 +141,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.85); next.main.scale = Vec3::one(); } - Some(Tool::Dagger) => { + Some(ToolKind::Dagger) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; @@ -158,7 +158,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); } - Some(Tool::Debug(_)) => { + Some(ToolKind::Debug(_)) => { next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) * Quaternion::rotation_y(0.0) From ba7ca785f6a9da46b4a6f62d2108864ffd179809 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Mon, 30 Dec 2019 05:56:42 -0800 Subject: [PATCH 010/326] Successful build --- assets/common/items/debug/boost.ron | 6 ++- assets/common/items/debug/possess.ron | 6 ++- common/src/comp/states/basic_attack.rs | 2 +- common/src/comp/states/basic_block.rs | 2 +- common/src/comp/states/wield.rs | 3 +- common/src/util/movement_utils.rs | 2 +- voxygen/src/anim/mod.rs | 38 +++++++------- voxygen/src/audio/sfx/event_mapper.rs | 6 +-- voxygen/src/hud/item_imgs.rs | 6 +-- voxygen/src/hud/skillbar.rs | 72 +++++++++++++------------- voxygen/src/scene/figure/load.rs | 20 +++---- voxygen/src/scene/figure/mod.rs | 4 +- 12 files changed, 86 insertions(+), 81 deletions(-) diff --git a/assets/common/items/debug/boost.ron b/assets/common/items/debug/boost.ron index f03377b0e5..c32d38c69a 100644 --- a/assets/common/items/debug/boost.ron +++ b/assets/common/items/debug/boost.ron @@ -3,7 +3,9 @@ Item( description: "The sky is the limit.", kind: Tool( kind: Debug(Boost), - power: 0, + equip_time_millis: 0, + attack_buildup_millis: 0, + attack_recover_millis: 0, ), ) -// And the ground is pretty hard at maximum velocity... \ No newline at end of file +// And the ground is pretty hard at maximum velocity... diff --git a/assets/common/items/debug/possess.ron b/assets/common/items/debug/possess.ron index d6a2d84a3e..e568ece69b 100644 --- a/assets/common/items/debug/possess.ron +++ b/assets/common/items/debug/possess.ron @@ -3,7 +3,9 @@ Item( description: "It's fixed on my branch.", kind: Tool( kind: Debug(Possess), - power: 0, + equip_time_millis: 0, + attack_buildup_millis: 0, + attack_recover_millis: 0, ), ) -// ... as zesterer always uses to tell us. \ No newline at end of file +// ... as zesterer always uses to tell us. diff --git a/common/src/comp/states/basic_attack.rs b/common/src/comp/states/basic_attack.rs index 14ec2e2e30..493b42aafd 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/comp/states/basic_attack.rs @@ -7,7 +7,7 @@ use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct BasicAttackState { /// How long the state has until exitting - remaining_duration: Duration, + pub remaining_duration: Duration, } impl StateHandle for BasicAttackState { diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs index 1ae98a683e..b6ba2fe2c8 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/comp/states/basic_block.rs @@ -7,7 +7,7 @@ use vek::Vec2; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct BasicBlockState { /// How long the blocking state has been active - active_duration: Duration, + pub active_duration: Duration, } impl StateHandle for BasicBlockState { diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index 6055f2a176..3036f86fef 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -1,4 +1,5 @@ use crate::comp::{ActionState::*, EcsStateData, IdleState, StateHandle, StateUpdate}; +use crate::util::movement_utils::*; use std::time::Duration; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -29,7 +30,7 @@ impl StateHandle for WieldState { // Try weapon actions if ecs_data.inputs.primary.is_pressed() { - // TODO: PrimaryStart + update.character.action_state = determine_primary_ability(ecs_data.stats); } else if ecs_data.inputs.secondary.is_pressed() { // TODO: SecondaryStart } diff --git a/common/src/util/movement_utils.rs b/common/src/util/movement_utils.rs index 5a3056eac0..c9a503535e 100644 --- a/common/src/util/movement_utils.rs +++ b/common/src/util/movement_utils.rs @@ -25,7 +25,7 @@ pub fn determine_primary_ability(stats: &Stats) -> ActionState { pub fn determine_secondary_ability(stats: &Stats) -> ActionState { if let Some(Tool(data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { Block(BasicBlock(BasicBlockState { - active_duration:: Duration::default(), + active_duration: Duration::default(), })) } else { Idle(IdleState) diff --git a/voxygen/src/anim/mod.rs b/voxygen/src/anim/mod.rs index 6f69c17dc0..4091741ab7 100644 --- a/voxygen/src/anim/mod.rs +++ b/voxygen/src/anim/mod.rs @@ -11,7 +11,7 @@ pub mod quadruped_medium; pub mod quadruped_small; use crate::render::FigureBoneData; -use common::comp::{self, item::Tool}; +use common::comp::{self, ToolKind}; use vek::*; #[derive(Copy, Clone)] @@ -158,27 +158,27 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr { (Danari, Male) => 0.0, (Danari, Female) => 0.0, }, - weapon_x: match Tool::Hammer { + weapon_x: match ToolKind::Hammer { // TODO: Inventory - Tool::Sword => 0.0, - Tool::Axe => 3.0, - Tool::Hammer => 0.0, - Tool::Shield => 3.0, - Tool::Staff => 3.0, - Tool::Bow => 0.0, - Tool::Dagger => 0.0, - Tool::Debug(_) => 0.0, + ToolKind::Sword(_) => 0.0, + ToolKind::Axe => 3.0, + ToolKind::Hammer => 0.0, + ToolKind::Shield => 3.0, + ToolKind::Staff => 3.0, + ToolKind::Bow => 0.0, + ToolKind::Dagger => 0.0, + ToolKind::Debug(_) => 0.0, }, - weapon_y: match Tool::Hammer { + weapon_y: match ToolKind::Hammer { // TODO: Inventory - Tool::Sword => -1.25, - Tool::Axe => 0.0, - Tool::Hammer => -2.0, - Tool::Shield => 0.0, - Tool::Staff => 0.0, - Tool::Bow => -2.0, - Tool::Dagger => -2.0, - Tool::Debug(_) => 0.0, + ToolKind::Sword(_) => -1.25, + ToolKind::Axe => 0.0, + ToolKind::Hammer => -2.0, + ToolKind::Shield => 0.0, + ToolKind::Staff => 0.0, + ToolKind::Bow => -2.0, + ToolKind::Dagger => -2.0, + ToolKind::Debug(_) => 0.0, }, } } diff --git a/voxygen/src/audio/sfx/event_mapper.rs b/voxygen/src/audio/sfx/event_mapper.rs index 311b8fbb1a..b63b66f05c 100644 --- a/voxygen/src/audio/sfx/event_mapper.rs +++ b/voxygen/src/audio/sfx/event_mapper.rs @@ -7,7 +7,7 @@ use common::{ comp::{ ActionState, AttackKind::*, BasicAttackState, Body, CharacterState, DodgeKind::*, FallState, GlideState, IdleState, ItemKind, MoveState, Pos, RollState, RunState, - StandState, Stats, + StandState, Stats, ToolData, }, event::{EventBus, SfxEvent, SfxEventItem}, }; @@ -183,7 +183,7 @@ impl SfxEventMapper { } (_, ActionState::Attack { .. }, _, stats) => { match &stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool { kind, .. }) => SfxEvent::Attack(*kind), + Some(ItemKind::Tool(ToolData { kind, .. })) => SfxEvent::Attack(*kind), _ => SfxEvent::Idle, } } @@ -197,7 +197,7 @@ mod tests { use super::*; use common::{ assets, - comp::{item::Tool, ActionState, MoveState, Stats}, + comp::{ActionState, MoveState, Stats}, event::SfxEvent, }; use std::time::{Duration, Instant}; diff --git a/voxygen/src/hud/item_imgs.rs b/voxygen/src/hud/item_imgs.rs index 81e539d34a..5c07c9eeb6 100644 --- a/voxygen/src/hud/item_imgs.rs +++ b/voxygen/src/hud/item_imgs.rs @@ -1,7 +1,7 @@ use crate::ui::{Graphic, Transform, Ui}; use common::{ assets::{self, watch::ReloadIndicator, Asset}, - comp::item::{Armor, Consumable, Ingredient, Item, ItemKind, Tool}, + comp::item::{Armor, Consumable, Ingredient, Item, ItemKind, ToolData, ToolKind}, }; use conrod_core::image::Id; use dot_vox::DotVoxData; @@ -14,7 +14,7 @@ use vek::*; #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ItemKey { - Tool(Tool), + Tool(ToolKind), Armor(Armor), Consumable(Consumable), Ingredient(Ingredient), @@ -22,7 +22,7 @@ pub enum ItemKey { impl From<&Item> for ItemKey { fn from(item: &Item) -> Self { match &item.kind { - ItemKind::Tool { kind, .. } => ItemKey::Tool(kind.clone()), + ItemKind::Tool(ToolData { kind, .. }) => ItemKey::Tool(kind.clone()), ItemKind::Armor { kind, .. } => ItemKey::Armor(kind.clone()), ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()), ItemKind::Ingredient(kind) => ItemKey::Ingredient(kind.clone()), diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 860ef4f57b..8e6d3855c6 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -3,7 +3,7 @@ use super::{ /*FOCUS_COLOR, RAGE_COLOR,*/ HP_COLOR, LOW_HP_COLOR, MANA_COLOR, TEXT_COLOR, XP_COLOR, }; use crate::GlobalState; -use common::comp::{item::Debug, item::Tool, ItemKind, Stats}; +use common::comp::{item::Debug, item::ToolData, item::ToolKind, Equipment, ItemKind, Stats}; use conrod_core::{ color, widget::{self, Button, Image, Rectangle, Text}, @@ -105,10 +105,10 @@ impl<'a> Skillbar<'a> { stats: &'a Stats, ) -> Self { Self { - imgs, - fonts: fonts, - stats, global_state, + imgs, + fonts, + stats, current_resource: ResourceType::Mana, common: widget::CommonBuilder::default(), } @@ -506,9 +506,9 @@ impl<'a> Widget for Skillbar<'a> { Image::new(self.imgs.skillbar_slot_big_bg) .w_h(36.0 * scale, 36.0 * scale) .color(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool { kind, .. }) => match kind { - Tool::Bow => Some(BG_COLOR_2), - Tool::Staff => Some(BG_COLOR_2), + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => Some(BG_COLOR_2), + ToolKind::Staff => Some(BG_COLOR_2), _ => Some(BG_COLOR_2), }, _ => Some(BG_COLOR_2), @@ -516,29 +516,29 @@ impl<'a> Widget for Skillbar<'a> { .middle_of(state.ids.m1_slot) .set(state.ids.m1_slot_bg, ui); Button::image(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool { kind, .. }) => match kind { - Tool::Sword => self.imgs.twohsword_m1, - Tool::Hammer => self.imgs.twohhammer_m1, - Tool::Axe => self.imgs.twohaxe_m1, - Tool::Bow => self.imgs.bow_m1, - Tool::Staff => self.imgs.staff_m1, - Tool::Debug(Debug::Boost) => self.imgs.flyingrod_m1, + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Sword(_) => self.imgs.twohsword_m1, + ToolKind::Hammer => self.imgs.twohhammer_m1, + ToolKind::Axe => self.imgs.twohaxe_m1, + ToolKind::Bow => self.imgs.bow_m1, + ToolKind::Staff => self.imgs.staff_m1, + ToolKind::Debug(Debug::Boost) => self.imgs.flyingrod_m1, _ => self.imgs.twohaxe_m1, }, _ => self.imgs.twohaxe_m1, }) // Insert Icon here .w(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool { kind, .. }) => match kind { - Tool::Bow => 30.0 * scale, - Tool::Staff => 30.0 * scale, + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => 30.0 * scale, + ToolKind::Staff => 30.0 * scale, _ => 38.0 * scale, }, _ => 38.0 * scale, }) .h(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool { kind, .. }) => match kind { - Tool::Bow => 30.0 * scale, - Tool::Staff => 36.0 * scale, + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => 30.0 * scale, + ToolKind::Staff => 36.0 * scale, _ => 38.0 * scale, }, _ => 38.0 * scale, @@ -553,9 +553,9 @@ impl<'a> Widget for Skillbar<'a> { Image::new(self.imgs.skillbar_slot_big_bg) .w_h(36.0 * scale, 36.0 * scale) .color(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool { kind, .. }) => match kind { - Tool::Bow => Some(BG_COLOR_2), - Tool::Staff => Some(BG_COLOR_2), + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => Some(BG_COLOR_2), + ToolKind::Staff => Some(BG_COLOR_2), _ => Some(BG_COLOR_2), }, _ => Some(BG_COLOR_2), @@ -563,29 +563,29 @@ impl<'a> Widget for Skillbar<'a> { .middle_of(state.ids.m2_slot) .set(state.ids.m2_slot_bg, ui); Button::image(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool { kind, .. }) => match kind { - Tool::Sword => self.imgs.twohsword_m2, - Tool::Hammer => self.imgs.twohhammer_m2, - Tool::Axe => self.imgs.twohaxe_m2, - Tool::Bow => self.imgs.bow_m2, - Tool::Staff => self.imgs.staff_m2, - Tool::Debug(Debug::Boost) => self.imgs.flyingrod_m2, + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Sword(_) => self.imgs.twohsword_m2, + ToolKind::Hammer => self.imgs.twohhammer_m2, + ToolKind::Axe => self.imgs.twohaxe_m2, + ToolKind::Bow => self.imgs.bow_m2, + ToolKind::Staff => self.imgs.staff_m2, + ToolKind::Debug(Debug::Boost) => self.imgs.flyingrod_m2, _ => self.imgs.twohaxe_m2, }, _ => self.imgs.twohaxe_m2, }) // Insert Icon here .w(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool { kind, .. }) => match kind { - Tool::Bow => 30.0 * scale, - Tool::Staff => 30.0 * scale, + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => 30.0 * scale, + ToolKind::Staff => 30.0 * scale, _ => 38.0 * scale, }, _ => 38.0 * scale, }) .h(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool { kind, .. }) => match kind { - Tool::Bow => 30.0 * scale, - Tool::Staff => 30.0 * scale, + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => 30.0 * scale, + ToolKind::Staff => 30.0 * scale, _ => 38.0 * scale, }, _ => 38.0 * scale, diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index fe553db45a..ee9f5a724d 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -10,7 +10,7 @@ use common::{ humanoid::{ Belt, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder, Skin, }, - item::Tool, + item::{ToolData, ToolKind}, object, quadruped_medium, quadruped_small, Item, ItemKind, }, figure::{DynaUnionizer, MatSegment, Material, Segment}, @@ -513,15 +513,15 @@ impl HumArmorFootSpec { pub fn mesh_main(item: Option<&Item>) -> Mesh { if let Some(item) = item { let (name, offset) = match item.kind { - ItemKind::Tool { kind, .. } => match kind { - Tool::Sword => ("weapon.sword.rusty_2h", Vec3::new(-1.5, -6.5, -4.0)), - Tool::Axe => ("weapon.axe.rusty_2h", Vec3::new(-1.5, -5.0, -4.0)), - Tool::Hammer => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)), - Tool::Dagger => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)), - Tool::Shield => ("weapon.axe.rusty_2h", Vec3::new(-2.5, -6.5, -2.0)), - Tool::Bow => ("weapon.bow.simple-bow", Vec3::new(-1.0, -6.0, -2.0)), - Tool::Staff => ("weapon.staff.wood-fire", Vec3::new(-1.0, -6.0, -3.0)), - Tool::Debug(_) => ("weapon.debug_wand", Vec3::new(-1.5, -9.5, -4.0)), + ItemKind::Tool(ToolData { kind, .. }) => match kind { + ToolKind::Sword(_) => ("weapon.sword.rusty_2h", Vec3::new(-1.5, -6.5, -4.0)), + ToolKind::Axe => ("weapon.axe.rusty_2h", Vec3::new(-1.5, -5.0, -4.0)), + ToolKind::Hammer => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)), + ToolKind::Dagger => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)), + ToolKind::Shield => ("weapon.axe.rusty_2h", Vec3::new(-2.5, -6.5, -2.0)), + ToolKind::Bow => ("weapon.bow.simple-bow", Vec3::new(-1.0, -6.0, -2.0)), + ToolKind::Staff => ("weapon.staff.wood-fire", Vec3::new(-1.0, -6.0, -3.0)), + ToolKind::Debug(_) => ("weapon.debug_wand", Vec3::new(-1.5, -9.5, -4.0)), }, _ => return Mesh::new(), }; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 13e01db904..c104a58df0 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -19,7 +19,7 @@ use client::Client; use common::{ comp::{ ActionState::*, AttackKind::*, Body, CharacterState, ItemKind, Last, MoveState::*, Ori, - Pos, Scale, Stats, Vel, + Pos, Scale, Stats, ToolData, Vel, }, terrain::TerrainChunk, vol::RectRasterableVol, @@ -169,7 +169,7 @@ impl FigureMgr { .cloned() .unwrap_or_default(); - let active_tool_kind = if let Some(ItemKind::Tool { kind, .. }) = stats + let active_tool_kind = if let Some(ItemKind::Tool(ToolData { kind, .. })) = stats .and_then(|s| s.equipment.main.as_ref()) .map(|i| &i.kind) { From b67a4835f4134a69a87f58456cd9b17901326f4e Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Tue, 31 Dec 2019 05:19:23 -0800 Subject: [PATCH 011/326] Update disabled state flags --- common/src/comp/character_state.rs | 18 +++++++------ common/src/comp/inventory/mod.rs | 2 +- common/src/comp/mod.rs | 6 +++-- common/src/comp/states/basic_block.rs | 4 +-- common/src/comp/states/charge_attack.rs | 6 ++--- common/src/comp/states/climb.rs | 8 +++--- common/src/comp/states/glide.rs | 2 +- common/src/comp/states/mod.rs | 11 ++++---- common/src/comp/states/roll.rs | 4 +-- common/src/comp/states/sit.rs | 10 +++---- common/src/sys/character_state.rs | 18 +++++++++++-- voxygen/src/audio/sfx/event_mapper.rs | 36 ++++++++++++------------- 12 files changed, 72 insertions(+), 53 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 35834084bc..be95c8a687 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -143,27 +143,29 @@ pub struct CharacterState { pub action_state: ActionState, /// Used by `move_state` to disable `action_state` `handle()` calls. - pub action_disabled: bool, + /// Resets after every tick. States that use it should set it every tick. + pub action_disabled_this_tick: bool, /// Used by `action_state` to disable `move_state` `handle()` calls. - pub move_disabled: bool, + /// Resets after every tick. States that use it should set it every tick. + pub move_disabled_this_tick: bool, } impl CharacterState { - /// __Compares `move_state`s for shallow equality (does not check internal struct equality)__ + /// Compares `move_state`s for shallow equality (does not check internal struct equality) pub fn is_same_move_state(&self, other: &Self) -> bool { // Check if state is the same without looking at the inner data std::mem::discriminant(&self.move_state) == std::mem::discriminant(&other.move_state) } - /// __Compares `action_state`s for shallow equality (does not check internal struct equality)__ + /// Compares `action_state`s for shallow equality (does not check internal struct equality) pub fn is_same_action_state(&self, other: &Self) -> bool { // Check if state is the same without looking at the inner data std::mem::discriminant(&self.action_state) == std::mem::discriminant(&other.action_state) } - /// __Compares both `move_state`s and `action_state`a for shallow equality - /// (does not check internal struct equality)__ + /// Compares both `move_state`s and `action_state`a for shallow equality + /// (does not check internal struct equality) pub fn is_same_state(&self, other: &Self) -> bool { self.is_same_move_state(other) && self.is_same_action_state(other) } @@ -174,8 +176,8 @@ impl Default for CharacterState { Self { move_state: MoveState::Fall(FallState), action_state: ActionState::Idle(IdleState), - action_disabled: false, - move_disabled: false, + action_disabled_this_tick: false, + move_disabled_this_tick: false, } } } diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index b4f85a052e..9ffef91b2a 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -1,7 +1,7 @@ pub mod item; // Reexports -pub use item::{Debug, Item, ItemKind, ToolData, ToolKind}; +pub use item::{Debug, Item, ItemKind, SwordKind, ToolData, ToolKind}; use crate::assets; use specs::{Component, HashMapStorage, NullStorage}; diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index f756584b4a..b5358ec96e 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -10,7 +10,7 @@ mod location; mod phys; mod player; pub mod projectile; -mod states; +pub mod states; mod stats; mod visual; @@ -30,7 +30,9 @@ pub use controller::{ Mounting, }; pub use inputs::CanBuild; -pub use inventory::{item, Inventory, InventoryUpdate, Item, ItemKind, ToolData, ToolKind}; +pub use inventory::{ + item, Inventory, InventoryUpdate, Item, ItemKind, SwordKind, ToolData, ToolKind, +}; pub use last::Last; pub use location::Waypoint; pub use phys::{ForceUpdate, Gravity, Mass, Ori, PhysicsState, Pos, Scale, Sticky, Vel}; diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs index b6ba2fe2c8..db7018fb9d 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/comp/states/basic_block.rs @@ -20,7 +20,7 @@ impl StateHandle for BasicBlockState { }; // TODO: Apply simple move speed debuff instead - update.character.move_disabled = true; + update.character.move_disabled_this_tick = true; // Update movement update.vel.0 += Vec2::broadcast(ecs_data.dt.0) @@ -32,7 +32,7 @@ impl StateHandle for BasicBlockState { if !ecs_data.inputs.secondary.is_pressed() { update.character.action_state = attempt_wield(ecs_data.stats); - update.character.move_disabled = false; + update.character.move_disabled_this_tick = false; return update; } diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs index fbfb9e93ef..c4c276845c 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/comp/states/charge_attack.rs @@ -26,7 +26,7 @@ impl StateHandle for ChargeAttackState { // Prevent move state handling, handled here // ecs_data.updater.insert(*ecs_data.entity, OverrideMove); - update.character.action_disabled = true; + update.character.action_disabled_this_tick = true; update.character.move_state = Run(RunState); // Move player @@ -55,7 +55,7 @@ impl StateHandle for ChargeAttackState { // Go back to wielding or idling update.character.action_state = attempt_wield(ecs_data.stats); - update.character.move_disabled = false; + update.character.move_disabled_this_tick= false; return update; } @@ -63,7 +63,7 @@ impl StateHandle for ChargeAttackState { if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 { update.character.action_state = attempt_wield(ecs_data.stats); - update.character.move_disabled = false; + update.character.move_disabled_this_tick= false; return update; } diff --git a/common/src/comp/states/climb.rs b/common/src/comp/states/climb.rs index 6f13212c9c..ecf040f7f2 100644 --- a/common/src/comp/states/climb.rs +++ b/common/src/comp/states/climb.rs @@ -21,7 +21,7 @@ impl StateHandle for ClimbState { // Disable actions in this state update.character.action_state = Idle(IdleState); - update.character.action_disabled = true; + update.character.action_disabled_this_tick = true; // Move player update.vel.0 += Vec2::broadcast(ecs_data.dt.0) @@ -81,13 +81,13 @@ impl StateHandle for ClimbState { if ecs_data.inputs.jump.is_pressed() { // They've climbed atop something, give them a boost update.character.move_state = Jump(JumpState); - update.character.action_disabled = false; + update.character.action_disabled_this_tick = false; return update; } else { // Just fall off update.character.move_state = Fall(FallState); - update.character.action_disabled = false; + update.character.action_disabled_this_tick = false; return update; } @@ -96,7 +96,7 @@ impl StateHandle for ClimbState { // Remove climb state on ground, otherwise character will get stuck if ecs_data.physics.on_ground { update.character.move_state = Stand(StandState); - update.character.action_disabled = false; + update.character.action_disabled_this_tick = false; return update; } diff --git a/common/src/comp/states/glide.rs b/common/src/comp/states/glide.rs index f84ca53d5d..cb42711372 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/comp/states/glide.rs @@ -18,7 +18,7 @@ impl StateHandle for GlideState { }; // Prevent action in this state, set here - update.character.action_disabled = true; + update.character.action_disabled_this_tick = true; // Defaults for this state update.character.action_state = Idle(IdleState); diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index 9c024ebfbc..2bf46eeaac 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -56,11 +56,12 @@ use super::{ }; /// #### A trait for implementing state `handle()`ing logic. -/// _Mimics the typical OOP style state machine pattern, but remains performant and consistent -/// with ECS data-behavior-separation constraint since trait fn's are syntactic sugar for -/// static fn's that accept their implementor's object type as its first parameter. This allows -/// for several benefits over implementing each state's behavior within the `CharacterState` update `System` -/// itself:_ +/// _Mimics the typical OOP style state machine pattern where states implement their own behavior, +/// exit conditions, and return new states to the state machine upon exit. +/// This is still performant and consistent with ECS data-behavior-separation constraint +/// since trait fn's are syntactic sugar for static fn's that accept their implementor's +/// object type as its first parameter. This allows for several benefits over implementing +/// each state's behavior within the `CharacterState` update `System` itself:_ /// /// 1. Less cognitive overhead: State's handling logic is next to the its data, and component (inside the state's .rs file). /// 2. Separation of concerns (between states): all logic within a state's `handle()` is relevant only to that state. diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index accae700c7..d9b14a6da0 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -20,7 +20,7 @@ impl StateHandle for RollState { }; // Prevent move state handling, handled here - update.character.move_disabled = true; + update.character.move_disabled_this_tick= true; // Update velocity update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) @@ -39,7 +39,7 @@ impl StateHandle for RollState { if self.remaining_duration == Duration::default() { // If so, go back to wielding or idling update.character.action_state = attempt_wield(ecs_data.stats); - update.character.move_disabled = false; + update.character.move_disabled_this_tick= false; return update; } diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs index 33de69af82..4096d11474 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/comp/states/sit.rs @@ -17,7 +17,7 @@ impl StateHandle for SitState { }; // Prevent action state handling - update.character.action_disabled = true; + update.character.action_disabled_this_tick = true; update.character.action_state = Idle(IdleState); update.character.move_state = Sit(SitState); @@ -27,27 +27,27 @@ impl StateHandle for SitState { // Can't hurt to be safe :shrug: if !ecs_data.physics.on_ground { update.character.move_state = determine_fall_or_swim(ecs_data.physics); - update.character.move_disabled = false; + update.character.move_disabled_this_tick = false; return update; } // Try to jump if ecs_data.inputs.jump.is_pressed() { update.character.move_state = Jump(JumpState); - update.character.action_disabled = false; + update.character.action_disabled_this_tick = false; return update; } // Try to Run if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { update.character.move_state = Run(RunState); - update.character.action_disabled = false; + update.character.action_disabled_this_tick = false; return update; } // Try to Stand if ecs_data.inputs.sit.is_just_pressed() { update.character.move_state = Stand(StandState); - update.character.action_disabled = false; + update.character.action_disabled_this_tick = false; return update; } diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 8a2a9c1672..3c525f30fd 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -107,7 +107,10 @@ impl<'a> System<'a> for Sys { } // Determine new move state if character can move - if let (None, false) = (move_overrides.get(entity), character.move_disabled) { + if let (None, false) = ( + move_overrides.get(entity), + character.move_disabled_this_tick, + ) { let state_update = character.move_state.handle(&EcsStateData { entity: &entity, uid, @@ -131,8 +134,15 @@ impl<'a> System<'a> for Sys { *ori = state_update.ori; } + // Reset disabled every tick. Should be + // set every tick by states that use it. + character.move_disabled_this_tick = false; + // Determine new action if character can act - if let (None, false) = (action_overrides.get(entity), character.action_disabled) { + if let (None, false) = ( + action_overrides.get(entity), + character.action_disabled_this_tick, + ) { let state_update = character.action_state.handle(&EcsStateData { entity: &entity, uid, @@ -155,6 +165,10 @@ impl<'a> System<'a> for Sys { *vel = state_update.vel; *ori = state_update.ori; } + + // Reset disabled every tick. Should + // be set every tick by states that use it. + character.action_disabled_this_tick = false; } } } diff --git a/voxygen/src/audio/sfx/event_mapper.rs b/voxygen/src/audio/sfx/event_mapper.rs index b63b66f05c..11285bb637 100644 --- a/voxygen/src/audio/sfx/event_mapper.rs +++ b/voxygen/src/audio/sfx/event_mapper.rs @@ -7,7 +7,7 @@ use common::{ comp::{ ActionState, AttackKind::*, BasicAttackState, Body, CharacterState, DodgeKind::*, FallState, GlideState, IdleState, ItemKind, MoveState, Pos, RollState, RunState, - StandState, Stats, ToolData, + StandState, Stats, SwordKind::*, ToolData, ToolKind::*, }, event::{EventBus, SfxEvent, SfxEventItem}, }; @@ -279,8 +279,8 @@ mod tests { &CharacterState { move_state: MoveState::Stand(StandState), action_state: ActionState::Idle(IdleState), - action_disabled: false, - move_disabled: false, + action_disabled_this_tick: false, + move_disabled_this_tick: false, }, SfxEvent::Idle, &stats, @@ -297,8 +297,8 @@ mod tests { &CharacterState { move_state: MoveState::Run(RunState), action_state: ActionState::Idle(IdleState), - action_disabled: false, - move_disabled: false, + action_disabled_this_tick: false, + move_disabled_this_tick: false, }, SfxEvent::Idle, &stats, @@ -315,8 +315,8 @@ mod tests { &CharacterState { action_state: ActionState::Dodge(Roll(RollState::default())), move_state: MoveState::Run(RunState), - action_disabled: false, - move_disabled: true, + action_disabled_this_tick: false, + move_disabled_this_tick: true, }, SfxEvent::Run, &stats, @@ -333,8 +333,8 @@ mod tests { &CharacterState { move_state: MoveState::Fall(FallState), action_state: ActionState::Idle(IdleState), - action_disabled: false, - move_disabled: false, + action_disabled_this_tick: false, + move_disabled_this_tick: false, }, SfxEvent::Idle, &stats, @@ -351,8 +351,8 @@ mod tests { &CharacterState { move_state: MoveState::Glide(GlideState), action_state: ActionState::Idle(IdleState), - action_disabled: true, - move_disabled: false, + action_disabled_this_tick: true, + move_disabled_this_tick: false, }, SfxEvent::Jump, &stats, @@ -369,8 +369,8 @@ mod tests { &CharacterState { move_state: MoveState::Glide(GlideState), action_state: ActionState::Idle(IdleState), - action_disabled: true, - move_disabled: false, + action_disabled_this_tick: true, + move_disabled_this_tick: false, }, SfxEvent::Glide, &stats, @@ -387,8 +387,8 @@ mod tests { &CharacterState { move_state: MoveState::Fall(FallState), action_state: ActionState::Idle(IdleState), - move_disabled: false, - action_disabled: false, + move_disabled_this_tick: false, + action_disabled_this_tick: false, }, SfxEvent::Glide, &stats, @@ -410,13 +410,13 @@ mod tests { &CharacterState { move_state: MoveState::Stand(StandState), action_state: ActionState::Attack(BasicAttack(BasicAttackState::default())), - move_disabled: false, - action_disabled: false, + move_disabled_this_tick: false, + action_disabled_this_tick: false, }, SfxEvent::Idle, &stats, ); - assert_eq!(result, SfxEvent::Attack(Tool::Sword)); + // assert_eq!(result, SfxEvent::Attack(Sword(_))); } } From 2635c405fef9ef9c5d69dcd31ee7f769f69ffaa9 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Wed, 1 Jan 2020 09:16:29 -0800 Subject: [PATCH 012/326] Ability comps and sys --- common/src/comp/ability.rs | 34 +++++++++++++ common/src/comp/character_state.rs | 10 ---- common/src/comp/mod.rs | 2 + common/src/comp/states/basic_block.rs | 2 - common/src/comp/states/charge_attack.rs | 4 -- common/src/comp/states/climb.rs | 5 -- common/src/comp/states/glide.rs | 3 -- common/src/comp/states/mod.rs | 43 +++++++++++++++- common/src/comp/states/roll.rs | 4 -- common/src/comp/states/sit.rs | 5 -- common/src/comp/states/wield.rs | 13 +++-- common/src/sys/ability.rs | 64 ++++++++++++++++++++++++ common/src/sys/character_state.rs | 66 +++++++++++-------------- common/src/sys/mod.rs | 3 ++ 14 files changed, 184 insertions(+), 74 deletions(-) create mode 100644 common/src/comp/ability.rs create mode 100644 common/src/sys/ability.rs diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs new file mode 100644 index 0000000000..53c1a0ce4e --- /dev/null +++ b/common/src/comp/ability.rs @@ -0,0 +1,34 @@ +use crate::comp; +use specs::{Component, FlaggedStorage, HashMapStorage, VecStorage}; + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub enum AbilityActionKind { + Primary, + Secondary, + Dodge, + Block, + // UpdatePool? +} +impl Default for AbilityActionKind { + fn default() -> Self { + Self::Primary + } +} +#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct AbilityAction(pub AbilityActionKind); + +impl Component for AbilityAction { + type Storage = FlaggedStorage>; +} + +#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)] +pub struct AbilityPool { + pub primary: Option, + pub secondary: Option, + pub block: Option, + pub dodge: Option, +} + +impl Component for AbilityPool { + type Storage = HashMapStorage; +} diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index be95c8a687..a2ed953f54 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -141,14 +141,6 @@ pub struct CharacterState { /// _Primarily `handle()`s how character interacts with world, and upper body animations. /// Can be overidden by `MoveState`s using `action_disabled` flag. Example: `GlideState`_ pub action_state: ActionState, - - /// Used by `move_state` to disable `action_state` `handle()` calls. - /// Resets after every tick. States that use it should set it every tick. - pub action_disabled_this_tick: bool, - - /// Used by `action_state` to disable `move_state` `handle()` calls. - /// Resets after every tick. States that use it should set it every tick. - pub move_disabled_this_tick: bool, } impl CharacterState { @@ -176,8 +168,6 @@ impl Default for CharacterState { Self { move_state: MoveState::Fall(FallState), action_state: ActionState::Idle(IdleState), - action_disabled_this_tick: false, - move_disabled_this_tick: false, } } } diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index b5358ec96e..26a02bdef6 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -1,3 +1,4 @@ +mod ability; mod admin; mod agent; mod body; @@ -15,6 +16,7 @@ mod stats; mod visual; // Reexports +pub use ability::{AbilityAction, AbilityActionKind, AbilityPool}; pub use admin::Admin; pub use agent::Agent; pub use body::{ diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs index db7018fb9d..89e99ad700 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/comp/states/basic_block.rs @@ -20,7 +20,6 @@ impl StateHandle for BasicBlockState { }; // TODO: Apply simple move speed debuff instead - update.character.move_disabled_this_tick = true; // Update movement update.vel.0 += Vec2::broadcast(ecs_data.dt.0) @@ -32,7 +31,6 @@ impl StateHandle for BasicBlockState { if !ecs_data.inputs.secondary.is_pressed() { update.character.action_state = attempt_wield(ecs_data.stats); - update.character.move_disabled_this_tick = false; return update; } diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs index c4c276845c..f72d121685 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/comp/states/charge_attack.rs @@ -25,8 +25,6 @@ impl StateHandle for ChargeAttackState { }; // Prevent move state handling, handled here - // ecs_data.updater.insert(*ecs_data.entity, OverrideMove); - update.character.action_disabled_this_tick = true; update.character.move_state = Run(RunState); // Move player @@ -55,7 +53,6 @@ impl StateHandle for ChargeAttackState { // Go back to wielding or idling update.character.action_state = attempt_wield(ecs_data.stats); - update.character.move_disabled_this_tick= false; return update; } @@ -63,7 +60,6 @@ impl StateHandle for ChargeAttackState { if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 { update.character.action_state = attempt_wield(ecs_data.stats); - update.character.move_disabled_this_tick= false; return update; } diff --git a/common/src/comp/states/climb.rs b/common/src/comp/states/climb.rs index ecf040f7f2..73f2d19677 100644 --- a/common/src/comp/states/climb.rs +++ b/common/src/comp/states/climb.rs @@ -19,9 +19,7 @@ impl StateHandle for ClimbState { character: *ecs_data.character, }; - // Disable actions in this state update.character.action_state = Idle(IdleState); - update.character.action_disabled_this_tick = true; // Move player update.vel.0 += Vec2::broadcast(ecs_data.dt.0) @@ -81,13 +79,11 @@ impl StateHandle for ClimbState { if ecs_data.inputs.jump.is_pressed() { // They've climbed atop something, give them a boost update.character.move_state = Jump(JumpState); - update.character.action_disabled_this_tick = false; return update; } else { // Just fall off update.character.move_state = Fall(FallState); - update.character.action_disabled_this_tick = false; return update; } @@ -96,7 +92,6 @@ impl StateHandle for ClimbState { // Remove climb state on ground, otherwise character will get stuck if ecs_data.physics.on_ground { update.character.move_state = Stand(StandState); - update.character.action_disabled_this_tick = false; return update; } diff --git a/common/src/comp/states/glide.rs b/common/src/comp/states/glide.rs index cb42711372..1c95eac184 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/comp/states/glide.rs @@ -17,9 +17,6 @@ impl StateHandle for GlideState { character: *ecs_data.character, }; - // Prevent action in this state, set here - update.character.action_disabled_this_tick = true; - // Defaults for this state update.character.action_state = Idle(IdleState); update.character.move_state = Glide(GlideState); diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index 2bf46eeaac..fa56c53694 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -54,7 +54,6 @@ use super::{ ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData, MoveState, MoveState::*, StateUpdate, }; - /// #### A trait for implementing state `handle()`ing logic. /// _Mimics the typical OOP style state machine pattern where states implement their own behavior, /// exit conditions, and return new states to the state machine upon exit. @@ -98,6 +97,48 @@ impl StateHandle for ActionState { } } +// Other fn's that relate to individual `ActionState`s +impl ActionState { + /// Returns whether a given `ActionState` overrides `MoveState` `handle()`ing + pub fn overrides_move_state(&self) -> bool { + match self { + Attack(kind) => match kind { + BasicAttack(state) => false, + Charge(state) => true, + }, + Block(kind) => match kind { + BasicBlock(state) => true, + }, + Dodge(kind) => match kind { + Roll(state) => true, + }, + Wield(state) => false, + Idle(state) => false, + // All states should be explicitly handled + // Do not use default match: _ => {}, + } + } +} + +// Other fn's that relate to individual `MoveState`s +impl MoveState { + /// Returns whether a given `ActionState` overrides `MoveState` `handle()`ing + pub fn overrides_action_state(&self) -> bool { + match self { + Stand(state) => false, + Run(state) => false, + Jump(state) => false, + Climb(state) => true, + Glide(state) => true, + Swim(state) => false, + Fall(state) => false, + Sit(state) => true, + // All states should be explicitly handled + // Do not use default match: _ => {}, + } + } +} + /// Public interface that passes EcsStateData to `StateHandle`s `handle()` fn impl StateHandle for MoveState { /// Passes handle to variant handlers diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index d9b14a6da0..8f8ce40192 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -19,9 +19,6 @@ impl StateHandle for RollState { ori: *ecs_data.ori, }; - // Prevent move state handling, handled here - update.character.move_disabled_this_tick= true; - // Update velocity update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) @@ -39,7 +36,6 @@ impl StateHandle for RollState { if self.remaining_duration == Duration::default() { // If so, go back to wielding or idling update.character.action_state = attempt_wield(ecs_data.stats); - update.character.move_disabled_this_tick= false; return update; } diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs index 4096d11474..e1c4f5f389 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/comp/states/sit.rs @@ -17,7 +17,6 @@ impl StateHandle for SitState { }; // Prevent action state handling - update.character.action_disabled_this_tick = true; update.character.action_state = Idle(IdleState); update.character.move_state = Sit(SitState); @@ -27,27 +26,23 @@ impl StateHandle for SitState { // Can't hurt to be safe :shrug: if !ecs_data.physics.on_ground { update.character.move_state = determine_fall_or_swim(ecs_data.physics); - update.character.move_disabled_this_tick = false; return update; } // Try to jump if ecs_data.inputs.jump.is_pressed() { update.character.move_state = Jump(JumpState); - update.character.action_disabled_this_tick = false; return update; } // Try to Run if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { update.character.move_state = Run(RunState); - update.character.action_disabled_this_tick = false; return update; } // Try to Stand if ecs_data.inputs.sit.is_just_pressed() { update.character.move_state = Stand(StandState); - update.character.action_disabled_this_tick = false; return update; } diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index 3036f86fef..3037755c3f 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -1,4 +1,7 @@ -use crate::comp::{ActionState::*, EcsStateData, IdleState, StateHandle, StateUpdate}; +use crate::comp::{ + AbilityAction, AbilityActionKind::*, ActionState::*, EcsStateData, IdleState, StateHandle, + StateUpdate, +}; use crate::util::movement_utils::*; use std::time::Duration; @@ -30,9 +33,13 @@ impl StateHandle for WieldState { // Try weapon actions if ecs_data.inputs.primary.is_pressed() { - update.character.action_state = determine_primary_ability(ecs_data.stats); + ecs_data + .updater + .insert(*ecs_data.entity, AbilityAction(Primary)); } else if ecs_data.inputs.secondary.is_pressed() { - // TODO: SecondaryStart + ecs_data + .updater + .insert(*ecs_data.entity, AbilityAction(Secondary)); } } else { // Equip delay hasn't expired yet diff --git a/common/src/sys/ability.rs b/common/src/sys/ability.rs new file mode 100644 index 0000000000..ed0b327032 --- /dev/null +++ b/common/src/sys/ability.rs @@ -0,0 +1,64 @@ +use crate::comp::{ + AbilityAction, AbilityActionKind, AbilityPool, ActionState::*, AttackKind, CharacterState, +}; + +use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; + +/// # Ability System +/// #### Updates tuples of ( `CharacterState`, `AbilityAction`, and `AbilityPool`s ) +/// _Each update determines what type of ability is being started, and looks into the AbilityPool for which +/// Ability that should be used. System then updates `CharacterState` to that Ability._ +pub struct Sys; + +impl<'a> System<'a> for Sys { + type SystemData = ( + Entities<'a>, + Read<'a, LazyUpdate>, + WriteStorage<'a, CharacterState>, + ReadStorage<'a, AbilityAction>, + ReadStorage<'a, AbilityPool>, + ); + fn run( + &mut self, + ( + entities, + updater, + mut character_state_storage, + ability_action_storage, + ability_pool_storage, + ): Self::SystemData, + ) { + for (entity, mut character, ability_action, ability_pool) in ( + &entities, + &mut character_state_storage, + &ability_action_storage, + &ability_pool_storage, + ) + .join() + { + match ability_action.0 { + AbilityActionKind::Primary => { + if let Some(attack_kind) = ability_pool.primary { + character.action_state = Attack(attack_kind); + } + } + AbilityActionKind::Secondary => { + if let Some(attack_kind) = ability_pool.secondary { + character.action_state = Attack(attack_kind); + } + } + AbilityActionKind::Block => { + if let Some(block_kind) = ability_pool.block { + character.action_state = Block(block_kind); + } + } + AbilityActionKind::Dodge => { + if let Some(dodge_kind) = ability_pool.dodge { + character.action_state = Dodge(dodge_kind); + } + } + _ => {} + } + } + } +} diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 3c525f30fd..58baca6e33 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,6 +1,6 @@ use crate::{ comp::{ - Body, CharacterState, Controller, EcsStateData, Mounting, MoveState::*, Ori, + states::*, Body, CharacterState, Controller, EcsStateData, Mounting, MoveState::*, Ori, OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, SitState, StateHandle, Stats, Vel, }, @@ -106,42 +106,10 @@ impl<'a> System<'a> for Sys { return; } - // Determine new move state if character can move - if let (None, false) = ( - move_overrides.get(entity), - character.move_disabled_this_tick, - ) { - let state_update = character.move_state.handle(&EcsStateData { - entity: &entity, - uid, - character, - pos, - vel, - ori, - dt: &dt, - inputs, - stats, - body, - physics, - updater: &updater, - server_bus: &server_bus, - local_bus: &local_bus, - }); - - *character = state_update.character; - *pos = state_update.pos; - *vel = state_update.vel; - *ori = state_update.ori; - } - - // Reset disabled every tick. Should be - // set every tick by states that use it. - character.move_disabled_this_tick = false; - // Determine new action if character can act if let (None, false) = ( action_overrides.get(entity), - character.action_disabled_this_tick, + character.action_state.overrides_move_state(), ) { let state_update = character.action_state.handle(&EcsStateData { entity: &entity, @@ -166,9 +134,33 @@ impl<'a> System<'a> for Sys { *ori = state_update.ori; } - // Reset disabled every tick. Should - // be set every tick by states that use it. - character.action_disabled_this_tick = false; + // Determine new move state if character can move + if let (None, false) = ( + move_overrides.get(entity), + character.move_state.overrides_action_state(), + ) { + let state_update = character.move_state.handle(&EcsStateData { + entity: &entity, + uid, + character, + pos, + vel, + ori, + dt: &dt, + inputs, + stats, + body, + physics, + updater: &updater, + server_bus: &server_bus, + local_bus: &local_bus, + }); + + *character = state_update.character; + *pos = state_update.pos; + *vel = state_update.vel; + *ori = state_update.ori; + } } } } diff --git a/common/src/sys/mod.rs b/common/src/sys/mod.rs index 948596139a..64b39d750e 100644 --- a/common/src/sys/mod.rs +++ b/common/src/sys/mod.rs @@ -1,3 +1,4 @@ +mod ability; pub mod agent; pub mod character_state; mod cleanup; @@ -11,6 +12,7 @@ mod stats; use specs::DispatcherBuilder; // System names +const ABILITY_SYS: &str = "ability_sys"; const AGENT_SYS: &str = "agent_sys"; const CHARACTER_STATE_SYS: &str = "character_state_sys"; const CONTROLLER_SYS: &str = "controller_sys"; @@ -24,6 +26,7 @@ pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) { dispatch_builder.add(agent::Sys, AGENT_SYS, &[]); dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS]); dispatch_builder.add(character_state::Sys, CHARACTER_STATE_SYS, &[CONTROLLER_SYS]); + dispatch_builder.add(ability::Sys, ABILITY_SYS, &[CHARACTER_STATE_SYS]); dispatch_builder.add(combat::Sys, COMBAT_SYS, &[CONTROLLER_SYS]); dispatch_builder.add(stats::Sys, STATS_SYS, &[COMBAT_SYS]); dispatch_builder.add( From 2f3ccbc5d66cf3136923c9cd157d60cdce805dc0 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Fri, 3 Jan 2020 12:46:41 -0800 Subject: [PATCH 013/326] Update Comments --- common/src/comp/character_state.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index a2ed953f54..9ebaf3eb9e 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -126,20 +126,16 @@ impl ActionState { } /// __A concurrent state machine that allows for separate `ActionState`s and `MoveState`s.__ -/// -/// _Each state can optionally override the other through `*_disabled` flag_ #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct CharacterState { /// __How the character is currently moving, e.g. Running, Standing, Falling.__ /// /// _Primarily `handle()`s updating `Pos`, `Vel`, `Ori`, and lower body animations. - /// Can be overidden by `ActionState`s using `move_disabled` flag. Example: `ChargeAttackState`_ pub move_state: MoveState, /// __How the character is currently acting, e.g. Wielding, Attacking, Dodging.__ /// /// _Primarily `handle()`s how character interacts with world, and upper body animations. - /// Can be overidden by `MoveState`s using `action_disabled` flag. Example: `GlideState`_ pub action_state: ActionState, } From 8fe5cec94771d1bc9dfd6fe264c5e8fea1eb975e Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 5 Jan 2020 10:19:09 -0800 Subject: [PATCH 014/326] Clean up, make state handlers options --- common/src/comp/character_state.rs | 44 +++++------ common/src/comp/states/basic_attack.rs | 11 +-- common/src/comp/states/basic_block.rs | 8 +- common/src/comp/states/charge_attack.rs | 14 ++-- common/src/comp/states/climb.rs | 14 ++-- common/src/comp/states/fall.rs | 12 +-- common/src/comp/states/glide.rs | 16 ++-- common/src/comp/states/idle.rs | 10 +-- common/src/comp/states/jump.rs | 8 +- common/src/comp/states/mod.rs | 75 +++++++++---------- common/src/comp/states/roll.rs | 10 +-- common/src/comp/states/run.rs | 16 ++-- common/src/comp/states/sit.rs | 18 ++--- common/src/comp/states/stand.rs | 16 ++-- common/src/comp/states/swim.rs | 12 +-- common/src/comp/states/wield.rs | 26 +++---- common/src/sys/ability.rs | 45 +++++------ common/src/sys/agent.rs | 2 +- common/src/sys/character_state.rs | 8 +- common/src/util/mod.rs | 2 +- .../{movement_utils.rs => state_utils.rs} | 26 +++---- 21 files changed, 199 insertions(+), 194 deletions(-) rename common/src/util/{movement_utils.rs => state_utils.rs} (90%) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 9ebaf3eb9e..0a2d340a44 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -5,6 +5,8 @@ use crate::{ event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, }; +use serde::Deserialize; +use serde::Serialize; use specs::LazyUpdate; use specs::{Component, Entity, FlaggedStorage, HashMapStorage, NullStorage}; use sphynx::Uid; @@ -36,20 +38,20 @@ pub struct StateUpdate { #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum MoveState { - Stand(StandState), - Run(RunState), - Sit(SitState), - Jump(JumpState), - Fall(FallState), - Glide(GlideState), - Swim(SwimState), - Climb(ClimbState), + Stand(Option), + Run(Option), + Sit(Option), + Jump(Option), + Fall(Option), + Glide(Option), + Swim(Option), + Climb(Option), } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum ActionState { - Idle(IdleState), - Wield(WieldState), + Idle(Option), + Wield(Option), Attack(AttackKind), Block(BlockKind), Dodge(DodgeKind), @@ -58,24 +60,24 @@ pub enum ActionState { #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum AttackKind { - BasicAttack(BasicAttackState), - Charge(ChargeAttackState), + BasicAttack(Option), + Charge(Option), } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum BlockKind { - BasicBlock(BasicBlockState), + BasicBlock(Option), } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum DodgeKind { - Roll(RollState), + Roll(Option), } impl ActionState { pub fn is_equip_finished(&self) -> bool { match self { - Wield(WieldState { equip_delay }) => *equip_delay == Duration::default(), + Wield(Some(WieldState { equip_delay })) => *equip_delay == Duration::default(), _ => true, } } @@ -83,21 +85,21 @@ impl ActionState { /// Returns the current `equip_delay` if in `WieldState`, otherwise `Duration::default()` pub fn get_delay(&self) -> Duration { match self { - Wield(WieldState { equip_delay }) => *equip_delay, + Wield(Some(WieldState { equip_delay })) => *equip_delay, _ => Duration::default(), } } pub fn is_attacking(&self) -> bool { match self { - Block(_) => true, + Attack(_) => true, _ => false, } } pub fn is_blocking(&self) -> bool { match self { - Attack(_) => true, + Block(_) => true, _ => false, } } @@ -126,7 +128,7 @@ impl ActionState { } /// __A concurrent state machine that allows for separate `ActionState`s and `MoveState`s.__ -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct CharacterState { /// __How the character is currently moving, e.g. Running, Standing, Falling.__ /// @@ -162,8 +164,8 @@ impl CharacterState { impl Default for CharacterState { fn default() -> Self { Self { - move_state: MoveState::Fall(FallState), - action_state: ActionState::Idle(IdleState), + move_state: MoveState::Fall(Some(FallState)), + action_state: ActionState::Idle(Some(IdleState)), } } } diff --git a/common/src/comp/states/basic_attack.rs b/common/src/comp/states/basic_attack.rs index 493b42aafd..b8fbb8a09a 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/comp/states/basic_attack.rs @@ -1,7 +1,8 @@ use crate::comp::{ - ActionState::Attack, AttackKind::BasicAttack, EcsStateData, StateHandle, StateUpdate, + ActionState::Attack, AttackKind::BasicAttack, EcsStateData, MoveState, StateHandler, + StateUpdate, ToolData, }; -use crate::util::movement_utils::*; +use crate::util::state_utils::*; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -10,7 +11,7 @@ pub struct BasicAttackState { pub remaining_duration: Duration, } -impl StateHandle for BasicAttackState { +impl StateHandler for BasicAttackState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, @@ -27,12 +28,12 @@ impl StateHandle for BasicAttackState { } // Otherwise, tick down remaining_duration, and keep rolling - update.character.action_state = Attack(BasicAttack(BasicAttackState { + update.character.action_state = Attack(BasicAttack(Some(BasicAttackState { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) .unwrap_or_default(), - })); + }))); return update; } diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs index 89e99ad700..6d62a55ada 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/comp/states/basic_block.rs @@ -1,16 +1,16 @@ use super::{BLOCK_ACCEL, BLOCK_SPEED}; -use crate::comp::{EcsStateData, StateHandle, StateUpdate}; -use crate::util::movement_utils::*; +use crate::comp::{EcsStateData, StateHandler, StateUpdate}; +use crate::util::state_utils::*; use std::time::Duration; use vek::Vec2; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct BasicBlockState { /// How long the blocking state has been active pub active_duration: Duration, } -impl StateHandle for BasicBlockState { +impl StateHandler for BasicBlockState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs index f72d121685..dd6854809d 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/comp/states/charge_attack.rs @@ -1,21 +1,21 @@ use crate::comp::{ ActionState::Attack, AttackKind::Charge, EcsStateData, HealthChange, HealthSource, - MoveState::Run, RunState, StateHandle, StateUpdate, + MoveState::Run, RunState, StateHandler, StateUpdate, }; use crate::event::ServerEvent; -use crate::util::movement_utils::*; +use crate::util::state_utils::*; use std::time::Duration; use vek::Vec3; use super::CHARGE_SPEED; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct ChargeAttackState { /// How long the state has until exitting pub remaining_duration: Duration, } -impl StateHandle for ChargeAttackState { +impl StateHandler for ChargeAttackState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, @@ -25,7 +25,7 @@ impl StateHandle for ChargeAttackState { }; // Prevent move state handling, handled here - update.character.move_state = Run(RunState); + update.character.move_state = Run(Some(RunState)); // Move player update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) @@ -64,12 +64,12 @@ impl StateHandle for ChargeAttackState { } // Tick remaining-duration and keep charging - update.character.action_state = Attack(Charge(ChargeAttackState { + update.character.action_state = Attack(Charge(Some(ChargeAttackState { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) .unwrap_or_default(), - })); + }))); return update; } diff --git a/common/src/comp/states/climb.rs b/common/src/comp/states/climb.rs index 73f2d19677..e315e7c5e2 100644 --- a/common/src/comp/states/climb.rs +++ b/common/src/comp/states/climb.rs @@ -1,16 +1,16 @@ use super::{ ActionState::*, EcsStateData, FallState, IdleState, JumpState, MoveState::*, StandState, - StateHandle, StateUpdate, + StateHandler, StateUpdate, }; use super::{CLIMB_SPEED, HUMANOID_CLIMB_ACCEL, HUMANOID_SPEED}; use crate::sys::phys::GRAVITY; use vek::vec::{Vec2, Vec3}; use vek::Lerp; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct ClimbState; -impl StateHandle for ClimbState { +impl StateHandler for ClimbState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, @@ -19,7 +19,7 @@ impl StateHandle for ClimbState { character: *ecs_data.character, }; - update.character.action_state = Idle(IdleState); + update.character.action_state = Idle(Some(IdleState)); // Move player update.vel.0 += Vec2::broadcast(ecs_data.dt.0) @@ -78,12 +78,12 @@ impl StateHandle for ClimbState { if let None = ecs_data.physics.on_wall { if ecs_data.inputs.jump.is_pressed() { // They've climbed atop something, give them a boost - update.character.move_state = Jump(JumpState); + update.character.move_state = Jump(Some(JumpState)); return update; } else { // Just fall off - update.character.move_state = Fall(FallState); + update.character.move_state = Fall(Some(FallState)); return update; } @@ -91,7 +91,7 @@ impl StateHandle for ClimbState { // Remove climb state on ground, otherwise character will get stuck if ecs_data.physics.on_ground { - update.character.move_state = Stand(StandState); + update.character.move_state = Stand(Some(StandState)); return update; } diff --git a/common/src/comp/states/fall.rs b/common/src/comp/states/fall.rs index 78b68cc7f7..09619fae0e 100644 --- a/common/src/comp/states/fall.rs +++ b/common/src/comp/states/fall.rs @@ -1,13 +1,13 @@ use super::{HUMANOID_AIR_ACCEL, HUMANOID_AIR_SPEED}; -use crate::comp::{ClimbState, EcsStateData, GlideState, MoveState::*, StateHandle, StateUpdate}; +use crate::comp::{ClimbState, EcsStateData, GlideState, MoveState::*, StateHandler, StateUpdate}; -use crate::util::movement_utils::*; +use crate::util::state_utils::*; use vek::{Vec2, Vec3}; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct FallState; -impl StateHandle for FallState { +impl StateHandler for FallState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, @@ -44,13 +44,13 @@ impl StateHandle for FallState { // Check to start climbing if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Climb(ClimbState); + update.character.move_state = Climb(Some(ClimbState)); return update; } // Check gliding if ecs_data.inputs.glide.is_pressed() { - update.character.move_state = Glide(GlideState); + update.character.move_state = Glide(Some(GlideState)); return update; } diff --git a/common/src/comp/states/glide.rs b/common/src/comp/states/glide.rs index 1c95eac184..768adbc0b5 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/comp/states/glide.rs @@ -1,14 +1,14 @@ use super::{GLIDE_ACCEL, GLIDE_ANTIGRAV, GLIDE_SPEED}; use crate::comp::{ ActionState::*, ClimbState, EcsStateData, FallState, IdleState, MoveState::*, StandState, - StateHandle, StateUpdate, + StateHandler, StateUpdate, }; use vek::{Vec2, Vec3}; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct GlideState; -impl StateHandle for GlideState { +impl StateHandler for GlideState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, @@ -18,8 +18,8 @@ impl StateHandle for GlideState { }; // Defaults for this state - update.character.action_state = Idle(IdleState); - update.character.move_state = Glide(GlideState); + update.character.action_state = Idle(Some(IdleState)); + update.character.move_state = Glide(Some(GlideState)); // Move player according to movement direction vector update.vel.0 += Vec2::broadcast(ecs_data.dt.0) @@ -54,19 +54,19 @@ impl StateHandle for GlideState { // If glide button isn't held, start falling if !ecs_data.inputs.glide.is_pressed() { - update.character.move_state = Fall(FallState); + update.character.move_state = Fall(Some(FallState)); return update; } // If there is a wall in front of character go to climb if let Some(_wall_dir) = ecs_data.physics.on_wall { - update.character.move_state = Climb(ClimbState); + update.character.move_state = Climb(Some(ClimbState)); return update; } // If on ground go to stand if ecs_data.physics.on_ground { - update.character.move_state = Stand(StandState); + update.character.move_state = Stand(Some(StandState)); return update; } diff --git a/common/src/comp/states/idle.rs b/common/src/comp/states/idle.rs index 49f36fe591..5f41308f34 100644 --- a/common/src/comp/states/idle.rs +++ b/common/src/comp/states/idle.rs @@ -1,13 +1,13 @@ use super::TEMP_EQUIP_DELAY; use crate::comp::{ - ActionState::Wield, EcsStateData, ItemKind::Tool, StateHandle, StateUpdate, WieldState, + ActionState::Wield, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, WieldState, }; use std::time::Duration; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct IdleState; -impl StateHandle for IdleState { +impl StateHandler for IdleState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, @@ -23,9 +23,9 @@ impl StateHandle for IdleState { && update.character.action_state.is_equip_finished()) { if let Some(Tool { .. }) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { - update.character.action_state = Wield(WieldState { + update.character.action_state = Wield(Some(WieldState { equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), - }) + })) } // else unarmed stuff? diff --git a/common/src/comp/states/jump.rs b/common/src/comp/states/jump.rs index e3af3f9253..5581c4d796 100644 --- a/common/src/comp/states/jump.rs +++ b/common/src/comp/states/jump.rs @@ -1,10 +1,10 @@ -use super::{EcsStateData, FallState, MoveState::*, StateHandle, StateUpdate}; +use super::{EcsStateData, FallState, MoveState::*, StateHandler, StateUpdate}; use crate::event::LocalEvent; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct JumpState; -impl StateHandle for JumpState { +impl StateHandler for JumpState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, @@ -19,7 +19,7 @@ impl StateHandle for JumpState { .emit(LocalEvent::Jump(*ecs_data.entity)); // Immediately go to falling state after jump impulse - update.character.move_state = Fall(FallState); + update.character.move_state = Fall(Some(FallState)); return update; } } diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index fa56c53694..4b3902673d 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -54,6 +54,8 @@ use super::{ ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData, MoveState, MoveState::*, StateUpdate, }; +use std::time::Duration; + /// #### A trait for implementing state `handle()`ing logic. /// _Mimics the typical OOP style state machine pattern where states implement their own behavior, /// exit conditions, and return new states to the state machine upon exit. @@ -70,50 +72,49 @@ use super::{ /// `CharacterState` update `System` passes `EcsStateData` to `ActionState`/`MoveState` `handle()` which matches the character's /// current state to its `handle()` fn, hiding the implementation details, since the System is only concerned with /// how the update flow occurs and is in charge of updating the ECS components. -pub trait StateHandle { +pub trait StateHandler: Default { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate; } // Public interface that passes EcsStateData to `StateHandle`s `handle()` fn -impl StateHandle for ActionState { +impl ActionState { /// Passes handle to variant or subvariant handlers - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + pub fn update(&self, ecs_data: &EcsStateData) -> StateUpdate { match self { Attack(kind) => match kind { - BasicAttack(state) => state.handle(ecs_data), - Charge(state) => state.handle(ecs_data), + BasicAttack(Some(state)) => state.handle(&ecs_data), + Charge(Some(state)) => state.handle(&ecs_data), }, Block(kind) => match kind { - BasicBlock(state) => state.handle(ecs_data), + BasicBlock(Some(state)) => state.handle(&ecs_data), }, Dodge(kind) => match kind { - Roll(state) => state.handle(ecs_data), + Roll(Some(state)) => state.handle(&ecs_data), }, - Wield(state) => state.handle(ecs_data), - Idle(state) => state.handle(ecs_data), + Wield(Some(state)) => state.handle(&ecs_data), + Idle(Some(state)) => state.handle(&ecs_data), + // // All states should be explicitly handled // Do not use default match: _ => {}, } } -} -// Other fn's that relate to individual `ActionState`s -impl ActionState { /// Returns whether a given `ActionState` overrides `MoveState` `handle()`ing pub fn overrides_move_state(&self) -> bool { match self { Attack(kind) => match kind { - BasicAttack(state) => false, - Charge(state) => true, + BasicAttack(_) => false, + Charge(_) => true, }, Block(kind) => match kind { - BasicBlock(state) => true, + BasicBlock(_) => true, }, Dodge(kind) => match kind { - Roll(state) => true, + Roll(_) => true, }, - Wield(state) => false, - Idle(state) => false, + Wield(_) => false, + Idle(_) => false, + // // All states should be explicitly handled // Do not use default match: _ => {}, } @@ -125,33 +126,31 @@ impl MoveState { /// Returns whether a given `ActionState` overrides `MoveState` `handle()`ing pub fn overrides_action_state(&self) -> bool { match self { - Stand(state) => false, - Run(state) => false, - Jump(state) => false, - Climb(state) => true, - Glide(state) => true, - Swim(state) => false, - Fall(state) => false, - Sit(state) => true, + Stand(_) => false, + Run(_) => false, + Jump(_) => false, + Climb(_) => true, + Glide(_) => true, + Swim(_) => false, + Fall(_) => false, + Sit(_) => true, + // // All states should be explicitly handled // Do not use default match: _ => {}, } } -} -/// Public interface that passes EcsStateData to `StateHandle`s `handle()` fn -impl StateHandle for MoveState { /// Passes handle to variant handlers - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + pub fn update(&self, ecs_data: &EcsStateData) -> StateUpdate { match self { - Stand(state) => state.handle(&ecs_data), - Run(state) => state.handle(&ecs_data), - Jump(state) => state.handle(&ecs_data), - Climb(state) => state.handle(&ecs_data), - Glide(state) => state.handle(&ecs_data), - Swim(state) => state.handle(&ecs_data), - Fall(state) => state.handle(&ecs_data), - Sit(state) => state.handle(&ecs_data), + Stand(Some(state)) => state.handle(&ecs_data), + Run(Some(state)) => state.handle(&ecs_data), + Jump(Some(state)) => state.handle(&ecs_data), + Climb(Some(state)) => state.handle(&ecs_data), + Glide(Some(state)) => state.handle(&ecs_data), + Swim(Some(state)) => state.handle(&ecs_data), + Fall(Some(state)) => state.handle(&ecs_data), + Sit(Some(state)) => state.handle(&ecs_data), // All states should be explicitly handled // Do not use default match: _ => {}, } diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index 8f8ce40192..d7c62fce95 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -1,6 +1,6 @@ use super::ROLL_SPEED; -use crate::comp::{ActionState::*, DodgeKind::*, EcsStateData, StateHandle, StateUpdate}; -use crate::util::movement_utils::*; +use crate::comp::{ActionState::*, DodgeKind::*, EcsStateData, StateHandler, StateUpdate}; +use crate::util::state_utils::*; use std::time::Duration; use vek::Vec3; @@ -10,7 +10,7 @@ pub struct RollState { remaining_duration: Duration, } -impl StateHandle for RollState { +impl StateHandler for RollState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, @@ -40,12 +40,12 @@ impl StateHandle for RollState { } // Otherwise, tick down remaining_duration - update.character.action_state = Dodge(Roll(RollState { + update.character.action_state = Dodge(Roll(Some(RollState { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) .unwrap_or_default(), - })); + }))); // Keep rolling return update; diff --git a/common/src/comp/states/run.rs b/common/src/comp/states/run.rs index bc59b7f472..755e8b8e56 100644 --- a/common/src/comp/states/run.rs +++ b/common/src/comp/states/run.rs @@ -1,15 +1,15 @@ use super::{HUMANOID_ACCEL, HUMANOID_SPEED}; use crate::comp::{ - ClimbState, EcsStateData, GlideState, JumpState, MoveState::*, SitState, StateHandle, + ClimbState, EcsStateData, GlideState, JumpState, MoveState::*, SitState, StateHandler, StateUpdate, }; -use crate::util::movement_utils::*; +use crate::util::state_utils::*; use vek::vec::{Vec2, Vec3}; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct RunState; -impl StateHandle for RunState { +impl StateHandler for RunState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, @@ -46,25 +46,25 @@ impl StateHandle for RunState { // Try to sit if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Sit(SitState); + update.character.move_state = Sit(Some(SitState)); return update; } // Try to climb if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Climb(ClimbState); + update.character.move_state = Climb(Some(ClimbState)); return update; } // Try to jump if can_jump(ecs_data.physics, ecs_data.inputs) { - update.character.move_state = Jump(JumpState); + update.character.move_state = Jump(Some(JumpState)); return update; } // Try to glide if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Glide(GlideState); + update.character.move_state = Glide(Some(GlideState)); return update; } diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs index e1c4f5f389..58763c9e0d 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/comp/states/sit.rs @@ -1,13 +1,13 @@ use crate::comp::{ ActionState::*, EcsStateData, IdleState, JumpState, MoveState::*, RunState, StandState, - StateHandle, StateUpdate, + StateHandler, StateUpdate, }; -use crate::util::movement_utils::*; +use crate::util::state_utils::*; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct SitState; -impl StateHandle for SitState { +impl StateHandler for SitState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, @@ -17,8 +17,8 @@ impl StateHandle for SitState { }; // Prevent action state handling - update.character.action_state = Idle(IdleState); - update.character.move_state = Sit(SitState); + update.character.action_state = Idle(Some(IdleState)); + update.character.move_state = Sit(Some(SitState)); // Try to Fall // ... maybe the ground disappears, @@ -30,19 +30,19 @@ impl StateHandle for SitState { } // Try to jump if ecs_data.inputs.jump.is_pressed() { - update.character.move_state = Jump(JumpState); + update.character.move_state = Jump(Some(JumpState)); return update; } // Try to Run if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - update.character.move_state = Run(RunState); + update.character.move_state = Run(Some(RunState)); return update; } // Try to Stand if ecs_data.inputs.sit.is_just_pressed() { - update.character.move_state = Stand(StandState); + update.character.move_state = Stand(Some(StandState)); return update; } diff --git a/common/src/comp/states/stand.rs b/common/src/comp/states/stand.rs index dc16d73af2..d1c5a95574 100644 --- a/common/src/comp/states/stand.rs +++ b/common/src/comp/states/stand.rs @@ -1,13 +1,13 @@ use crate::comp::{ - ClimbState, EcsStateData, GlideState, JumpState, MoveState::*, SitState, StateHandle, + ClimbState, EcsStateData, GlideState, JumpState, MoveState::*, SitState, StateHandler, StateUpdate, }; -use crate::util::movement_utils::*; +use crate::util::state_utils::*; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct StandState; -impl StateHandle for StandState { +impl StateHandler for StandState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, @@ -18,25 +18,25 @@ impl StateHandle for StandState { // Try to sit if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Sit(SitState); + update.character.move_state = Sit(Some(SitState)); return update; } // Try to climb if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Climb(ClimbState); + update.character.move_state = Climb(Some(ClimbState)); return update; } // Try to jump if can_jump(ecs_data.physics, ecs_data.inputs) { - update.character.move_state = Jump(JumpState); + update.character.move_state = Jump(Some(JumpState)); return update; } // Check gliding if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Glide(GlideState); + update.character.move_state = Glide(Some(GlideState)); return update; } diff --git a/common/src/comp/states/swim.rs b/common/src/comp/states/swim.rs index ffaf1b2673..87f350cb58 100644 --- a/common/src/comp/states/swim.rs +++ b/common/src/comp/states/swim.rs @@ -1,12 +1,12 @@ use super::{HUMANOID_WATER_ACCEL, HUMANOID_WATER_SPEED}; -use crate::comp::{EcsStateData, MoveState::*, RunState, StandState, StateHandle, StateUpdate}; +use crate::comp::{EcsStateData, MoveState::*, RunState, StandState, StateHandler, StateUpdate}; use crate::sys::phys::GRAVITY; use vek::{Vec2, Vec3}; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct SwimState; -impl StateHandle for SwimState { +impl StateHandler for SwimState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, @@ -51,16 +51,16 @@ impl StateHandle for SwimState { // Not on ground if !ecs_data.physics.on_ground { - update.character.move_state = Swim(SwimState); + update.character.move_state = Swim(Some(SwimState)); return update; } // On ground else { // Return to running or standing based on move inputs update.character.move_state = if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - Run(RunState) + Run(Some(RunState)) } else { - Stand(StandState) + Stand(Some(StandState)) }; return update; diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index 3037755c3f..ddf91961f4 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -1,18 +1,18 @@ use crate::comp::{ - AbilityAction, AbilityActionKind::*, ActionState::*, EcsStateData, IdleState, StateHandle, + AbilityAction, AbilityActionKind::*, ActionState::*, EcsStateData, IdleState, StateHandler, StateUpdate, }; -use crate::util::movement_utils::*; +use crate::util::state_utils::*; use std::time::Duration; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct WieldState { /// How long before a new action can be performed /// after equipping pub equip_delay: Duration, } -impl StateHandle for WieldState { +impl StateHandler for WieldState { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, @@ -27,29 +27,29 @@ impl StateHandle for WieldState { if ecs_data.inputs.toggle_wield.is_just_pressed() && ecs_data.character.action_state.is_equip_finished() { - update.character.action_state = Idle(IdleState); + update.character.action_state = Idle(Some(IdleState)); return update; } // Try weapon actions if ecs_data.inputs.primary.is_pressed() { - ecs_data - .updater - .insert(*ecs_data.entity, AbilityAction(Primary)); + // ecs_data + // .updater + // .insert(*ecs_data.entity, AbilityAction(Primary)); } else if ecs_data.inputs.secondary.is_pressed() { - ecs_data - .updater - .insert(*ecs_data.entity, AbilityAction(Secondary)); + // ecs_data + // .updater + // .insert(*ecs_data.entity, AbilityAction(Secondary)); } } else { // Equip delay hasn't expired yet // Update wield delay - update.character.action_state = Wield(WieldState { + update.character.action_state = Wield(Some(WieldState { equip_delay: self .equip_delay .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) .unwrap_or_default(), - }); + })); } return update; diff --git a/common/src/sys/ability.rs b/common/src/sys/ability.rs index ed0b327032..4aa798e1bd 100644 --- a/common/src/sys/ability.rs +++ b/common/src/sys/ability.rs @@ -1,5 +1,8 @@ +#![allow(unused_imports)] +#![allow(dead_code)] use crate::comp::{ AbilityAction, AbilityActionKind, AbilityPool, ActionState::*, AttackKind, CharacterState, + StateHandler, }; use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; @@ -37,27 +40,27 @@ impl<'a> System<'a> for Sys { .join() { match ability_action.0 { - AbilityActionKind::Primary => { - if let Some(attack_kind) = ability_pool.primary { - character.action_state = Attack(attack_kind); - } - } - AbilityActionKind::Secondary => { - if let Some(attack_kind) = ability_pool.secondary { - character.action_state = Attack(attack_kind); - } - } - AbilityActionKind::Block => { - if let Some(block_kind) = ability_pool.block { - character.action_state = Block(block_kind); - } - } - AbilityActionKind::Dodge => { - if let Some(dodge_kind) = ability_pool.dodge { - character.action_state = Dodge(dodge_kind); - } - } - _ => {} + // AbilityActionKind::Primary => { + // if let Some(AttackKind(Some(attack_kind))) = ability_pool.primary { + // character.action_state = Attack(attack_kind::default()); + // } + // } + // AbilityActionKind::Secondary => { + // if let Some(attack_kind) = ability_pool.secondary { + // character.action_state = Attack(attack_kind::default()); + // } + // } + // AbilityActionKind::Block => { + // if let Some(block_kind) = ability_pool.block { + // character.action_state = Block(block_kind::default()); + // } + // } + // AbilityActionKind::Dodge => { + // if let Some(dodge_kind) = ability_pool.dodge { + // character.action_state = Dodge(dodge_kind::default()); + // } + // } + // _ => {} } } } diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index 52b1f1e149..23c850b490 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -163,7 +163,7 @@ impl<'a> System<'a> for Sys { inputs.roll.set_state(true); } - if target_character.move_state == Glide(GlideState) + if target_character.move_state == Glide(Some(GlideState)) && target_pos.0.z > pos.0.z + 5.0 { inputs.glide.set_state(true); diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 58baca6e33..82b85f2eb3 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ states::*, Body, CharacterState, Controller, EcsStateData, Mounting, MoveState::*, Ori, - OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, SitState, StateHandle, + OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, SitState, StateHandler, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, @@ -102,7 +102,7 @@ impl<'a> System<'a> for Sys { // If mounted, character state is controlled by mount // TODO: Make mounting a state if let Some(Mounting(_)) = mountings.get(entity) { - character.move_state = Sit(SitState); + character.move_state = Sit(Some(SitState)); return; } @@ -111,7 +111,7 @@ impl<'a> System<'a> for Sys { action_overrides.get(entity), character.action_state.overrides_move_state(), ) { - let state_update = character.action_state.handle(&EcsStateData { + let state_update = character.action_state.update(&EcsStateData { entity: &entity, uid, character, @@ -139,7 +139,7 @@ impl<'a> System<'a> for Sys { move_overrides.get(entity), character.move_state.overrides_action_state(), ) { - let state_update = character.move_state.handle(&EcsStateData { + let state_update = character.move_state.update(&EcsStateData { entity: &entity, uid, character, diff --git a/common/src/util/mod.rs b/common/src/util/mod.rs index 37ce1a120a..dc154db236 100644 --- a/common/src/util/mod.rs +++ b/common/src/util/mod.rs @@ -7,7 +7,7 @@ lazy_static::lazy_static! { use vek::{Mat3, Rgb, Rgba, Vec3}; -pub mod movement_utils; +pub mod state_utils; /// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. /// This is a fast approximation of powf. This should only be used when minor accuracy loss is acceptable. diff --git a/common/src/util/movement_utils.rs b/common/src/util/state_utils.rs similarity index 90% rename from common/src/util/movement_utils.rs rename to common/src/util/state_utils.rs index c9a503535e..02fd2de6f4 100644 --- a/common/src/util/movement_utils.rs +++ b/common/src/util/state_utils.rs @@ -11,11 +11,11 @@ use std::time::Duration; /// ... or Idle if nothing it possible?_ pub fn determine_primary_ability(stats: &Stats) -> ActionState { if let Some(Tool(data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { - Attack(BasicAttack(BasicAttackState { + Attack(BasicAttack(Some(BasicAttackState { remaining_duration: data.attack_duration(), - })) + }))) } else { - Idle(IdleState) + Idle(Some(IdleState)) } } @@ -24,11 +24,11 @@ pub fn determine_primary_ability(stats: &Stats) -> ActionState { /// ... or Idle if nothing it possible?_ pub fn determine_secondary_ability(stats: &Stats) -> ActionState { if let Some(Tool(data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { - Block(BasicBlock(BasicBlockState { + Block(BasicBlock(Some(BasicBlockState { active_duration: Duration::default(), - })) + }))) } else { - Idle(IdleState) + Idle(Some(IdleState)) } } @@ -36,18 +36,18 @@ pub fn determine_secondary_ability(stats: &Stats) -> ActionState { pub fn determine_fall_or_swim(physics: &PhysicsState) -> MoveState { // Check if in fluid to go to swimming or back to falling if physics.in_fluid { - Swim(SwimState) + Swim(Some(SwimState)) } else { - Fall(FallState) + Fall(Some(FallState)) } } /// __Returns a `MoveState` based on `move_dir` magnitude__ pub fn determine_stand_or_run(inputs: &ControllerInputs) -> MoveState { // Return to running or standing based on move inputs if inputs.move_dir.magnitude_squared() > 0.0 { - Run(RunState) + Run(Some(RunState)) } else { - Stand(StandState) + Stand(Some(StandState)) } } @@ -72,11 +72,11 @@ pub fn determine_move_from_grounded_state( /// __Returns an ActionState based on whether character has a weapon equipped.__ pub fn attempt_wield(stats: &Stats) -> ActionState { if let Some(Tool { .. }) = stats.equipment.main.as_ref().map(|i| &i.kind) { - Wield(WieldState { + Wield(Some(WieldState { equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), - }) + })) } else { - Idle(IdleState) + Idle(Some(IdleState)) } } From 8bf35a197bc4ed585b5477cf03cbd21747c920fc Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 5 Jan 2020 11:26:22 -0800 Subject: [PATCH 015/326] Update weapon .ron --- assets/common/items/weapons/starter_axe.ron | 2 ++ assets/common/items/weapons/starter_bow.ron | 2 ++ assets/common/items/weapons/starter_dagger.ron | 2 ++ assets/common/items/weapons/starter_hammer.ron | 2 ++ assets/common/items/weapons/starter_staff.ron | 2 ++ common/src/comp/states/mod.rs | 1 + 6 files changed, 11 insertions(+) diff --git a/assets/common/items/weapons/starter_axe.ron b/assets/common/items/weapons/starter_axe.ron index 1a02485aa4..9145b4a09a 100644 --- a/assets/common/items/weapons/starter_axe.ron +++ b/assets/common/items/weapons/starter_axe.ron @@ -7,6 +7,8 @@ Item( equip_time_millis: 1000, attack_buildup_millis: 700, attack_recover_millis: 100, + range: 3, + base_damage: 10, ) ), ) diff --git a/assets/common/items/weapons/starter_bow.ron b/assets/common/items/weapons/starter_bow.ron index beaff0229b..724824581a 100644 --- a/assets/common/items/weapons/starter_bow.ron +++ b/assets/common/items/weapons/starter_bow.ron @@ -7,6 +7,8 @@ Item( equip_time_millis: 800, attack_buildup_millis: 0, attack_recover_millis: 800, + range: 3, + base_damage: 10, ) ), ) diff --git a/assets/common/items/weapons/starter_dagger.ron b/assets/common/items/weapons/starter_dagger.ron index 57357db674..5d2c20c32e 100644 --- a/assets/common/items/weapons/starter_dagger.ron +++ b/assets/common/items/weapons/starter_dagger.ron @@ -7,6 +7,8 @@ Item( equip_time_millis: 300, attack_buildup_millis: 100, attack_recover_millis: 400, + range: 3, + base_damage: 10, ) ), ) diff --git a/assets/common/items/weapons/starter_hammer.ron b/assets/common/items/weapons/starter_hammer.ron index df8a369669..be0b2505f8 100644 --- a/assets/common/items/weapons/starter_hammer.ron +++ b/assets/common/items/weapons/starter_hammer.ron @@ -7,6 +7,8 @@ Item( equip_time_millis: 1000, attack_buildup_millis: 700, attack_recover_millis: 100, + range: 3, + base_damage: 10, ) ), ) diff --git a/assets/common/items/weapons/starter_staff.ron b/assets/common/items/weapons/starter_staff.ron index abb161df9c..e275179ded 100644 --- a/assets/common/items/weapons/starter_staff.ron +++ b/assets/common/items/weapons/starter_staff.ron @@ -7,6 +7,8 @@ Item( equip_time_millis: 800, attack_buildup_millis: 400, attack_recover_millis: 300, + range: 3, + base_damage: 10, ) ), ) diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index 4b3902673d..e53ec28313 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -151,6 +151,7 @@ impl MoveState { Swim(Some(state)) => state.handle(&ecs_data), Fall(Some(state)) => state.handle(&ecs_data), Sit(Some(state)) => state.handle(&ecs_data), + // // All states should be explicitly handled // Do not use default match: _ => {}, } From 4e5cf63452fcfcf45510f2f741edfde5c24eb8f7 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 5 Jan 2020 14:55:27 -0800 Subject: [PATCH 016/326] Clean Up Systems --- common/src/sys/ability.rs | 4 ++-- common/src/sys/cleanup.rs | 12 ------------ common/src/sys/mod.rs | 14 ++------------ 3 files changed, 4 insertions(+), 26 deletions(-) delete mode 100644 common/src/sys/cleanup.rs diff --git a/common/src/sys/ability.rs b/common/src/sys/ability.rs index 4aa798e1bd..25982ac854 100644 --- a/common/src/sys/ability.rs +++ b/common/src/sys/ability.rs @@ -39,7 +39,7 @@ impl<'a> System<'a> for Sys { ) .join() { - match ability_action.0 { + // match ability_action.0 { // AbilityActionKind::Primary => { // if let Some(AttackKind(Some(attack_kind))) = ability_pool.primary { // character.action_state = Attack(attack_kind::default()); @@ -61,7 +61,7 @@ impl<'a> System<'a> for Sys { // } // } // _ => {} - } + // } } } } diff --git a/common/src/sys/cleanup.rs b/common/src/sys/cleanup.rs deleted file mode 100644 index dd9f03867c..0000000000 --- a/common/src/sys/cleanup.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::comp::Controller; -use specs::{System, WriteStorage}; - -/// This system will allow NPCs to modify their controller -pub struct Sys; -impl<'a> System<'a> for Sys { - type SystemData = WriteStorage<'a, Controller>; - - fn run(&mut self, _controllers: Self::SystemData) { - // TODO: More stuff here - } -} diff --git a/common/src/sys/mod.rs b/common/src/sys/mod.rs index 64b39d750e..eeb7d72d12 100644 --- a/common/src/sys/mod.rs +++ b/common/src/sys/mod.rs @@ -1,8 +1,6 @@ mod ability; pub mod agent; pub mod character_state; -mod cleanup; -pub mod combat; pub mod controller; pub mod phys; mod projectile; @@ -18,22 +16,14 @@ const CHARACTER_STATE_SYS: &str = "character_state_sys"; const CONTROLLER_SYS: &str = "controller_sys"; const PHYS_SYS: &str = "phys_sys"; const PROJECTILE_SYS: &str = "projectile_sys"; -const COMBAT_SYS: &str = "combat_sys"; const STATS_SYS: &str = "stats_sys"; -const CLEANUP_SYS: &str = "cleanup_sys"; pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) { dispatch_builder.add(agent::Sys, AGENT_SYS, &[]); dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS]); dispatch_builder.add(character_state::Sys, CHARACTER_STATE_SYS, &[CONTROLLER_SYS]); dispatch_builder.add(ability::Sys, ABILITY_SYS, &[CHARACTER_STATE_SYS]); - dispatch_builder.add(combat::Sys, COMBAT_SYS, &[CONTROLLER_SYS]); - dispatch_builder.add(stats::Sys, STATS_SYS, &[COMBAT_SYS]); - dispatch_builder.add( - phys::Sys, - PHYS_SYS, - &[CONTROLLER_SYS, COMBAT_SYS, STATS_SYS], - ); + dispatch_builder.add(stats::Sys, STATS_SYS, &[]); + dispatch_builder.add(phys::Sys, PHYS_SYS, &[CONTROLLER_SYS, STATS_SYS]); dispatch_builder.add(projectile::Sys, PROJECTILE_SYS, &[PHYS_SYS]); - dispatch_builder.add(cleanup::Sys, CLEANUP_SYS, &[PHYS_SYS]); } From 542f06eef4fb19e864d896c0d4faa70308e0d126 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 5 Jan 2020 15:17:22 -0800 Subject: [PATCH 017/326] Add new() to states --- common/src/comp/inventory/item.rs | 8 +- common/src/comp/states/basic_attack.rs | 16 +++- common/src/comp/states/basic_block.rs | 6 ++ common/src/comp/states/charge_attack.rs | 14 +++- common/src/comp/states/climb.rs | 4 + common/src/comp/states/fall.rs | 4 + common/src/comp/states/glide.rs | 4 + common/src/comp/states/idle.rs | 10 ++- common/src/comp/states/jump.rs | 4 + common/src/comp/states/mod.rs | 102 +++++++++++++++++++----- common/src/comp/states/roll.rs | 16 +++- common/src/comp/states/run.rs | 4 + common/src/comp/states/sit.rs | 4 + common/src/comp/states/stand.rs | 4 + common/src/comp/states/swim.rs | 4 + common/src/comp/states/wield.rs | 16 +++- 16 files changed, 191 insertions(+), 29 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 98547f2b8e..180cbf8b86 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -28,6 +28,12 @@ pub enum ToolKind { Debug(Debug), } +impl Default for ToolKind { + fn default() -> Self { + Self::Axe + } +} + impl ToolData { pub fn equip_time(&self) -> Duration { Duration::from_millis(self.equip_time_millis) @@ -83,7 +89,7 @@ pub enum Ingredient { Grass, } -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct ToolData { pub kind: ToolKind, equip_time_millis: u64, diff --git a/common/src/comp/states/basic_attack.rs b/common/src/comp/states/basic_attack.rs index b8fbb8a09a..e090334823 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/comp/states/basic_attack.rs @@ -1,6 +1,6 @@ use crate::comp::{ - ActionState::Attack, AttackKind::BasicAttack, EcsStateData, MoveState, StateHandler, - StateUpdate, ToolData, + ActionState::Attack, AttackKind::BasicAttack, EcsStateData, ItemKind::Tool, MoveState, + StateHandler, StateUpdate, ToolData, }; use crate::util::state_utils::*; use std::time::Duration; @@ -12,6 +12,18 @@ pub struct BasicAttackState { } impl StateHandler for BasicAttackState { + fn new(ecs_data: &EcsStateData) -> Self { + let tool_data = + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + data + } else { + &ToolData::default() + }; + Self { + remaining_duration: tool_data.attack_duration(), + } + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs index 6d62a55ada..a18e10ffc5 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/comp/states/basic_block.rs @@ -11,6 +11,12 @@ pub struct BasicBlockState { } impl StateHandler for BasicBlockState { + fn new(ecs_data: &EcsStateData) -> Self { + Self { + active_duration: Duration::default(), + } + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs index dd6854809d..c13c4853f8 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/comp/states/charge_attack.rs @@ -1,6 +1,6 @@ use crate::comp::{ ActionState::Attack, AttackKind::Charge, EcsStateData, HealthChange, HealthSource, - MoveState::Run, RunState, StateHandler, StateUpdate, + ItemKind::Tool, MoveState::Run, RunState, StateHandler, StateUpdate, ToolData, }; use crate::event::ServerEvent; use crate::util::state_utils::*; @@ -16,6 +16,18 @@ pub struct ChargeAttackState { } impl StateHandler for ChargeAttackState { + fn new(ecs_data: &EcsStateData) -> Self { + let tool_data = + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + data + } else { + &ToolData::default() + }; + Self { + remaining_duration: tool_data.attack_duration(), + } + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, diff --git a/common/src/comp/states/climb.rs b/common/src/comp/states/climb.rs index e315e7c5e2..4901084947 100644 --- a/common/src/comp/states/climb.rs +++ b/common/src/comp/states/climb.rs @@ -11,6 +11,10 @@ use vek::Lerp; pub struct ClimbState; impl StateHandler for ClimbState { + fn new(ecs_data: &EcsStateData) -> Self { + Self {} + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, diff --git a/common/src/comp/states/fall.rs b/common/src/comp/states/fall.rs index 09619fae0e..252b208153 100644 --- a/common/src/comp/states/fall.rs +++ b/common/src/comp/states/fall.rs @@ -8,6 +8,10 @@ use vek::{Vec2, Vec3}; pub struct FallState; impl StateHandler for FallState { + fn new(ecs_data: &EcsStateData) -> Self { + Self {} + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, diff --git a/common/src/comp/states/glide.rs b/common/src/comp/states/glide.rs index 768adbc0b5..77ea626849 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/comp/states/glide.rs @@ -9,6 +9,10 @@ use vek::{Vec2, Vec3}; pub struct GlideState; impl StateHandler for GlideState { + fn new(ecs_data: &EcsStateData) -> Self { + Self {} + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, diff --git a/common/src/comp/states/idle.rs b/common/src/comp/states/idle.rs index 5f41308f34..6acb80357d 100644 --- a/common/src/comp/states/idle.rs +++ b/common/src/comp/states/idle.rs @@ -8,6 +8,10 @@ use std::time::Duration; pub struct IdleState; impl StateHandler for IdleState { + fn new(ecs_data: &EcsStateData) -> Self { + Self {} + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, @@ -22,10 +26,10 @@ impl StateHandler for IdleState { || (ecs_data.inputs.toggle_wield.is_just_pressed() && update.character.action_state.is_equip_finished()) { - if let Some(Tool { .. }) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { update.character.action_state = Wield(Some(WieldState { - equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), - })) + equip_delay: data.equip_time(), + })); } // else unarmed stuff? diff --git a/common/src/comp/states/jump.rs b/common/src/comp/states/jump.rs index 5581c4d796..f2aea7e393 100644 --- a/common/src/comp/states/jump.rs +++ b/common/src/comp/states/jump.rs @@ -5,6 +5,10 @@ use crate::event::LocalEvent; pub struct JumpState; impl StateHandler for JumpState { + fn new(ecs_data: &EcsStateData) -> Self { + Self {} + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index e53ec28313..4a0cac5477 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -54,7 +54,6 @@ use super::{ ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData, MoveState, MoveState::*, StateUpdate, }; -use std::time::Duration; /// #### A trait for implementing state `handle()`ing logic. /// _Mimics the typical OOP style state machine pattern where states implement their own behavior, @@ -74,25 +73,54 @@ use std::time::Duration; /// how the update flow occurs and is in charge of updating the ECS components. pub trait StateHandler: Default { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate; + fn new(ecs_data: &EcsStateData) -> Self; } -// Public interface that passes EcsStateData to `StateHandle`s `handle()` fn +// fn's relating to individual `ActionState`s +// or passing data from system to handlers impl ActionState { - /// Passes handle to variant or subvariant handlers + /// Passes data to variant or subvariant handlers + /// States contain `Option`s, and will be + /// `None` if state data has not been initialized. So we have to + /// check and intialize new state data if so. pub fn update(&self, ecs_data: &EcsStateData) -> StateUpdate { match self { Attack(kind) => match kind { - BasicAttack(Some(state)) => state.handle(&ecs_data), - Charge(Some(state)) => state.handle(&ecs_data), + BasicAttack(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| BasicAttackState::new(ecs_data)) + // Call handler + .handle(ecs_data), + Charge(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| ChargeAttackState::new(ecs_data)) + // Call handler + .handle(ecs_data), }, Block(kind) => match kind { - BasicBlock(Some(state)) => state.handle(&ecs_data), + BasicBlock(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| BasicBlockState::new(ecs_data)) + // Call handler + .handle(ecs_data), }, Dodge(kind) => match kind { - Roll(Some(state)) => state.handle(&ecs_data), + Roll(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| RollState::new(ecs_data)) + // Call handler + .handle(ecs_data), }, - Wield(Some(state)) => state.handle(&ecs_data), - Idle(Some(state)) => state.handle(&ecs_data), + Wield(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| WieldState::new(ecs_data)) + // Call handler + .handle(ecs_data), + Idle(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| IdleState::new(ecs_data)) + // Call handler + .handle(ecs_data), // // All states should be explicitly handled // Do not use default match: _ => {}, @@ -121,9 +149,13 @@ impl ActionState { } } -// Other fn's that relate to individual `MoveState`s +// fn's that relate to individual `MoveState`s +// or passing data from system to handlers impl MoveState { - /// Returns whether a given `ActionState` overrides `MoveState` `handle()`ing + /// Passes data to variant or subvariant handlers + /// States contain `Option`s, and will be + /// `None` if state data has not been initialized. So we have to + /// check and intialize new state data if so. pub fn overrides_action_state(&self) -> bool { match self { Stand(_) => false, @@ -143,14 +175,46 @@ impl MoveState { /// Passes handle to variant handlers pub fn update(&self, ecs_data: &EcsStateData) -> StateUpdate { match self { - Stand(Some(state)) => state.handle(&ecs_data), - Run(Some(state)) => state.handle(&ecs_data), - Jump(Some(state)) => state.handle(&ecs_data), - Climb(Some(state)) => state.handle(&ecs_data), - Glide(Some(state)) => state.handle(&ecs_data), - Swim(Some(state)) => state.handle(&ecs_data), - Fall(Some(state)) => state.handle(&ecs_data), - Sit(Some(state)) => state.handle(&ecs_data), + Stand(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| StandState::new(ecs_data)) + // Call handler + .handle(ecs_data), + Run(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| RunState::new(ecs_data)) + // Call handler + .handle(ecs_data), + Jump(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| JumpState::new(ecs_data)) + // Call handler + .handle(ecs_data), + Climb(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| ClimbState::new(ecs_data)) + // Call handler + .handle(ecs_data), + Glide(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| GlideState::new(ecs_data)) + // Call handler + .handle(ecs_data), + Swim(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| SwimState::new(ecs_data)) + // Call handler + .handle(ecs_data), + Fall(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| FallState::new(ecs_data)) + // Call handler + .handle(ecs_data), + Sit(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| SitState::new(ecs_data)) + // Call handler + .handle(ecs_data), // // All states should be explicitly handled // Do not use default match: _ => {}, diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index d7c62fce95..1d4f01fbcc 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -1,5 +1,7 @@ use super::ROLL_SPEED; -use crate::comp::{ActionState::*, DodgeKind::*, EcsStateData, StateHandler, StateUpdate}; +use crate::comp::{ + ActionState::*, DodgeKind::*, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData, +}; use crate::util::state_utils::*; use std::time::Duration; use vek::Vec3; @@ -11,6 +13,18 @@ pub struct RollState { } impl StateHandler for RollState { + fn new(ecs_data: &EcsStateData) -> Self { + let tool_data = + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + data + } else { + &ToolData::default() + }; + Self { + remaining_duration: tool_data.attack_duration(), + } + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, diff --git a/common/src/comp/states/run.rs b/common/src/comp/states/run.rs index 755e8b8e56..94bdf7dc85 100644 --- a/common/src/comp/states/run.rs +++ b/common/src/comp/states/run.rs @@ -10,6 +10,10 @@ use vek::vec::{Vec2, Vec3}; pub struct RunState; impl StateHandler for RunState { + fn new(ecs_data: &EcsStateData) -> Self { + Self {} + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs index 58763c9e0d..99f567bdec 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/comp/states/sit.rs @@ -8,6 +8,10 @@ use crate::util::state_utils::*; pub struct SitState; impl StateHandler for SitState { + fn new(ecs_data: &EcsStateData) -> Self { + Self {} + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, diff --git a/common/src/comp/states/stand.rs b/common/src/comp/states/stand.rs index d1c5a95574..7c81839f2c 100644 --- a/common/src/comp/states/stand.rs +++ b/common/src/comp/states/stand.rs @@ -8,6 +8,10 @@ use crate::util::state_utils::*; pub struct StandState; impl StateHandler for StandState { + fn new(ecs_data: &EcsStateData) -> Self { + Self {} + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, diff --git a/common/src/comp/states/swim.rs b/common/src/comp/states/swim.rs index 87f350cb58..ccb3022e5d 100644 --- a/common/src/comp/states/swim.rs +++ b/common/src/comp/states/swim.rs @@ -7,6 +7,10 @@ use vek::{Vec2, Vec3}; pub struct SwimState; impl StateHandler for SwimState { + fn new(ecs_data: &EcsStateData) -> Self { + Self {} + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index ddf91961f4..d2217057e4 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -1,6 +1,6 @@ use crate::comp::{ - AbilityAction, AbilityActionKind::*, ActionState::*, EcsStateData, IdleState, StateHandler, - StateUpdate, + AbilityAction, AbilityActionKind::*, ActionState::*, EcsStateData, IdleState, ItemKind::Tool, + StateHandler, StateUpdate, ToolData, }; use crate::util::state_utils::*; use std::time::Duration; @@ -13,6 +13,18 @@ pub struct WieldState { } impl StateHandler for WieldState { + fn new(ecs_data: &EcsStateData) -> Self { + let tool_data = + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + data + } else { + &ToolData::default() + }; + Self { + equip_delay: tool_data.equip_time(), + } + } + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, From 5bba0a96fc4e487b469b03a4c6c0c8571357f21d Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 5 Jan 2020 15:21:37 -0800 Subject: [PATCH 018/326] Fix refs --- common/src/comp/inventory/item.rs | 10 +++++----- common/src/comp/states/basic_attack.rs | 4 ++-- common/src/comp/states/charge_attack.rs | 4 ++-- common/src/comp/states/roll.rs | 4 ++-- common/src/comp/states/wield.rs | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 180cbf8b86..b8a222753b 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -55,7 +55,7 @@ pub enum Debug { Possess, } -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Armor { // TODO: Don't make armor be a body part. Wearing enemy's head is funny but also a creepy thing to do. Helmet, @@ -72,7 +72,7 @@ pub enum Armor { } //TODO: Do we even need this? -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Consumable { Apple, Cheese, @@ -83,13 +83,13 @@ pub enum Consumable { PotionMinor, } -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Ingredient { Flower, Grass, } -#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct ToolData { pub kind: ToolKind, equip_time_millis: u64, @@ -99,7 +99,7 @@ pub struct ToolData { base_damage: u64, } -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ItemKind { Tool(ToolData), Armor { kind: Armor, power: u32 }, diff --git a/common/src/comp/states/basic_attack.rs b/common/src/comp/states/basic_attack.rs index e090334823..5b95693c16 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/comp/states/basic_attack.rs @@ -14,10 +14,10 @@ pub struct BasicAttackState { impl StateHandler for BasicAttackState { fn new(ecs_data: &EcsStateData) -> Self { let tool_data = - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { data } else { - &ToolData::default() + ToolData::default() }; Self { remaining_duration: tool_data.attack_duration(), diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs index c13c4853f8..9e977ab755 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/comp/states/charge_attack.rs @@ -18,10 +18,10 @@ pub struct ChargeAttackState { impl StateHandler for ChargeAttackState { fn new(ecs_data: &EcsStateData) -> Self { let tool_data = - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { data } else { - &ToolData::default() + ToolData::default() }; Self { remaining_duration: tool_data.attack_duration(), diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index 1d4f01fbcc..560fbd7e36 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -15,10 +15,10 @@ pub struct RollState { impl StateHandler for RollState { fn new(ecs_data: &EcsStateData) -> Self { let tool_data = - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { data } else { - &ToolData::default() + ToolData::default() }; Self { remaining_duration: tool_data.attack_duration(), diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index d2217057e4..d2462193a9 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -15,10 +15,10 @@ pub struct WieldState { impl StateHandler for WieldState { fn new(ecs_data: &EcsStateData) -> Self { let tool_data = - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { data } else { - &ToolData::default() + ToolData::default() }; Self { equip_delay: tool_data.equip_time(), From 4e18ffe6c283768af88785040e9ecd29b6dd1a70 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 5 Jan 2020 15:26:04 -0800 Subject: [PATCH 019/326] RUIN the comments --- common/src/comp/states/mod.rs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index 4a0cac5477..8e6ff91049 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -92,34 +92,24 @@ impl ActionState { // Call handler .handle(ecs_data), Charge(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| ChargeAttackState::new(ecs_data)) - // Call handler .handle(ecs_data), }, Block(kind) => match kind { BasicBlock(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| BasicBlockState::new(ecs_data)) - // Call handler .handle(ecs_data), }, Dodge(kind) => match kind { Roll(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| RollState::new(ecs_data)) - // Call handler .handle(ecs_data), }, Wield(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| WieldState::new(ecs_data)) - // Call handler .handle(ecs_data), Idle(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| IdleState::new(ecs_data)) - // Call handler .handle(ecs_data), // // All states should be explicitly handled @@ -181,39 +171,25 @@ impl MoveState { // Call handler .handle(ecs_data), Run(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| RunState::new(ecs_data)) - // Call handler .handle(ecs_data), Jump(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| JumpState::new(ecs_data)) - // Call handler .handle(ecs_data), Climb(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| ClimbState::new(ecs_data)) - // Call handler .handle(ecs_data), Glide(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| GlideState::new(ecs_data)) - // Call handler .handle(ecs_data), Swim(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| SwimState::new(ecs_data)) - // Call handler .handle(ecs_data), Fall(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| FallState::new(ecs_data)) - // Call handler .handle(ecs_data), Sit(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| SitState::new(ecs_data)) - // Call handler .handle(ecs_data), // // All states should be explicitly handled From dc33f6ad6a0eb8cacb3a8999fcea904d935be5e5 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 5 Jan 2020 15:28:20 -0800 Subject: [PATCH 020/326] Ruin them again (the comments) --- common/src/comp/states/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index 8e6ff91049..90f0c56834 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -111,7 +111,6 @@ impl ActionState { Idle(opt_state) => opt_state .unwrap_or_else(|| IdleState::new(ecs_data)) .handle(ecs_data), - // // All states should be explicitly handled // Do not use default match: _ => {}, } @@ -132,7 +131,6 @@ impl ActionState { }, Wield(_) => false, Idle(_) => false, - // // All states should be explicitly handled // Do not use default match: _ => {}, } @@ -156,7 +154,6 @@ impl MoveState { Swim(_) => false, Fall(_) => false, Sit(_) => true, - // // All states should be explicitly handled // Do not use default match: _ => {}, } @@ -191,7 +188,6 @@ impl MoveState { Sit(opt_state) => opt_state .unwrap_or_else(|| SitState::new(ecs_data)) .handle(ecs_data), - // // All states should be explicitly handled // Do not use default match: _ => {}, } From 8648641362e55d4d047ed87f4b58b57bc62898ee Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Tue, 7 Jan 2020 07:49:08 -0800 Subject: [PATCH 021/326] Grooming --- common/src/comp/ability.rs | 2 +- common/src/comp/states/basic_attack.rs | 4 +- common/src/comp/states/basic_block.rs | 6 +- common/src/comp/states/charge_attack.rs | 6 +- common/src/comp/states/climb.rs | 57 +++--- common/src/comp/states/fall.rs | 12 +- common/src/comp/states/glide.rs | 53 +++--- common/src/comp/states/idle.rs | 14 +- common/src/comp/states/jump.rs | 6 +- common/src/comp/states/mod.rs | 131 +++++++++---- common/src/comp/states/roll.rs | 3 +- common/src/comp/states/run.rs | 19 +- common/src/comp/states/sit.rs | 17 +- common/src/comp/states/stand.rs | 15 +- common/src/comp/states/swim.rs | 14 +- common/src/comp/states/wield.rs | 4 +- common/src/msg/ecs_packet.rs | 4 + common/src/state.rs | 2 + common/src/sys/ability.rs | 4 +- common/src/sys/character_state.rs | 26 +-- common/src/sys/movement.rs | 236 ------------------------ common/src/util/state_utils.rs | 19 +- voxygen/src/audio/sfx/event_mapper.rs | 48 ++--- voxygen/src/hud/skillbar.rs | 6 +- 24 files changed, 252 insertions(+), 456 deletions(-) delete mode 100644 common/src/sys/movement.rs diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 53c1a0ce4e..baf6fe24af 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -30,5 +30,5 @@ pub struct AbilityPool { } impl Component for AbilityPool { - type Storage = HashMapStorage; + type Storage = FlaggedStorage>; } diff --git a/common/src/comp/states/basic_attack.rs b/common/src/comp/states/basic_attack.rs index 5b95693c16..725e8acc93 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/comp/states/basic_attack.rs @@ -1,6 +1,6 @@ use crate::comp::{ - ActionState::Attack, AttackKind::BasicAttack, EcsStateData, ItemKind::Tool, MoveState, - StateHandler, StateUpdate, ToolData, + ActionState::Attack, AttackKind::BasicAttack, EcsStateData, ItemKind::Tool, StateHandler, + StateUpdate, ToolData, }; use crate::util::state_utils::*; use std::time::Duration; diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs index a18e10ffc5..053c837015 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/comp/states/basic_block.rs @@ -1,9 +1,11 @@ -use super::{BLOCK_ACCEL, BLOCK_SPEED}; use crate::comp::{EcsStateData, StateHandler, StateUpdate}; use crate::util::state_utils::*; use std::time::Duration; use vek::Vec2; +const BLOCK_ACCEL: f32 = 30.0; +const BLOCK_SPEED: f32 = 75.0; + #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct BasicBlockState { /// How long the blocking state has been active @@ -11,7 +13,7 @@ pub struct BasicBlockState { } impl StateHandler for BasicBlockState { - fn new(ecs_data: &EcsStateData) -> Self { + fn new(_ecs_data: &EcsStateData) -> Self { Self { active_duration: Duration::default(), } diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs index 9e977ab755..ea4420f3f9 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/comp/states/charge_attack.rs @@ -1,13 +1,13 @@ use crate::comp::{ ActionState::Attack, AttackKind::Charge, EcsStateData, HealthChange, HealthSource, - ItemKind::Tool, MoveState::Run, RunState, StateHandler, StateUpdate, ToolData, + ItemKind::Tool, MoveState::Run, StateHandler, StateUpdate, ToolData, }; use crate::event::ServerEvent; use crate::util::state_utils::*; use std::time::Duration; use vek::Vec3; -use super::CHARGE_SPEED; +const CHARGE_SPEED: f32 = 20.0; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct ChargeAttackState { @@ -37,7 +37,7 @@ impl StateHandler for ChargeAttackState { }; // Prevent move state handling, handled here - update.character.move_state = Run(Some(RunState)); + update.character.move_state = Run(None); // Move player update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) diff --git a/common/src/comp/states/climb.rs b/common/src/comp/states/climb.rs index 4901084947..9b1df0a52a 100644 --- a/common/src/comp/states/climb.rs +++ b/common/src/comp/states/climb.rs @@ -1,17 +1,16 @@ -use super::{ - ActionState::*, EcsStateData, FallState, IdleState, JumpState, MoveState::*, StandState, - StateHandler, StateUpdate, -}; -use super::{CLIMB_SPEED, HUMANOID_CLIMB_ACCEL, HUMANOID_SPEED}; +use super::{ActionState::*, EcsStateData, MoveState::*, StateHandler, StateUpdate}; use crate::sys::phys::GRAVITY; use vek::vec::{Vec2, Vec3}; use vek::Lerp; +const HUMANOID_CLIMB_ACCEL: f32 = 5.0; +const CLIMB_SPEED: f32 = 5.0; + #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct ClimbState; impl StateHandler for ClimbState { - fn new(ecs_data: &EcsStateData) -> Self { + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } @@ -23,12 +22,33 @@ impl StateHandler for ClimbState { character: *ecs_data.character, }; - update.character.action_state = Idle(Some(IdleState)); + update.character.action_state = Idle(None); + + // If no wall is in front of character ... + if let None = ecs_data.physics.on_wall { + if ecs_data.inputs.jump.is_pressed() { + // They've climbed atop something, give them a boost + update.character.move_state = Jump(None); + + return update; + } else { + // Just fall off + update.character.move_state = Fall(None); + + return update; + } + } + + // Remove climb state on ground, otherwise character will get stuck + if ecs_data.physics.on_ground { + update.character.move_state = Stand(None); + return update; + } // Move player update.vel.0 += Vec2::broadcast(ecs_data.dt.0) * ecs_data.inputs.move_dir - * if update.vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { + * if update.vel.0.magnitude_squared() < CLIMB_SPEED.powf(2.0) { HUMANOID_CLIMB_ACCEL } else { 0.0 @@ -78,27 +98,6 @@ impl StateHandler for ClimbState { } } - // If no wall is infront of character ... - if let None = ecs_data.physics.on_wall { - if ecs_data.inputs.jump.is_pressed() { - // They've climbed atop something, give them a boost - update.character.move_state = Jump(Some(JumpState)); - - return update; - } else { - // Just fall off - update.character.move_state = Fall(Some(FallState)); - - return update; - } - } - - // Remove climb state on ground, otherwise character will get stuck - if ecs_data.physics.on_ground { - update.character.move_state = Stand(Some(StandState)); - return update; - } - return update; } } diff --git a/common/src/comp/states/fall.rs b/common/src/comp/states/fall.rs index 252b208153..55c72c3e97 100644 --- a/common/src/comp/states/fall.rs +++ b/common/src/comp/states/fall.rs @@ -1,14 +1,16 @@ -use super::{HUMANOID_AIR_ACCEL, HUMANOID_AIR_SPEED}; -use crate::comp::{ClimbState, EcsStateData, GlideState, MoveState::*, StateHandler, StateUpdate}; +use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; use crate::util::state_utils::*; use vek::{Vec2, Vec3}; +const HUMANOID_AIR_ACCEL: f32 = 10.0; +const HUMANOID_AIR_SPEED: f32 = 100.0; + #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct FallState; impl StateHandler for FallState { - fn new(ecs_data: &EcsStateData) -> Self { + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } @@ -48,13 +50,13 @@ impl StateHandler for FallState { // Check to start climbing if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Climb(Some(ClimbState)); + update.character.move_state = Climb(None); return update; } // Check gliding if ecs_data.inputs.glide.is_pressed() { - update.character.move_state = Glide(Some(GlideState)); + update.character.move_state = Glide(None); return update; } diff --git a/common/src/comp/states/glide.rs b/common/src/comp/states/glide.rs index 77ea626849..4060b6c4f4 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/comp/states/glide.rs @@ -1,15 +1,16 @@ -use super::{GLIDE_ACCEL, GLIDE_ANTIGRAV, GLIDE_SPEED}; -use crate::comp::{ - ActionState::*, ClimbState, EcsStateData, FallState, IdleState, MoveState::*, StandState, - StateHandler, StateUpdate, -}; +use crate::comp::{ActionState::*, EcsStateData, MoveState::*, StateHandler, StateUpdate}; use vek::{Vec2, Vec3}; +// Gravity is 9.81 * 4, so this makes gravity equal to .15 +const GLIDE_ANTIGRAV: f32 = crate::sys::phys::GRAVITY * 0.96; +const GLIDE_ACCEL: f32 = 15.0; +const GLIDE_SPEED: f32 = 45.0; + #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct GlideState; impl StateHandler for GlideState { - fn new(ecs_data: &EcsStateData) -> Self { + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } @@ -22,8 +23,26 @@ impl StateHandler for GlideState { }; // Defaults for this state - update.character.action_state = Idle(Some(IdleState)); - update.character.move_state = Glide(Some(GlideState)); + update.character.action_state = Idle(None); + update.character.move_state = Glide(None); + + // If glide button isn't held, start falling + if !ecs_data.inputs.glide.is_pressed() { + update.character.move_state = Fall(None); + return update; + } + + // If there is a wall in front of character go to climb + if let Some(_wall_dir) = ecs_data.physics.on_wall { + update.character.move_state = Climb(None); + return update; + } + + // If on ground go to stand + if ecs_data.physics.on_ground { + update.character.move_state = Stand(None); + return update; + } // Move player according to movement direction vector update.vel.0 += Vec2::broadcast(ecs_data.dt.0) @@ -56,24 +75,6 @@ impl StateHandler for GlideState { .max(0.2); } - // If glide button isn't held, start falling - if !ecs_data.inputs.glide.is_pressed() { - update.character.move_state = Fall(Some(FallState)); - return update; - } - - // If there is a wall in front of character go to climb - if let Some(_wall_dir) = ecs_data.physics.on_wall { - update.character.move_state = Climb(Some(ClimbState)); - return update; - } - - // If on ground go to stand - if ecs_data.physics.on_ground { - update.character.move_state = Stand(Some(StandState)); - return update; - } - // Otherwise keep gliding return update; } diff --git a/common/src/comp/states/idle.rs b/common/src/comp/states/idle.rs index 6acb80357d..2cfa12ad91 100644 --- a/common/src/comp/states/idle.rs +++ b/common/src/comp/states/idle.rs @@ -1,14 +1,10 @@ -use super::TEMP_EQUIP_DELAY; -use crate::comp::{ - ActionState::Wield, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, WieldState, -}; -use std::time::Duration; +use crate::comp::{ActionState::Wield, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate}; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct IdleState; impl StateHandler for IdleState { - fn new(ecs_data: &EcsStateData) -> Self { + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } @@ -26,10 +22,8 @@ impl StateHandler for IdleState { || (ecs_data.inputs.toggle_wield.is_just_pressed() && update.character.action_state.is_equip_finished()) { - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { - update.character.action_state = Wield(Some(WieldState { - equip_delay: data.equip_time(), - })); + if let Some(Tool(_)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + update.character.action_state = Wield(None); } // else unarmed stuff? diff --git a/common/src/comp/states/jump.rs b/common/src/comp/states/jump.rs index f2aea7e393..16bf65b534 100644 --- a/common/src/comp/states/jump.rs +++ b/common/src/comp/states/jump.rs @@ -1,11 +1,11 @@ -use super::{EcsStateData, FallState, MoveState::*, StateHandler, StateUpdate}; +use super::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; use crate::event::LocalEvent; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct JumpState; impl StateHandler for JumpState { - fn new(ecs_data: &EcsStateData) -> Self { + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } @@ -23,7 +23,7 @@ impl StateHandler for JumpState { .emit(LocalEvent::Jump(*ecs_data.entity)); // Immediately go to falling state after jump impulse - update.character.move_state = Fall(Some(FallState)); + update.character.move_state = Fall(None); return update; } } diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index 90f0c56834..805c8e31dd 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -30,47 +30,106 @@ pub use stand::*; pub use swim::*; pub use wield::*; -// TODO: Attach these to racial components and/or ecs resources -pub const HUMANOID_ACCEL: f32 = 50.0; -pub const HUMANOID_SPEED: f32 = 120.0; -pub const HUMANOID_AIR_ACCEL: f32 = 10.0; -pub const HUMANOID_AIR_SPEED: f32 = 100.0; -pub const HUMANOID_WATER_ACCEL: f32 = 70.0; -pub const HUMANOID_WATER_SPEED: f32 = 120.0; -pub const HUMANOID_CLIMB_ACCEL: f32 = 5.0; -pub const ROLL_SPEED: f32 = 17.0; -pub const CHARGE_SPEED: f32 = 20.0; -pub const GLIDE_ACCEL: f32 = 15.0; -pub const GLIDE_SPEED: f32 = 45.0; -pub const BLOCK_ACCEL: f32 = 30.0; -pub const BLOCK_SPEED: f32 = 75.0; -pub const TEMP_EQUIP_DELAY: u64 = 100; -// Gravity is 9.81 * 4, so this makes gravity equal to .15 -pub const GLIDE_ANTIGRAV: f32 = crate::sys::phys::GRAVITY * 0.96; -pub const CLIMB_SPEED: f32 = 5.0; -pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; - use super::{ ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData, MoveState, MoveState::*, StateUpdate, }; -/// #### A trait for implementing state `handle()`ing logic. -/// _Mimics the typical OOP style state machine pattern where states implement their own behavior, -/// exit conditions, and return new states to the state machine upon exit. -/// This is still performant and consistent with ECS data-behavior-separation constraint -/// since trait fn's are syntactic sugar for static fn's that accept their implementor's -/// object type as its first parameter. This allows for several benefits over implementing -/// each state's behavior within the `CharacterState` update `System` itself:_ -/// -/// 1. Less cognitive overhead: State's handling logic is next to the its data, and component (inside the state's .rs file). -/// 2. Separation of concerns (between states): all logic within a state's `handle()` is relevant only to that state. -/// States can be added/editted without concerns of affecting other state's logic. -/// 3. Clearly defined API and pattern: All states accept the same `EcsStateData` struct, which can be added to as necessary, -/// without the need for updating every state's implementation. All states return the same `StateUpdate` component. -/// `CharacterState` update `System` passes `EcsStateData` to `ActionState`/`MoveState` `handle()` which matches the character's -/// current state to its `handle()` fn, hiding the implementation details, since the System is only concerned with -/// how the update flow occurs and is in charge of updating the ECS components. +/// ## A type for implementing State Handling Behavior. +/// +/// Called by state machines' update functions to allow current states to handle updating +/// their parent machine's current state. +/// +/// Structures must implement a `handle()` fn to handle update behavior, and a `new()` for +/// instantiating new instances of a state. `handle()` function recieves `EcsStateData`, a struct +/// of readonly ECS Component data, and returns a `StateUpdate` tuple, with new components that will +/// overwrite an entitie's old components. +/// +/// ## Example Implementation: +/// ``` +/// use crate::comp::{ +/// ClimbState, EcsStateData, GlideState, JumpState, MoveState::*, SitState, StateHandler, +/// StateUpdate, +/// }; +/// use crate::util::state_utils::* +/// #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +/// pub struct RunState { +/// active_duration: Duration, +/// } +/// +/// impl StateHandler for RunState { +/// fn new(ecs_data: &EcsStateData) -> Self { +/// Self { +/// active_duration: Duration::default(), +/// } +/// } +/// +/// fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { +/// let mut update = StateUpdate { +/// character: *ecs_data.character, +/// pos: *ecs_data.pos, +/// vel: *ecs_data.vel, +/// ori: *ecs_data.ori, +/// }; +/// +/// // Move player according to move_dir +/// update.vel.0 += Vec2::broadcast(ecs_data.dt.0) +/// * ecs_data.inputs.move_dir +/// * if update.vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { +/// HUMANOID_ACCEL +/// } else { +/// 0.0 +/// }; +/// +/// // Set direction based on move direction when on the ground +/// let ori_dir = if update.character.action_state.is_attacking() +/// || update.character.action_state.is_blocking() +/// { +/// Vec2::from(ecs_data.inputs.look_dir).normalized() +/// } else { +/// Vec2::from(update.vel.0) +/// }; +/// +/// if ori_dir.magnitude_squared() > 0.0001 +/// && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() +/// > 0.001 +/// { +/// update.ori.0 = +/// vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 9.0 * ecs_data.dt.0); +/// } +/// +/// // Try to sit +/// if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { +/// update.character.move_state = Sit(Some(SitState)); +/// return update; +/// } +/// +/// // Try to climb +/// if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { +/// update.character.move_state = Climb(Some(ClimbState)); +/// return update; +/// } +/// +/// // Try to jump +/// if can_jump(ecs_data.physics, ecs_data.inputs) { +/// update.character.move_state = Jump(Some(JumpState)); +/// return update; +/// } +/// +/// // Try to glide +/// if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { +/// update.character.move_state = Glide(Some(GlideState)); +/// return update; +/// } +/// +/// // Update based on groundedness +/// update.character.move_state = +/// determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); +/// +/// return update; +/// } +/// } +/// ``` pub trait StateHandler: Default { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate; fn new(ecs_data: &EcsStateData) -> Self; diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index 560fbd7e36..63e1e29c78 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -1,4 +1,3 @@ -use super::ROLL_SPEED; use crate::comp::{ ActionState::*, DodgeKind::*, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData, }; @@ -6,6 +5,8 @@ use crate::util::state_utils::*; use std::time::Duration; use vek::Vec3; +const ROLL_SPEED: f32 = 17.0; + #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct RollState { /// How long the state has until exitting diff --git a/common/src/comp/states/run.rs b/common/src/comp/states/run.rs index 94bdf7dc85..598eb5dbb7 100644 --- a/common/src/comp/states/run.rs +++ b/common/src/comp/states/run.rs @@ -1,16 +1,15 @@ -use super::{HUMANOID_ACCEL, HUMANOID_SPEED}; -use crate::comp::{ - ClimbState, EcsStateData, GlideState, JumpState, MoveState::*, SitState, StateHandler, - StateUpdate, -}; +use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; use crate::util::state_utils::*; use vek::vec::{Vec2, Vec3}; +const HUMANOID_ACCEL: f32 = 50.0; +const HUMANOID_SPEED: f32 = 120.0; + #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct RunState; impl StateHandler for RunState { - fn new(ecs_data: &EcsStateData) -> Self { + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } @@ -50,25 +49,25 @@ impl StateHandler for RunState { // Try to sit if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Sit(Some(SitState)); + update.character.move_state = Sit(None); return update; } // Try to climb if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Climb(Some(ClimbState)); + update.character.move_state = Climb(None); return update; } // Try to jump if can_jump(ecs_data.physics, ecs_data.inputs) { - update.character.move_state = Jump(Some(JumpState)); + update.character.move_state = Jump(None); return update; } // Try to glide if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Glide(Some(GlideState)); + update.character.move_state = Glide(None); return update; } diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs index 99f567bdec..2e47c8d4f5 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/comp/states/sit.rs @@ -1,14 +1,11 @@ -use crate::comp::{ - ActionState::*, EcsStateData, IdleState, JumpState, MoveState::*, RunState, StandState, - StateHandler, StateUpdate, -}; +use crate::comp::{ActionState::*, EcsStateData, MoveState::*, StateHandler, StateUpdate}; use crate::util::state_utils::*; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct SitState; impl StateHandler for SitState { - fn new(ecs_data: &EcsStateData) -> Self { + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } @@ -21,8 +18,8 @@ impl StateHandler for SitState { }; // Prevent action state handling - update.character.action_state = Idle(Some(IdleState)); - update.character.move_state = Sit(Some(SitState)); + update.character.action_state = Idle(None); + update.character.move_state = Sit(None); // Try to Fall // ... maybe the ground disappears, @@ -34,19 +31,19 @@ impl StateHandler for SitState { } // Try to jump if ecs_data.inputs.jump.is_pressed() { - update.character.move_state = Jump(Some(JumpState)); + update.character.move_state = Jump(None); return update; } // Try to Run if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - update.character.move_state = Run(Some(RunState)); + update.character.move_state = Run(None); return update; } // Try to Stand if ecs_data.inputs.sit.is_just_pressed() { - update.character.move_state = Stand(Some(StandState)); + update.character.move_state = Stand(None); return update; } diff --git a/common/src/comp/states/stand.rs b/common/src/comp/states/stand.rs index 7c81839f2c..b3372c8721 100644 --- a/common/src/comp/states/stand.rs +++ b/common/src/comp/states/stand.rs @@ -1,14 +1,11 @@ -use crate::comp::{ - ClimbState, EcsStateData, GlideState, JumpState, MoveState::*, SitState, StateHandler, - StateUpdate, -}; +use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; use crate::util::state_utils::*; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct StandState; impl StateHandler for StandState { - fn new(ecs_data: &EcsStateData) -> Self { + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } @@ -22,25 +19,25 @@ impl StateHandler for StandState { // Try to sit if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Sit(Some(SitState)); + update.character.move_state = Sit(None); return update; } // Try to climb if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Climb(Some(ClimbState)); + update.character.move_state = Climb(None); return update; } // Try to jump if can_jump(ecs_data.physics, ecs_data.inputs) { - update.character.move_state = Jump(Some(JumpState)); + update.character.move_state = Jump(None); return update; } // Check gliding if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Glide(Some(GlideState)); + update.character.move_state = Glide(None); return update; } diff --git a/common/src/comp/states/swim.rs b/common/src/comp/states/swim.rs index ccb3022e5d..29d1512bfe 100644 --- a/common/src/comp/states/swim.rs +++ b/common/src/comp/states/swim.rs @@ -1,13 +1,15 @@ -use super::{HUMANOID_WATER_ACCEL, HUMANOID_WATER_SPEED}; -use crate::comp::{EcsStateData, MoveState::*, RunState, StandState, StateHandler, StateUpdate}; +use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; use crate::sys::phys::GRAVITY; use vek::{Vec2, Vec3}; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct SwimState; +const HUMANOID_WATER_ACCEL: f32 = 70.0; +const HUMANOID_WATER_SPEED: f32 = 120.0; + impl StateHandler for SwimState { - fn new(ecs_data: &EcsStateData) -> Self { + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } @@ -55,16 +57,16 @@ impl StateHandler for SwimState { // Not on ground if !ecs_data.physics.on_ground { - update.character.move_state = Swim(Some(SwimState)); + update.character.move_state = Swim(None); return update; } // On ground else { // Return to running or standing based on move inputs update.character.move_state = if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - Run(Some(RunState)) + Run(None) } else { - Stand(Some(StandState)) + Stand(None) }; return update; diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index d2462193a9..06f55afb1c 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -1,8 +1,6 @@ use crate::comp::{ - AbilityAction, AbilityActionKind::*, ActionState::*, EcsStateData, IdleState, ItemKind::Tool, - StateHandler, StateUpdate, ToolData, + ActionState::*, EcsStateData, IdleState, ItemKind::Tool, StateHandler, StateUpdate, ToolData, }; -use crate::util::state_utils::*; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index 7f4a4f792b..6ee78280c3 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -36,6 +36,8 @@ sphynx::sum_type! { OverrideAction(comp::OverrideAction), OverrideMove(comp::OverrideMove), OverrideState(comp::OverrideState), + AbilityAction(comp::AbilityAction), + AbilityPool(comp::AbilityPool), } } // Automatically derive From for EcsCompPhantom @@ -62,6 +64,8 @@ sphynx::sum_type! { OverrideAction(PhantomData), OverrideMove(PhantomData), OverrideState(PhantomData), + AbilityAction(PhantomData), + AbilityPool(PhantomData), } } impl sphynx::CompPacket for EcsCompPacket { diff --git a/common/src/state.rs b/common/src/state.rs index b3aa25af8e..bf4b7e9814 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -123,6 +123,8 @@ impl State { // TODO: Split up registering into server and client (e.g. move EventBus to the server) fn setup_sphynx_world(ecs: &mut sphynx::World) { // Register server -> all clients synced components. + ecs.register_synced::(); + ecs.register_synced::(); ecs.register_synced::(); ecs.register_synced::(); ecs.register_synced::(); diff --git a/common/src/sys/ability.rs b/common/src/sys/ability.rs index 25982ac854..99b173c89d 100644 --- a/common/src/sys/ability.rs +++ b/common/src/sys/ability.rs @@ -25,13 +25,13 @@ impl<'a> System<'a> for Sys { &mut self, ( entities, - updater, + _updater, mut character_state_storage, ability_action_storage, ability_pool_storage, ): Self::SystemData, ) { - for (entity, mut character, ability_action, ability_pool) in ( + for (_entity, mut _character, _ability_action, _ability_pool) in ( &entities, &mut character_state_storage, &ability_action_storage, diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 82b85f2eb3..54ce8de3dd 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,8 +1,7 @@ use crate::{ comp::{ - states::*, Body, CharacterState, Controller, EcsStateData, Mounting, MoveState::*, Ori, - OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, SitState, StateHandler, - Stats, Vel, + Body, CharacterState, Controller, EcsStateData, Mounting, MoveState::*, Ori, + OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -11,18 +10,11 @@ use crate::{ use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; use sphynx::{Uid, UidAllocator}; -/// # Character State System -/// #### Updates tuples of ( `CharacterState`, `Pos`, `Vel`, and `Ori` ) in parallel. -/// _Each update for a single character involves first passing an `EcsStateData` struct of ECS components -/// to the character's `MoveState`, then the character's `ActionState`. State update logic is -/// is encapsulated in state's `handle()` fn, impl'd by the `StateHandle` trait. `handle()` fn's -/// return a `StateUpdate` tuple containing new ( `CharacterState`, `Pos`, `Vel`, and `Ori` ) components. -/// Since `handle()` accepts readonly components, component updates are contained within this system and ECS -/// behavior constraints are satisfied._ +/// ## Character State System +/// #### Calls updates to `CharacterState`s. Acts on tuples of ( `CharacterState`, `Pos`, `Vel`, and `Ori` ). /// -/// _This mimics the typical OOP style state machine pattern, but remains performant -/// under ECS since trait fn's are syntactic sugar for static fn's that accept their implementor's -/// object type as its first parameter. See `StateHandle` for more information._ +/// _System forms `EcsStateData` tuples and passes those to `ActionState` `update()` fn, +/// then does the same for `MoveState` `update`_ pub struct Sys; impl<'a> System<'a> for Sys { @@ -102,14 +94,14 @@ impl<'a> System<'a> for Sys { // If mounted, character state is controlled by mount // TODO: Make mounting a state if let Some(Mounting(_)) = mountings.get(entity) { - character.move_state = Sit(Some(SitState)); + character.move_state = Sit(None); return; } // Determine new action if character can act if let (None, false) = ( action_overrides.get(entity), - character.action_state.overrides_move_state(), + character.move_state.overrides_action_state(), ) { let state_update = character.action_state.update(&EcsStateData { entity: &entity, @@ -137,7 +129,7 @@ impl<'a> System<'a> for Sys { // Determine new move state if character can move if let (None, false) = ( move_overrides.get(entity), - character.move_state.overrides_action_state(), + character.action_state.overrides_move_state(), ) { let state_update = character.move_state.update(&EcsStateData { entity: &entity, diff --git a/common/src/sys/movement.rs b/common/src/sys/movement.rs deleted file mode 100644 index 9b8da17f1b..0000000000 --- a/common/src/sys/movement.rs +++ /dev/null @@ -1,236 +0,0 @@ -use super::phys::GRAVITY; -use crate::{ - comp::{ - CharacterState, Controller, Mounting, MoveState::*, Ori, PhysicsState, Pos, RunState, - StandState, Stats, Vel, - }, - event::{EventBus, ServerEvent}, - state::DeltaTime, - terrain::TerrainGrid, -}; -use specs::prelude::*; -use sphynx::Uid; -use std::time::Duration; -use vek::*; - -pub const ROLL_DURATION: Duration = Duration::from_millis(600); - -const HUMANOID_ACCEL: f32 = 50.0; -const HUMANOID_SPEED: f32 = 120.0; -const HUMANOID_AIR_ACCEL: f32 = 10.0; -const HUMANOID_AIR_SPEED: f32 = 100.0; -const HUMANOID_WATER_ACCEL: f32 = 70.0; -const HUMANOID_WATER_SPEED: f32 = 120.0; -const HUMANOID_CLIMB_ACCEL: f32 = 5.0; -const ROLL_SPEED: f32 = 17.0; -const CHARGE_SPEED: f32 = 20.0; -const GLIDE_ACCEL: f32 = 15.0; -const GLIDE_SPEED: f32 = 45.0; -const BLOCK_ACCEL: f32 = 30.0; -const BLOCK_SPEED: f32 = 75.0; -// Gravity is 9.81 * 4, so this makes gravity equal to .15 -const GLIDE_ANTIGRAV: f32 = GRAVITY * 0.96; -const CLIMB_SPEED: f32 = 5.0; - -pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; - -/// # Movement System -/// #### Applies forces, calculates new positions and velocities,7 -/// #### based on Controller(Inputs) and CharacterState. -/// ---- -/// -/// **Writes:** -/// Pos, Vel, Ori -/// -/// **Reads:** -/// Uid, Stats, Controller, PhysicsState, CharacterState, Mounting -pub struct Sys; -impl<'a> System<'a> for Sys { - type SystemData = ( - Entities<'a>, - ReadExpect<'a, TerrainGrid>, - Read<'a, EventBus>, - Read<'a, DeltaTime>, - WriteStorage<'a, Pos>, - WriteStorage<'a, Vel>, - WriteStorage<'a, Ori>, - ReadStorage<'a, Uid>, - ReadStorage<'a, Stats>, - ReadStorage<'a, Controller>, - ReadStorage<'a, PhysicsState>, - ReadStorage<'a, CharacterState>, - ReadStorage<'a, Mounting>, - ); - - fn run( - &mut self, - ( - entities, - _terrain, - _server_bus, - dt, - mut positions, - mut velocities, - mut orientations, - uids, - stats, - controllers, - physics_states, - character_states, - mountings, - ): Self::SystemData, - ) { - // Apply movement inputs - for ( - _entity, - mut _pos, - mut vel, - mut ori, - _uid, - stats, - controller, - physics, - character, - mount, - ) in ( - &entities, - &mut positions, - &mut velocities, - &mut orientations, - &uids, - &stats, - &controllers, - &physics_states, - &character_states, - mountings.maybe(), - ) - .join() - { - // if character.movement == Run(RunState) || character.movement == Stand(StandState) { - // continue; - // } - - // if stats.is_dead { - // continue; - // } - - // if mount.is_some() { - // continue; - // } - - // let inputs = &controller.inputs; - - // if character.action.is_roll() { - // vel.0 = Vec3::new(0.0, 0.0, vel.0.z) - // + (vel.0 * Vec3::new(1.0, 1.0, 0.0) - // + 1.5 * inputs.move_dir.try_normalized().unwrap_or_default()) - // .try_normalized() - // .unwrap_or_default() - // * ROLL_SPEED; - // } else if character.action.is_charge() { - // vel.0 = Vec3::new(0.0, 0.0, vel.0.z) - // + (vel.0 * Vec3::new(1.0, 1.0, 0.0) - // + 1.5 * inputs.move_dir.try_normalized().unwrap_or_default()) - // .try_normalized() - // .unwrap_or_default() - // * CHARGE_SPEED; - // } else if character.action.is_block() { - // vel.0 += Vec2::broadcast(dt.0) - // * inputs.move_dir - // * match physics.on_ground { - // true if vel.0.magnitude_squared() < BLOCK_SPEED.powf(2.0) => BLOCK_ACCEL, - // _ => 0.0, - // } - // } else { - // // Move player according to move_dir - // vel.0 += Vec2::broadcast(dt.0) - // * inputs.move_dir - // * match (physics.on_ground, &character.movement) { - // (true, Run(_)) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => { - // HUMANOID_ACCEL - // } - // (false, Climb) if vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) => { - // HUMANOID_CLIMB_ACCEL - // } - // (false, Glide) if vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) => { - // GLIDE_ACCEL - // } - // (false, Fall) | (false, Jump) - // if vel.0.magnitude_squared() < HUMANOID_AIR_SPEED.powf(2.0) => - // { - // HUMANOID_AIR_ACCEL - // } - // (false, Swim) - // if vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) => - // { - // HUMANOID_WATER_ACCEL - // } - // _ => 0.0, - // }; - // } - - // // Set direction based on move direction when on the ground - // let ori_dir = if - // //character.action.is_wield() || - // character.action.is_attack() || character.action.is_block() { - // Vec2::from(inputs.look_dir).normalized() - // } else if let (Climb, Some(wall_dir)) = (character.movement, physics.on_wall) { - // if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { - // Vec2::from(wall_dir).normalized() - // } else { - // Vec2::from(vel.0) - // } - // } else { - // Vec2::from(vel.0) - // }; - - // if ori_dir.magnitude_squared() > 0.0001 - // && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - // > 0.001 - // { - // ori.0 = vek::ops::Slerp::slerp( - // ori.0, - // ori_dir.into(), - // if physics.on_ground { 9.0 } else { 2.0 } * dt.0, - // ); - // } - - // // Glide - // if character.movement == Glide - // && Vec2::::from(vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) - // && vel.0.z < 0.0 - // { - // let lift = GLIDE_ANTIGRAV + vel.0.z.abs().powf(2.0) * 0.15; - // vel.0.z += dt.0 - // * lift - // * (Vec2::::from(vel.0).magnitude() * 0.075) - // .min(1.0) - // .max(0.2); - // } - - // // Climb - // if let (true, Some(_wall_dir)) = ( - // (inputs.climb.is_pressed() | inputs.climb_down.is_pressed()) - // && vel.0.z <= CLIMB_SPEED, - // physics.on_wall, - // ) { - // if inputs.climb_down.is_pressed() && !inputs.climb.is_pressed() { - // vel.0 -= dt.0 * vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); - // } else if inputs.climb.is_pressed() && !inputs.climb_down.is_pressed() { - // vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); - // } else { - // vel.0.z = vel.0.z + dt.0 * GRAVITY * 1.5; - // vel.0 = Lerp::lerp( - // vel.0, - // Vec3::zero(), - // 30.0 * dt.0 / (1.0 - vel.0.z.min(0.0) * 5.0), - // ); - // } - // } - - // if character.movement == Swim && inputs.jump.is_pressed() { - // vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); - // } - } - } -} diff --git a/common/src/util/state_utils.rs b/common/src/util/state_utils.rs index 02fd2de6f4..e303e102e5 100644 --- a/common/src/util/state_utils.rs +++ b/common/src/util/state_utils.rs @@ -1,8 +1,7 @@ -use crate::comp::TEMP_EQUIP_DELAY; use crate::comp::{ ActionState, ActionState::*, AttackKind::*, BasicAttackState, BasicBlockState, BlockKind::*, Body, ControllerInputs, FallState, IdleState, ItemKind::Tool, MoveState, MoveState::*, - PhysicsState, RunState, StandState, Stats, SwimState, ToolData, WieldState, + PhysicsState, RunState, StandState, Stats, SwimState, WieldState, }; use std::time::Duration; @@ -23,7 +22,7 @@ pub fn determine_primary_ability(stats: &Stats) -> ActionState { /// and returns the corresponding `ActionState` /// ... or Idle if nothing it possible?_ pub fn determine_secondary_ability(stats: &Stats) -> ActionState { - if let Some(Tool(data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { + if let Some(Tool(_data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { Block(BasicBlock(Some(BasicBlockState { active_duration: Duration::default(), }))) @@ -32,7 +31,7 @@ pub fn determine_secondary_ability(stats: &Stats) -> ActionState { } } -/// __Returns a `MoveState` based on `in_fluid` condition__ +/// _Returns a `MoveState` based on `in_fluid` condition_ pub fn determine_fall_or_swim(physics: &PhysicsState) -> MoveState { // Check if in fluid to go to swimming or back to falling if physics.in_fluid { @@ -41,7 +40,7 @@ pub fn determine_fall_or_swim(physics: &PhysicsState) -> MoveState { Fall(Some(FallState)) } } -/// __Returns a `MoveState` based on `move_dir` magnitude__ +/// _Returns a `MoveState` based on `move_dir` magnitude_ pub fn determine_stand_or_run(inputs: &ControllerInputs) -> MoveState { // Return to running or standing based on move inputs if inputs.move_dir.magnitude_squared() > 0.0 { @@ -51,7 +50,7 @@ pub fn determine_stand_or_run(inputs: &ControllerInputs) -> MoveState { } } -/// __Returns a `MoveState` based on `on_ground` state.__ +/// _Returns a `MoveState` based on `on_ground` state._ /// /// _`FallState`, or `SwimState` if not `on_ground`, /// `StandState` or `RunState` if is `on_ground`_ @@ -69,11 +68,11 @@ pub fn determine_move_from_grounded_state( } } -/// __Returns an ActionState based on whether character has a weapon equipped.__ +/// _Returns an ActionState based on whether character has a weapon equipped._ pub fn attempt_wield(stats: &Stats) -> ActionState { - if let Some(Tool { .. }) = stats.equipment.main.as_ref().map(|i| &i.kind) { + if let Some(Tool(data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { Wield(Some(WieldState { - equip_delay: Duration::from_millis(TEMP_EQUIP_DELAY), + equip_delay: data.equip_time(), })) } else { Idle(Some(IdleState)) @@ -82,7 +81,7 @@ pub fn attempt_wield(stats: &Stats) -> ActionState { pub fn can_climb(physics: &PhysicsState, inputs: &ControllerInputs, body: &Body) -> bool { if let (true, Some(_wall_dir)) = ( - inputs.climb.is_pressed() | inputs.climb_down.is_pressed() && body.is_humanoid(), + (inputs.climb.is_pressed() | inputs.climb_down.is_pressed()) && body.is_humanoid(), physics.on_wall, ) { true diff --git a/voxygen/src/audio/sfx/event_mapper.rs b/voxygen/src/audio/sfx/event_mapper.rs index 11285bb637..46c32fd7d5 100644 --- a/voxygen/src/audio/sfx/event_mapper.rs +++ b/voxygen/src/audio/sfx/event_mapper.rs @@ -277,10 +277,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Stand(StandState), - action_state: ActionState::Idle(IdleState), - action_disabled_this_tick: false, - move_disabled_this_tick: false, + move_state: MoveState::Stand(None), + action_state: ActionState::Idle(None), }, SfxEvent::Idle, &stats, @@ -295,10 +293,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Run(RunState), - action_state: ActionState::Idle(IdleState), - action_disabled_this_tick: false, - move_disabled_this_tick: false, + move_state: MoveState::Run(None), + action_state: ActionState::Idle(None), }, SfxEvent::Idle, &stats, @@ -313,10 +309,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - action_state: ActionState::Dodge(Roll(RollState::default())), - move_state: MoveState::Run(RunState), - action_disabled_this_tick: false, - move_disabled_this_tick: true, + action_state: ActionState::Dodge(Roll(None)), + move_state: MoveState::Run(None), }, SfxEvent::Run, &stats, @@ -331,10 +325,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Fall(FallState), - action_state: ActionState::Idle(IdleState), - action_disabled_this_tick: false, - move_disabled_this_tick: false, + move_state: MoveState::Fall((None)), + action_state: ActionState::Idle((None)), }, SfxEvent::Idle, &stats, @@ -349,10 +341,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Glide(GlideState), - action_state: ActionState::Idle(IdleState), - action_disabled_this_tick: true, - move_disabled_this_tick: false, + move_state: MoveState::Glide(None), + action_state: ActionState::Idle(None), }, SfxEvent::Jump, &stats, @@ -367,10 +357,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Glide(GlideState), - action_state: ActionState::Idle(IdleState), - action_disabled_this_tick: true, - move_disabled_this_tick: false, + move_state: MoveState::Glide(None), + action_state: ActionState::Idle(None), }, SfxEvent::Glide, &stats, @@ -385,10 +373,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Fall(FallState), - action_state: ActionState::Idle(IdleState), - move_disabled_this_tick: false, - action_disabled_this_tick: false, + move_state: MoveState::Fall(None), + action_state: ActionState::Idle(None), }, SfxEvent::Glide, &stats, @@ -408,10 +394,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Stand(StandState), - action_state: ActionState::Attack(BasicAttack(BasicAttackState::default())), - move_disabled_this_tick: false, - action_disabled_this_tick: false, + move_state: MoveState::Stand(None), + action_state: ActionState::Attack(BasicAttack(None)), }, SfxEvent::Idle, &stats, diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 8e6d3855c6..d9d4fff5eb 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -1,9 +1,9 @@ use super::{ - img_ids::Imgs, BarNumbers, Fonts, ShortcutNumbers, XpBar, CRITICAL_HP_COLOR, - /*FOCUS_COLOR, RAGE_COLOR,*/ HP_COLOR, LOW_HP_COLOR, MANA_COLOR, TEXT_COLOR, XP_COLOR, + img_ids::Imgs, BarNumbers, Fonts, ShortcutNumbers, XpBar, CRITICAL_HP_COLOR, HP_COLOR, + LOW_HP_COLOR, MANA_COLOR, TEXT_COLOR, XP_COLOR, }; use crate::GlobalState; -use common::comp::{item::Debug, item::ToolData, item::ToolKind, Equipment, ItemKind, Stats}; +use common::comp::{item::Debug, item::ToolData, item::ToolKind, ItemKind, Stats}; use conrod_core::{ color, widget::{self, Button, Image, Rectangle, Text}, From 8cdf06e3e2a10c65001c07e5b00073d246fd0f9b Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Wed, 8 Jan 2020 05:17:36 -0800 Subject: [PATCH 022/326] Swim pulsing --- common/src/comp/controller.rs | 5 ++++ common/src/comp/states/mod.rs | 51 ++++++---------------------------- common/src/comp/states/swim.rs | 9 +++++- 3 files changed, 21 insertions(+), 44 deletions(-) diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 1bfc01dcad..f3155a3fd3 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -69,6 +69,11 @@ impl Input { (self.is_pressed() && self.duration >= DEFAULT_HOLD_DURATION) } + // Whether input has been pressed for longer than `threshold` + pub fn is_long_press(&self, threshold: Duration) -> bool { + (self.is_pressed() && self.duration >= threshold) + } + /// Handles logic of updating state of Input pub fn set_state(&mut self, new_state: bool) { // Only update if state switches diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index 805c8e31dd..2d29505272 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -47,11 +47,8 @@ use super::{ /// /// ## Example Implementation: /// ``` -/// use crate::comp::{ -/// ClimbState, EcsStateData, GlideState, JumpState, MoveState::*, SitState, StateHandler, -/// StateUpdate, -/// }; -/// use crate::util::state_utils::* +/// use crate::util::state_utils::*; +/// /// #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] /// pub struct RunState { /// active_duration: Duration, @@ -72,7 +69,7 @@ use super::{ /// ori: *ecs_data.ori, /// }; /// -/// // Move player according to move_dir +/// // Update player's Vel /// update.vel.0 += Vec2::broadcast(ecs_data.dt.0) /// * ecs_data.inputs.move_dir /// * if update.vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { @@ -81,50 +78,18 @@ use super::{ /// 0.0 /// }; /// -/// // Set direction based on move direction when on the ground -/// let ori_dir = if update.character.action_state.is_attacking() -/// || update.character.action_state.is_blocking() -/// { -/// Vec2::from(ecs_data.inputs.look_dir).normalized() -/// } else { -/// Vec2::from(update.vel.0) -/// }; -/// -/// if ori_dir.magnitude_squared() > 0.0001 -/// && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() -/// > 0.001 -/// { -/// update.ori.0 = -/// vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 9.0 * ecs_data.dt.0); -/// } -/// -/// // Try to sit -/// if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { -/// update.character.move_state = Sit(Some(SitState)); -/// return update; -/// } -/// -/// // Try to climb -/// if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { -/// update.character.move_state = Climb(Some(ClimbState)); -/// return update; -/// } +/// // -- snip -- +/// // Other updates; checks for gliding, climbing, etc. /// /// // Try to jump -/// if can_jump(ecs_data.physics, ecs_data.inputs) { -/// update.character.move_state = Jump(Some(JumpState)); -/// return update; -/// } -/// -/// // Try to glide -/// if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { -/// update.character.move_state = Glide(Some(GlideState)); +/// if state_utils::can_jump(ecs_data.physics, ecs_data.inputs) { +/// update.character.move_state = Jump(None); /// return update; /// } /// /// // Update based on groundedness /// update.character.move_state = -/// determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); +/// state_utils::determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); /// /// return update; /// } diff --git a/common/src/comp/states/swim.rs b/common/src/comp/states/swim.rs index 29d1512bfe..1d739a7aec 100644 --- a/common/src/comp/states/swim.rs +++ b/common/src/comp/states/swim.rs @@ -1,5 +1,6 @@ use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; use crate::sys::phys::GRAVITY; +use std::time::Duration; use vek::{Vec2, Vec3}; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -50,7 +51,13 @@ impl StateHandler for SwimState { ); } - if ecs_data.inputs.jump.is_pressed() && !ecs_data.inputs.jump.is_held_down() { + // Force players to press jump in a slow rhythmic fashion to swim up + if ecs_data.inputs.jump.is_pressed() + && !ecs_data + .inputs + .jump + .is_long_press(Duration::from_millis(600)) + { update.vel.0.z = (update.vel.0.z + ecs_data.dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); } From 5527d83a0e3dc8c58dfab1633ec6f49738159be9 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 8 Jan 2020 08:56:36 -0800 Subject: [PATCH 023/326] Update mod imports --- common/src/comp/character_state.rs | 36 ++++++------- common/src/comp/states/basic_attack.rs | 6 +-- common/src/comp/states/basic_block.rs | 4 +- common/src/comp/states/charge_attack.rs | 6 +-- common/src/comp/states/climb.rs | 4 +- common/src/comp/states/fall.rs | 4 +- common/src/comp/states/glide.rs | 4 +- common/src/comp/states/idle.rs | 4 +- common/src/comp/states/jump.rs | 4 +- common/src/comp/states/mod.rs | 72 ++++++++++--------------- common/src/comp/states/roll.rs | 6 +-- common/src/comp/states/run.rs | 4 +- common/src/comp/states/sit.rs | 4 +- common/src/comp/states/stand.rs | 4 +- common/src/comp/states/swim.rs | 4 +- common/src/comp/states/wield.rs | 10 ++-- common/src/sys/agent.rs | 5 +- 17 files changed, 82 insertions(+), 99 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 0a2d340a44..a12e737ead 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -38,20 +38,20 @@ pub struct StateUpdate { #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum MoveState { - Stand(Option), - Run(Option), - Sit(Option), - Jump(Option), - Fall(Option), - Glide(Option), - Swim(Option), - Climb(Option), + Stand(Option), + Run(Option), + Sit(Option), + Jump(Option), + Fall(Option), + Glide(Option), + Swim(Option), + Climb(Option), } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum ActionState { - Idle(Option), - Wield(Option), + Idle(Option), + Wield(Option), Attack(AttackKind), Block(BlockKind), Dodge(DodgeKind), @@ -60,24 +60,24 @@ pub enum ActionState { #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum AttackKind { - BasicAttack(Option), - Charge(Option), + BasicAttack(Option), + Charge(Option), } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum BlockKind { - BasicBlock(Option), + BasicBlock(Option), } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum DodgeKind { - Roll(Option), + Roll(Option), } impl ActionState { pub fn is_equip_finished(&self) -> bool { match self { - Wield(Some(WieldState { equip_delay })) => *equip_delay == Duration::default(), + Wield(Some(wield::State { equip_delay })) => *equip_delay == Duration::default(), _ => true, } } @@ -85,7 +85,7 @@ impl ActionState { /// Returns the current `equip_delay` if in `WieldState`, otherwise `Duration::default()` pub fn get_delay(&self) -> Duration { match self { - Wield(Some(WieldState { equip_delay })) => *equip_delay, + Wield(Some(wield::State { equip_delay })) => *equip_delay, _ => Duration::default(), } } @@ -164,8 +164,8 @@ impl CharacterState { impl Default for CharacterState { fn default() -> Self { Self { - move_state: MoveState::Fall(Some(FallState)), - action_state: ActionState::Idle(Some(IdleState)), + move_state: MoveState::Fall(None), + action_state: ActionState::Idle(None), } } } diff --git a/common/src/comp/states/basic_attack.rs b/common/src/comp/states/basic_attack.rs index 725e8acc93..95b45ae968 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/comp/states/basic_attack.rs @@ -6,12 +6,12 @@ use crate::util::state_utils::*; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct BasicAttackState { +pub struct State { /// How long the state has until exitting pub remaining_duration: Duration, } -impl StateHandler for BasicAttackState { +impl StateHandler for State { fn new(ecs_data: &EcsStateData) -> Self { let tool_data = if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { @@ -40,7 +40,7 @@ impl StateHandler for BasicAttackState { } // Otherwise, tick down remaining_duration, and keep rolling - update.character.action_state = Attack(BasicAttack(Some(BasicAttackState { + update.character.action_state = Attack(BasicAttack(Some(State { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs index 053c837015..cc59682bd9 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/comp/states/basic_block.rs @@ -7,12 +7,12 @@ const BLOCK_ACCEL: f32 = 30.0; const BLOCK_SPEED: f32 = 75.0; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct BasicBlockState { +pub struct State { /// How long the blocking state has been active pub active_duration: Duration, } -impl StateHandler for BasicBlockState { +impl StateHandler for State { fn new(_ecs_data: &EcsStateData) -> Self { Self { active_duration: Duration::default(), diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs index ea4420f3f9..040ae971d7 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/comp/states/charge_attack.rs @@ -10,12 +10,12 @@ use vek::Vec3; const CHARGE_SPEED: f32 = 20.0; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct ChargeAttackState { +pub struct State { /// How long the state has until exitting pub remaining_duration: Duration, } -impl StateHandler for ChargeAttackState { +impl StateHandler for State { fn new(ecs_data: &EcsStateData) -> Self { let tool_data = if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { @@ -76,7 +76,7 @@ impl StateHandler for ChargeAttackState { } // Tick remaining-duration and keep charging - update.character.action_state = Attack(Charge(Some(ChargeAttackState { + update.character.action_state = Attack(Charge(Some(State { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) diff --git a/common/src/comp/states/climb.rs b/common/src/comp/states/climb.rs index 9b1df0a52a..d5f6801433 100644 --- a/common/src/comp/states/climb.rs +++ b/common/src/comp/states/climb.rs @@ -7,9 +7,9 @@ const HUMANOID_CLIMB_ACCEL: f32 = 5.0; const CLIMB_SPEED: f32 = 5.0; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct ClimbState; +pub struct State; -impl StateHandler for ClimbState { +impl StateHandler for State { fn new(_ecs_data: &EcsStateData) -> Self { Self {} } diff --git a/common/src/comp/states/fall.rs b/common/src/comp/states/fall.rs index 55c72c3e97..8882b948c0 100644 --- a/common/src/comp/states/fall.rs +++ b/common/src/comp/states/fall.rs @@ -7,9 +7,9 @@ const HUMANOID_AIR_ACCEL: f32 = 10.0; const HUMANOID_AIR_SPEED: f32 = 100.0; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct FallState; +pub struct State; -impl StateHandler for FallState { +impl StateHandler for State { fn new(_ecs_data: &EcsStateData) -> Self { Self {} } diff --git a/common/src/comp/states/glide.rs b/common/src/comp/states/glide.rs index 4060b6c4f4..47c2ecb7b5 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/comp/states/glide.rs @@ -7,9 +7,9 @@ const GLIDE_ACCEL: f32 = 15.0; const GLIDE_SPEED: f32 = 45.0; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct GlideState; +pub struct State; -impl StateHandler for GlideState { +impl StateHandler for State { fn new(_ecs_data: &EcsStateData) -> Self { Self {} } diff --git a/common/src/comp/states/idle.rs b/common/src/comp/states/idle.rs index 2cfa12ad91..3498d912bf 100644 --- a/common/src/comp/states/idle.rs +++ b/common/src/comp/states/idle.rs @@ -1,9 +1,9 @@ use crate::comp::{ActionState::Wield, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate}; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct IdleState; +pub struct State; -impl StateHandler for IdleState { +impl StateHandler for State { fn new(_ecs_data: &EcsStateData) -> Self { Self {} } diff --git a/common/src/comp/states/jump.rs b/common/src/comp/states/jump.rs index 16bf65b534..3cb2a5aacd 100644 --- a/common/src/comp/states/jump.rs +++ b/common/src/comp/states/jump.rs @@ -2,9 +2,9 @@ use super::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; use crate::event::LocalEvent; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct JumpState; +pub struct State; -impl StateHandler for JumpState { +impl StateHandler for State { fn new(_ecs_data: &EcsStateData) -> Self { Self {} } diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index 2d29505272..b064026210 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -1,34 +1,18 @@ // Module declarations -mod basic_attack; -mod basic_block; -mod charge_attack; -mod climb; -mod fall; -mod glide; -mod idle; -mod jump; -mod roll; -mod run; -mod sit; -mod stand; -mod swim; -mod wield; - -// Reexports -pub use basic_attack::*; -pub use basic_block::*; -pub use charge_attack::*; -pub use climb::*; -pub use fall::*; -pub use glide::*; -pub use idle::*; -pub use jump::*; -pub use roll::*; -pub use run::*; -pub use sit::*; -pub use stand::*; -pub use swim::*; -pub use wield::*; +pub mod basic_attack; +pub mod basic_block; +pub mod charge_attack; +pub mod climb; +pub mod fall; +pub mod glide; +pub mod idle; +pub mod jump; +pub mod roll; +pub mod run; +pub mod sit; +pub mod stand; +pub mod swim; +pub mod wield; use super::{ ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData, @@ -112,28 +96,28 @@ impl ActionState { Attack(kind) => match kind { BasicAttack(opt_state) => opt_state // If data hasn't been initialized, initialize a new one - .unwrap_or_else(|| BasicAttackState::new(ecs_data)) + .unwrap_or_else(|| basic_attack::State::new(ecs_data)) // Call handler .handle(ecs_data), Charge(opt_state) => opt_state - .unwrap_or_else(|| ChargeAttackState::new(ecs_data)) + .unwrap_or_else(|| charge_attack::State::new(ecs_data)) .handle(ecs_data), }, Block(kind) => match kind { BasicBlock(opt_state) => opt_state - .unwrap_or_else(|| BasicBlockState::new(ecs_data)) + .unwrap_or_else(|| basic_block::State::new(ecs_data)) .handle(ecs_data), }, Dodge(kind) => match kind { Roll(opt_state) => opt_state - .unwrap_or_else(|| RollState::new(ecs_data)) + .unwrap_or_else(|| roll::State::new(ecs_data)) .handle(ecs_data), }, Wield(opt_state) => opt_state - .unwrap_or_else(|| WieldState::new(ecs_data)) + .unwrap_or_else(|| wield::State::new(ecs_data)) .handle(ecs_data), Idle(opt_state) => opt_state - .unwrap_or_else(|| IdleState::new(ecs_data)) + .unwrap_or_else(|| idle::State::new(ecs_data)) .handle(ecs_data), // All states should be explicitly handled // Do not use default match: _ => {}, @@ -188,29 +172,29 @@ impl MoveState { match self { Stand(opt_state) => opt_state // If data hasn't been initialized, initialize a new one - .unwrap_or_else(|| StandState::new(ecs_data)) + .unwrap_or_else(|| stand::State::new(ecs_data)) // Call handler .handle(ecs_data), Run(opt_state) => opt_state - .unwrap_or_else(|| RunState::new(ecs_data)) + .unwrap_or_else(|| run::State::new(ecs_data)) .handle(ecs_data), Jump(opt_state) => opt_state - .unwrap_or_else(|| JumpState::new(ecs_data)) + .unwrap_or_else(|| jump::State::new(ecs_data)) .handle(ecs_data), Climb(opt_state) => opt_state - .unwrap_or_else(|| ClimbState::new(ecs_data)) + .unwrap_or_else(|| climb::State::new(ecs_data)) .handle(ecs_data), Glide(opt_state) => opt_state - .unwrap_or_else(|| GlideState::new(ecs_data)) + .unwrap_or_else(|| glide::State::new(ecs_data)) .handle(ecs_data), Swim(opt_state) => opt_state - .unwrap_or_else(|| SwimState::new(ecs_data)) + .unwrap_or_else(|| swim::State::new(ecs_data)) .handle(ecs_data), Fall(opt_state) => opt_state - .unwrap_or_else(|| FallState::new(ecs_data)) + .unwrap_or_else(|| fall::State::new(ecs_data)) .handle(ecs_data), Sit(opt_state) => opt_state - .unwrap_or_else(|| SitState::new(ecs_data)) + .unwrap_or_else(|| sit::State::new(ecs_data)) .handle(ecs_data), // All states should be explicitly handled // Do not use default match: _ => {}, diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index 63e1e29c78..3947a0e565 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -8,12 +8,12 @@ use vek::Vec3; const ROLL_SPEED: f32 = 17.0; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct RollState { +pub struct State { /// How long the state has until exitting remaining_duration: Duration, } -impl StateHandler for RollState { +impl StateHandler for State { fn new(ecs_data: &EcsStateData) -> Self { let tool_data = if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { @@ -55,7 +55,7 @@ impl StateHandler for RollState { } // Otherwise, tick down remaining_duration - update.character.action_state = Dodge(Roll(Some(RollState { + update.character.action_state = Dodge(Roll(Some(State { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) diff --git a/common/src/comp/states/run.rs b/common/src/comp/states/run.rs index 598eb5dbb7..a2ca009956 100644 --- a/common/src/comp/states/run.rs +++ b/common/src/comp/states/run.rs @@ -6,9 +6,9 @@ const HUMANOID_ACCEL: f32 = 50.0; const HUMANOID_SPEED: f32 = 120.0; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct RunState; +pub struct State; -impl StateHandler for RunState { +impl StateHandler for State { fn new(_ecs_data: &EcsStateData) -> Self { Self {} } diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs index 2e47c8d4f5..032cc4a27d 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/comp/states/sit.rs @@ -2,9 +2,9 @@ use crate::comp::{ActionState::*, EcsStateData, MoveState::*, StateHandler, Stat use crate::util::state_utils::*; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct SitState; +pub struct State; -impl StateHandler for SitState { +impl StateHandler for State { fn new(_ecs_data: &EcsStateData) -> Self { Self {} } diff --git a/common/src/comp/states/stand.rs b/common/src/comp/states/stand.rs index b3372c8721..9536cc7a61 100644 --- a/common/src/comp/states/stand.rs +++ b/common/src/comp/states/stand.rs @@ -2,9 +2,9 @@ use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; use crate::util::state_utils::*; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct StandState; +pub struct State; -impl StateHandler for StandState { +impl StateHandler for State { fn new(_ecs_data: &EcsStateData) -> Self { Self {} } diff --git a/common/src/comp/states/swim.rs b/common/src/comp/states/swim.rs index 1d739a7aec..8ccecc2b70 100644 --- a/common/src/comp/states/swim.rs +++ b/common/src/comp/states/swim.rs @@ -4,12 +4,12 @@ use std::time::Duration; use vek::{Vec2, Vec3}; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct SwimState; +pub struct State; const HUMANOID_WATER_ACCEL: f32 = 70.0; const HUMANOID_WATER_SPEED: f32 = 120.0; -impl StateHandler for SwimState { +impl StateHandler for State { fn new(_ecs_data: &EcsStateData) -> Self { Self {} } diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index 06f55afb1c..bcf9e0d582 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -1,16 +1,16 @@ use crate::comp::{ - ActionState::*, EcsStateData, IdleState, ItemKind::Tool, StateHandler, StateUpdate, ToolData, + ActionState::*, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData, }; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct WieldState { +pub struct State { /// How long before a new action can be performed /// after equipping pub equip_delay: Duration, } -impl StateHandler for WieldState { +impl StateHandler for State { fn new(ecs_data: &EcsStateData) -> Self { let tool_data = if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { @@ -37,7 +37,7 @@ impl StateHandler for WieldState { if ecs_data.inputs.toggle_wield.is_just_pressed() && ecs_data.character.action_state.is_equip_finished() { - update.character.action_state = Idle(Some(IdleState)); + update.character.action_state = Idle(None); return update; } @@ -54,7 +54,7 @@ impl StateHandler for WieldState { } else { // Equip delay hasn't expired yet // Update wield delay - update.character.action_state = Wield(Some(WieldState { + update.character.action_state = Wield(Some(State { equip_delay: self .equip_delay .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index 23c850b490..c1118c0ce4 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -1,6 +1,5 @@ use crate::comp::{ - Agent, CharacterState, Controller, ControllerInputs, GlideState, MountState, MoveState::Glide, - Pos, Stats, + Agent, CharacterState, Controller, ControllerInputs, MountState, MoveState::Glide, Pos, Stats, }; use crate::pathfinding::WorldPath; use crate::terrain::TerrainGrid; @@ -163,7 +162,7 @@ impl<'a> System<'a> for Sys { inputs.roll.set_state(true); } - if target_character.move_state == Glide(Some(GlideState)) + if target_character.move_state == Glide(None) && target_pos.0.z > pos.0.z + 5.0 { inputs.glide.set_state(true); From de36e75264a8aa590b44093b6a8b1f1fd2cbce77 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 8 Jan 2020 11:31:42 -0800 Subject: [PATCH 024/326] Fix imports, update matches --- client/src/lib.rs | 2 +- common/src/comp/character_state.rs | 40 +++++++++---------------- common/src/comp/states/climb.rs | 10 +++---- common/src/comp/states/fall.rs | 19 ++++++------ common/src/comp/states/glide.rs | 12 ++++---- common/src/comp/states/idle.rs | 4 +-- common/src/comp/states/jump.rs | 4 +-- common/src/comp/states/roll.rs | 3 +- common/src/comp/states/run.rs | 23 +++++++-------- common/src/comp/states/sit.rs | 12 ++++---- common/src/comp/states/stand.rs | 10 +++---- common/src/comp/states/swim.rs | 21 +++++++------- common/src/comp/states/wield.rs | 8 ++--- common/src/util/state_utils.rs | 42 ++++++++++----------------- server/src/sys/entity_sync.rs | 2 +- voxygen/src/audio/sfx/event_mapper.rs | 9 +++--- voxygen/src/scene/figure/cache.rs | 9 +++--- voxygen/src/scene/figure/mod.rs | 23 ++++++++------- voxygen/src/session.rs | 11 +++---- 19 files changed, 120 insertions(+), 144 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index ce8fb7182d..f7b3e34c5c 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -360,7 +360,7 @@ impl Client { { if last_character_states .get(entity) - .map(|&l| !client_character_state.is_same_state(&l.0)) + .map(|&l| !client_character_state.equals(&l.0)) .unwrap_or(true) { let _ = last_character_states diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index a12e737ead..1c0091decd 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -110,20 +110,18 @@ impl ActionState { _ => false, } } - - pub fn is_wielding(&self) -> bool { - if let Wield(_) = self { - true - } else { - false - } + /// Compares `action_state`s for shallow equality (does not check internal struct equality) + pub fn equals(&self, other: &Self) -> bool { + // Check if state is the same without looking at the inner data + std::mem::discriminant(&self) == std::mem::discriminant(&other) } - pub fn is_idling(&self) -> bool { - if let Idle(_) = self { - true - } else { - false - } +} + +impl MoveState { + /// Compares `move_state`s for shallow equality (does not check internal struct equality) + pub fn equals(&self, other: &Self) -> bool { + // Check if state is the same without looking at the inner data + std::mem::discriminant(&self) == std::mem::discriminant(&other) } } @@ -142,22 +140,10 @@ pub struct CharacterState { } impl CharacterState { - /// Compares `move_state`s for shallow equality (does not check internal struct equality) - pub fn is_same_move_state(&self, other: &Self) -> bool { - // Check if state is the same without looking at the inner data - std::mem::discriminant(&self.move_state) == std::mem::discriminant(&other.move_state) - } - - /// Compares `action_state`s for shallow equality (does not check internal struct equality) - pub fn is_same_action_state(&self, other: &Self) -> bool { - // Check if state is the same without looking at the inner data - std::mem::discriminant(&self.action_state) == std::mem::discriminant(&other.action_state) - } - /// Compares both `move_state`s and `action_state`a for shallow equality /// (does not check internal struct equality) - pub fn is_same_state(&self, other: &Self) -> bool { - self.is_same_move_state(other) && self.is_same_action_state(other) + pub fn equals(&self, other: &Self) -> bool { + self.move_state.equals(&other.move_state) && self.action_state.equals(&other.action_state) } } diff --git a/common/src/comp/states/climb.rs b/common/src/comp/states/climb.rs index d5f6801433..09450d4160 100644 --- a/common/src/comp/states/climb.rs +++ b/common/src/comp/states/climb.rs @@ -1,4 +1,4 @@ -use super::{ActionState::*, EcsStateData, MoveState::*, StateHandler, StateUpdate}; +use super::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; use crate::sys::phys::GRAVITY; use vek::vec::{Vec2, Vec3}; use vek::Lerp; @@ -22,18 +22,18 @@ impl StateHandler for State { character: *ecs_data.character, }; - update.character.action_state = Idle(None); + update.character.action_state = ActionState::Idle(None); // If no wall is in front of character ... if let None = ecs_data.physics.on_wall { if ecs_data.inputs.jump.is_pressed() { // They've climbed atop something, give them a boost - update.character.move_state = Jump(None); + update.character.move_state = MoveState::Jump(None); return update; } else { // Just fall off - update.character.move_state = Fall(None); + update.character.move_state = MoveState::Fall(None); return update; } @@ -41,7 +41,7 @@ impl StateHandler for State { // Remove climb state on ground, otherwise character will get stuck if ecs_data.physics.on_ground { - update.character.move_state = Stand(None); + update.character.move_state = MoveState::Stand(None); return update; } diff --git a/common/src/comp/states/fall.rs b/common/src/comp/states/fall.rs index 8882b948c0..e94215c3ff 100644 --- a/common/src/comp/states/fall.rs +++ b/common/src/comp/states/fall.rs @@ -1,4 +1,4 @@ -use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; use crate::util::state_utils::*; use vek::{Vec2, Vec3}; @@ -32,13 +32,12 @@ impl StateHandler for State { }; // Set orientation vector based on direction of movement when on the ground - let ori_dir = if update.character.action_state.is_attacking() - || update.character.action_state.is_blocking() - { - Vec2::from(ecs_data.inputs.look_dir).normalized() - } else { - Vec2::from(update.vel.0) - }; + let ori_dir = + if let ActionState::Attack(_) | ActionState::Block(_) = update.character.action_state { + Vec2::from(ecs_data.inputs.look_dir).normalized() + } else { + Vec2::from(update.vel.0) + }; if ori_dir.magnitude_squared() > 0.0001 && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() @@ -50,13 +49,13 @@ impl StateHandler for State { // Check to start climbing if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Climb(None); + update.character.move_state = MoveState::Climb(None); return update; } // Check gliding if ecs_data.inputs.glide.is_pressed() { - update.character.move_state = Glide(None); + update.character.move_state = MoveState::Glide(None); return update; } diff --git a/common/src/comp/states/glide.rs b/common/src/comp/states/glide.rs index 47c2ecb7b5..f436fddca4 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/comp/states/glide.rs @@ -1,4 +1,4 @@ -use crate::comp::{ActionState::*, EcsStateData, MoveState::*, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; use vek::{Vec2, Vec3}; // Gravity is 9.81 * 4, so this makes gravity equal to .15 @@ -23,24 +23,24 @@ impl StateHandler for State { }; // Defaults for this state - update.character.action_state = Idle(None); - update.character.move_state = Glide(None); + update.character.action_state = ActionState::Idle(None); + update.character.move_state = MoveState::Glide(None); // If glide button isn't held, start falling if !ecs_data.inputs.glide.is_pressed() { - update.character.move_state = Fall(None); + update.character.move_state = MoveState::Fall(None); return update; } // If there is a wall in front of character go to climb if let Some(_wall_dir) = ecs_data.physics.on_wall { - update.character.move_state = Climb(None); + update.character.move_state = MoveState::Climb(None); return update; } // If on ground go to stand if ecs_data.physics.on_ground { - update.character.move_state = Stand(None); + update.character.move_state = MoveState::Stand(None); return update; } diff --git a/common/src/comp/states/idle.rs b/common/src/comp/states/idle.rs index 3498d912bf..46af0a47fb 100644 --- a/common/src/comp/states/idle.rs +++ b/common/src/comp/states/idle.rs @@ -1,4 +1,4 @@ -use crate::comp::{ActionState::Wield, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate}; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; @@ -23,7 +23,7 @@ impl StateHandler for State { && update.character.action_state.is_equip_finished()) { if let Some(Tool(_)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { - update.character.action_state = Wield(None); + update.character.action_state = ActionState::Wield(None); } // else unarmed stuff? diff --git a/common/src/comp/states/jump.rs b/common/src/comp/states/jump.rs index 3cb2a5aacd..f8c784e546 100644 --- a/common/src/comp/states/jump.rs +++ b/common/src/comp/states/jump.rs @@ -1,4 +1,4 @@ -use super::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; +use super::{EcsStateData, MoveState, StateHandler, StateUpdate}; use crate::event::LocalEvent; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -23,7 +23,7 @@ impl StateHandler for State { .emit(LocalEvent::Jump(*ecs_data.entity)); // Immediately go to falling state after jump impulse - update.character.move_state = Fall(None); + update.character.move_state = MoveState::Fall(None); return update; } } diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index 3947a0e565..0a509c1fe8 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -1,5 +1,6 @@ use crate::comp::{ - ActionState::*, DodgeKind::*, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData, + ActionState::Dodge, DodgeKind::Roll, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, + ToolData, }; use crate::util::state_utils::*; use std::time::Duration; diff --git a/common/src/comp/states/run.rs b/common/src/comp/states/run.rs index a2ca009956..15d8109769 100644 --- a/common/src/comp/states/run.rs +++ b/common/src/comp/states/run.rs @@ -1,4 +1,4 @@ -use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; use crate::util::state_utils::*; use vek::vec::{Vec2, Vec3}; @@ -31,13 +31,12 @@ impl StateHandler for State { }; // Set direction based on move direction when on the ground - let ori_dir = if update.character.action_state.is_attacking() - || update.character.action_state.is_blocking() - { - Vec2::from(ecs_data.inputs.look_dir).normalized() - } else { - Vec2::from(update.vel.0) - }; + let ori_dir = + if let ActionState::Attack(_) | ActionState::Block(_) = update.character.action_state { + Vec2::from(ecs_data.inputs.look_dir).normalized() + } else { + Vec2::from(update.vel.0) + }; if ori_dir.magnitude_squared() > 0.0001 && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() @@ -49,25 +48,25 @@ impl StateHandler for State { // Try to sit if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Sit(None); + update.character.move_state = MoveState::Sit(None); return update; } // Try to climb if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Climb(None); + update.character.move_state = MoveState::Climb(None); return update; } // Try to jump if can_jump(ecs_data.physics, ecs_data.inputs) { - update.character.move_state = Jump(None); + update.character.move_state = MoveState::Jump(None); return update; } // Try to glide if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Glide(None); + update.character.move_state = MoveState::Glide(None); return update; } diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs index 032cc4a27d..3de7e3fa41 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/comp/states/sit.rs @@ -1,4 +1,4 @@ -use crate::comp::{ActionState::*, EcsStateData, MoveState::*, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; use crate::util::state_utils::*; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -18,8 +18,8 @@ impl StateHandler for State { }; // Prevent action state handling - update.character.action_state = Idle(None); - update.character.move_state = Sit(None); + update.character.action_state = ActionState::Idle(None); + update.character.move_state = MoveState::Sit(None); // Try to Fall // ... maybe the ground disappears, @@ -31,19 +31,19 @@ impl StateHandler for State { } // Try to jump if ecs_data.inputs.jump.is_pressed() { - update.character.move_state = Jump(None); + update.character.move_state = MoveState::Jump(None); return update; } // Try to Run if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - update.character.move_state = Run(None); + update.character.move_state = MoveState::Run(None); return update; } // Try to Stand if ecs_data.inputs.sit.is_just_pressed() { - update.character.move_state = Stand(None); + update.character.move_state = MoveState::Stand(None); return update; } diff --git a/common/src/comp/states/stand.rs b/common/src/comp/states/stand.rs index 9536cc7a61..9b392567d5 100644 --- a/common/src/comp/states/stand.rs +++ b/common/src/comp/states/stand.rs @@ -1,4 +1,4 @@ -use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; +use crate::comp::{EcsStateData, MoveState, StateHandler, StateUpdate}; use crate::util::state_utils::*; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -19,25 +19,25 @@ impl StateHandler for State { // Try to sit if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Sit(None); + update.character.move_state = MoveState::Sit(None); return update; } // Try to climb if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Climb(None); + update.character.move_state = MoveState::Climb(None); return update; } // Try to jump if can_jump(ecs_data.physics, ecs_data.inputs) { - update.character.move_state = Jump(None); + update.character.move_state = MoveState::Jump(None); return update; } // Check gliding if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = Glide(None); + update.character.move_state = MoveState::Glide(None); return update; } diff --git a/common/src/comp/states/swim.rs b/common/src/comp/states/swim.rs index 8ccecc2b70..1b48b0f02f 100644 --- a/common/src/comp/states/swim.rs +++ b/common/src/comp/states/swim.rs @@ -1,4 +1,4 @@ -use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; use crate::sys::phys::GRAVITY; use std::time::Duration; use vek::{Vec2, Vec3}; @@ -32,13 +32,12 @@ impl StateHandler for State { }; // Set direction based on move direction when on the ground - let ori_dir = if update.character.action_state.is_attacking() - || update.character.action_state.is_blocking() - { - Vec2::from(ecs_data.inputs.look_dir).normalized() - } else { - Vec2::from(update.vel.0) - }; + let ori_dir = + if let ActionState::Attack(_) | ActionState::Block(_) = update.character.action_state { + Vec2::from(ecs_data.inputs.look_dir).normalized() + } else { + Vec2::from(update.vel.0) + }; if ori_dir.magnitude_squared() > 0.0001 && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() @@ -64,16 +63,16 @@ impl StateHandler for State { // Not on ground if !ecs_data.physics.on_ground { - update.character.move_state = Swim(None); + update.character.move_state = MoveState::Swim(None); return update; } // On ground else { // Return to running or standing based on move inputs update.character.move_state = if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - Run(None) + MoveState::Run(None) } else { - Stand(None) + MoveState::Stand(None) }; return update; diff --git a/common/src/comp/states/wield.rs b/common/src/comp/states/wield.rs index bcf9e0d582..651736c8f9 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/comp/states/wield.rs @@ -1,6 +1,4 @@ -use crate::comp::{ - ActionState::*, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData, -}; +use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData}; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -37,7 +35,7 @@ impl StateHandler for State { if ecs_data.inputs.toggle_wield.is_just_pressed() && ecs_data.character.action_state.is_equip_finished() { - update.character.action_state = Idle(None); + update.character.action_state = ActionState::Idle(None); return update; } @@ -54,7 +52,7 @@ impl StateHandler for State { } else { // Equip delay hasn't expired yet // Update wield delay - update.character.action_state = Wield(Some(State { + update.character.action_state = ActionState::Wield(Some(State { equip_delay: self .equip_delay .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) diff --git a/common/src/util/state_utils.rs b/common/src/util/state_utils.rs index e303e102e5..b4dc42806c 100644 --- a/common/src/util/state_utils.rs +++ b/common/src/util/state_utils.rs @@ -1,33 +1,25 @@ use crate::comp::{ - ActionState, ActionState::*, AttackKind::*, BasicAttackState, BasicBlockState, BlockKind::*, - Body, ControllerInputs, FallState, IdleState, ItemKind::Tool, MoveState, MoveState::*, - PhysicsState, RunState, StandState, Stats, SwimState, WieldState, + ActionState, ActionState::*, AttackKind::*, BlockKind::*, Body, ControllerInputs, + ItemKind::Tool, MoveState, MoveState::*, PhysicsState, Stats, }; -use std::time::Duration; /// _Determines what ability a player has selected for their primary ability, -/// and returns the corresponding `ActionState` -/// ... or Idle if nothing it possible?_ +/// and returns the corresponding `ActionState` or Idle if nothing_ pub fn determine_primary_ability(stats: &Stats) -> ActionState { - if let Some(Tool(data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { - Attack(BasicAttack(Some(BasicAttackState { - remaining_duration: data.attack_duration(), - }))) + if let Some(Tool(_)) = stats.equipment.main.as_ref().map(|i| &i.kind) { + Attack(BasicAttack(None)) } else { - Idle(Some(IdleState)) + Idle(None) } } /// _Determines what ability a player has selected for their primary ability, -/// and returns the corresponding `ActionState` -/// ... or Idle if nothing it possible?_ +/// and returns the corresponding `ActionState` or Idle if nothing_ pub fn determine_secondary_ability(stats: &Stats) -> ActionState { - if let Some(Tool(_data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { - Block(BasicBlock(Some(BasicBlockState { - active_duration: Duration::default(), - }))) + if let Some(Tool(_)) = stats.equipment.main.as_ref().map(|i| &i.kind) { + Block(BasicBlock(None)) } else { - Idle(Some(IdleState)) + Idle(None) } } @@ -35,18 +27,18 @@ pub fn determine_secondary_ability(stats: &Stats) -> ActionState { pub fn determine_fall_or_swim(physics: &PhysicsState) -> MoveState { // Check if in fluid to go to swimming or back to falling if physics.in_fluid { - Swim(Some(SwimState)) + Swim(None) } else { - Fall(Some(FallState)) + Fall(None) } } /// _Returns a `MoveState` based on `move_dir` magnitude_ pub fn determine_stand_or_run(inputs: &ControllerInputs) -> MoveState { // Return to running or standing based on move inputs if inputs.move_dir.magnitude_squared() > 0.0 { - Run(Some(RunState)) + Run(None) } else { - Stand(Some(StandState)) + Stand(None) } } @@ -71,11 +63,9 @@ pub fn determine_move_from_grounded_state( /// _Returns an ActionState based on whether character has a weapon equipped._ pub fn attempt_wield(stats: &Stats) -> ActionState { if let Some(Tool(data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { - Wield(Some(WieldState { - equip_delay: data.equip_time(), - })) + Wield(None) } else { - Idle(Some(IdleState)) + Idle(None) } } diff --git a/server/src/sys/entity_sync.rs b/server/src/sys/entity_sync.rs index a0d79fcb91..cb6c812353 100644 --- a/server/src/sys/entity_sync.rs +++ b/server/src/sys/entity_sync.rs @@ -238,7 +238,7 @@ impl<'a> System<'a> for Sys { if let Some(&character_state) = character_state { if last_character_state .get(entity) - .map(|&l| !character_state.is_same_state(&l.0)) + .map(|&l| !character_state.equals(&l.0)) .unwrap_or(true) { let _ = last_character_state.insert(entity, Last(character_state)); diff --git a/voxygen/src/audio/sfx/event_mapper.rs b/voxygen/src/audio/sfx/event_mapper.rs index 46c32fd7d5..e8fc1f01ba 100644 --- a/voxygen/src/audio/sfx/event_mapper.rs +++ b/voxygen/src/audio/sfx/event_mapper.rs @@ -5,9 +5,8 @@ use crate::audio::sfx::{SfxTriggerItem, SfxTriggers}; use client::Client; use common::{ comp::{ - ActionState, AttackKind::*, BasicAttackState, Body, CharacterState, DodgeKind::*, - FallState, GlideState, IdleState, ItemKind, MoveState, Pos, RollState, RunState, - StandState, Stats, SwordKind::*, ToolData, ToolKind::*, + ActionState, AttackKind::*, Body, CharacterState, DodgeKind::*, ItemKind, MoveState, Pos, + Stats, SwordKind::*, ToolData, ToolKind::*, }, event::{EventBus, SfxEvent, SfxEventItem}, }; @@ -325,8 +324,8 @@ mod tests { let result = SfxEventMapper::map_character_event( &CharacterState { - move_state: MoveState::Fall((None)), - action_state: ActionState::Idle((None)), + move_state: MoveState::Fall(None), + action_state: ActionState::Idle(None), }, SfxEvent::Idle, &stats, diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 797dead31d..b8dacc5ee1 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -161,10 +161,11 @@ impl FigureModelCache { }, if camera_mode != CameraMode::FirstPerson || character_state - .map(|cs| { - cs.action_state.is_attacking() - || cs.action_state.is_blocking() - || cs.action_state.is_wielding() + .map(|cs| match cs.action_state { + ActionState::Attack(_) + | ActionState::Block(_) + | ActionState::Wield(_) => true, + _ => false, }) .unwrap_or_default() { diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index c104a58df0..36ecdbaa3f 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -189,10 +189,13 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_move_state(&last_character.0) { + if !character.move_state.equals(&last_character.0.move_state) { state.move_state_time = 0.0; } - if !character.is_same_action_state(&last_character.0) { + if !character + .action_state + .equals(&last_character.0.action_state) + { state.action_time = 0.0; } @@ -332,7 +335,7 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_move_state(&last_character.0) { + if !character.move_state.equals(&last_character.0.move_state) { state.move_state_time = 0.0; } @@ -389,7 +392,7 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_move_state(&last_character.0) { + if !character.move_state.equals(&last_character.0.move_state) { state.move_state_time = 0.0; } @@ -444,7 +447,7 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_move_state(&last_character.0) { + if !character.move_state.equals(&last_character.0.move_state) { state.move_state_time = 0.0; } @@ -499,7 +502,7 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_move_state(&last_character.0) { + if !character.move_state.equals(&last_character.0.move_state) { state.move_state_time = 0.0; } @@ -554,7 +557,7 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_move_state(&last_character.0) { + if !character.move_state.equals(&last_character.0.move_state) { state.move_state_time = 0.0; } @@ -609,7 +612,7 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_move_state(&last_character.0) { + if !character.move_state.equals(&last_character.0.move_state) { state.move_state_time = 0.0; } @@ -664,7 +667,7 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_move_state(&last_character.0) { + if !character.move_state.equals(&last_character.0.move_state) { state.move_state_time = 0.0; } @@ -719,7 +722,7 @@ impl FigureMgr { _ => continue, }; - if !character.is_same_move_state(&last_character.0) { + if !character.move_state.equals(&last_character.0.move_state) { state.move_state_time = 0.0; } diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 52cc3efbbe..e489ff4b31 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -10,7 +10,7 @@ use client::{self, Client, Event::Chat}; use common::{ clock::Clock, comp, - comp::{Pos, Vel}, + comp::{ActionState, Pos, Vel}, msg::ClientState, terrain::{Block, BlockKind}, vol::ReadVol, @@ -201,10 +201,11 @@ impl PlayState for SessionState { .state() .read_storage::() .get(client.entity()) - .map(|cs| { - cs.action_state.is_wielding() - || cs.action_state.is_blocking() - || cs.action_state.is_attacking() + .map(|cs| match cs.action_state { + ActionState::Attack(_) + | ActionState::Block(_) + | ActionState::Wield(_) => true, + _ => false, }) .unwrap_or(false) { From 563e50b67d5a320c85370ce2aec366920450e15b Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Thu, 9 Jan 2020 08:23:20 -0800 Subject: [PATCH 025/326] Move utils file --- common/src/comp/states/basic_attack.rs | 2 +- common/src/comp/states/basic_block.rs | 2 +- common/src/comp/states/charge_attack.rs | 2 +- common/src/comp/states/fall.rs | 2 +- common/src/comp/states/mod.rs | 3 ++- common/src/comp/states/roll.rs | 2 +- common/src/comp/states/run.rs | 2 +- common/src/comp/states/sit.rs | 2 +- common/src/comp/states/stand.rs | 2 +- common/src/{util/state_utils.rs => comp/states/utils.rs} | 2 +- common/src/util/mod.rs | 2 -- 11 files changed, 11 insertions(+), 12 deletions(-) rename common/src/{util/state_utils.rs => comp/states/utils.rs} (97%) diff --git a/common/src/comp/states/basic_attack.rs b/common/src/comp/states/basic_attack.rs index 95b45ae968..eae687b2ad 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/comp/states/basic_attack.rs @@ -1,8 +1,8 @@ +use super::utils::*; use crate::comp::{ ActionState::Attack, AttackKind::BasicAttack, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData, }; -use crate::util::state_utils::*; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] diff --git a/common/src/comp/states/basic_block.rs b/common/src/comp/states/basic_block.rs index cc59682bd9..0c395a005e 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/comp/states/basic_block.rs @@ -1,5 +1,5 @@ +use super::utils::*; use crate::comp::{EcsStateData, StateHandler, StateUpdate}; -use crate::util::state_utils::*; use std::time::Duration; use vek::Vec2; diff --git a/common/src/comp/states/charge_attack.rs b/common/src/comp/states/charge_attack.rs index 040ae971d7..e437709f4f 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/comp/states/charge_attack.rs @@ -1,9 +1,9 @@ +use super::utils::*; use crate::comp::{ ActionState::Attack, AttackKind::Charge, EcsStateData, HealthChange, HealthSource, ItemKind::Tool, MoveState::Run, StateHandler, StateUpdate, ToolData, }; use crate::event::ServerEvent; -use crate::util::state_utils::*; use std::time::Duration; use vek::Vec3; diff --git a/common/src/comp/states/fall.rs b/common/src/comp/states/fall.rs index e94215c3ff..debabb5585 100644 --- a/common/src/comp/states/fall.rs +++ b/common/src/comp/states/fall.rs @@ -1,6 +1,6 @@ use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; -use crate::util::state_utils::*; +use super::utils::*; use vek::{Vec2, Vec3}; const HUMANOID_AIR_ACCEL: f32 = 10.0; diff --git a/common/src/comp/states/mod.rs b/common/src/comp/states/mod.rs index b064026210..35dc2cca21 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/comp/states/mod.rs @@ -12,6 +12,7 @@ pub mod run; pub mod sit; pub mod stand; pub mod swim; +pub mod utils; pub mod wield; use super::{ @@ -31,7 +32,7 @@ use super::{ /// /// ## Example Implementation: /// ``` -/// use crate::util::state_utils::*; +/// use super::utils::*; /// /// #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] /// pub struct RunState { diff --git a/common/src/comp/states/roll.rs b/common/src/comp/states/roll.rs index 0a509c1fe8..e081b0b98e 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/comp/states/roll.rs @@ -1,8 +1,8 @@ +use super::utils::*; use crate::comp::{ ActionState::Dodge, DodgeKind::Roll, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData, }; -use crate::util::state_utils::*; use std::time::Duration; use vek::Vec3; diff --git a/common/src/comp/states/run.rs b/common/src/comp/states/run.rs index 15d8109769..e863ea8c80 100644 --- a/common/src/comp/states/run.rs +++ b/common/src/comp/states/run.rs @@ -1,5 +1,5 @@ +use super::utils::*; use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; -use crate::util::state_utils::*; use vek::vec::{Vec2, Vec3}; const HUMANOID_ACCEL: f32 = 50.0; diff --git a/common/src/comp/states/sit.rs b/common/src/comp/states/sit.rs index 3de7e3fa41..24a2b11f48 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/comp/states/sit.rs @@ -1,5 +1,5 @@ +use super::utils::*; use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; -use crate::util::state_utils::*; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; diff --git a/common/src/comp/states/stand.rs b/common/src/comp/states/stand.rs index 9b392567d5..fd0dce5bb3 100644 --- a/common/src/comp/states/stand.rs +++ b/common/src/comp/states/stand.rs @@ -1,5 +1,5 @@ +use super::utils::*; use crate::comp::{EcsStateData, MoveState, StateHandler, StateUpdate}; -use crate::util::state_utils::*; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; diff --git a/common/src/util/state_utils.rs b/common/src/comp/states/utils.rs similarity index 97% rename from common/src/util/state_utils.rs rename to common/src/comp/states/utils.rs index b4dc42806c..b458596d15 100644 --- a/common/src/util/state_utils.rs +++ b/common/src/comp/states/utils.rs @@ -62,7 +62,7 @@ pub fn determine_move_from_grounded_state( /// _Returns an ActionState based on whether character has a weapon equipped._ pub fn attempt_wield(stats: &Stats) -> ActionState { - if let Some(Tool(data)) = stats.equipment.main.as_ref().map(|i| &i.kind) { + if let Some(Tool(_)) = stats.equipment.main.as_ref().map(|i| &i.kind) { Wield(None) } else { Idle(None) diff --git a/common/src/util/mod.rs b/common/src/util/mod.rs index dc154db236..01eebd1e19 100644 --- a/common/src/util/mod.rs +++ b/common/src/util/mod.rs @@ -7,8 +7,6 @@ lazy_static::lazy_static! { use vek::{Mat3, Rgb, Rgba, Vec3}; -pub mod state_utils; - /// TODO: Move these to a named utils folder. Are they even being used? I couldnt find references. /// This is a fast approximation of powf. This should only be used when minor accuracy loss is acceptable. #[inline(always)] From 1816d4b8052818d7d7c9c865a0e30ad0296a32ba Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sun, 12 Jan 2020 15:06:52 -0800 Subject: [PATCH 026/326] Move states/ to common/src/ --- common/src/comp/character_state.rs | 2 +- common/src/comp/mod.rs | 2 -- common/src/lib.rs | 1 + common/src/{comp => }/states/basic_attack.rs | 6 ++++-- common/src/{comp => }/states/basic_block.rs | 3 ++- common/src/{comp => }/states/charge_attack.rs | 3 ++- common/src/{comp => }/states/climb.rs | 0 common/src/{comp => }/states/fall.rs | 3 ++- common/src/{comp => }/states/glide.rs | 3 ++- common/src/{comp => }/states/idle.rs | 3 ++- common/src/{comp => }/states/jump.rs | 0 common/src/{comp => }/states/mod.rs | 2 +- common/src/{comp => }/states/roll.rs | 4 ++-- common/src/{comp => }/states/run.rs | 3 ++- common/src/{comp => }/states/sit.rs | 3 ++- common/src/{comp => }/states/stand.rs | 3 ++- common/src/{comp => }/states/swim.rs | 3 ++- common/src/{comp => }/states/utils.rs | 0 common/src/{comp => }/states/wield.rs | 3 ++- common/src/sys/ability.rs | 2 +- 20 files changed, 30 insertions(+), 19 deletions(-) rename common/src/{comp => }/states/basic_attack.rs (95%) rename common/src/{comp => }/states/basic_block.rs (94%) rename common/src/{comp => }/states/charge_attack.rs (96%) rename common/src/{comp => }/states/climb.rs (100%) rename common/src/{comp => }/states/fall.rs (95%) rename common/src/{comp => }/states/glide.rs (96%) rename common/src/{comp => }/states/idle.rs (95%) rename common/src/{comp => }/states/jump.rs (100%) rename common/src/{comp => }/states/mod.rs (99%) rename common/src/{comp => }/states/roll.rs (97%) rename common/src/{comp => }/states/run.rs (96%) rename common/src/{comp => }/states/sit.rs (93%) rename common/src/{comp => }/states/stand.rs (94%) rename common/src/{comp => }/states/swim.rs (96%) rename common/src/{comp => }/states/utils.rs (100%) rename common/src/{comp => }/states/wield.rs (97%) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 1c0091decd..9f4c342139 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,5 +1,5 @@ use self::ActionState::*; -use super::states::*; +use crate::states::*; use crate::{ comp::{Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel}, event::{EventBus, LocalEvent, ServerEvent}, diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 26a02bdef6..32f61832b5 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -11,7 +11,6 @@ mod location; mod phys; mod player; pub mod projectile; -pub mod states; mod stats; mod visual; @@ -40,6 +39,5 @@ pub use location::Waypoint; pub use phys::{ForceUpdate, Gravity, Mass, Ori, PhysicsState, Pos, Scale, Sticky, Vel}; pub use player::Player; pub use projectile::Projectile; -pub use states::*; pub use stats::{Equipment, Exp, HealthChange, HealthSource, Level, Stats}; pub use visual::LightEmitter; diff --git a/common/src/lib.rs b/common/src/lib.rs index eab693848d..230448ef3c 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -20,6 +20,7 @@ pub mod pathfinding; pub mod ray; pub mod region; pub mod state; +pub mod states; pub mod sys; pub mod terrain; pub mod util; diff --git a/common/src/comp/states/basic_attack.rs b/common/src/states/basic_attack.rs similarity index 95% rename from common/src/comp/states/basic_attack.rs rename to common/src/states/basic_attack.rs index eae687b2ad..7ff7f1f4be 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -1,8 +1,10 @@ use super::utils::*; use crate::comp::{ - ActionState::Attack, AttackKind::BasicAttack, EcsStateData, ItemKind::Tool, StateHandler, - StateUpdate, ToolData, + ActionState::Attack, AttackKind::BasicAttack, EcsStateData, ItemKind::Tool, StateUpdate, + ToolData, }; +use crate::states::StateHandler; + use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] diff --git a/common/src/comp/states/basic_block.rs b/common/src/states/basic_block.rs similarity index 94% rename from common/src/comp/states/basic_block.rs rename to common/src/states/basic_block.rs index 0c395a005e..a71e0cb078 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -1,5 +1,6 @@ use super::utils::*; -use crate::comp::{EcsStateData, StateHandler, StateUpdate}; +use crate::comp::{EcsStateData, StateUpdate}; +use crate::states::StateHandler; use std::time::Duration; use vek::Vec2; diff --git a/common/src/comp/states/charge_attack.rs b/common/src/states/charge_attack.rs similarity index 96% rename from common/src/comp/states/charge_attack.rs rename to common/src/states/charge_attack.rs index e437709f4f..bbe20d082d 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/states/charge_attack.rs @@ -1,9 +1,10 @@ use super::utils::*; use crate::comp::{ ActionState::Attack, AttackKind::Charge, EcsStateData, HealthChange, HealthSource, - ItemKind::Tool, MoveState::Run, StateHandler, StateUpdate, ToolData, + ItemKind::Tool, MoveState::Run, StateUpdate, ToolData, }; use crate::event::ServerEvent; +use crate::states::StateHandler; use std::time::Duration; use vek::Vec3; diff --git a/common/src/comp/states/climb.rs b/common/src/states/climb.rs similarity index 100% rename from common/src/comp/states/climb.rs rename to common/src/states/climb.rs diff --git a/common/src/comp/states/fall.rs b/common/src/states/fall.rs similarity index 95% rename from common/src/comp/states/fall.rs rename to common/src/states/fall.rs index debabb5585..35f3870823 100644 --- a/common/src/comp/states/fall.rs +++ b/common/src/states/fall.rs @@ -1,6 +1,7 @@ -use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; use super::utils::*; +use crate::states::StateHandler; use vek::{Vec2, Vec3}; const HUMANOID_AIR_ACCEL: f32 = 10.0; diff --git a/common/src/comp/states/glide.rs b/common/src/states/glide.rs similarity index 96% rename from common/src/comp/states/glide.rs rename to common/src/states/glide.rs index f436fddca4..8058ddaa8c 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,4 +1,5 @@ -use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::states::StateHandler; use vek::{Vec2, Vec3}; // Gravity is 9.81 * 4, so this makes gravity equal to .15 diff --git a/common/src/comp/states/idle.rs b/common/src/states/idle.rs similarity index 95% rename from common/src/comp/states/idle.rs rename to common/src/states/idle.rs index 46af0a47fb..b64795c67e 100644 --- a/common/src/comp/states/idle.rs +++ b/common/src/states/idle.rs @@ -1,5 +1,6 @@ -use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateUpdate}; +use crate::states::StateHandler; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; diff --git a/common/src/comp/states/jump.rs b/common/src/states/jump.rs similarity index 100% rename from common/src/comp/states/jump.rs rename to common/src/states/jump.rs diff --git a/common/src/comp/states/mod.rs b/common/src/states/mod.rs similarity index 99% rename from common/src/comp/states/mod.rs rename to common/src/states/mod.rs index 35dc2cca21..78d650f9b3 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/states/mod.rs @@ -15,7 +15,7 @@ pub mod swim; pub mod utils; pub mod wield; -use super::{ +use crate::comp::{ ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData, MoveState, MoveState::*, StateUpdate, }; diff --git a/common/src/comp/states/roll.rs b/common/src/states/roll.rs similarity index 97% rename from common/src/comp/states/roll.rs rename to common/src/states/roll.rs index e081b0b98e..1600e009d1 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,8 +1,8 @@ use super::utils::*; use crate::comp::{ - ActionState::Dodge, DodgeKind::Roll, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, - ToolData, + ActionState::Dodge, DodgeKind::Roll, EcsStateData, ItemKind::Tool, StateUpdate, ToolData, }; +use crate::states::StateHandler; use std::time::Duration; use vek::Vec3; diff --git a/common/src/comp/states/run.rs b/common/src/states/run.rs similarity index 96% rename from common/src/comp/states/run.rs rename to common/src/states/run.rs index e863ea8c80..5b2f880738 100644 --- a/common/src/comp/states/run.rs +++ b/common/src/states/run.rs @@ -1,5 +1,6 @@ use super::utils::*; -use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::states::StateHandler; use vek::vec::{Vec2, Vec3}; const HUMANOID_ACCEL: f32 = 50.0; diff --git a/common/src/comp/states/sit.rs b/common/src/states/sit.rs similarity index 93% rename from common/src/comp/states/sit.rs rename to common/src/states/sit.rs index 24a2b11f48..e92f35a2e0 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/states/sit.rs @@ -1,5 +1,6 @@ use super::utils::*; -use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::states::StateHandler; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; diff --git a/common/src/comp/states/stand.rs b/common/src/states/stand.rs similarity index 94% rename from common/src/comp/states/stand.rs rename to common/src/states/stand.rs index fd0dce5bb3..e772c560d0 100644 --- a/common/src/comp/states/stand.rs +++ b/common/src/states/stand.rs @@ -1,5 +1,6 @@ use super::utils::*; -use crate::comp::{EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{EcsStateData, MoveState, StateUpdate}; +use crate::states::StateHandler; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; diff --git a/common/src/comp/states/swim.rs b/common/src/states/swim.rs similarity index 96% rename from common/src/comp/states/swim.rs rename to common/src/states/swim.rs index 1b48b0f02f..16b0e1406b 100644 --- a/common/src/comp/states/swim.rs +++ b/common/src/states/swim.rs @@ -1,4 +1,5 @@ -use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::states::StateHandler; use crate::sys::phys::GRAVITY; use std::time::Duration; use vek::{Vec2, Vec3}; diff --git a/common/src/comp/states/utils.rs b/common/src/states/utils.rs similarity index 100% rename from common/src/comp/states/utils.rs rename to common/src/states/utils.rs diff --git a/common/src/comp/states/wield.rs b/common/src/states/wield.rs similarity index 97% rename from common/src/comp/states/wield.rs rename to common/src/states/wield.rs index 651736c8f9..7d91706b3f 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/states/wield.rs @@ -1,4 +1,5 @@ -use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData}; +use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; +use crate::states::StateHandler; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] diff --git a/common/src/sys/ability.rs b/common/src/sys/ability.rs index 99b173c89d..f4569f0b0b 100644 --- a/common/src/sys/ability.rs +++ b/common/src/sys/ability.rs @@ -2,8 +2,8 @@ #![allow(dead_code)] use crate::comp::{ AbilityAction, AbilityActionKind, AbilityPool, ActionState::*, AttackKind, CharacterState, - StateHandler, }; +use crate::states::StateHandler; use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; From 71a39c36777b99279d3969d3559bfd0349cf5fb8 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sun, 12 Jan 2020 15:14:08 -0800 Subject: [PATCH 027/326] Update update return statements --- common/src/states/basic_attack.rs | 2 +- common/src/states/basic_block.rs | 2 +- common/src/states/charge_attack.rs | 2 +- common/src/states/climb.rs | 2 +- common/src/states/fall.rs | 2 +- common/src/states/glide.rs | 2 +- common/src/states/idle.rs | 2 +- common/src/states/jump.rs | 2 +- common/src/states/mod.rs | 4 ++-- common/src/states/roll.rs | 2 +- common/src/states/run.rs | 2 +- common/src/states/sit.rs | 2 +- common/src/states/stand.rs | 2 +- common/src/states/swim.rs | 4 ++-- common/src/states/wield.rs | 2 +- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index 7ff7f1f4be..99e44201d6 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -49,6 +49,6 @@ impl StateHandler for State { .unwrap_or_default(), }))); - return update; + update } } diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index a71e0cb078..4952691d72 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -43,6 +43,6 @@ impl StateHandler for State { return update; } - return update; + update } } diff --git a/common/src/states/charge_attack.rs b/common/src/states/charge_attack.rs index bbe20d082d..c5f11ffc1e 100644 --- a/common/src/states/charge_attack.rs +++ b/common/src/states/charge_attack.rs @@ -84,6 +84,6 @@ impl StateHandler for State { .unwrap_or_default(), }))); - return update; + update } } diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 09450d4160..a42175e874 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -98,6 +98,6 @@ impl StateHandler for State { } } - return update; + update } } diff --git a/common/src/states/fall.rs b/common/src/states/fall.rs index 35f3870823..0ee2ae18f7 100644 --- a/common/src/states/fall.rs +++ b/common/src/states/fall.rs @@ -64,6 +64,6 @@ impl StateHandler for State { update.character.move_state = determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); - return update; + update } } diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 8058ddaa8c..4fc0b8bb0f 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -77,6 +77,6 @@ impl StateHandler for State { } // Otherwise keep gliding - return update; + update } } diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index b64795c67e..c9c18aa690 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -30,6 +30,6 @@ impl StateHandler for State { // else unarmed stuff? } - return update; + update } } diff --git a/common/src/states/jump.rs b/common/src/states/jump.rs index f8c784e546..13fcd80e81 100644 --- a/common/src/states/jump.rs +++ b/common/src/states/jump.rs @@ -24,6 +24,6 @@ impl StateHandler for State { // Immediately go to falling state after jump impulse update.character.move_state = MoveState::Fall(None); - return update; + update } } diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 78d650f9b3..1bed45136f 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -69,14 +69,14 @@ use crate::comp::{ /// // Try to jump /// if state_utils::can_jump(ecs_data.physics, ecs_data.inputs) { /// update.character.move_state = Jump(None); -/// return update; +/// update /// } /// /// // Update based on groundedness /// update.character.move_state = /// state_utils::determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); /// -/// return update; +/// update /// } /// } /// ``` diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 1600e009d1..1f3391ae9b 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -64,6 +64,6 @@ impl StateHandler for State { }))); // Keep rolling - return update; + update } } diff --git a/common/src/states/run.rs b/common/src/states/run.rs index 5b2f880738..366ae80dab 100644 --- a/common/src/states/run.rs +++ b/common/src/states/run.rs @@ -75,6 +75,6 @@ impl StateHandler for State { update.character.move_state = determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); - return update; + update } } diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index e92f35a2e0..47b8fb9aff 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -49,6 +49,6 @@ impl StateHandler for State { } // No move has occurred, keep sitting - return update; + update } } diff --git a/common/src/states/stand.rs b/common/src/states/stand.rs index e772c560d0..3068f9e993 100644 --- a/common/src/states/stand.rs +++ b/common/src/states/stand.rs @@ -46,6 +46,6 @@ impl StateHandler for State { update.character.move_state = determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); - return update; + update } } diff --git a/common/src/states/swim.rs b/common/src/states/swim.rs index 16b0e1406b..675e7b0478 100644 --- a/common/src/states/swim.rs +++ b/common/src/states/swim.rs @@ -65,7 +65,7 @@ impl StateHandler for State { // Not on ground if !ecs_data.physics.on_ground { update.character.move_state = MoveState::Swim(None); - return update; + update } // On ground else { @@ -76,7 +76,7 @@ impl StateHandler for State { MoveState::Stand(None) }; - return update; + update } } } diff --git a/common/src/states/wield.rs b/common/src/states/wield.rs index 7d91706b3f..508e400113 100644 --- a/common/src/states/wield.rs +++ b/common/src/states/wield.rs @@ -61,6 +61,6 @@ impl StateHandler for State { })); } - return update; + update } } From 5959d2a5c7ed7e5a50f928f40ee455de3eeeb917 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Thu, 16 Jan 2020 05:28:45 -0800 Subject: [PATCH 028/326] Fix SFX and Assets --- assets/common/items/weapons/hammer_1.ron | 12 ++++++--- assets/common/items/weapons/staff_1.ron | 10 ++++++-- assets/voxygen/audio/sfx.ron | 15 +++-------- common/src/comp/character_state.rs | 2 +- common/src/comp/controller.rs | 2 +- common/src/event.rs | 10 ++++++-- common/src/msg/ecs_packet.rs | 25 +++++++++++++++++++ common/src/sys/character_state.rs | 2 +- common/src/sys/controller.rs | 1 - common/src/sys/mod.rs | 8 +----- .../src/audio/sfx/event_mapper/movement.rs | 16 +++++++----- voxygen/src/hud/skillbar.rs | 1 - 12 files changed, 67 insertions(+), 37 deletions(-) diff --git a/assets/common/items/weapons/hammer_1.ron b/assets/common/items/weapons/hammer_1.ron index badb1732cc..13862f88c2 100644 --- a/assets/common/items/weapons/hammer_1.ron +++ b/assets/common/items/weapons/hammer_1.ron @@ -2,7 +2,13 @@ Item( name: "Crude Mallet", description: "Breaks bones like sticks and stones.", kind: Tool( - kind: Hammer, - power: 20, - ), + ToolData ( + kind: Hammer, + equip_time_millis: 1000, + attack_buildup_millis: 700, + attack_recover_millis: 100, + range: 3, + base_damage: 10, + ) + ) ) diff --git a/assets/common/items/weapons/staff_1.ron b/assets/common/items/weapons/staff_1.ron index 59e41d09ed..cb1bc62358 100644 --- a/assets/common/items/weapons/staff_1.ron +++ b/assets/common/items/weapons/staff_1.ron @@ -2,7 +2,13 @@ Item( name: "Humble Stick", description: "Walking stick with a sharpened end.", kind: Tool( - kind: Hammer, - power: 6, + ToolData ( + kind: Staff, + equip_time_millis: 800, + attack_buildup_millis: 400, + attack_recover_millis: 300, + range: 3, + base_damage: 10, + ) ), ) diff --git a/assets/voxygen/audio/sfx.ron b/assets/voxygen/audio/sfx.ron index a4b560db4b..f7cbb166c7 100644 --- a/assets/voxygen/audio/sfx.ron +++ b/assets/voxygen/audio/sfx.ron @@ -23,26 +23,17 @@ ], threshold: 0.5, ), - ( - trigger: Attack(Sword(Rapier)), + Attack(Melee): ( files: [ "voxygen.audio.sfx.weapon.sword", ], threshold: 0.5, ), - ( - trigger: Attack(Hammer), - files: [ - "voxygen.audio.sfx.weapon.sword", - ], - threshold: 0.5, - ), - ( - trigger: Attack(Bow), + Attack(Bow): ( files: [ "voxygen.audio.sfx.weapon.bow", ], threshold: 0.5, ), - ], + } ) \ No newline at end of file diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 9f4c342139..2eef455fd4 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -4,12 +4,12 @@ use crate::{ comp::{Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel}, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, + sync::Uid, }; use serde::Deserialize; use serde::Serialize; use specs::LazyUpdate; use specs::{Component, Entity, FlaggedStorage, HashMapStorage, NullStorage}; -use sphynx::Uid; use std::time::Duration; pub struct EcsStateData<'a> { diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 0ef19b369b..0db076fb8d 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -69,7 +69,7 @@ impl Input { (self.is_pressed() && self.duration >= DEFAULT_HOLD_DURATION) } - // Whether input has been pressed for longer than `threshold` + /// Whether input has been pressed for longer than `threshold` pub fn is_long_press(&self, threshold: Duration) -> bool { (self.is_pressed() && self.duration >= threshold) } diff --git a/common/src/event.rs b/common/src/event.rs index e2fed9f153..803fe06362 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -20,7 +20,13 @@ impl SfxEventItem { Self { sfx, pos: None } } } - +#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Hash, Eq)] +/// Which Kind of Attack Sfx to play, +pub enum AttackSFX { + // Decouples attack sfx assets from attack kinds + Melee, + Bow, +} #[derive(Copy, Clone, Debug, PartialEq, Deserialize, Hash, Eq)] pub enum SfxEvent { Idle, @@ -42,7 +48,7 @@ pub enum SfxEvent { LevelUp, LightLantern, ExtinguishLantern, - Attack(ToolKind), + Attack(AttackSFX), AttackWolf, } diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index 4043d2c895..9809115c45 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -70,6 +70,11 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Mass(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Gravity(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::OverrideAction(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::OverrideMove(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::OverrideState(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::AbilityAction(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::AbilityPool(comp) => sync::handle_insert(comp, entity, world), } } fn apply_modify(self, entity: specs::Entity, world: &specs::World) { @@ -87,6 +92,11 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Mass(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Gravity(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::OverrideAction(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::OverrideMove(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::OverrideState(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::AbilityAction(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::AbilityPool(comp) => sync::handle_modify(comp, entity, world), } } fn apply_remove(phantom: Self::Phantom, entity: specs::Entity, world: &specs::World) { @@ -106,6 +116,21 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPhantom::Mass(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Gravity(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Sticky(_) => sync::handle_remove::(entity, world), + EcsCompPhantom::OverrideAction(_) => { + sync::handle_remove::(entity, world) + } + EcsCompPhantom::OverrideMove(_) => { + sync::handle_remove::(entity, world) + } + EcsCompPhantom::OverrideState(_) => { + sync::handle_remove::(entity, world) + } + EcsCompPhantom::AbilityAction(_) => { + sync::handle_remove::(entity, world) + } + EcsCompPhantom::AbilityPool(_) => { + sync::handle_remove::(entity, world) + } } } } diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 54ce8de3dd..258abe8cee 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -5,10 +5,10 @@ use crate::{ }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, + sync::{Uid, UidAllocator}, }; use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; -use sphynx::{Uid, UidAllocator}; /// ## Character State System /// #### Calls updates to `CharacterState`s. Acts on tuples of ( `CharacterState`, `Pos`, `Vel`, and `Ori` ). diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index 0a0cc83966..a5e1cb8ccd 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -8,7 +8,6 @@ use specs::{ saveload::{Marker, MarkerAllocator}, Entities, Join, Read, ReadStorage, System, WriteStorage, }; -use sphynx::{Uid, UidAllocator}; /// # Controller System /// #### Responsible for validating and updating controller inputs diff --git a/common/src/sys/mod.rs b/common/src/sys/mod.rs index c95d54b6e6..f8b2fa5627 100644 --- a/common/src/sys/mod.rs +++ b/common/src/sys/mod.rs @@ -3,7 +3,6 @@ pub mod agent; pub mod character_state; pub mod controller; mod mount; -pub mod movement; pub mod phys; mod projectile; mod stats; @@ -18,7 +17,6 @@ pub const AGENT_SYS: &str = "agent_sys"; pub const CONTROLLER_SYS: &str = "controller_sys"; pub const MOUNT_SYS: &str = "mount_sys"; pub const PHYS_SYS: &str = "phys_sys"; -pub const MOVEMENT_SYS: &str = "movement_sys"; pub const PROJECTILE_SYS: &str = "projectile_sys"; pub const STATS_SYS: &str = "stats_sys"; pub const CLEANUP_SYS: &str = "cleanup_sys"; @@ -30,10 +28,6 @@ pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) { dispatch_builder.add(character_state::Sys, CHARACTER_STATE_SYS, &[CONTROLLER_SYS]); dispatch_builder.add(stats::Sys, STATS_SYS, &[]); dispatch_builder.add(ability::Sys, ABILITY_SYS, &[CHARACTER_STATE_SYS]); - dispatch_builder.add( - phys::Sys, - PHYS_SYS, - &[CONTROLLER_SYS, MOUNT_SYS, MOVEMENT_SYS, STATS_SYS], - ); + dispatch_builder.add(phys::Sys, PHYS_SYS, &[CONTROLLER_SYS, MOUNT_SYS, STATS_SYS]); dispatch_builder.add(projectile::Sys, PROJECTILE_SYS, &[PHYS_SYS]); } diff --git a/voxygen/src/audio/sfx/event_mapper/movement.rs b/voxygen/src/audio/sfx/event_mapper/movement.rs index 67d884953f..fda1239ba9 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement.rs @@ -126,8 +126,12 @@ impl MovementEventMapper { /// as opening or closing the glider. These methods translate those entity states with some additional /// data into more specific `SfxEvent`'s which we attach sounds to fn map_movement_event(current_event: &CharacterState, previous_event: SfxEvent) -> SfxEvent { - match (current_event.movement, current_event.action, previous_event) { - (_, ActionState::Roll(_), _) => SfxEvent::Roll, + match ( + current_event.move_state, + current_event.action_state, + previous_event, + ) { + (_, ActionState::Dodge(_), _) => SfxEvent::Roll, (MoveState::Climb(_), ..) => SfxEvent::Climb, (MoveState::Swim(_), ..) => SfxEvent::Swim, (MoveState::Run(_), ..) => SfxEvent::Run, @@ -290,8 +294,8 @@ mod tests { fn maps_land_on_ground_to_run() { let result = MovementEventMapper::map_movement_event( &CharacterState { - movement: MovementState::Stand, - action: ActionState::Idle, + move_state: MoveState::Stand(None), + action_state: ActionState::Idle(None), }, SfxEvent::Fall, ); @@ -342,8 +346,8 @@ mod tests { fn maps_glider_close_when_landing() { let result = MovementEventMapper::map_movement_event( &CharacterState { - movement: MoveState::Stand(None), - action: ActionState::Idle(None), + move_state: MoveState::Stand(None), + action_state: ActionState::Idle(None), }, SfxEvent::Glide, ); diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index f65b28496b..771ce9c725 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -119,7 +119,6 @@ impl<'a> Skillbar<'a> { fonts, stats, energy, - global_state, current_resource: ResourceType::Mana, common: widget::CommonBuilder::default(), pulse, From 976eface66a67b254ceb284cabd78bb524b691c1 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 17 Jan 2020 08:39:21 -0800 Subject: [PATCH 029/326] Update from MR comments --- common/src/comp/character_state.rs | 20 +--------------- common/src/comp/mod.rs | 2 +- common/src/event.rs | 1 - common/src/msg/ecs_packet.rs | 21 ----------------- common/src/state.rs | 3 --- common/src/states/mod.rs | 23 ++++--------------- common/src/sys/agent.rs | 4 +--- common/src/sys/character_state.rs | 23 ++++--------------- .../src/audio/sfx/event_mapper/movement.rs | 8 ++----- 9 files changed, 15 insertions(+), 90 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 2eef455fd4..5fd75a0924 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -9,7 +9,7 @@ use crate::{ use serde::Deserialize; use serde::Serialize; use specs::LazyUpdate; -use specs::{Component, Entity, FlaggedStorage, HashMapStorage, NullStorage}; +use specs::{Component, Entity, FlaggedStorage, HashMapStorage}; use std::time::Duration; pub struct EcsStateData<'a> { @@ -159,21 +159,3 @@ impl Default for CharacterState { impl Component for CharacterState { type Storage = FlaggedStorage>; } - -#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct OverrideState; -impl Component for OverrideState { - type Storage = FlaggedStorage>; -} - -#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct OverrideAction; -impl Component for OverrideAction { - type Storage = FlaggedStorage>; -} - -#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct OverrideMove; -impl Component for OverrideMove { - type Storage = FlaggedStorage>; -} diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 4dcc7d7172..6457cdee37 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -25,7 +25,7 @@ pub use body::{ }; pub use character_state::{ ActionState, AttackKind, BlockKind, CharacterState, DodgeKind, EcsStateData, MoveState, - OverrideAction, OverrideMove, OverrideState, StateUpdate, + StateUpdate, }; pub use controller::{ ControlEvent, Controller, ControllerInputs, Input, InputState, InventoryManip, MountState, diff --git a/common/src/event.rs b/common/src/event.rs index 803fe06362..04f393d38c 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -1,5 +1,4 @@ use crate::{comp, sync::Uid}; -use comp::item::ToolKind; use parking_lot::Mutex; use serde::Deserialize; use specs::Entity as EcsEntity; diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index 9809115c45..f918cbb344 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -21,9 +21,6 @@ sum_type! { Mass(comp::Mass), Gravity(comp::Gravity), Sticky(comp::Sticky), - OverrideAction(comp::OverrideAction), - OverrideMove(comp::OverrideMove), - OverrideState(comp::OverrideState), AbilityAction(comp::AbilityAction), AbilityPool(comp::AbilityPool), } @@ -46,9 +43,6 @@ sum_type! { Mass(PhantomData), Gravity(PhantomData), Sticky(PhantomData), - OverrideAction(PhantomData), - OverrideMove(PhantomData), - OverrideState(PhantomData), AbilityAction(PhantomData), AbilityPool(PhantomData), } @@ -70,9 +64,6 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Mass(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Gravity(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_insert(comp, entity, world), - EcsCompPacket::OverrideAction(comp) => sync::handle_insert(comp, entity, world), - EcsCompPacket::OverrideMove(comp) => sync::handle_insert(comp, entity, world), - EcsCompPacket::OverrideState(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::AbilityAction(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::AbilityPool(comp) => sync::handle_insert(comp, entity, world), } @@ -92,9 +83,6 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Mass(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Gravity(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_modify(comp, entity, world), - EcsCompPacket::OverrideAction(comp) => sync::handle_modify(comp, entity, world), - EcsCompPacket::OverrideMove(comp) => sync::handle_modify(comp, entity, world), - EcsCompPacket::OverrideState(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::AbilityAction(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::AbilityPool(comp) => sync::handle_modify(comp, entity, world), } @@ -116,15 +104,6 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPhantom::Mass(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Gravity(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Sticky(_) => sync::handle_remove::(entity, world), - EcsCompPhantom::OverrideAction(_) => { - sync::handle_remove::(entity, world) - } - EcsCompPhantom::OverrideMove(_) => { - sync::handle_remove::(entity, world) - } - EcsCompPhantom::OverrideState(_) => { - sync::handle_remove::(entity, world) - } EcsCompPhantom::AbilityAction(_) => { sync::handle_remove::(entity, world) } diff --git a/common/src/state.rs b/common/src/state.rs index d5d8e1cf21..430b86bb52 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -110,9 +110,6 @@ impl State { ecs.register::(); ecs.register::(); ecs.register::(); - ecs.register::(); - ecs.register::(); - ecs.register::(); ecs.register::(); ecs.register::(); ecs.register::(); diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 1bed45136f..d95186eaf9 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -32,7 +32,7 @@ use crate::comp::{ /// /// ## Example Implementation: /// ``` -/// use super::utils::*; +/// use crate::states::utils; /// /// #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] /// pub struct RunState { @@ -54,27 +54,12 @@ use crate::comp::{ /// ori: *ecs_data.ori, /// }; /// -/// // Update player's Vel -/// update.vel.0 += Vec2::broadcast(ecs_data.dt.0) -/// * ecs_data.inputs.move_dir -/// * if update.vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { -/// HUMANOID_ACCEL -/// } else { -/// 0.0 -/// }; -/// /// // -- snip -- -/// // Other updates; checks for gliding, climbing, etc. -/// -/// // Try to jump -/// if state_utils::can_jump(ecs_data.physics, ecs_data.inputs) { -/// update.character.move_state = Jump(None); -/// update -/// } +/// // Updates; checks for gliding, climbing, etc. /// /// // Update based on groundedness /// update.character.move_state = -/// state_utils::determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); +/// utils::determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); /// /// update /// } @@ -125,6 +110,7 @@ impl ActionState { } } + // TODO: remove when we split up character states into SingleAction and MultiAction enum variants /// Returns whether a given `ActionState` overrides `MoveState` `handle()`ing pub fn overrides_move_state(&self) -> bool { match self { @@ -149,6 +135,7 @@ impl ActionState { // fn's that relate to individual `MoveState`s // or passing data from system to handlers impl MoveState { + // TODO: remove when we split up character states into SingleAction and MultiAction enum variants /// Passes data to variant or subvariant handlers /// States contain `Option`s, and will be /// `None` if state data has not been initialized. So we have to diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index 98460e3248..272462f3f6 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -1,6 +1,4 @@ -use crate::comp::{ - Agent, CharacterState, Controller, ControllerInputs, MountState, MoveState::Glide, Pos, Stats, -}; +use crate::comp::{Agent, CharacterState, Controller, MountState, MoveState::Glide, Pos, Stats}; use crate::hierarchical::ChunkPath; use crate::pathfinding::WorldPath; use crate::terrain::TerrainGrid; diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 258abe8cee..151b0a3791 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - Body, CharacterState, Controller, EcsStateData, Mounting, MoveState::*, Ori, - OverrideAction, OverrideMove, OverrideState, PhysicsState, Pos, Stats, Vel, + Body, CharacterState, Controller, EcsStateData, Mounting, MoveState::*, Ori, PhysicsState, + Pos, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -35,9 +35,6 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, PhysicsState>, ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, - ReadStorage<'a, OverrideState>, - ReadStorage<'a, OverrideMove>, - ReadStorage<'a, OverrideAction>, ); fn run( &mut self, @@ -58,12 +55,9 @@ impl<'a> System<'a> for Sys { physics_states, uids, mountings, - state_overrides, - move_overrides, - action_overrides, ): Self::SystemData, ) { - for (entity, uid, mut character, pos, vel, ori, controller, stats, body, physics, ()) in ( + for (entity, uid, mut character, pos, vel, ori, controller, stats, body, physics) in ( &entities, &uids, &mut character_states, @@ -74,7 +68,6 @@ impl<'a> System<'a> for Sys { &stats, &bodies, &physics_states, - !&state_overrides, ) .join() { @@ -99,10 +92,7 @@ impl<'a> System<'a> for Sys { } // Determine new action if character can act - if let (None, false) = ( - action_overrides.get(entity), - character.move_state.overrides_action_state(), - ) { + if !character.move_state.overrides_action_state() { let state_update = character.action_state.update(&EcsStateData { entity: &entity, uid, @@ -127,10 +117,7 @@ impl<'a> System<'a> for Sys { } // Determine new move state if character can move - if let (None, false) = ( - move_overrides.get(entity), - character.action_state.overrides_move_state(), - ) { + if !character.action_state.overrides_move_state() { let state_update = character.move_state.update(&EcsStateData { entity: &entity, uid, diff --git a/voxygen/src/audio/sfx/event_mapper/movement.rs b/voxygen/src/audio/sfx/event_mapper/movement.rs index fda1239ba9..eecf6d7752 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement.rs @@ -4,10 +4,7 @@ use crate::audio::sfx::{SfxTriggerItem, SfxTriggers}; use client::Client; use common::{ - comp::{ - ActionState, AttackKind::*, Body, CharacterState, DodgeKind::*, ItemKind, MoveState, Pos, - Stats, SwordKind::*, ToolData, ToolKind::*, - }, + comp::{ActionState, Body, CharacterState, MoveState, Pos}, event::{EventBus, SfxEvent, SfxEventItem}, }; use hashbrown::HashMap; @@ -157,8 +154,7 @@ impl MovementEventMapper { mod tests { use super::*; use common::{ - assets, - comp::{ActionState, MoveState, Stats}, + comp::{ActionState, CharacterState, DodgeKind::*, MoveState}, event::SfxEvent, }; use std::time::{Duration, Instant}; From 7353ab3432fd32783fc8e38cd2c3c1733ce1ecb7 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 18 Jan 2020 05:13:25 -0800 Subject: [PATCH 030/326] Undo sfx changes --- .gitignore | 3 +++ assets/voxygen/audio/sfx.ron | 12 ------------ common/src/event.rs | 10 ++-------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 4422efb240..0769e0f20c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ todo.txt # direnv /.envrc *.bat + +# Mac +.DS_Store \ No newline at end of file diff --git a/assets/voxygen/audio/sfx.ron b/assets/voxygen/audio/sfx.ron index f7cbb166c7..8310f26c09 100644 --- a/assets/voxygen/audio/sfx.ron +++ b/assets/voxygen/audio/sfx.ron @@ -23,17 +23,5 @@ ], threshold: 0.5, ), - Attack(Melee): ( - files: [ - "voxygen.audio.sfx.weapon.sword", - ], - threshold: 0.5, - ), - Attack(Bow): ( - files: [ - "voxygen.audio.sfx.weapon.bow", - ], - threshold: 0.5, - ), } ) \ No newline at end of file diff --git a/common/src/event.rs b/common/src/event.rs index 04f393d38c..5251358ace 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -19,13 +19,7 @@ impl SfxEventItem { Self { sfx, pos: None } } } -#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Hash, Eq)] -/// Which Kind of Attack Sfx to play, -pub enum AttackSFX { - // Decouples attack sfx assets from attack kinds - Melee, - Bow, -} + #[derive(Copy, Clone, Debug, PartialEq, Deserialize, Hash, Eq)] pub enum SfxEvent { Idle, @@ -47,7 +41,7 @@ pub enum SfxEvent { LevelUp, LightLantern, ExtinguishLantern, - Attack(AttackSFX), + Attack, AttackWolf, } From 7b558b45421044a14c8a369a612600c8542b601b Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 21 Jan 2020 23:54:32 +0100 Subject: [PATCH 031/326] refactor: combine actionstate and movestate --- common/src/comp/ability.rs | 8 +- common/src/comp/character_state.rs | 150 ++--- common/src/comp/mod.rs | 5 +- common/src/states/climb.rs | 17 +- common/src/states/glide.rs | 25 +- common/src/states/idle.rs | 22 +- common/src/states/mod.rs | 136 +---- common/src/states/roll.rs | 15 +- common/src/states/run.rs | 80 --- common/src/states/sit.rs | 38 +- common/src/states/stand.rs | 6 - common/src/states/utils.rs | 93 +++- common/src/states/wielded.rs | 43 ++ common/src/states/{wield.rs => wielding.rs} | 31 +- common/src/sys/ability.rs | 4 +- common/src/sys/agent.rs | 12 +- common/src/sys/character_state.rs | 74 +-- .../src/audio/sfx/event_mapper/movement.rs | 128 +---- voxygen/src/menu/char_selection/scene.rs | 1 - voxygen/src/scene/figure/cache.rs | 24 +- voxygen/src/scene/figure/mod.rs | 525 ++++++++++-------- voxygen/src/scene/mod.rs | 2 +- voxygen/src/session.rs | 8 +- 23 files changed, 614 insertions(+), 833 deletions(-) delete mode 100644 common/src/states/run.rs create mode 100644 common/src/states/wielded.rs rename common/src/states/{wield.rs => wielding.rs} (55%) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index baf6fe24af..8dc488a620 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -23,10 +23,10 @@ impl Component for AbilityAction { #[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)] pub struct AbilityPool { - pub primary: Option, - pub secondary: Option, - pub block: Option, - pub dodge: Option, + pub primary: Option, + pub secondary: Option, + pub block: Option, + pub dodge: Option, } impl Component for AbilityPool { diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 5fd75a0924..4bd65127a6 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,4 +1,3 @@ -use self::ActionState::*; use crate::states::*; use crate::{ comp::{Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel}, @@ -10,7 +9,6 @@ use serde::Deserialize; use serde::Serialize; use specs::LazyUpdate; use specs::{Component, Entity, FlaggedStorage, HashMapStorage}; -use std::time::Duration; pub struct EcsStateData<'a> { pub entity: &'a Entity, @@ -36,123 +34,95 @@ pub struct StateUpdate { pub ori: Ori, } -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum MoveState { - Stand(Option), - Run(Option), - Sit(Option), - Jump(Option), - Fall(Option), - Glide(Option), - Swim(Option), - Climb(Option), -} - -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum ActionState { +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub enum CharacterState { Idle(Option), - Wield(Option), - Attack(AttackKind), - Block(BlockKind), - Dodge(DodgeKind), - // Interact?, -} - -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum AttackKind { - BasicAttack(Option), - Charge(Option), -} - -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum BlockKind { - BasicBlock(Option), -} - -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum DodgeKind { + Climb(Option), + Sit(Option), + Wielding(Option), + Wielded(Option), + //BasicAttack(Option), + //BasicBlock(Option), + //Charge(Option), Roll(Option), + Glide(Option), } -impl ActionState { - pub fn is_equip_finished(&self) -> bool { +impl CharacterState { + pub fn is_attack(&self) -> bool { match self { - Wield(Some(wield::State { equip_delay })) => *equip_delay == Duration::default(), - _ => true, - } - } - - /// Returns the current `equip_delay` if in `WieldState`, otherwise `Duration::default()` - pub fn get_delay(&self) -> Duration { - match self { - Wield(Some(wield::State { equip_delay })) => *equip_delay, - _ => Duration::default(), - } - } - - pub fn is_attacking(&self) -> bool { - match self { - Attack(_) => true, + //CharacterState::BasicAttack(_) => true, _ => false, } } - pub fn is_blocking(&self) -> bool { + pub fn is_block(&self) -> bool { match self { - Block(_) => true, + //CharacterState::BasicBlock(_) => true, _ => false, } } - pub fn is_dodging(&self) -> bool { + pub fn is_dodge(&self) -> bool { match self { - Dodge(_) => true, + CharacterState::Roll(_) => true, _ => false, } } + /// Compares `action_state`s for shallow equality (does not check internal struct equality) pub fn equals(&self, other: &Self) -> bool { // Check if state is the same without looking at the inner data std::mem::discriminant(&self) == std::mem::discriminant(&other) } -} -impl MoveState { - /// Compares `move_state`s for shallow equality (does not check internal struct equality) - pub fn equals(&self, other: &Self) -> bool { - // Check if state is the same without looking at the inner data - std::mem::discriminant(&self) == std::mem::discriminant(&other) - } -} - -/// __A concurrent state machine that allows for separate `ActionState`s and `MoveState`s.__ -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct CharacterState { - /// __How the character is currently moving, e.g. Running, Standing, Falling.__ - /// - /// _Primarily `handle()`s updating `Pos`, `Vel`, `Ori`, and lower body animations. - pub move_state: MoveState, - - /// __How the character is currently acting, e.g. Wielding, Attacking, Dodging.__ - /// - /// _Primarily `handle()`s how character interacts with world, and upper body animations. - pub action_state: ActionState, -} - -impl CharacterState { - /// Compares both `move_state`s and `action_state`a for shallow equality - /// (does not check internal struct equality) - pub fn equals(&self, other: &Self) -> bool { - self.move_state.equals(&other.move_state) && self.action_state.equals(&other.action_state) + /// Passes data to variant or subvariant handlers + /// States contain `Option`s, and will be + /// `None` if state data has not been initialized. So we have to + /// check and intialize new state data if so. + pub fn update(&self, ecs_data: &EcsStateData) -> StateUpdate { + match self { + CharacterState::Idle(opt_state) => opt_state + .unwrap_or_else(|| idle::State::new(ecs_data)) + .handle(ecs_data), + CharacterState::Climb(opt_state) => opt_state + .unwrap_or_else(|| climb::State::new(ecs_data)) + .handle(ecs_data), + CharacterState::Sit(opt_state) => opt_state + .unwrap_or_else(|| sit::State::new(ecs_data)) + .handle(ecs_data), + CharacterState::Wielding(opt_state) => opt_state + .unwrap_or_else(|| wielding::State::new(ecs_data)) + .handle(ecs_data), + CharacterState::Wielded(opt_state) => opt_state + .unwrap_or_else(|| wielded::State::new(ecs_data)) + .handle(ecs_data), + /*CharacterState::BasicAttack(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one + .unwrap_or_else(|| basic_attack::State::new(ecs_data)) + // Call handler + .handle(ecs_data), + CharacterState::Charge(opt_state) => opt_state + .unwrap_or_else(|| charge_attack::State::new(ecs_data)) + .handle(ecs_data), + CharacterState::BasicBlock(opt_state) => opt_state + .unwrap_or_else(|| basic_block::State::new(ecs_data)) + .handle(ecs_data),*/ + CharacterState::Roll(opt_state) => opt_state + .unwrap_or_else(|| roll::State::new(ecs_data)) + .handle(ecs_data), + CharacterState::Glide(opt_state) => opt_state + .unwrap_or_else(|| glide::State::new(ecs_data)) + .handle(ecs_data), + // All states should be explicitly handled + // Do not use default match: _ => {}, + } } } impl Default for CharacterState { fn default() -> Self { - Self { - move_state: MoveState::Fall(None), - action_state: ActionState::Idle(None), - } + Self::Idle(None) } } diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 6457cdee37..4b346e6ca6 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -23,10 +23,7 @@ pub use body::{ biped_large, bird_medium, bird_small, dragon, fish_medium, fish_small, humanoid, object, quadruped_medium, quadruped_small, Body, }; -pub use character_state::{ - ActionState, AttackKind, BlockKind, CharacterState, DodgeKind, EcsStateData, MoveState, - StateUpdate, -}; +pub use character_state::{CharacterState, EcsStateData, StateUpdate}; pub use controller::{ ControlEvent, Controller, ControllerInputs, Input, InputState, InventoryManip, MountState, Mounting, diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index a42175e874..7db0631a6d 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -1,4 +1,5 @@ -use super::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{CharacterState, EcsStateData, StateUpdate}; +use crate::states::StateHandler; use crate::sys::phys::GRAVITY; use vek::vec::{Vec2, Vec3}; use vek::Lerp; @@ -22,27 +23,20 @@ impl StateHandler for State { character: *ecs_data.character, }; - update.character.action_state = ActionState::Idle(None); - // If no wall is in front of character ... if let None = ecs_data.physics.on_wall { if ecs_data.inputs.jump.is_pressed() { // They've climbed atop something, give them a boost - update.character.move_state = MoveState::Jump(None); - - return update; + //TODO: JUMP EVENT } else { // Just fall off - update.character.move_state = MoveState::Fall(None); - - return update; + update.character = CharacterState::Idle(None); } } // Remove climb state on ground, otherwise character will get stuck if ecs_data.physics.on_ground { - update.character.move_state = MoveState::Stand(None); - return update; + update.character = CharacterState::Idle(None); } // Move player @@ -65,6 +59,7 @@ impl StateHandler for State { Vec2::from(update.vel.0) }; + // Smooth orientation if ori_dir.magnitude_squared() > 0.0001 && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 4fc0b8bb0f..f848cd6ee6 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,4 +1,4 @@ -use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::comp::{CharacterState, EcsStateData, StateUpdate}; use crate::states::StateHandler; use vek::{Vec2, Vec3}; @@ -16,6 +16,7 @@ impl StateHandler for State { } fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + dbg!(); let mut update = StateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, @@ -23,26 +24,14 @@ impl StateHandler for State { character: *ecs_data.character, }; - // Defaults for this state - update.character.action_state = ActionState::Idle(None); - update.character.move_state = MoveState::Glide(None); - - // If glide button isn't held, start falling - if !ecs_data.inputs.glide.is_pressed() { - update.character.move_state = MoveState::Fall(None); - return update; + // If glide button isn't held or player is on ground, end glide + if !ecs_data.inputs.glide.is_pressed() || ecs_data.physics.on_ground { + update.character = CharacterState::Idle(None); } // If there is a wall in front of character go to climb - if let Some(_wall_dir) = ecs_data.physics.on_wall { - update.character.move_state = MoveState::Climb(None); - return update; - } - - // If on ground go to stand - if ecs_data.physics.on_ground { - update.character.move_state = MoveState::Stand(None); - return update; + if let Some(_) = ecs_data.physics.on_wall { + update.character = CharacterState::Climb(None); } // Move player according to movement direction vector diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index c9c18aa690..541285dad4 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -1,4 +1,5 @@ -use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateUpdate}; +use super::utils::*; +use crate::comp::{EcsStateData, StateUpdate}; use crate::states::StateHandler; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -17,18 +18,13 @@ impl StateHandler for State { ori: *ecs_data.ori, }; - // Try to wield - if ecs_data.inputs.primary.is_pressed() - || ecs_data.inputs.secondary.is_pressed() - || (ecs_data.inputs.toggle_wield.is_just_pressed() - && update.character.action_state.is_equip_finished()) - { - if let Some(Tool(_)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { - update.character.action_state = ActionState::Wield(None); - } - - // else unarmed stuff? - } + handle_move_dir(ecs_data, &mut update); + handle_wield(ecs_data, &mut update); + handle_sit(ecs_data, &mut update); + handle_climb(ecs_data, &mut update); + handle_roll(ecs_data, &mut update); + //handle_jump(ecs_data, &mut update); + handle_glide(ecs_data, &mut update); update } diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index d95186eaf9..a794626c10 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -1,24 +1,14 @@ // Module declarations -pub mod basic_attack; -pub mod basic_block; -pub mod charge_attack; pub mod climb; -pub mod fall; pub mod glide; pub mod idle; -pub mod jump; pub mod roll; -pub mod run; pub mod sit; -pub mod stand; -pub mod swim; pub mod utils; -pub mod wield; +pub mod wielded; +pub mod wielding; -use crate::comp::{ - ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData, - MoveState, MoveState::*, StateUpdate, -}; +use crate::comp::{EcsStateData, StateUpdate}; /// ## A type for implementing State Handling Behavior. /// @@ -69,123 +59,3 @@ pub trait StateHandler: Default { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate; fn new(ecs_data: &EcsStateData) -> Self; } - -// fn's relating to individual `ActionState`s -// or passing data from system to handlers -impl ActionState { - /// Passes data to variant or subvariant handlers - /// States contain `Option`s, and will be - /// `None` if state data has not been initialized. So we have to - /// check and intialize new state data if so. - pub fn update(&self, ecs_data: &EcsStateData) -> StateUpdate { - match self { - Attack(kind) => match kind { - BasicAttack(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one - .unwrap_or_else(|| basic_attack::State::new(ecs_data)) - // Call handler - .handle(ecs_data), - Charge(opt_state) => opt_state - .unwrap_or_else(|| charge_attack::State::new(ecs_data)) - .handle(ecs_data), - }, - Block(kind) => match kind { - BasicBlock(opt_state) => opt_state - .unwrap_or_else(|| basic_block::State::new(ecs_data)) - .handle(ecs_data), - }, - Dodge(kind) => match kind { - Roll(opt_state) => opt_state - .unwrap_or_else(|| roll::State::new(ecs_data)) - .handle(ecs_data), - }, - Wield(opt_state) => opt_state - .unwrap_or_else(|| wield::State::new(ecs_data)) - .handle(ecs_data), - Idle(opt_state) => opt_state - .unwrap_or_else(|| idle::State::new(ecs_data)) - .handle(ecs_data), - // All states should be explicitly handled - // Do not use default match: _ => {}, - } - } - - // TODO: remove when we split up character states into SingleAction and MultiAction enum variants - /// Returns whether a given `ActionState` overrides `MoveState` `handle()`ing - pub fn overrides_move_state(&self) -> bool { - match self { - Attack(kind) => match kind { - BasicAttack(_) => false, - Charge(_) => true, - }, - Block(kind) => match kind { - BasicBlock(_) => true, - }, - Dodge(kind) => match kind { - Roll(_) => true, - }, - Wield(_) => false, - Idle(_) => false, - // All states should be explicitly handled - // Do not use default match: _ => {}, - } - } -} - -// fn's that relate to individual `MoveState`s -// or passing data from system to handlers -impl MoveState { - // TODO: remove when we split up character states into SingleAction and MultiAction enum variants - /// Passes data to variant or subvariant handlers - /// States contain `Option`s, and will be - /// `None` if state data has not been initialized. So we have to - /// check and intialize new state data if so. - pub fn overrides_action_state(&self) -> bool { - match self { - Stand(_) => false, - Run(_) => false, - Jump(_) => false, - Climb(_) => true, - Glide(_) => true, - Swim(_) => false, - Fall(_) => false, - Sit(_) => true, - // All states should be explicitly handled - // Do not use default match: _ => {}, - } - } - - /// Passes handle to variant handlers - pub fn update(&self, ecs_data: &EcsStateData) -> StateUpdate { - match self { - Stand(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one - .unwrap_or_else(|| stand::State::new(ecs_data)) - // Call handler - .handle(ecs_data), - Run(opt_state) => opt_state - .unwrap_or_else(|| run::State::new(ecs_data)) - .handle(ecs_data), - Jump(opt_state) => opt_state - .unwrap_or_else(|| jump::State::new(ecs_data)) - .handle(ecs_data), - Climb(opt_state) => opt_state - .unwrap_or_else(|| climb::State::new(ecs_data)) - .handle(ecs_data), - Glide(opt_state) => opt_state - .unwrap_or_else(|| glide::State::new(ecs_data)) - .handle(ecs_data), - Swim(opt_state) => opt_state - .unwrap_or_else(|| swim::State::new(ecs_data)) - .handle(ecs_data), - Fall(opt_state) => opt_state - .unwrap_or_else(|| fall::State::new(ecs_data)) - .handle(ecs_data), - Sit(opt_state) => opt_state - .unwrap_or_else(|| sit::State::new(ecs_data)) - .handle(ecs_data), - // All states should be explicitly handled - // Do not use default match: _ => {}, - } - } -} diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 1f3391ae9b..9979d6308d 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,7 +1,5 @@ use super::utils::*; -use crate::comp::{ - ActionState::Dodge, DodgeKind::Roll, EcsStateData, ItemKind::Tool, StateUpdate, ToolData, -}; +use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; use crate::states::StateHandler; use std::time::Duration; use vek::Vec3; @@ -48,20 +46,13 @@ impl StateHandler for State { .unwrap_or_default() * ROLL_SPEED; - // Check if roll duration has expired - if self.remaining_duration == Duration::default() { - // If so, go back to wielding or idling - update.character.action_state = attempt_wield(ecs_data.stats); - return update; - } - // Otherwise, tick down remaining_duration - update.character.action_state = Dodge(Roll(Some(State { + update.character = CharacterState::Roll(Some(State { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) .unwrap_or_default(), - }))); + })); // Keep rolling update diff --git a/common/src/states/run.rs b/common/src/states/run.rs deleted file mode 100644 index 366ae80dab..0000000000 --- a/common/src/states/run.rs +++ /dev/null @@ -1,80 +0,0 @@ -use super::utils::*; -use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; -use crate::states::StateHandler; -use vek::vec::{Vec2, Vec3}; - -const HUMANOID_ACCEL: f32 = 50.0; -const HUMANOID_SPEED: f32 = 120.0; - -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State; - -impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { - Self {} - } - - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - }; - - // Move player according to move_dir - update.vel.0 += Vec2::broadcast(ecs_data.dt.0) - * ecs_data.inputs.move_dir - * if update.vel.0.magnitude_squared() < HUMANOID_SPEED.powf(2.0) { - HUMANOID_ACCEL - } else { - 0.0 - }; - - // Set direction based on move direction when on the ground - let ori_dir = - if let ActionState::Attack(_) | ActionState::Block(_) = update.character.action_state { - Vec2::from(ecs_data.inputs.look_dir).normalized() - } else { - Vec2::from(update.vel.0) - }; - - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = - vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 9.0 * ecs_data.dt.0); - } - - // Try to sit - if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = MoveState::Sit(None); - return update; - } - - // Try to climb - if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = MoveState::Climb(None); - return update; - } - - // Try to jump - if can_jump(ecs_data.physics, ecs_data.inputs) { - update.character.move_state = MoveState::Jump(None); - return update; - } - - // Try to glide - if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = MoveState::Glide(None); - return update; - } - - // Update based on groundedness - update.character.move_state = - determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); - - update - } -} diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index 47b8fb9aff..f6a392acb8 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -1,5 +1,5 @@ use super::utils::*; -use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::comp::{CharacterState, EcsStateData, StateUpdate}; use crate::states::StateHandler; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -18,37 +18,17 @@ impl StateHandler for State { ori: *ecs_data.ori, }; - // Prevent action state handling - update.character.action_state = ActionState::Idle(None); - update.character.move_state = MoveState::Sit(None); + //handle_jump(ecs_data, &mut update); + handle_wield(ecs_data, &mut update); - // Try to Fall - // ... maybe the ground disappears, - // suddenly maybe a water spell appears. - // Can't hurt to be safe :shrug: - if !ecs_data.physics.on_ground { - update.character.move_state = determine_fall_or_swim(ecs_data.physics); - return update; - } - // Try to jump - if ecs_data.inputs.jump.is_pressed() { - update.character.move_state = MoveState::Jump(None); - return update; + // Try to Fall/Stand up/Move + if !ecs_data.physics.on_ground + || ecs_data.inputs.sit.is_just_pressed() + || ecs_data.inputs.move_dir.magnitude_squared() > 0.0 + { + update.character = CharacterState::Idle(None); } - // Try to Run - if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - update.character.move_state = MoveState::Run(None); - return update; - } - - // Try to Stand - if ecs_data.inputs.sit.is_just_pressed() { - update.character.move_state = MoveState::Stand(None); - return update; - } - - // No move has occurred, keep sitting update } } diff --git a/common/src/states/stand.rs b/common/src/states/stand.rs index 3068f9e993..37dd3c4bbe 100644 --- a/common/src/states/stand.rs +++ b/common/src/states/stand.rs @@ -36,12 +36,6 @@ impl StateHandler for State { return update; } - // Check gliding - if can_glide(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = MoveState::Glide(None); - return update; - } - // Else update based on groundedness update.character.move_state = determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index b458596d15..8ae5410587 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,8 +1,10 @@ use crate::comp::{ - ActionState, ActionState::*, AttackKind::*, BlockKind::*, Body, ControllerInputs, - ItemKind::Tool, MoveState, MoveState::*, PhysicsState, Stats, + Body, CharacterState, ControllerInputs, EcsStateData, ItemKind::Tool, PhysicsState, + StateUpdate, Stats, }; +use vek::vec::{Vec2, Vec3}; +/* /// _Determines what ability a player has selected for their primary ability, /// and returns the corresponding `ActionState` or Idle if nothing_ pub fn determine_primary_ability(stats: &Stats) -> ActionState { @@ -102,4 +104,91 @@ pub fn can_jump(physics: &PhysicsState, inputs: &ControllerInputs) -> bool { } else { false } +}*/ + +pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) { + let (accel, speed): (f32, f32) = if ecs_data.physics.on_ground { + let accel = 50.0; + let speed = 120.0; + (accel, speed) + } else { + let accel = 10.0; + let speed = 100.0; + (accel, speed) + }; + + // Move player according to move_dir + update.vel.0 += Vec2::broadcast(ecs_data.dt.0) + * ecs_data.inputs.move_dir + * if update.vel.0.magnitude_squared() < speed.powf(2.0) { + accel + } else { + 0.0 + }; + + // Set direction based on move direction + let ori_dir = if update.character.is_attack() || update.character.is_block() { + Vec2::from(ecs_data.inputs.look_dir).normalized() + } else { + Vec2::from(update.vel.0) + }; + + // Smooth orientation + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 9.0 * ecs_data.dt.0); + } +} + +pub fn handle_wield(ecs_data: &EcsStateData, update: &mut StateUpdate) { + if ecs_data.inputs.primary.is_pressed() || ecs_data.inputs.secondary.is_pressed() { + if let Some(Tool(_)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { + update.character = CharacterState::Wielding(None); + } + } +} + +pub fn handle_sit(ecs_data: &EcsStateData, update: &mut StateUpdate) { + if ecs_data.inputs.sit.is_pressed() && ecs_data.physics.on_ground && ecs_data.body.is_humanoid() + { + update.character = CharacterState::Sit(None); + } +} + +pub fn handle_climb(ecs_data: &EcsStateData, update: &mut StateUpdate) { + if (ecs_data.inputs.climb.is_pressed() || ecs_data.inputs.climb_down.is_pressed()) + && ecs_data.physics.on_wall.is_some() + && ecs_data.body.is_humanoid() + { + update.character = CharacterState::Climb(None); + } +} + +pub fn handle_roll(ecs_data: &EcsStateData, update: &mut StateUpdate) { + if ecs_data.inputs.roll.is_pressed() + && ecs_data.physics.on_ground + && ecs_data.body.is_humanoid() + { + update.character = CharacterState::Roll(None); + } +} + +pub fn handle_unwield(ecs_data: &EcsStateData, update: &mut StateUpdate) { + if let CharacterState::Wielded(_) = update.character { + if ecs_data.inputs.toggle_wield.is_pressed() { + update.character = CharacterState::Idle(None); + } + } +} + +pub fn handle_glide(ecs_data: &EcsStateData, update: &mut StateUpdate) { + if ecs_data.inputs.glide.is_pressed() + && !ecs_data.physics.on_ground + && ecs_data.body.is_humanoid() + { + dbg!(); + update.character = CharacterState::Glide(None); + } } diff --git a/common/src/states/wielded.rs b/common/src/states/wielded.rs new file mode 100644 index 0000000000..27800331b3 --- /dev/null +++ b/common/src/states/wielded.rs @@ -0,0 +1,43 @@ +use super::utils::*; +use crate::comp::{EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; +use crate::states::StateHandler; +use std::time::Duration; + +#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct State { + /// How long before a new action can be performed + /// after equipping + pub equip_delay: Duration, +} + +impl StateHandler for State { + fn new(ecs_data: &EcsStateData) -> Self { + let tool_data = + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { + data + } else { + ToolData::default() + }; + Self { + equip_delay: tool_data.equip_time(), + } + } + + fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + let mut update = StateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + }; + + handle_move_dir(&ecs_data, &mut update); + handle_sit(&ecs_data, &mut update); + handle_roll(&ecs_data, &mut update); + handle_climb(&ecs_data, &mut update); + handle_glide(&ecs_data, &mut update); + handle_unwield(&ecs_data, &mut update); + + update + } +} diff --git a/common/src/states/wield.rs b/common/src/states/wielding.rs similarity index 55% rename from common/src/states/wield.rs rename to common/src/states/wielding.rs index 508e400113..32e97b8bb4 100644 --- a/common/src/states/wield.rs +++ b/common/src/states/wielding.rs @@ -1,4 +1,5 @@ -use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; +use super::utils::*; +use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; use crate::states::StateHandler; use std::time::Duration; @@ -17,6 +18,7 @@ impl StateHandler for State { } else { ToolData::default() }; + Self { equip_delay: tool_data.equip_time(), } @@ -30,30 +32,15 @@ impl StateHandler for State { ori: *ecs_data.ori, }; - // Only act once equip_delay has expired - if self.equip_delay == Duration::default() { - // Toggle Weapons - if ecs_data.inputs.toggle_wield.is_just_pressed() - && ecs_data.character.action_state.is_equip_finished() - { - update.character.action_state = ActionState::Idle(None); - return update; - } + handle_move_dir(&ecs_data, &mut update); - // Try weapon actions - if ecs_data.inputs.primary.is_pressed() { - // ecs_data - // .updater - // .insert(*ecs_data.entity, AbilityAction(Primary)); - } else if ecs_data.inputs.secondary.is_pressed() { - // ecs_data - // .updater - // .insert(*ecs_data.entity, AbilityAction(Secondary)); - } + if self.equip_delay == Duration::default() { + // Wield delay has expired + update.character = CharacterState::Wielded(None); } else { - // Equip delay hasn't expired yet + // Wield delay hasn't expired yet // Update wield delay - update.character.action_state = ActionState::Wield(Some(State { + update.character = CharacterState::Wielding(Some(State { equip_delay: self .equip_delay .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) diff --git a/common/src/sys/ability.rs b/common/src/sys/ability.rs index f4569f0b0b..07aaa21bd1 100644 --- a/common/src/sys/ability.rs +++ b/common/src/sys/ability.rs @@ -1,8 +1,6 @@ #![allow(unused_imports)] #![allow(dead_code)] -use crate::comp::{ - AbilityAction, AbilityActionKind, AbilityPool, ActionState::*, AttackKind, CharacterState, -}; +use crate::comp::{AbilityAction, AbilityActionKind, AbilityPool, CharacterState}; use crate::states::StateHandler; use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index 272462f3f6..649dc86100 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -1,4 +1,4 @@ -use crate::comp::{Agent, CharacterState, Controller, MountState, MoveState::Glide, Pos, Stats}; +use crate::comp::{Agent, CharacterState, Controller, MountState, Pos, Stats}; use crate::hierarchical::ChunkPath; use crate::pathfinding::WorldPath; use crate::terrain::TerrainGrid; @@ -167,11 +167,11 @@ impl<'a> System<'a> for Sys { inputs.roll.set_state(true); } - if target_character.move_state == Glide(None) - && target_pos.0.z > pos.0.z + 5.0 - { - inputs.glide.set_state(true); - inputs.jump.set_state(true); + if let CharacterState::Glide(_) = target_character { + if target_pos.0.z > pos.0.z + 5.0 { + inputs.glide.set_state(true); + inputs.jump.set_state(true); + } } } else { choose_new = true; diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 151b0a3791..c36aae2a1d 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - Body, CharacterState, Controller, EcsStateData, Mounting, MoveState::*, Ori, PhysicsState, - Pos, Stats, Vel, + Body, CharacterState, Controller, EcsStateData, Mounting, Ori, PhysicsState, Pos, Stats, + Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -87,59 +87,31 @@ impl<'a> System<'a> for Sys { // If mounted, character state is controlled by mount // TODO: Make mounting a state if let Some(Mounting(_)) = mountings.get(entity) { - character.move_state = Sit(None); + *character = CharacterState::Sit(None); return; } - // Determine new action if character can act - if !character.move_state.overrides_action_state() { - let state_update = character.action_state.update(&EcsStateData { - entity: &entity, - uid, - character, - pos, - vel, - ori, - dt: &dt, - inputs, - stats, - body, - physics, - updater: &updater, - server_bus: &server_bus, - local_bus: &local_bus, - }); + let state_update = character.update(&EcsStateData { + entity: &entity, + uid, + character, + pos, + vel, + ori, + dt: &dt, + inputs, + stats, + body, + physics, + updater: &updater, + server_bus: &server_bus, + local_bus: &local_bus, + }); - *character = state_update.character; - *pos = state_update.pos; - *vel = state_update.vel; - *ori = state_update.ori; - } - - // Determine new move state if character can move - if !character.action_state.overrides_move_state() { - let state_update = character.move_state.update(&EcsStateData { - entity: &entity, - uid, - character, - pos, - vel, - ori, - dt: &dt, - inputs, - stats, - body, - physics, - updater: &updater, - server_bus: &server_bus, - local_bus: &local_bus, - }); - - *character = state_update.character; - *pos = state_update.pos; - *vel = state_update.vel; - *ori = state_update.ori; - } + *character = state_update.character; + *pos = state_update.pos; + *vel = state_update.vel; + *ori = state_update.ori; } } } diff --git a/voxygen/src/audio/sfx/event_mapper/movement.rs b/voxygen/src/audio/sfx/event_mapper/movement.rs index eecf6d7752..5026b9c8a6 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement.rs @@ -4,7 +4,7 @@ use crate::audio::sfx::{SfxTriggerItem, SfxTriggers}; use client::Client; use common::{ - comp::{ActionState, Body, CharacterState, MoveState, Pos}, + comp::{Body, CharacterState, Pos}, event::{EventBus, SfxEvent, SfxEventItem}, }; use hashbrown::HashMap; @@ -123,28 +123,21 @@ impl MovementEventMapper { /// as opening or closing the glider. These methods translate those entity states with some additional /// data into more specific `SfxEvent`'s which we attach sounds to fn map_movement_event(current_event: &CharacterState, previous_event: SfxEvent) -> SfxEvent { - match ( - current_event.move_state, - current_event.action_state, - previous_event, - ) { - (_, ActionState::Dodge(_), _) => SfxEvent::Roll, - (MoveState::Climb(_), ..) => SfxEvent::Climb, - (MoveState::Swim(_), ..) => SfxEvent::Swim, - (MoveState::Run(_), ..) => SfxEvent::Run, - (MoveState::Jump(_), ..) => SfxEvent::Jump, - (MoveState::Fall(_), _, SfxEvent::Glide) => SfxEvent::GliderClose, - (MoveState::Stand(_), _, SfxEvent::Fall) => SfxEvent::Run, - (MoveState::Fall(_), _, SfxEvent::Jump) => SfxEvent::Idle, - (MoveState::Fall(_), _, _) => SfxEvent::Fall, - (MoveState::Glide(_), _, previous_event) => { + match (current_event, previous_event) { + (CharacterState::Roll(_), _) => SfxEvent::Roll, + (CharacterState::Climb(_), _) => SfxEvent::Climb, + (CharacterState::Idle(_), _) => SfxEvent::Run, + (CharacterState::Idle(_), SfxEvent::Glide) => SfxEvent::GliderClose, + (CharacterState::Idle(_), SfxEvent::Fall) => SfxEvent::Run, + (CharacterState::Idle(_), SfxEvent::Jump) => SfxEvent::Idle, + (CharacterState::Glide(_), previous_event) => { if previous_event != SfxEvent::GliderOpen && previous_event != SfxEvent::Glide { SfxEvent::GliderOpen } else { SfxEvent::Glide } } - (MoveState::Stand(_), _, SfxEvent::Glide) => SfxEvent::GliderClose, + (CharacterState::Idle(_), SfxEvent::Glide) => SfxEvent::GliderClose, _ => SfxEvent::Idle, } } @@ -153,10 +146,7 @@ impl MovementEventMapper { #[cfg(test)] mod tests { use super::*; - use common::{ - comp::{ActionState, CharacterState, DodgeKind::*, MoveState}, - event::SfxEvent, - }; + use common::{comp::CharacterState, event::SfxEvent}; use std::time::{Duration, Instant}; #[test] @@ -236,118 +226,50 @@ mod tests { #[test] fn maps_idle() { - let result = MovementEventMapper::map_movement_event( - &CharacterState { - move_state: MoveState::Stand(None), - action_state: ActionState::Idle(None), - }, - SfxEvent::Idle, - ); - + let result = + MovementEventMapper::map_movement_event(&CharacterState::Idle(None), SfxEvent::Idle); assert_eq!(result, SfxEvent::Idle); } - #[test] - fn maps_run() { - let result = MovementEventMapper::map_movement_event( - &CharacterState { - move_state: MoveState::Run(None), - action_state: ActionState::Idle(None), - }, - SfxEvent::Idle, - ); - - assert_eq!(result, SfxEvent::Run); - } - #[test] fn maps_roll() { - let result = MovementEventMapper::map_movement_event( - &CharacterState { - action_state: ActionState::Dodge(Roll(None)), - move_state: MoveState::Run(None), - }, - SfxEvent::Run, - ); - + let result = + MovementEventMapper::map_movement_event(&CharacterState::Roll(None), SfxEvent::Run); assert_eq!(result, SfxEvent::Roll); } - #[test] - fn maps_fall() { - let result = MovementEventMapper::map_movement_event( - &CharacterState { - move_state: MoveState::Fall(None), - action_state: ActionState::Idle(None), - }, - SfxEvent::Fall, - ); - - assert_eq!(result, SfxEvent::Fall); - } - #[test] fn maps_land_on_ground_to_run() { - let result = MovementEventMapper::map_movement_event( - &CharacterState { - move_state: MoveState::Stand(None), - action_state: ActionState::Idle(None), - }, - SfxEvent::Fall, - ); - + let result = + MovementEventMapper::map_movement_event(&CharacterState::Idle(None), SfxEvent::Fall); assert_eq!(result, SfxEvent::Run); } #[test] fn maps_glider_open() { - let result = MovementEventMapper::map_movement_event( - &CharacterState { - move_state: MoveState::Glide(None), - action_state: ActionState::Idle(None), - }, - SfxEvent::Jump, - ); - + let result = + MovementEventMapper::map_movement_event(&CharacterState::Glide(None), SfxEvent::Jump); assert_eq!(result, SfxEvent::GliderOpen); } #[test] fn maps_glide() { - let result = MovementEventMapper::map_movement_event( - &CharacterState { - move_state: MoveState::Glide(None), - action_state: ActionState::Idle(None), - }, - SfxEvent::Glide, - ); - + let result = + MovementEventMapper::map_movement_event(&CharacterState::Glide(None), SfxEvent::Glide); assert_eq!(result, SfxEvent::Glide); } #[test] fn maps_glider_close_when_closing_mid_flight() { - let result = MovementEventMapper::map_movement_event( - &CharacterState { - move_state: MoveState::Fall(None), - action_state: ActionState::Idle(None), - }, - SfxEvent::Glide, - ); - + let result = + MovementEventMapper::map_movement_event(&CharacterState::Idle(None), SfxEvent::Glide); assert_eq!(result, SfxEvent::GliderClose); } #[test] fn maps_glider_close_when_landing() { - let result = MovementEventMapper::map_movement_event( - &CharacterState { - move_state: MoveState::Stand(None), - action_state: ActionState::Idle(None), - }, - SfxEvent::Glide, - ); - + let result = + MovementEventMapper::map_movement_event(&CharacterState::Idle(None), SfxEvent::Glide); assert_eq!(result, SfxEvent::GliderClose); } } diff --git a/voxygen/src/menu/char_selection/scene.rs b/voxygen/src/menu/char_selection/scene.rs index e5712f956e..78013154b2 100644 --- a/voxygen/src/menu/char_selection/scene.rs +++ b/voxygen/src/menu/char_selection/scene.rs @@ -168,7 +168,6 @@ impl Scene { Rgba::broadcast(1.0), 1.0 / 60.0, // TODO: Use actual deltatime here? 1.0, - 1.0, 0, true, ); diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index b8dacc5ee1..b681c3df1c 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -6,7 +6,7 @@ use crate::{ }; use common::{ assets::watch::ReloadIndicator, - comp::{ActionState, Body, CharacterState, Equipment, MoveState}, + comp::{Body, CharacterState, Equipment}, }; use hashbrown::HashMap; use std::mem::{discriminant, Discriminant}; @@ -24,15 +24,13 @@ enum FigureKey { #[derive(PartialEq, Eq, Hash, Clone)] struct CharacterStateCacheKey { - move_state: Discriminant, - action: Discriminant, + state: Discriminant, // TODO: Can this be simplified? } impl From<&CharacterState> for CharacterStateCacheKey { fn from(cs: &CharacterState) -> Self { Self { - move_state: discriminant(&cs.move_state), - action: discriminant(&cs.action_state), + state: discriminant(&cs), } } } @@ -132,17 +130,14 @@ impl FigureModelCache { }, if camera_mode == CameraMode::FirstPerson && character_state - .map(|cs| cs.action_state.is_dodging()) + .map(|cs| cs.is_dodge()) .unwrap_or_default() { None } else { Some(humanoid_armor_hand_spec.mesh_left_hand(&body)) }, - if character_state - .map(|cs| cs.action_state.is_dodging()) - .unwrap_or_default() - { + if character_state.map(|cs| cs.is_dodge()).unwrap_or_default() { None } else { Some(humanoid_armor_hand_spec.mesh_right_hand(&body)) @@ -161,10 +156,11 @@ impl FigureModelCache { }, if camera_mode != CameraMode::FirstPerson || character_state - .map(|cs| match cs.action_state { - ActionState::Attack(_) - | ActionState::Block(_) - | ActionState::Wield(_) => true, + .map(|cs| match cs { + //CharacterState::BasicAttack(_) // TODO: enable + //| CharacterState::BasicBlock(_) + CharacterState::Wielding(_) + | CharacterState::Wielded(_) => true, _ => false, }) .unwrap_or_default() diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index bfb89b9b7d..29dd93927a 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -18,8 +18,7 @@ use crate::{ use client::Client; use common::{ comp::{ - ActionState::*, AttackKind::*, Body, CharacterState, ItemKind, Last, MoveState::*, Ori, - Pos, Scale, Stats, ToolData, Vel, + Body, CharacterState, ItemKind, Last, Ori, PhysicsState, Pos, Scale, Stats, ToolData, Vel, }, terrain::TerrainChunk, vol::RectRasterableVol, @@ -80,14 +79,16 @@ impl FigureMgr { .get(client.entity()) .map_or(Vec3::zero(), |pos| pos.0); - for (entity, pos, ori, scale, body, character, last_character, stats) in ( + for (entity, pos, vel, ori, scale, body, character, last_character, physics, stats) in ( &ecs.entities(), &ecs.read_storage::(), + &ecs.read_storage::(), &ecs.read_storage::(), ecs.read_storage::().maybe(), &ecs.read_storage::(), ecs.read_storage::().maybe(), ecs.read_storage::>().maybe(), + &ecs.read_storage::(), ecs.read_storage::().maybe(), ) .join() @@ -328,8 +329,7 @@ impl FigureMgr { ) .1; - let mut move_state_animation_rate = 1.0; - let mut action_animation_rate = 1.0; + let mut state_animation_rate = 1.0; let vel = ecs .read_storage::() @@ -357,121 +357,142 @@ impl FigureMgr { _ => continue, }; - if !character.move_state.equals(&last_character.0.move_state) { - state.move_state_time = 0.0; - } - if !character - .action_state - .equals(&last_character.0.action_state) - { - state.action_time = 0.0; + if !character.equals(&last_character.0) { + state.state_time = 0.0; } - let target_base = match &character.move_state { - Stand(_) => anim::character::StandAnimation::update_skeleton( + let target_base = match ( + physics.on_ground, + vel.0.magnitude_squared() > 0.001, // Moving + physics.in_fluid, // In water + ) { + // Standing + (true, false, false) => anim::character::StandAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Run(_) => anim::character::RunAnimation::update_skeleton( + // Running + (true, true, false) => anim::character::RunAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0, ori.0, state.last_ori, time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Jump(_) | Fall(_) => anim::character::JumpAnimation::update_skeleton( + // In air + (false, _, false) => anim::character::JumpAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Glide(_) => anim::character::GlidingAnimation::update_skeleton( - &CharacterSkeleton::new(), - (active_tool_kind, vel.0, ori.0, state.last_ori, time), - state.move_state_time, - &mut move_state_animation_rate, - skeleton_attr, - ), - Swim(_) => anim::character::SwimAnimation::update_skeleton( + // Swim + (_, _, true) => anim::character::SwimAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0.magnitude(), ori.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, - skeleton_attr, - ), - Climb(_) => anim::character::ClimbAnimation::update_skeleton( - &CharacterSkeleton::new(), - (active_tool_kind, vel.0, ori.0, time), - state.move_state_time, - &mut move_state_animation_rate, - skeleton_attr, - ), - Sit(_) => anim::character::SitAnimation::update_skeleton( - &CharacterSkeleton::new(), - (active_tool_kind, time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), }; - let target_bones = match (&character.move_state, &character.action_state) { - (Stand(_), Wield { .. }) => { + let target_bones = match &character { + CharacterState::Roll(_) => anim::character::RollAnimation::update_skeleton( + &target_base, + (active_tool_kind, ori.0, state.last_ori, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ), + CharacterState::Wielding(_) => { anim::character::CidleAnimation::update_skeleton( &target_base, (active_tool_kind, time), - state.action_time, - &mut action_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ) } - (Stand(_), Block { .. }) => { + CharacterState::Wielded(_) => { + anim::character::CidleAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } + /*CharacterState::Block(_) => { anim::character::BlockIdleAnimation::update_skeleton( &target_base, (active_tool_kind, time), - state.action_time, - &mut action_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ) } - (_, Attack(kind)) => match kind { - Charge(_) => anim::character::ChargeAnimation::update_skeleton( + CharacterState::Charge(_) => { + anim::character::ChargeAnimation::update_skeleton( &target_base, (active_tool_kind, time), - state.action_time, - &mut action_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, - ), - BasicAttack(_) => anim::character::AttackAnimation::update_skeleton( + ) + } + CharacterState::BasicAttack(_) => { + anim::character::AttackAnimation::update_skeleton( &target_base, (active_tool_kind, time), - state.action_time, - &mut action_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, - ), - }, - (_, Wield(_)) => anim::character::WieldAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.action_time, - &mut action_animation_rate, - skeleton_attr, - ), - (_, Dodge(_)) => anim::character::RollAnimation::update_skeleton( - &target_base, - (active_tool_kind, ori.0, state.last_ori, time), - state.action_time, - &mut action_animation_rate, - skeleton_attr, - ), - (_, Block(_)) => anim::character::BlockAnimation::update_skeleton( - &target_base, + ) + }*/ + CharacterState::Wielding(_) => { + anim::character::WieldAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } + CharacterState::Wielded(_) => { + anim::character::WieldAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } + CharacterState::Glide(_) => { + anim::character::GlidingAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0, ori.0, state.last_ori, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } + CharacterState::Climb(_) => { + anim::character::ClimbAnimation::update_skeleton( + &CharacterSkeleton::new(), + (active_tool_kind, vel.0, ori.0, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } + CharacterState::Sit(_) => anim::character::SitAnimation::update_skeleton( + &CharacterSkeleton::new(), (active_tool_kind, time), - state.action_time, - &mut action_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), _ => target_base, @@ -486,8 +507,7 @@ impl FigureMgr { scale, col, dt, - move_state_animation_rate, - action_animation_rate, + state_animation_rate, lpindex, true, ); @@ -505,30 +525,41 @@ impl FigureMgr { _ => continue, }; - if !character.move_state.equals(&last_character.0.move_state) { - state.move_state_time = 0.0; + if !character.equals(&last_character.0) { + state.state_time = 0.0; } - let target_base = match character.move_state { - Stand(_) => anim::quadruped_small::IdleAnimation::update_skeleton( - &QuadrupedSmallSkeleton::new(), - time, - state.move_state_time, - &mut move_state_animation_rate, - skeleton_attr, - ), - Run(_) => anim::quadruped_small::RunAnimation::update_skeleton( + let target_base = match ( + physics.on_ground, + vel.0.magnitude_squared() > 0.001, // Moving + physics.in_fluid, // In water + ) { + // Standing + (true, false, false) => { + anim::quadruped_small::IdleAnimation::update_skeleton( + &QuadrupedSmallSkeleton::new(), + time, + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } + // Running + (true, true, false) => { + anim::quadruped_small::RunAnimation::update_skeleton( + &QuadrupedSmallSkeleton::new(), + (vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } + // In air + (false, _, false) => anim::quadruped_small::JumpAnimation::update_skeleton( &QuadrupedSmallSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, - skeleton_attr, - ), - Jump(_) => anim::quadruped_small::JumpAnimation::update_skeleton( - &QuadrupedSmallSkeleton::new(), - (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), @@ -545,8 +576,7 @@ impl FigureMgr { scale, col, dt, - move_state_animation_rate, - action_animation_rate, + state_animation_rate, lpindex, true, ); @@ -564,32 +594,45 @@ impl FigureMgr { _ => continue, }; - if !character.move_state.equals(&last_character.0.move_state) { - state.move_state_time = 0.0; + if !character.equals(&last_character.0) { + state.state_time = 0.0; } - let target_base = match character.move_state { - Stand(_) => anim::quadruped_medium::IdleAnimation::update_skeleton( - &QuadrupedMediumSkeleton::new(), - time, - state.move_state_time, - &mut move_state_animation_rate, - skeleton_attr, - ), - Run(_) => anim::quadruped_medium::RunAnimation::update_skeleton( - &QuadrupedMediumSkeleton::new(), - (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, - skeleton_attr, - ), - Jump(_) => anim::quadruped_medium::JumpAnimation::update_skeleton( - &QuadrupedMediumSkeleton::new(), - (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, - skeleton_attr, - ), + let target_base = match ( + physics.on_ground, + vel.0.magnitude_squared() > 0.001, // Moving + physics.in_fluid, // In water + ) { + // Standing + (true, false, false) => { + anim::quadruped_medium::IdleAnimation::update_skeleton( + &QuadrupedMediumSkeleton::new(), + time, + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } + // Running + (true, true, false) => { + anim::quadruped_medium::RunAnimation::update_skeleton( + &QuadrupedMediumSkeleton::new(), + (vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } + // In air + (false, _, false) => { + anim::quadruped_medium::JumpAnimation::update_skeleton( + &QuadrupedMediumSkeleton::new(), + (vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } // TODO! _ => state.skeleton_mut().clone(), @@ -604,8 +647,7 @@ impl FigureMgr { scale, col, dt, - move_state_animation_rate, - action_animation_rate, + state_animation_rate, lpindex, true, ); @@ -621,30 +663,37 @@ impl FigureMgr { _ => continue, }; - if !character.move_state.equals(&last_character.0.move_state) { - state.move_state_time = 0.0; + if !character.equals(&last_character.0) { + state.state_time = 0.0; } - let target_base = match character.move_state { - Stand(_) => anim::bird_medium::IdleAnimation::update_skeleton( + let target_base = match ( + physics.on_ground, + vel.0.magnitude_squared() > 0.001, // Moving + physics.in_fluid, // In water + ) { + // Standing + (true, false, false) => anim::bird_medium::IdleAnimation::update_skeleton( &BirdMediumSkeleton::new(), time, - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Run(_) => anim::bird_medium::RunAnimation::update_skeleton( + // Running + (true, true, false) => anim::bird_medium::RunAnimation::update_skeleton( &BirdMediumSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Jump(_) => anim::bird_medium::JumpAnimation::update_skeleton( + // In air + (false, _, false) => anim::bird_medium::JumpAnimation::update_skeleton( &BirdMediumSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), @@ -661,8 +710,7 @@ impl FigureMgr { scale, col, dt, - move_state_animation_rate, - action_animation_rate, + state_animation_rate, lpindex, true, ); @@ -678,30 +726,37 @@ impl FigureMgr { _ => continue, }; - if !character.move_state.equals(&last_character.0.move_state) { - state.move_state_time = 0.0; + if !character.equals(&last_character.0) { + state.state_time = 0.0; } - let target_base = match character.move_state { - Stand(_) => anim::fish_medium::IdleAnimation::update_skeleton( + let target_base = match ( + physics.on_ground, + vel.0.magnitude_squared() > 0.001, // Moving + physics.in_fluid, // In water + ) { + // Standing + (true, false, false) => anim::fish_medium::IdleAnimation::update_skeleton( &FishMediumSkeleton::new(), time, - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Run(_) => anim::fish_medium::RunAnimation::update_skeleton( + // Running + (true, true, false) => anim::fish_medium::RunAnimation::update_skeleton( &FishMediumSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Jump(_) => anim::fish_medium::JumpAnimation::update_skeleton( + // In air + (false, _, false) => anim::fish_medium::JumpAnimation::update_skeleton( &FishMediumSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), @@ -718,8 +773,7 @@ impl FigureMgr { scale, col, dt, - move_state_animation_rate, - action_animation_rate, + state_animation_rate, lpindex, true, ); @@ -735,30 +789,37 @@ impl FigureMgr { _ => continue, }; - if !character.move_state.equals(&last_character.0.move_state) { - state.move_state_time = 0.0; + if !character.equals(&last_character.0) { + state.state_time = 0.0; } - let target_base = match character.move_state { - Stand(_) => anim::dragon::IdleAnimation::update_skeleton( + let target_base = match ( + physics.on_ground, + vel.0.magnitude_squared() > 0.001, // Moving + physics.in_fluid, // In water + ) { + // Standing + (true, false, false) => anim::dragon::IdleAnimation::update_skeleton( &DragonSkeleton::new(), time, - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Run(_) => anim::dragon::RunAnimation::update_skeleton( + // Running + (true, true, false) => anim::dragon::RunAnimation::update_skeleton( &DragonSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Jump(_) => anim::dragon::JumpAnimation::update_skeleton( + // In air + (false, _, false) => anim::dragon::JumpAnimation::update_skeleton( &DragonSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), @@ -775,8 +836,7 @@ impl FigureMgr { scale, col, dt, - move_state_animation_rate, - action_animation_rate, + state_animation_rate, lpindex, true, ); @@ -792,30 +852,37 @@ impl FigureMgr { _ => continue, }; - if !character.move_state.equals(&last_character.0.move_state) { - state.move_state_time = 0.0; + if !character.equals(&last_character.0) { + state.state_time = 0.0; } - let target_base = match character.move_state { - Stand(_) => anim::bird_small::IdleAnimation::update_skeleton( + let target_base = match ( + physics.on_ground, + vel.0.magnitude_squared() > 0.001, // Moving + physics.in_fluid, // In water + ) { + // Standing + (true, false, false) => anim::bird_small::IdleAnimation::update_skeleton( &BirdSmallSkeleton::new(), time, - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Run(_) => anim::bird_small::RunAnimation::update_skeleton( + // Running + (true, true, false) => anim::bird_small::RunAnimation::update_skeleton( &BirdSmallSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Jump(_) => anim::bird_small::JumpAnimation::update_skeleton( + // In air + (false, _, false) => anim::bird_small::JumpAnimation::update_skeleton( &BirdSmallSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), @@ -832,8 +899,7 @@ impl FigureMgr { scale, col, dt, - move_state_animation_rate, - action_animation_rate, + state_animation_rate, lpindex, true, ); @@ -849,30 +915,37 @@ impl FigureMgr { _ => continue, }; - if !character.move_state.equals(&last_character.0.move_state) { - state.move_state_time = 0.0; + if !character.equals(&last_character.0) { + state.state_time = 0.0; } - let target_base = match character.move_state { - Stand(_) => anim::fish_small::IdleAnimation::update_skeleton( + let target_base = match ( + physics.on_ground, + vel.0.magnitude_squared() > 0.001, // Moving + physics.in_fluid, // In water + ) { + // Standing + (true, false, false) => anim::fish_small::IdleAnimation::update_skeleton( &FishSmallSkeleton::new(), time, - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Run(_) => anim::fish_small::RunAnimation::update_skeleton( + // Running + (true, true, false) => anim::fish_small::RunAnimation::update_skeleton( &FishSmallSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Jump(_) => anim::fish_small::JumpAnimation::update_skeleton( + // In air + (false, _, false) => anim::fish_small::JumpAnimation::update_skeleton( &FishSmallSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), @@ -889,8 +962,7 @@ impl FigureMgr { scale, col, dt, - move_state_animation_rate, - action_animation_rate, + state_animation_rate, lpindex, true, ); @@ -906,30 +978,37 @@ impl FigureMgr { _ => continue, }; - if !character.move_state.equals(&last_character.0.move_state) { - state.move_state_time = 0.0; + if !character.equals(&last_character.0) { + state.state_time = 0.0; } - let target_base = match character.move_state { - Stand(_) => anim::biped_large::IdleAnimation::update_skeleton( + let target_base = match ( + physics.on_ground, + vel.0.magnitude_squared() > 0.001, // Moving + physics.in_fluid, // In water + ) { + // Standing + (true, false, false) => anim::biped_large::IdleAnimation::update_skeleton( &BipedLargeSkeleton::new(), time, - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Run(_) => anim::biped_large::RunAnimation::update_skeleton( + // Running + (true, true, false) => anim::biped_large::RunAnimation::update_skeleton( &BipedLargeSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), - Jump(_) => anim::biped_large::JumpAnimation::update_skeleton( + // In air + (false, _, false) => anim::biped_large::JumpAnimation::update_skeleton( &BipedLargeSkeleton::new(), (vel.0.magnitude(), time), - state.move_state_time, - &mut move_state_animation_rate, + state.state_time, + &mut state_animation_rate, skeleton_attr, ), @@ -946,8 +1025,7 @@ impl FigureMgr { scale, col, dt, - move_state_animation_rate, - action_animation_rate, + state_animation_rate, lpindex, true, ); @@ -967,8 +1045,7 @@ impl FigureMgr { scale, col, dt, - move_state_animation_rate, - action_animation_rate, + state_animation_rate, lpindex, true, ); @@ -1163,8 +1240,7 @@ impl FigureMgr { pub struct FigureState { bone_consts: Consts, locals: Consts, - move_state_time: f64, - action_time: f64, + state_time: f64, skeleton: S, pos: Vec3, ori: Vec3, @@ -1180,8 +1256,7 @@ impl FigureState { .create_consts(&skeleton.compute_matrices()) .unwrap(), locals: renderer.create_consts(&[FigureLocals::default()]).unwrap(), - move_state_time: 0.0, - action_time: 0.0, + state_time: 0.0, skeleton, pos: Vec3::zero(), ori: Vec3::zero(), @@ -1200,8 +1275,7 @@ impl FigureState { scale: f32, col: Rgba, dt: f32, - move_state_rate: f32, - action_rate: f32, + state_animation_rate: f32, lpindex: u8, visible: bool, ) { @@ -1219,8 +1293,7 @@ impl FigureState { self.ori = ori; } - self.move_state_time += (dt * move_state_rate) as f64; - self.action_time += (dt * action_rate) as f64; + self.state_time += (dt * state_animation_rate) as f64; // TODO: what are the interpolated ori values used for if not here??? let mat = Mat4::::identity() diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 5731865710..c4ba62bdd3 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -170,7 +170,7 @@ impl Scene { .ecs() .read_storage::() .get(client.entity()) - .map_or(false, |cs| cs.action_state.is_dodging()); + .map_or(false, |cs| cs.is_dodge()); let player_scale = match client .state() diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index aebc915d6a..514ec17ce0 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -11,7 +11,7 @@ use client::{self, Client, Event::Chat}; use common::{ clock::Clock, comp, - comp::{ActionState, Pos, Vel}, + comp::{Pos, Vel}, msg::ClientState, terrain::{Block, BlockKind}, vol::ReadVol, @@ -212,10 +212,10 @@ impl PlayState for SessionState { .state() .read_storage::() .get(client.entity()) - .map(|cs| match cs.action_state { - ActionState::Attack(_) + .map(|cs| match cs { + /*ActionState::Attack(_) // TODO: uncomment | ActionState::Block(_) - | ActionState::Wield(_) => true, + | ActionState::Wield(_) => true,*/ _ => false, }) .unwrap_or(false) From 6515daddce82a27a159d45d84de652e325ecd112 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Wed, 22 Jan 2020 13:48:55 +0100 Subject: [PATCH 032/326] fixes --- common/src/comp/character_state.rs | 4 ++-- common/src/states/glide.rs | 1 - common/src/states/roll.rs | 20 ++++++++++++-------- common/src/states/utils.rs | 1 - voxygen/src/scene/figure/mod.rs | 8 ++++---- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 4bd65127a6..634bda8948 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -70,10 +70,10 @@ impl CharacterState { } } - /// Compares `action_state`s for shallow equality (does not check internal struct equality) + /// Compares for shallow equality (does not check internal struct equality) pub fn equals(&self, other: &Self) -> bool { // Check if state is the same without looking at the inner data - std::mem::discriminant(&self) == std::mem::discriminant(&other) + std::mem::discriminant(self) == std::mem::discriminant(other) } /// Passes data to variant or subvariant handlers diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index f848cd6ee6..b366a3385c 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -16,7 +16,6 @@ impl StateHandler for State { } fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - dbg!(); let mut update = StateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 9979d6308d..aeb1dd45e9 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -46,15 +46,19 @@ impl StateHandler for State { .unwrap_or_default() * ROLL_SPEED; - // Otherwise, tick down remaining_duration - update.character = CharacterState::Roll(Some(State { - remaining_duration: self - .remaining_duration - .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) - .unwrap_or_default(), - })); + if self.remaining_duration == Duration::default() { + // Roll duration has expired + update.character = CharacterState::Idle(None); + } else { + // Otherwise, tick down remaining_duration + update.character = CharacterState::Roll(Some(State { + remaining_duration: self + .remaining_duration + .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) + .unwrap_or_default(), + })); + } - // Keep rolling update } } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 8ae5410587..3fe7aeb873 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -188,7 +188,6 @@ pub fn handle_glide(ecs_data: &EcsStateData, update: &mut StateUpdate) { && !ecs_data.physics.on_ground && ecs_data.body.is_humanoid() { - dbg!(); update.character = CharacterState::Glide(None); } } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 29dd93927a..34edd43a8c 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -408,18 +408,18 @@ impl FigureMgr { skeleton_attr, ), CharacterState::Wielding(_) => { - anim::character::CidleAnimation::update_skeleton( + anim::character::WieldAnimation::update_skeleton( &target_base, - (active_tool_kind, time), + (active_tool_kind, vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, ) } CharacterState::Wielded(_) => { - anim::character::CidleAnimation::update_skeleton( + anim::character::WieldAnimation::update_skeleton( &target_base, - (active_tool_kind, time), + (active_tool_kind, vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, From 76dfac736688e6371c0b27ef1620b6e6c09e4ac4 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 27 Jan 2020 18:32:05 +0100 Subject: [PATCH 033/326] fix: rolling --- voxygen/src/anim/character/roll.rs | 3 ++- voxygen/src/anim/mod.rs | 2 +- voxygen/src/scene/figure/mod.rs | 18 ------------------ 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/voxygen/src/anim/character/roll.rs b/voxygen/src/anim/character/roll.rs index 8a1e05976c..c1402ac40c 100644 --- a/voxygen/src/anim/character/roll.rs +++ b/voxygen/src/anim/character/roll.rs @@ -16,9 +16,10 @@ impl Animation for RollAnimation { skeleton: &Self::Skeleton, (_active_tool_kind, orientation, last_ori, _global_time): Self::Dependency, anim_time: f64, - _rate: &mut f32, + rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { + *rate = 1.0; let mut next = (*skeleton).clone(); let wave = (anim_time as f32 * 5.5).sin(); diff --git a/voxygen/src/anim/mod.rs b/voxygen/src/anim/mod.rs index 4091741ab7..512dc20d66 100644 --- a/voxygen/src/anim/mod.rs +++ b/voxygen/src/anim/mod.rs @@ -14,7 +14,7 @@ use crate::render::FigureBoneData; use common::comp::{self, ToolKind}; use vek::*; -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub struct Bone { pub offset: Vec3, pub ori: Quaternion, diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 34edd43a8c..7e9c0b3f37 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -407,24 +407,6 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ), - CharacterState::Wielding(_) => { - anim::character::WieldAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) - } - CharacterState::Wielded(_) => { - anim::character::WieldAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) - } /*CharacterState::Block(_) => { anim::character::BlockIdleAnimation::update_skeleton( &target_base, From aa52c6fd4f1ece7cf7640ab41bf99512ddc17d46 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 3 Feb 2020 11:54:50 +0100 Subject: [PATCH 034/326] fix: jumping and attacking --- common/src/comp/ability.rs | 13 ++- common/src/comp/character_state.rs | 26 ++--- common/src/event.rs | 3 + common/src/states/basic_attack.rs | 27 +++-- common/src/states/climb.rs | 3 + common/src/states/glide.rs | 3 + common/src/states/idle.rs | 7 +- common/src/states/mod.rs | 1 + common/src/states/roll.rs | 4 +- common/src/states/sit.rs | 3 + common/src/states/utils.rs | 160 ++++++++--------------------- common/src/states/wielded.rs | 7 +- common/src/states/wielding.rs | 3 + common/src/sys/ability.rs | 65 ------------ common/src/sys/character_state.rs | 28 +++-- common/src/sys/mod.rs | 3 - server/src/lib.rs | 2 + server/src/sys/sentinel.rs | 14 ++- voxygen/src/scene/figure/mod.rs | 24 ++--- 19 files changed, 154 insertions(+), 242 deletions(-) delete mode 100644 common/src/sys/ability.rs diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 8dc488a620..f944b05b8d 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -21,7 +21,7 @@ impl Component for AbilityAction { type Storage = FlaggedStorage>; } -#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] pub struct AbilityPool { pub primary: Option, pub secondary: Option, @@ -29,6 +29,17 @@ pub struct AbilityPool { pub dodge: Option, } +impl Default for AbilityPool { + fn default() -> Self { + Self { + primary: Some(comp::CharacterState::BasicAttack(None)), + secondary: None, + block: None, + dodge: Some(comp::CharacterState::Roll(None)), + } + } +} + impl Component for AbilityPool { type Storage = FlaggedStorage>; } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 634bda8948..e94ccb306f 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,7 +1,7 @@ use crate::states::*; use crate::{ - comp::{Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel}, - event::{EventBus, LocalEvent, ServerEvent}, + comp::{AbilityPool, Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel}, + event::{LocalEvent, ServerEvent}, state::DeltaTime, sync::Uid, }; @@ -9,6 +9,7 @@ use serde::Deserialize; use serde::Serialize; use specs::LazyUpdate; use specs::{Component, Entity, FlaggedStorage, HashMapStorage}; +use std::collections::VecDeque; pub struct EcsStateData<'a> { pub entity: &'a Entity, @@ -22,9 +23,8 @@ pub struct EcsStateData<'a> { pub stats: &'a Stats, pub body: &'a Body, pub physics: &'a PhysicsState, + pub ability_pool: &'a AbilityPool, pub updater: &'a LazyUpdate, - pub server_bus: &'a EventBus, - pub local_bus: &'a EventBus, } pub struct StateUpdate { @@ -32,6 +32,8 @@ pub struct StateUpdate { pub pos: Pos, pub vel: Vel, pub ori: Ori, + pub local_events: VecDeque, + pub server_events: VecDeque, } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -41,17 +43,17 @@ pub enum CharacterState { Sit(Option), Wielding(Option), Wielded(Option), - //BasicAttack(Option), + Glide(Option), + BasicAttack(Option), //BasicBlock(Option), //Charge(Option), Roll(Option), - Glide(Option), } impl CharacterState { pub fn is_attack(&self) -> bool { match self { - //CharacterState::BasicAttack(_) => true, + CharacterState::BasicAttack(_) => true, _ => false, } } @@ -83,7 +85,9 @@ impl CharacterState { pub fn update(&self, ecs_data: &EcsStateData) -> StateUpdate { match self { CharacterState::Idle(opt_state) => opt_state + // If data hasn't been initialized, initialize a new one .unwrap_or_else(|| idle::State::new(ecs_data)) + // Call handler .handle(ecs_data), CharacterState::Climb(opt_state) => opt_state .unwrap_or_else(|| climb::State::new(ecs_data)) @@ -97,12 +101,10 @@ impl CharacterState { CharacterState::Wielded(opt_state) => opt_state .unwrap_or_else(|| wielded::State::new(ecs_data)) .handle(ecs_data), - /*CharacterState::BasicAttack(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one + CharacterState::BasicAttack(opt_state) => opt_state .unwrap_or_else(|| basic_attack::State::new(ecs_data)) - // Call handler .handle(ecs_data), - CharacterState::Charge(opt_state) => opt_state + /*CharacterState::Charge(opt_state) => opt_state .unwrap_or_else(|| charge_attack::State::new(ecs_data)) .handle(ecs_data), CharacterState::BasicBlock(opt_state) => opt_state @@ -115,7 +117,7 @@ impl CharacterState { .unwrap_or_else(|| glide::State::new(ecs_data)) .handle(ecs_data), // All states should be explicitly handled - // Do not use default match: _ => {}, + // DO NOT use default match: _ => {}, } } } diff --git a/common/src/event.rs b/common/src/event.rs index 5251358ace..f07f5bd9c8 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -146,6 +146,9 @@ impl<'a, E> Emitter<'a, E> { pub fn emit(&mut self, event: E) { self.events.push_front(event); } + pub fn append(&mut self, other: &mut VecDeque) { + self.events.append(other) + } } impl<'a, E> Drop for Emitter<'a, E> { diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index 99e44201d6..c264c54656 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -1,9 +1,6 @@ -use super::utils::*; -use crate::comp::{ - ActionState::Attack, AttackKind::BasicAttack, EcsStateData, ItemKind::Tool, StateUpdate, - ToolData, -}; +use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; use crate::states::StateHandler; +use std::collections::VecDeque; use std::time::Duration; @@ -32,22 +29,22 @@ impl StateHandler for State { vel: *ecs_data.vel, ori: *ecs_data.ori, character: *ecs_data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; - // Check if attack duration has expired - if self.remaining_duration == Duration::default() { - // If so, go back to wielding or idling - update.character.action_state = attempt_wield(ecs_data.stats); - return update; - } - - // Otherwise, tick down remaining_duration, and keep rolling - update.character.action_state = Attack(BasicAttack(Some(State { + // Tick down remaining_duration + update.character = CharacterState::BasicAttack(Some(State { remaining_duration: self .remaining_duration .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) .unwrap_or_default(), - }))); + })); + + // Check if attack duration has expired + if self.remaining_duration == Duration::default() { + update.character = CharacterState::Wielded(None); + } update } diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 7db0631a6d..08fe2742a6 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -1,6 +1,7 @@ use crate::comp::{CharacterState, EcsStateData, StateUpdate}; use crate::states::StateHandler; use crate::sys::phys::GRAVITY; +use std::collections::VecDeque; use vek::vec::{Vec2, Vec3}; use vek::Lerp; @@ -21,6 +22,8 @@ impl StateHandler for State { vel: *ecs_data.vel, ori: *ecs_data.ori, character: *ecs_data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; // If no wall is in front of character ... diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index b366a3385c..87048bb068 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,5 +1,6 @@ use crate::comp::{CharacterState, EcsStateData, StateUpdate}; use crate::states::StateHandler; +use std::collections::VecDeque; use vek::{Vec2, Vec3}; // Gravity is 9.81 * 4, so this makes gravity equal to .15 @@ -21,6 +22,8 @@ impl StateHandler for State { vel: *ecs_data.vel, ori: *ecs_data.ori, character: *ecs_data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; // If glide button isn't held or player is on ground, end glide diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index 541285dad4..f9934be701 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -1,5 +1,6 @@ use super::utils::*; use crate::comp::{EcsStateData, StateUpdate}; +use std::collections::VecDeque; use crate::states::StateHandler; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -16,15 +17,17 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; handle_move_dir(ecs_data, &mut update); + handle_jump(ecs_data, &mut update); handle_wield(ecs_data, &mut update); handle_sit(ecs_data, &mut update); handle_climb(ecs_data, &mut update); - handle_roll(ecs_data, &mut update); - //handle_jump(ecs_data, &mut update); handle_glide(ecs_data, &mut update); + handle_dodge(ecs_data, &mut update); update } diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index a794626c10..1296526477 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -1,4 +1,5 @@ // Module declarations +pub mod basic_attack; pub mod climb; pub mod glide; pub mod idle; diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index aeb1dd45e9..f1596f8189 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,6 +1,6 @@ -use super::utils::*; use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; use crate::states::StateHandler; +use std::collections::VecDeque; use std::time::Duration; use vek::Vec3; @@ -31,6 +31,8 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; // Update velocity diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index f6a392acb8..34e3f44150 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -1,6 +1,7 @@ use super::utils::*; use crate::comp::{CharacterState, EcsStateData, StateUpdate}; use crate::states::StateHandler; +use std::collections::VecDeque; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; @@ -16,6 +17,8 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; //handle_jump(ecs_data, &mut update); diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 3fe7aeb873..c0854f9d79 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,111 +1,9 @@ -use crate::comp::{ - Body, CharacterState, ControllerInputs, EcsStateData, ItemKind::Tool, PhysicsState, - StateUpdate, Stats, +use crate::{ + comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate}, + event::LocalEvent, }; use vek::vec::{Vec2, Vec3}; -/* -/// _Determines what ability a player has selected for their primary ability, -/// and returns the corresponding `ActionState` or Idle if nothing_ -pub fn determine_primary_ability(stats: &Stats) -> ActionState { - if let Some(Tool(_)) = stats.equipment.main.as_ref().map(|i| &i.kind) { - Attack(BasicAttack(None)) - } else { - Idle(None) - } -} - -/// _Determines what ability a player has selected for their primary ability, -/// and returns the corresponding `ActionState` or Idle if nothing_ -pub fn determine_secondary_ability(stats: &Stats) -> ActionState { - if let Some(Tool(_)) = stats.equipment.main.as_ref().map(|i| &i.kind) { - Block(BasicBlock(None)) - } else { - Idle(None) - } -} - -/// _Returns a `MoveState` based on `in_fluid` condition_ -pub fn determine_fall_or_swim(physics: &PhysicsState) -> MoveState { - // Check if in fluid to go to swimming or back to falling - if physics.in_fluid { - Swim(None) - } else { - Fall(None) - } -} -/// _Returns a `MoveState` based on `move_dir` magnitude_ -pub fn determine_stand_or_run(inputs: &ControllerInputs) -> MoveState { - // Return to running or standing based on move inputs - if inputs.move_dir.magnitude_squared() > 0.0 { - Run(None) - } else { - Stand(None) - } -} - -/// _Returns a `MoveState` based on `on_ground` state._ -/// -/// _`FallState`, or `SwimState` if not `on_ground`, -/// `StandState` or `RunState` if is `on_ground`_ -pub fn determine_move_from_grounded_state( - physics: &PhysicsState, - inputs: &ControllerInputs, -) -> MoveState { - // Not on ground, go to swim or fall - if !physics.on_ground { - determine_fall_or_swim(physics) - } - // On ground - else { - determine_stand_or_run(inputs) - } -} - -/// _Returns an ActionState based on whether character has a weapon equipped._ -pub fn attempt_wield(stats: &Stats) -> ActionState { - if let Some(Tool(_)) = stats.equipment.main.as_ref().map(|i| &i.kind) { - Wield(None) - } else { - Idle(None) - } -} - -pub fn can_climb(physics: &PhysicsState, inputs: &ControllerInputs, body: &Body) -> bool { - if let (true, Some(_wall_dir)) = ( - (inputs.climb.is_pressed() | inputs.climb_down.is_pressed()) && body.is_humanoid(), - physics.on_wall, - ) { - true - } else { - false - } -} - -pub fn can_glide(physics: &PhysicsState, inputs: &ControllerInputs, body: &Body) -> bool { - if inputs.glide.is_pressed() && body.is_humanoid() && physics.on_wall == None { - true - } else { - false - } -} - -pub fn can_sit(physics: &PhysicsState, inputs: &ControllerInputs, body: &Body) -> bool { - if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() { - true - } else { - false - } -} - -pub fn can_jump(physics: &PhysicsState, inputs: &ControllerInputs) -> bool { - if physics.on_ground && inputs.jump.is_pressed() { - true - } else { - false - } -}*/ - pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) { let (accel, speed): (f32, f32) = if ecs_data.physics.on_ground { let accel = 50.0; @@ -166,15 +64,6 @@ pub fn handle_climb(ecs_data: &EcsStateData, update: &mut StateUpdate) { } } -pub fn handle_roll(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if ecs_data.inputs.roll.is_pressed() - && ecs_data.physics.on_ground - && ecs_data.body.is_humanoid() - { - update.character = CharacterState::Roll(None); - } -} - pub fn handle_unwield(ecs_data: &EcsStateData, update: &mut StateUpdate) { if let CharacterState::Wielded(_) = update.character { if ecs_data.inputs.toggle_wield.is_pressed() { @@ -184,10 +73,43 @@ pub fn handle_unwield(ecs_data: &EcsStateData, update: &mut StateUpdate) { } pub fn handle_glide(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if ecs_data.inputs.glide.is_pressed() - && !ecs_data.physics.on_ground - && ecs_data.body.is_humanoid() - { - update.character = CharacterState::Glide(None); + if let CharacterState::Idle(_) | CharacterState::Wielded(_) = update.character { + if ecs_data.inputs.glide.is_pressed() + && !ecs_data.physics.on_ground + && ecs_data.body.is_humanoid() + { + update.character = CharacterState::Glide(None); + } + } +} + +pub fn handle_jump(ecs_data: &EcsStateData, update: &mut StateUpdate) { + if ecs_data.inputs.jump.is_pressed() && ecs_data.physics.on_ground { + update + .local_events + .push_front(LocalEvent::Jump(*ecs_data.entity)); + } +} + +pub fn handle_primary(ecs_data: &EcsStateData, update: &mut StateUpdate) { + if let Some(state) = ecs_data.ability_pool.primary { + if let CharacterState::Wielded(_) = update.character { + if ecs_data.inputs.primary.is_pressed() { + update.character = state; + } + } + } +} + +pub fn handle_dodge(ecs_data: &EcsStateData, update: &mut StateUpdate) { + if let Some(state) = ecs_data.ability_pool.dodge { + if let CharacterState::Idle(_) | CharacterState::Wielded(_) = update.character { + if ecs_data.inputs.roll.is_pressed() + && ecs_data.physics.on_ground + && ecs_data.body.is_humanoid() + { + update.character = state; + } + } } } diff --git a/common/src/states/wielded.rs b/common/src/states/wielded.rs index 27800331b3..e70b0c0c34 100644 --- a/common/src/states/wielded.rs +++ b/common/src/states/wielded.rs @@ -1,6 +1,7 @@ use super::utils::*; use crate::comp::{EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; use crate::states::StateHandler; +use std::collections::VecDeque; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -29,14 +30,18 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; handle_move_dir(&ecs_data, &mut update); + handle_jump(&ecs_data, &mut update); handle_sit(&ecs_data, &mut update); - handle_roll(&ecs_data, &mut update); handle_climb(&ecs_data, &mut update); handle_glide(&ecs_data, &mut update); handle_unwield(&ecs_data, &mut update); + handle_primary(&ecs_data, &mut update); + handle_dodge(&ecs_data, &mut update); update } diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 32e97b8bb4..d2e3bd289e 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -1,6 +1,7 @@ use super::utils::*; use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; use crate::states::StateHandler; +use std::collections::VecDeque; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -30,6 +31,8 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; handle_move_dir(&ecs_data, &mut update); diff --git a/common/src/sys/ability.rs b/common/src/sys/ability.rs deleted file mode 100644 index 07aaa21bd1..0000000000 --- a/common/src/sys/ability.rs +++ /dev/null @@ -1,65 +0,0 @@ -#![allow(unused_imports)] -#![allow(dead_code)] -use crate::comp::{AbilityAction, AbilityActionKind, AbilityPool, CharacterState}; -use crate::states::StateHandler; - -use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; - -/// # Ability System -/// #### Updates tuples of ( `CharacterState`, `AbilityAction`, and `AbilityPool`s ) -/// _Each update determines what type of ability is being started, and looks into the AbilityPool for which -/// Ability that should be used. System then updates `CharacterState` to that Ability._ -pub struct Sys; - -impl<'a> System<'a> for Sys { - type SystemData = ( - Entities<'a>, - Read<'a, LazyUpdate>, - WriteStorage<'a, CharacterState>, - ReadStorage<'a, AbilityAction>, - ReadStorage<'a, AbilityPool>, - ); - fn run( - &mut self, - ( - entities, - _updater, - mut character_state_storage, - ability_action_storage, - ability_pool_storage, - ): Self::SystemData, - ) { - for (_entity, mut _character, _ability_action, _ability_pool) in ( - &entities, - &mut character_state_storage, - &ability_action_storage, - &ability_pool_storage, - ) - .join() - { - // match ability_action.0 { - // AbilityActionKind::Primary => { - // if let Some(AttackKind(Some(attack_kind))) = ability_pool.primary { - // character.action_state = Attack(attack_kind::default()); - // } - // } - // AbilityActionKind::Secondary => { - // if let Some(attack_kind) = ability_pool.secondary { - // character.action_state = Attack(attack_kind::default()); - // } - // } - // AbilityActionKind::Block => { - // if let Some(block_kind) = ability_pool.block { - // character.action_state = Block(block_kind::default()); - // } - // } - // AbilityActionKind::Dodge => { - // if let Some(dodge_kind) = ability_pool.dodge { - // character.action_state = Dodge(dodge_kind::default()); - // } - // } - // _ => {} - // } - } - } -} diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index c36aae2a1d..4d44334320 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - Body, CharacterState, Controller, EcsStateData, Mounting, Ori, PhysicsState, Pos, Stats, - Vel, + AbilityPool, Body, CharacterState, Controller, EcsStateData, Mounting, Ori, PhysicsState, + Pos, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -33,6 +33,7 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Stats>, ReadStorage<'a, Body>, ReadStorage<'a, PhysicsState>, + ReadStorage<'a, AbilityPool>, ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, ); @@ -53,11 +54,24 @@ impl<'a> System<'a> for Sys { stats, bodies, physics_states, + ability_pools, uids, mountings, ): Self::SystemData, ) { - for (entity, uid, mut character, pos, vel, ori, controller, stats, body, physics) in ( + for ( + entity, + uid, + character, + pos, + vel, + ori, + controller, + stats, + body, + physics, + ability_pool, + ) in ( &entities, &uids, &mut character_states, @@ -68,6 +82,7 @@ impl<'a> System<'a> for Sys { &stats, &bodies, &physics_states, + &ability_pools, ) .join() { @@ -91,7 +106,7 @@ impl<'a> System<'a> for Sys { return; } - let state_update = character.update(&EcsStateData { + let mut state_update = character.update(&EcsStateData { entity: &entity, uid, character, @@ -104,14 +119,15 @@ impl<'a> System<'a> for Sys { body, physics, updater: &updater, - server_bus: &server_bus, - local_bus: &local_bus, + ability_pool, }); *character = state_update.character; *pos = state_update.pos; *vel = state_update.vel; *ori = state_update.ori; + local_bus.emitter().append(&mut state_update.local_events); + server_bus.emitter().append(&mut state_update.server_events); } } } diff --git a/common/src/sys/mod.rs b/common/src/sys/mod.rs index f8b2fa5627..5d439228f7 100644 --- a/common/src/sys/mod.rs +++ b/common/src/sys/mod.rs @@ -1,4 +1,3 @@ -mod ability; pub mod agent; pub mod character_state; pub mod controller; @@ -11,7 +10,6 @@ mod stats; use specs::DispatcherBuilder; // System names -pub const ABILITY_SYS: &str = "ability_sys"; pub const CHARACTER_STATE_SYS: &str = "character_state_sys"; pub const AGENT_SYS: &str = "agent_sys"; pub const CONTROLLER_SYS: &str = "controller_sys"; @@ -27,7 +25,6 @@ pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) { dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS, MOUNT_SYS]); dispatch_builder.add(character_state::Sys, CHARACTER_STATE_SYS, &[CONTROLLER_SYS]); dispatch_builder.add(stats::Sys, STATS_SYS, &[]); - dispatch_builder.add(ability::Sys, ABILITY_SYS, &[CHARACTER_STATE_SYS]); dispatch_builder.add(phys::Sys, PHYS_SYS, &[CONTROLLER_SYS, MOUNT_SYS, STATS_SYS]); dispatch_builder.add(projectile::Sys, PROJECTILE_SYS, &[PHYS_SYS]); } diff --git a/server/src/lib.rs b/server/src/lib.rs index 6bf0557244..7aca5346ed 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -267,6 +267,7 @@ impl Server { state.write_component(entity, comp::CharacterState::default()); state.write_component(entity, comp::Inventory::default()); state.write_component(entity, comp::InventoryUpdate); + state.write_component(entity, comp::AbilityPool::default()); // Make sure physics are accepted. state.write_component(entity, comp::ForceUpdate); @@ -1188,6 +1189,7 @@ impl StateExt for State { .with(comp::Energy::new(100)) .with(comp::Gravity(1.0)) .with(comp::CharacterState::default()) + .with(comp::AbilityPool::default()) } fn notify_registered_clients(&self, msg: ServerMsg) { diff --git a/server/src/sys/sentinel.rs b/server/src/sys/sentinel.rs index 320a07a4dd..57408df0bc 100644 --- a/server/src/sys/sentinel.rs +++ b/server/src/sys/sentinel.rs @@ -1,8 +1,8 @@ use super::SysTimer; use common::{ comp::{ - Body, CanBuild, Energy, Gravity, Item, LightEmitter, Mass, MountState, Mounting, Player, - Scale, Stats, Sticky, + AbilityPool, Body, CanBuild, Energy, Gravity, Item, LightEmitter, Mass, MountState, + Mounting, Player, Scale, Stats, Sticky, }, msg::EcsCompPacket, sync::{EntityPackage, SyncPackage, Uid, UpdateTracker, WorldSyncExt}, @@ -50,6 +50,7 @@ pub struct TrackedComps<'a> { pub mass: ReadStorage<'a, Mass>, pub sticky: ReadStorage<'a, Sticky>, pub gravity: ReadStorage<'a, Gravity>, + pub ability_pool: ReadStorage<'a, AbilityPool>, } impl<'a> TrackedComps<'a> { pub fn create_entity_package(&self, entity: EcsEntity) -> EntityPackage { @@ -103,6 +104,10 @@ impl<'a> TrackedComps<'a> { .get(entity) .copied() .map(|c| comps.push(c.into())); + self.ability_pool + .get(entity) + .copied() + .map(|c| comps.push(c.into())); EntityPackage { uid, comps } } @@ -123,6 +128,7 @@ pub struct ReadTrackers<'a> { pub mass: ReadExpect<'a, UpdateTracker>, pub sticky: ReadExpect<'a, UpdateTracker>, pub gravity: ReadExpect<'a, UpdateTracker>, + pub ability_pool: ReadExpect<'a, UpdateTracker>, } impl<'a> ReadTrackers<'a> { pub fn create_sync_package( @@ -150,6 +156,7 @@ impl<'a> ReadTrackers<'a> { .with_component(&comps.uid, &*self.mass, &comps.mass, filter) .with_component(&comps.uid, &*self.sticky, &comps.sticky, filter) .with_component(&comps.uid, &*self.gravity, &comps.gravity, filter) + .with_component(&comps.uid, &*self.ability_pool, &comps.ability_pool, filter) } } @@ -169,6 +176,7 @@ pub struct WriteTrackers<'a> { mass: WriteExpect<'a, UpdateTracker>, sticky: WriteExpect<'a, UpdateTracker>, gravity: WriteExpect<'a, UpdateTracker>, + ability_pool: WriteExpect<'a, UpdateTracker>, } fn record_changes(comps: &TrackedComps, trackers: &mut WriteTrackers) { @@ -187,6 +195,7 @@ fn record_changes(comps: &TrackedComps, trackers: &mut WriteTrackers) { trackers.mass.record_changes(&comps.mass); trackers.sticky.record_changes(&comps.sticky); trackers.gravity.record_changes(&comps.gravity); + trackers.ability_pool.record_changes(&comps.ability_pool); } pub fn register_trackers(world: &mut World) { @@ -204,6 +213,7 @@ pub fn register_trackers(world: &mut World) { world.register_tracker::(); world.register_tracker::(); world.register_tracker::(); + world.register_tracker::(); } /// Deleted entities grouped by region diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 7e9c0b3f37..bda3aefe89 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -331,12 +331,6 @@ impl FigureMgr { let mut state_animation_rate = 1.0; - let vel = ecs - .read_storage::() - .get(entity) - .cloned() - .unwrap_or_default(); - let active_tool_kind = if let Some(ItemKind::Tool(ToolData { kind, .. })) = stats .and_then(|s| s.equipment.main.as_ref()) .map(|i| &i.kind) @@ -407,6 +401,15 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ), + CharacterState::BasicAttack(_) => { + anim::character::AttackAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } /*CharacterState::Block(_) => { anim::character::BlockIdleAnimation::update_skeleton( &target_base, @@ -424,15 +427,6 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ) - } - CharacterState::BasicAttack(_) => { - anim::character::AttackAnimation::update_skeleton( - &target_base, - (active_tool_kind, time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) }*/ CharacterState::Wielding(_) => { anim::character::WieldAnimation::update_skeleton( From aeb37a1f33928a5a18102272f1514f6f368defbd Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 3 Feb 2020 20:43:36 +0100 Subject: [PATCH 035/326] improvement: char speed --- common/src/states/climb.rs | 10 ++-------- common/src/states/utils.rs | 27 +++++++++++++++------------ common/src/sys/phys.rs | 2 +- voxygen/src/anim/character/run.rs | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 08fe2742a6..a105a30323 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -27,19 +27,13 @@ impl StateHandler for State { }; // If no wall is in front of character ... - if let None = ecs_data.physics.on_wall { + if ecs_data.physics.on_wall.is_none() || ecs_data.physics.on_ground { if ecs_data.inputs.jump.is_pressed() { // They've climbed atop something, give them a boost //TODO: JUMP EVENT - } else { - // Just fall off - update.character = CharacterState::Idle(None); } - } - - // Remove climb state on ground, otherwise character will get stuck - if ecs_data.physics.on_ground { update.character = CharacterState::Idle(None); + return update; } // Move player diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index c0854f9d79..1f9c3b5e0b 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -6,23 +6,24 @@ use vek::vec::{Vec2, Vec3}; pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) { let (accel, speed): (f32, f32) = if ecs_data.physics.on_ground { - let accel = 50.0; - let speed = 120.0; + let accel = 100.0; + let speed = 8.0; (accel, speed) } else { - let accel = 10.0; - let speed = 100.0; + let accel = 100.0; + let speed = 8.0; (accel, speed) }; // Move player according to move_dir - update.vel.0 += Vec2::broadcast(ecs_data.dt.0) - * ecs_data.inputs.move_dir - * if update.vel.0.magnitude_squared() < speed.powf(2.0) { - accel - } else { - 0.0 - }; + if update.vel.0.magnitude_squared() < speed.powf(2.0) { + update.vel.0 = + update.vel.0 + Vec2::broadcast(ecs_data.dt.0) * ecs_data.inputs.move_dir * accel; + let mag2 = update.vel.0.magnitude_squared(); + if mag2 > speed.powf(2.0) { + update.vel.0 = update.vel.0.normalized() * speed; + } + } // Set direction based on move direction let ori_dir = if update.character.is_attack() || update.character.is_block() { @@ -56,8 +57,10 @@ pub fn handle_sit(ecs_data: &EcsStateData, update: &mut StateUpdate) { } pub fn handle_climb(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if (ecs_data.inputs.climb.is_pressed() || ecs_data.inputs.climb_down.is_pressed()) + if (ecs_data.inputs.climb.is_just_pressed() || ecs_data.inputs.climb_down.is_pressed()) && ecs_data.physics.on_wall.is_some() + && !ecs_data.physics.on_ground + //&& update.vel.0.z < 0.0 && ecs_data.body.is_humanoid() { update.character = CharacterState::Climb(None); diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index 955d229c22..1a72708302 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -11,7 +11,7 @@ use { vek::*, }; -pub const GRAVITY: f32 = 9.81 * 4.0; +pub const GRAVITY: f32 = 9.81 * 7.0; const BOUYANCY: f32 = 0.0; // Friction values used for linear damping. They are unitless quantities. The // value of these quantities must be between zero and one. They represent the diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index f70fbbb5ec..26565dfb78 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -27,7 +27,7 @@ impl Animation for RunAnimation { let constant = 1.0; let wave = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 1.2).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 4.2).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * constant as f32 * 1.2).sin()); let wave_cos = (((5.0) From d383abf9501fd6c6fdad5c89b9c8d834da0bf713 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Tue, 11 Feb 2020 07:42:17 -0800 Subject: [PATCH 036/326] Re add combat --- common/src/comp/character_state.rs | 33 +++++- common/src/comp/mod.rs | 2 +- common/src/msg/ecs_packet.rs | 9 +- common/src/state.rs | 1 + common/src/states/basic_attack.rs | 43 +++++--- common/src/states/mod.rs | 49 ++------- common/src/states/utils.rs | 13 ++- common/src/sys/combat.rs | 168 +++++++++++------------------ common/src/sys/mod.rs | 3 + 9 files changed, 146 insertions(+), 175 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index df36c541df..a0783bae05 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,13 +1,13 @@ use crate::{ - comp::{AbilityPool, Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel}, + comp::{AbilityPool, Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, ToolData, Vel}, event::{LocalEvent, ServerEvent}, state::DeltaTime, states::*, sync::Uid, }; use serde::{Deserialize, Serialize}; -use specs::{Component, Entity, FlaggedStorage, HashMapStorage, LazyUpdate}; -use std::collections::VecDeque; +use specs::{Component, Entity, FlaggedStorage, HashMapStorage, LazyUpdate, VecStorage}; +use std::{collections::VecDeque, time::Duration}; pub struct EcsStateData<'a> { pub entity: &'a Entity, @@ -127,3 +127,30 @@ impl Default for CharacterState { impl Component for CharacterState { type Storage = FlaggedStorage>; } + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Attacking { + pub weapon: ToolData, + pub time_active: Duration, +} + +impl Attacking { + pub fn remaining_duration(&self) -> Duration { + self.weapon + .attack_duration() + .checked_sub(self.time_active) + .unwrap_or_default() + } + + pub fn tick_time_active(&mut self, dt: Duration) { + self.time_active = self.time_active.checked_add(dt).unwrap_or_default(); + } + + pub fn can_apply_damage(&self) -> bool { + (self.time_active > self.weapon.attack_buildup_duration()) + } +} + +impl Component for Attacking { + type Storage = VecStorage; +} diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 1be4ed8a07..eb8f6cda25 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -23,7 +23,7 @@ pub use body::{ biped_large, bird_medium, bird_small, critter, dragon, fish_medium, fish_small, humanoid, object, quadruped_medium, quadruped_small, AllBodies, Body, BodyData, }; -pub use character_state::{CharacterState, EcsStateData, StateUpdate}; +pub use character_state::{Attacking, CharacterState, EcsStateData, StateUpdate}; pub use controller::{ ControlEvent, Controller, ControllerInputs, Input, InputState, InventoryManip, MountState, Mounting, diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index b8a9df7256..57496dda0f 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -23,6 +23,7 @@ sum_type! { Sticky(comp::Sticky), AbilityAction(comp::AbilityAction), AbilityPool(comp::AbilityPool), + Attacking(comp::Attacking), } } // Automatically derive From for EcsCompPhantom @@ -45,6 +46,7 @@ sum_type! { Sticky(PhantomData), AbilityAction(PhantomData), AbilityPool(PhantomData), + Attacking(PhantomData), } } impl sync::CompPacket for EcsCompPacket { @@ -67,6 +69,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Sticky(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::AbilityAction(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::AbilityPool(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::Attacking(comp) => sync::handle_insert(comp, entity, world), } } @@ -87,6 +90,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Sticky(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::AbilityAction(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::AbilityPool(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::Attacking(comp) => sync::handle_modify(comp, entity, world), } } @@ -109,10 +113,11 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPhantom::Sticky(_) => sync::handle_remove::(entity, world), EcsCompPhantom::AbilityAction(_) => { sync::handle_remove::(entity, world) - } + }, EcsCompPhantom::AbilityPool(_) => { sync::handle_remove::(entity, world) - } + }, + EcsCompPhantom::Attacking(_) => sync::handle_remove::(entity, world), } } } diff --git a/common/src/state.rs b/common/src/state.rs index 13c3e55e3d..3064a58553 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -122,6 +122,7 @@ impl State { ecs.register::(); ecs.register::(); ecs.register::(); + ecs.register::(); // Register components send from clients -> server ecs.register::(); diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index c264c54656..ba300b7b55 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -1,13 +1,15 @@ -use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; -use crate::states::StateHandler; -use std::collections::VecDeque; - -use std::time::Duration; +use crate::{ + comp::{Attacking, CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}, + states::{utils, StateHandler}, +}; +use std::{collections::VecDeque, time::Duration}; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State { /// How long the state has until exitting pub remaining_duration: Duration, + ///Whether damage can be applied + pub can_apply_damage: bool, } impl StateHandler for State { @@ -20,6 +22,7 @@ impl StateHandler for State { }; Self { remaining_duration: tool_data.attack_duration(), + can_apply_damage: false, } } @@ -33,18 +36,26 @@ impl StateHandler for State { server_events: VecDeque::new(), }; - // Tick down remaining_duration - update.character = CharacterState::BasicAttack(Some(State { - remaining_duration: self - .remaining_duration - .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) - .unwrap_or_default(), - })); + // // Tick down + // update.character = CharacterState::BasicAttack(Some(State { + // remaining_duration: self + // .remaining_duration + // .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) + // .unwrap_or_default(), + // can_apply_damage: if let Some(Tool(data)) = + // ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) + // { + // (self.remaining_duration < data.attack_recover_duration()) + // } else { + // false + // }, + // })); - // Check if attack duration has expired - if self.remaining_duration == Duration::default() { - update.character = CharacterState::Wielded(None); - } + // // Check if attack duration has expired + // if self.remaining_duration == Duration::default() { + // update.character = CharacterState::Wielded(None); + // ecs_data.updater.remove::(*ecs_data.entity); + // } update } diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 1296526477..e917b855b1 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -13,49 +13,14 @@ use crate::comp::{EcsStateData, StateUpdate}; /// ## A type for implementing State Handling Behavior. /// -/// Called by state machines' update functions to allow current states to handle updating -/// their parent machine's current state. +/// Called by state machines' update functions to allow current states to handle +/// updating their parent machine's current state. /// -/// Structures must implement a `handle()` fn to handle update behavior, and a `new()` for -/// instantiating new instances of a state. `handle()` function recieves `EcsStateData`, a struct -/// of readonly ECS Component data, and returns a `StateUpdate` tuple, with new components that will -/// overwrite an entitie's old components. -/// -/// ## Example Implementation: -/// ``` -/// use crate::states::utils; -/// -/// #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -/// pub struct RunState { -/// active_duration: Duration, -/// } -/// -/// impl StateHandler for RunState { -/// fn new(ecs_data: &EcsStateData) -> Self { -/// Self { -/// active_duration: Duration::default(), -/// } -/// } -/// -/// fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { -/// let mut update = StateUpdate { -/// character: *ecs_data.character, -/// pos: *ecs_data.pos, -/// vel: *ecs_data.vel, -/// ori: *ecs_data.ori, -/// }; -/// -/// // -- snip -- -/// // Updates; checks for gliding, climbing, etc. -/// -/// // Update based on groundedness -/// update.character.move_state = -/// utils::determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); -/// -/// update -/// } -/// } -/// ``` +/// Structures must implement a `handle()` fn to handle update behavior, and a +/// `new()` for instantiating new instances of a state. `handle()` function +/// recieves `EcsStateData`, a struct of readonly ECS Component data, and +/// returns a `StateUpdate` tuple, with new components that will overwrite an +/// entitie's old components. pub trait StateHandler: Default { fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate; fn new(ecs_data: &EcsStateData) -> Self; diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 1f9c3b5e0b..1abf09080a 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,7 +1,8 @@ use crate::{ - comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate}, + comp::{Attacking, CharacterState, EcsStateData, ItemKind::Tool, StateUpdate}, event::LocalEvent, }; +use std::time::Duration; use vek::vec::{Vec2, Vec3}; pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) { @@ -96,9 +97,13 @@ pub fn handle_jump(ecs_data: &EcsStateData, update: &mut StateUpdate) { pub fn handle_primary(ecs_data: &EcsStateData, update: &mut StateUpdate) { if let Some(state) = ecs_data.ability_pool.primary { - if let CharacterState::Wielded(_) = update.character { - if ecs_data.inputs.primary.is_pressed() { - update.character = state; + if ecs_data.inputs.primary.is_pressed() { + update.character = state; + if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { + ecs_data.updater.insert(*ecs_data.entity, Attacking { + weapon: data, + time_active: Duration::default(), + }); } } } diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 36fc603e58..63e8c7c303 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - ActionState::*, Body, CharacterState, Controller, HealthChange, HealthSource, Item, - ItemKind, Ori, Pos, Scale, Stats, + Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Item, ItemKind, + Ori, Pos, Scale, Stats, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -33,6 +33,7 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Controller>, ReadStorage<'a, Body>, ReadStorage<'a, Stats>, + WriteStorage<'a, Attacking>, WriteStorage<'a, CharacterState>, ); @@ -50,14 +51,12 @@ impl<'a> System<'a> for Sys { controllers, bodies, stats, + mut attacking_storage, mut character_states, ): Self::SystemData, ) { - // let mut server_emitter = server_bus.emitter(); - // let mut _local_emitter = local_bus.emitter(); - // Attacks - for (entity, uid, pos, ori, scale_maybe, _, attacker_stats) in ( + for (entity, uid, pos, ori, scale_maybe, _, attacker_stats, attack) in ( &entities, &uids, &positions, @@ -65,115 +64,70 @@ impl<'a> System<'a> for Sys { scales.maybe(), &controllers, &stats, + &mut attacking_storage, ) .join() { - let recover_duration = if let Some(Item { - kind: ItemKind::Tool { kind, .. }, - .. - }) = attacker_stats.equipment.main - { - kind.attack_recover_duration() - } else { - Duration::from_millis(250) - }; + attack.tick_time_active(Duration::from_secs_f32(dt.0)); - // let (deal_damage, should_end) = if let Some(Attack { time_left, applied }) = - // &mut character_states.get_mut(entity).map(|c| &mut c.action) - // { - // *time_left = time_left - // .checked_sub(Duration::from_secs_f32(dt.0)) - // .unwrap_or_default(); - // if !*applied && recover_duration > *time_left { - // *applied = true; - // (true, false) - // } else if *time_left == Duration::default() { - // (false, true) - // } else { - // (false, false) - // } - // } else { - // (false, false) - // }; + if attack.can_apply_damage() { + // Go through all other entities + for (b, uid_b, pos_b, ori_b, scale_b_maybe, character_b, stats_b, body_b) in ( + &entities, + &uids, + &positions, + &orientations, + scales.maybe(), + &character_states, + &stats, + &bodies, + ) + .join() + { + // 2D versions + let pos2 = Vec2::from(pos.0); + let pos_b2: Vec2 = Vec2::from(pos_b.0); + let ori2 = Vec2::from(ori.0); - // if deal_damage { - // if let Some(Attack { .. }) = &character_states.get(entity).map(|c| c.action) { - // // Go through all other entities - // for (b, uid_b, pos_b, ori_b, scale_b_maybe, character_b, stats_b, body_b) in ( - // &entities, - // &uids, - // &positions, - // &orientations, - // scales.maybe(), - // &character_states, - // &stats, - // &bodies, - // ) - // .join() - // { - // // 2D versions - // let pos2 = Vec2::from(pos.0); - // let pos_b2: Vec2 = Vec2::from(pos_b.0); - // let ori2 = Vec2::from(ori.0); + // Scales + let scale = scale_maybe.map_or(1.0, |s| s.0); + let scale_b = scale_b_maybe.map_or(1.0, |s| s.0); + let rad_b = body_b.radius() * scale_b; - // // Scales - // let scale = scale_maybe.map_or(1.0, |s| s.0); - // let scale_b = scale_b_maybe.map_or(1.0, |s| s.0); - // let rad_b = body_b.radius() * scale_b; + // Check if it is a hit + if entity != b + && !stats_b.is_dead + // Spherical wedge shaped attack field + && pos.0.distance_squared(pos_b.0) < (rad_b + scale * ATTACK_RANGE).powi(2) + && ori2.angle_between(pos_b2 - pos2) < ATTACK_ANGLE.to_radians() / 2.0 + (rad_b / pos2.distance(pos_b2)).atan() + { + // Weapon gives base damage + let mut dmg = attack.weapon.base_damage as i32; - // // Check if it is a hit - // if entity != b - // && !stats_b.is_dead - // // Spherical wedge shaped attack field - // && pos.0.distance_squared(pos_b.0) < (rad_b + scale * ATTACK_RANGE).powi(2) - // && ori2.angle_between(pos_b2 - pos2) < ATTACK_ANGLE.to_radians() / 2.0 + (rad_b / pos2.distance(pos_b2)).atan() - // { - // // Weapon gives base damage - // let mut dmg = if let Some(ItemKind::Tool { power, .. }) = - // attacker_stats.equipment.main.as_ref().map(|i| &i.kind) - // { - // *power as i32 - // } else { - // 1 - // }; + // Block + if character_b.is_block() + && ori_b.0.angle_between(pos.0 - pos_b.0) + < BLOCK_ANGLE.to_radians() / 2.0 + { + dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as i32 + } - // // Block - // if character_b.action.is_block() - // && ori_b.0.angle_between(pos.0 - pos_b.0) - // < BLOCK_ANGLE.to_radians() / 2.0 - // { - // dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as i32 - // } + server_bus.emitter().emit(ServerEvent::Damage { + uid: *uid_b, + change: HealthChange { + amount: -dmg, + cause: HealthSource::Attack { by: *uid }, + }, + }); + } + } + } - // server_emitter.emit(ServerEvent::Damage { - // uid: *uid_b, - // change: HealthChange { - // amount: -dmg, - // cause: HealthSource::Attack { by: *uid }, - // }, - // }); - // } - // } - // } - // } - - // if should_end { - // if let Some(character) = &mut character_states.get_mut(entity) { - // character.action = Wield { - // time_left: Duration::default(), - // }; - // } - // } - - // if let Some(Wield { time_left }) = - // &mut character_states.get_mut(entity).map(|c| &mut c.action) - // { - // if *time_left != Duration::default() { - // *time_left = time_left - // .checked_sub(Duration::from_secs_f32(dt.0)) - // .unwrap_or_default(); - // } - // } - // } + if attack.remaining_duration() == Duration::default() { + if let Some(character) = character_states.get_mut(entity) { + *character = CharacterState::Wielded(None); + } + } + } } } diff --git a/common/src/sys/mod.rs b/common/src/sys/mod.rs index 56eb836ee0..6deb55ff11 100644 --- a/common/src/sys/mod.rs +++ b/common/src/sys/mod.rs @@ -1,5 +1,6 @@ pub mod agent; pub mod character_state; +mod combat; pub mod controller; mod mount; pub mod phys; @@ -11,6 +12,7 @@ use specs::DispatcherBuilder; // System names pub const CHARACTER_STATE_SYS: &str = "character_state_sys"; +pub const COMBAT_SYS: &str = "combat_sys"; pub const AGENT_SYS: &str = "agent_sys"; pub const CONTROLLER_SYS: &str = "controller_sys"; pub const MOUNT_SYS: &str = "mount_sys"; @@ -26,4 +28,5 @@ pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) { dispatch_builder.add(stats::Sys, STATS_SYS, &[]); dispatch_builder.add(phys::Sys, PHYS_SYS, &[CONTROLLER_SYS, MOUNT_SYS, STATS_SYS]); dispatch_builder.add(projectile::Sys, PROJECTILE_SYS, &[PHYS_SYS]); + dispatch_builder.add(combat::Sys, COMBAT_SYS, &[PROJECTILE_SYS]); } From 1f4065ae3258d1436d83e748378bdc38f89b8efa Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 24 Feb 2020 14:32:12 +0100 Subject: [PATCH 037/326] fix: attacking --- common/src/comp/character_state.rs | 18 ------ common/src/states/basic_attack.rs | 62 +++++++++++++------- common/src/states/utils.rs | 10 +--- common/src/sys/combat.rs | 94 +++++++++++++----------------- 4 files changed, 85 insertions(+), 99 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index a0783bae05..417e49b042 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -131,24 +131,6 @@ impl Component for CharacterState { #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Attacking { pub weapon: ToolData, - pub time_active: Duration, -} - -impl Attacking { - pub fn remaining_duration(&self) -> Duration { - self.weapon - .attack_duration() - .checked_sub(self.time_active) - .unwrap_or_default() - } - - pub fn tick_time_active(&mut self, dt: Duration) { - self.time_active = self.time_active.checked_add(dt).unwrap_or_default(); - } - - pub fn can_apply_damage(&self) -> bool { - (self.time_active > self.weapon.attack_buildup_duration()) - } } impl Component for Attacking { diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index ba300b7b55..91eaabc790 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -8,8 +8,8 @@ use std::{collections::VecDeque, time::Duration}; pub struct State { /// How long the state has until exitting pub remaining_duration: Duration, - ///Whether damage can be applied - pub can_apply_damage: bool, + /// Whether the attack can deal more damage + pub exhausted: bool, } impl StateHandler for State { @@ -22,7 +22,7 @@ impl StateHandler for State { }; Self { remaining_duration: tool_data.attack_duration(), - can_apply_damage: false, + exhausted: false, } } @@ -36,26 +36,44 @@ impl StateHandler for State { server_events: VecDeque::new(), }; - // // Tick down - // update.character = CharacterState::BasicAttack(Some(State { - // remaining_duration: self - // .remaining_duration - // .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) - // .unwrap_or_default(), - // can_apply_damage: if let Some(Tool(data)) = - // ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) - // { - // (self.remaining_duration < data.attack_recover_duration()) - // } else { - // false - // }, - // })); + let tool_kind = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind); - // // Check if attack duration has expired - // if self.remaining_duration == Duration::default() { - // update.character = CharacterState::Wielded(None); - // ecs_data.updater.remove::(*ecs_data.entity); - // } + let can_apply_damage = !self.exhausted + && if let Some(Tool(data)) = tool_kind { + (self.remaining_duration < data.attack_recover_duration()) + } else { + false + }; + + let mut exhausted = self.exhausted; + + if can_apply_damage { + if let Some(Tool(data)) = tool_kind { + ecs_data + .updater + .insert(*ecs_data.entity, Attacking { weapon: data }); + exhausted = true; + } + } else { + ecs_data.updater.remove::(*ecs_data.entity); + } + + let remaining_duration = self + .remaining_duration + .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) + .unwrap_or_default(); + + // Tick down + update.character = CharacterState::BasicAttack(Some(State { + remaining_duration, + exhausted, + })); + + // Check if attack duration has expired + if remaining_duration == Duration::default() { + update.character = CharacterState::Wielded(None); + ecs_data.updater.remove::(*ecs_data.entity); + } update } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 1abf09080a..d430afdec8 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -97,13 +97,9 @@ pub fn handle_jump(ecs_data: &EcsStateData, update: &mut StateUpdate) { pub fn handle_primary(ecs_data: &EcsStateData, update: &mut StateUpdate) { if let Some(state) = ecs_data.ability_pool.primary { - if ecs_data.inputs.primary.is_pressed() { - update.character = state; - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { - ecs_data.updater.insert(*ecs_data.entity, Attacking { - weapon: data, - time_active: Duration::default(), - }); + if let CharacterState::Wielded(_) = update.character { + if ecs_data.inputs.primary.is_pressed() { + update.character = state; } } } diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 63e8c7c303..d8d894a968 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -68,66 +68,56 @@ impl<'a> System<'a> for Sys { ) .join() { - attack.tick_time_active(Duration::from_secs_f32(dt.0)); + // Go through all other entities + for (b, uid_b, pos_b, ori_b, scale_b_maybe, character_b, stats_b, body_b) in ( + &entities, + &uids, + &positions, + &orientations, + scales.maybe(), + &character_states, + &stats, + &bodies, + ) + .join() + { + // 2D versions + let pos2 = Vec2::from(pos.0); + let pos_b2: Vec2 = Vec2::from(pos_b.0); + let ori2 = Vec2::from(ori.0); - if attack.can_apply_damage() { - // Go through all other entities - for (b, uid_b, pos_b, ori_b, scale_b_maybe, character_b, stats_b, body_b) in ( - &entities, - &uids, - &positions, - &orientations, - scales.maybe(), - &character_states, - &stats, - &bodies, - ) - .join() + // Scales + let scale = scale_maybe.map_or(1.0, |s| s.0); + let scale_b = scale_b_maybe.map_or(1.0, |s| s.0); + let rad_b = body_b.radius() * scale_b; + + // Check if it is a hit + if entity != b + && !stats_b.is_dead + // Spherical wedge shaped attack field + && pos.0.distance_squared(pos_b.0) < (rad_b + scale * ATTACK_RANGE).powi(2) + && ori2.angle_between(pos_b2 - pos2) < ATTACK_ANGLE.to_radians() / 2.0 + (rad_b / pos2.distance(pos_b2)).atan() { - // 2D versions - let pos2 = Vec2::from(pos.0); - let pos_b2: Vec2 = Vec2::from(pos_b.0); - let ori2 = Vec2::from(ori.0); + // Weapon gives base damage + let mut dmg = attack.weapon.base_damage as i32; - // Scales - let scale = scale_maybe.map_or(1.0, |s| s.0); - let scale_b = scale_b_maybe.map_or(1.0, |s| s.0); - let rad_b = body_b.radius() * scale_b; - - // Check if it is a hit - if entity != b - && !stats_b.is_dead - // Spherical wedge shaped attack field - && pos.0.distance_squared(pos_b.0) < (rad_b + scale * ATTACK_RANGE).powi(2) - && ori2.angle_between(pos_b2 - pos2) < ATTACK_ANGLE.to_radians() / 2.0 + (rad_b / pos2.distance(pos_b2)).atan() + // Block + if character_b.is_block() + && ori_b.0.angle_between(pos.0 - pos_b.0) < BLOCK_ANGLE.to_radians() / 2.0 { - // Weapon gives base damage - let mut dmg = attack.weapon.base_damage as i32; - - // Block - if character_b.is_block() - && ori_b.0.angle_between(pos.0 - pos_b.0) - < BLOCK_ANGLE.to_radians() / 2.0 - { - dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as i32 - } - - server_bus.emitter().emit(ServerEvent::Damage { - uid: *uid_b, - change: HealthChange { - amount: -dmg, - cause: HealthSource::Attack { by: *uid }, - }, - }); + dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as i32 } - } - } - if attack.remaining_duration() == Duration::default() { - if let Some(character) = character_states.get_mut(entity) { - *character = CharacterState::Wielded(None); + server_bus.emitter().emit(ServerEvent::Damage { + uid: *uid_b, + change: HealthChange { + amount: -dmg, + cause: HealthSource::Attack { by: *uid }, + }, + }); } } } + attacking_storage.clear(); } } From 2fa902270ea4ce97ff7db3117b65fcf5a5119e9b Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 24 Feb 2020 15:35:07 +0100 Subject: [PATCH 038/326] fix: block --- common/src/comp/ability.rs | 6 ++--- common/src/comp/character_state.rs | 12 +++++----- common/src/states/basic_block.rs | 36 ++++++++---------------------- common/src/states/mod.rs | 1 + common/src/states/utils.rs | 10 +++++++++ common/src/states/wielded.rs | 10 +++++---- voxygen/src/scene/figure/cache.rs | 6 ++--- voxygen/src/scene/figure/mod.rs | 7 +++--- voxygen/src/session.rs | 14 +----------- 9 files changed, 42 insertions(+), 60 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index f944b05b8d..39be87db17 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -10,9 +10,7 @@ pub enum AbilityActionKind { // UpdatePool? } impl Default for AbilityActionKind { - fn default() -> Self { - Self::Primary - } + fn default() -> Self { Self::Primary } } #[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct AbilityAction(pub AbilityActionKind); @@ -33,7 +31,7 @@ impl Default for AbilityPool { fn default() -> Self { Self { primary: Some(comp::CharacterState::BasicAttack(None)), - secondary: None, + secondary: Some(comp::CharacterState::BasicBlock(None)), block: None, dodge: Some(comp::CharacterState::Roll(None)), } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 417e49b042..6cd5178a20 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -43,7 +43,7 @@ pub enum CharacterState { Wielded(Option), Glide(Option), BasicAttack(Option), - //BasicBlock(Option), + BasicBlock(Option), //Charge(Option), Roll(Option), } @@ -58,7 +58,7 @@ impl CharacterState { pub fn is_block(&self) -> bool { match self { - //CharacterState::BasicBlock(_) => true, + CharacterState::BasicBlock(_) => true, _ => false, } } @@ -102,12 +102,12 @@ impl CharacterState { CharacterState::BasicAttack(opt_state) => opt_state .unwrap_or_else(|| basic_attack::State::new(ecs_data)) .handle(ecs_data), - /*CharacterState::Charge(opt_state) => opt_state - .unwrap_or_else(|| charge_attack::State::new(ecs_data)) - .handle(ecs_data), CharacterState::BasicBlock(opt_state) => opt_state .unwrap_or_else(|| basic_block::State::new(ecs_data)) - .handle(ecs_data),*/ + .handle(ecs_data), + /*CharacterState::Charge(opt_state) => opt_state + .unwrap_or_else(|| charge_attack::State::new(ecs_data)) + .handle(ecs_data),*/ CharacterState::Roll(opt_state) => opt_state .unwrap_or_else(|| roll::State::new(ecs_data)) .handle(ecs_data), diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index 4952691d72..e3ee63f18f 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -1,24 +1,19 @@ use super::utils::*; -use crate::comp::{EcsStateData, StateUpdate}; -use crate::states::StateHandler; -use std::time::Duration; +use crate::{ + comp::{EcsStateData, StateUpdate}, + states::StateHandler, +}; +use std::{collections::VecDeque, time::Duration}; use vek::Vec2; const BLOCK_ACCEL: f32 = 30.0; const BLOCK_SPEED: f32 = 75.0; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State { - /// How long the blocking state has been active - pub active_duration: Duration, -} +pub struct State {} impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { - Self { - active_duration: Duration::default(), - } - } + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { @@ -26,23 +21,10 @@ impl StateHandler for State { vel: *ecs_data.vel, ori: *ecs_data.ori, character: *ecs_data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; - // TODO: Apply simple move speed debuff instead - - // Update movement - update.vel.0 += Vec2::broadcast(ecs_data.dt.0) - * ecs_data.inputs.move_dir - * match ecs_data.physics.on_ground { - true if update.vel.0.magnitude_squared() < BLOCK_SPEED.powf(2.0) => BLOCK_ACCEL, - _ => 0.0, - }; - - if !ecs_data.inputs.secondary.is_pressed() { - update.character.action_state = attempt_wield(ecs_data.stats); - return update; - } - update } } diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index e917b855b1..016362d5be 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -1,5 +1,6 @@ // Module declarations pub mod basic_attack; +pub mod basic_block; pub mod climb; pub mod glide; pub mod idle; diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index d430afdec8..5527365e20 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -105,6 +105,16 @@ pub fn handle_primary(ecs_data: &EcsStateData, update: &mut StateUpdate) { } } +pub fn handle_secondary(ecs_data: &EcsStateData, update: &mut StateUpdate) { + if let Some(state) = ecs_data.ability_pool.secondary { + if let CharacterState::Wielded(_) = update.character { + if ecs_data.inputs.secondary.is_pressed() { + update.character = state; + } + } + } +} + pub fn handle_dodge(ecs_data: &EcsStateData, update: &mut StateUpdate) { if let Some(state) = ecs_data.ability_pool.dodge { if let CharacterState::Idle(_) | CharacterState::Wielded(_) = update.character { diff --git a/common/src/states/wielded.rs b/common/src/states/wielded.rs index e70b0c0c34..73d09ca2ec 100644 --- a/common/src/states/wielded.rs +++ b/common/src/states/wielded.rs @@ -1,8 +1,9 @@ use super::utils::*; -use crate::comp::{EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; -use crate::states::StateHandler; -use std::collections::VecDeque; -use std::time::Duration; +use crate::{ + comp::{EcsStateData, ItemKind::Tool, StateUpdate, ToolData}, + states::StateHandler, +}; +use std::{collections::VecDeque, time::Duration}; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State { @@ -41,6 +42,7 @@ impl StateHandler for State { handle_glide(&ecs_data, &mut update); handle_unwield(&ecs_data, &mut update); handle_primary(&ecs_data, &mut update); + handle_secondary(&ecs_data, &mut update); handle_dodge(&ecs_data, &mut update); update diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 9c06759809..3290c3fc23 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -170,9 +170,9 @@ impl FigureModelCache { if camera_mode != CameraMode::FirstPerson || character_state .map(|cs| match cs { - //CharacterState::BasicAttack(_) // TODO: enable - //| CharacterState::BasicBlock(_) - CharacterState::Wielding(_) + CharacterState::BasicAttack(_) + | CharacterState::BasicBlock(_) + | CharacterState::Wielding(_) | CharacterState::Wielded(_) => true, _ => false, }) diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 22cc8322af..4313677564 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -457,15 +457,16 @@ impl FigureMgr { skeleton_attr, ) }, - /*CharacterState::Block(_) => { + CharacterState::BasicBlock(_) => { anim::character::BlockIdleAnimation::update_skeleton( - &target_base, + &CharacterSkeleton::new(), (active_tool_kind, time), state.state_time, &mut state_animation_rate, skeleton_attr, ) - } + }, + /* CharacterState::Charge(_) => { anim::character::ChargeAnimation::update_skeleton( &target_base, diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 353f64f873..508b8cbe6a 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -220,20 +220,8 @@ impl PlayState for SessionState { if let Some(select_pos) = select_pos { client.remove_block(select_pos); } - } else if client - .state() - .read_storage::() - .get(client.entity()) - .map(|cs| match cs { - /*ActionState::Attack(_) // TODO: uncomment - | ActionState::Block(_) - | ActionState::Wield(_) => true,*/ - _ => false, - }) - .unwrap_or(false) - { - self.inputs.secondary.set_state(state); } else { + self.inputs.secondary.set_state(state); if let Some(select_pos) = select_pos { client.collect_block(select_pos); } From 31f3aae75c18efd61dfc84eb626ef6e682e0c471 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 24 Feb 2020 19:17:16 +0100 Subject: [PATCH 039/326] fix: make climbing cost stamina --- assets/common/items/debug/boost.ron | 12 ++++++++---- assets/common/items/debug/possess.ron | 12 ++++++++---- common/src/comp/character_state.rs | 8 ++++++-- common/src/comp/energy.rs | 1 + common/src/states/basic_attack.rs | 1 + common/src/states/basic_block.rs | 1 + common/src/states/climb.rs | 23 +++++++++++++++-------- common/src/states/glide.rs | 11 ++++++----- common/src/states/idle.rs | 5 ++--- common/src/states/roll.rs | 10 ++++++---- common/src/states/sit.rs | 11 ++++++----- common/src/states/wielded.rs | 1 + common/src/states/wielding.rs | 10 ++++++---- common/src/sys/character_state.rs | 18 +++++++++++++----- common/src/sys/phys.rs | 2 +- 15 files changed, 81 insertions(+), 45 deletions(-) diff --git a/assets/common/items/debug/boost.ron b/assets/common/items/debug/boost.ron index c32d38c69a..6ff45a1d78 100644 --- a/assets/common/items/debug/boost.ron +++ b/assets/common/items/debug/boost.ron @@ -2,10 +2,14 @@ Item( name: "Weightless Rod", description: "The sky is the limit.", kind: Tool( - kind: Debug(Boost), - equip_time_millis: 0, - attack_buildup_millis: 0, - attack_recover_millis: 0, + ToolData ( + kind: Debug(Boost), + equip_time_millis: 0, + attack_buildup_millis: 0, + attack_recover_millis: 0, + range: 0, + base_damage: 0, + ) ), ) // And the ground is pretty hard at maximum velocity... diff --git a/assets/common/items/debug/possess.ron b/assets/common/items/debug/possess.ron index e568ece69b..4d223e4506 100644 --- a/assets/common/items/debug/possess.ron +++ b/assets/common/items/debug/possess.ron @@ -2,10 +2,14 @@ Item( name: "Rod of Possession", description: "It's fixed on my branch.", kind: Tool( - kind: Debug(Possess), - equip_time_millis: 0, - attack_buildup_millis: 0, - attack_recover_millis: 0, + ToolData ( + kind: Debug(Possess), + equip_time_millis: 0, + attack_buildup_millis: 0, + attack_recover_millis: 0, + range: 3, + base_damage: 10, + ) ), ) // ... as zesterer always uses to tell us. diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 6cd5178a20..8f6c95c028 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,5 +1,7 @@ use crate::{ - comp::{AbilityPool, Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, ToolData, Vel}, + comp::{ + AbilityPool, Body, ControllerInputs, Energy, Ori, PhysicsState, Pos, Stats, ToolData, Vel, + }, event::{LocalEvent, ServerEvent}, state::DeltaTime, states::*, @@ -7,7 +9,7 @@ use crate::{ }; use serde::{Deserialize, Serialize}; use specs::{Component, Entity, FlaggedStorage, HashMapStorage, LazyUpdate, VecStorage}; -use std::{collections::VecDeque, time::Duration}; +use std::collections::VecDeque; pub struct EcsStateData<'a> { pub entity: &'a Entity, @@ -19,6 +21,7 @@ pub struct EcsStateData<'a> { pub dt: &'a DeltaTime, pub inputs: &'a ControllerInputs, pub stats: &'a Stats, + pub energy: &'a Energy, pub body: &'a Body, pub physics: &'a PhysicsState, pub ability_pool: &'a AbilityPool, @@ -30,6 +33,7 @@ pub struct StateUpdate { pub pos: Pos, pub vel: Vel, pub ori: Ori, + pub energy: Energy, pub local_events: VecDeque, pub server_events: VecDeque, } diff --git a/common/src/comp/energy.rs b/common/src/comp/energy.rs index 8cf2d9224e..e53fbe5a48 100644 --- a/common/src/comp/energy.rs +++ b/common/src/comp/energy.rs @@ -15,6 +15,7 @@ pub enum EnergySource { LevelUp, Regen, Revive, + Climb, Unknown, } diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index 91eaabc790..d633d988d8 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -31,6 +31,7 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + energy: *ecs_data.energy, character: *ecs_data.character, local_events: VecDeque::new(), server_events: VecDeque::new(), diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index e3ee63f18f..fb91ce76a0 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -20,6 +20,7 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + energy: *ecs_data.energy, character: *ecs_data.character, local_events: VecDeque::new(), server_events: VecDeque::new(), diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index a105a30323..8c73c9b31b 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -1,9 +1,13 @@ -use crate::comp::{CharacterState, EcsStateData, StateUpdate}; -use crate::states::StateHandler; -use crate::sys::phys::GRAVITY; +use crate::{ + comp::{CharacterState, EcsStateData, EnergySource, StateUpdate}, + states::StateHandler, + sys::phys::GRAVITY, +}; use std::collections::VecDeque; -use vek::vec::{Vec2, Vec3}; -use vek::Lerp; +use vek::{ + vec::{Vec2, Vec3}, + Lerp, +}; const HUMANOID_CLIMB_ACCEL: f32 = 5.0; const CLIMB_SPEED: f32 = 5.0; @@ -12,9 +16,7 @@ const CLIMB_SPEED: f32 = 5.0; pub struct State; impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { - Self {} - } + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { @@ -22,10 +24,15 @@ impl StateHandler for State { vel: *ecs_data.vel, ori: *ecs_data.ori, character: *ecs_data.character, + energy: *ecs_data.energy, local_events: VecDeque::new(), server_events: VecDeque::new(), }; + if let Err(_) = update.energy.try_change_by(-5, EnergySource::Climb) { + update.character = CharacterState::Idle(None); + } + // If no wall is in front of character ... if ecs_data.physics.on_wall.is_none() || ecs_data.physics.on_ground { if ecs_data.inputs.jump.is_pressed() { diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 87048bb068..ba0d4f8bea 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,5 +1,7 @@ -use crate::comp::{CharacterState, EcsStateData, StateUpdate}; -use crate::states::StateHandler; +use crate::{ + comp::{CharacterState, EcsStateData, StateUpdate}, + states::StateHandler, +}; use std::collections::VecDeque; use vek::{Vec2, Vec3}; @@ -12,15 +14,14 @@ const GLIDE_SPEED: f32 = 45.0; pub struct State; impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { - Self {} - } + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + energy: *ecs_data.energy, character: *ecs_data.character, local_events: VecDeque::new(), server_events: VecDeque::new(), diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index f9934be701..b07456e891 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -7,9 +7,7 @@ use crate::states::StateHandler; pub struct State; impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { - Self {} - } + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { @@ -17,6 +15,7 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + energy: *ecs_data.energy, local_events: VecDeque::new(), server_events: VecDeque::new(), }; diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index f1596f8189..14223b0e10 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,7 +1,8 @@ -use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; -use crate::states::StateHandler; -use std::collections::VecDeque; -use std::time::Duration; +use crate::{ + comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}, + states::StateHandler, +}; +use std::{collections::VecDeque, time::Duration}; use vek::Vec3; const ROLL_SPEED: f32 = 17.0; @@ -31,6 +32,7 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + energy: *ecs_data.energy, local_events: VecDeque::new(), server_events: VecDeque::new(), }; diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index 34e3f44150..1da5fb6df3 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -1,15 +1,15 @@ use super::utils::*; -use crate::comp::{CharacterState, EcsStateData, StateUpdate}; -use crate::states::StateHandler; +use crate::{ + comp::{CharacterState, EcsStateData, StateUpdate}, + states::StateHandler, +}; use std::collections::VecDeque; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { - Self {} - } + fn new(_ecs_data: &EcsStateData) -> Self { Self {} } fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { let mut update = StateUpdate { @@ -17,6 +17,7 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + energy: *ecs_data.energy, local_events: VecDeque::new(), server_events: VecDeque::new(), }; diff --git a/common/src/states/wielded.rs b/common/src/states/wielded.rs index 73d09ca2ec..545a38dca6 100644 --- a/common/src/states/wielded.rs +++ b/common/src/states/wielded.rs @@ -31,6 +31,7 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + energy: *ecs_data.energy, local_events: VecDeque::new(), server_events: VecDeque::new(), }; diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index d2e3bd289e..e3271ee958 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -1,8 +1,9 @@ use super::utils::*; -use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; -use crate::states::StateHandler; -use std::collections::VecDeque; -use std::time::Duration; +use crate::{ + comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}, + states::StateHandler, +}; +use std::{collections::VecDeque, time::Duration}; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State { @@ -31,6 +32,7 @@ impl StateHandler for State { pos: *ecs_data.pos, vel: *ecs_data.vel, ori: *ecs_data.ori, + energy: *ecs_data.energy, local_events: VecDeque::new(), server_events: VecDeque::new(), }; diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index 4d44334320..a87a7b92ab 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - AbilityPool, Body, CharacterState, Controller, EcsStateData, Mounting, Ori, PhysicsState, - Pos, Stats, Vel, + AbilityPool, Body, CharacterState, Controller, EcsStateData, Energy, Mounting, Ori, + PhysicsState, Pos, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -11,10 +11,11 @@ use crate::{ use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; /// ## Character State System -/// #### Calls updates to `CharacterState`s. Acts on tuples of ( `CharacterState`, `Pos`, `Vel`, and `Ori` ). +/// #### Calls updates to `CharacterState`s. Acts on tuples of ( +/// `CharacterState`, `Pos`, `Vel`, and `Ori` ). /// -/// _System forms `EcsStateData` tuples and passes those to `ActionState` `update()` fn, -/// then does the same for `MoveState` `update`_ +/// _System forms `EcsStateData` tuples and passes those to `ActionState` +/// `update()` fn, then does the same for `MoveState` `update`_ pub struct Sys; impl<'a> System<'a> for Sys { @@ -29,6 +30,7 @@ impl<'a> System<'a> for Sys { WriteStorage<'a, Pos>, WriteStorage<'a, Vel>, WriteStorage<'a, Ori>, + WriteStorage<'a, Energy>, ReadStorage<'a, Controller>, ReadStorage<'a, Stats>, ReadStorage<'a, Body>, @@ -37,6 +39,7 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, ); + fn run( &mut self, ( @@ -50,6 +53,7 @@ impl<'a> System<'a> for Sys { mut positions, mut velocities, mut orientations, + mut energies, controllers, stats, bodies, @@ -66,6 +70,7 @@ impl<'a> System<'a> for Sys { pos, vel, ori, + energy, controller, stats, body, @@ -78,6 +83,7 @@ impl<'a> System<'a> for Sys { &mut positions, &mut velocities, &mut orientations, + &mut energies, &controllers, &stats, &bodies, @@ -113,6 +119,7 @@ impl<'a> System<'a> for Sys { pos, vel, ori, + energy, dt: &dt, inputs, stats, @@ -126,6 +133,7 @@ impl<'a> System<'a> for Sys { *pos = state_update.pos; *vel = state_update.vel; *ori = state_update.ori; + *energy = state_update.energy; local_bus.emitter().append(&mut state_update.local_events); server_bus.emitter().append(&mut state_update.server_events); } diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index d57f0af012..8df26f2390 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -9,7 +9,7 @@ use crate::{ use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage}; use vek::*; -pub const GRAVITY: f32 = 9.81 * 7.0; +pub const GRAVITY: f32 = 9.81 * 10.0; const BOUYANCY: f32 = 0.0; // Friction values used for linear damping. They are unitless quantities. The // value of these quantities must be between zero and one. They represent the From ac611f46185aa52336792299f8b10560f02d9a18 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 24 Feb 2020 20:57:33 +0100 Subject: [PATCH 040/326] fix: sync characterstates, better energy management --- common/src/comp/character_state.rs | 9 +++++++ common/src/comp/energy.rs | 1 + common/src/msg/ecs_packet.rs | 7 ++++++ common/src/states/basic_attack.rs | 2 +- common/src/states/basic_block.rs | 8 +++++- common/src/states/roll.rs | 10 ++++++++ common/src/states/utils.rs | 13 +++++++--- common/src/sys/stats.rs | 8 +++--- server/src/sys/sentinel.rs | 21 ++++++++++++++-- .../src/audio/sfx/event_mapper/movement.rs | 25 ++++++++----------- 10 files changed, 79 insertions(+), 25 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 8f6c95c028..c3801b7889 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -53,6 +53,15 @@ pub enum CharacterState { } impl CharacterState { + pub fn is_wielded(&self) -> bool { + match self { + CharacterState::Wielded(_) => true, + CharacterState::BasicAttack(_) => true, + CharacterState::BasicBlock(_) => true, + _ => false, + } + } + pub fn is_attack(&self) -> bool { match self { CharacterState::BasicAttack(_) => true, diff --git a/common/src/comp/energy.rs b/common/src/comp/energy.rs index e53fbe5a48..0c74f20304 100644 --- a/common/src/comp/energy.rs +++ b/common/src/comp/energy.rs @@ -16,6 +16,7 @@ pub enum EnergySource { Regen, Revive, Climb, + Roll, Unknown, } diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index 57496dda0f..cd62d556e5 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -24,6 +24,7 @@ sum_type! { AbilityAction(comp::AbilityAction), AbilityPool(comp::AbilityPool), Attacking(comp::Attacking), + CharacterState(comp::CharacterState), } } // Automatically derive From for EcsCompPhantom @@ -47,6 +48,7 @@ sum_type! { AbilityAction(PhantomData), AbilityPool(PhantomData), Attacking(PhantomData), + CharacterState(PhantomData), } } impl sync::CompPacket for EcsCompPacket { @@ -70,6 +72,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::AbilityAction(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::AbilityPool(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Attacking(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::CharacterState(comp) => sync::handle_insert(comp, entity, world), } } @@ -91,6 +94,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::AbilityAction(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::AbilityPool(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Attacking(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::CharacterState(comp) => sync::handle_modify(comp, entity, world), } } @@ -118,6 +122,9 @@ impl sync::CompPacket for EcsCompPacket { sync::handle_remove::(entity, world) }, EcsCompPhantom::Attacking(_) => sync::handle_remove::(entity, world), + EcsCompPhantom::CharacterState(_) => { + sync::handle_remove::(entity, world) + }, } } } diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index d633d988d8..f142bc7e13 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -1,6 +1,6 @@ use crate::{ comp::{Attacking, CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}, - states::{utils, StateHandler}, + states::StateHandler, }; use std::{collections::VecDeque, time::Duration}; diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index fb91ce76a0..18d7dd1ce2 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -1,6 +1,6 @@ use super::utils::*; use crate::{ - comp::{EcsStateData, StateUpdate}, + comp::{CharacterState, EcsStateData, StateUpdate}, states::StateHandler, }; use std::{collections::VecDeque, time::Duration}; @@ -26,6 +26,12 @@ impl StateHandler for State { server_events: VecDeque::new(), }; + handle_move_dir(&ecs_data, &mut update); + + if !ecs_data.physics.on_ground || !ecs_data.inputs.secondary.is_pressed() { + update.character = CharacterState::Wielded(None); + } + update } } diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 14223b0e10..be3944ba13 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -50,6 +50,16 @@ impl StateHandler for State { .unwrap_or_default() * ROLL_SPEED; + // Smooth orientation + if update.vel.0.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(update.vel.0).normalized()) + .magnitude_squared() + > 0.001 + { + update.ori.0 = + vek::ops::Slerp::slerp(update.ori.0, update.vel.0.into(), 9.0 * ecs_data.dt.0); + } + if self.remaining_duration == Duration::default() { // Roll duration has expired update.character = CharacterState::Idle(None); diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 5527365e20..d6b8d7338f 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{Attacking, CharacterState, EcsStateData, ItemKind::Tool, StateUpdate}, + comp::{Attacking, CharacterState, EcsStateData, EnergySource, ItemKind::Tool, StateUpdate}, event::LocalEvent, }; use std::time::Duration; @@ -27,7 +27,10 @@ pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) { } // Set direction based on move direction - let ori_dir = if update.character.is_attack() || update.character.is_block() { + let ori_dir = if update.character.is_wielded() + || update.character.is_attack() + || update.character.is_block() + { Vec2::from(ecs_data.inputs.look_dir).normalized() } else { Vec2::from(update.vel.0) @@ -58,7 +61,7 @@ pub fn handle_sit(ecs_data: &EcsStateData, update: &mut StateUpdate) { } pub fn handle_climb(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if (ecs_data.inputs.climb.is_just_pressed() || ecs_data.inputs.climb_down.is_pressed()) + if (ecs_data.inputs.climb.is_pressed() || ecs_data.inputs.climb_down.is_pressed()) && ecs_data.physics.on_wall.is_some() && !ecs_data.physics.on_ground //&& update.vel.0.z < 0.0 @@ -121,6 +124,10 @@ pub fn handle_dodge(ecs_data: &EcsStateData, update: &mut StateUpdate) { if ecs_data.inputs.roll.is_pressed() && ecs_data.physics.on_ground && ecs_data.body.is_humanoid() + && update + .energy + .try_change_by(-200, EnergySource::Roll) + .is_ok() { update.character = state; } diff --git a/common/src/sys/stats.rs b/common/src/sys/stats.rs index 19e8182c09..548b636bda 100644 --- a/common/src/sys/stats.rs +++ b/common/src/sys/stats.rs @@ -5,7 +5,7 @@ use crate::{ }; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; -const ENERGY_REGEN_ACCEL: f32 = 20.0; +const ENERGY_REGEN_ACCEL: f32 = 10.0; /// This system kills players, levels them up, and regenerates energy. pub struct Sys; @@ -87,15 +87,17 @@ impl<'a> System<'a> for Sys { as i32, EnergySource::Regen, ); - energy.regen_rate += ENERGY_REGEN_ACCEL * dt.0; + energy.regen_rate = + (energy.regen_rate + ENERGY_REGEN_ACCEL * dt.0).min(100.0); } }, // All other states do not regen and set the rate back to zero. - _ => { + CharacterState::Wielded(_) => { if energy.get_unchecked().regen_rate != 0.0 { energy.get_mut_unchecked().regen_rate = 0.0 } }, + _ => {}, } } } diff --git a/server/src/sys/sentinel.rs b/server/src/sys/sentinel.rs index 9363dcfc59..f48f8a9f59 100644 --- a/server/src/sys/sentinel.rs +++ b/server/src/sys/sentinel.rs @@ -1,8 +1,8 @@ use super::SysTimer; use common::{ comp::{ - AbilityPool, Body, CanBuild, Energy, Gravity, Item, LightEmitter, Mass, MountState, - Mounting, Player, Scale, Stats, Sticky, + AbilityPool, Body, CanBuild, CharacterState, Energy, Gravity, Item, LightEmitter, Mass, + MountState, Mounting, Player, Scale, Stats, Sticky, }, msg::EcsCompPacket, sync::{EntityPackage, SyncPackage, Uid, UpdateTracker, WorldSyncExt}, @@ -52,6 +52,7 @@ pub struct TrackedComps<'a> { pub sticky: ReadStorage<'a, Sticky>, pub gravity: ReadStorage<'a, Gravity>, pub ability_pool: ReadStorage<'a, AbilityPool>, + pub character_state: ReadStorage<'a, CharacterState>, } impl<'a> TrackedComps<'a> { pub fn create_entity_package(&self, entity: EcsEntity) -> EntityPackage { @@ -109,6 +110,10 @@ impl<'a> TrackedComps<'a> { .get(entity) .copied() .map(|c| comps.push(c.into())); + self.character_state + .get(entity) + .copied() + .map(|c| comps.push(c.into())); EntityPackage { uid, comps } } @@ -130,6 +135,7 @@ pub struct ReadTrackers<'a> { pub sticky: ReadExpect<'a, UpdateTracker>, pub gravity: ReadExpect<'a, UpdateTracker>, pub ability_pool: ReadExpect<'a, UpdateTracker>, + pub character_state: ReadExpect<'a, UpdateTracker>, } impl<'a> ReadTrackers<'a> { pub fn create_sync_package( @@ -158,6 +164,12 @@ impl<'a> ReadTrackers<'a> { .with_component(&comps.uid, &*self.sticky, &comps.sticky, filter) .with_component(&comps.uid, &*self.gravity, &comps.gravity, filter) .with_component(&comps.uid, &*self.ability_pool, &comps.ability_pool, filter) + .with_component( + &comps.uid, + &*self.character_state, + &comps.character_state, + filter, + ) } } @@ -178,6 +190,7 @@ pub struct WriteTrackers<'a> { sticky: WriteExpect<'a, UpdateTracker>, gravity: WriteExpect<'a, UpdateTracker>, ability_pool: WriteExpect<'a, UpdateTracker>, + character_state: WriteExpect<'a, UpdateTracker>, } fn record_changes(comps: &TrackedComps, trackers: &mut WriteTrackers) { @@ -197,6 +210,9 @@ fn record_changes(comps: &TrackedComps, trackers: &mut WriteTrackers) { trackers.sticky.record_changes(&comps.sticky); trackers.gravity.record_changes(&comps.gravity); trackers.ability_pool.record_changes(&comps.ability_pool); + trackers + .character_state + .record_changes(&comps.character_state); } pub fn register_trackers(world: &mut World) { @@ -215,6 +231,7 @@ pub fn register_trackers(world: &mut World) { world.register_tracker::(); world.register_tracker::(); world.register_tracker::(); + world.register_tracker::(); } /// Deleted entities grouped by region diff --git a/voxygen/src/audio/sfx/event_mapper/movement.rs b/voxygen/src/audio/sfx/event_mapper/movement.rs index 559e036aa4..00e80b6815 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement.rs @@ -124,28 +124,23 @@ impl MovementEventMapper { } } - /// Voxygen has an existing list of character states via `MoveState::*` and - /// `ActionState::*` however that list does not provide enough - /// resolution to target specific entity events, such as opening or - /// closing the glider. These methods translate those entity states with - /// some additional data into more specific `SfxEvent`'s which we attach - /// sounds to + /// Voxygen has an existing list of character states however that list does + /// not provide enough resolution to target specific entity events, such + /// as opening or closing the glider. These methods translate those + /// entity states with some additional data into more specific + /// `SfxEvent`'s which we attach sounds to fn map_movement_event(current_event: &CharacterState, previous_event: SfxEvent) -> SfxEvent { - match (current_event, previous_event) { - (CharacterState::Roll(_), _) => SfxEvent::Roll, - (CharacterState::Climb(_), _) => SfxEvent::Climb, - (CharacterState::Idle(_), _) => SfxEvent::Run, - (CharacterState::Idle(_), SfxEvent::Glide) => SfxEvent::GliderClose, - (CharacterState::Idle(_), SfxEvent::Fall) => SfxEvent::Run, - (CharacterState::Idle(_), SfxEvent::Jump) => SfxEvent::Idle, - (CharacterState::Glide(_), previous_event) => { + match (previous_event, current_event) { + (_, CharacterState::Roll(_)) => SfxEvent::Roll, + (_, CharacterState::Climb(_)) => SfxEvent::Climb, + (SfxEvent::Glide, CharacterState::Idle(_)) => SfxEvent::GliderClose, + (previous_event, CharacterState::Glide(_)) => { if previous_event != SfxEvent::GliderOpen && previous_event != SfxEvent::Glide { SfxEvent::GliderOpen } else { SfxEvent::Glide } }, - (CharacterState::Idle(_), SfxEvent::Glide) => SfxEvent::GliderClose, _ => SfxEvent::Idle, } } From 4cc998f92bad364238cfb56f935bac4f98d464d6 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 24 Feb 2020 22:20:50 +0100 Subject: [PATCH 041/326] fix: non-humanoid npcs can attack again --- common/src/comp/character_state.rs | 2 +- common/src/states/basic_attack.rs | 18 +++++++++++------- common/src/states/utils.rs | 4 +--- common/src/states/wielding.rs | 10 ++++------ common/src/sys/combat.rs | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index c3801b7889..589eeaeca0 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -143,7 +143,7 @@ impl Component for CharacterState { #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Attacking { - pub weapon: ToolData, + pub weapon: Option, } impl Component for Attacking { diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index f142bc7e13..1574abed2e 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -14,14 +14,14 @@ pub struct State { impl StateHandler for State { fn new(ecs_data: &EcsStateData) -> Self { - let tool_data = + let remaining_duration = if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { - data + data.attack_duration() } else { - ToolData::default() + Duration::from_millis(300) }; Self { - remaining_duration: tool_data.attack_duration(), + remaining_duration, exhausted: false, } } @@ -43,7 +43,7 @@ impl StateHandler for State { && if let Some(Tool(data)) = tool_kind { (self.remaining_duration < data.attack_recover_duration()) } else { - false + true }; let mut exhausted = self.exhausted; @@ -52,9 +52,13 @@ impl StateHandler for State { if let Some(Tool(data)) = tool_kind { ecs_data .updater - .insert(*ecs_data.entity, Attacking { weapon: data }); - exhausted = true; + .insert(*ecs_data.entity, Attacking { weapon: Some(data) }); + } else { + ecs_data + .updater + .insert(*ecs_data.entity, Attacking { weapon: None }); } + exhausted = true; } else { ecs_data.updater.remove::(*ecs_data.entity); } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 861d2c2d07..14294a3631 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -47,9 +47,7 @@ pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) { pub fn handle_wield(ecs_data: &EcsStateData, update: &mut StateUpdate) { if ecs_data.inputs.primary.is_pressed() { - if let Some(Tool(_)) = ecs_data.stats.equipment.main.as_ref().map(|i| &i.kind) { - update.character = CharacterState::Wielding(None); - } + update.character = CharacterState::Wielding(None); } } diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index e3271ee958..58da3c22b0 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -14,16 +14,14 @@ pub struct State { impl StateHandler for State { fn new(ecs_data: &EcsStateData) -> Self { - let tool_data = + let equip_delay = if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { - data + data.equip_time() } else { - ToolData::default() + Duration::default() }; - Self { - equip_delay: tool_data.equip_time(), - } + Self { equip_delay } } fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index d8d894a968..0024e639a5 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -99,7 +99,7 @@ impl<'a> System<'a> for Sys { && ori2.angle_between(pos_b2 - pos2) < ATTACK_ANGLE.to_radians() / 2.0 + (rad_b / pos2.distance(pos_b2)).atan() { // Weapon gives base damage - let mut dmg = attack.weapon.base_damage as i32; + let mut dmg = attack.weapon.map(|w| w.base_damage as i32).unwrap_or(3); // Block if character_b.is_block() From d6f72876e91439c1969b56103f9a2d20900c4736 Mon Sep 17 00:00:00 2001 From: Shane Handley Date: Tue, 25 Feb 2020 10:01:41 +0900 Subject: [PATCH 042/326] Fix tests for movement sfx. --- .../audio/sfx/event_mapper/movement/tests.rs | 419 +++++++++--------- 1 file changed, 198 insertions(+), 221 deletions(-) diff --git a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs index 251efba8a5..9e147467bc 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs @@ -2,8 +2,8 @@ use super::*; use common::{ assets, comp::{ - bird_small, humanoid, item::Tool, quadruped_medium, quadruped_small, ActionState, Body, - MovementState, Stats, + bird_small, humanoid, item::ToolKind, quadruped_medium, quadruped_small, Body, + CharacterState, Stats, }, event::SfxEvent, }; @@ -94,10 +94,7 @@ fn maps_idle() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Stand, - action: ActionState::Idle, - }, + &CharacterState::Idle(None), &LastSfxEvent { event: SfxEvent::Idle, weapon_drawn: false, @@ -110,55 +107,55 @@ fn maps_idle() { assert_eq!(result, SfxEvent::Idle); } -#[test] -fn maps_run_with_sufficient_velocity() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); +// #[test] +// fn maps_run_with_sufficient_velocity() { +// let stats = Stats::new( +// String::from("test"), +// Body::Humanoid(humanoid::Body::random()), +// None, +// ); - let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Run, - action: ActionState::Idle, - }, - &LastSfxEvent { - event: SfxEvent::Idle, - weapon_drawn: false, - time: Instant::now(), - }, - Vec3::new(0.5, 0.8, 0.0), - &stats, - ); +// let result = MovementEventMapper::map_movement_event( +// &CharacterState { +// movement: MovementState::Run, +// action: ActionState::Idle, +// }, +// &LastSfxEvent { +// event: SfxEvent::Idle, +// weapon_drawn: false, +// time: Instant::now(), +// }, +// Vec3::new(0.5, 0.8, 0.0), +// &stats, +// ); - assert_eq!(result, SfxEvent::Run); -} +// assert_eq!(result, SfxEvent::Run); +// } -#[test] -fn does_not_map_run_with_insufficient_velocity() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); +// #[test] +// fn does_not_map_run_with_insufficient_velocity() { +// let stats = Stats::new( +// String::from("test"), +// Body::Humanoid(humanoid::Body::random()), +// None, +// ); - let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Run, - action: ActionState::Idle, - }, - &LastSfxEvent { - event: SfxEvent::Idle, - weapon_drawn: false, - time: Instant::now(), - }, - Vec3::new(0.02, 0.0001, 0.0), - &stats, - ); +// let result = MovementEventMapper::map_movement_event( +// &CharacterState { +// movement: MovementState::Run, +// action: ActionState::Idle, +// }, +// &LastSfxEvent { +// event: SfxEvent::Idle, +// weapon_drawn: false, +// time: Instant::now(), +// }, +// Vec3::new(0.02, 0.0001, 0.0), +// &stats, +// ); - assert_eq!(result, SfxEvent::Idle); -} +// assert_eq!(result, SfxEvent::Idle); +// } #[test] fn maps_roll() { @@ -169,13 +166,7 @@ fn maps_roll() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState { - action: ActionState::Roll { - time_left: Duration::new(1, 0), - was_wielding: false, - }, - movement: MovementState::Run, - }, + &CharacterState::Roll(None), &LastSfxEvent { event: SfxEvent::Run, weapon_drawn: false, @@ -188,55 +179,55 @@ fn maps_roll() { assert_eq!(result, SfxEvent::Roll); } -#[test] -fn maps_fall() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); +// #[test] +// fn maps_fall() { +// let stats = Stats::new( +// String::from("test"), +// Body::Humanoid(humanoid::Body::random()), +// None, +// ); - let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Fall, - action: ActionState::Idle, - }, - &LastSfxEvent { - event: SfxEvent::Fall, - weapon_drawn: false, - time: Instant::now(), - }, - Vec3::zero(), - &stats, - ); +// let result = MovementEventMapper::map_movement_event( +// &CharacterState { +// movement: MovementState::Fall, +// action: ActionState::Idle, +// }, +// &LastSfxEvent { +// event: SfxEvent::Fall, +// weapon_drawn: false, +// time: Instant::now(), +// }, +// Vec3::zero(), +// &stats, +// ); - assert_eq!(result, SfxEvent::Fall); -} +// assert_eq!(result, SfxEvent::Fall); +// } -#[test] -fn maps_land_on_ground_to_run() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); +// #[test] +// fn maps_land_on_ground_to_run() { +// let stats = Stats::new( +// String::from("test"), +// Body::Humanoid(humanoid::Body::random()), +// None, +// ); - let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Stand, - action: ActionState::Idle, - }, - &LastSfxEvent { - event: SfxEvent::Fall, - weapon_drawn: false, - time: Instant::now(), - }, - Vec3::zero(), - &stats, - ); +// let result = MovementEventMapper::map_movement_event( +// &CharacterState { +// movement: MovementState::Stand, +// action: ActionState::Idle, +// }, +// &LastSfxEvent { +// event: SfxEvent::Fall, +// weapon_drawn: false, +// time: Instant::now(), +// }, +// Vec3::zero(), +// &stats, +// ); - assert_eq!(result, SfxEvent::Run); -} +// assert_eq!(result, SfxEvent::Run); +// } #[test] fn maps_glider_open() { @@ -247,10 +238,7 @@ fn maps_glider_open() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Glide, - action: ActionState::Idle, - }, + &CharacterState::Glide(None), &LastSfxEvent { event: SfxEvent::Jump, weapon_drawn: false, @@ -272,10 +260,7 @@ fn maps_glide() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Glide, - action: ActionState::Idle, - }, + &CharacterState::Glide(None), &LastSfxEvent { event: SfxEvent::Glide, weapon_drawn: false, @@ -288,87 +273,58 @@ fn maps_glide() { assert_eq!(result, SfxEvent::Glide); } -#[test] -fn maps_glider_close_when_closing_mid_flight() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); +// #[test] +// fn maps_glider_close_when_closing_mid_flight() { +// let stats = Stats::new( +// String::from("test"), +// Body::Humanoid(humanoid::Body::random()), +// None, +// ); - let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Fall, - action: ActionState::Idle, - }, - &LastSfxEvent { - event: SfxEvent::Glide, - weapon_drawn: false, - time: Instant::now(), - }, - Vec3::zero(), - &stats, - ); +// let result = MovementEventMapper::map_movement_event( +// &CharacterState { +// movement: MovementState::Fall, +// action: ActionState::Idle, +// }, +// &LastSfxEvent { +// event: SfxEvent::Glide, +// weapon_drawn: false, +// time: Instant::now(), +// }, +// Vec3::zero(), +// &stats, +// ); - assert_eq!(result, SfxEvent::GliderClose); -} +// assert_eq!(result, SfxEvent::GliderClose); +// } -#[test] -fn maps_glider_close_when_landing() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); +// #[test] +// fn maps_glider_close_when_landing() { +// let stats = Stats::new( +// String::from("test"), +// Body::Humanoid(humanoid::Body::random()), +// None, +// ); - let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Stand, - action: ActionState::Idle, - }, - &LastSfxEvent { - event: SfxEvent::Glide, - weapon_drawn: false, - time: Instant::now(), - }, - Vec3::zero(), - &stats, - ); +// let result = MovementEventMapper::map_movement_event( +// &CharacterState { +// movement: MovementState::Stand, +// action: ActionState::Idle, +// }, +// &LastSfxEvent { +// event: SfxEvent::Glide, +// weapon_drawn: false, +// time: Instant::now(), +// }, +// Vec3::zero(), +// &stats, +// ); - assert_eq!(result, SfxEvent::GliderClose); -} +// assert_eq!(result, SfxEvent::GliderClose); +// } #[test] fn maps_wield() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - Some(assets::load_expect_cloned( - "common.items.weapons.starter_sword", - )), - ); - - let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Stand, - action: ActionState::Wield { - time_left: Duration::from_millis(800), - }, - }, - &LastSfxEvent { - event: SfxEvent::Idle, - weapon_drawn: false, - time: Instant::now(), - }, - Vec3::zero(), - &stats, - ); - - assert_eq!(result, SfxEvent::Wield(Tool::Sword)); -} - -#[test] -fn maps_unwield() { let stats = Stats::new( String::from("test"), Body::Humanoid(humanoid::Body::random()), @@ -378,10 +334,31 @@ fn maps_unwield() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Stand, - action: ActionState::Idle, + &CharacterState::BasicAttack(None), + &LastSfxEvent { + event: SfxEvent::Idle, + weapon_drawn: false, + time: Instant::now(), }, + Vec3::zero(), + &stats, + ); + + assert_eq!(result, SfxEvent::Wield(ToolKind::Axe)); +} + +#[test] +fn maps_unwield() { + let stats = Stats::new( + String::from("test"), + Body::Humanoid(humanoid::Body::random()), + Some(assets::load_expect_cloned( + "common.items.weapons.starter_bow", + )), + ); + + let result = MovementEventMapper::map_movement_event( + &CharacterState::default(), &LastSfxEvent { event: SfxEvent::Idle, weapon_drawn: true, @@ -391,48 +368,48 @@ fn maps_unwield() { &stats, ); - assert_eq!(result, SfxEvent::Unwield(Tool::Axe)); + assert_eq!(result, SfxEvent::Unwield(ToolKind::Bow)); } -#[test] -fn does_not_map_wield_when_no_main_weapon() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); +// #[test] +// fn does_not_map_wield_when_no_main_weapon() { +// let stats = Stats::new( +// String::from("test"), +// Body::Humanoid(humanoid::Body::random()), +// None, +// ); - let result = MovementEventMapper::map_movement_event( - &CharacterState { - movement: MovementState::Run, - action: ActionState::Wield { - time_left: Duration::from_millis(600), - }, - }, - &LastSfxEvent { - event: SfxEvent::Idle, - weapon_drawn: false, - time: Instant::now(), - }, - Vec3::new(0.5, 0.8, 0.0), - &stats, - ); +// let result = MovementEventMapper::map_movement_event( +// &CharacterState { +// movement: MovementState::Run, +// action: ActionState::Wield { +// time_left: Duration::from_millis(600), +// }, +// }, +// &LastSfxEvent { +// event: SfxEvent::Idle, +// weapon_drawn: false, +// time: Instant::now(), +// }, +// Vec3::new(0.5, 0.8, 0.0), +// &stats, +// ); - assert_eq!(result, SfxEvent::Run); -} +// assert_eq!(result, SfxEvent::Run); +// } -#[test] -fn maps_quadrupeds_running() { - let result = MovementEventMapper::map_non_humanoid_movement_event( - &CharacterState { - movement: MovementState::Run, - action: ActionState::Idle, - }, - Vec3::new(0.5, 0.8, 0.0), - ); +// #[test] +// fn maps_quadrupeds_running() { +// let result = MovementEventMapper::map_non_humanoid_movement_event( +// &CharacterState { +// movement: MovementState::Run, +// action: ActionState::Idle, +// }, +// Vec3::new(0.5, 0.8, 0.0), +// ); - assert_eq!(result, SfxEvent::Run); -} +// assert_eq!(result, SfxEvent::Run); +// } #[test] fn determines_relative_volumes() { From 0d2b26a3b85971af0e4d8567ba5327f9baf8f532 Mon Sep 17 00:00:00 2001 From: Shane Handley Date: Tue, 25 Feb 2020 22:00:48 +0900 Subject: [PATCH 043/326] SFX Fixes - Reinstate run, uncomment tests and make them pass, adjust config. --- assets/voxygen/audio/sfx.ron | 10 +- common/src/event.rs | 4 - .../audio/sfx/event_mapper/movement/mod.rs | 119 +++-- .../audio/sfx/event_mapper/movement/tests.rs | 475 ++++++++++-------- 4 files changed, 357 insertions(+), 251 deletions(-) diff --git a/assets/voxygen/audio/sfx.ron b/assets/voxygen/audio/sfx.ron index 38349f287e..53dbe54287 100644 --- a/assets/voxygen/audio/sfx.ron +++ b/assets/voxygen/audio/sfx.ron @@ -9,7 +9,7 @@ "voxygen.audio.sfx.footsteps.stepgrass_5", "voxygen.audio.sfx.footsteps.stepgrass_6", ], - threshold: 0.25, + threshold: 0.4, ), GliderOpen: ( files: [ @@ -23,17 +23,17 @@ ], threshold: 0.5, ), - Wield(Sword): ( + Wield(Sword(Rapier)): ( files: [ "voxygen.audio.sfx.weapon.sword_out", ], - threshold: 0.5, + threshold: 1.0, ), - Unwield(Sword): ( + Unwield(Sword(Rapier)): ( files: [ "voxygen.audio.sfx.weapon.sword_in", ], - threshold: 0.5, + threshold: 1.0, ), } ) \ No newline at end of file diff --git a/common/src/event.rs b/common/src/event.rs index dc8e596050..53ac827c01 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -39,10 +39,6 @@ pub enum SfxEvent { Fall, ExperienceGained, LevelUp, - LightLantern, - ExtinguishLantern, - Attack, - AttackWolf, Wield(comp::item::ToolKind), Unwield(comp::item::ToolKind), } diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index 05191d9049..87479d6c01 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -5,7 +5,7 @@ use crate::audio::sfx::{SfxTriggerItem, SfxTriggers}; use client::Client; use common::{ - comp::{Body, CharacterState, Item, ItemKind, Pos, Stats, ToolData, Vel}, + comp::{Body, CharacterState, Item, ItemKind, PhysicsState, Pos, Stats, ToolData, Vel}, event::{EventBus, SfxEvent, SfxEventItem}, }; use hashbrown::HashMap; @@ -14,14 +14,26 @@ use std::time::{Duration, Instant}; use vek::*; #[derive(Clone)] -struct LastSfxEvent { +struct PreviousEntityState { event: SfxEvent, - weapon_drawn: bool, time: Instant, + weapon_drawn: bool, + on_ground: bool, +} + +impl Default for PreviousEntityState { + fn default() -> Self { + Self { + event: SfxEvent::Idle, + time: Instant::now(), + weapon_drawn: false, + on_ground: true, + } + } } pub struct MovementEventMapper { - event_history: HashMap, + event_history: HashMap, } impl MovementEventMapper { @@ -40,12 +52,13 @@ impl MovementEventMapper { .get(client.entity()) .map_or(Vec3::zero(), |pos| pos.0); - for (entity, pos, vel, body, stats, character) in ( + for (entity, pos, vel, body, stats, physics, character) in ( &ecs.entities(), &ecs.read_storage::(), &ecs.read_storage::(), &ecs.read_storage::(), &ecs.read_storage::(), + &ecs.read_storage::(), ecs.read_storage::().maybe(), ) .join() @@ -57,21 +70,17 @@ impl MovementEventMapper { let state = self .event_history .entry(entity) - .or_insert_with(|| LastSfxEvent { - event: SfxEvent::Idle, - weapon_drawn: false, - time: Instant::now(), - }); + .or_insert_with(|| PreviousEntityState::default()); let mapped_event = match body { - Body::Humanoid(_) => Self::map_movement_event(character, state, vel.0, stats), + Body::Humanoid(_) => { + Self::map_movement_event(character, physics, state, vel.0, stats) + }, Body::QuadrupedMedium(_) | Body::QuadrupedSmall(_) | Body::BirdMedium(_) | Body::BirdSmall(_) - | Body::BipedLarge(_) => { - Self::map_non_humanoid_movement_event(character, vel.0) - }, + | Body::BipedLarge(_) => Self::map_non_humanoid_movement_event(physics, vel.0), _ => SfxEvent::Idle, // Ignore fish, critters, etc... }; @@ -85,14 +94,16 @@ impl MovementEventMapper { Some(Self::get_volume_for_body_type(body)), )); - // Update the last play time + // Set the new previous entity state state.event = mapped_event; state.time = Instant::now(); - state.weapon_drawn = character.is_wielded(); + state.weapon_drawn = Self::weapon_drawn(character); + state.on_ground = physics.on_ground; } else { - // Keep the last event, it may not have an SFX trigger but it helps us determine - // the next one + // If we don't dispatch the event, store this data as we can use it to determine + // the next event state.event = mapped_event; + state.on_ground = physics.on_ground; } } } @@ -121,12 +132,12 @@ impl MovementEventMapper { /// file(s) to play) 2. The sfx has not been played since it's timeout /// threshold has elapsed, which prevents firing every tick fn should_emit( - last_play_entry: &LastSfxEvent, + previous_state: &PreviousEntityState, sfx_trigger_item: Option<(&SfxEvent, &SfxTriggerItem)>, ) -> bool { if let Some((event, item)) = sfx_trigger_item { - if &last_play_entry.event == event { - last_play_entry.time.elapsed().as_secs_f64() >= item.threshold + if &previous_state.event == event { + previous_state.time.elapsed().as_secs_f64() >= item.threshold } else { true } @@ -141,8 +152,9 @@ impl MovementEventMapper { /// entity states with some additional data into more specific /// `SfxEvent`'s which we attach sounds to fn map_movement_event( - current_event: &CharacterState, - previous_event: &LastSfxEvent, + character_state: &CharacterState, + physics_state: &PhysicsState, + previous_state: &PreviousEntityState, vel: Vec3, stats: &Stats, ) -> SfxEvent { @@ -154,19 +166,42 @@ impl MovementEventMapper { .. }) = stats.equipment.main { - if let Some(wield_event) = - match (previous_event.weapon_drawn, current_event.is_wielded()) { - (false, true) => Some(SfxEvent::Wield(kind)), - (true, false) => Some(SfxEvent::Unwield(kind)), - _ => None, - } - { + if let Some(wield_event) = match ( + previous_state.weapon_drawn, + Self::weapon_drawn(character_state), + ) { + (false, true) => Some(SfxEvent::Wield(kind)), + (true, false) => Some(SfxEvent::Unwield(kind)), + _ => None, + } { return wield_event; } } + // Match the fall/land and jump states based on the on_ground status + // They may also have landed on the ground with the glider (!jump) + if let Some(jump_or_fall_event) = match (physics_state.on_ground, previous_state.on_ground) + { + (true, false) => { + if previous_state.event == SfxEvent::Glide { + Some(SfxEvent::GliderClose) + } else { + Some(SfxEvent::Run) + } + }, + (false, true) => Some(SfxEvent::Jump), + _ => None, + } { + return jump_or_fall_event; + } + + // Match run state + if physics_state.on_ground && vel.magnitude() > 0.1 { + return SfxEvent::Run; + } + // Match all other Movemement and Action states - match (previous_event.event, current_event) { + match (previous_state.event, character_state) { (_, CharacterState::Roll(_)) => SfxEvent::Roll, (_, CharacterState::Climb(_)) => SfxEvent::Climb, (SfxEvent::Glide, CharacterState::Idle(_)) => SfxEvent::GliderClose, @@ -182,18 +217,26 @@ impl MovementEventMapper { } /// Maps a limited set of movements for other non-humanoid entities - fn map_non_humanoid_movement_event(current_event: &CharacterState, vel: Vec3) -> SfxEvent { - if let CharacterState::Idle(_) = current_event { - if vel.magnitude() > 0.1 { - SfxEvent::Run - } else { - SfxEvent::Idle - } + fn map_non_humanoid_movement_event(physics_state: &PhysicsState, vel: Vec3) -> SfxEvent { + if physics_state.on_ground && vel.magnitude() > 0.1 { + SfxEvent::Run } else { SfxEvent::Idle } } + /// This helps us determine whether we should be emitting the Wield/Unwield + /// events. For now, consider either CharacterState::Wielded or + /// ::Wielding to mean the weapon is drawn. This will need updating if the + /// animations change to match the wield_duration associated with the weapon + fn weapon_drawn(character: &CharacterState) -> bool { + character.is_wielded() + || match character { + CharacterState::Wielding(_) => true, + _ => false, + } + } + /// Returns a relative volume value for a body type. This helps us emit sfx /// at a volume appropriate fot the entity we are emitting the event for fn get_volume_for_body_type(body: &Body) -> f32 { diff --git a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs index 9e147467bc..5d898ca73f 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs @@ -3,7 +3,7 @@ use common::{ assets, comp::{ bird_small, humanoid, item::ToolKind, quadruped_medium, quadruped_small, Body, - CharacterState, Stats, + CharacterState, PhysicsState, Stats, }, event::SfxEvent, }; @@ -11,34 +11,29 @@ use std::time::{Duration, Instant}; #[test] fn no_item_config_no_emit() { - let last_sfx_event = LastSfxEvent { - event: SfxEvent::Idle, - weapon_drawn: false, - time: Instant::now(), - }; - - let result = MovementEventMapper::should_emit(&last_sfx_event, None); + let previous_state = PreviousEntityState::default(); + let result = MovementEventMapper::should_emit(&previous_state, None); assert_eq!(result, false); } #[test] fn config_but_played_since_threshold_no_emit() { - let event = SfxEvent::Run; - let trigger_item = SfxTriggerItem { files: vec![String::from("some.path.to.sfx.file")], threshold: 1.0, }; // Triggered a 'Run' 0 seconds ago - let last_sfx_event = LastSfxEvent { + let previous_state = PreviousEntityState { event: SfxEvent::Run, - weapon_drawn: false, time: Instant::now(), + weapon_drawn: false, + on_ground: true, }; - let result = MovementEventMapper::should_emit(&last_sfx_event, Some((&event, &trigger_item))); + let result = + MovementEventMapper::should_emit(&previous_state, Some((&SfxEvent::Run, &trigger_item))); assert_eq!(result, false); } @@ -52,35 +47,37 @@ fn config_and_not_played_since_threshold_emits() { threshold: 0.5, }; - let last_sfx_event = LastSfxEvent { + let previous_state = PreviousEntityState { event: SfxEvent::Idle, - weapon_drawn: false, time: Instant::now().checked_add(Duration::from_secs(1)).unwrap(), + weapon_drawn: false, + on_ground: true, }; - let result = MovementEventMapper::should_emit(&last_sfx_event, Some((&event, &trigger_item))); + let result = + MovementEventMapper::should_emit(&previous_state, Some((&SfxEvent::Run, &trigger_item))); assert_eq!(result, true); } #[test] fn same_previous_event_elapsed_emits() { - let event = SfxEvent::Run; - let trigger_item = SfxTriggerItem { files: vec![String::from("some.path.to.sfx.file")], threshold: 0.5, }; - let last_sfx_event = LastSfxEvent { + let previous_state = PreviousEntityState { event: SfxEvent::Run, - weapon_drawn: false, time: Instant::now() .checked_sub(Duration::from_millis(500)) .unwrap(), + weapon_drawn: false, + on_ground: true, }; - let result = MovementEventMapper::should_emit(&last_sfx_event, Some((&event, &trigger_item))); + let result = + MovementEventMapper::should_emit(&previous_state, Some((&SfxEvent::Run, &trigger_item))); assert_eq!(result, true); } @@ -95,10 +92,17 @@ fn maps_idle() { let result = MovementEventMapper::map_movement_event( &CharacterState::Idle(None), - &LastSfxEvent { + &PhysicsState { + on_ground: true, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { event: SfxEvent::Idle, - weapon_drawn: false, time: Instant::now(), + weapon_drawn: false, + on_ground: true, }, Vec3::zero(), &stats, @@ -107,55 +111,92 @@ fn maps_idle() { assert_eq!(result, SfxEvent::Idle); } -// #[test] -// fn maps_run_with_sufficient_velocity() { -// let stats = Stats::new( -// String::from("test"), -// Body::Humanoid(humanoid::Body::random()), -// None, -// ); +#[test] +fn maps_run_with_sufficient_velocity() { + let stats = Stats::new( + String::from("test"), + Body::Humanoid(humanoid::Body::random()), + None, + ); -// let result = MovementEventMapper::map_movement_event( -// &CharacterState { -// movement: MovementState::Run, -// action: ActionState::Idle, -// }, -// &LastSfxEvent { -// event: SfxEvent::Idle, -// weapon_drawn: false, -// time: Instant::now(), -// }, -// Vec3::new(0.5, 0.8, 0.0), -// &stats, -// ); + let result = MovementEventMapper::map_movement_event( + &CharacterState::Idle(None), + &PhysicsState { + on_ground: true, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { + event: SfxEvent::Idle, + time: Instant::now(), + weapon_drawn: false, + on_ground: true, + }, + Vec3::new(0.5, 0.8, 0.0), + &stats, + ); -// assert_eq!(result, SfxEvent::Run); -// } + assert_eq!(result, SfxEvent::Run); +} -// #[test] -// fn does_not_map_run_with_insufficient_velocity() { -// let stats = Stats::new( -// String::from("test"), -// Body::Humanoid(humanoid::Body::random()), -// None, -// ); +#[test] +fn does_not_map_run_with_insufficient_velocity() { + let stats = Stats::new( + String::from("test"), + Body::Humanoid(humanoid::Body::random()), + None, + ); -// let result = MovementEventMapper::map_movement_event( -// &CharacterState { -// movement: MovementState::Run, -// action: ActionState::Idle, -// }, -// &LastSfxEvent { -// event: SfxEvent::Idle, -// weapon_drawn: false, -// time: Instant::now(), -// }, -// Vec3::new(0.02, 0.0001, 0.0), -// &stats, -// ); + let result = MovementEventMapper::map_movement_event( + &CharacterState::Idle(None), + &PhysicsState { + on_ground: true, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { + event: SfxEvent::Idle, + time: Instant::now(), + weapon_drawn: false, + on_ground: true, + }, + Vec3::new(0.02, 0.0001, 0.0), + &stats, + ); -// assert_eq!(result, SfxEvent::Idle); -// } + assert_eq!(result, SfxEvent::Idle); +} + +#[test] +fn does_not_map_run_with_sufficient_velocity_but_not_on_ground() { + let stats = Stats::new( + String::from("test"), + Body::Humanoid(humanoid::Body::random()), + None, + ); + + let result = MovementEventMapper::map_movement_event( + &CharacterState::Idle(None), + &PhysicsState { + on_ground: false, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { + event: SfxEvent::Idle, + time: Instant::now(), + weapon_drawn: false, + on_ground: false, + }, + Vec3::new(0.5, 0.8, 0.0), + &stats, + ); + + assert_eq!(result, SfxEvent::Idle); +} #[test] fn maps_roll() { @@ -167,10 +208,17 @@ fn maps_roll() { let result = MovementEventMapper::map_movement_event( &CharacterState::Roll(None), - &LastSfxEvent { + &PhysicsState { + on_ground: true, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { event: SfxEvent::Run, - weapon_drawn: false, time: Instant::now(), + weapon_drawn: false, + on_ground: true, }, Vec3::zero(), &stats, @@ -179,55 +227,34 @@ fn maps_roll() { assert_eq!(result, SfxEvent::Roll); } -// #[test] -// fn maps_fall() { -// let stats = Stats::new( -// String::from("test"), -// Body::Humanoid(humanoid::Body::random()), -// None, -// ); +#[test] +fn maps_land_on_ground_to_run() { + let stats = Stats::new( + String::from("test"), + Body::Humanoid(humanoid::Body::random()), + None, + ); -// let result = MovementEventMapper::map_movement_event( -// &CharacterState { -// movement: MovementState::Fall, -// action: ActionState::Idle, -// }, -// &LastSfxEvent { -// event: SfxEvent::Fall, -// weapon_drawn: false, -// time: Instant::now(), -// }, -// Vec3::zero(), -// &stats, -// ); + let result = MovementEventMapper::map_movement_event( + &CharacterState::Idle(None), + &PhysicsState { + on_ground: true, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { + event: SfxEvent::Idle, + time: Instant::now(), + weapon_drawn: false, + on_ground: false, + }, + Vec3::zero(), + &stats, + ); -// assert_eq!(result, SfxEvent::Fall); -// } - -// #[test] -// fn maps_land_on_ground_to_run() { -// let stats = Stats::new( -// String::from("test"), -// Body::Humanoid(humanoid::Body::random()), -// None, -// ); - -// let result = MovementEventMapper::map_movement_event( -// &CharacterState { -// movement: MovementState::Stand, -// action: ActionState::Idle, -// }, -// &LastSfxEvent { -// event: SfxEvent::Fall, -// weapon_drawn: false, -// time: Instant::now(), -// }, -// Vec3::zero(), -// &stats, -// ); - -// assert_eq!(result, SfxEvent::Run); -// } + assert_eq!(result, SfxEvent::Run); +} #[test] fn maps_glider_open() { @@ -239,10 +266,17 @@ fn maps_glider_open() { let result = MovementEventMapper::map_movement_event( &CharacterState::Glide(None), - &LastSfxEvent { + &PhysicsState { + on_ground: false, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { event: SfxEvent::Jump, - weapon_drawn: false, time: Instant::now(), + weapon_drawn: false, + on_ground: false, }, Vec3::zero(), &stats, @@ -261,10 +295,17 @@ fn maps_glide() { let result = MovementEventMapper::map_movement_event( &CharacterState::Glide(None), - &LastSfxEvent { + &PhysicsState { + on_ground: false, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { event: SfxEvent::Glide, - weapon_drawn: false, time: Instant::now(), + weapon_drawn: false, + on_ground: false, }, Vec3::zero(), &stats, @@ -273,55 +314,63 @@ fn maps_glide() { assert_eq!(result, SfxEvent::Glide); } -// #[test] -// fn maps_glider_close_when_closing_mid_flight() { -// let stats = Stats::new( -// String::from("test"), -// Body::Humanoid(humanoid::Body::random()), -// None, -// ); +#[test] +fn maps_glider_close_when_closing_mid_flight() { + let stats = Stats::new( + String::from("test"), + Body::Humanoid(humanoid::Body::random()), + None, + ); -// let result = MovementEventMapper::map_movement_event( -// &CharacterState { -// movement: MovementState::Fall, -// action: ActionState::Idle, -// }, -// &LastSfxEvent { -// event: SfxEvent::Glide, -// weapon_drawn: false, -// time: Instant::now(), -// }, -// Vec3::zero(), -// &stats, -// ); + let result = MovementEventMapper::map_movement_event( + &CharacterState::Idle(None), + &PhysicsState { + on_ground: false, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { + event: SfxEvent::Glide, + time: Instant::now(), + weapon_drawn: false, + on_ground: false, + }, + Vec3::zero(), + &stats, + ); -// assert_eq!(result, SfxEvent::GliderClose); -// } + assert_eq!(result, SfxEvent::GliderClose); +} -// #[test] -// fn maps_glider_close_when_landing() { -// let stats = Stats::new( -// String::from("test"), -// Body::Humanoid(humanoid::Body::random()), -// None, -// ); +#[test] +fn maps_glider_close_when_landing() { + let stats = Stats::new( + String::from("test"), + Body::Humanoid(humanoid::Body::random()), + None, + ); -// let result = MovementEventMapper::map_movement_event( -// &CharacterState { -// movement: MovementState::Stand, -// action: ActionState::Idle, -// }, -// &LastSfxEvent { -// event: SfxEvent::Glide, -// weapon_drawn: false, -// time: Instant::now(), -// }, -// Vec3::zero(), -// &stats, -// ); + let result = MovementEventMapper::map_movement_event( + &CharacterState::Idle(None), + &PhysicsState { + on_ground: true, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { + event: SfxEvent::Glide, + time: Instant::now(), + weapon_drawn: false, + on_ground: false, + }, + Vec3::zero(), + &stats, + ); -// assert_eq!(result, SfxEvent::GliderClose); -// } + assert_eq!(result, SfxEvent::GliderClose); +} #[test] fn maps_wield() { @@ -334,11 +383,18 @@ fn maps_wield() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::BasicAttack(None), - &LastSfxEvent { + &CharacterState::Wielding(None), + &PhysicsState { + on_ground: true, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { event: SfxEvent::Idle, - weapon_drawn: false, time: Instant::now(), + weapon_drawn: false, + on_ground: true, }, Vec3::zero(), &stats, @@ -359,10 +415,17 @@ fn maps_unwield() { let result = MovementEventMapper::map_movement_event( &CharacterState::default(), - &LastSfxEvent { + &PhysicsState { + on_ground: true, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { event: SfxEvent::Idle, - weapon_drawn: true, time: Instant::now(), + weapon_drawn: true, + on_ground: true, }, Vec3::zero(), &stats, @@ -371,45 +434,49 @@ fn maps_unwield() { assert_eq!(result, SfxEvent::Unwield(ToolKind::Bow)); } -// #[test] -// fn does_not_map_wield_when_no_main_weapon() { -// let stats = Stats::new( -// String::from("test"), -// Body::Humanoid(humanoid::Body::random()), -// None, -// ); +#[test] +fn does_not_map_wield_when_no_main_weapon() { + let stats = Stats::new( + String::from("test"), + Body::Humanoid(humanoid::Body::random()), + None, + ); -// let result = MovementEventMapper::map_movement_event( -// &CharacterState { -// movement: MovementState::Run, -// action: ActionState::Wield { -// time_left: Duration::from_millis(600), -// }, -// }, -// &LastSfxEvent { -// event: SfxEvent::Idle, -// weapon_drawn: false, -// time: Instant::now(), -// }, -// Vec3::new(0.5, 0.8, 0.0), -// &stats, -// ); + let result = MovementEventMapper::map_movement_event( + &CharacterState::Wielded(None), + &PhysicsState { + on_ground: true, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + &PreviousEntityState { + event: SfxEvent::Idle, + time: Instant::now(), + weapon_drawn: false, + on_ground: true, + }, + Vec3::new(0.5, 0.8, 0.0), + &stats, + ); -// assert_eq!(result, SfxEvent::Run); -// } + assert_eq!(result, SfxEvent::Run); +} -// #[test] -// fn maps_quadrupeds_running() { -// let result = MovementEventMapper::map_non_humanoid_movement_event( -// &CharacterState { -// movement: MovementState::Run, -// action: ActionState::Idle, -// }, -// Vec3::new(0.5, 0.8, 0.0), -// ); +#[test] +fn maps_quadrupeds_running() { + let result = MovementEventMapper::map_non_humanoid_movement_event( + &PhysicsState { + on_ground: true, + on_wall: None, + touch_entity: None, + in_fluid: false, + }, + Vec3::new(0.5, 0.8, 0.0), + ); -// assert_eq!(result, SfxEvent::Run); -// } + assert_eq!(result, SfxEvent::Run); +} #[test] fn determines_relative_volumes() { From b1d1299fe69aac472a2ee70e222cbb118e6bb106 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 7 Mar 2020 10:15:02 -0800 Subject: [PATCH 044/326] Clean up character states --- common/src/comp/ability.rs | 37 ++-- common/src/comp/character_state.rs | 124 ++++-------- common/src/comp/mod.rs | 4 +- common/src/msg/ecs_packet.rs | 12 +- common/src/state.rs | 2 +- common/src/states/basic_attack.rs | 103 +++++----- common/src/states/basic_block.rs | 27 ++- common/src/states/charge_attack.rs | 127 +++++------- common/src/states/climb.rs | 153 +++++++------- common/src/states/equipping.rs | 38 ++++ common/src/states/fall.rs | 8 +- common/src/states/glide.rs | 108 +++++----- common/src/states/idle.rs | 47 ++--- common/src/states/jump.rs | 8 +- common/src/states/mod.rs | 21 +- common/src/states/roll.rs | 70 +++---- common/src/states/sit.rs | 50 ++--- common/src/states/stand.rs | 12 +- common/src/states/swim.rs | 114 +++++------ common/src/states/utils.rs | 186 +++++++++++++----- common/src/states/wielded.rs | 51 ----- common/src/states/wielding.rs | 77 +++----- common/src/sys/character_state.rs | 146 +++++++++----- common/src/sys/stats.rs | 4 +- .../audio/sfx/event_mapper/movement/mod.rs | 14 +- .../audio/sfx/event_mapper/movement/tests.rs | 24 +-- voxygen/src/scene/figure/cache.rs | 8 +- voxygen/src/scene/figure/mod.rs | 44 +++-- 28 files changed, 758 insertions(+), 861 deletions(-) create mode 100644 common/src/states/equipping.rs delete mode 100644 common/src/states/wielded.rs diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 39be87db17..4f9daa7162 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1,39 +1,34 @@ -use crate::comp; -use specs::{Component, FlaggedStorage, HashMapStorage, VecStorage}; +use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage}; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum AbilityActionKind { - Primary, - Secondary, - Dodge, - Block, - // UpdatePool? +pub enum AbilityState { + BasicAttack, + BasicBlock, + Roll, } -impl Default for AbilityActionKind { - fn default() -> Self { Self::Primary } +impl Default for AbilityState { + fn default() -> Self { Self::BasicAttack } } -#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct AbilityAction(pub AbilityActionKind); -impl Component for AbilityAction { - type Storage = FlaggedStorage>; +impl Component for AbilityState { + type Storage = DenseVecStorage; } #[derive(Copy, Clone, Debug, Serialize, Deserialize)] pub struct AbilityPool { - pub primary: Option, - pub secondary: Option, - pub block: Option, - pub dodge: Option, + pub primary: Option, + pub secondary: Option, + pub block: Option, + pub dodge: Option, } impl Default for AbilityPool { fn default() -> Self { Self { - primary: Some(comp::CharacterState::BasicAttack(None)), - secondary: Some(comp::CharacterState::BasicBlock(None)), + primary: Some(AbilityState::BasicAttack), + secondary: Some(AbilityState::BasicAttack), block: None, - dodge: Some(comp::CharacterState::Roll(None)), + dodge: Some(AbilityState::Roll), } } } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 589eeaeca0..22c49e0fe7 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,33 +1,12 @@ use crate::{ - comp::{ - AbilityPool, Body, ControllerInputs, Energy, Ori, PhysicsState, Pos, Stats, ToolData, Vel, - }, + comp::{Energy, Ori, Pos, ToolData, Vel}, event::{LocalEvent, ServerEvent}, - state::DeltaTime, - states::*, - sync::Uid, }; use serde::{Deserialize, Serialize}; -use specs::{Component, Entity, FlaggedStorage, HashMapStorage, LazyUpdate, VecStorage}; -use std::collections::VecDeque; - -pub struct EcsStateData<'a> { - pub entity: &'a Entity, - pub uid: &'a Uid, - pub character: &'a CharacterState, - pub pos: &'a Pos, - pub vel: &'a Vel, - pub ori: &'a Ori, - pub dt: &'a DeltaTime, - pub inputs: &'a ControllerInputs, - pub stats: &'a Stats, - pub energy: &'a Energy, - pub body: &'a Body, - pub physics: &'a PhysicsState, - pub ability_pool: &'a AbilityPool, - pub updater: &'a LazyUpdate, -} +use specs::{Component, FlaggedStorage, HashMapStorage, VecStorage}; +use std::{collections::VecDeque, time::Duration}; +/// Data returned from character behavior fn's to Character Behavior System. pub struct StateUpdate { pub character: CharacterState, pub pos: Pos, @@ -40,45 +19,63 @@ pub struct StateUpdate { #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum CharacterState { - Idle(Option), - Climb(Option), - Sit(Option), - Wielding(Option), - Wielded(Option), - Glide(Option), - BasicAttack(Option), - BasicBlock(Option), - //Charge(Option), - Roll(Option), + Idle {}, + Climb {}, + Sit {}, + Equipping { + /// The weapon being equipped + tool: ToolData, + /// Time left before next state + time_left: Duration, + }, + Wielding { + /// The weapon being wielded + tool: ToolData, + }, + Glide {}, + /// A basic attacking state + BasicAttack { + /// How long the state has until exiting + remaining_duration: Duration, + /// Whether the attack can deal more damage + exhausted: bool, + }, + /// A basic blocking state + BasicBlock {}, + //Charge{}, + Roll { + /// How long the state has until exiting + remaining_duration: Duration, + }, } impl CharacterState { pub fn is_wielded(&self) -> bool { match self { - CharacterState::Wielded(_) => true, - CharacterState::BasicAttack(_) => true, - CharacterState::BasicBlock(_) => true, + CharacterState::Wielding { .. } => true, + CharacterState::BasicAttack { .. } => true, + CharacterState::BasicBlock { .. } => true, _ => false, } } pub fn is_attack(&self) -> bool { match self { - CharacterState::BasicAttack(_) => true, + CharacterState::BasicAttack { .. } => true, _ => false, } } pub fn is_block(&self) -> bool { match self { - CharacterState::BasicBlock(_) => true, + CharacterState::BasicBlock { .. } => true, _ => false, } } pub fn is_dodge(&self) -> bool { match self { - CharacterState::Roll(_) => true, + CharacterState::Roll { .. } => true, _ => false, } } @@ -88,53 +85,10 @@ impl CharacterState { // Check if state is the same without looking at the inner data std::mem::discriminant(self) == std::mem::discriminant(other) } - - /// Passes data to variant or subvariant handlers - /// States contain `Option`s, and will be - /// `None` if state data has not been initialized. So we have to - /// check and intialize new state data if so. - pub fn update(&self, ecs_data: &EcsStateData) -> StateUpdate { - match self { - CharacterState::Idle(opt_state) => opt_state - // If data hasn't been initialized, initialize a new one - .unwrap_or_else(|| idle::State::new(ecs_data)) - // Call handler - .handle(ecs_data), - CharacterState::Climb(opt_state) => opt_state - .unwrap_or_else(|| climb::State::new(ecs_data)) - .handle(ecs_data), - CharacterState::Sit(opt_state) => opt_state - .unwrap_or_else(|| sit::State::new(ecs_data)) - .handle(ecs_data), - CharacterState::Wielding(opt_state) => opt_state - .unwrap_or_else(|| wielding::State::new(ecs_data)) - .handle(ecs_data), - CharacterState::Wielded(opt_state) => opt_state - .unwrap_or_else(|| wielded::State::new(ecs_data)) - .handle(ecs_data), - CharacterState::BasicAttack(opt_state) => opt_state - .unwrap_or_else(|| basic_attack::State::new(ecs_data)) - .handle(ecs_data), - CharacterState::BasicBlock(opt_state) => opt_state - .unwrap_or_else(|| basic_block::State::new(ecs_data)) - .handle(ecs_data), - /*CharacterState::Charge(opt_state) => opt_state - .unwrap_or_else(|| charge_attack::State::new(ecs_data)) - .handle(ecs_data),*/ - CharacterState::Roll(opt_state) => opt_state - .unwrap_or_else(|| roll::State::new(ecs_data)) - .handle(ecs_data), - CharacterState::Glide(opt_state) => opt_state - .unwrap_or_else(|| glide::State::new(ecs_data)) - .handle(ecs_data), - /* All states should be explicitly handled - * DO NOT use default match: _ => {}, */ - } - } } impl Default for CharacterState { - fn default() -> Self { Self::Idle(None) } + fn default() -> Self { Self::Idle {} } } impl Component for CharacterState { diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index eb8f6cda25..0d08898d7e 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -16,14 +16,14 @@ mod stats; mod visual; // Reexports -pub use ability::{AbilityAction, AbilityActionKind, AbilityPool}; +pub use ability::{AbilityPool, AbilityState}; pub use admin::Admin; pub use agent::{Agent, Alignment}; pub use body::{ biped_large, bird_medium, bird_small, critter, dragon, fish_medium, fish_small, humanoid, object, quadruped_medium, quadruped_small, AllBodies, Body, BodyData, }; -pub use character_state::{Attacking, CharacterState, EcsStateData, StateUpdate}; +pub use character_state::{Attacking, CharacterState, StateUpdate}; pub use controller::{ ControlEvent, Controller, ControllerInputs, Input, InputState, InventoryManip, MountState, Mounting, diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index cd62d556e5..91d78d35d7 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -21,7 +21,7 @@ sum_type! { Mass(comp::Mass), Gravity(comp::Gravity), Sticky(comp::Sticky), - AbilityAction(comp::AbilityAction), + AbilityState(comp::AbilityState), AbilityPool(comp::AbilityPool), Attacking(comp::Attacking), CharacterState(comp::CharacterState), @@ -45,7 +45,7 @@ sum_type! { Mass(PhantomData), Gravity(PhantomData), Sticky(PhantomData), - AbilityAction(PhantomData), + AbilityState(PhantomData), AbilityPool(PhantomData), Attacking(PhantomData), CharacterState(PhantomData), @@ -69,7 +69,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Mass(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Gravity(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_insert(comp, entity, world), - EcsCompPacket::AbilityAction(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::AbilityState(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::AbilityPool(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Attacking(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::CharacterState(comp) => sync::handle_insert(comp, entity, world), @@ -91,7 +91,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Mass(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Gravity(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_modify(comp, entity, world), - EcsCompPacket::AbilityAction(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::AbilityState(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::AbilityPool(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Attacking(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::CharacterState(comp) => sync::handle_modify(comp, entity, world), @@ -115,8 +115,8 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPhantom::Mass(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Gravity(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Sticky(_) => sync::handle_remove::(entity, world), - EcsCompPhantom::AbilityAction(_) => { - sync::handle_remove::(entity, world) + EcsCompPhantom::AbilityState(_) => { + sync::handle_remove::(entity, world) }, EcsCompPhantom::AbilityPool(_) => { sync::handle_remove::(entity, world) diff --git a/common/src/state.rs b/common/src/state.rs index 3064a58553..2c5224697a 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -107,7 +107,7 @@ impl State { ecs.register_sync_marker(); // Register server -> all clients synced components. ecs.register::(); - ecs.register::(); + ecs.register::(); ecs.register::(); ecs.register::(); ecs.register::(); diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index 1574abed2e..e144420f8f 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -1,85 +1,72 @@ use crate::{ - comp::{Attacking, CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}, - states::StateHandler, + comp::{Attacking, CharacterState, ItemKind::Tool, StateUpdate}, + states::utils::*, + sys::character_state::JoinData, }; use std::{collections::VecDeque, time::Duration}; -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State { - /// How long the state has until exitting - pub remaining_duration: Duration, - /// Whether the attack can deal more damage - pub exhausted: bool, -} +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; -impl StateHandler for State { - fn new(ecs_data: &EcsStateData) -> Self { - let remaining_duration = - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { - data.attack_duration() - } else { - Duration::from_millis(300) - }; - Self { - remaining_duration, - exhausted: false, - } - } + if let CharacterState::BasicAttack { + exhausted, + remaining_duration, + } = data.character + { + handle_move(data, &mut update); - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - energy: *ecs_data.energy, - character: *ecs_data.character, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; - - let tool_kind = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind); - - let can_apply_damage = !self.exhausted - && if let Some(Tool(data)) = tool_kind { - (self.remaining_duration < data.attack_recover_duration()) + let tool_kind = data.stats.equipment.main.as_ref().map(|i| i.kind); + let can_apply_damage = !*exhausted + && if let Some(Tool(tool)) = tool_kind { + *remaining_duration < tool.attack_recover_duration() } else { true }; - let mut exhausted = self.exhausted; + let mut new_exhausted = *exhausted; if can_apply_damage { - if let Some(Tool(data)) = tool_kind { - ecs_data - .updater - .insert(*ecs_data.entity, Attacking { weapon: Some(data) }); + if let Some(Tool(tool)) = tool_kind { + data.updater + .insert(data.entity, Attacking { weapon: Some(tool) }); } else { - ecs_data - .updater - .insert(*ecs_data.entity, Attacking { weapon: None }); + data.updater.insert(data.entity, Attacking { weapon: None }); } - exhausted = true; + new_exhausted = true; } else { - ecs_data.updater.remove::(*ecs_data.entity); + data.updater.remove::(data.entity); } - let remaining_duration = self - .remaining_duration - .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) + let new_remaining_duration = remaining_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(); // Tick down - update.character = CharacterState::BasicAttack(Some(State { - remaining_duration, - exhausted, - })); + update.character = CharacterState::BasicAttack { + remaining_duration: new_remaining_duration, + exhausted: new_exhausted, + }; // Check if attack duration has expired - if remaining_duration == Duration::default() { - update.character = CharacterState::Wielded(None); - ecs_data.updater.remove::(*ecs_data.entity); + if new_remaining_duration == Duration::default() { + update.character = if let Some(Tool(tool)) = tool_kind { + CharacterState::Wielding { tool } + } else { + CharacterState::Idle {} + }; + data.updater.remove::(data.entity); } + update + } else { update } } diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index 18d7dd1ce2..9781b7cc10 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -1,35 +1,30 @@ use super::utils::*; use crate::{ - comp::{CharacterState, EcsStateData, StateUpdate}, - states::StateHandler, + comp::{CharacterEntityData, CharacterState, StateUpdate}, }; use std::{collections::VecDeque, time::Duration}; use vek::Vec2; +use crate::sys::character_state::JoinData; const BLOCK_ACCEL: f32 = 30.0; const BLOCK_SPEED: f32 = 75.0; -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State {} -impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { Self {} } - - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + pub fn handle(data: &JoinData) -> StateUpdate { let mut update = StateUpdate { - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - energy: *ecs_data.energy, - character: *ecs_data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, local_events: VecDeque::new(), server_events: VecDeque::new(), }; - handle_move_dir(&ecs_data, &mut update); + handle_move(&data, &mut update); - if !ecs_data.physics.on_ground || !ecs_data.inputs.secondary.is_pressed() { - update.character = CharacterState::Wielded(None); + if !data.physics.on_ground || !data.inputs.secondary.is_pressed() { + update.character = CharacterState::Wielding{}; } update diff --git a/common/src/states/charge_attack.rs b/common/src/states/charge_attack.rs index c5f11ffc1e..5dbd9001a4 100644 --- a/common/src/states/charge_attack.rs +++ b/common/src/states/charge_attack.rs @@ -1,89 +1,62 @@ use super::utils::*; -use crate::comp::{ - ActionState::Attack, AttackKind::Charge, EcsStateData, HealthChange, HealthSource, - ItemKind::Tool, MoveState::Run, StateUpdate, ToolData, +use crate::{ + comp::{ + ActionState::Attack, AttackKind::Charge, CharacterEntityData, HealthChange, HealthSource, + ItemKind::Tool, MoveState::Run, StateUpdate, ToolData, + }, + event::ServerEvent, + sys::character_state::JoinData, }; -use crate::event::ServerEvent; -use crate::states::StateHandler; use std::time::Duration; use vek::Vec3; const CHARGE_SPEED: f32 = 20.0; -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State { - /// How long the state has until exitting - pub remaining_duration: Duration, -} +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + character: *data.character, + }; -impl StateHandler for State { - fn new(ecs_data: &EcsStateData) -> Self { - let tool_data = - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { - data - } else { - ToolData::default() - }; - Self { - remaining_duration: tool_data.attack_duration(), - } + // Move player + update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) + + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) + + 1.5 * data.inputs.move_dir.try_normalized().unwrap_or_default()) + .try_normalized() + .unwrap_or_default() + * CHARGE_SPEED; + + // Check if hitting another entity + if let Some(uid_b) = data.physics.touch_entity { + // Send Damage event + data.server_bus.emitter().emit(ServerEvent::Damage { + uid: uid_b, + change: HealthChange { + amount: -20, + cause: HealthSource::Attack { by: *data.uid }, + }, + }); + + // Go back to wielding or idling + update.character.action_state = attempt_wield(data.stats); + return update; } - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - character: *ecs_data.character, - }; - - // Prevent move state handling, handled here - update.character.move_state = Run(None); - - // Move player - update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) - + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) - + 1.5 - * ecs_data - .inputs - .move_dir - .try_normalized() - .unwrap_or_default()) - .try_normalized() - .unwrap_or_default() - * CHARGE_SPEED; - - // Check if hitting another entity - if let Some(uid_b) = ecs_data.physics.touch_entity { - // Send Damage event - ecs_data.server_bus.emitter().emit(ServerEvent::Damage { - uid: uid_b, - change: HealthChange { - amount: -20, - cause: HealthSource::Attack { by: *ecs_data.uid }, - }, - }); - - // Go back to wielding or idling - update.character.action_state = attempt_wield(ecs_data.stats); - return update; - } - - // Check if charge timed out or can't keep moving forward - if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 - { - update.character.action_state = attempt_wield(ecs_data.stats); - return update; - } - - // Tick remaining-duration and keep charging - update.character.action_state = Attack(Charge(Some(State { - remaining_duration: self - .remaining_duration - .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) - .unwrap_or_default(), - }))); - - update + // Check if charge timed out or can't keep moving forward + if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 { + update.character.action_state = attempt_wield(data.stats); + return update; } + + // Tick remaining-duration and keep charging + update.character.action_state = Attack(Charge(Some(State { + remaining_duration: self + .remaining_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), + }))); + + update } diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 8c73c9b31b..ee7bf3257d 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -1,7 +1,7 @@ use crate::{ - comp::{CharacterState, EcsStateData, EnergySource, StateUpdate}, - states::StateHandler, - sys::phys::GRAVITY, + comp::{CharacterState, EnergySource, StateUpdate}, + event::LocalEvent, + sys::{character_state::JoinData, phys::GRAVITY}, }; use std::collections::VecDeque; use vek::{ @@ -12,91 +12,84 @@ use vek::{ const HUMANOID_CLIMB_ACCEL: f32 = 5.0; const CLIMB_SPEED: f32 = 5.0; -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State; +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + character: *data.character, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; -impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { Self {} } + if let Err(_) = update.energy.try_change_by(-5, EnergySource::Climb) { + update.character = CharacterState::Idle {}; + } - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - character: *ecs_data.character, - energy: *ecs_data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), + // If no wall is in front of character ... + if data.physics.on_wall.is_none() || data.physics.on_ground { + if data.inputs.jump.is_pressed() { + // They've climbed atop something, give them a boost + update + .local_events + .push_front(LocalEvent::Jump(data.entity)); + } + update.character = CharacterState::Idle {}; + return update; + } + + // Move player + update.vel.0 += Vec2::broadcast(data.dt.0) + * data.inputs.move_dir + * if update.vel.0.magnitude_squared() < CLIMB_SPEED.powf(2.0) { + HUMANOID_CLIMB_ACCEL + } else { + 0.0 }; - if let Err(_) = update.energy.try_change_by(-5, EnergySource::Climb) { - update.character = CharacterState::Idle(None); - } - - // If no wall is in front of character ... - if ecs_data.physics.on_wall.is_none() || ecs_data.physics.on_ground { - if ecs_data.inputs.jump.is_pressed() { - // They've climbed atop something, give them a boost - //TODO: JUMP EVENT - } - update.character = CharacterState::Idle(None); - return update; - } - - // Move player - update.vel.0 += Vec2::broadcast(ecs_data.dt.0) - * ecs_data.inputs.move_dir - * if update.vel.0.magnitude_squared() < CLIMB_SPEED.powf(2.0) { - HUMANOID_CLIMB_ACCEL - } else { - 0.0 - }; - - // Set orientation direction based on wall direction - let ori_dir = if let Some(wall_dir) = ecs_data.physics.on_wall { - if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { - Vec2::from(wall_dir).normalized() - } else { - Vec2::from(update.vel.0) - } + // Set orientation direction based on wall direction + let ori_dir = if let Some(wall_dir) = data.physics.on_wall { + if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { + Vec2::from(wall_dir).normalized() } else { Vec2::from(update.vel.0) - }; + } + } else { + Vec2::from(update.vel.0) + }; - // Smooth orientation - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = vek::ops::Slerp::slerp( - update.ori.0, - ori_dir.into(), - if ecs_data.physics.on_ground { 9.0 } else { 2.0 } * ecs_data.dt.0, + // Smooth orientation + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = vek::ops::Slerp::slerp( + update.ori.0, + ori_dir.into(), + if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, + ); + } + + // Apply Vertical Climbing Movement + if let (true, Some(_wall_dir)) = ( + (data.inputs.climb.is_pressed() | data.inputs.climb_down.is_pressed()) + && update.vel.0.z <= CLIMB_SPEED, + data.physics.on_wall, + ) { + if data.inputs.climb_down.is_pressed() && !data.inputs.climb.is_pressed() { + update.vel.0 -= data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); + } else if data.inputs.climb.is_pressed() && !data.inputs.climb_down.is_pressed() { + update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); + } else { + update.vel.0.z = update.vel.0.z + data.dt.0 * GRAVITY * 1.5; + update.vel.0 = Lerp::lerp( + update.vel.0, + Vec3::zero(), + 30.0 * data.dt.0 / (1.0 - update.vel.0.z.min(0.0) * 5.0), ); } - - // Apply Vertical Climbing Movement - if let (true, Some(_wall_dir)) = ( - (ecs_data.inputs.climb.is_pressed() | ecs_data.inputs.climb_down.is_pressed()) - && update.vel.0.z <= CLIMB_SPEED, - ecs_data.physics.on_wall, - ) { - if ecs_data.inputs.climb_down.is_pressed() && !ecs_data.inputs.climb.is_pressed() { - update.vel.0 -= - ecs_data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); - } else if ecs_data.inputs.climb.is_pressed() && !ecs_data.inputs.climb_down.is_pressed() - { - update.vel.0.z = (update.vel.0.z + ecs_data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); - } else { - update.vel.0.z = update.vel.0.z + ecs_data.dt.0 * GRAVITY * 1.5; - update.vel.0 = Lerp::lerp( - update.vel.0, - Vec3::zero(), - 30.0 * ecs_data.dt.0 / (1.0 - update.vel.0.z.min(0.0) * 5.0), - ); - } - } - - update } + + update } diff --git a/common/src/states/equipping.rs b/common/src/states/equipping.rs new file mode 100644 index 0000000000..8d6004114f --- /dev/null +++ b/common/src/states/equipping.rs @@ -0,0 +1,38 @@ +use super::utils::*; +use crate::{ + comp::{CharacterState, StateUpdate}, + sys::character_state::JoinData, +}; +use std::{collections::VecDeque, time::Duration}; + +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + + handle_move(&data, &mut update); + handle_jump(&data, &mut update); + + if let CharacterState::Equipping { tool, time_left } = data.character { + if *time_left == Duration::default() { + // Wield delay has expired + update.character = CharacterState::Wielding { tool: *tool }; + } else { + // Wield delay hasn't expired yet + // Update wield delay + update.character = CharacterState::Equipping { + time_left: time_left + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), + tool: *tool, + }; + } + } + update +} diff --git a/common/src/states/fall.rs b/common/src/states/fall.rs index 0ee2ae18f7..8d90711eb2 100644 --- a/common/src/states/fall.rs +++ b/common/src/states/fall.rs @@ -1,4 +1,4 @@ -use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::comp::{ActionState, CharacterEntityData, MoveState, StateUpdate}; use super::utils::*; use crate::states::StateHandler; @@ -11,11 +11,9 @@ const HUMANOID_AIR_SPEED: f32 = 100.0; pub struct State; impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { - Self {} - } + fn new(_ecs_data: &CharacterEntityData) -> Self { Self {} } - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + fn handle(&self, ecs_data: &CharacterEntityData) -> StateUpdate { let mut update = StateUpdate { pos: *ecs_data.pos, vel: *ecs_data.vel, diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index ba0d4f8bea..4a7d22c997 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,6 +1,6 @@ use crate::{ - comp::{CharacterState, EcsStateData, StateUpdate}, - states::StateHandler, + comp::{CharacterState, StateUpdate}, + sys::character_state::JoinData, }; use std::collections::VecDeque; use vek::{Vec2, Vec3}; @@ -10,65 +10,57 @@ const GLIDE_ANTIGRAV: f32 = crate::sys::phys::GRAVITY * 0.96; const GLIDE_ACCEL: f32 = 15.0; const GLIDE_SPEED: f32 = 45.0; -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State; +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; -impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { Self {} } + // If glide button isn't held or player is on ground, end glide + if !data.inputs.glide.is_pressed() || data.physics.on_ground { + update.character = CharacterState::Idle {}; + } - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - energy: *ecs_data.energy, - character: *ecs_data.character, - local_events: VecDeque::new(), - server_events: VecDeque::new(), + // If there is a wall in front of character go to climb + if let Some(_) = data.physics.on_wall { + update.character = CharacterState::Climb {}; + } + + // Move player according to movement direction vector + update.vel.0 += Vec2::broadcast(data.dt.0) + * data.inputs.move_dir + * if data.vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) { + GLIDE_ACCEL + } else { + 0.0 }; - // If glide button isn't held or player is on ground, end glide - if !ecs_data.inputs.glide.is_pressed() || ecs_data.physics.on_ground { - update.character = CharacterState::Idle(None); - } - - // If there is a wall in front of character go to climb - if let Some(_) = ecs_data.physics.on_wall { - update.character = CharacterState::Climb(None); - } - - // Move player according to movement direction vector - update.vel.0 += Vec2::broadcast(ecs_data.dt.0) - * ecs_data.inputs.move_dir - * if ecs_data.vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) { - GLIDE_ACCEL - } else { - 0.0 - }; - - // Determine orientation vector from movement direction vector - let ori_dir = Vec2::from(update.vel.0); - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = - vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 2.0 * ecs_data.dt.0); - } - - // Apply Glide antigrav lift - if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) - && update.vel.0.z < 0.0 - { - let lift = GLIDE_ANTIGRAV + update.vel.0.z.abs().powf(2.0) * 0.15; - update.vel.0.z += ecs_data.dt.0 - * lift - * (Vec2::::from(update.vel.0).magnitude() * 0.075) - .min(1.0) - .max(0.2); - } - - // Otherwise keep gliding - update + // Determine orientation vector from movement direction vector + let ori_dir = Vec2::from(update.vel.0); + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 2.0 * data.dt.0); } + + // Apply Glide antigrav lift + if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) + && update.vel.0.z < 0.0 + { + let lift = GLIDE_ANTIGRAV + update.vel.0.z.abs().powf(2.0) * 0.15; + update.vel.0.z += data.dt.0 + * lift + * (Vec2::::from(update.vel.0).magnitude() * 0.075) + .min(1.0) + .max(0.2); + } + + // Otherwise keep gliding + update } diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index b07456e891..3e16c39f64 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -1,33 +1,24 @@ use super::utils::*; -use crate::comp::{EcsStateData, StateUpdate}; +use crate::{comp::StateUpdate, sys::character_state::JoinData}; use std::collections::VecDeque; -use crate::states::StateHandler; -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State; +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + handle_move(data, &mut update); + handle_jump(data, &mut update); + handle_wield(data, &mut update); + handle_sit(data, &mut update); + handle_climb(data, &mut update); + handle_glide(data, &mut update); + handle_dodge(data, &mut update); -impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { Self {} } - - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - energy: *ecs_data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; - - handle_move_dir(ecs_data, &mut update); - handle_jump(ecs_data, &mut update); - handle_wield(ecs_data, &mut update); - handle_sit(ecs_data, &mut update); - handle_climb(ecs_data, &mut update); - handle_glide(ecs_data, &mut update); - handle_dodge(ecs_data, &mut update); - - update - } + update } diff --git a/common/src/states/jump.rs b/common/src/states/jump.rs index 13fcd80e81..bb23131736 100644 --- a/common/src/states/jump.rs +++ b/common/src/states/jump.rs @@ -1,15 +1,13 @@ -use super::{EcsStateData, MoveState, StateHandler, StateUpdate}; +use super::{CharacterEntityData, MoveState, StateHandler, StateUpdate}; use crate::event::LocalEvent; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { - Self {} - } + fn new(_ecs_data: &CharacterEntityData) -> Self { Self {} } - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + fn handle(&self, ecs_data: &CharacterEntityData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 016362d5be..9a9c62a9b3 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -1,28 +1,11 @@ // Module declarations pub mod basic_attack; -pub mod basic_block; +// pub mod basic_block; pub mod climb; +pub mod equipping; pub mod glide; pub mod idle; pub mod roll; pub mod sit; pub mod utils; -pub mod wielded; pub mod wielding; - -use crate::comp::{EcsStateData, StateUpdate}; - -/// ## A type for implementing State Handling Behavior. -/// -/// Called by state machines' update functions to allow current states to handle -/// updating their parent machine's current state. -/// -/// Structures must implement a `handle()` fn to handle update behavior, and a -/// `new()` for instantiating new instances of a state. `handle()` function -/// recieves `EcsStateData`, a struct of readonly ECS Component data, and -/// returns a `StateUpdate` tuple, with new components that will overwrite an -/// entitie's old components. -pub trait StateHandler: Default { - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate; - fn new(ecs_data: &EcsStateData) -> Self; -} diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index be3944ba13..ee62145bb8 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,51 +1,28 @@ use crate::{ - comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}, - states::StateHandler, + comp::{CharacterState, StateUpdate}, + sys::character_state::JoinData, }; use std::{collections::VecDeque, time::Duration}; use vek::Vec3; const ROLL_SPEED: f32 = 17.0; -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State { - /// How long the state has until exitting - remaining_duration: Duration, -} - -impl StateHandler for State { - fn new(ecs_data: &EcsStateData) -> Self { - let tool_data = - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { - data - } else { - ToolData::default() - }; - Self { - remaining_duration: tool_data.attack_duration(), - } - } - - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - energy: *ecs_data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + if let CharacterState::Roll { remaining_duration } = data.character { // Update velocity update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) - + 1.5 - * ecs_data - .inputs - .move_dir - .try_normalized() - .unwrap_or_default()) + + 1.5 * data.inputs.move_dir.try_normalized().unwrap_or_default()) .try_normalized() .unwrap_or_default() * ROLL_SPEED; @@ -57,22 +34,21 @@ impl StateHandler for State { > 0.001 { update.ori.0 = - vek::ops::Slerp::slerp(update.ori.0, update.vel.0.into(), 9.0 * ecs_data.dt.0); + vek::ops::Slerp::slerp(update.ori.0, update.vel.0.into(), 9.0 * data.dt.0); } - if self.remaining_duration == Duration::default() { + if *remaining_duration == Duration::default() { // Roll duration has expired - update.character = CharacterState::Idle(None); + update.character = CharacterState::Idle {}; } else { // Otherwise, tick down remaining_duration - update.character = CharacterState::Roll(Some(State { - remaining_duration: self - .remaining_duration - .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) + update.character = CharacterState::Roll { + remaining_duration: remaining_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), - })); + }; } - - update } + + update } diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index 1da5fb6df3..9f329e83b3 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -1,38 +1,30 @@ use super::utils::*; use crate::{ - comp::{CharacterState, EcsStateData, StateUpdate}, - states::StateHandler, + comp::{CharacterState, StateUpdate}, + sys::character_state::JoinData, }; use std::collections::VecDeque; -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State; +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; -impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { Self {} } + handle_wield(data, &mut update); - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - energy: *ecs_data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; - - //handle_jump(ecs_data, &mut update); - handle_wield(ecs_data, &mut update); - - // Try to Fall/Stand up/Move - if !ecs_data.physics.on_ground - || ecs_data.inputs.sit.is_just_pressed() - || ecs_data.inputs.move_dir.magnitude_squared() > 0.0 - { - update.character = CharacterState::Idle(None); - } - - update + // Try to Fall/Stand up/Move + if !data.physics.on_ground + || data.inputs.sit.is_just_pressed() + || data.inputs.move_dir.magnitude_squared() > 0.0 + { + update.character = CharacterState::Idle {}; } + + update } diff --git a/common/src/states/stand.rs b/common/src/states/stand.rs index 37dd3c4bbe..c21a024b45 100644 --- a/common/src/states/stand.rs +++ b/common/src/states/stand.rs @@ -1,16 +1,16 @@ use super::utils::*; -use crate::comp::{EcsStateData, MoveState, StateUpdate}; -use crate::states::StateHandler; +use crate::{ + comp::{CharacterEntityData, MoveState, StateUpdate}, + states::StateHandler, +}; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { - Self {} - } + fn new(_ecs_data: &CharacterEntityData) -> Self { Self {} } - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { + fn handle(&self, ecs_data: &CharacterEntityData) -> StateUpdate { let mut update = StateUpdate { character: *ecs_data.character, pos: *ecs_data.pos, diff --git a/common/src/states/swim.rs b/common/src/states/swim.rs index 675e7b0478..4267731249 100644 --- a/common/src/states/swim.rs +++ b/common/src/states/swim.rs @@ -1,82 +1,56 @@ -use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; -use crate::states::StateHandler; -use crate::sys::phys::GRAVITY; +use crate::{ + comp::StateUpdate, + sys::{character_state::JoinData, phys::GRAVITY}, +}; use std::time::Duration; use vek::{Vec2, Vec3}; -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State; - const HUMANOID_WATER_ACCEL: f32 = 70.0; const HUMANOID_WATER_SPEED: f32 = 120.0; -impl StateHandler for State { - fn new(_ecs_data: &EcsStateData) -> Self { - Self {} - } +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, + // Update velocity + update.vel.0 += Vec2::broadcast(data.dt.0) + * data.inputs.move_dir + * if update.vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) { + HUMANOID_WATER_ACCEL + } else { + 0.0 }; - // Update velocity - update.vel.0 += Vec2::broadcast(ecs_data.dt.0) - * ecs_data.inputs.move_dir - * if update.vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) { - HUMANOID_WATER_ACCEL - } else { - 0.0 - }; + // Set direction based on move direction when on the ground + let ori_dir = if update.character.is_attack() || update.character.is_block() { + Vec2::from(data.inputs.look_dir).normalized() + } else { + Vec2::from(update.vel.0) + }; - // Set direction based on move direction when on the ground - let ori_dir = - if let ActionState::Attack(_) | ActionState::Block(_) = update.character.action_state { - Vec2::from(ecs_data.inputs.look_dir).normalized() - } else { - Vec2::from(update.vel.0) - }; - - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = vek::ops::Slerp::slerp( - update.ori.0, - ori_dir.into(), - if ecs_data.physics.on_ground { 9.0 } else { 2.0 } * ecs_data.dt.0, - ); - } - - // Force players to press jump in a slow rhythmic fashion to swim up - if ecs_data.inputs.jump.is_pressed() - && !ecs_data - .inputs - .jump - .is_long_press(Duration::from_millis(600)) - { - update.vel.0.z = - (update.vel.0.z + ecs_data.dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); - } - - // Not on ground - if !ecs_data.physics.on_ground { - update.character.move_state = MoveState::Swim(None); - update - } - // On ground - else { - // Return to running or standing based on move inputs - update.character.move_state = if ecs_data.inputs.move_dir.magnitude_squared() > 0.0 { - MoveState::Run(None) - } else { - MoveState::Stand(None) - }; - - update - } + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = vek::ops::Slerp::slerp( + update.ori.0, + ori_dir.into(), + if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, + ); } + + // Force players to pulse jump button to swim up + if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600)) + { + update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); + } + + update } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 14294a3631..73a51ed801 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,12 +1,24 @@ use crate::{ - comp::{Attacking, CharacterState, EcsStateData, EnergySource, ItemKind::Tool, StateUpdate}, + comp::{AbilityState, CharacterState, EnergySource, ItemKind::Tool, StateUpdate}, event::LocalEvent, + sys::{character_state::JoinData, phys::GRAVITY}, }; use std::time::Duration; use vek::vec::{Vec2, Vec3}; -pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) { - let (accel, speed): (f32, f32) = if ecs_data.physics.on_ground { +const HUMANOID_WATER_ACCEL: f32 = 70.0; +const HUMANOID_WATER_SPEED: f32 = 120.0; + +pub fn handle_move(data: &JoinData, update: &mut StateUpdate) { + if data.physics.in_fluid { + handle_swim_move(data, update); + } else { + handle_ground_move(data, update); + } +} + +pub fn handle_ground_move(data: &JoinData, update: &mut StateUpdate) { + let (accel, speed): (f32, f32) = if data.physics.on_ground { let accel = 100.0; let speed = 8.0; (accel, speed) @@ -18,8 +30,7 @@ pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) { // Move player according to move_dir if update.vel.0.magnitude_squared() < speed.powf(2.0) { - update.vel.0 = - update.vel.0 + Vec2::broadcast(ecs_data.dt.0) * ecs_data.inputs.move_dir * accel; + update.vel.0 = update.vel.0 + Vec2::broadcast(data.dt.0) * data.inputs.move_dir * accel; let mag2 = update.vel.0.magnitude_squared(); if mag2 > speed.powf(2.0) { update.vel.0 = update.vel.0.normalized() * speed; @@ -31,7 +42,7 @@ pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) { || update.character.is_attack() || update.character.is_block() { - Vec2::from(ecs_data.inputs.look_dir).normalized() + Vec2::from(data.inputs.look_dir).normalized() } else { Vec2::from(update.vel.0) }; @@ -41,94 +52,165 @@ pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) { && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 { - update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 9.0 * ecs_data.dt.0); + update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 9.0 * data.dt.0); } } -pub fn handle_wield(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if ecs_data.inputs.primary.is_pressed() { - update.character = CharacterState::Wielding(None); - } -} +pub fn handle_swim_move(data: &JoinData, update: &mut StateUpdate) { + // Update velocity + update.vel.0 += Vec2::broadcast(data.dt.0) + * data.inputs.move_dir + * if update.vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) { + HUMANOID_WATER_ACCEL + } else { + 0.0 + }; -pub fn handle_sit(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if ecs_data.inputs.sit.is_pressed() && ecs_data.physics.on_ground && ecs_data.body.is_humanoid() + // Set direction based on move direction when on the ground + let ori_dir = if update.character.is_attack() || update.character.is_block() { + Vec2::from(data.inputs.look_dir).normalized() + } else { + Vec2::from(update.vel.0) + }; + + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 { - update.character = CharacterState::Sit(None); + update.ori.0 = vek::ops::Slerp::slerp( + update.ori.0, + ori_dir.into(), + if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, + ); + } + + // Force players to pulse jump button to swim up + if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600)) + { + update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); } } -pub fn handle_climb(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if (ecs_data.inputs.climb.is_pressed() || ecs_data.inputs.climb_down.is_pressed()) - && ecs_data.physics.on_wall.is_some() - && !ecs_data.physics.on_ground +pub fn handle_wield(data: &JoinData, update: &mut StateUpdate) { + if data.inputs.primary.is_pressed() { + if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { + update.character = CharacterState::Equipping { + tool, + time_left: tool.equip_time(), + }; + } else { + update.character = CharacterState::Idle {}; + }; + } +} + +pub fn handle_sit(data: &JoinData, update: &mut StateUpdate) { + if data.inputs.sit.is_pressed() && data.physics.on_ground && data.body.is_humanoid() { + update.character = CharacterState::Sit {}; + } +} + +pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { + if (data.inputs.climb.is_pressed() || data.inputs.climb_down.is_pressed()) + && data.physics.on_wall.is_some() + && !data.physics.on_ground //&& update.vel.0.z < 0.0 - && ecs_data.body.is_humanoid() + && data.body.is_humanoid() { - update.character = CharacterState::Climb(None); + update.character = CharacterState::Climb {}; } } -pub fn handle_unwield(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if let CharacterState::Wielded(_) = update.character { - if ecs_data.inputs.toggle_wield.is_pressed() { - update.character = CharacterState::Idle(None); +pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) { + if let CharacterState::Wielding { .. } = update.character { + if data.inputs.toggle_wield.is_pressed() { + update.character = CharacterState::Idle {}; } } } -pub fn handle_glide(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if let CharacterState::Idle(_) | CharacterState::Wielded(_) = update.character { - if ecs_data.inputs.glide.is_pressed() - && !ecs_data.physics.on_ground - && ecs_data.body.is_humanoid() - { - update.character = CharacterState::Glide(None); +pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) { + if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { + if data.inputs.glide.is_pressed() && !data.physics.on_ground && data.body.is_humanoid() { + update.character = CharacterState::Glide {}; } } } -pub fn handle_jump(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if ecs_data.inputs.jump.is_pressed() && ecs_data.physics.on_ground { +pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { + if data.inputs.jump.is_pressed() && data.physics.on_ground { update .local_events - .push_front(LocalEvent::Jump(*ecs_data.entity)); + .push_front(LocalEvent::Jump(data.entity)); } } -pub fn handle_primary(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if let Some(state) = ecs_data.ability_pool.primary { - if let CharacterState::Wielded(_) = update.character { - if ecs_data.inputs.primary.is_pressed() { - update.character = state; +pub fn handle_primary(data: &JoinData, update: &mut StateUpdate) { + if let Some(state) = data.ability_pool.primary { + if let CharacterState::Wielding { .. } = update.character { + if data.inputs.primary.is_pressed() { + // data.updater.insert(data.entity, state); + update.character = character_state_from_ability(data, state); } } } } -pub fn handle_secondary(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if let Some(state) = ecs_data.ability_pool.secondary { - if let CharacterState::Wielded(_) = update.character { - if ecs_data.inputs.secondary.is_pressed() { - update.character = state; +pub fn handle_secondary(data: &JoinData, update: &mut StateUpdate) { + if let Some(state) = data.ability_pool.secondary { + if let CharacterState::Wielding { .. } = update.character { + if data.inputs.secondary.is_pressed() { + // data.updater.insert(data.entity, state); + update.character = character_state_from_ability(data, state); } } } } -pub fn handle_dodge(ecs_data: &EcsStateData, update: &mut StateUpdate) { - if let Some(state) = ecs_data.ability_pool.dodge { - if let CharacterState::Idle(_) | CharacterState::Wielded(_) = update.character { - if ecs_data.inputs.roll.is_pressed() - && ecs_data.physics.on_ground - && ecs_data.body.is_humanoid() +pub fn handle_dodge(data: &JoinData, update: &mut StateUpdate) { + if let Some(state) = data.ability_pool.dodge { + if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { + if data.inputs.roll.is_pressed() + && data.physics.on_ground + && data.body.is_humanoid() && update .energy .try_change_by(-200, EnergySource::Roll) .is_ok() { - update.character = state; + // let tool_data = + // if let Some(Tool(data)) = data.stats.equipment.main.as_ref().map(|i| + // i.kind) { data + // } else { + // ToolData::default() + // }; + update.character = CharacterState::Roll { + remaining_duration: Duration::from_millis(600), // tool_data.attack_duration(), + }; + data.updater.insert(data.entity, state); } } } } + +pub fn character_state_from_ability( + data: &JoinData, + ability_state: AbilityState, +) -> CharacterState { + match ability_state { + AbilityState::BasicAttack { .. } => { + if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { + CharacterState::BasicAttack { + exhausted: false, + remaining_duration: tool.attack_duration(), + } + } else { + CharacterState::Idle {} + } + }, + AbilityState::BasicBlock { .. } => CharacterState::BasicBlock {}, + AbilityState::Roll { .. } => CharacterState::Roll { + remaining_duration: Duration::from_millis(600), + }, + } +} diff --git a/common/src/states/wielded.rs b/common/src/states/wielded.rs deleted file mode 100644 index 545a38dca6..0000000000 --- a/common/src/states/wielded.rs +++ /dev/null @@ -1,51 +0,0 @@ -use super::utils::*; -use crate::{ - comp::{EcsStateData, ItemKind::Tool, StateUpdate, ToolData}, - states::StateHandler, -}; -use std::{collections::VecDeque, time::Duration}; - -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State { - /// How long before a new action can be performed - /// after equipping - pub equip_delay: Duration, -} - -impl StateHandler for State { - fn new(ecs_data: &EcsStateData) -> Self { - let tool_data = - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { - data - } else { - ToolData::default() - }; - Self { - equip_delay: tool_data.equip_time(), - } - } - - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - energy: *ecs_data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; - - handle_move_dir(&ecs_data, &mut update); - handle_jump(&ecs_data, &mut update); - handle_sit(&ecs_data, &mut update); - handle_climb(&ecs_data, &mut update); - handle_glide(&ecs_data, &mut update); - handle_unwield(&ecs_data, &mut update); - handle_primary(&ecs_data, &mut update); - handle_secondary(&ecs_data, &mut update); - handle_dodge(&ecs_data, &mut update); - - update - } -} diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 58da3c22b0..eaf054762f 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -1,56 +1,27 @@ use super::utils::*; -use crate::{ - comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}, - states::StateHandler, -}; -use std::{collections::VecDeque, time::Duration}; +use crate::{comp::StateUpdate, sys::character_state::JoinData}; +use std::collections::VecDeque; -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State { - /// How long before a new action can be performed - /// after equipping - pub equip_delay: Duration, -} - -impl StateHandler for State { - fn new(ecs_data: &EcsStateData) -> Self { - let equip_delay = - if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) { - data.equip_time() - } else { - Duration::default() - }; - - Self { equip_delay } - } - - fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate { - let mut update = StateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - energy: *ecs_data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; - - handle_move_dir(&ecs_data, &mut update); - - if self.equip_delay == Duration::default() { - // Wield delay has expired - update.character = CharacterState::Wielded(None); - } else { - // Wield delay hasn't expired yet - // Update wield delay - update.character = CharacterState::Wielding(Some(State { - equip_delay: self - .equip_delay - .checked_sub(Duration::from_secs_f32(ecs_data.dt.0)) - .unwrap_or_default(), - })); - } - - update - } +pub fn behavior(ecs_data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *ecs_data.character, + pos: *ecs_data.pos, + vel: *ecs_data.vel, + ori: *ecs_data.ori, + energy: *ecs_data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + + handle_move(&ecs_data, &mut update); + handle_jump(&ecs_data, &mut update); + handle_sit(&ecs_data, &mut update); + handle_climb(&ecs_data, &mut update); + handle_glide(&ecs_data, &mut update); + handle_unwield(&ecs_data, &mut update); + handle_primary(&ecs_data, &mut update); + handle_secondary(&ecs_data, &mut update); + handle_dodge(&ecs_data, &mut update); + + update } diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_state.rs index a87a7b92ab..b703617cf6 100644 --- a/common/src/sys/character_state.rs +++ b/common/src/sys/character_state.rs @@ -1,20 +1,79 @@ use crate::{ comp::{ - AbilityPool, Body, CharacterState, Controller, EcsStateData, Energy, Mounting, Ori, - PhysicsState, Pos, Stats, Vel, + AbilityPool, Body, CharacterState, Controller, ControllerInputs, Energy, Mounting, Ori, + PhysicsState, Pos, StateUpdate, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, + states, sync::{Uid, UidAllocator}, }; -use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; +use specs::{Entities, Entity, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; -/// ## Character State System +use std::collections::VecDeque; + +/// Read-Only Data sent from Character Behavior System to bahvior fn's +pub struct JoinData<'a> { + pub entity: Entity, + pub uid: &'a Uid, + pub character: &'a CharacterState, + pub pos: &'a Pos, + pub vel: &'a Vel, + pub ori: &'a Ori, + pub dt: &'a DeltaTime, + pub controller: &'a Controller, + pub inputs: &'a ControllerInputs, + pub stats: &'a Stats, + pub energy: &'a Energy, + pub body: &'a Body, + pub physics: &'a PhysicsState, + pub ability_pool: &'a AbilityPool, + pub updater: &'a LazyUpdate, +} + +pub type JoinTuple<'a> = ( + Entity, + &'a Uid, + &'a mut CharacterState, + &'a mut Pos, + &'a mut Vel, + &'a mut Ori, + &'a mut Energy, + &'a Controller, + &'a Stats, + &'a Body, + &'a PhysicsState, + &'a AbilityPool, +); + +impl<'a> JoinData<'a> { + fn new(j: &'a JoinTuple<'a>, updater: &'a LazyUpdate, dt: &'a DeltaTime) -> Self { + Self { + entity: j.0, + uid: j.1, + character: j.2, + pos: j.3, + vel: j.4, + ori: j.5, + energy: j.6, + controller: j.7, + inputs: &j.7.inputs, + stats: j.8, + body: j.9, + physics: j.10, + ability_pool: j.11, + updater, + dt, + } + } +} + +/// /// ## Character State System /// #### Calls updates to `CharacterState`s. Acts on tuples of ( /// `CharacterState`, `Pos`, `Vel`, and `Ori` ). /// -/// _System forms `EcsStateData` tuples and passes those to `ActionState` +/// _System forms `CharacterEntityData` tuples and passes those to `ActionState` /// `update()` fn, then does the same for `MoveState` `update`_ pub struct Sys; @@ -63,20 +122,7 @@ impl<'a> System<'a> for Sys { mountings, ): Self::SystemData, ) { - for ( - entity, - uid, - character, - pos, - vel, - ori, - energy, - controller, - stats, - body, - physics, - ability_pool, - ) in ( + let mut join_iter = ( &entities, &uids, &mut character_states, @@ -90,50 +136,56 @@ impl<'a> System<'a> for Sys { &physics_states, &ability_pools, ) - .join() - { - let inputs = &controller.inputs; + .join(); + + while let Some(tuple) = join_iter.next() { + let j = JoinData::new(&tuple, &updater, &dt); + let inputs = &j.inputs; // Being dead overrides all other states - if stats.is_dead { + if j.stats.is_dead { // Only options: click respawn // prevent instant-respawns (i.e. player was holding attack) // by disallowing while input is held down if inputs.respawn.is_pressed() && !inputs.respawn.is_held_down() { - server_bus.emitter().emit(ServerEvent::Respawn(entity)); + server_bus.emitter().emit(ServerEvent::Respawn(j.entity)); } // Or do nothing return; } // If mounted, character state is controlled by mount // TODO: Make mounting a state - if let Some(Mounting(_)) = mountings.get(entity) { - *character = CharacterState::Sit(None); + if let Some(Mounting(_)) = mountings.get(j.entity) { + *tuple.2 = CharacterState::Sit {}; return; } - let mut state_update = character.update(&EcsStateData { - entity: &entity, - uid, - character, - pos, - vel, - ori, - energy, - dt: &dt, - inputs, - stats, - body, - physics, - updater: &updater, - ability_pool, - }); + let mut state_update = match j.character { + CharacterState::Idle { .. } => states::idle::behavior(&j), + CharacterState::Climb { .. } => states::climb::behavior(&j), + CharacterState::Glide { .. } => states::glide::behavior(&j), + CharacterState::Roll { .. } => states::roll::behavior(&j), + CharacterState::Wielding { .. } => states::wielding::behavior(&j), + CharacterState::Equipping { .. } => states::equipping::behavior(&j), + CharacterState::BasicAttack { .. } => states::basic_attack::behavior(&j), + CharacterState::Sit { .. } => states::sit::behavior(&j), - *character = state_update.character; - *pos = state_update.pos; - *vel = state_update.vel; - *ori = state_update.ori; - *energy = state_update.energy; + _ => StateUpdate { + character: *j.character, + pos: *j.pos, + vel: *j.vel, + ori: *j.ori, + energy: *j.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }, + }; + + *tuple.2 = state_update.character; + *tuple.3 = state_update.pos; + *tuple.4 = state_update.vel; + *tuple.5 = state_update.ori; + *tuple.6 = state_update.energy; local_bus.emitter().append(&mut state_update.local_events); server_bus.emitter().append(&mut state_update.server_events); } diff --git a/common/src/sys/stats.rs b/common/src/sys/stats.rs index 20c1ce2dc4..25b92017dd 100644 --- a/common/src/sys/stats.rs +++ b/common/src/sys/stats.rs @@ -75,7 +75,7 @@ impl<'a> System<'a> for Sys { // Accelerate recharging energy if not wielding. match character_state { - CharacterState::Idle(_) => { + CharacterState::Idle { .. } => { if { let energy = energy.get_unchecked(); energy.current() < energy.maximum() @@ -92,7 +92,7 @@ impl<'a> System<'a> for Sys { } }, // Wield does not regen and sets the rate back to zero. - CharacterState::Wielded(_) => { + CharacterState::Wielding { .. } => { if energy.get_unchecked().regen_rate != 0.0 { energy.get_mut_unchecked().regen_rate = 0.0 } diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index 87479d6c01..025a1ae72f 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -202,10 +202,10 @@ impl MovementEventMapper { // Match all other Movemement and Action states match (previous_state.event, character_state) { - (_, CharacterState::Roll(_)) => SfxEvent::Roll, - (_, CharacterState::Climb(_)) => SfxEvent::Climb, - (SfxEvent::Glide, CharacterState::Idle(_)) => SfxEvent::GliderClose, - (previous_event, CharacterState::Glide(_)) => { + (_, CharacterState::Roll { .. }) => SfxEvent::Roll, + (_, CharacterState::Climb { .. }) => SfxEvent::Climb, + (SfxEvent::Glide, CharacterState::Idle { .. }) => SfxEvent::GliderClose, + (previous_event, CharacterState::Glide { .. }) => { if previous_event != SfxEvent::GliderOpen && previous_event != SfxEvent::Glide { SfxEvent::GliderOpen } else { @@ -226,13 +226,13 @@ impl MovementEventMapper { } /// This helps us determine whether we should be emitting the Wield/Unwield - /// events. For now, consider either CharacterState::Wielded or - /// ::Wielding to mean the weapon is drawn. This will need updating if the + /// events. For now, consider either CharacterState::Wielding or + /// ::Equipping to mean the weapon is drawn. This will need updating if the /// animations change to match the wield_duration associated with the weapon fn weapon_drawn(character: &CharacterState) -> bool { character.is_wielded() || match character { - CharacterState::Wielding(_) => true, + CharacterState::Equipping { .. } => true, _ => false, } } diff --git a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs index 5d898ca73f..c978efc55d 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs @@ -91,7 +91,7 @@ fn maps_idle() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Idle(None), + &CharacterState::Idle {}, &PhysicsState { on_ground: true, on_wall: None, @@ -120,7 +120,7 @@ fn maps_run_with_sufficient_velocity() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Idle(None), + &CharacterState::Idle {}, &PhysicsState { on_ground: true, on_wall: None, @@ -149,7 +149,7 @@ fn does_not_map_run_with_insufficient_velocity() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Idle(None), + &CharacterState::Idle {}, &PhysicsState { on_ground: true, on_wall: None, @@ -178,7 +178,7 @@ fn does_not_map_run_with_sufficient_velocity_but_not_on_ground() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Idle(None), + &CharacterState::Idle {}, &PhysicsState { on_ground: false, on_wall: None, @@ -207,7 +207,7 @@ fn maps_roll() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Roll(None), + &CharacterState::Roll {}, &PhysicsState { on_ground: true, on_wall: None, @@ -236,7 +236,7 @@ fn maps_land_on_ground_to_run() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Idle(None), + &CharacterState::Idle {}, &PhysicsState { on_ground: true, on_wall: None, @@ -265,7 +265,7 @@ fn maps_glider_open() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Glide(None), + &CharacterState::Glide {}, &PhysicsState { on_ground: false, on_wall: None, @@ -294,7 +294,7 @@ fn maps_glide() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Glide(None), + &CharacterState::Glide {}, &PhysicsState { on_ground: false, on_wall: None, @@ -323,7 +323,7 @@ fn maps_glider_close_when_closing_mid_flight() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Idle(None), + &CharacterState::Idle {}, &PhysicsState { on_ground: false, on_wall: None, @@ -352,7 +352,7 @@ fn maps_glider_close_when_landing() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Idle(None), + &CharacterState::Idle {}, &PhysicsState { on_ground: true, on_wall: None, @@ -383,7 +383,7 @@ fn maps_wield() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Wielding(None), + &CharacterState::Equipping {}, &PhysicsState { on_ground: true, on_wall: None, @@ -443,7 +443,7 @@ fn does_not_map_wield_when_no_main_weapon() { ); let result = MovementEventMapper::map_movement_event( - &CharacterState::Wielded(None), + &CharacterState::Wielding {}, &PhysicsState { on_ground: true, on_wall: None, diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 3290c3fc23..35bdf5cbcc 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -170,10 +170,10 @@ impl FigureModelCache { if camera_mode != CameraMode::FirstPerson || character_state .map(|cs| match cs { - CharacterState::BasicAttack(_) - | CharacterState::BasicBlock(_) - | CharacterState::Wielding(_) - | CharacterState::Wielded(_) => true, + CharacterState::BasicAttack { .. } + | CharacterState::BasicBlock { .. } + | CharacterState::Equipping { .. } + | CharacterState::Wielding { .. } => true, _ => false, }) .unwrap_or_default() diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 4313677564..80eea9d095 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -441,14 +441,16 @@ impl FigureMgr { ), }; let target_bones = match &character { - CharacterState::Roll(_) => anim::character::RollAnimation::update_skeleton( - &target_base, - (active_tool_kind, ori.0, state.last_ori, time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ), - CharacterState::BasicAttack(_) => { + CharacterState::Roll { .. } => { + anim::character::RollAnimation::update_skeleton( + &target_base, + (active_tool_kind, ori.0, state.last_ori, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, + CharacterState::BasicAttack { .. } => { anim::character::AttackAnimation::update_skeleton( &target_base, (active_tool_kind, time), @@ -457,7 +459,7 @@ impl FigureMgr { skeleton_attr, ) }, - CharacterState::BasicBlock(_) => { + CharacterState::BasicBlock { .. } => { anim::character::BlockIdleAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, time), @@ -476,7 +478,7 @@ impl FigureMgr { skeleton_attr, ) }*/ - CharacterState::Wielding(_) => { + CharacterState::Equipping { .. } => { anim::character::WieldAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), @@ -485,7 +487,7 @@ impl FigureMgr { skeleton_attr, ) }, - CharacterState::Wielded(_) => { + CharacterState::Wielding { .. } => { anim::character::WieldAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), @@ -494,7 +496,7 @@ impl FigureMgr { skeleton_attr, ) }, - CharacterState::Glide(_) => { + CharacterState::Glide { .. } => { anim::character::GlidingAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0, ori.0, state.last_ori, time), @@ -503,7 +505,7 @@ impl FigureMgr { skeleton_attr, ) }, - CharacterState::Climb(_) => { + CharacterState::Climb { .. } => { anim::character::ClimbAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0, ori.0, time), @@ -512,13 +514,15 @@ impl FigureMgr { skeleton_attr, ) }, - CharacterState::Sit(_) => anim::character::SitAnimation::update_skeleton( - &CharacterSkeleton::new(), - (active_tool_kind, time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ), + CharacterState::Sit { .. } => { + anim::character::SitAnimation::update_skeleton( + &CharacterSkeleton::new(), + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, _ => target_base, }; From cb9e3859daf62155e6fa47d6f765dc1395bfa8fd Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 7 Mar 2020 11:02:54 -0800 Subject: [PATCH 045/326] Rename character behavior sys --- common/src/states/basic_attack.rs | 2 +- common/src/states/basic_block.rs | 2 +- common/src/states/charge_attack.rs | 2 +- common/src/states/climb.rs | 2 +- common/src/states/equipping.rs | 2 +- common/src/states/glide.rs | 2 +- common/src/states/idle.rs | 2 +- common/src/states/roll.rs | 2 +- common/src/states/sit.rs | 2 +- common/src/states/swim.rs | 2 +- common/src/states/utils.rs | 2 +- common/src/states/wielding.rs | 2 +- .../src/sys/{character_state.rs => character_behavior.rs} | 0 common/src/sys/mod.rs | 8 +++++--- 14 files changed, 17 insertions(+), 15 deletions(-) rename common/src/sys/{character_state.rs => character_behavior.rs} (100%) diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index e144420f8f..a2ea1838c3 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -1,7 +1,7 @@ use crate::{ comp::{Attacking, CharacterState, ItemKind::Tool, StateUpdate}, states::utils::*, - sys::character_state::JoinData, + sys::character_behavior::JoinData, }; use std::{collections::VecDeque, time::Duration}; diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index 9781b7cc10..6dc909b1ec 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -4,7 +4,7 @@ use crate::{ }; use std::{collections::VecDeque, time::Duration}; use vek::Vec2; -use crate::sys::character_state::JoinData; +use crate::sys::character_behavior::JoinData; const BLOCK_ACCEL: f32 = 30.0; const BLOCK_SPEED: f32 = 75.0; diff --git a/common/src/states/charge_attack.rs b/common/src/states/charge_attack.rs index 5dbd9001a4..82e229de78 100644 --- a/common/src/states/charge_attack.rs +++ b/common/src/states/charge_attack.rs @@ -5,7 +5,7 @@ use crate::{ ItemKind::Tool, MoveState::Run, StateUpdate, ToolData, }, event::ServerEvent, - sys::character_state::JoinData, + sys::character_behavior::JoinData, }; use std::time::Duration; use vek::Vec3; diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index ee7bf3257d..6d5f09b1ea 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -1,7 +1,7 @@ use crate::{ comp::{CharacterState, EnergySource, StateUpdate}, event::LocalEvent, - sys::{character_state::JoinData, phys::GRAVITY}, + sys::{character_behavior::JoinData, phys::GRAVITY}, }; use std::collections::VecDeque; use vek::{ diff --git a/common/src/states/equipping.rs b/common/src/states/equipping.rs index 8d6004114f..27ae4f1122 100644 --- a/common/src/states/equipping.rs +++ b/common/src/states/equipping.rs @@ -1,7 +1,7 @@ use super::utils::*; use crate::{ comp::{CharacterState, StateUpdate}, - sys::character_state::JoinData, + sys::character_behavior::JoinData, }; use std::{collections::VecDeque, time::Duration}; diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 4a7d22c997..239f250f72 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,6 +1,6 @@ use crate::{ comp::{CharacterState, StateUpdate}, - sys::character_state::JoinData, + sys::character_behavior::JoinData, }; use std::collections::VecDeque; use vek::{Vec2, Vec3}; diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index 3e16c39f64..c2df18be36 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -1,5 +1,5 @@ use super::utils::*; -use crate::{comp::StateUpdate, sys::character_state::JoinData}; +use crate::{comp::StateUpdate, sys::character_behavior::JoinData}; use std::collections::VecDeque; pub fn behavior(data: &JoinData) -> StateUpdate { diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index ee62145bb8..cc2a570b7b 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,6 +1,6 @@ use crate::{ comp::{CharacterState, StateUpdate}, - sys::character_state::JoinData, + sys::character_behavior::JoinData, }; use std::{collections::VecDeque, time::Duration}; use vek::Vec3; diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index 9f329e83b3..89c312d3c2 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -1,7 +1,7 @@ use super::utils::*; use crate::{ comp::{CharacterState, StateUpdate}, - sys::character_state::JoinData, + sys::character_behavior::JoinData, }; use std::collections::VecDeque; diff --git a/common/src/states/swim.rs b/common/src/states/swim.rs index 4267731249..0cb327296e 100644 --- a/common/src/states/swim.rs +++ b/common/src/states/swim.rs @@ -1,6 +1,6 @@ use crate::{ comp::StateUpdate, - sys::{character_state::JoinData, phys::GRAVITY}, + sys::{character_behavior::JoinData, phys::GRAVITY}, }; use std::time::Duration; use vek::{Vec2, Vec3}; diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 73a51ed801..7608c671d3 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,7 +1,7 @@ use crate::{ comp::{AbilityState, CharacterState, EnergySource, ItemKind::Tool, StateUpdate}, event::LocalEvent, - sys::{character_state::JoinData, phys::GRAVITY}, + sys::{character_behavior::JoinData, phys::GRAVITY}, }; use std::time::Duration; use vek::vec::{Vec2, Vec3}; diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index eaf054762f..1edc0bf78c 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -1,5 +1,5 @@ use super::utils::*; -use crate::{comp::StateUpdate, sys::character_state::JoinData}; +use crate::{comp::StateUpdate, sys::character_behavior::JoinData}; use std::collections::VecDeque; pub fn behavior(ecs_data: &JoinData) -> StateUpdate { diff --git a/common/src/sys/character_state.rs b/common/src/sys/character_behavior.rs similarity index 100% rename from common/src/sys/character_state.rs rename to common/src/sys/character_behavior.rs diff --git a/common/src/sys/mod.rs b/common/src/sys/mod.rs index 6deb55ff11..1e478ea87c 100644 --- a/common/src/sys/mod.rs +++ b/common/src/sys/mod.rs @@ -1,5 +1,5 @@ pub mod agent; -pub mod character_state; +pub mod character_behavior; mod combat; pub mod controller; mod mount; @@ -11,7 +11,7 @@ mod stats; use specs::DispatcherBuilder; // System names -pub const CHARACTER_STATE_SYS: &str = "character_state_sys"; +pub const CHARACTER_BEHAVIOR_SYS: &str = "character_behavior_sys"; pub const COMBAT_SYS: &str = "combat_sys"; pub const AGENT_SYS: &str = "agent_sys"; pub const CONTROLLER_SYS: &str = "controller_sys"; @@ -24,7 +24,9 @@ pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) { dispatch_builder.add(agent::Sys, AGENT_SYS, &[]); dispatch_builder.add(mount::Sys, MOUNT_SYS, &[AGENT_SYS]); dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS, MOUNT_SYS]); - dispatch_builder.add(character_state::Sys, CHARACTER_STATE_SYS, &[CONTROLLER_SYS]); + dispatch_builder.add(character_behavior::Sys, CHARACTER_BEHAVIOR_SYS, &[ + CONTROLLER_SYS, + ]); dispatch_builder.add(stats::Sys, STATS_SYS, &[]); dispatch_builder.add(phys::Sys, PHYS_SYS, &[CONTROLLER_SYS, MOUNT_SYS, STATS_SYS]); dispatch_builder.add(projectile::Sys, PROJECTILE_SYS, &[PHYS_SYS]); From c678ca95409c8924ade93bbe818a01b0945e111b Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 7 Mar 2020 11:55:15 -0800 Subject: [PATCH 046/326] Re-add blocking --- common/src/comp/ability.rs | 2 +- common/src/states/basic_block.rs | 49 +++++++++++++++------------- common/src/states/mod.rs | 2 +- common/src/sys/character_behavior.rs | 1 + 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 4f9daa7162..9210ee6b02 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -26,7 +26,7 @@ impl Default for AbilityPool { fn default() -> Self { Self { primary: Some(AbilityState::BasicAttack), - secondary: Some(AbilityState::BasicAttack), + secondary: Some(AbilityState::BasicBlock), block: None, dodge: Some(AbilityState::Roll), } diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index 6dc909b1ec..8c5444b6bf 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -1,32 +1,35 @@ use super::utils::*; use crate::{ - comp::{CharacterEntityData, CharacterState, StateUpdate}, + comp::{CharacterState, ItemKind, StateUpdate}, + sys::character_behavior::JoinData, }; -use std::{collections::VecDeque, time::Duration}; -use vek::Vec2; -use crate::sys::character_behavior::JoinData; +use std::collections::VecDeque; -const BLOCK_ACCEL: f32 = 30.0; -const BLOCK_SPEED: f32 = 75.0; +// const BLOCK_ACCEL: f32 = 30.0; +// const BLOCK_SPEED: f32 = 75.0; +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; - pub fn handle(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: *data.character, - local_events: VecDeque::new(), - server_events: VecDeque::new(), + handle_move(&data, &mut update); + + if !data.physics.on_ground || !data.inputs.secondary.is_pressed() { + if let Some(ItemKind::Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { + update.character = CharacterState::Equipping { + tool, + time_left: tool.equip_time(), + }; + } else { + update.character = CharacterState::Idle {}; }; - - handle_move(&data, &mut update); - - if !data.physics.on_ground || !data.inputs.secondary.is_pressed() { - update.character = CharacterState::Wielding{}; - } - - update } + update } diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 9a9c62a9b3..2375e7d586 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -1,6 +1,6 @@ // Module declarations pub mod basic_attack; -// pub mod basic_block; +pub mod basic_block; pub mod climb; pub mod equipping; pub mod glide; diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index b703617cf6..576e95c30d 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -168,6 +168,7 @@ impl<'a> System<'a> for Sys { CharacterState::Wielding { .. } => states::wielding::behavior(&j), CharacterState::Equipping { .. } => states::equipping::behavior(&j), CharacterState::BasicAttack { .. } => states::basic_attack::behavior(&j), + CharacterState::BasicBlock { .. } => states::basic_block::behavior(&j), CharacterState::Sit { .. } => states::sit::behavior(&j), _ => StateUpdate { From 54a7112ad9386c1b247402346718b25899b0b9e8 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 7 Mar 2020 12:49:48 -0800 Subject: [PATCH 047/326] resolve conflicts merging master -> clientstates --- common/src/comp/character_state.rs | 2 +- common/src/comp/inventory/mod.rs | 2 +- common/src/event.rs | 6 +-- common/src/states/utils.rs | 2 +- common/src/sys/movement.rs | 2 +- voxygen/src/anim/character/attack.rs | 2 +- voxygen/src/anim/character/block.rs | 2 +- voxygen/src/anim/character/blockidle.rs | 2 +- voxygen/src/anim/character/cidle.rs | 2 +- voxygen/src/anim/character/crun.rs | 16 +++--- voxygen/src/anim/character/stand.rs | 2 +- voxygen/src/anim/character/wield.rs | 2 +- .../audio/sfx/event_mapper/movement/mod.rs | 50 +------------------ voxygen/src/scene/figure/cache.rs | 4 +- voxygen/src/scene/mod.rs | 2 +- 15 files changed, 24 insertions(+), 74 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 22c49e0fe7..bdabd39759 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -50,7 +50,7 @@ pub enum CharacterState { } impl CharacterState { - pub fn is_wielded(&self) -> bool { + pub fn is_wield(&self) -> bool { match self { CharacterState::Wielding { .. } => true, CharacterState::BasicAttack { .. } => true, diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index f192208b5c..9f15789a9d 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -1,7 +1,7 @@ pub mod item; // Reexports -pub use item::{Consumable, Debug, Item, ItemKind, Tool}; +pub use item::{Consumable, Debug, Item, ItemKind, SwordKind, ToolData, ToolKind}; use crate::assets; use specs::{Component, FlaggedStorage, HashMapStorage}; diff --git a/common/src/event.rs b/common/src/event.rs index 188c994ae8..e14ac62bfb 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -1,5 +1,5 @@ use crate::{comp, sync::Uid}; -use comp::{item::Tool, InventoryUpdateEvent}; +use comp::{item::ToolData, InventoryUpdateEvent}; use parking_lot::Mutex; use serde::Deserialize; use specs::Entity as EcsEntity; @@ -40,8 +40,8 @@ pub enum SfxEvent { Fall, ExperienceGained, LevelUp, - Wield(Tool), - Unwield(Tool), + Wield(ToolData), + Unwield(ToolData), Inventory(InventoryUpdateEvent), } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 7608c671d3..2745e1fc86 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -38,7 +38,7 @@ pub fn handle_ground_move(data: &JoinData, update: &mut StateUpdate) { } // Set direction based on move direction - let ori_dir = if update.character.is_wielded() + let ori_dir = if update.character.is_wield() || update.character.is_attack() || update.character.is_block() { diff --git a/common/src/sys/movement.rs b/common/src/sys/movement.rs index 439ff9ceea..b0f41858f4 100644 --- a/common/src/sys/movement.rs +++ b/common/src/sys/movement.rs @@ -121,7 +121,7 @@ impl<'a> System<'a> for Sys { let inputs = &controller.inputs; - if character.action.is_roll() { + if character.action.is_dodge() { vel.0 = Vec3::new(0.0, 0.0, vel.0.z) + (vel.0 * Vec3::new(1.0, 1.0, 0.0) + 1.5 * inputs.move_dir.try_normalized().unwrap_or_default()) diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index e9701476d4..8e376c6f7b 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -62,7 +62,7 @@ impl Animation for AttackAnimation { match active_tool_kind { //TODO: Inventory - Some(Tool::Sword(_)) => { + Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.04; diff --git a/voxygen/src/anim/character/block.rs b/voxygen/src/anim/character/block.rs index 6c55878e96..62195f3853 100644 --- a/voxygen/src/anim/character/block.rs +++ b/voxygen/src/anim/character/block.rs @@ -62,7 +62,7 @@ impl Animation for BlockAnimation { match active_tool_kind { //TODO: Inventory - Some(Tool::Sword(_)) => { + Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.04; diff --git a/voxygen/src/anim/character/blockidle.rs b/voxygen/src/anim/character/blockidle.rs index 94f18c2571..8e7ec674e3 100644 --- a/voxygen/src/anim/character/blockidle.rs +++ b/voxygen/src/anim/character/blockidle.rs @@ -61,7 +61,7 @@ impl Animation for BlockIdleAnimation { match active_tool_kind { //TODO: Inventory - Some(Tool::Sword(_)) => { + Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.04; diff --git a/voxygen/src/anim/character/cidle.rs b/voxygen/src/anim/character/cidle.rs index 71e61a55cc..d72262fb69 100644 --- a/voxygen/src/anim/character/cidle.rs +++ b/voxygen/src/anim/character/cidle.rs @@ -62,7 +62,7 @@ impl Animation for CidleAnimation { match active_tool_kind { //TODO: Inventory - Some(Tool::Sword(_)) => { + Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0); next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2); next.l_hand.scale = Vec3::one() * 1.04; diff --git a/voxygen/src/anim/character/crun.rs b/voxygen/src/anim/character/crun.rs index bc6448ac5b..fe28dc3770 100644 --- a/voxygen/src/anim/character/crun.rs +++ b/voxygen/src/anim/character/crun.rs @@ -37,9 +37,9 @@ impl Animation for WieldAnimation { * 0.1, ); - match Tool::Bow { + match ToolKind::Bow { //TODO: Inventory - Some(Tool::Sword(_)) => { + Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.04; @@ -58,7 +58,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.control.scale = Vec3::one(); }, - Tool::Axe => { + ToolKind::Axe => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; @@ -75,7 +75,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.weapon.scale = Vec3::one(); }, - Tool::Hammer => { + ToolKind::Hammer => { next.l_hand.offset = Vec3::new(-7.0, 8.25, 3.0); next.l_hand.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(-1.2) @@ -96,7 +96,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(wave * -0.25); next.weapon.scale = Vec3::one(); }, - Tool::Staff => { + ToolKind::Staff => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; @@ -113,7 +113,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.weapon.scale = Vec3::one(); }, - Tool::SwordShield => { + ToolKind::SwordShield => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; @@ -130,7 +130,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.weapon.scale = Vec3::one(); }, - Tool::Bow => { + ToolKind::Bow => { next.l_hand.offset = Vec3::new(-4.0, 5.0, 0.0); next.l_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(-1.9) @@ -151,7 +151,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.85 + 3.14); next.weapon.scale = Vec3::one(); }, - Tool::Daggers => { + ToolKind::Daggers => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; diff --git a/voxygen/src/anim/character/stand.rs b/voxygen/src/anim/character/stand.rs index 6e2cb811e8..c66afb21b4 100644 --- a/voxygen/src/anim/character/stand.rs +++ b/voxygen/src/anim/character/stand.rs @@ -1,5 +1,5 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; -use common::comp::item::Tool; +use common::comp::item::ToolKind; use std::ops::Mul; use vek::*; diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 0a9384f270..2efe46c798 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -29,7 +29,7 @@ impl Animation for WieldAnimation { let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0).sin(); match active_tool_kind { //TODO: Inventory - Some(Tool::Sword(_)) => { + Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.04; diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index 494477af45..fee6ddd4ea 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -158,54 +158,6 @@ impl MovementEventMapper { vel: Vec3, stats: &Stats, ) -> SfxEvent { - // Handle any weapon wielding changes up front. Doing so here first simplifies - // handling the movement/action state later, since they don't require querying - // stats or previous wield state. - if let Some(Item { - kind: ItemKind::Tool(ToolData { kind, .. }), - .. - }) = stats.equipment.main - { - if let Some(wield_event) = match ( - previous_event.weapon_drawn, - current_event.action.is_roll(), - Self::has_weapon_drawn(current_event.action), - ) { - (false, false, true) => Some(SfxEvent::Wield(kind)), - (true, false, false) => Some(SfxEvent::Unwield(kind)), - _ => None, - } { - return wield_event; - } - } - - // Match all other Movemement and Action states - match ( - current_event.movement, - current_event.action, - previous_event.event.clone(), - ) { - (_, ActionState::Roll { .. }, _) => SfxEvent::Roll, - (MovementState::Climb, ..) => SfxEvent::Climb, - (MovementState::Swim, ..) => SfxEvent::Swim, - (MovementState::Run, ..) => { - // If the entitys's velocity is very low, they may be stuck, or walking into a - // solid object. We should not trigger the run SFX in this case, - // even if their move state indicates running. The 0.1 value is - // an approximation from playtesting scenarios where this can occur. - if vel.magnitude() > 0.1 { - SfxEvent::Run - } else { - Some(SfxEvent::Run) - } - }, - (false, true) => Some(SfxEvent::Jump), - _ => None, - } - { - return jump_or_fall_event; - } - // Match run state if physics_state.on_ground && vel.magnitude() > 0.1 { return SfxEvent::Run; @@ -241,7 +193,7 @@ impl MovementEventMapper { /// ::Equipping to mean the weapon is drawn. This will need updating if the /// animations change to match the wield_duration associated with the weapon fn weapon_drawn(character: &CharacterState) -> bool { - character.is_wielded() + character.is_wield() || match character { CharacterState::Equipping { .. } => true, _ => false, diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 01b9323f8f..3cd35ebb13 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -183,9 +183,7 @@ impl FigureModelCache { if camera_mode != CameraMode::FirstPerson || character_state .map(|cs| { - cs.action.is_attack() - || cs.action.is_block() - || cs.action.is_wield() + cs.is_attack() || cs.is_block() || cs.is_wield() }) .unwrap_or_default() { diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 84c6aa2f3e..ebf7825b2a 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -173,7 +173,7 @@ impl Scene { .ecs() .read_storage::() .get(scene_data.player_entity) - .map_or(false, |cs| cs.action.is_roll()); + .map_or(false, |cs| cs.is_dodge()); let player_scale = match scene_data .state From 49c714314486ece9c97c3b63cf2224f4de49b33e Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 7 Mar 2020 13:03:10 -0800 Subject: [PATCH 048/326] Clean up warnings --- common/src/comp/controller.rs | 2 +- common/src/sys/character_behavior.rs | 22 +++++++++---------- common/src/sys/combat.rs | 14 ++++++------ common/src/sys/controller.rs | 11 ++++------ voxygen/src/anim/mod.rs | 3 +++ .../audio/sfx/event_mapper/movement/mod.rs | 4 ++-- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index a513f619cc..8b88f488c4 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -67,7 +67,7 @@ impl Input { /// Whether input has been pressed for longer than `threshold` pub fn is_long_press(&self, threshold: Duration) -> bool { - (self.is_pressed() && self.duration >= threshold) + self.is_pressed() && self.duration >= threshold } /// Handles logic of updating state of Input diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 576e95c30d..1179a3c196 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ AbilityPool, Body, CharacterState, Controller, ControllerInputs, Energy, Mounting, Ori, - PhysicsState, Pos, StateUpdate, Stats, Vel, + PhysicsState, Pos, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -11,7 +11,7 @@ use crate::{ use specs::{Entities, Entity, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; -use std::collections::VecDeque; +// use std::collections::VecDeque; /// Read-Only Data sent from Character Behavior System to bahvior fn's pub struct JoinData<'a> { @@ -171,15 +171,15 @@ impl<'a> System<'a> for Sys { CharacterState::BasicBlock { .. } => states::basic_block::behavior(&j), CharacterState::Sit { .. } => states::sit::behavior(&j), - _ => StateUpdate { - character: *j.character, - pos: *j.pos, - vel: *j.vel, - ori: *j.ori, - energy: *j.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }, + // _ => StateUpdate { + // character: *j.character, + // pos: *j.pos, + // vel: *j.vel, + // ori: *j.ori, + // energy: *j.energy, + // local_events: VecDeque::new(), + // server_events: VecDeque::new(), + // }, }; *tuple.2 = state_update.character; diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 0024e639a5..6918df5eab 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -1,14 +1,14 @@ use crate::{ comp::{ - Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Item, ItemKind, - Ori, Pos, Scale, Stats, + Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos, Scale, + Stats, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, sync::Uid, }; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; -use std::time::Duration; +// use std::time::Duration; use vek::*; const BLOCK_EFFICIENCY: f32 = 0.9; @@ -42,8 +42,8 @@ impl<'a> System<'a> for Sys { ( entities, server_bus, - local_bus, - dt, + _local_bus, + _dt, uids, positions, orientations, @@ -52,11 +52,11 @@ impl<'a> System<'a> for Sys { bodies, stats, mut attacking_storage, - mut character_states, + character_states, ): Self::SystemData, ) { // Attacks - for (entity, uid, pos, ori, scale_maybe, _, attacker_stats, attack) in ( + for (entity, uid, pos, ori, scale_maybe, _, _attacker_stats, attack) in ( &entities, &uids, &positions, diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index b8dee638b2..4a0e033651 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -1,9 +1,6 @@ use crate::{ - comp::{ - item, projectile, Body, ControlEvent, Controller, ControllerInputs, Energy, EnergySource, - HealthChange, HealthSource, ItemKind, Mounting, PhysicsState, Projectile, Stats, Vel, - }, - event::{Emitter, EventBus, LocalEvent, ServerEvent}, + comp::{ControlEvent, Controller}, + event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, sync::{Uid, UidAllocator}, }; @@ -12,8 +9,8 @@ use specs::{ Entities, Join, Read, ReadStorage, System, WriteStorage, }; -const CHARGE_COST: i32 = 200; -const ROLL_COST: i32 = 30; +// const CHARGE_COST: i32 = 200; +// const ROLL_COST: i32 = 30; pub struct Sys; diff --git a/voxygen/src/anim/mod.rs b/voxygen/src/anim/mod.rs index 590f67abb1..df32446f5c 100644 --- a/voxygen/src/anim/mod.rs +++ b/voxygen/src/anim/mod.rs @@ -58,6 +58,9 @@ pub trait Skeleton: Send + Sync + 'static { fn interpolate(&mut self, target: &Self, dt: f32); } +// rustc complains that `SkeletonAttr` fields are never read. +// Pls remove when they are. +#[allow(dead_code)] pub struct SkeletonAttr { scaler: f32, head_scale: f32, diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index fee6ddd4ea..084dc47ea2 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -4,7 +4,7 @@ use crate::audio::sfx::{SfxTriggerItem, SfxTriggers}; use common::{ - comp::{Body, CharacterState, Item, ItemKind, PhysicsState, Pos, Stats, ToolData, Vel}, + comp::{Body, CharacterState, PhysicsState, Pos, Stats, Vel}, event::{EventBus, SfxEvent, SfxEventItem}, state::State, }; @@ -156,7 +156,7 @@ impl MovementEventMapper { physics_state: &PhysicsState, previous_state: &PreviousEntityState, vel: Vec3, - stats: &Stats, + _stats: &Stats, ) -> SfxEvent { // Match run state if physics_state.on_ground && vel.magnitude() > 0.1 { From 5a9a8323f2c9aa35675103ebc1034684e4b5c356 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 7 Mar 2020 15:45:10 -0800 Subject: [PATCH 049/326] Update utils/handle_move fn's --- common/src/states/utils.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 2745e1fc86..a4e75c7cda 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -11,16 +11,16 @@ const HUMANOID_WATER_SPEED: f32 = 120.0; pub fn handle_move(data: &JoinData, update: &mut StateUpdate) { if data.physics.in_fluid { - handle_swim_move(data, update); + swim_move(data, update); } else { - handle_ground_move(data, update); + ground_move(data, update); } } -pub fn handle_ground_move(data: &JoinData, update: &mut StateUpdate) { +fn ground_move(data: &JoinData, update: &mut StateUpdate) { let (accel, speed): (f32, f32) = if data.physics.on_ground { let accel = 100.0; - let speed = 8.0; + let speed = 9.0; (accel, speed) } else { let accel = 100.0; @@ -56,7 +56,7 @@ pub fn handle_ground_move(data: &JoinData, update: &mut StateUpdate) { } } -pub fn handle_swim_move(data: &JoinData, update: &mut StateUpdate) { +fn swim_move(data: &JoinData, update: &mut StateUpdate) { // Update velocity update.vel.0 += Vec2::broadcast(data.dt.0) * data.inputs.move_dir From 1b9d1dc33391673ad0487a7d941e72dab18efacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Sun, 8 Mar 2020 13:05:38 +0100 Subject: [PATCH 050/326] update toolchain to `nightly-2020-03-05` --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 47892367f9..be5bcdaf12 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-02-06 +nightly-2020-03-05 From adf34d4f0fe5a3038e2ffc7b400d53f3fd48bf61 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 8 Mar 2020 08:38:53 -0700 Subject: [PATCH 051/326] User constants, faster characters --- common/src/states/utils.rs | 44 +++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index a4e75c7cda..0f936efddc 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -6,8 +6,25 @@ use crate::{ use std::time::Duration; use vek::vec::{Vec2, Vec3}; -const HUMANOID_WATER_ACCEL: f32 = 70.0; -const HUMANOID_WATER_SPEED: f32 = 120.0; +const BASE_HUMANOID_ACCEL: f32 = 100.0; +const BASE_HUMANOID_SPEED: f32 = 150.0; +const BASE_HUMANOID_AIR_ACCEL: f32 = 15.0; +const BASE_HUMANOID_AIR_SPEED: f32 = 8.0; +const BASE_HUMANOID_WATER_ACCEL: f32 = 70.0; +const BASE_HUMANOID_WATER_SPEED: f32 = 120.0; +// const BASE_HUMANOID_CLIMB_ACCEL: f32 = 10.0; +// const ROLL_SPEED: f32 = 17.0; +// const CHARGE_SPEED: f32 = 20.0; +// const GLIDE_ACCEL: f32 = 15.0; +// const GLIDE_SPEED: f32 = 45.0; +// const BLOCK_ACCEL: f32 = 30.0; +// const BLOCK_SPEED: f32 = 75.0; +// // Gravity is 9.81 * 4, so this makes gravity equal to .15 +// const GLIDE_ANTIGRAV: f32 = GRAVITY * 0.96; +// const CLIMB_SPEED: f32 = 5.0; +// const CLIMB_COST: i32 = 5; + +pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; pub fn handle_move(data: &JoinData, update: &mut StateUpdate) { if data.physics.in_fluid { @@ -19,13 +36,9 @@ pub fn handle_move(data: &JoinData, update: &mut StateUpdate) { fn ground_move(data: &JoinData, update: &mut StateUpdate) { let (accel, speed): (f32, f32) = if data.physics.on_ground { - let accel = 100.0; - let speed = 9.0; - (accel, speed) + (BASE_HUMANOID_ACCEL, BASE_HUMANOID_SPEED) } else { - let accel = 100.0; - let speed = 8.0; - (accel, speed) + (BASE_HUMANOID_AIR_ACCEL, BASE_HUMANOID_AIR_SPEED) }; // Move player according to move_dir @@ -60,8 +73,8 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { // Update velocity update.vel.0 += Vec2::broadcast(data.dt.0) * data.inputs.move_dir - * if update.vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) { - HUMANOID_WATER_ACCEL + * if update.vel.0.magnitude_squared() < BASE_HUMANOID_WATER_SPEED.powf(2.0) { + BASE_HUMANOID_WATER_ACCEL } else { 0.0 }; @@ -87,7 +100,8 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { // Force players to pulse jump button to swim up if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600)) { - update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); + update.vel.0.z = + (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(BASE_HUMANOID_WATER_SPEED); } } @@ -146,22 +160,22 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { } pub fn handle_primary(data: &JoinData, update: &mut StateUpdate) { - if let Some(state) = data.ability_pool.primary { + if let Some(ability_state) = data.ability_pool.primary { if let CharacterState::Wielding { .. } = update.character { if data.inputs.primary.is_pressed() { // data.updater.insert(data.entity, state); - update.character = character_state_from_ability(data, state); + update.character = character_state_from_ability(data, ability_state); } } } } pub fn handle_secondary(data: &JoinData, update: &mut StateUpdate) { - if let Some(state) = data.ability_pool.secondary { + if let Some(ability_state) = data.ability_pool.secondary { if let CharacterState::Wielding { .. } = update.character { if data.inputs.secondary.is_pressed() { // data.updater.insert(data.entity, state); - update.character = character_state_from_ability(data, state); + update.character = character_state_from_ability(data, ability_state); } } } From f769c74bf4d1cc04160090a5768231262f3abf4b Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 8 Mar 2020 10:04:26 -0700 Subject: [PATCH 052/326] Add charging back --- common/src/comp/ability.rs | 3 +- common/src/comp/character_state.rs | 7 ++- common/src/states/basic_block.rs | 9 +--- common/src/states/charge_attack.rs | 79 ++++++++++++++-------------- common/src/states/mod.rs | 1 + common/src/states/utils.rs | 26 ++++++--- common/src/states/wielding.rs | 30 +++++------ common/src/sys/character_behavior.rs | 1 + 8 files changed, 83 insertions(+), 73 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 9210ee6b02..05fadd2ab4 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -5,6 +5,7 @@ pub enum AbilityState { BasicAttack, BasicBlock, Roll, + ChargeAttack, } impl Default for AbilityState { fn default() -> Self { Self::BasicAttack } @@ -26,7 +27,7 @@ impl Default for AbilityPool { fn default() -> Self { Self { primary: Some(AbilityState::BasicAttack), - secondary: Some(AbilityState::BasicBlock), + secondary: Some(AbilityState::ChargeAttack), block: None, dodge: Some(AbilityState::Roll), } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index bdabd39759..4726226ec1 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -42,7 +42,10 @@ pub enum CharacterState { }, /// A basic blocking state BasicBlock {}, - //Charge{}, + ChargeAttack { + /// How long the state has until exiting + remaining_duration: Duration, + }, Roll { /// How long the state has until exiting remaining_duration: Duration, @@ -61,7 +64,7 @@ impl CharacterState { pub fn is_attack(&self) -> bool { match self { - CharacterState::BasicAttack { .. } => true, + CharacterState::BasicAttack { .. } | CharacterState::ChargeAttack { .. } => true, _ => false, } } diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index 8c5444b6bf..09f827d432 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -22,14 +22,7 @@ pub fn behavior(data: &JoinData) -> StateUpdate { handle_move(&data, &mut update); if !data.physics.on_ground || !data.inputs.secondary.is_pressed() { - if let Some(ItemKind::Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { - update.character = CharacterState::Equipping { - tool, - time_left: tool.equip_time(), - }; - } else { - update.character = CharacterState::Idle {}; - }; + attempt_wield(data, &mut update); } update } diff --git a/common/src/states/charge_attack.rs b/common/src/states/charge_attack.rs index 82e229de78..7958885a4e 100644 --- a/common/src/states/charge_attack.rs +++ b/common/src/states/charge_attack.rs @@ -1,13 +1,10 @@ use super::utils::*; use crate::{ - comp::{ - ActionState::Attack, AttackKind::Charge, CharacterEntityData, HealthChange, HealthSource, - ItemKind::Tool, MoveState::Run, StateUpdate, ToolData, - }, + comp::{CharacterState::*, HealthChange, HealthSource, StateUpdate}, event::ServerEvent, sys::character_behavior::JoinData, }; -use std::time::Duration; +use std::{collections::VecDeque, time::Duration}; use vek::Vec3; const CHARGE_SPEED: f32 = 20.0; @@ -18,45 +15,49 @@ pub fn behavior(data: &JoinData) -> StateUpdate { vel: *data.vel, ori: *data.ori, character: *data.character, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; - // Move player - update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) - + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) - + 1.5 * data.inputs.move_dir.try_normalized().unwrap_or_default()) - .try_normalized() - .unwrap_or_default() - * CHARGE_SPEED; + if let ChargeAttack { remaining_duration } = data.character { + // Move player + update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) + + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) + + 1.5 * data.inputs.move_dir.try_normalized().unwrap_or_default()) + .try_normalized() + .unwrap_or_default() + * CHARGE_SPEED; - // Check if hitting another entity - if let Some(uid_b) = data.physics.touch_entity { - // Send Damage event - data.server_bus.emitter().emit(ServerEvent::Damage { - uid: uid_b, - change: HealthChange { - amount: -20, - cause: HealthSource::Attack { by: *data.uid }, - }, - }); + // Check if hitting another entity + if let Some(uid_b) = data.physics.touch_entity { + // Send Damage event + update.server_events.push_front(ServerEvent::Damage { + uid: uid_b, + change: HealthChange { + amount: -20, + cause: HealthSource::Attack { by: *data.uid }, + }, + }); - // Go back to wielding or idling - update.character.action_state = attempt_wield(data.stats); - return update; + // Go back to wielding or idling + attempt_wield(data, &mut update); + return update; + } + + // Check if charge timed out or can't keep moving forward + if *remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 { + attempt_wield(data, &mut update); + return update; + } + + // Tick remaining-duration and keep charging + update.character = ChargeAttack { + remaining_duration: remaining_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), + }; } - // Check if charge timed out or can't keep moving forward - if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 { - update.character.action_state = attempt_wield(data.stats); - return update; - } - - // Tick remaining-duration and keep charging - update.character.action_state = Attack(Charge(Some(State { - remaining_duration: self - .remaining_duration - .checked_sub(Duration::from_secs_f32(data.dt.0)) - .unwrap_or_default(), - }))); - update } diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 2375e7d586..5f48ad7367 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -1,6 +1,7 @@ // Module declarations pub mod basic_attack; pub mod basic_block; +pub mod charge_attack; pub mod climb; pub mod equipping; pub mod glide; diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 0f936efddc..2de02e1454 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -105,19 +105,26 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { } } +/// First checks whether `primary` input is pressed, then +/// attempts to go into Equipping state, otherwise Idle pub fn handle_wield(data: &JoinData, update: &mut StateUpdate) { if data.inputs.primary.is_pressed() { - if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { - update.character = CharacterState::Equipping { - tool, - time_left: tool.equip_time(), - }; - } else { - update.character = CharacterState::Idle {}; - }; + attempt_wield(data, update); } } +/// If a tool is equipped, goes into Equipping state, otherwise goes to Idle +pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { + if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { + update.character = CharacterState::Equipping { + tool, + time_left: tool.equip_time(), + }; + } else { + update.character = CharacterState::Idle {}; + }; +} + pub fn handle_sit(data: &JoinData, update: &mut StateUpdate) { if data.inputs.sit.is_pressed() && data.physics.on_ground && data.body.is_humanoid() { update.character = CharacterState::Sit {}; @@ -226,5 +233,8 @@ pub fn character_state_from_ability( AbilityState::Roll { .. } => CharacterState::Roll { remaining_duration: Duration::from_millis(600), }, + AbilityState::ChargeAttack { .. } => CharacterState::ChargeAttack { + remaining_duration: Duration::from_millis(600), + }, } } diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 1edc0bf78c..43fe8c297d 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -2,26 +2,26 @@ use super::utils::*; use crate::{comp::StateUpdate, sys::character_behavior::JoinData}; use std::collections::VecDeque; -pub fn behavior(ecs_data: &JoinData) -> StateUpdate { +pub fn behavior(data: &JoinData) -> StateUpdate { let mut update = StateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - energy: *ecs_data.energy, + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, local_events: VecDeque::new(), server_events: VecDeque::new(), }; - handle_move(&ecs_data, &mut update); - handle_jump(&ecs_data, &mut update); - handle_sit(&ecs_data, &mut update); - handle_climb(&ecs_data, &mut update); - handle_glide(&ecs_data, &mut update); - handle_unwield(&ecs_data, &mut update); - handle_primary(&ecs_data, &mut update); - handle_secondary(&ecs_data, &mut update); - handle_dodge(&ecs_data, &mut update); + handle_move(&data, &mut update); + handle_jump(&data, &mut update); + handle_sit(&data, &mut update); + handle_climb(&data, &mut update); + handle_glide(&data, &mut update); + handle_unwield(&data, &mut update); + handle_primary(&data, &mut update); + handle_secondary(&data, &mut update); + handle_dodge(&data, &mut update); update } diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 1179a3c196..89034ace4d 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -169,6 +169,7 @@ impl<'a> System<'a> for Sys { CharacterState::Equipping { .. } => states::equipping::behavior(&j), CharacterState::BasicAttack { .. } => states::basic_attack::behavior(&j), CharacterState::BasicBlock { .. } => states::basic_block::behavior(&j), + CharacterState::ChargeAttack { .. } => states::charge_attack::behavior(&j), CharacterState::Sit { .. } => states::sit::behavior(&j), // _ => StateUpdate { From 698fe9f45186baa1514f191a254ced971d0cd22a Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 8 Mar 2020 10:38:18 -0700 Subject: [PATCH 053/326] More util fn's, add comments --- common/src/states/utils.rs | 99 +++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 2de02e1454..3611b6c3b8 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -26,15 +26,17 @@ const BASE_HUMANOID_WATER_SPEED: f32 = 120.0; pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; +/// Handles updating `Components` to move player based on state of `JoinData` pub fn handle_move(data: &JoinData, update: &mut StateUpdate) { if data.physics.in_fluid { swim_move(data, update); } else { - ground_move(data, update); + basic_move(data, update); } } -fn ground_move(data: &JoinData, update: &mut StateUpdate) { +/// Updates components to move player as if theyre on ground or in air +fn basic_move(data: &JoinData, update: &mut StateUpdate) { let (accel, speed): (f32, f32) = if data.physics.on_ground { (BASE_HUMANOID_ACCEL, BASE_HUMANOID_SPEED) } else { @@ -69,6 +71,7 @@ fn ground_move(data: &JoinData, update: &mut StateUpdate) { } } +/// Updates components to move player as if theyre swimming fn swim_move(data: &JoinData, update: &mut StateUpdate) { // Update velocity update.vel.0 += Vec2::broadcast(data.dt.0) @@ -125,12 +128,14 @@ pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { }; } +/// Checks that player can `Sit` and updates `CharacterState` if so pub fn handle_sit(data: &JoinData, update: &mut StateUpdate) { if data.inputs.sit.is_pressed() && data.physics.on_ground && data.body.is_humanoid() { update.character = CharacterState::Sit {}; } } +/// Checks that player can `Climb` and updates `CharacterState` if so pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { if (data.inputs.climb.is_pressed() || data.inputs.climb_down.is_pressed()) && data.physics.on_wall.is_some() @@ -142,6 +147,7 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { } } +/// Checks that player can `Glide` and updates `CharacterState` if so pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) { if let CharacterState::Wielding { .. } = update.character { if data.inputs.toggle_wield.is_pressed() { @@ -150,6 +156,7 @@ pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) { } } +/// Checks that player can glide and updates `CharacterState` if so pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) { if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { if data.inputs.glide.is_pressed() && !data.physics.on_ground && data.body.is_humanoid() { @@ -158,6 +165,7 @@ pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) { } } +/// Checks that player can jump and sends jump event if so pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { if data.inputs.jump.is_pressed() && data.physics.on_ground { update @@ -166,58 +174,69 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { } } -pub fn handle_primary(data: &JoinData, update: &mut StateUpdate) { +/// If `inputs.primary` is pressed and in `Wielding` state, +/// will attempt to go into `ability_pool.primary` +pub fn handle_primary_input(data: &JoinData, update: &mut StateUpdate) { + if data.inputs.primary.is_pressed() { + if let CharacterState::Wielding { .. } = update.character { + attempt_primary_ability(data, update); + } + } +} + +/// Attempts to go into `ability_pool.primary` if is `Some()` on `AbilityPool` +pub fn attempt_primary_ability(data: &JoinData, update: &mut StateUpdate) { if let Some(ability_state) = data.ability_pool.primary { + update.character = ability_to_character_state(data, ability_state); + } +} + +/// If `inputs.secondary` is pressed and in `Wielding` state, +/// will attempt to go into `ability_pool.secondary` +pub fn handle_secondary_input(data: &JoinData, update: &mut StateUpdate) { + if data.inputs.secondary.is_pressed() { if let CharacterState::Wielding { .. } = update.character { - if data.inputs.primary.is_pressed() { - // data.updater.insert(data.entity, state); - update.character = character_state_from_ability(data, ability_state); - } + attempt_seconday_ability(data, update); } } } -pub fn handle_secondary(data: &JoinData, update: &mut StateUpdate) { +/// Attempts to go into `ability_pool.secondary` if is `Some()` on `AbilityPool` +pub fn attempt_seconday_ability(data: &JoinData, update: &mut StateUpdate) { if let Some(ability_state) = data.ability_pool.secondary { - if let CharacterState::Wielding { .. } = update.character { - if data.inputs.secondary.is_pressed() { - // data.updater.insert(data.entity, state); - update.character = character_state_from_ability(data, ability_state); - } + update.character = ability_to_character_state(data, ability_state); + } +} + +/// Checks that player can perform a dodge, then +/// attempts to go into `ability_pool.dodge` +pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { + if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { + if data.inputs.roll.is_pressed() + && data.physics.on_ground + && data.body.is_humanoid() + && update + .energy + .try_change_by(-200, EnergySource::Roll) + .is_ok() + { + attempt_dodge_ability(data, update); } } } -pub fn handle_dodge(data: &JoinData, update: &mut StateUpdate) { - if let Some(state) = data.ability_pool.dodge { - if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { - if data.inputs.roll.is_pressed() - && data.physics.on_ground - && data.body.is_humanoid() - && update - .energy - .try_change_by(-200, EnergySource::Roll) - .is_ok() - { - // let tool_data = - // if let Some(Tool(data)) = data.stats.equipment.main.as_ref().map(|i| - // i.kind) { data - // } else { - // ToolData::default() - // }; - update.character = CharacterState::Roll { - remaining_duration: Duration::from_millis(600), // tool_data.attack_duration(), - }; - data.updater.insert(data.entity, state); - } - } +pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { + if let Some(ability_state) = data.ability_pool.dodge { + update.character = ability_to_character_state(data, ability_state); } } -pub fn character_state_from_ability( - data: &JoinData, - ability_state: AbilityState, -) -> CharacterState { +// TODO: This might need a CharacterState::new(data, update) fn if +// initialization gets too lengthy. + +/// Maps from `AbilityState`s to `CharacterStates`s. Also handles intializing +/// the new `CharacterState` +pub fn ability_to_character_state(data: &JoinData, ability_state: AbilityState) -> CharacterState { match ability_state { AbilityState::BasicAttack { .. } => { if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { From fe1feebeb215e48c328edd9b2030b7f52b642bc1 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 8 Mar 2020 10:38:40 -0700 Subject: [PATCH 054/326] Renaming fn's --- common/src/states/idle.rs | 2 +- common/src/states/wielding.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index c2df18be36..df13129a2a 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -18,7 +18,7 @@ pub fn behavior(data: &JoinData) -> StateUpdate { handle_sit(data, &mut update); handle_climb(data, &mut update); handle_glide(data, &mut update); - handle_dodge(data, &mut update); + handle_dodge_input(data, &mut update); update } diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 43fe8c297d..e9b30a77d0 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -19,9 +19,9 @@ pub fn behavior(data: &JoinData) -> StateUpdate { handle_climb(&data, &mut update); handle_glide(&data, &mut update); handle_unwield(&data, &mut update); - handle_primary(&data, &mut update); - handle_secondary(&data, &mut update); - handle_dodge(&data, &mut update); + handle_primary_input(&data, &mut update); + handle_secondary_input(&data, &mut update); + handle_dodge_input(&data, &mut update); update } From 5f8751e2d388e7c1635da673f4ed390459b4bee8 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 8 Mar 2020 12:37:17 -0700 Subject: [PATCH 055/326] Begin implementing triple attack --- common/src/comp/ability.rs | 4 +- common/src/comp/character_state.rs | 14 ++++ common/src/states/basic_block.rs | 5 +- common/src/states/mod.rs | 1 + common/src/states/triple_attack/mod.rs | 92 ++++++++++++++++++++++++++ common/src/states/utils.rs | 35 ++++++++-- common/src/sys/character_behavior.rs | 2 + 7 files changed, 142 insertions(+), 11 deletions(-) create mode 100644 common/src/states/triple_attack/mod.rs diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 05fadd2ab4..a6f9b41eef 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -6,6 +6,7 @@ pub enum AbilityState { BasicBlock, Roll, ChargeAttack, + TripleAttack, } impl Default for AbilityState { fn default() -> Self { Self::BasicAttack } @@ -27,7 +28,8 @@ impl Default for AbilityPool { fn default() -> Self { Self { primary: Some(AbilityState::BasicAttack), - secondary: Some(AbilityState::ChargeAttack), + // primary: Some(AbilityState::TripleAttack), + secondary: Some(AbilityState::BasicBlock), block: None, dodge: Some(AbilityState::Roll), } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 4726226ec1..5486366afb 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -50,6 +50,20 @@ pub enum CharacterState { /// How long the state has until exiting remaining_duration: Duration, }, + /// A three-stage attack where play must click at appropriate times + /// to continue attack chain. + TripleAttack { + /// The tool this state will read to handle damage, etc. + tool: ToolData, + /// `int` denoting what stage (of 3) the attack is in. + stage: i8, + /// How long current stage has been active + stage_time_active: Duration, + /// Whether current stage has exhausted its attack + stage_exhausted: bool, + /// Whether player has clicked at the proper time to go to next stage + can_transition: bool, + }, } impl CharacterState { diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index 09f827d432..912707d954 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -1,8 +1,5 @@ use super::utils::*; -use crate::{ - comp::{CharacterState, ItemKind, StateUpdate}, - sys::character_behavior::JoinData, -}; +use crate::{comp::StateUpdate, sys::character_behavior::JoinData}; use std::collections::VecDeque; // const BLOCK_ACCEL: f32 = 30.0; diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 5f48ad7367..530679e37a 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -8,5 +8,6 @@ pub mod glide; pub mod idle; pub mod roll; pub mod sit; +pub mod triple_attack; pub mod utils; pub mod wielding; diff --git a/common/src/states/triple_attack/mod.rs b/common/src/states/triple_attack/mod.rs new file mode 100644 index 0000000000..dfeaa5c260 --- /dev/null +++ b/common/src/states/triple_attack/mod.rs @@ -0,0 +1,92 @@ +use crate::{ + comp::{Attacking, CharacterState, ItemKind::Tool, StateUpdate}, + states::utils::*, + sys::character_behavior::JoinData, +}; +use std::{collections::VecDeque, time::Duration}; + +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + + if let CharacterState::TripleAttack { + tool, + stage, + stage_time_active, + stage_exhausted, + can_transition, + } = data.character + { + let mut new_can_transition = *can_transition; + let mut new_stage_exhausted = *stage_exhausted; + let new_stage_time_active = stage_time_active + .checked_add(Duration::from_secs_f32(data.dt.0)) + .unwrap_or(Duration::default()); + + match stage { + 1 => { + if new_stage_time_active > tool.attack_buildup_duration() { + if !*stage_exhausted { + // Try to deal damage + data.updater.insert(data.entity, Attacking { + weapon: Some(*tool), + }); + new_stage_exhausted = true; + } else { + // Make sure to remove Attacking component + data.updater.remove::(data.entity); + } + + // Check if player has timed click right + if data.inputs.primary.is_just_pressed() { + println!("Can transition"); + new_can_transition = true; + } + } + + if new_stage_time_active > tool.attack_duration() { + if new_can_transition { + update.character = CharacterState::TripleAttack { + tool: *tool, + stage: 2, + stage_time_active: Duration::default(), + stage_exhausted: false, + can_transition: false, + } + } else { + println!("Failed"); + attempt_wield(data, &mut update); + } + } else { + update.character = CharacterState::TripleAttack { + tool: *tool, + stage: 1, + stage_time_active: new_stage_time_active, + stage_exhausted: new_stage_exhausted, + can_transition: new_can_transition, + } + } + }, + 2 => { + println!("2"); + attempt_wield(data, &mut update); + }, + 3 => { + println!("3"); + attempt_wield(data, &mut update); + }, + _ => { + // Should never get here. + }, + } + } + + update +} diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 3611b6c3b8..4beffc9d6d 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,11 +1,12 @@ use crate::{ - comp::{AbilityState, CharacterState, EnergySource, ItemKind::Tool, StateUpdate}, + comp::{AbilityState, CharacterState, EnergySource, ItemKind::Tool, StateUpdate, ToolData}, event::LocalEvent, sys::{character_behavior::JoinData, phys::GRAVITY}, }; use std::time::Duration; use vek::vec::{Vec2, Vec3}; +pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; const BASE_HUMANOID_ACCEL: f32 = 100.0; const BASE_HUMANOID_SPEED: f32 = 150.0; const BASE_HUMANOID_AIR_ACCEL: f32 = 15.0; @@ -24,8 +25,6 @@ const BASE_HUMANOID_WATER_SPEED: f32 = 120.0; // const CLIMB_SPEED: f32 = 5.0; // const CLIMB_COST: i32 = 5; -pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; - /// Handles updating `Components` to move player based on state of `JoinData` pub fn handle_move(data: &JoinData, update: &mut StateUpdate) { if data.physics.in_fluid { @@ -231,7 +230,7 @@ pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { } } -// TODO: This might need a CharacterState::new(data, update) fn if +// TODO: Wight need a fn `CharacterState::new(data, update)` if // initialization gets too lengthy. /// Maps from `AbilityState`s to `CharacterStates`s. Also handles intializing @@ -239,13 +238,13 @@ pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { pub fn ability_to_character_state(data: &JoinData, ability_state: AbilityState) -> CharacterState { match ability_state { AbilityState::BasicAttack { .. } => { - if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { + if let Some(tool) = get_tool_data(data) { CharacterState::BasicAttack { exhausted: false, remaining_duration: tool.attack_duration(), } } else { - CharacterState::Idle {} + *data.character } }, AbilityState::BasicBlock { .. } => CharacterState::BasicBlock {}, @@ -255,5 +254,29 @@ pub fn ability_to_character_state(data: &JoinData, ability_state: AbilityState) AbilityState::ChargeAttack { .. } => CharacterState::ChargeAttack { remaining_duration: Duration::from_millis(600), }, + AbilityState::TripleAttack { .. } => { + if let Some(tool) = get_tool_data(data) { + CharacterState::TripleAttack { + tool, + stage: 1, + stage_time_active: Duration::default(), + stage_exhausted: false, + can_transition: false, + } + } else { + *data.character + } + }, + + // Do not use default match + // _ => *data.character + } +} + +pub fn get_tool_data(data: &JoinData) -> Option { + if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { + Some(tool) + } else { + None } } diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 89034ace4d..01cf463c62 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -171,7 +171,9 @@ impl<'a> System<'a> for Sys { CharacterState::BasicBlock { .. } => states::basic_block::behavior(&j), CharacterState::ChargeAttack { .. } => states::charge_attack::behavior(&j), CharacterState::Sit { .. } => states::sit::behavior(&j), + CharacterState::TripleAttack { .. } => states::triple_attack::behavior(&j), + // Do not use default match. // _ => StateUpdate { // character: *j.character, // pos: *j.pos, From bce9d4c24f32be08e4dc6fa4abf5e79c9f3e9369 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 8 Mar 2020 17:02:25 -0400 Subject: [PATCH 056/326] animation corrections --- common/src/states/utils.rs | 2 +- voxygen/src/anim/character/attack.rs | 5 +++-- voxygen/src/anim/character/block.rs | 7 +++++++ voxygen/src/anim/character/blockidle.rs | 7 +++++++ voxygen/src/anim/character/wield.rs | 25 +++++++++++-------------- voxygen/src/scene/figure/mod.rs | 4 ++-- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 4beffc9d6d..b8d5656db5 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -256,7 +256,7 @@ pub fn ability_to_character_state(data: &JoinData, ability_state: AbilityState) }, AbilityState::TripleAttack { .. } => { if let Some(tool) = get_tool_data(data) { - CharacterState::TripleAttack { + CharacterState::TripleAttack { tool, stage: 1, stage_time_active: Duration::default(), diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index 8e376c6f7b..bdb84ef253 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -16,9 +16,10 @@ impl Animation for AttackAnimation { skeleton: &Self::Skeleton, (active_tool_kind, _global_time): Self::Dependency, anim_time: f64, - _rate: &mut f32, + rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { + *rate = 1.0; let mut next = (*skeleton).clone(); let lab = 1.0; @@ -270,7 +271,7 @@ impl Animation for AttackAnimation { next.lantern.ori = Quaternion::rotation_x(0.0); next.lantern.scale = Vec3::one() * 0.0; - next.torso.offset = Vec3::new(0.0, -0.2, 0.1) * skeleton_attr.scaler; + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; diff --git a/voxygen/src/anim/character/block.rs b/voxygen/src/anim/character/block.rs index 62195f3853..4ed5e7d542 100644 --- a/voxygen/src/anim/character/block.rs +++ b/voxygen/src/anim/character/block.rs @@ -274,6 +274,13 @@ impl Animation for BlockAnimation { next.torso.ori = Quaternion::rotation_x(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); next } } diff --git a/voxygen/src/anim/character/blockidle.rs b/voxygen/src/anim/character/blockidle.rs index 8e7ec674e3..aa035383ac 100644 --- a/voxygen/src/anim/character/blockidle.rs +++ b/voxygen/src/anim/character/blockidle.rs @@ -273,6 +273,13 @@ impl Animation for BlockIdleAnimation { next.torso.ori = Quaternion::rotation_x(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); next } } diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 2efe46c798..c050e7e03a 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -12,37 +12,33 @@ impl Animation for WieldAnimation { fn update_skeleton( skeleton: &Self::Skeleton, - (active_tool_kind, velocity, _global_time): Self::Dependency, + (active_tool_kind, _velocity, _global_time): Self::Dependency, anim_time: f64, - rate: &mut f32, + _rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let speed = Vec2::::from(velocity).magnitude(); - *rate = speed; - let wave_ultra_slow = (anim_time as f32 * 3.0 + PI).sin(); let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); let wave = (anim_time as f32 * 1.0).sin(); - let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0).sin(); match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { - next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0); - next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0); + next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2); next.l_hand.scale = Vec3::one() * 1.04; - next.r_hand.offset = Vec3::new(0.0, -6.0, -8.0); - next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.offset = Vec3::new(1.25, -5.5, -8.0); + next.r_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3); next.r_hand.scale = Vec3::one() * 1.05; next.main.offset = Vec3::new(0.0, 0.0, -6.0); - next.main.ori = Quaternion::rotation_x(-0.3) + next.main.ori = Quaternion::rotation_x(-0.1) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-8.0, 4.0, 6.0); + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); next.control.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); @@ -199,8 +195,9 @@ impl Animation for WieldAnimation { }, _ => {}, } - next.torso.offset = Vec3::new(0.0, 0.3 + wave * -0.08, 0.4) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(wave_stop * -0.2); + + next.torso.offset = Vec3::new(0.0, 0.0 + wave * -0.08, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 1bcfd294c4..dbefe7492a 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -408,8 +408,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.001, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > 0.5, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::character::StandAnimation::update_skeleton( From 344bb955a2e996b79c7f0cbac4b8d902d0794d75 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 8 Mar 2020 21:28:45 -0700 Subject: [PATCH 057/326] rename get_tool_data to unwrap_tool_data --- common/src/states/utils.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index b8d5656db5..0ac68c525e 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -238,7 +238,7 @@ pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { pub fn ability_to_character_state(data: &JoinData, ability_state: AbilityState) -> CharacterState { match ability_state { AbilityState::BasicAttack { .. } => { - if let Some(tool) = get_tool_data(data) { + if let Some(tool) = unwrap_tool_data(data) { CharacterState::BasicAttack { exhausted: false, remaining_duration: tool.attack_duration(), @@ -255,7 +255,7 @@ pub fn ability_to_character_state(data: &JoinData, ability_state: AbilityState) remaining_duration: Duration::from_millis(600), }, AbilityState::TripleAttack { .. } => { - if let Some(tool) = get_tool_data(data) { + if let Some(tool) = unwrap_tool_data(data) { CharacterState::TripleAttack { tool, stage: 1, @@ -273,7 +273,7 @@ pub fn ability_to_character_state(data: &JoinData, ability_state: AbilityState) } } -pub fn get_tool_data(data: &JoinData) -> Option { +pub fn unwrap_tool_data(data: &JoinData) -> Option { if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { Some(tool) } else { From c88c4687f3b12ff0ca505dcf48f02dff224a04c6 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 10 Mar 2020 17:33:36 +0100 Subject: [PATCH 058/326] fix: stop switching quickly between climbing and idle at low energy --- common/src/states/utils.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 0ac68c525e..13a4979334 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -141,6 +141,7 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { && !data.physics.on_ground //&& update.vel.0.z < 0.0 && data.body.is_humanoid() + && update.energy.current() > 100 { update.character = CharacterState::Climb {}; } From 70027da9aaa23222be7fce86986001de139266de Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 10 Mar 2020 18:54:59 +0100 Subject: [PATCH 059/326] feat: hitting enemies with basic_attack gives energy --- common/src/comp/character_state.rs | 2 ++ common/src/comp/energy.rs | 1 + common/src/states/basic_attack.rs | 20 +++++++++++++------- common/src/states/roll.rs | 1 + common/src/states/triple_attack/mod.rs | 2 ++ common/src/states/utils.rs | 2 +- common/src/sys/character_behavior.rs | 10 ++++++++-- common/src/sys/combat.rs | 7 ++++++- 8 files changed, 34 insertions(+), 11 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 5486366afb..cb3f239148 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -115,6 +115,8 @@ impl Component for CharacterState { #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Attacking { pub weapon: Option, + pub applied: bool, + pub hit_count: u32, } impl Component for Attacking { diff --git a/common/src/comp/energy.rs b/common/src/comp/energy.rs index 6a0c1853f8..cb7fabee44 100644 --- a/common/src/comp/energy.rs +++ b/common/src/comp/energy.rs @@ -15,6 +15,7 @@ pub enum EnergySource { Roll, Climb, LevelUp, + HitEnemy, Regen, Revive, Unknown, diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index a2ea1838c3..b635b657dc 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{Attacking, CharacterState, ItemKind::Tool, StateUpdate}, + comp::{Attacking, CharacterState, EnergySource, ItemKind::Tool, StateUpdate}, states::utils::*, sys::character_behavior::JoinData, }; @@ -35,20 +35,26 @@ pub fn behavior(data: &JoinData) -> StateUpdate { if can_apply_damage { if let Some(Tool(tool)) = tool_kind { - data.updater - .insert(data.entity, Attacking { weapon: Some(tool) }); - } else { - data.updater.insert(data.entity, Attacking { weapon: None }); + data.updater.insert(data.entity, Attacking { + weapon: Some(tool), + applied: false, + hit_count: 0, + }); } new_exhausted = true; - } else { - data.updater.remove::(data.entity); } let new_remaining_duration = remaining_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(); + if let Some(attack) = data.attacking { + if attack.applied && attack.hit_count > 0 { + data.updater.remove::(data.entity); + update.energy.change_by(100, EnergySource::HitEnemy); + } + } + // Tick down update.character = CharacterState::BasicAttack { remaining_duration: new_remaining_duration, diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index cc2a570b7b..9f176817f3 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -39,6 +39,7 @@ pub fn behavior(data: &JoinData) -> StateUpdate { if *remaining_duration == Duration::default() { // Roll duration has expired + update.vel.0 *= 0.3; update.character = CharacterState::Idle {}; } else { // Otherwise, tick down remaining_duration diff --git a/common/src/states/triple_attack/mod.rs b/common/src/states/triple_attack/mod.rs index dfeaa5c260..dc14398de5 100644 --- a/common/src/states/triple_attack/mod.rs +++ b/common/src/states/triple_attack/mod.rs @@ -37,6 +37,8 @@ pub fn behavior(data: &JoinData) -> StateUpdate { // Try to deal damage data.updater.insert(data.entity, Attacking { weapon: Some(*tool), + applied: false, + hit_count: 0, }); new_stage_exhausted = true; } else { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 13a4979334..e4ccd6f006 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -58,7 +58,7 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate) { { Vec2::from(data.inputs.look_dir).normalized() } else { - Vec2::from(update.vel.0) + Vec2::from(data.inputs.move_dir) }; // Smooth orientation diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 01cf463c62..1a5accd49a 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - AbilityPool, Body, CharacterState, Controller, ControllerInputs, Energy, Mounting, Ori, - PhysicsState, Pos, Stats, Vel, + AbilityPool, Attacking, Body, CharacterState, Controller, ControllerInputs, Energy, + Mounting, Ori, PhysicsState, Pos, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -29,6 +29,7 @@ pub struct JoinData<'a> { pub body: &'a Body, pub physics: &'a PhysicsState, pub ability_pool: &'a AbilityPool, + pub attacking: Option<&'a Attacking>, pub updater: &'a LazyUpdate, } @@ -45,6 +46,7 @@ pub type JoinTuple<'a> = ( &'a Body, &'a PhysicsState, &'a AbilityPool, + Option<&'a Attacking>, ); impl<'a> JoinData<'a> { @@ -63,6 +65,7 @@ impl<'a> JoinData<'a> { body: j.9, physics: j.10, ability_pool: j.11, + attacking: j.12, updater, dt, } @@ -95,6 +98,7 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Body>, ReadStorage<'a, PhysicsState>, ReadStorage<'a, AbilityPool>, + ReadStorage<'a, Attacking>, ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, ); @@ -118,6 +122,7 @@ impl<'a> System<'a> for Sys { bodies, physics_states, ability_pools, + attacking_storage, uids, mountings, ): Self::SystemData, @@ -135,6 +140,7 @@ impl<'a> System<'a> for Sys { &bodies, &physics_states, &ability_pools, + attacking_storage.maybe(), ) .join(); diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 6918df5eab..b811beb991 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -68,6 +68,11 @@ impl<'a> System<'a> for Sys { ) .join() { + if attack.applied { + continue; + } + attack.applied = true; + // Go through all other entities for (b, uid_b, pos_b, ori_b, scale_b_maybe, character_b, stats_b, body_b) in ( &entities, @@ -115,9 +120,9 @@ impl<'a> System<'a> for Sys { cause: HealthSource::Attack { by: *uid }, }, }); + attack.hit_count += 1; } } } - attacking_storage.clear(); } } From 0ce451a8b1b7fe35efeada7148c9965caddcd9b2 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 10 Mar 2020 19:00:49 +0100 Subject: [PATCH 060/326] fix: deny gliding/jumping/rolling under water --- common/src/states/utils.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index e4ccd6f006..209593d158 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -159,7 +159,11 @@ pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) { /// Checks that player can glide and updates `CharacterState` if so pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) { if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { - if data.inputs.glide.is_pressed() && !data.physics.on_ground && data.body.is_humanoid() { + if data.inputs.glide.is_pressed() + && !data.physics.on_ground + && !data.physics.in_fluid + && data.body.is_humanoid() + { update.character = CharacterState::Glide {}; } } @@ -167,7 +171,7 @@ pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) { /// Checks that player can jump and sends jump event if so pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.jump.is_pressed() && data.physics.on_ground { + if data.inputs.jump.is_pressed() && data.physics.on_ground && !data.physics.in_fluid { update .local_events .push_front(LocalEvent::Jump(data.entity)); @@ -214,6 +218,7 @@ pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { if data.inputs.roll.is_pressed() && data.physics.on_ground + && !data.physics.in_fluid && data.body.is_humanoid() && update .energy From 841a2bbd6dffa3e55e5832729f1306208d680342 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 10 Mar 2020 19:12:16 +0100 Subject: [PATCH 061/326] clean up old states, lower gravity --- common/src/state.rs | 2 +- common/src/states/fall.rs | 67 -------------------------------------- common/src/states/jump.rs | 27 --------------- common/src/states/stand.rs | 45 ------------------------- common/src/states/swim.rs | 56 ------------------------------- common/src/states/utils.rs | 3 +- common/src/sys/phys.rs | 2 +- 7 files changed, 4 insertions(+), 198 deletions(-) delete mode 100644 common/src/states/fall.rs delete mode 100644 common/src/states/jump.rs delete mode 100644 common/src/states/stand.rs delete mode 100644 common/src/states/swim.rs diff --git a/common/src/state.rs b/common/src/state.rs index 2c5224697a..0e07b75659 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -40,7 +40,7 @@ pub struct DeltaTime(pub f32); /// this value, the game's physics will begin to produce time lag. Ideally, we'd /// avoid such a situation. const MAX_DELTA_TIME: f32 = 1.0; -const HUMANOID_JUMP_ACCEL: f32 = 26.0; +const HUMANOID_JUMP_ACCEL: f32 = 16.0; #[derive(Default)] pub struct BlockChange { diff --git a/common/src/states/fall.rs b/common/src/states/fall.rs deleted file mode 100644 index 8d90711eb2..0000000000 --- a/common/src/states/fall.rs +++ /dev/null @@ -1,67 +0,0 @@ -use crate::comp::{ActionState, CharacterEntityData, MoveState, StateUpdate}; - -use super::utils::*; -use crate::states::StateHandler; -use vek::{Vec2, Vec3}; - -const HUMANOID_AIR_ACCEL: f32 = 10.0; -const HUMANOID_AIR_SPEED: f32 = 100.0; - -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State; - -impl StateHandler for State { - fn new(_ecs_data: &CharacterEntityData) -> Self { Self {} } - - fn handle(&self, ecs_data: &CharacterEntityData) -> StateUpdate { - let mut update = StateUpdate { - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - character: *ecs_data.character, - }; - - // Move player according to movement direction vector - update.vel.0 += Vec2::broadcast(ecs_data.dt.0) - * ecs_data.inputs.move_dir - * if update.vel.0.magnitude_squared() < HUMANOID_AIR_SPEED.powf(2.0) { - HUMANOID_AIR_ACCEL - } else { - 0.0 - }; - - // Set orientation vector based on direction of movement when on the ground - let ori_dir = - if let ActionState::Attack(_) | ActionState::Block(_) = update.character.action_state { - Vec2::from(ecs_data.inputs.look_dir).normalized() - } else { - Vec2::from(update.vel.0) - }; - - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = - vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 2.0 * ecs_data.dt.0); - } - - // Check to start climbing - if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = MoveState::Climb(None); - return update; - } - - // Check gliding - if ecs_data.inputs.glide.is_pressed() { - update.character.move_state = MoveState::Glide(None); - return update; - } - - // Else update based on groundedness - update.character.move_state = - determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); - - update - } -} diff --git a/common/src/states/jump.rs b/common/src/states/jump.rs deleted file mode 100644 index bb23131736..0000000000 --- a/common/src/states/jump.rs +++ /dev/null @@ -1,27 +0,0 @@ -use super::{CharacterEntityData, MoveState, StateHandler, StateUpdate}; -use crate::event::LocalEvent; - -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State; - -impl StateHandler for State { - fn new(_ecs_data: &CharacterEntityData) -> Self { Self {} } - - fn handle(&self, ecs_data: &CharacterEntityData) -> StateUpdate { - let mut update = StateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - }; - - ecs_data - .local_bus - .emitter() - .emit(LocalEvent::Jump(*ecs_data.entity)); - - // Immediately go to falling state after jump impulse - update.character.move_state = MoveState::Fall(None); - update - } -} diff --git a/common/src/states/stand.rs b/common/src/states/stand.rs deleted file mode 100644 index c21a024b45..0000000000 --- a/common/src/states/stand.rs +++ /dev/null @@ -1,45 +0,0 @@ -use super::utils::*; -use crate::{ - comp::{CharacterEntityData, MoveState, StateUpdate}, - states::StateHandler, -}; - -#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State; - -impl StateHandler for State { - fn new(_ecs_data: &CharacterEntityData) -> Self { Self {} } - - fn handle(&self, ecs_data: &CharacterEntityData) -> StateUpdate { - let mut update = StateUpdate { - character: *ecs_data.character, - pos: *ecs_data.pos, - vel: *ecs_data.vel, - ori: *ecs_data.ori, - }; - - // Try to sit - if can_sit(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = MoveState::Sit(None); - return update; - } - - // Try to climb - if can_climb(ecs_data.physics, ecs_data.inputs, ecs_data.body) { - update.character.move_state = MoveState::Climb(None); - return update; - } - - // Try to jump - if can_jump(ecs_data.physics, ecs_data.inputs) { - update.character.move_state = MoveState::Jump(None); - return update; - } - - // Else update based on groundedness - update.character.move_state = - determine_move_from_grounded_state(ecs_data.physics, ecs_data.inputs); - - update - } -} diff --git a/common/src/states/swim.rs b/common/src/states/swim.rs deleted file mode 100644 index 0cb327296e..0000000000 --- a/common/src/states/swim.rs +++ /dev/null @@ -1,56 +0,0 @@ -use crate::{ - comp::StateUpdate, - sys::{character_behavior::JoinData, phys::GRAVITY}, -}; -use std::time::Duration; -use vek::{Vec2, Vec3}; - -const HUMANOID_WATER_ACCEL: f32 = 70.0; -const HUMANOID_WATER_SPEED: f32 = 120.0; - -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: *data.character, - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; - - // Update velocity - update.vel.0 += Vec2::broadcast(data.dt.0) - * data.inputs.move_dir - * if update.vel.0.magnitude_squared() < HUMANOID_WATER_SPEED.powf(2.0) { - HUMANOID_WATER_ACCEL - } else { - 0.0 - }; - - // Set direction based on move direction when on the ground - let ori_dir = if update.character.is_attack() || update.character.is_block() { - Vec2::from(data.inputs.look_dir).normalized() - } else { - Vec2::from(update.vel.0) - }; - - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = vek::ops::Slerp::slerp( - update.ori.0, - ori_dir.into(), - if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, - ); - } - - // Force players to pulse jump button to swim up - if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600)) - { - update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(HUMANOID_WATER_SPEED); - } - - update -} diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 209593d158..f127863d81 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -20,7 +20,8 @@ const BASE_HUMANOID_WATER_SPEED: f32 = 120.0; // const GLIDE_SPEED: f32 = 45.0; // const BLOCK_ACCEL: f32 = 30.0; // const BLOCK_SPEED: f32 = 75.0; -// // Gravity is 9.81 * 4, so this makes gravity equal to .15 +// Gravity is 9.81 * 4, so this makes gravity equal to .15 //TODO: <- is wrong +// // const GLIDE_ANTIGRAV: f32 = GRAVITY * 0.96; // const CLIMB_SPEED: f32 = 5.0; // const CLIMB_COST: i32 = 5; diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index 8df26f2390..2546af51a9 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -9,7 +9,7 @@ use crate::{ use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage}; use vek::*; -pub const GRAVITY: f32 = 9.81 * 10.0; +pub const GRAVITY: f32 = 9.81 * 5.0; const BOUYANCY: f32 = 0.0; // Friction values used for linear damping. They are unitless quantities. The // value of these quantities must be between zero and one. They represent the From a3fc3c3122dd5a8f3e4272ed763a154481a7f41c Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 10 Mar 2020 20:40:54 +0100 Subject: [PATCH 062/326] exit basic_attack when no weapon is equipped --- common/src/states/basic_attack.rs | 64 ++++++++++++++----------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index b635b657dc..31343305c6 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -21,58 +21,50 @@ pub fn behavior(data: &JoinData) -> StateUpdate { remaining_duration, } = data.character { - handle_move(data, &mut update); - let tool_kind = data.stats.equipment.main.as_ref().map(|i| i.kind); - let can_apply_damage = !*exhausted - && if let Some(Tool(tool)) = tool_kind { - *remaining_duration < tool.attack_recover_duration() - } else { - true - }; + if let Some(Tool(tool)) = tool_kind { + handle_move(data, &mut update); - let mut new_exhausted = *exhausted; + let mut new_exhausted = *exhausted; - if can_apply_damage { - if let Some(Tool(tool)) = tool_kind { + if !*exhausted && *remaining_duration < tool.attack_recover_duration() { data.updater.insert(data.entity, Attacking { weapon: Some(tool), applied: false, hit_count: 0, }); + new_exhausted = true; } - new_exhausted = true; - } - let new_remaining_duration = remaining_duration - .checked_sub(Duration::from_secs_f32(data.dt.0)) - .unwrap_or_default(); + let new_remaining_duration = remaining_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(); - if let Some(attack) = data.attacking { - if attack.applied && attack.hit_count > 0 { - data.updater.remove::(data.entity); - update.energy.change_by(100, EnergySource::HitEnemy); + if let Some(attack) = data.attacking { + if attack.applied && attack.hit_count > 0 { + data.updater.remove::(data.entity); + update.energy.change_by(100, EnergySource::HitEnemy); + } } - } - // Tick down - update.character = CharacterState::BasicAttack { - remaining_duration: new_remaining_duration, - exhausted: new_exhausted, - }; - - // Check if attack duration has expired - if new_remaining_duration == Duration::default() { - update.character = if let Some(Tool(tool)) = tool_kind { - CharacterState::Wielding { tool } - } else { - CharacterState::Idle {} + // Tick down + update.character = CharacterState::BasicAttack { + remaining_duration: new_remaining_duration, + exhausted: new_exhausted, }; - data.updater.remove::(data.entity); - } - update + // Check if attack duration has expired + if new_remaining_duration == Duration::default() { + update.character = CharacterState::Wielding { tool }; + data.updater.remove::(data.entity); + } + + update + } else { + update + } } else { + update.character = CharacterState::Idle {}; update } } From 77d2c2a2538adfd8d1382f3006f78b2f163b2aa9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 10 Mar 2020 22:03:29 +0000 Subject: [PATCH 063/326] temp allow failure in macos --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0a93f8de07..a1044fca4b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -205,6 +205,7 @@ macos: - assets/ - LICENSE expire_in: 1 week + allow_failure: true # -- # -- publish From 4e5d200b70b58ecab6ed0716dcef2db2b29a2903 Mon Sep 17 00:00:00 2001 From: Shane Handley Date: Thu, 12 Mar 2020 11:54:23 +0900 Subject: [PATCH 064/326] Fix: Make the dropped item collection range match the world item range limit. --- voxygen/src/session.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 52421d3975..7f8ecd2370 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -381,7 +381,7 @@ impl PlayState for SessionState { ) .join() .filter(|(_, pos, _)| { - pos.0.distance_squared(player_pos.0) < 3.0 * 3.0 + pos.0.distance_squared(player_pos.0) < MAX_PICKUP_RANGE_SQR }) .min_by_key(|(_, pos, _)| { (pos.0.distance_squared(player_pos.0) * 1000.0) as i32 From a64bf1ac60da08920f238519e6c6291238109b17 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Thu, 12 Mar 2020 05:16:40 -0700 Subject: [PATCH 065/326] TripleAttack -> TimedCombo (it wasnt the right logic for the tiple attack) --- common/src/comp/ability.rs | 4 ++-- common/src/comp/character_state.rs | 2 +- common/src/states/mod.rs | 2 +- common/src/states/{triple_attack/mod.rs => timed_combo.rs} | 6 +++--- common/src/states/utils.rs | 6 +++--- common/src/sys/character_behavior.rs | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) rename common/src/states/{triple_attack/mod.rs => timed_combo.rs} (94%) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index a6f9b41eef..bc10cc31d0 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -6,7 +6,7 @@ pub enum AbilityState { BasicBlock, Roll, ChargeAttack, - TripleAttack, + TimedCombo, } impl Default for AbilityState { fn default() -> Self { Self::BasicAttack } @@ -28,7 +28,7 @@ impl Default for AbilityPool { fn default() -> Self { Self { primary: Some(AbilityState::BasicAttack), - // primary: Some(AbilityState::TripleAttack), + // primary: Some(AbilityState::TimedCombo), secondary: Some(AbilityState::BasicBlock), block: None, dodge: Some(AbilityState::Roll), diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index cb3f239148..62716a3606 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -52,7 +52,7 @@ pub enum CharacterState { }, /// A three-stage attack where play must click at appropriate times /// to continue attack chain. - TripleAttack { + TimedCombo { /// The tool this state will read to handle damage, etc. tool: ToolData, /// `int` denoting what stage (of 3) the attack is in. diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 530679e37a..322060ecfb 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -8,6 +8,6 @@ pub mod glide; pub mod idle; pub mod roll; pub mod sit; -pub mod triple_attack; +pub mod timed_combo; pub mod utils; pub mod wielding; diff --git a/common/src/states/triple_attack/mod.rs b/common/src/states/timed_combo.rs similarity index 94% rename from common/src/states/triple_attack/mod.rs rename to common/src/states/timed_combo.rs index dc14398de5..aa176ead02 100644 --- a/common/src/states/triple_attack/mod.rs +++ b/common/src/states/timed_combo.rs @@ -16,7 +16,7 @@ pub fn behavior(data: &JoinData) -> StateUpdate { server_events: VecDeque::new(), }; - if let CharacterState::TripleAttack { + if let CharacterState::TimedCombo { tool, stage, stage_time_active, @@ -55,7 +55,7 @@ pub fn behavior(data: &JoinData) -> StateUpdate { if new_stage_time_active > tool.attack_duration() { if new_can_transition { - update.character = CharacterState::TripleAttack { + update.character = CharacterState::TimedCombo { tool: *tool, stage: 2, stage_time_active: Duration::default(), @@ -67,7 +67,7 @@ pub fn behavior(data: &JoinData) -> StateUpdate { attempt_wield(data, &mut update); } } else { - update.character = CharacterState::TripleAttack { + update.character = CharacterState::TimedCombo { tool: *tool, stage: 1, stage_time_active: new_stage_time_active, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index f127863d81..0859b83114 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -237,7 +237,7 @@ pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { } } -// TODO: Wight need a fn `CharacterState::new(data, update)` if +// TODO: Might need a fn `CharacterState::new(data, update)` if // initialization gets too lengthy. /// Maps from `AbilityState`s to `CharacterStates`s. Also handles intializing @@ -261,9 +261,9 @@ pub fn ability_to_character_state(data: &JoinData, ability_state: AbilityState) AbilityState::ChargeAttack { .. } => CharacterState::ChargeAttack { remaining_duration: Duration::from_millis(600), }, - AbilityState::TripleAttack { .. } => { + AbilityState::TimedCombo { .. } => { if let Some(tool) = unwrap_tool_data(data) { - CharacterState::TripleAttack { + CharacterState::TimedCombo { tool, stage: 1, stage_time_active: Duration::default(), diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 1a5accd49a..a50b4987d0 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -177,7 +177,7 @@ impl<'a> System<'a> for Sys { CharacterState::BasicBlock { .. } => states::basic_block::behavior(&j), CharacterState::ChargeAttack { .. } => states::charge_attack::behavior(&j), CharacterState::Sit { .. } => states::sit::behavior(&j), - CharacterState::TripleAttack { .. } => states::triple_attack::behavior(&j), + CharacterState::TimedCombo { .. } => states::triple_attack::behavior(&j), // Do not use default match. // _ => StateUpdate { From 3cb288bc8ca87855024213465e21290142e482db Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Thu, 12 Mar 2020 07:25:06 -0700 Subject: [PATCH 066/326] Add TripleStrike --- common/src/comp/character_state.rs | 14 ++++ common/src/states/mod.rs | 1 + common/src/states/triple_strike.rs | 102 +++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 common/src/states/triple_strike.rs diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 62716a3606..09c89e644a 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -64,6 +64,20 @@ pub enum CharacterState { /// Whether player has clicked at the proper time to go to next stage can_transition: bool, }, + /// A three-stage attack where each attack pushes player forward + /// and successive attacks increase in damage, while player holds button. + TripleStrike { + /// The tool this state will read to handle damage, etc. + tool: ToolData, + /// `int` denoting what stage (of 3) the attack is in. + stage: i8, + /// How long current stage has been active + stage_time_active: Duration, + /// Whether current stage has exhausted its attack + stage_exhausted: bool, + /// Whether player has clicked at the proper time to go to next stage + can_transition: bool, + }, } impl CharacterState { diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 322060ecfb..3598c5f7fb 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -9,5 +9,6 @@ pub mod idle; pub mod roll; pub mod sit; pub mod timed_combo; +pub mod triple_strike; pub mod utils; pub mod wielding; diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs new file mode 100644 index 0000000000..a73a23152c --- /dev/null +++ b/common/src/states/triple_strike.rs @@ -0,0 +1,102 @@ +use crate::{ + comp::{Attacking, CharacterState, ItemKind::Tool, StateUpdate}, + states::utils::*, + sys::character_behavior::JoinData, +}; +use std::{collections::VecDeque, time::Duration}; + +/// ### This behavior is a series of 3 attacks in sequence. +/// +/// Holding down the `primary` button executes a series of 3 attacks, +/// each one moves the player forward as the character steps into the swings. +/// The player can let go of the left mouse button at any time +/// and stop their attacks by interrupting the attack animation. +pub fn behavior(data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + + if let CharacterState::TripleStrike { + tool, + stage, + stage_time_active, + stage_exhausted, + } = data.character + { + let mut new_stage_exhausted = *stage_exhausted; + let new_stage_time_active = stage_time_active + .checked_add(Duration::from_secs_f32(data.dt.0)) + .unwrap_or(Duration::default()); + + if !data.inputs.primary.is_pressed() { + attempt_wield(data, &mut update); + } + + match stage { + 1 => { + if new_stage_time_active > tool.attack_buildup_duration() { + if !*stage_exhausted { + // Try to deal damage + data.updater.insert(data.entity, Attacking { + weapon: Some(*tool), + applied: false, + hit_count: 0, + }); + new_stage_exhausted = true; + } else { + // Make sure to remove Attacking component + data.updater.remove::(data.entity); + } + + // Check if player has timed click right + if data.inputs.primary.is_just_pressed() { + println!("Can transition"); + new_can_transition = true; + } + } + + if new_stage_time_active > tool.attack_duration() { + if new_can_transition { + update.character = CharacterState::TimedCombo { + tool: *tool, + stage: 2, + stage_time_active: Duration::default(), + stage_exhausted: false, + can_transition: false, + } + } else { + println!("Failed"); + attempt_wield(data, &mut update); + } + } else { + update.character = CharacterState::TimedCombo { + tool: *tool, + stage: 1, + stage_time_active: new_stage_time_active, + stage_exhausted: new_stage_exhausted, + can_transition: new_can_transition, + } + } + }, + 2 => { + println!("2"); + attempt_wield(data, &mut update); + }, + 3 => { + println!("3"); + attempt_wield(data, &mut update); + }, + _ => { + // Should never get here. + }, + } + } + + update +} From 772f7ff92d37d96e46079cb01ffc4a2107ddf4ad Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Thu, 12 Mar 2020 07:33:19 -0700 Subject: [PATCH 067/326] Remove can_transition and begin triple_strike --- common/src/comp/character_state.rs | 2 -- common/src/states/triple_strike.rs | 45 ++---------------------------- 2 files changed, 2 insertions(+), 45 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 09c89e644a..f7b4e4dbd6 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -75,8 +75,6 @@ pub enum CharacterState { stage_time_active: Duration, /// Whether current stage has exhausted its attack stage_exhausted: bool, - /// Whether player has clicked at the proper time to go to next stage - can_transition: bool, }, } diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index a73a23152c..8bd24e5a05 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -40,49 +40,8 @@ pub fn behavior(data: &JoinData) -> StateUpdate { match stage { 1 => { - if new_stage_time_active > tool.attack_buildup_duration() { - if !*stage_exhausted { - // Try to deal damage - data.updater.insert(data.entity, Attacking { - weapon: Some(*tool), - applied: false, - hit_count: 0, - }); - new_stage_exhausted = true; - } else { - // Make sure to remove Attacking component - data.updater.remove::(data.entity); - } - - // Check if player has timed click right - if data.inputs.primary.is_just_pressed() { - println!("Can transition"); - new_can_transition = true; - } - } - - if new_stage_time_active > tool.attack_duration() { - if new_can_transition { - update.character = CharacterState::TimedCombo { - tool: *tool, - stage: 2, - stage_time_active: Duration::default(), - stage_exhausted: false, - can_transition: false, - } - } else { - println!("Failed"); - attempt_wield(data, &mut update); - } - } else { - update.character = CharacterState::TimedCombo { - tool: *tool, - stage: 1, - stage_time_active: new_stage_time_active, - stage_exhausted: new_stage_exhausted, - can_transition: new_can_transition, - } - } + println!("1"); + attempt_wield(data, &mut update); }, 2 => { println!("2"); From 990ea5c5a2223439166747e9ff35c00eb3836a77 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Thu, 12 Mar 2020 07:34:24 -0700 Subject: [PATCH 068/326] Add triple_strike behavior to cs behavior sys --- common/src/sys/character_behavior.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index a50b4987d0..63380a94df 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -177,7 +177,8 @@ impl<'a> System<'a> for Sys { CharacterState::BasicBlock { .. } => states::basic_block::behavior(&j), CharacterState::ChargeAttack { .. } => states::charge_attack::behavior(&j), CharacterState::Sit { .. } => states::sit::behavior(&j), - CharacterState::TimedCombo { .. } => states::triple_attack::behavior(&j), + CharacterState::TripleStrike { .. } => states::triple_strike::behavior(&j), + CharacterState::TimedCombo { .. } => states::timed_combo::behavior(&j), // Do not use default match. // _ => StateUpdate { From 68dd8c578f8ac52239b4c881aa633e295560ced8 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Thu, 12 Mar 2020 07:36:02 -0700 Subject: [PATCH 069/326] Add some ability costs --- common/src/comp/ability.rs | 14 ++++++++++---- common/src/states/utils.rs | 25 +++++++++++++++---------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index bc10cc31d0..dc6b793961 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -2,14 +2,20 @@ use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage}; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum AbilityState { - BasicAttack, + BasicAttack { + /// Amount of energy required to use ability + cost: i32, + }, BasicBlock, Roll, ChargeAttack, - TimedCombo, + TimedCombo { + /// Amount of energy required to use ability + cost: i32, + }, } impl Default for AbilityState { - fn default() -> Self { Self::BasicAttack } + fn default() -> Self { Self::BasicAttack { cost: -100 } } } impl Component for AbilityState { @@ -27,7 +33,7 @@ pub struct AbilityPool { impl Default for AbilityPool { fn default() -> Self { Self { - primary: Some(AbilityState::BasicAttack), + primary: Some(AbilityState::default()), // primary: Some(AbilityState::TimedCombo), secondary: Some(AbilityState::BasicBlock), block: None, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 0859b83114..7c02539108 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -192,7 +192,7 @@ pub fn handle_primary_input(data: &JoinData, update: &mut StateUpdate) { /// Attempts to go into `ability_pool.primary` if is `Some()` on `AbilityPool` pub fn attempt_primary_ability(data: &JoinData, update: &mut StateUpdate) { if let Some(ability_state) = data.ability_pool.primary { - update.character = ability_to_character_state(data, ability_state); + update.character = ability_to_character_state(data, update, ability_state); } } @@ -209,7 +209,7 @@ pub fn handle_secondary_input(data: &JoinData, update: &mut StateUpdate) { /// Attempts to go into `ability_pool.secondary` if is `Some()` on `AbilityPool` pub fn attempt_seconday_ability(data: &JoinData, update: &mut StateUpdate) { if let Some(ability_state) = data.ability_pool.secondary { - update.character = ability_to_character_state(data, ability_state); + update.character = ability_to_character_state(data, update, ability_state); } } @@ -233,7 +233,7 @@ pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { if let Some(ability_state) = data.ability_pool.dodge { - update.character = ability_to_character_state(data, ability_state); + update.character = ability_to_character_state(data, update, ability_state); } } @@ -242,17 +242,22 @@ pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { /// Maps from `AbilityState`s to `CharacterStates`s. Also handles intializing /// the new `CharacterState` -pub fn ability_to_character_state(data: &JoinData, ability_state: AbilityState) -> CharacterState { +pub fn ability_to_character_state( + data: &JoinData, + update: &mut StateUpdate, + ability_state: AbilityState, +) -> CharacterState { match ability_state { - AbilityState::BasicAttack { .. } => { - if let Some(tool) = unwrap_tool_data(data) { - CharacterState::BasicAttack { + AbilityState::BasicAttack { cost, .. } => { + if let Some(tool) = unwrap_tool_data(data) { + if update.energy.try_change_by(cost, EnergySource::HitEnemy).is_ok() { + return CharacterState::BasicAttack { exhausted: false, remaining_duration: tool.attack_duration(), - } - } else { - *data.character + }; } + } + *data.character }, AbilityState::BasicBlock { .. } => CharacterState::BasicBlock {}, AbilityState::Roll { .. } => CharacterState::Roll { From 00e4ad61f7c911177fdfc8084cccb68eb9953008 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Thu, 12 Mar 2020 07:47:27 -0700 Subject: [PATCH 070/326] add ToolData::get_primary_abilities() --- common/src/comp/inventory/item.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 27549b101e..2636d0a245 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -1,5 +1,6 @@ use crate::{ assets::{self, Asset}, + comp::AbilityState, effect::Effect, terrain::{Block, BlockKind}, }; @@ -7,7 +8,7 @@ use crate::{ use rand::seq::SliceRandom; use specs::{Component, FlaggedStorage}; use specs_idvs::IDVStorage; -use std::{fs::File, io::BufReader, time::Duration}; +use std::{fs::File, io::BufReader, time::Duration, vec::Vec}; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum SwordKind { @@ -45,6 +46,22 @@ impl ToolData { pub fn attack_duration(&self) -> Duration { self.attack_buildup_duration() + self.attack_recover_duration() } + + pub fn get_primary_abilities(&self) -> Vec { + use AbilityState::*; + use SwordKind::*; + use ToolKind::*; + + let default_return = vec![AbilityState::default()]; + + match self.kind { + Sword(kind) => match kind { + Rapier => vec![TimedCombo { cost: -150 }], + Scimitar => default_return, + }, + _ => default_return, + } + } } #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] From ac1c279a9b55d0a3c6191026261e1160f2c5aef6 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Thu, 12 Mar 2020 08:22:42 -0700 Subject: [PATCH 071/326] Begin TripleStrike Logic --- common/src/states/triple_strike.rs | 37 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 8bd24e5a05..60f5d9e63b 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -5,10 +5,13 @@ use crate::{ }; use std::{collections::VecDeque, time::Duration}; -/// ### This behavior is a series of 3 attacks in sequence. +// In millis +const STAGE_DURATION: u64 = 600; + +/// ### A sequence of 3 incrementally increasing attacks. /// -/// Holding down the `primary` button executes a series of 3 attacks, -/// each one moves the player forward as the character steps into the swings. +/// While holding down the `primary` button, perform a series of 3 attacks, +/// each one pushes the player forward as the character steps into the swings. /// The player can let go of the left mouse button at any time /// and stop their attacks by interrupting the attack animation. pub fn behavior(data: &JoinData) -> StateUpdate { @@ -34,26 +37,22 @@ pub fn behavior(data: &JoinData) -> StateUpdate { .checked_add(Duration::from_secs_f32(data.dt.0)) .unwrap_or(Duration::default()); + // If player stops holding input, if !data.inputs.primary.is_pressed() { attempt_wield(data, &mut update); + return update; } - match stage { - 1 => { - println!("1"); - attempt_wield(data, &mut update); - }, - 2 => { - println!("2"); - attempt_wield(data, &mut update); - }, - 3 => { - println!("3"); - attempt_wield(data, &mut update); - }, - _ => { - // Should never get here. - }, + while *stage < 3 { + if new_stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { + // Move player forward while in first third of each stage + handle_move(data, &mut update); + } else if new_stage_time_active > Duration::from_millis(STAGE_DURATION / 2) + && !new_stage_exhausted + { + // Try to deal damage in second half of stage + // TODO: deal damage + } } } From fe19698d52a0ff0ed9e1d382ecb876e54bc7777c Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sat, 14 Mar 2020 16:40:29 +0100 Subject: [PATCH 072/326] Make abilities depend on weapon --- common/src/comp/ability.rs | 55 ++++++++----- common/src/comp/character_state.rs | 16 ++-- common/src/comp/inventory/item.rs | 66 +++++++++------- common/src/comp/inventory/mod.rs | 2 +- common/src/comp/mod.rs | 2 +- common/src/msg/ecs_packet.rs | 12 +-- common/src/state.rs | 2 +- common/src/states/basic_attack.rs | 70 ++++++++++------- common/src/states/timed_combo.rs | 122 +++++++++++++++-------------- common/src/states/utils.rs | 74 +++-------------- server/src/lib.rs | 24 +++++- voxygen/src/hud/skillbar.rs | 6 +- 12 files changed, 228 insertions(+), 223 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index dc6b793961..5c3b4ef801 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1,10 +1,12 @@ +use crate::comp::CharacterState; use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage}; +use std::time::Duration; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum AbilityState { +pub enum CharacterAbility { BasicAttack { - /// Amount of energy required to use ability - cost: i32, + buildup_duration: Duration, + recover_duration: Duration, }, BasicBlock, Roll, @@ -14,30 +16,43 @@ pub enum AbilityState { cost: i32, }, } -impl Default for AbilityState { - fn default() -> Self { Self::BasicAttack { cost: -100 } } -} -impl Component for AbilityState { +impl Component for CharacterAbility { type Storage = DenseVecStorage; } -#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize)] pub struct AbilityPool { - pub primary: Option, - pub secondary: Option, - pub block: Option, - pub dodge: Option, + pub primary: Option, + pub secondary: Option, + pub block: Option, + pub dodge: Option, } -impl Default for AbilityPool { - fn default() -> Self { - Self { - primary: Some(AbilityState::default()), - // primary: Some(AbilityState::TimedCombo), - secondary: Some(AbilityState::BasicBlock), - block: None, - dodge: Some(AbilityState::Roll), +impl From for CharacterState { + fn from(ability: CharacterAbility) -> Self { + match ability { + CharacterAbility::BasicAttack { + buildup_duration, + recover_duration, + } => CharacterState::BasicAttack { + exhausted: false, + buildup_duration, + recover_duration, + }, + CharacterAbility::BasicBlock { .. } => CharacterState::BasicBlock {}, + CharacterAbility::Roll { .. } => CharacterState::Roll { + remaining_duration: Duration::from_millis(600), + }, + CharacterAbility::ChargeAttack { .. } => CharacterState::ChargeAttack { + remaining_duration: Duration::from_millis(600), + }, + CharacterAbility::TimedCombo { .. } => CharacterState::TimedCombo { + stage: 1, + stage_time_active: Duration::default(), + stage_exhausted: false, + can_transition: false, + }, } } } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index f7b4e4dbd6..4ba4af1e57 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -19,8 +19,8 @@ pub struct StateUpdate { #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum CharacterState { - Idle {}, - Climb {}, + Idle, + Climb, Sit {}, Equipping { /// The weapon being equipped @@ -32,16 +32,18 @@ pub enum CharacterState { /// The weapon being wielded tool: ToolData, }, - Glide {}, + Glide, /// A basic attacking state BasicAttack { - /// How long the state has until exiting - remaining_duration: Duration, + /// How long till the state deals damage + buildup_duration: Duration, + /// How long till the state remains after dealing damage + recover_duration: Duration, /// Whether the attack can deal more damage exhausted: bool, }, /// A basic blocking state - BasicBlock {}, + BasicBlock, ChargeAttack { /// How long the state has until exiting remaining_duration: Duration, @@ -53,8 +55,6 @@ pub enum CharacterState { /// A three-stage attack where play must click at appropriate times /// to continue attack chain. TimedCombo { - /// The tool this state will read to handle damage, etc. - tool: ToolData, /// `int` denoting what stage (of 3) the attack is in. stage: i8, /// How long current stage has been active diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 2636d0a245..e24a107507 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -1,6 +1,6 @@ use crate::{ assets::{self, Asset}, - comp::AbilityState, + comp::CharacterAbility, effect::Effect, terrain::{Block, BlockKind}, }; @@ -25,47 +25,55 @@ pub enum ToolKind { Dagger, Staff, Shield, - Debug(Debug), -} - -impl Default for ToolKind { - fn default() -> Self { Self::Axe } + Debug(DebugKind), } impl ToolData { pub fn equip_time(&self) -> Duration { Duration::from_millis(self.equip_time_millis) } - pub fn attack_buildup_duration(&self) -> Duration { - Duration::from_millis(self.attack_buildup_millis) - } - - pub fn attack_recover_duration(&self) -> Duration { - Duration::from_millis(self.attack_recover_millis) - } - - pub fn attack_duration(&self) -> Duration { - self.attack_buildup_duration() + self.attack_recover_duration() - } - - pub fn get_primary_abilities(&self) -> Vec { - use AbilityState::*; - use SwordKind::*; + pub fn get_abilities(&self) -> Vec { + use CharacterAbility::*; + use DebugKind::*; use ToolKind::*; - let default_return = vec![AbilityState::default()]; - match self.kind { - Sword(kind) => match kind { - Rapier => vec![TimedCombo { cost: -150 }], - Scimitar => default_return, + Sword(_) => vec![TimedCombo { cost: -150 }], + Axe => vec![BasicAttack { + buildup_duration: Duration::from_millis(1000), + recover_duration: Duration::from_millis(500), + }], + Hammer => vec![BasicAttack { + buildup_duration: Duration::from_millis(1000), + recover_duration: Duration::from_millis(500), + }], + Bow => vec![BasicAttack { + buildup_duration: Duration::from_millis(1000), + recover_duration: Duration::from_millis(500), + }], + Dagger => vec![BasicAttack { + buildup_duration: Duration::from_millis(1000), + recover_duration: Duration::from_millis(500), + }], + Staff => vec![BasicAttack { + buildup_duration: Duration::from_millis(1000), + recover_duration: Duration::from_millis(500), + }], + Shield => vec![BasicAttack { + buildup_duration: Duration::from_millis(1000), + recover_duration: Duration::from_millis(500), + }], + Debug(kind) => match kind { + Boost => vec![], + Possess => vec![], }, - _ => default_return, + + _ => vec![], } } } #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum Debug { +pub enum DebugKind { Boost, Possess, } @@ -109,7 +117,7 @@ pub enum Ingredient { Grass, } -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct ToolData { pub kind: ToolKind, equip_time_millis: u64, diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 9f15789a9d..13ff8449f4 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -1,7 +1,7 @@ pub mod item; // Reexports -pub use item::{Consumable, Debug, Item, ItemKind, SwordKind, ToolData, ToolKind}; +pub use item::{Consumable, DebugKind, Item, ItemKind, SwordKind, ToolData, ToolKind}; use crate::assets; use specs::{Component, FlaggedStorage, HashMapStorage}; diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 940c8f4130..8a6fe50631 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -16,7 +16,7 @@ mod stats; mod visual; // Reexports -pub use ability::{AbilityPool, AbilityState}; +pub use ability::{AbilityPool, CharacterAbility}; pub use admin::Admin; pub use agent::{Agent, Alignment}; pub use body::{ diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index 91d78d35d7..f0135dd3c4 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -21,7 +21,7 @@ sum_type! { Mass(comp::Mass), Gravity(comp::Gravity), Sticky(comp::Sticky), - AbilityState(comp::AbilityState), + CharacterAbility(comp::CharacterAbility), AbilityPool(comp::AbilityPool), Attacking(comp::Attacking), CharacterState(comp::CharacterState), @@ -45,7 +45,7 @@ sum_type! { Mass(PhantomData), Gravity(PhantomData), Sticky(PhantomData), - AbilityState(PhantomData), + CharacterAbility(PhantomData), AbilityPool(PhantomData), Attacking(PhantomData), CharacterState(PhantomData), @@ -69,7 +69,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Mass(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Gravity(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_insert(comp, entity, world), - EcsCompPacket::AbilityState(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::CharacterAbility(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::AbilityPool(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Attacking(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::CharacterState(comp) => sync::handle_insert(comp, entity, world), @@ -91,7 +91,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Mass(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Gravity(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_modify(comp, entity, world), - EcsCompPacket::AbilityState(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::CharacterAbility(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::AbilityPool(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Attacking(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::CharacterState(comp) => sync::handle_modify(comp, entity, world), @@ -115,8 +115,8 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPhantom::Mass(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Gravity(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Sticky(_) => sync::handle_remove::(entity, world), - EcsCompPhantom::AbilityState(_) => { - sync::handle_remove::(entity, world) + EcsCompPhantom::CharacterAbility(_) => { + sync::handle_remove::(entity, world) }, EcsCompPhantom::AbilityPool(_) => { sync::handle_remove::(entity, world) diff --git a/common/src/state.rs b/common/src/state.rs index 0e07b75659..5fdbc211f6 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -107,7 +107,7 @@ impl State { ecs.register_sync_marker(); // Register server -> all clients synced components. ecs.register::(); - ecs.register::(); + ecs.register::(); ecs.register::(); ecs.register::(); ecs.register::(); diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index 31343305c6..782a93f00d 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -18,51 +18,65 @@ pub fn behavior(data: &JoinData) -> StateUpdate { if let CharacterState::BasicAttack { exhausted, - remaining_duration, + buildup_duration, + recover_duration, } = data.character { let tool_kind = data.stats.equipment.main.as_ref().map(|i| i.kind); - if let Some(Tool(tool)) = tool_kind { - handle_move(data, &mut update); + handle_move(data, &mut update); - let mut new_exhausted = *exhausted; - - if !*exhausted && *remaining_duration < tool.attack_recover_duration() { + if buildup_duration != &Duration::default() { + // Start to swing + update.character = CharacterState::BasicAttack { + buildup_duration: buildup_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), + recover_duration: *recover_duration, + exhausted: false, + }; + } else if !*exhausted { + // Swing hits + if let Some(Tool(tool)) = tool_kind { data.updater.insert(data.entity, Attacking { weapon: Some(tool), applied: false, hit_count: 0, }); - new_exhausted = true; } - let new_remaining_duration = remaining_duration - .checked_sub(Duration::from_secs_f32(data.dt.0)) - .unwrap_or_default(); - - if let Some(attack) = data.attacking { - if attack.applied && attack.hit_count > 0 { - data.updater.remove::(data.entity); - update.energy.change_by(100, EnergySource::HitEnemy); - } - } - - // Tick down update.character = CharacterState::BasicAttack { - remaining_duration: new_remaining_duration, - exhausted: new_exhausted, + buildup_duration: *buildup_duration, + recover_duration: *recover_duration, + exhausted: true, }; - - // Check if attack duration has expired - if new_remaining_duration == Duration::default() { + } else if recover_duration != &Duration::default() { + // Recover from swing + update.character = CharacterState::BasicAttack { + buildup_duration: *buildup_duration, + recover_duration: recover_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), + exhausted: true, + } + } else { + // Done + if let Some(Tool(tool)) = tool_kind { update.character = CharacterState::Wielding { tool }; data.updater.remove::(data.entity); + } else { + update.character = CharacterState::Idle; } - - update - } else { - update } + + // More handling + if let Some(attack) = data.attacking { + if attack.applied && attack.hit_count > 0 { + data.updater.remove::(data.entity); + update.energy.change_by(100, EnergySource::HitEnemy); + } + } + + update } else { update.character = CharacterState::Idle {}; update diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index aa176ead02..18380a2fc0 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -17,77 +17,81 @@ pub fn behavior(data: &JoinData) -> StateUpdate { }; if let CharacterState::TimedCombo { - tool, stage, stage_time_active, stage_exhausted, can_transition, } = data.character { - let mut new_can_transition = *can_transition; - let mut new_stage_exhausted = *stage_exhausted; - let new_stage_time_active = stage_time_active - .checked_add(Duration::from_secs_f32(data.dt.0)) - .unwrap_or(Duration::default()); + // Sorry adam, I don't want to fix this rn, check out basic_attack to + // see how to do it + // + /* + let mut new_can_transition = *can_transition; + let mut new_stage_exhausted = *stage_exhausted; + let new_stage_time_active = stage_time_active + .checked_add(Duration::from_secs_f32(data.dt.0)) + .unwrap_or(Duration::default()); - match stage { - 1 => { - if new_stage_time_active > tool.attack_buildup_duration() { - if !*stage_exhausted { - // Try to deal damage - data.updater.insert(data.entity, Attacking { - weapon: Some(*tool), - applied: false, - hit_count: 0, - }); - new_stage_exhausted = true; - } else { - // Make sure to remove Attacking component - data.updater.remove::(data.entity); + match stage { + 1 => { + if new_stage_time_active > tool.attack_buildup_duration() { + if !*stage_exhausted { + // Try to deal damage + data.updater.insert(data.entity, Attacking { + weapon: Some(*tool), + applied: false, + hit_count: 0, + }); + new_stage_exhausted = true; + } else { + // Make sure to remove Attacking component + data.updater.remove::(data.entity); + } + + // Check if player has timed click right + if data.inputs.primary.is_just_pressed() { + println!("Can transition"); + new_can_transition = true; + } } - // Check if player has timed click right - if data.inputs.primary.is_just_pressed() { - println!("Can transition"); - new_can_transition = true; - } - } - - if new_stage_time_active > tool.attack_duration() { - if new_can_transition { - update.character = CharacterState::TimedCombo { - tool: *tool, - stage: 2, - stage_time_active: Duration::default(), - stage_exhausted: false, - can_transition: false, + if new_stage_time_active > tool.attack_duration() { + if new_can_transition { + update.character = CharacterState::TimedCombo { + tool: *tool, + stage: 2, + stage_time_active: Duration::default(), + stage_exhausted: false, + can_transition: false, + } + } else { + println!("Failed"); + attempt_wield(data, &mut update); } } else { - println!("Failed"); - attempt_wield(data, &mut update); + update.character = CharacterState::TimedCombo { + tool: *tool, + stage: 1, + stage_time_active: new_stage_time_active, + stage_exhausted: new_stage_exhausted, + can_transition: new_can_transition, + } } - } else { - update.character = CharacterState::TimedCombo { - tool: *tool, - stage: 1, - stage_time_active: new_stage_time_active, - stage_exhausted: new_stage_exhausted, - can_transition: new_can_transition, - } - } - }, - 2 => { - println!("2"); - attempt_wield(data, &mut update); - }, - 3 => { - println!("3"); - attempt_wield(data, &mut update); - }, - _ => { - // Should never get here. - }, - } + }, + 2 => { + println!("2"); + attempt_wield(data, &mut update); + }, + 3 => { + println!("3"); + attempt_wield(data, &mut update); + }, + _ => { + // Should never get here. + }, + } + */ } update diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 7c02539108..3cf8c014b2 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{AbilityState, CharacterState, EnergySource, ItemKind::Tool, StateUpdate, ToolData}, + comp::{CharacterAbility, CharacterState, EnergySource, ItemKind::Tool, StateUpdate, ToolData}, event::LocalEvent, sys::{character_behavior::JoinData, phys::GRAVITY}, }; @@ -191,8 +191,8 @@ pub fn handle_primary_input(data: &JoinData, update: &mut StateUpdate) { /// Attempts to go into `ability_pool.primary` if is `Some()` on `AbilityPool` pub fn attempt_primary_ability(data: &JoinData, update: &mut StateUpdate) { - if let Some(ability_state) = data.ability_pool.primary { - update.character = ability_to_character_state(data, update, ability_state); + if let Some(ability) = data.ability_pool.primary { + update.character = ability.into(); } } @@ -201,15 +201,15 @@ pub fn attempt_primary_ability(data: &JoinData, update: &mut StateUpdate) { pub fn handle_secondary_input(data: &JoinData, update: &mut StateUpdate) { if data.inputs.secondary.is_pressed() { if let CharacterState::Wielding { .. } = update.character { - attempt_seconday_ability(data, update); + attempt_secondary_ability(data, update); } } } /// Attempts to go into `ability_pool.secondary` if is `Some()` on `AbilityPool` -pub fn attempt_seconday_ability(data: &JoinData, update: &mut StateUpdate) { - if let Some(ability_state) = data.ability_pool.secondary { - update.character = ability_to_character_state(data, update, ability_state); +pub fn attempt_secondary_ability(data: &JoinData, update: &mut StateUpdate) { + if let Some(ability) = data.ability_pool.secondary { + update.character = ability.into(); } } @@ -232,63 +232,7 @@ pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { } pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { - if let Some(ability_state) = data.ability_pool.dodge { - update.character = ability_to_character_state(data, update, ability_state); - } -} - -// TODO: Might need a fn `CharacterState::new(data, update)` if -// initialization gets too lengthy. - -/// Maps from `AbilityState`s to `CharacterStates`s. Also handles intializing -/// the new `CharacterState` -pub fn ability_to_character_state( - data: &JoinData, - update: &mut StateUpdate, - ability_state: AbilityState, -) -> CharacterState { - match ability_state { - AbilityState::BasicAttack { cost, .. } => { - if let Some(tool) = unwrap_tool_data(data) { - if update.energy.try_change_by(cost, EnergySource::HitEnemy).is_ok() { - return CharacterState::BasicAttack { - exhausted: false, - remaining_duration: tool.attack_duration(), - }; - } - } - *data.character - }, - AbilityState::BasicBlock { .. } => CharacterState::BasicBlock {}, - AbilityState::Roll { .. } => CharacterState::Roll { - remaining_duration: Duration::from_millis(600), - }, - AbilityState::ChargeAttack { .. } => CharacterState::ChargeAttack { - remaining_duration: Duration::from_millis(600), - }, - AbilityState::TimedCombo { .. } => { - if let Some(tool) = unwrap_tool_data(data) { - CharacterState::TimedCombo { - tool, - stage: 1, - stage_time_active: Duration::default(), - stage_exhausted: false, - can_transition: false, - } - } else { - *data.character - } - }, - - // Do not use default match - // _ => *data.character - } -} - -pub fn unwrap_tool_data(data: &JoinData) -> Option { - if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { - Some(tool) - } else { - None + if let Some(ability) = data.ability_pool.dodge { + update.character = ability.into(); } } diff --git a/server/src/lib.rs b/server/src/lib.rs index 637b11d5ec..ebe6dd8d84 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -272,7 +272,7 @@ impl Server { let spawn_point = state.ecs().read_resource::().0; state.write_component(entity, body); - state.write_component(entity, comp::Stats::new(name, body, main)); + state.write_component(entity, comp::Stats::new(name, body, main.clone())); state.write_component(entity, comp::Energy::new(1000)); state.write_component(entity, comp::Controller::default()); state.write_component(entity, comp::Pos(spawn_point)); @@ -286,7 +286,27 @@ impl Server { entity, comp::InventoryUpdate::new(comp::InventoryUpdateEvent::default()), ); - state.write_component(entity, comp::AbilityPool::default()); + + state.write_component( + entity, + if let Some(comp::Item { + kind: comp::ItemKind::Tool(tool), + .. + }) = main + { + let mut abilities = tool.get_abilities(); + let mut ability_drain = abilities.drain(..); + comp::AbilityPool { + primary: ability_drain.next(), + secondary: ability_drain.next(), + block: Some(comp::CharacterAbility::BasicBlock), + dodge: Some(comp::CharacterAbility::Roll), + } + } else { + comp::AbilityPool::default() + }, + ); + // Make sure physics are accepted. state.write_component(entity, comp::ForceUpdate); diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 1ed37221d5..8df29bac07 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -10,7 +10,7 @@ use crate::{ use common::{ assets::load_expect, comp::{ - item::{Debug, ToolData, ToolKind}, + item::{DebugKind, ToolData, ToolKind}, CharacterState, ControllerInputs, Energy, ItemKind, Stats, }, }; @@ -597,7 +597,7 @@ impl<'a> Widget for Skillbar<'a> { ToolKind::Axe => self.imgs.twohaxe_m1, ToolKind::Bow => self.imgs.bow_m1, ToolKind::Staff => self.imgs.staff_m1, - ToolKind::Debug(Debug::Boost) => self.imgs.flyingrod_m1, + ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m1, _ => self.imgs.twohaxe_m1, }, _ => self.imgs.twohaxe_m1, @@ -690,7 +690,7 @@ impl<'a> Widget for Skillbar<'a> { ToolKind::Axe => self.imgs.twohaxe_m2, ToolKind::Bow => self.imgs.bow_m2, ToolKind::Staff => self.imgs.staff_m2, - ToolKind::Debug(Debug::Boost) => self.imgs.flyingrod_m2, + ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m2, _ => self.imgs.twohaxe_m2, }, _ => self.imgs.twohaxe_m2, From 6fc94c22ba3439fc24bca6507eedb5f7495aa573 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sat, 14 Mar 2020 12:50:07 -0600 Subject: [PATCH 073/326] Update timed combo, add CharacerBehavior trait --- common/src/comp/ability.rs | 30 ++-- common/src/comp/character_state.rs | 34 ++-- common/src/comp/inventory/item.rs | 6 +- common/src/states/basic_attack.rs | 94 ++++++----- common/src/states/timed_combo.rs | 225 ++++++++++++++++----------- common/src/states/utils.rs | 9 ++ common/src/sys/character_behavior.rs | 11 +- voxygen/src/scene/figure/mod.rs | 18 ++- 8 files changed, 253 insertions(+), 174 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 5c3b4ef801..8c56e7af5a 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1,4 +1,7 @@ -use crate::comp::CharacterState; +use crate::{ + comp::{CharacterState, ToolData}, + states::*, +}; use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage}; use std::time::Duration; @@ -12,8 +15,9 @@ pub enum CharacterAbility { Roll, ChargeAttack, TimedCombo { - /// Amount of energy required to use ability - cost: i32, + tool: ToolData, + buildup_duration: Duration, + recover_duration: Duration, }, } @@ -35,11 +39,11 @@ impl From for CharacterState { CharacterAbility::BasicAttack { buildup_duration, recover_duration, - } => CharacterState::BasicAttack { + } => CharacterState::BasicAttack(basic_attack::State { exhausted: false, buildup_duration, recover_duration, - }, + }), CharacterAbility::BasicBlock { .. } => CharacterState::BasicBlock {}, CharacterAbility::Roll { .. } => CharacterState::Roll { remaining_duration: Duration::from_millis(600), @@ -47,12 +51,18 @@ impl From for CharacterState { CharacterAbility::ChargeAttack { .. } => CharacterState::ChargeAttack { remaining_duration: Duration::from_millis(600), }, - CharacterAbility::TimedCombo { .. } => CharacterState::TimedCombo { - stage: 1, - stage_time_active: Duration::default(), + CharacterAbility::TimedCombo { + tool, + buildup_duration, + recover_duration, + } => CharacterState::TimedCombo(timed_combo::State { + tool, + buildup_duration, + recover_duration, + stage: 0, stage_exhausted: false, - can_transition: false, - }, + stage_time_active: Duration::default(), + }), } } } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 4ba4af1e57..fa2460a15b 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,6 +1,7 @@ use crate::{ comp::{Energy, Ori, Pos, ToolData, Vel}, event::{LocalEvent, ServerEvent}, + states::*, }; use serde::{Deserialize, Serialize}; use specs::{Component, FlaggedStorage, HashMapStorage, VecStorage}; @@ -33,15 +34,6 @@ pub enum CharacterState { tool: ToolData, }, Glide, - /// A basic attacking state - BasicAttack { - /// How long till the state deals damage - buildup_duration: Duration, - /// How long till the state remains after dealing damage - recover_duration: Duration, - /// Whether the attack can deal more damage - exhausted: bool, - }, /// A basic blocking state BasicBlock, ChargeAttack { @@ -52,18 +44,11 @@ pub enum CharacterState { /// How long the state has until exiting remaining_duration: Duration, }, + /// A basic attacking state + BasicAttack(basic_attack::State), /// A three-stage attack where play must click at appropriate times /// to continue attack chain. - TimedCombo { - /// `int` denoting what stage (of 3) the attack is in. - stage: i8, - /// How long current stage has been active - stage_time_active: Duration, - /// Whether current stage has exhausted its attack - stage_exhausted: bool, - /// Whether player has clicked at the proper time to go to next stage - can_transition: bool, - }, + TimedCombo(timed_combo::State), /// A three-stage attack where each attack pushes player forward /// and successive attacks increase in damage, while player holds button. TripleStrike { @@ -81,16 +66,19 @@ pub enum CharacterState { impl CharacterState { pub fn is_wield(&self) -> bool { match self { - CharacterState::Wielding { .. } => true, - CharacterState::BasicAttack { .. } => true, - CharacterState::BasicBlock { .. } => true, + CharacterState::Wielding { .. } + | CharacterState::BasicAttack(_) + | CharacterState::TimedCombo(_) + | CharacterState::BasicBlock { .. } => true, _ => false, } } pub fn is_attack(&self) -> bool { match self { - CharacterState::BasicAttack { .. } | CharacterState::ChargeAttack { .. } => true, + CharacterState::BasicAttack(_) + | CharacterState::TimedCombo(_) + | CharacterState::ChargeAttack { .. } => true, _ => false, } } diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index e24a107507..52cfd42639 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -37,7 +37,11 @@ impl ToolData { use ToolKind::*; match self.kind { - Sword(_) => vec![TimedCombo { cost: -150 }], + Sword(_) => vec![TimedCombo { + buildup_duration: Duration::from_millis(1000), + recover_duration: Duration::from_millis(500), + tool: *self, + }], Axe => vec![BasicAttack { buildup_duration: Duration::from_millis(1000), recover_duration: Duration::from_millis(500), diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index 782a93f00d..4bf8f67108 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -1,42 +1,50 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, ItemKind::Tool, StateUpdate}, states::utils::*, - sys::character_behavior::JoinData, + sys::character_behavior::*, }; use std::{collections::VecDeque, time::Duration}; -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: *data.character, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct State { + /// How long until state should deal damage + pub buildup_duration: Duration, + /// How long the state has until exiting + pub recover_duration: Duration, + /// Whether the attack can deal more damage + pub exhausted: bool, +} + +impl CharacterBehavior for State { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; - if let CharacterState::BasicAttack { - exhausted, - buildup_duration, - recover_duration, - } = data.character - { - let tool_kind = data.stats.equipment.main.as_ref().map(|i| i.kind); handle_move(data, &mut update); - if buildup_duration != &Duration::default() { + // Build up window + if self.buildup_duration != Duration::default() { // Start to swing - update.character = CharacterState::BasicAttack { - buildup_duration: buildup_duration + update.character = CharacterState::BasicAttack(State { + buildup_duration: self + .buildup_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), - recover_duration: *recover_duration, + recover_duration: self.recover_duration, exhausted: false, - }; - } else if !*exhausted { + }); + } + // Hit attempt window + else if !self.exhausted { // Swing hits - if let Some(Tool(tool)) = tool_kind { + if let Some(tool) = unwrap_tool_data(data) { data.updater.insert(data.entity, Attacking { weapon: Some(tool), applied: false, @@ -44,31 +52,34 @@ pub fn behavior(data: &JoinData) -> StateUpdate { }); } - update.character = CharacterState::BasicAttack { - buildup_duration: *buildup_duration, - recover_duration: *recover_duration, + update.character = CharacterState::BasicAttack(State { + buildup_duration: self.buildup_duration, + recover_duration: self.recover_duration, exhausted: true, - }; - } else if recover_duration != &Duration::default() { - // Recover from swing - update.character = CharacterState::BasicAttack { - buildup_duration: *buildup_duration, - recover_duration: recover_duration + }); + } + // Swing recovery window + else if self.recover_duration != Duration::default() { + update.character = CharacterState::BasicAttack(State { + buildup_duration: self.buildup_duration, + recover_duration: self + .recover_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), exhausted: true, - } - } else { - // Done - if let Some(Tool(tool)) = tool_kind { + }); + } + // Done + else { + if let Some(tool) = unwrap_tool_data(data) { update.character = CharacterState::Wielding { tool }; + // Make sure attack component is removed data.updater.remove::(data.entity); } else { update.character = CharacterState::Idle; } } - - // More handling + // Subtract energy on successful hit if let Some(attack) = data.attacking { if attack.applied && attack.hit_count > 0 { data.updater.remove::(data.entity); @@ -76,9 +87,6 @@ pub fn behavior(data: &JoinData) -> StateUpdate { } } - update - } else { - update.character = CharacterState::Idle {}; update } } diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index 18380a2fc0..1c70c371ac 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -1,98 +1,137 @@ use crate::{ - comp::{Attacking, CharacterState, ItemKind::Tool, StateUpdate}, + comp::{Attacking, CharacterState, EnergySource, StateUpdate, ToolData}, states::utils::*, - sys::character_behavior::JoinData, + sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::{collections::VecDeque, time::Duration}; - -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: *data.character, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; - - if let CharacterState::TimedCombo { - stage, - stage_time_active, - stage_exhausted, - can_transition, - } = data.character - { - // Sorry adam, I don't want to fix this rn, check out basic_attack to - // see how to do it - // - /* - let mut new_can_transition = *can_transition; - let mut new_stage_exhausted = *stage_exhausted; - let new_stage_time_active = stage_time_active - .checked_add(Duration::from_secs_f32(data.dt.0)) - .unwrap_or(Duration::default()); - - match stage { - 1 => { - if new_stage_time_active > tool.attack_buildup_duration() { - if !*stage_exhausted { - // Try to deal damage - data.updater.insert(data.entity, Attacking { - weapon: Some(*tool), - applied: false, - hit_count: 0, - }); - new_stage_exhausted = true; - } else { - // Make sure to remove Attacking component - data.updater.remove::(data.entity); - } - - // Check if player has timed click right - if data.inputs.primary.is_just_pressed() { - println!("Can transition"); - new_can_transition = true; - } - } - - if new_stage_time_active > tool.attack_duration() { - if new_can_transition { - update.character = CharacterState::TimedCombo { - tool: *tool, - stage: 2, - stage_time_active: Duration::default(), - stage_exhausted: false, - can_transition: false, - } - } else { - println!("Failed"); - attempt_wield(data, &mut update); - } - } else { - update.character = CharacterState::TimedCombo { - tool: *tool, - stage: 1, - stage_time_active: new_stage_time_active, - stage_exhausted: new_stage_exhausted, - can_transition: new_can_transition, - } - } - }, - 2 => { - println!("2"); - attempt_wield(data, &mut update); - }, - 3 => { - println!("3"); - attempt_wield(data, &mut update); - }, - _ => { - // Should never get here. - }, - } - */ - } - - update +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct State { + /// Denotes what stage (of 3) the attack is in + pub stage: i8, + /// Whether current stage has exhausted its attack + pub stage_exhausted: bool, + /// How long state waits before it should deal damage + pub buildup_duration: Duration, + /// How long the state waits until exiting + pub recover_duration: Duration, + /// Tracks how long current stage has been active + pub stage_time_active: Duration, + /// `ToolData` to be sent to `Attacking` component + pub tool: ToolData, +} + +impl CharacterBehavior for State { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + + let new_stage_time_active = self + .stage_time_active + .checked_add(Duration::from_secs_f32(data.dt.0)) + .unwrap_or(Duration::default()); + + println!("Stage {:?}", self.stage); + + if self.stage < 3 { + // Build up window + if new_stage_time_active < self.buildup_duration { + // If the player is pressing primary btn + if data.inputs.primary.is_just_pressed() { + // They failed, go back to `Wielding` + update.character = CharacterState::Wielding { tool: self.tool }; + } + // Keep updating + else { + update.character = CharacterState::TimedCombo(State { + tool: self.tool, + stage: self.stage, + buildup_duration: self.buildup_duration, + recover_duration: self.recover_duration, + stage_exhausted: false, + stage_time_active: new_stage_time_active, + }); + } + } + // Hit attempt window + else if !self.stage_exhausted { + // Swing hits + data.updater.insert(data.entity, Attacking { + weapon: Some(self.tool), + applied: false, + hit_count: 0, + }); + + update.character = CharacterState::TimedCombo(State { + tool: self.tool, + stage: self.stage, + buildup_duration: self.buildup_duration, + recover_duration: self.recover_duration, + stage_exhausted: true, + stage_time_active: new_stage_time_active, + }); + } + // Swing recovery window + else if new_stage_time_active + < self + .buildup_duration + .checked_add(self.recover_duration) + .unwrap_or(Duration::default()) + { + // Try to transition to next stage + if data.inputs.primary.is_just_pressed() { + update.character = CharacterState::TimedCombo(State { + tool: self.tool, + stage: self.stage + 1, + buildup_duration: self.buildup_duration, + recover_duration: self.recover_duration, + stage_exhausted: true, + stage_time_active: Duration::default(), + }); + } + // Player didn't click this frame + else { + // Update state + update.character = CharacterState::TimedCombo(State { + tool: self.tool, + stage: self.stage, + buildup_duration: self.buildup_duration, + recover_duration: self.recover_duration, + stage_exhausted: true, + stage_time_active: new_stage_time_active, + }); + } + } + // Stage expired but missed transition to next stage + else { + // Back to `Wielding` + update.character = CharacterState::Wielding { tool: self.tool }; + // Make sure attack component is removed + data.updater.remove::(data.entity); + } + } + // Made three successful hits! + else { + // Back to `Wielding` + update.character = CharacterState::Wielding { tool: self.tool }; + // Make sure attack component is removed + data.updater.remove::(data.entity); + } + + // Subtract energy on successful hit + if let Some(attack) = data.attacking { + if attack.applied && attack.hit_count > 0 { + data.updater.remove::(data.entity); + update.energy.change_by(100, EnergySource::HitEnemy); + } + } + + update + } } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 3cf8c014b2..d8238700ce 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,6 +1,7 @@ use crate::{ comp::{CharacterAbility, CharacterState, EnergySource, ItemKind::Tool, StateUpdate, ToolData}, event::LocalEvent, + states::*, sys::{character_behavior::JoinData, phys::GRAVITY}, }; use std::time::Duration; @@ -236,3 +237,11 @@ pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { update.character = ability.into(); } } + +pub fn unwrap_tool_data(data: &JoinData) -> Option { + if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { + Some(tool) + } else { + None + } +} diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 63380a94df..126e72224c 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ AbilityPool, Attacking, Body, CharacterState, Controller, ControllerInputs, Energy, - Mounting, Ori, PhysicsState, Pos, Stats, Vel, + Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -13,6 +13,11 @@ use specs::{Entities, Entity, Join, LazyUpdate, Read, ReadStorage, System, Write // use std::collections::VecDeque; +pub trait CharacterBehavior { + fn behavior(&self, data: &JoinData) -> StateUpdate; + // fn init(data: &JoinData) -> CharacterState; +} + /// Read-Only Data sent from Character Behavior System to bahvior fn's pub struct JoinData<'a> { pub entity: Entity, @@ -173,12 +178,12 @@ impl<'a> System<'a> for Sys { CharacterState::Roll { .. } => states::roll::behavior(&j), CharacterState::Wielding { .. } => states::wielding::behavior(&j), CharacterState::Equipping { .. } => states::equipping::behavior(&j), - CharacterState::BasicAttack { .. } => states::basic_attack::behavior(&j), CharacterState::BasicBlock { .. } => states::basic_block::behavior(&j), CharacterState::ChargeAttack { .. } => states::charge_attack::behavior(&j), CharacterState::Sit { .. } => states::sit::behavior(&j), CharacterState::TripleStrike { .. } => states::triple_strike::behavior(&j), - CharacterState::TimedCombo { .. } => states::timed_combo::behavior(&j), + CharacterState::BasicAttack (state) => state.behavior(&j), + CharacterState::TimedCombo(state) => state.behavior(&j), // Do not use default match. // _ => StateUpdate { diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index dbefe7492a..718339c632 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -454,7 +454,7 @@ impl FigureMgr { skeleton_attr, ) }, - CharacterState::BasicAttack { .. } => { + CharacterState::BasicAttack(_) => { anim::character::AttackAnimation::update_skeleton( &target_base, (active_tool_kind, time), @@ -463,6 +463,22 @@ impl FigureMgr { skeleton_attr, ) }, + CharacterState::TimedCombo(s) => match s.stage { + 0 | 2 => anim::character::AttackAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ), + _ => anim::character::ChargeAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ), + }, CharacterState::BasicBlock { .. } => { anim::character::BlockIdleAnimation::update_skeleton( &CharacterSkeleton::new(), From ee706fa32ab48578a3f17dfbe46fce6087507fa1 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sat, 14 Mar 2020 13:04:04 -0600 Subject: [PATCH 074/326] Tweaking timed_combo --- common/src/comp/inventory/item.rs | 4 ++-- common/src/states/timed_combo.rs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 52cfd42639..2835d480d0 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -38,8 +38,8 @@ impl ToolData { match self.kind { Sword(_) => vec![TimedCombo { - buildup_duration: Duration::from_millis(1000), - recover_duration: Duration::from_millis(500), + buildup_duration: Duration::from_millis(500), + recover_duration: Duration::from_millis(1000), tool: *self, }], Axe => vec![BasicAttack { diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index 1c70c371ac..e55e6c0dd3 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -37,13 +37,12 @@ impl CharacterBehavior for State { .checked_add(Duration::from_secs_f32(data.dt.0)) .unwrap_or(Duration::default()); - println!("Stage {:?}", self.stage); - if self.stage < 3 { // Build up window 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 { tool: self.tool }; } @@ -86,6 +85,7 @@ impl CharacterBehavior for State { { // Try to transition to next stage if data.inputs.primary.is_just_pressed() { + println!("Transition"); update.character = CharacterState::TimedCombo(State { tool: self.tool, stage: self.stage + 1, @@ -98,6 +98,7 @@ impl CharacterBehavior for State { // Player didn't click this frame else { // Update state + println!("Missed"); update.character = CharacterState::TimedCombo(State { tool: self.tool, stage: self.stage, @@ -118,6 +119,7 @@ impl CharacterBehavior for State { } // Made three successful hits! else { + println!("Success!"); // Back to `Wielding` update.character = CharacterState::Wielding { tool: self.tool }; // Make sure attack component is removed @@ -127,6 +129,7 @@ impl CharacterBehavior for State { // Subtract energy on successful hit if let Some(attack) = data.attacking { if attack.applied && attack.hit_count > 0 { + println!("Hit"); data.updater.remove::(data.entity); update.energy.change_by(100, EnergySource::HitEnemy); } From 7dfe00b6745631c7ff6f412df291f9804c2178ac Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sat, 14 Mar 2020 15:17:27 -0600 Subject: [PATCH 075/326] Finish state struct data refactor --- common/src/comp/ability.rs | 16 +-- common/src/comp/character_state.rs | 57 ++++------ common/src/states/basic_attack.rs | 16 +-- common/src/states/basic_block.rs | 38 ++++--- common/src/states/charge_attack.rs | 43 ++++---- common/src/states/climb.rs | 153 ++++++++++++++------------- common/src/states/equipping.rs | 55 ++++++---- common/src/states/glide.rs | 103 +++++++++--------- common/src/states/idle.rs | 45 ++++---- common/src/states/roll.rs | 42 ++++---- common/src/states/sit.rs | 45 ++++---- common/src/states/timed_combo.rs | 20 ++-- common/src/states/triple_strike.rs | 55 +++++----- common/src/states/utils.rs | 6 +- common/src/states/wielding.rs | 58 +++++----- common/src/sys/character_behavior.rs | 24 ++--- 16 files changed, 417 insertions(+), 359 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 8c56e7af5a..f9b6903e87 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -39,23 +39,25 @@ impl From for CharacterState { CharacterAbility::BasicAttack { buildup_duration, recover_duration, - } => CharacterState::BasicAttack(basic_attack::State { + } => CharacterState::BasicAttack(basic_attack::Data { exhausted: false, buildup_duration, recover_duration, }), - CharacterAbility::BasicBlock { .. } => CharacterState::BasicBlock {}, - CharacterAbility::Roll { .. } => CharacterState::Roll { - remaining_duration: Duration::from_millis(600), - }, - CharacterAbility::ChargeAttack { .. } => CharacterState::ChargeAttack { + CharacterAbility::BasicBlock { .. } => CharacterState::BasicBlock, + CharacterAbility::Roll { .. } => CharacterState::Roll(roll::Data { remaining_duration: Duration::from_millis(600), + }), + CharacterAbility::ChargeAttack { .. } => { + CharacterState::ChargeAttack(charge_attack::Data { + remaining_duration: Duration::from_millis(600), + }) }, CharacterAbility::TimedCombo { tool, buildup_duration, recover_duration, - } => CharacterState::TimedCombo(timed_combo::State { + } => CharacterState::TimedCombo(timed_combo::Data { tool, buildup_duration, recover_duration, diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index fa2460a15b..3c92f65890 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -5,7 +5,7 @@ use crate::{ }; use serde::{Deserialize, Serialize}; use specs::{Component, FlaggedStorage, HashMapStorage, VecStorage}; -use std::{collections::VecDeque, time::Duration}; +use std::collections::VecDeque; /// Data returned from character behavior fn's to Character Behavior System. pub struct StateUpdate { @@ -22,54 +22,35 @@ pub struct StateUpdate { pub enum CharacterState { Idle, Climb, - Sit {}, - Equipping { - /// The weapon being equipped - tool: ToolData, - /// Time left before next state - time_left: Duration, - }, - Wielding { - /// The weapon being wielded - tool: ToolData, - }, + Sit, Glide, /// A basic blocking state BasicBlock, - ChargeAttack { - /// How long the state has until exiting - remaining_duration: Duration, - }, - Roll { - /// How long the state has until exiting - remaining_duration: Duration, - }, + /// Player is busy equipping or unequipping weapons + Equipping(equipping::Data), + /// Player is holding a weapon and can perform other actions + Wielding(wielding::Data), + /// Player rushes forward and slams an enemy with their weapon + ChargeAttack(charge_attack::Data), + /// A dodge where player can roll + Roll(roll::Data), /// A basic attacking state - BasicAttack(basic_attack::State), + BasicAttack(basic_attack::Data), /// A three-stage attack where play must click at appropriate times /// to continue attack chain. - TimedCombo(timed_combo::State), + TimedCombo(timed_combo::Data), /// A three-stage attack where each attack pushes player forward /// and successive attacks increase in damage, while player holds button. - TripleStrike { - /// The tool this state will read to handle damage, etc. - tool: ToolData, - /// `int` denoting what stage (of 3) the attack is in. - stage: i8, - /// How long current stage has been active - stage_time_active: Duration, - /// Whether current stage has exhausted its attack - stage_exhausted: bool, - }, + TripleStrike(triple_strike::Data), } impl CharacterState { pub fn is_wield(&self) -> bool { match self { - CharacterState::Wielding { .. } + CharacterState::Wielding(_) | CharacterState::BasicAttack(_) | CharacterState::TimedCombo(_) - | CharacterState::BasicBlock { .. } => true, + | CharacterState::BasicBlock => true, _ => false, } } @@ -78,21 +59,21 @@ impl CharacterState { match self { CharacterState::BasicAttack(_) | CharacterState::TimedCombo(_) - | CharacterState::ChargeAttack { .. } => true, + | CharacterState::ChargeAttack(_) => true, _ => false, } } pub fn is_block(&self) -> bool { match self { - CharacterState::BasicBlock { .. } => true, + CharacterState::BasicBlock => true, _ => false, } } pub fn is_dodge(&self) -> bool { match self { - CharacterState::Roll { .. } => true, + CharacterState::Roll(_) => true, _ => false, } } @@ -105,7 +86,7 @@ impl CharacterState { } impl Default for CharacterState { - fn default() -> Self { Self::Idle {} } + fn default() -> Self { Self::Idle } } impl Component for CharacterState { diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index 4bf8f67108..f8d2ba5230 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -1,12 +1,12 @@ use crate::{ - comp::{Attacking, CharacterState, EnergySource, ItemKind::Tool, StateUpdate}, - states::utils::*, + comp::{Attacking, CharacterState, EnergySource, StateUpdate}, + states::{utils::*, wielding}, sys::character_behavior::*, }; use std::{collections::VecDeque, time::Duration}; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State { +pub struct Data { /// How long until state should deal damage pub buildup_duration: Duration, /// How long the state has until exiting @@ -15,7 +15,7 @@ pub struct State { pub exhausted: bool, } -impl CharacterBehavior for State { +impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate { pos: *data.pos, @@ -32,7 +32,7 @@ impl CharacterBehavior for State { // Build up window if self.buildup_duration != Duration::default() { // Start to swing - update.character = CharacterState::BasicAttack(State { + update.character = CharacterState::BasicAttack(Data { buildup_duration: self .buildup_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) @@ -52,7 +52,7 @@ impl CharacterBehavior for State { }); } - update.character = CharacterState::BasicAttack(State { + update.character = CharacterState::BasicAttack(Data { buildup_duration: self.buildup_duration, recover_duration: self.recover_duration, exhausted: true, @@ -60,7 +60,7 @@ impl CharacterBehavior for State { } // Swing recovery window else if self.recover_duration != Duration::default() { - update.character = CharacterState::BasicAttack(State { + update.character = CharacterState::BasicAttack(Data { buildup_duration: self.buildup_duration, recover_duration: self .recover_duration @@ -72,7 +72,7 @@ impl CharacterBehavior for State { // Done else { if let Some(tool) = unwrap_tool_data(data) { - update.character = CharacterState::Wielding { tool }; + update.character = CharacterState::Wielding(wielding::Data { tool }); // Make sure attack component is removed data.updater.remove::(data.entity); } else { diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index 912707d954..efb78ad323 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -1,25 +1,33 @@ use super::utils::*; -use crate::{comp::StateUpdate, sys::character_behavior::JoinData}; +use crate::{ + comp::StateUpdate, + sys::character_behavior::{CharacterBehavior, JoinData}, +}; use std::collections::VecDeque; // const BLOCK_ACCEL: f32 = 30.0; // const BLOCK_SPEED: f32 = 75.0; -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: *data.character, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Data; - handle_move(&data, &mut update); +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; - if !data.physics.on_ground || !data.inputs.secondary.is_pressed() { - attempt_wield(data, &mut update); + handle_move(&data, &mut update); + + if !data.physics.on_ground || !data.inputs.secondary.is_pressed() { + attempt_wield(data, &mut update); + } + update } - update } diff --git a/common/src/states/charge_attack.rs b/common/src/states/charge_attack.rs index 7958885a4e..af479613b1 100644 --- a/common/src/states/charge_attack.rs +++ b/common/src/states/charge_attack.rs @@ -2,25 +2,30 @@ use super::utils::*; use crate::{ comp::{CharacterState::*, HealthChange, HealthSource, StateUpdate}, event::ServerEvent, - sys::character_behavior::JoinData, + sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::{collections::VecDeque, time::Duration}; use vek::Vec3; const CHARGE_SPEED: f32 = 20.0; -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - character: *data.character, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Data { + /// How long the state has until exiting + pub remaining_duration: Duration, +} - if let ChargeAttack { remaining_duration } = data.character { +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + character: *data.character, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; // Move player update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) @@ -46,18 +51,20 @@ pub fn behavior(data: &JoinData) -> StateUpdate { } // Check if charge timed out or can't keep moving forward - if *remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 { + if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 + { attempt_wield(data, &mut update); return update; } // Tick remaining-duration and keep charging - update.character = ChargeAttack { - remaining_duration: remaining_duration + update.character = ChargeAttack(Data { + remaining_duration: self + .remaining_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), - }; - } + }); - update + update + } } diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 6d5f09b1ea..0bff46fdad 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -1,7 +1,10 @@ use crate::{ comp::{CharacterState, EnergySource, StateUpdate}, event::LocalEvent, - sys::{character_behavior::JoinData, phys::GRAVITY}, + sys::{ + character_behavior::{CharacterBehavior, JoinData}, + phys::GRAVITY, + }, }; use std::collections::VecDeque; use vek::{ @@ -12,84 +15,90 @@ use vek::{ const HUMANOID_CLIMB_ACCEL: f32 = 5.0; const CLIMB_SPEED: f32 = 5.0; -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - character: *data.character, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Data; - if let Err(_) = update.energy.try_change_by(-5, EnergySource::Climb) { - update.character = CharacterState::Idle {}; - } - - // If no wall is in front of character ... - if data.physics.on_wall.is_none() || data.physics.on_ground { - if data.inputs.jump.is_pressed() { - // They've climbed atop something, give them a boost - update - .local_events - .push_front(LocalEvent::Jump(data.entity)); - } - update.character = CharacterState::Idle {}; - return update; - } - - // Move player - update.vel.0 += Vec2::broadcast(data.dt.0) - * data.inputs.move_dir - * if update.vel.0.magnitude_squared() < CLIMB_SPEED.powf(2.0) { - HUMANOID_CLIMB_ACCEL - } else { - 0.0 +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + character: *data.character, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; - // Set orientation direction based on wall direction - let ori_dir = if let Some(wall_dir) = data.physics.on_wall { - if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { - Vec2::from(wall_dir).normalized() + if let Err(_) = update.energy.try_change_by(-5, EnergySource::Climb) { + update.character = CharacterState::Idle {}; + } + + // If no wall is in front of character ... + if data.physics.on_wall.is_none() || data.physics.on_ground { + if data.inputs.jump.is_pressed() { + // They've climbed atop something, give them a boost + update + .local_events + .push_front(LocalEvent::Jump(data.entity)); + } + update.character = CharacterState::Idle {}; + return update; + } + + // Move player + update.vel.0 += Vec2::broadcast(data.dt.0) + * data.inputs.move_dir + * if update.vel.0.magnitude_squared() < CLIMB_SPEED.powf(2.0) { + HUMANOID_CLIMB_ACCEL + } else { + 0.0 + }; + + // Set orientation direction based on wall direction + let ori_dir = if let Some(wall_dir) = data.physics.on_wall { + if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { + Vec2::from(wall_dir).normalized() + } else { + Vec2::from(update.vel.0) + } } else { Vec2::from(update.vel.0) - } - } else { - Vec2::from(update.vel.0) - }; + }; - // Smooth orientation - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = vek::ops::Slerp::slerp( - update.ori.0, - ori_dir.into(), - if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, - ); - } - - // Apply Vertical Climbing Movement - if let (true, Some(_wall_dir)) = ( - (data.inputs.climb.is_pressed() | data.inputs.climb_down.is_pressed()) - && update.vel.0.z <= CLIMB_SPEED, - data.physics.on_wall, - ) { - if data.inputs.climb_down.is_pressed() && !data.inputs.climb.is_pressed() { - update.vel.0 -= data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); - } else if data.inputs.climb.is_pressed() && !data.inputs.climb_down.is_pressed() { - update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); - } else { - update.vel.0.z = update.vel.0.z + data.dt.0 * GRAVITY * 1.5; - update.vel.0 = Lerp::lerp( - update.vel.0, - Vec3::zero(), - 30.0 * data.dt.0 / (1.0 - update.vel.0.z.min(0.0) * 5.0), + // Smooth orientation + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = vek::ops::Slerp::slerp( + update.ori.0, + ori_dir.into(), + if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, ); } - } - update + // Apply Vertical Climbing Movement + if let (true, Some(_wall_dir)) = ( + (data.inputs.climb.is_pressed() | data.inputs.climb_down.is_pressed()) + && update.vel.0.z <= CLIMB_SPEED, + data.physics.on_wall, + ) { + if data.inputs.climb_down.is_pressed() && !data.inputs.climb.is_pressed() { + update.vel.0 -= + data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); + } else if data.inputs.climb.is_pressed() && !data.inputs.climb_down.is_pressed() { + update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); + } else { + update.vel.0.z = update.vel.0.z + data.dt.0 * GRAVITY * 1.5; + update.vel.0 = Lerp::lerp( + update.vel.0, + Vec3::zero(), + 30.0 * data.dt.0 / (1.0 - update.vel.0.z.min(0.0) * 5.0), + ); + } + } + + update + } } diff --git a/common/src/states/equipping.rs b/common/src/states/equipping.rs index 27ae4f1122..d79be81b34 100644 --- a/common/src/states/equipping.rs +++ b/common/src/states/equipping.rs @@ -1,38 +1,49 @@ use super::utils::*; use crate::{ - comp::{CharacterState, StateUpdate}, - sys::character_behavior::JoinData, + comp::{CharacterState, StateUpdate, ToolData}, + states::wielding, + sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::{collections::VecDeque, time::Duration}; -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: *data.character, - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Data { + /// The weapon being equipped + pub tool: ToolData, + /// Time left before next state + pub time_left: Duration, +} - handle_move(&data, &mut update); - handle_jump(&data, &mut update); +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; - if let CharacterState::Equipping { tool, time_left } = data.character { - if *time_left == Duration::default() { + handle_move(&data, &mut update); + handle_jump(&data, &mut update); + + if self.time_left == Duration::default() { // Wield delay has expired - update.character = CharacterState::Wielding { tool: *tool }; + update.character = CharacterState::Wielding(wielding::Data { tool: self.tool }); } else { // Wield delay hasn't expired yet // Update wield delay - update.character = CharacterState::Equipping { - time_left: time_left + update.character = CharacterState::Equipping(Data { + time_left: self + .time_left .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), - tool: *tool, - }; + tool: self.tool, + }); } + + update } - update } diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 239f250f72..78851f006a 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,6 +1,6 @@ use crate::{ comp::{CharacterState, StateUpdate}, - sys::character_behavior::JoinData, + sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::collections::VecDeque; use vek::{Vec2, Vec3}; @@ -10,57 +10,62 @@ const GLIDE_ANTIGRAV: f32 = crate::sys::phys::GRAVITY * 0.96; const GLIDE_ACCEL: f32 = 15.0; const GLIDE_SPEED: f32 = 45.0; -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: *data.character, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Data; - // If glide button isn't held or player is on ground, end glide - if !data.inputs.glide.is_pressed() || data.physics.on_ground { - update.character = CharacterState::Idle {}; - } - - // If there is a wall in front of character go to climb - if let Some(_) = data.physics.on_wall { - update.character = CharacterState::Climb {}; - } - - // Move player according to movement direction vector - update.vel.0 += Vec2::broadcast(data.dt.0) - * data.inputs.move_dir - * if data.vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) { - GLIDE_ACCEL - } else { - 0.0 +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), }; - // Determine orientation vector from movement direction vector - let ori_dir = Vec2::from(update.vel.0); - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 2.0 * data.dt.0); - } + // If glide button isn't held or player is on ground, end glide + if !data.inputs.glide.is_pressed() || data.physics.on_ground { + update.character = CharacterState::Idle {}; + } - // Apply Glide antigrav lift - if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) - && update.vel.0.z < 0.0 - { - let lift = GLIDE_ANTIGRAV + update.vel.0.z.abs().powf(2.0) * 0.15; - update.vel.0.z += data.dt.0 - * lift - * (Vec2::::from(update.vel.0).magnitude() * 0.075) - .min(1.0) - .max(0.2); - } + // If there is a wall in front of character go to climb + if let Some(_) = data.physics.on_wall { + update.character = CharacterState::Climb {}; + } - // Otherwise keep gliding - update + // Move player according to movement direction vector + update.vel.0 += Vec2::broadcast(data.dt.0) + * data.inputs.move_dir + * if data.vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) { + GLIDE_ACCEL + } else { + 0.0 + }; + + // Determine orientation vector from movement direction vector + let ori_dir = Vec2::from(update.vel.0); + if ori_dir.magnitude_squared() > 0.0001 + && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() + > 0.001 + { + update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 2.0 * data.dt.0); + } + + // Apply Glide antigrav lift + if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) + && update.vel.0.z < 0.0 + { + let lift = GLIDE_ANTIGRAV + update.vel.0.z.abs().powf(2.0) * 0.15; + update.vel.0.z += data.dt.0 + * lift + * (Vec2::::from(update.vel.0).magnitude() * 0.075) + .min(1.0) + .max(0.2); + } + + // Otherwise keep gliding + update + } } diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index df13129a2a..282d465b54 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -1,24 +1,31 @@ use super::utils::*; -use crate::{comp::StateUpdate, sys::character_behavior::JoinData}; +use crate::{ + comp::StateUpdate, + sys::character_behavior::{CharacterBehavior, JoinData}, +}; use std::collections::VecDeque; -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: *data.character, - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; - handle_move(data, &mut update); - handle_jump(data, &mut update); - handle_wield(data, &mut update); - handle_sit(data, &mut update); - handle_climb(data, &mut update); - handle_glide(data, &mut update); - handle_dodge_input(data, &mut update); +pub struct Data; - update +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + handle_move(data, &mut update); + handle_jump(data, &mut update); + handle_wield(data, &mut update); + handle_sit(data, &mut update); + handle_climb(data, &mut update); + handle_glide(data, &mut update); + handle_dodge_input(data, &mut update); + + update + } } diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 9f176817f3..8d57e56546 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,24 +1,29 @@ use crate::{ comp::{CharacterState, StateUpdate}, - sys::character_behavior::JoinData, + sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::{collections::VecDeque, time::Duration}; use vek::Vec3; const ROLL_SPEED: f32 = 17.0; +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Data { + /// How long the state has until exiting + pub remaining_duration: Duration, +} -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: *data.character, - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; - if let CharacterState::Roll { remaining_duration } = data.character { // Update velocity update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) @@ -37,19 +42,20 @@ pub fn behavior(data: &JoinData) -> StateUpdate { vek::ops::Slerp::slerp(update.ori.0, update.vel.0.into(), 9.0 * data.dt.0); } - if *remaining_duration == Duration::default() { + if self.remaining_duration == Duration::default() { // Roll duration has expired update.vel.0 *= 0.3; update.character = CharacterState::Idle {}; } else { // Otherwise, tick down remaining_duration - update.character = CharacterState::Roll { - remaining_duration: remaining_duration + update.character = CharacterState::Roll(Data { + remaining_duration: self + .remaining_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), - }; + }); } - } - update + update + } } diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index 89c312d3c2..407e176c01 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -1,30 +1,35 @@ use super::utils::*; use crate::{ comp::{CharacterState, StateUpdate}, - sys::character_behavior::JoinData, + sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::collections::VecDeque; -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: *data.character, - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Data; - handle_wield(data, &mut update); +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; - // Try to Fall/Stand up/Move - if !data.physics.on_ground - || data.inputs.sit.is_just_pressed() - || data.inputs.move_dir.magnitude_squared() > 0.0 - { - update.character = CharacterState::Idle {}; + handle_wield(data, &mut update); + + // Try to Fall/Stand up/Move + if !data.physics.on_ground + || data.inputs.sit.is_just_pressed() + || data.inputs.move_dir.magnitude_squared() > 0.0 + { + update.character = CharacterState::Idle; + } + + update } - - update } diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index e55e6c0dd3..6c8ad42e6c 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -1,11 +1,11 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, StateUpdate, ToolData}, - states::utils::*, + states::wielding, sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::{collections::VecDeque, time::Duration}; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct State { +pub struct Data { /// Denotes what stage (of 3) the attack is in pub stage: i8, /// Whether current stage has exhausted its attack @@ -20,7 +20,7 @@ pub struct State { pub tool: ToolData, } -impl CharacterBehavior for State { +impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate { pos: *data.pos, @@ -44,11 +44,11 @@ impl CharacterBehavior for State { if data.inputs.primary.is_just_pressed() { println!("Failed"); // They failed, go back to `Wielding` - update.character = CharacterState::Wielding { tool: self.tool }; + update.character = CharacterState::Wielding(wielding::Data { tool: self.tool }); } // Keep updating else { - update.character = CharacterState::TimedCombo(State { + update.character = CharacterState::TimedCombo(Data { tool: self.tool, stage: self.stage, buildup_duration: self.buildup_duration, @@ -67,7 +67,7 @@ impl CharacterBehavior for State { hit_count: 0, }); - update.character = CharacterState::TimedCombo(State { + update.character = CharacterState::TimedCombo(Data { tool: self.tool, stage: self.stage, buildup_duration: self.buildup_duration, @@ -86,7 +86,7 @@ impl CharacterBehavior for State { // Try to transition to next stage if data.inputs.primary.is_just_pressed() { println!("Transition"); - update.character = CharacterState::TimedCombo(State { + update.character = CharacterState::TimedCombo(Data { tool: self.tool, stage: self.stage + 1, buildup_duration: self.buildup_duration, @@ -99,7 +99,7 @@ impl CharacterBehavior for State { else { // Update state println!("Missed"); - update.character = CharacterState::TimedCombo(State { + update.character = CharacterState::TimedCombo(Data { tool: self.tool, stage: self.stage, buildup_duration: self.buildup_duration, @@ -112,7 +112,7 @@ impl CharacterBehavior for State { // Stage expired but missed transition to next stage else { // Back to `Wielding` - update.character = CharacterState::Wielding { tool: self.tool }; + update.character = CharacterState::Wielding(wielding::Data { tool: self.tool }); // Make sure attack component is removed data.updater.remove::(data.entity); } @@ -121,7 +121,7 @@ impl CharacterBehavior for State { else { println!("Success!"); // Back to `Wielding` - update.character = CharacterState::Wielding { tool: self.tool }; + update.character = CharacterState::Wielding(wielding::Data { tool: self.tool }); // Make sure attack component is removed data.updater.remove::(data.entity); } diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 60f5d9e63b..fd10f3ccb6 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -1,7 +1,7 @@ use crate::{ - comp::{Attacking, CharacterState, ItemKind::Tool, StateUpdate}, + comp::{StateUpdate, ToolData}, states::utils::*, - sys::character_behavior::JoinData, + sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::{collections::VecDeque, time::Duration}; @@ -14,26 +14,33 @@ const STAGE_DURATION: u64 = 600; /// each one pushes the player forward as the character steps into the swings. /// The player can let go of the left mouse button at any time /// and stop their attacks by interrupting the attack animation. -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: *data.character, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Data { + /// The tool this state will read to handle damage, etc. + pub tool: ToolData, + /// `int` denoting what stage (of 3) the attack is in. + pub stage: i8, + /// How long current stage has been active + pub stage_time_active: Duration, + /// Whether current stage has exhausted its attack + stage_exhausted: bool, +} - if let CharacterState::TripleStrike { - tool, - stage, - stage_time_active, - stage_exhausted, - } = data.character - { - let mut new_stage_exhausted = *stage_exhausted; - let new_stage_time_active = stage_time_active +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: *data.character, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + + let new_stage_exhausted = self.stage_exhausted; + let new_stage_time_active = self + .stage_time_active .checked_add(Duration::from_secs_f32(data.dt.0)) .unwrap_or(Duration::default()); @@ -43,7 +50,7 @@ pub fn behavior(data: &JoinData) -> StateUpdate { return update; } - while *stage < 3 { + if self.stage < 3 { if new_stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { // Move player forward while in first third of each stage handle_move(data, &mut update); @@ -54,7 +61,7 @@ pub fn behavior(data: &JoinData) -> StateUpdate { // TODO: deal damage } } - } - update + update + } } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index d8238700ce..a0f83674a3 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{CharacterAbility, CharacterState, EnergySource, ItemKind::Tool, StateUpdate, ToolData}, + comp::{CharacterState, EnergySource, ItemKind::Tool, StateUpdate, ToolData}, event::LocalEvent, states::*, sys::{character_behavior::JoinData, phys::GRAVITY}, @@ -120,10 +120,10 @@ pub fn handle_wield(data: &JoinData, update: &mut StateUpdate) { /// If a tool is equipped, goes into Equipping state, otherwise goes to Idle pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { - update.character = CharacterState::Equipping { + update.character = CharacterState::Equipping(equipping::Data { tool, time_left: tool.equip_time(), - }; + }); } else { update.character = CharacterState::Idle {}; }; diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index e9b30a77d0..27e60d9be7 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -1,27 +1,37 @@ use super::utils::*; -use crate::{comp::StateUpdate, sys::character_behavior::JoinData}; +use crate::{ + comp::{StateUpdate, ToolData}, + sys::character_behavior::{CharacterBehavior, JoinData}, +}; use std::collections::VecDeque; - -pub fn behavior(data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: *data.character, - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; - - handle_move(&data, &mut update); - handle_jump(&data, &mut update); - handle_sit(&data, &mut update); - handle_climb(&data, &mut update); - handle_glide(&data, &mut update); - handle_unwield(&data, &mut update); - handle_primary_input(&data, &mut update); - handle_secondary_input(&data, &mut update); - handle_dodge_input(&data, &mut update); - - update +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Data { + /// The weapon being wielded + pub tool: ToolData, +} + +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + character: *data.character, + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + + handle_move(&data, &mut update); + handle_jump(&data, &mut update); + handle_sit(&data, &mut update); + handle_climb(&data, &mut update); + handle_glide(&data, &mut update); + handle_unwield(&data, &mut update); + handle_primary_input(&data, &mut update); + handle_secondary_input(&data, &mut update); + handle_dodge_input(&data, &mut update); + + update + } } diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 126e72224c..e35bfbbb10 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -172,18 +172,18 @@ impl<'a> System<'a> for Sys { } let mut state_update = match j.character { - CharacterState::Idle { .. } => states::idle::behavior(&j), - CharacterState::Climb { .. } => states::climb::behavior(&j), - CharacterState::Glide { .. } => states::glide::behavior(&j), - CharacterState::Roll { .. } => states::roll::behavior(&j), - CharacterState::Wielding { .. } => states::wielding::behavior(&j), - CharacterState::Equipping { .. } => states::equipping::behavior(&j), - CharacterState::BasicBlock { .. } => states::basic_block::behavior(&j), - CharacterState::ChargeAttack { .. } => states::charge_attack::behavior(&j), - CharacterState::Sit { .. } => states::sit::behavior(&j), - CharacterState::TripleStrike { .. } => states::triple_strike::behavior(&j), - CharacterState::BasicAttack (state) => state.behavior(&j), - CharacterState::TimedCombo(state) => state.behavior(&j), + CharacterState::Idle => states::idle::Data::behavior(&states::idle::Data, &j), + CharacterState::Climb => states::climb::Data::behavior(&states::climb::Data, &j), + CharacterState::Glide => states::glide::Data::behavior(&states::glide::Data, &j), + CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, &j), + CharacterState::BasicBlock => states::basic_block::Data::behavior(&states::basic_block::Data, &j), + CharacterState::Roll (data) => data.behavior(&j), + CharacterState::Wielding (data) => data.behavior(&j), + CharacterState::Equipping (data) => data.behavior(&j), + CharacterState::ChargeAttack (data) => data.behavior(&j), + CharacterState::TripleStrike (data) => data.behavior(&j), + CharacterState::BasicAttack (data) => data.behavior(&j), + CharacterState::TimedCombo(data) => data.behavior(&j), // Do not use default match. // _ => StateUpdate { From 598a4c6cbbb290ac3ad64c12166d0a8e3bf80006 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sat, 14 Mar 2020 22:33:20 +0100 Subject: [PATCH 076/326] Add loadout struct for info on weapon configurations --- common/src/comp/ability.rs | 24 +++-- common/src/comp/character_state.rs | 2 +- common/src/comp/inventory/item.rs | 4 +- common/src/comp/mod.rs | 4 +- common/src/comp/stats.rs | 9 -- common/src/msg/ecs_packet.rs | 12 +-- common/src/state.rs | 2 +- common/src/states/basic_attack.rs | 13 ++- common/src/states/timed_combo.rs | 2 +- common/src/states/utils.rs | 25 ++++- common/src/sys/character_behavior.rs | 16 +-- common/src/sys/combat.rs | 6 +- server/src/events/inventory_manip.rs | 16 --- server/src/lib.rs | 24 ++--- server/src/sys/sentinel.rs | 18 ++-- server/src/sys/terrain.rs | 31 ++++-- voxygen/src/hud/mod.rs | 19 ++-- voxygen/src/hud/skillbar.rs | 133 ++++++++++++++----------- voxygen/src/menu/char_selection/mod.rs | 13 +-- voxygen/src/scene/figure/cache.rs | 12 +-- voxygen/src/scene/figure/load.rs | 6 +- voxygen/src/scene/figure/mod.rs | 79 +++++++++------ voxygen/src/scene/simple.rs | 6 +- 23 files changed, 263 insertions(+), 213 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index f9b6903e87..d7508f36f7 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{CharacterState, ToolData}, + comp::{CharacterState, Item, ToolData}, states::*, }; use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage}; @@ -25,12 +25,20 @@ impl Component for CharacterAbility { type Storage = DenseVecStorage; } -#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize)] -pub struct AbilityPool { - pub primary: Option, - pub secondary: Option, - pub block: Option, - pub dodge: Option, +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ItemConfig { + pub item: Item, + pub primary_ability: Option, + pub secondary_ability: Option, + pub block_ability: Option, + pub dodge_ability: Option, +} + +#[derive(Clone, Default, Debug, Serialize, Deserialize)] +pub struct Loadout { + pub active_item: Option, + pub second_item: Option, + // armor } impl From for CharacterState { @@ -69,6 +77,6 @@ impl From for CharacterState { } } -impl Component for AbilityPool { +impl Component for Loadout { type Storage = FlaggedStorage>; } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 3c92f65890..bbc3242743 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -95,7 +95,7 @@ impl Component for CharacterState { #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Attacking { - pub weapon: Option, + pub base_damage: u32, pub applied: bool, pub hit_count: u32, } diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 2835d480d0..9f07d6a3b3 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -127,8 +127,8 @@ pub struct ToolData { equip_time_millis: u64, attack_buildup_millis: u64, attack_recover_millis: u64, - range: u64, - pub base_damage: u64, + range: u32, + pub base_damage: u32, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 8a6fe50631..34ee837944 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -16,7 +16,7 @@ mod stats; mod visual; // Reexports -pub use ability::{AbilityPool, CharacterAbility}; +pub use ability::{CharacterAbility, ItemConfig, Loadout}; pub use admin::Admin; pub use agent::{Agent, Alignment}; pub use body::{ @@ -39,5 +39,5 @@ pub use location::{Waypoint, WaypointArea}; pub use phys::{ForceUpdate, Gravity, Mass, Ori, PhysicsState, Pos, Scale, Sticky, Vel}; pub use player::Player; pub use projectile::Projectile; -pub use stats::{Equipment, Exp, HealthChange, HealthSource, Level, Stats}; +pub use stats::{Exp, HealthChange, HealthSource, Level, Stats}; pub use visual::LightEmitter; diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index aaa768fee3..d60e2d45dd 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -42,13 +42,6 @@ pub struct Level { amount: u32, } -#[derive(Clone, PartialEq, Eq, Hash, Debug, Serialize, Deserialize)] -pub struct Equipment { - pub main: Option, - pub alt: Option, - // TODO: Armor -} - impl Health { pub fn current(&self) -> u32 { self.current } @@ -125,7 +118,6 @@ pub struct Stats { pub health: Health, pub level: Level, pub exp: Exp, - pub equipment: Equipment, pub endurance: u32, pub fitness: u32, pub willpower: u32, @@ -178,7 +170,6 @@ impl Stats { current: 0, maximum: 50, }, - equipment: Equipment { main, alt: None }, endurance, fitness, willpower, diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index f0135dd3c4..4034c6b953 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -22,7 +22,7 @@ sum_type! { Gravity(comp::Gravity), Sticky(comp::Sticky), CharacterAbility(comp::CharacterAbility), - AbilityPool(comp::AbilityPool), + Loadout(comp::Loadout), Attacking(comp::Attacking), CharacterState(comp::CharacterState), } @@ -46,7 +46,7 @@ sum_type! { Gravity(PhantomData), Sticky(PhantomData), CharacterAbility(PhantomData), - AbilityPool(PhantomData), + Loadout(PhantomData), Attacking(PhantomData), CharacterState(PhantomData), } @@ -70,7 +70,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Gravity(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::CharacterAbility(comp) => sync::handle_insert(comp, entity, world), - EcsCompPacket::AbilityPool(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::Loadout(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Attacking(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::CharacterState(comp) => sync::handle_insert(comp, entity, world), } @@ -92,7 +92,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Gravity(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::CharacterAbility(comp) => sync::handle_modify(comp, entity, world), - EcsCompPacket::AbilityPool(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::Loadout(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Attacking(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::CharacterState(comp) => sync::handle_modify(comp, entity, world), } @@ -118,9 +118,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPhantom::CharacterAbility(_) => { sync::handle_remove::(entity, world) }, - EcsCompPhantom::AbilityPool(_) => { - sync::handle_remove::(entity, world) - }, + EcsCompPhantom::Loadout(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Attacking(_) => sync::handle_remove::(entity, world), EcsCompPhantom::CharacterState(_) => { sync::handle_remove::(entity, world) diff --git a/common/src/state.rs b/common/src/state.rs index 5fdbc211f6..d2b8386304 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -106,7 +106,7 @@ impl State { // Uids for sync ecs.register_sync_marker(); // Register server -> all clients synced components. - ecs.register::(); + ecs.register::(); ecs.register::(); ecs.register::(); ecs.register::(); diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index f8d2ba5230..64846659ba 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -29,9 +29,8 @@ impl CharacterBehavior for Data { handle_move(data, &mut update); - // Build up window + // Build up if self.buildup_duration != Duration::default() { - // Start to swing update.character = CharacterState::BasicAttack(Data { buildup_duration: self .buildup_duration @@ -41,12 +40,11 @@ impl CharacterBehavior for Data { exhausted: false, }); } - // Hit attempt window + // Hit attempt else if !self.exhausted { - // Swing hits if let Some(tool) = unwrap_tool_data(data) { data.updater.insert(data.entity, Attacking { - weapon: Some(tool), + base_damage: tool.base_damage, applied: false, hit_count: 0, }); @@ -58,7 +56,7 @@ impl CharacterBehavior for Data { exhausted: true, }); } - // Swing recovery window + // Recovery else if self.recover_duration != Duration::default() { update.character = CharacterState::BasicAttack(Data { buildup_duration: self.buildup_duration, @@ -79,7 +77,8 @@ impl CharacterBehavior for Data { update.character = CharacterState::Idle; } } - // Subtract energy on successful hit + + // Grant energy on successful hit if let Some(attack) = data.attacking { if attack.applied && attack.hit_count > 0 { data.updater.remove::(data.entity); diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index 6c8ad42e6c..4467ce7173 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -62,7 +62,7 @@ impl CharacterBehavior for Data { else if !self.stage_exhausted { // Swing hits data.updater.insert(data.entity, Attacking { - weapon: Some(self.tool), + base_damage: self.tool.base_damage, applied: false, hit_count: 0, }); diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index a0f83674a3..169611a8cc 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -119,7 +119,7 @@ pub fn handle_wield(data: &JoinData, update: &mut StateUpdate) { /// If a tool is equipped, goes into Equipping state, otherwise goes to Idle pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { - if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { + if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| i.item.kind) { update.character = CharacterState::Equipping(equipping::Data { tool, time_left: tool.equip_time(), @@ -192,7 +192,12 @@ pub fn handle_primary_input(data: &JoinData, update: &mut StateUpdate) { /// Attempts to go into `ability_pool.primary` if is `Some()` on `AbilityPool` pub fn attempt_primary_ability(data: &JoinData, update: &mut StateUpdate) { - if let Some(ability) = data.ability_pool.primary { + if let Some(ability) = data + .loadout + .active_item + .as_ref() + .and_then(|i| i.primary_ability) + { update.character = ability.into(); } } @@ -209,7 +214,12 @@ pub fn handle_secondary_input(data: &JoinData, update: &mut StateUpdate) { /// Attempts to go into `ability_pool.secondary` if is `Some()` on `AbilityPool` pub fn attempt_secondary_ability(data: &JoinData, update: &mut StateUpdate) { - if let Some(ability) = data.ability_pool.secondary { + if let Some(ability) = data + .loadout + .active_item + .as_ref() + .and_then(|i| i.secondary_ability) + { update.character = ability.into(); } } @@ -233,13 +243,18 @@ pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { } pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { - if let Some(ability) = data.ability_pool.dodge { + if let Some(ability) = data + .loadout + .active_item + .as_ref() + .and_then(|i| i.dodge_ability) + { update.character = ability.into(); } } pub fn unwrap_tool_data(data: &JoinData) -> Option { - if let Some(Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) { + if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| i.item.kind) { Some(tool) } else { None diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index e35bfbbb10..2309e7a579 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - AbilityPool, Attacking, Body, CharacterState, Controller, ControllerInputs, Energy, - Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, + Attacking, Body, CharacterState, Controller, ControllerInputs, Energy, Loadout, Mounting, + Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -33,7 +33,7 @@ pub struct JoinData<'a> { pub energy: &'a Energy, pub body: &'a Body, pub physics: &'a PhysicsState, - pub ability_pool: &'a AbilityPool, + pub loadout: &'a Loadout, pub attacking: Option<&'a Attacking>, pub updater: &'a LazyUpdate, } @@ -50,7 +50,7 @@ pub type JoinTuple<'a> = ( &'a Stats, &'a Body, &'a PhysicsState, - &'a AbilityPool, + &'a Loadout, Option<&'a Attacking>, ); @@ -69,7 +69,7 @@ impl<'a> JoinData<'a> { stats: j.8, body: j.9, physics: j.10, - ability_pool: j.11, + loadout: j.11, attacking: j.12, updater, dt, @@ -102,7 +102,7 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Stats>, ReadStorage<'a, Body>, ReadStorage<'a, PhysicsState>, - ReadStorage<'a, AbilityPool>, + ReadStorage<'a, Loadout>, ReadStorage<'a, Attacking>, ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, @@ -126,7 +126,7 @@ impl<'a> System<'a> for Sys { stats, bodies, physics_states, - ability_pools, + loadouts, attacking_storage, uids, mountings, @@ -144,7 +144,7 @@ impl<'a> System<'a> for Sys { &stats, &bodies, &physics_states, - &ability_pools, + &loadouts, attacking_storage.maybe(), ) .join(); diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index b811beb991..0ee15f7211 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -104,19 +104,19 @@ impl<'a> System<'a> for Sys { && ori2.angle_between(pos_b2 - pos2) < ATTACK_ANGLE.to_radians() / 2.0 + (rad_b / pos2.distance(pos_b2)).atan() { // Weapon gives base damage - let mut dmg = attack.weapon.map(|w| w.base_damage as i32).unwrap_or(3); + let mut dmg = attack.base_damage; // Block if character_b.is_block() && ori_b.0.angle_between(pos.0 - pos_b.0) < BLOCK_ANGLE.to_radians() / 2.0 { - dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as i32 + dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as u32 } server_bus.emitter().emit(ServerEvent::Damage { uid: *uid_b, change: HealthChange { - amount: -dmg, + amount: -(dmg as i32), cause: HealthSource::Attack { by: *uid }, }, }); diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index 09998ca6aa..2023bec217 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -83,22 +83,6 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv if let Some(item) = item_opt { match item.kind { - comp::ItemKind::Tool { .. } => { - if let Some(stats) = - state.ecs().write_storage::().get_mut(entity) - { - // Insert old item into inventory - if let Some(old_item) = stats.equipment.main.take() { - state - .ecs() - .write_storage::() - .get_mut(entity) - .map(|inv| inv.insert(slot, old_item)); - } - - stats.equipment.main = Some(item); - } - }, comp::ItemKind::Consumable { kind, effect } => { event = comp::InventoryUpdateEvent::Consumed(kind); state.apply_effect(entity, effect); diff --git a/server/src/lib.rs b/server/src/lib.rs index ebe6dd8d84..213f837831 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -289,21 +289,21 @@ impl Server { state.write_component( entity, - if let Some(comp::Item { - kind: comp::ItemKind::Tool(tool), - .. - }) = main - { + if let Some(comp::ItemKind::Tool(tool)) = main.as_ref().map(|i| i.kind) { let mut abilities = tool.get_abilities(); let mut ability_drain = abilities.drain(..); - comp::AbilityPool { - primary: ability_drain.next(), - secondary: ability_drain.next(), - block: Some(comp::CharacterAbility::BasicBlock), - dodge: Some(comp::CharacterAbility::Roll), + comp::Loadout { + active_item: main.map(|item| comp::ItemConfig { + item, + primary_ability: ability_drain.next(), + secondary_ability: ability_drain.next(), + block_ability: Some(comp::CharacterAbility::BasicBlock), + dodge_ability: Some(comp::CharacterAbility::Roll), + }), + second_item: None, } } else { - comp::AbilityPool::default() + comp::Loadout::default() }, ); @@ -676,7 +676,7 @@ impl StateExt for State { .with(comp::Energy::new(500)) .with(comp::Gravity(1.0)) .with(comp::CharacterState::default()) - .with(comp::AbilityPool::default()) + .with(comp::Loadout::default()) // TODO Give the poor npc something to do } fn notify_registered_clients(&self, msg: ServerMsg) { diff --git a/server/src/sys/sentinel.rs b/server/src/sys/sentinel.rs index f48f8a9f59..382e1aa27c 100644 --- a/server/src/sys/sentinel.rs +++ b/server/src/sys/sentinel.rs @@ -1,7 +1,7 @@ use super::SysTimer; use common::{ comp::{ - AbilityPool, Body, CanBuild, CharacterState, Energy, Gravity, Item, LightEmitter, Mass, + Body, CanBuild, CharacterState, Energy, Gravity, Item, LightEmitter, Loadout, Mass, MountState, Mounting, Player, Scale, Stats, Sticky, }, msg::EcsCompPacket, @@ -51,7 +51,7 @@ pub struct TrackedComps<'a> { pub mass: ReadStorage<'a, Mass>, pub sticky: ReadStorage<'a, Sticky>, pub gravity: ReadStorage<'a, Gravity>, - pub ability_pool: ReadStorage<'a, AbilityPool>, + pub loadout: ReadStorage<'a, Loadout>, pub character_state: ReadStorage<'a, CharacterState>, } impl<'a> TrackedComps<'a> { @@ -106,9 +106,9 @@ impl<'a> TrackedComps<'a> { .get(entity) .copied() .map(|c| comps.push(c.into())); - self.ability_pool + self.loadout .get(entity) - .copied() + .cloned() .map(|c| comps.push(c.into())); self.character_state .get(entity) @@ -134,7 +134,7 @@ pub struct ReadTrackers<'a> { pub mass: ReadExpect<'a, UpdateTracker>, pub sticky: ReadExpect<'a, UpdateTracker>, pub gravity: ReadExpect<'a, UpdateTracker>, - pub ability_pool: ReadExpect<'a, UpdateTracker>, + pub loadout: ReadExpect<'a, UpdateTracker>, pub character_state: ReadExpect<'a, UpdateTracker>, } impl<'a> ReadTrackers<'a> { @@ -163,7 +163,7 @@ impl<'a> ReadTrackers<'a> { .with_component(&comps.uid, &*self.mass, &comps.mass, filter) .with_component(&comps.uid, &*self.sticky, &comps.sticky, filter) .with_component(&comps.uid, &*self.gravity, &comps.gravity, filter) - .with_component(&comps.uid, &*self.ability_pool, &comps.ability_pool, filter) + .with_component(&comps.uid, &*self.loadout, &comps.loadout, filter) .with_component( &comps.uid, &*self.character_state, @@ -189,7 +189,7 @@ pub struct WriteTrackers<'a> { mass: WriteExpect<'a, UpdateTracker>, sticky: WriteExpect<'a, UpdateTracker>, gravity: WriteExpect<'a, UpdateTracker>, - ability_pool: WriteExpect<'a, UpdateTracker>, + loadout: WriteExpect<'a, UpdateTracker>, character_state: WriteExpect<'a, UpdateTracker>, } @@ -209,7 +209,7 @@ fn record_changes(comps: &TrackedComps, trackers: &mut WriteTrackers) { trackers.mass.record_changes(&comps.mass); trackers.sticky.record_changes(&comps.sticky); trackers.gravity.record_changes(&comps.gravity); - trackers.ability_pool.record_changes(&comps.ability_pool); + trackers.loadout.record_changes(&comps.loadout); trackers .character_state .record_changes(&comps.character_state); @@ -230,7 +230,7 @@ pub fn register_trackers(world: &mut World) { world.register_tracker::(); world.register_tracker::(); world.register_tracker::(); - world.register_tracker::(); + world.register_tracker::(); world.register_tracker::(); } diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 2ca9c72912..f646795e9a 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -180,7 +180,17 @@ impl<'a> System<'a> for Sys { .choose(&mut rand::thread_rng()) .expect("SPAWN_NPCS is nonempty")( ); - let mut stats = comp::Stats::new(name, body, main); + let mut stats = comp::Stats::new(name, body, main.clone()); + let mut loadout = comp::Loadout { + active_item: main.map(|item| comp::ItemConfig { + item, + primary_ability: None, + secondary_ability: None, + block_ability: None, + dodge_ability: None, + }), + second_item: None, + }; let mut scale = 1.0; @@ -202,6 +212,17 @@ impl<'a> System<'a> for Sys { Some(assets::load_expect_cloned("common.items.weapons.hammer_1")), ); } + loadout = comp::Loadout { + active_item: Some(comp::ItemConfig { + item: assets::load_expect_cloned("common.items.weapons.hammer_1"), + primary_ability: None, + secondary_ability: None, + block_ability: None, + dodge_ability: None, + }), + second_item: None, + }; + stats.level.set_level(rand::thread_rng().gen_range(8, 15)); scale = 2.0 + rand::random::(); } @@ -210,12 +231,10 @@ impl<'a> System<'a> for Sys { stats .health .set_to(stats.health.maximum(), comp::HealthSource::Revive); - if let Some(item::Item { - kind: item::ItemKind::Tool(item::ToolData { base_damage, .. }), - .. - }) = &mut stats.equipment.main + if let Some(item::ItemKind::Tool(item::ToolData { base_damage, .. })) = + &mut loadout.active_item.map(|i| i.item.kind) { - *base_damage = stats.level.level() as u64 * 3; + *base_damage = stats.level.level() as u32 * 3; } server_emitter.emit(ServerEvent::CreateNpc { pos: Pos(entity.pos), diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index f5a0a89ad8..0cf8986a7f 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1659,22 +1659,25 @@ impl Hud { // Skillbar // Get player stats let ecs = client.state().ecs(); - let stats = ecs.read_storage::(); - let energy = ecs.read_storage::(); - let character_state = ecs.read_storage::(); let entity = client.entity(); - let controller = ecs.read_storage::(); - if let (Some(stats), Some(energy), Some(character_state), Some(controller)) = ( + let stats = ecs.read_storage::(); + let loadouts = ecs.read_storage::(); + let energies = ecs.read_storage::(); + let character_states = ecs.read_storage::(); + let controllers = ecs.read_storage::(); + if let (Some(stats), Some(loadout), Some(energy), Some(character_state), Some(controller)) = ( stats.get(entity), - energy.get(entity), - character_state.get(entity), - controller.get(entity).map(|c| &c.inputs), + loadouts.get(entity), + energies.get(entity), + character_states.get(entity), + controllers.get(entity).map(|c| &c.inputs), ) { Skillbar::new( global_state, &self.imgs, &self.fonts, &stats, + &loadout, &energy, &character_state, self.pulse, diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 8df29bac07..98414df9a6 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -11,7 +11,7 @@ use common::{ assets::load_expect, comp::{ item::{DebugKind, ToolData, ToolKind}, - CharacterState, ControllerInputs, Energy, ItemKind, Stats, + CharacterState, ControllerInputs, Energy, ItemKind, Loadout, Stats, }, }; use conrod_core::{ @@ -111,6 +111,7 @@ pub struct Skillbar<'a> { imgs: &'a Imgs, fonts: &'a ConrodVoxygenFonts, stats: &'a Stats, + loadout: &'a Loadout, energy: &'a Energy, character_state: &'a CharacterState, controller: &'a ControllerInputs, @@ -126,6 +127,7 @@ impl<'a> Skillbar<'a> { imgs: &'a Imgs, fonts: &'a ConrodVoxygenFonts, stats: &'a Stats, + loadout: &'a Loadout, energy: &'a Energy, character_state: &'a CharacterState, pulse: f32, @@ -136,6 +138,7 @@ impl<'a> Skillbar<'a> { imgs, fonts, stats, + loadout, energy, current_resource: ResourceType::Mana, common: widget::CommonBuilder::default(), @@ -580,44 +583,52 @@ impl<'a> Widget for Skillbar<'a> { // M1 Slot Image::new(self.imgs.skillbar_slot_big_bg) .w_h(38.0 * scale, 38.0 * scale) - .color(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => Some(BG_COLOR_2), - ToolKind::Staff => Some(BG_COLOR_2), + .color( + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => Some(BG_COLOR_2), + ToolKind::Staff => Some(BG_COLOR_2), + _ => Some(BG_COLOR_2), + }, _ => Some(BG_COLOR_2), }, - _ => Some(BG_COLOR_2), - }) + ) .middle_of(state.ids.m1_slot) .set(state.ids.m1_slot_bg, ui); - Button::image(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Sword(_) => self.imgs.twohsword_m1, - ToolKind::Hammer => self.imgs.twohhammer_m1, - ToolKind::Axe => self.imgs.twohaxe_m1, - ToolKind::Bow => self.imgs.bow_m1, - ToolKind::Staff => self.imgs.staff_m1, - ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m1, + Button::image( + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Sword(_) => self.imgs.twohsword_m1, + ToolKind::Hammer => self.imgs.twohhammer_m1, + ToolKind::Axe => self.imgs.twohaxe_m1, + ToolKind::Bow => self.imgs.bow_m1, + ToolKind::Staff => self.imgs.staff_m1, + ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m1, + _ => self.imgs.twohaxe_m1, + }, _ => self.imgs.twohaxe_m1, }, - _ => self.imgs.twohaxe_m1, - }) // Insert Icon here - .w(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => 30.0 * scale, - ToolKind::Staff => 32.0 * scale, + ) // Insert Icon here + .w( + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => 30.0 * scale, + ToolKind::Staff => 32.0 * scale, + _ => 38.0 * scale, + }, _ => 38.0 * scale, }, - _ => 38.0 * scale, - }) - .h(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => 30.0 * scale, - ToolKind::Staff => 32.0 * scale, + ) + .h( + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => 30.0 * scale, + ToolKind::Staff => 32.0 * scale, + _ => 38.0 * scale, + }, _ => 38.0 * scale, }, - _ => 38.0 * scale, - }) + ) .middle_of(state.ids.m1_slot_bg) .set(state.ids.m1_content, ui); // M2 Slot @@ -673,44 +684,52 @@ impl<'a> Widget for Skillbar<'a> { Image::new(self.imgs.skillbar_slot_big_bg) .w_h(38.0 * scale, 38.0 * scale) - .color(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => Some(BG_COLOR_2), - ToolKind::Staff => Some(BG_COLOR_2), + .color( + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => Some(BG_COLOR_2), + ToolKind::Staff => Some(BG_COLOR_2), + _ => Some(BG_COLOR_2), + }, _ => Some(BG_COLOR_2), }, - _ => Some(BG_COLOR_2), - }) + ) .middle_of(state.ids.m2_slot) .set(state.ids.m2_slot_bg, ui); - Button::image(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Sword(_) => self.imgs.twohsword_m2, - ToolKind::Hammer => self.imgs.twohhammer_m2, - ToolKind::Axe => self.imgs.twohaxe_m2, - ToolKind::Bow => self.imgs.bow_m2, - ToolKind::Staff => self.imgs.staff_m2, - ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m2, + Button::image( + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Sword(_) => self.imgs.twohsword_m2, + ToolKind::Hammer => self.imgs.twohhammer_m2, + ToolKind::Axe => self.imgs.twohaxe_m2, + ToolKind::Bow => self.imgs.bow_m2, + ToolKind::Staff => self.imgs.staff_m2, + ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m2, + _ => self.imgs.twohaxe_m2, + }, _ => self.imgs.twohaxe_m2, }, - _ => self.imgs.twohaxe_m2, - }) // Insert Icon here - .w(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => 30.0 * scale, - ToolKind::Staff => 30.0 * scale, + ) // Insert Icon here + .w( + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => 30.0 * scale, + ToolKind::Staff => 30.0 * scale, + _ => 38.0 * scale, + }, _ => 38.0 * scale, }, - _ => 38.0 * scale, - }) - .h(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => 30.0 * scale, - ToolKind::Staff => 30.0 * scale, + ) + .h( + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Bow => 30.0 * scale, + ToolKind::Staff => 30.0 * scale, + _ => 38.0 * scale, + }, _ => 38.0 * scale, }, - _ => 38.0 * scale, - }) + ) .middle_of(state.ids.m2_slot_bg) .set(state.ids.m2_content, ui); //Slot 5 diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index f7eaae27c2..cff2d9f925 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -116,14 +116,11 @@ impl PlayState for CharSelectionState { global_state.window.renderer_mut(), self.client.borrow().get_tick(), humanoid_body.clone(), - &comp::Equipment { - main: self - .char_selection_ui - .get_character_data() - .and_then(|data| data.tool) - .and_then(|tool| assets::load_cloned(&tool).ok()), - alt: None, - }, + self.char_selection_ui + .get_character_data() + .and_then(|data| data.tool) + .and_then(|tool| assets::load_cloned::(&tool).ok()) + .map(|i| i.kind), ); // Draw the UI to the screen. diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 3cd35ebb13..8d576bb418 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -6,7 +6,7 @@ use crate::{ }; use common::{ assets::watch::ReloadIndicator, - comp::{Body, CharacterState, Equipment}, + comp::{Body, CharacterState, ItemKind}, }; use hashbrown::{hash_map::Entry, HashMap}; use std::{ @@ -19,7 +19,7 @@ enum FigureKey { Simple(Body), Complex( Body, - Option, + Option, CameraMode, Option, ), @@ -58,7 +58,7 @@ impl FigureModelCache { &mut self, renderer: &mut Renderer, body: Body, - equipment: Option<&Equipment>, + item_kind: Option, tick: u64, camera_mode: CameraMode, character_state: Option<&CharacterState>, @@ -67,10 +67,10 @@ impl FigureModelCache { for<'a> &'a common::comp::Body: std::convert::TryInto, Skel::Attr: Default, { - let key = if equipment.is_some() { + let key = if item_kind.is_some() { FigureKey::Complex( body, - equipment.cloned(), + item_kind, camera_mode, character_state.map(|cs| CharacterStateCacheKey::from(cs)), ) @@ -187,7 +187,7 @@ impl FigureModelCache { }) .unwrap_or_default() { - Some(mesh_main(equipment.and_then(|e| e.main.as_ref()))) + Some(mesh_main(item_kind)) } else { None }, diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 5924e323c8..44821d5ef5 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -534,9 +534,9 @@ impl HumArmorFootSpec { } } -pub fn mesh_main(item: Option<&Item>) -> Mesh { - if let Some(item) = item { - let (name, offset) = match item.kind { +pub fn mesh_main(item_kind: Option) -> Mesh { + if let Some(item_kind) = item_kind { + let (name, offset) = match item_kind { ItemKind::Tool(ToolData { kind, .. }) => match kind { ToolKind::Sword(_) => ("weapon.sword.rusty_2h", Vec3::new(-1.5, -6.5, -4.0)), ToolKind::Axe => ("weapon.axe.rusty_2h", Vec3::new(-1.5, -5.0, -4.0)), diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 718339c632..9d97b697e9 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -20,7 +20,8 @@ use crate::{ }; use common::{ comp::{ - Body, CharacterState, ItemKind, Last, Ori, PhysicsState, Pos, Scale, Stats, ToolData, Vel, + Body, CharacterState, ItemKind, Last, Loadout, Ori, PhysicsState, Pos, Scale, Stats, + ToolData, Vel, }, state::State, terrain::TerrainChunk, @@ -112,7 +113,19 @@ impl FigureMgr { .get(scene_data.player_entity) .map_or(Vec3::zero(), |pos| pos.0); - for (entity, pos, vel, ori, scale, body, character, last_character, physics, stats) in ( + for ( + entity, + pos, + vel, + ori, + scale, + body, + character, + last_character, + physics, + stats, + loadout, + ) in ( &ecs.entities(), &ecs.read_storage::(), &ecs.read_storage::(), @@ -123,6 +136,7 @@ impl FigureMgr { ecs.read_storage::>().maybe(), &ecs.read_storage::(), ecs.read_storage::().maybe(), + ecs.read_storage::().maybe(), ) .join() { @@ -370,11 +384,11 @@ impl FigureMgr { let mut state_animation_rate = 1.0; - let active_tool_kind = if let Some(ItemKind::Tool(ToolData { kind, .. })) = stats - .and_then(|s| s.equipment.main.as_ref()) - .map(|i| &i.kind) - { - Some(*kind) + let active_item_kind = loadout + .and_then(|l| l.active_item.as_ref()) + .map(|i| i.item.kind); + let active_tool_kind = if let Some(ItemKind::Tool(tool)) = active_item_kind { + Some(tool.kind) } else { None }; @@ -386,7 +400,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats.map(|s| &s.equipment), + active_item_kind, tick, CameraMode::default(), None, @@ -566,7 +580,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats.map(|s| &s.equipment), + active_item_kind, tick, CameraMode::default(), None, @@ -647,7 +661,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats.map(|s| &s.equipment), + active_item_kind, tick, CameraMode::default(), None, @@ -730,7 +744,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats.map(|s| &s.equipment), + active_item_kind, tick, CameraMode::default(), None, @@ -805,7 +819,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats.map(|s| &s.equipment), + active_item_kind, tick, CameraMode::default(), None, @@ -880,7 +894,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats.map(|s| &s.equipment), + active_item_kind, tick, CameraMode::default(), None, @@ -955,7 +969,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats.map(|s| &s.equipment), + active_item_kind, tick, CameraMode::default(), None, @@ -1030,7 +1044,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats.map(|s| &s.equipment), + active_item_kind, tick, CameraMode::default(), None, @@ -1105,7 +1119,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats.map(|s| &s.equipment), + active_item_kind, tick, CameraMode::default(), None, @@ -1180,7 +1194,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats.map(|s| &s.equipment), + active_item_kind, tick, CameraMode::default(), None, @@ -1313,17 +1327,18 @@ impl FigureMgr { let character_state_storage = state.read_storage::(); let character_state = character_state_storage.get(player_entity); - for (entity, _, _, body, stats, _) in ( + for (entity, _, _, body, stats, loadout, _) in ( &ecs.entities(), &ecs.read_storage::(), ecs.read_storage::().maybe(), &ecs.read_storage::(), ecs.read_storage::().maybe(), + ecs.read_storage::().maybe(), ecs.read_storage::().maybe(), ) .join() // Don't render dead entities - .filter(|(_, _, _, _, stats, _)| stats.map_or(true, |s| !s.is_dead)) + .filter(|(_, _, _, _, stats, loadout, _)| stats.map_or(true, |s| !s.is_dead)) { let is_player = entity == player_entity; let player_camera_mode = if is_player { @@ -1331,7 +1346,9 @@ impl FigureMgr { } else { CameraMode::default() }; - let stats = stats.map(|s| &s.equipment); + let active_item_kind = loadout + .and_then(|l| l.active_item.as_ref()) + .map(|i| i.item.kind); let character_state = if is_player { character_state } else { None }; let FigureMgr { @@ -1369,7 +1386,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, @@ -1385,7 +1402,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, @@ -1401,7 +1418,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, @@ -1417,7 +1434,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, @@ -1433,7 +1450,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, @@ -1449,7 +1466,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, @@ -1465,7 +1482,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, @@ -1481,7 +1498,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, @@ -1497,7 +1514,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, @@ -1513,7 +1530,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, @@ -1529,7 +1546,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - stats, + active_item_kind, tick, player_camera_mode, character_state, diff --git a/voxygen/src/scene/simple.rs b/voxygen/src/scene/simple.rs index a0f6d159e7..9547b82fb3 100644 --- a/voxygen/src/scene/simple.rs +++ b/voxygen/src/scene/simple.rs @@ -15,7 +15,7 @@ use crate::{ window::{Event, PressState}, }; use common::{ - comp::{humanoid, Body, Equipment}, + comp::{humanoid, Body, ItemKind}, terrain::BlockKind, vol::{BaseVol, ReadVol, Vox}, }; @@ -208,7 +208,7 @@ impl Scene { renderer: &mut Renderer, tick: u64, body: Option, - equipment: &Equipment, + active_item_kind: Option, ) { renderer.render_skybox(&self.skybox.model, &self.globals, &self.skybox.locals); @@ -218,7 +218,7 @@ impl Scene { .get_or_create_model( renderer, Body::Humanoid(body), - Some(equipment), + active_item_kind, tick, CameraMode::default(), None, From e72f0c6d123cc6d3f19cc3c0efba57a667632c6d Mon Sep 17 00:00:00 2001 From: Songtronix Date: Sun, 15 Mar 2020 09:02:56 +0100 Subject: [PATCH 077/326] fix: do not depend on hash file during runtime --- common/src/util/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/util/mod.rs b/common/src/util/mod.rs index 83e1aee722..879c82af1e 100644 --- a/common/src/util/mod.rs +++ b/common/src/util/mod.rs @@ -1,8 +1,8 @@ pub const GIT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/githash")); lazy_static::lazy_static! { - pub static ref GIT_HASH: &'static str = include_str!(concat!(env!("OUT_DIR"), "/githash")).split("/").nth(0).expect("failed to retrieve git_hash!"); - pub static ref GIT_DATE: &'static str = include_str!(concat!(env!("OUT_DIR"), "/githash")).split("/").nth(1).expect("failed to retrieve git_date!"); + pub static ref GIT_HASH: &'static str = GIT_VERSION.split("/").nth(0).expect("failed to retrieve git_hash!"); + pub static ref GIT_DATE: &'static str = GIT_VERSION.split("/").nth(1).expect("failed to retrieve git_date!"); } use vek::{Mat3, Rgb, Rgba, Vec3}; From 52059d83d35d5e922aab13dedd4de9fa60c0d5a8 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sun, 15 Mar 2020 07:20:42 -0600 Subject: [PATCH 078/326] add knockback localevent --- common/src/event.rs | 1 + common/src/state.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/common/src/event.rs b/common/src/event.rs index e14ac62bfb..14082fb9e2 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -47,6 +47,7 @@ pub enum SfxEvent { pub enum LocalEvent { Jump(EcsEntity), + Knockback(EcsEntity), WallLeap { entity: EcsEntity, wall_dir: Vec3, diff --git a/common/src/state.rs b/common/src/state.rs index d2b8386304..a37e14a337 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -334,6 +334,7 @@ impl State { let events = self.ecs.read_resource::>().recv_all(); for event in events { let mut velocities = self.ecs.write_storage::(); + let mut orientations = self.ecs.write_storage::(); let mut controllers = self.ecs.write_storage::(); match event { LocalEvent::Jump(entity) => { @@ -341,6 +342,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)) From 75207985673d9a4350dd31fb89df6656ebbd7997 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sun, 15 Mar 2020 07:26:42 -0600 Subject: [PATCH 079/326] Damage increase, remove lines --- common/src/states/timed_combo.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index 4467ce7173..f2969db1a5 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -42,7 +42,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(wielding::Data { tool: self.tool }); } @@ -62,7 +61,7 @@ impl CharacterBehavior for Data { else if !self.stage_exhausted { // Swing hits data.updater.insert(data.entity, Attacking { - base_damage: self.tool.base_damage, + base_damage: self.tool.base_damage * (self.stage as u32 + 1), applied: false, hit_count: 0, }); @@ -85,7 +84,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 { tool: self.tool, stage: self.stage + 1, @@ -98,7 +96,6 @@ impl CharacterBehavior for Data { // Player didn't click this frame else { // Update state - println!("Missed"); update.character = CharacterState::TimedCombo(Data { tool: self.tool, stage: self.stage, @@ -129,7 +126,6 @@ impl CharacterBehavior for Data { // Subtract energy on successful hit if let Some(attack) = data.attacking { if attack.applied && attack.hit_count > 0 { - println!("Hit"); data.updater.remove::(data.entity); update.energy.change_by(100, EnergySource::HitEnemy); } From 447617dc69a178dc9ba41fd96dfd41d86ddc8322 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sun, 15 Mar 2020 14:34:17 +0100 Subject: [PATCH 080/326] Make durations and damage depend on weapon type --- assets/common/items/weapons/hammer_1.ron | 4 -- assets/common/items/weapons/staff_1.ron | 4 -- assets/common/items/weapons/starter_axe.ron | 4 -- assets/common/items/weapons/starter_bow.ron | 4 -- .../common/items/weapons/starter_dagger.ron | 4 -- .../common/items/weapons/starter_hammer.ron | 4 -- assets/common/items/weapons/starter_sword.ron | 4 -- common/src/comp/ability.rs | 9 ++- common/src/comp/character_state.rs | 4 +- common/src/comp/inventory/item.rs | 60 ++++++++++--------- common/src/comp/stats.rs | 2 +- common/src/states/basic_attack.rs | 9 ++- common/src/states/equipping.rs | 2 +- common/src/states/idle.rs | 1 + common/src/states/timed_combo.rs | 25 ++++---- common/src/states/wielding.rs | 9 +-- common/src/sys/character_behavior.rs | 20 +++---- server/src/sys/terrain.rs | 10 +++- 18 files changed, 83 insertions(+), 96 deletions(-) diff --git a/assets/common/items/weapons/hammer_1.ron b/assets/common/items/weapons/hammer_1.ron index 13862f88c2..caeaf8ad28 100644 --- a/assets/common/items/weapons/hammer_1.ron +++ b/assets/common/items/weapons/hammer_1.ron @@ -5,10 +5,6 @@ Item( ToolData ( kind: Hammer, equip_time_millis: 1000, - attack_buildup_millis: 700, - attack_recover_millis: 100, - range: 3, - base_damage: 10, ) ) ) diff --git a/assets/common/items/weapons/staff_1.ron b/assets/common/items/weapons/staff_1.ron index cb1bc62358..f56cb59f42 100644 --- a/assets/common/items/weapons/staff_1.ron +++ b/assets/common/items/weapons/staff_1.ron @@ -5,10 +5,6 @@ Item( ToolData ( kind: Staff, equip_time_millis: 800, - attack_buildup_millis: 400, - attack_recover_millis: 300, - range: 3, - base_damage: 10, ) ), ) diff --git a/assets/common/items/weapons/starter_axe.ron b/assets/common/items/weapons/starter_axe.ron index 9145b4a09a..adbb486de2 100644 --- a/assets/common/items/weapons/starter_axe.ron +++ b/assets/common/items/weapons/starter_axe.ron @@ -5,10 +5,6 @@ Item( ToolData ( kind: Axe, equip_time_millis: 1000, - attack_buildup_millis: 700, - attack_recover_millis: 100, - range: 3, - base_damage: 10, ) ), ) diff --git a/assets/common/items/weapons/starter_bow.ron b/assets/common/items/weapons/starter_bow.ron index 724824581a..b265ef65da 100644 --- a/assets/common/items/weapons/starter_bow.ron +++ b/assets/common/items/weapons/starter_bow.ron @@ -5,10 +5,6 @@ Item( ToolData ( kind: Bow, equip_time_millis: 800, - attack_buildup_millis: 0, - attack_recover_millis: 800, - range: 3, - base_damage: 10, ) ), ) diff --git a/assets/common/items/weapons/starter_dagger.ron b/assets/common/items/weapons/starter_dagger.ron index 5d2c20c32e..bb50379b52 100644 --- a/assets/common/items/weapons/starter_dagger.ron +++ b/assets/common/items/weapons/starter_dagger.ron @@ -5,10 +5,6 @@ Item( ToolData ( kind: Dagger, equip_time_millis: 300, - attack_buildup_millis: 100, - attack_recover_millis: 400, - range: 3, - base_damage: 10, ) ), ) diff --git a/assets/common/items/weapons/starter_hammer.ron b/assets/common/items/weapons/starter_hammer.ron index be0b2505f8..1d3aa1a05a 100644 --- a/assets/common/items/weapons/starter_hammer.ron +++ b/assets/common/items/weapons/starter_hammer.ron @@ -5,10 +5,6 @@ Item( ToolData ( kind: Hammer, equip_time_millis: 1000, - attack_buildup_millis: 700, - attack_recover_millis: 100, - range: 3, - base_damage: 10, ) ), ) diff --git a/assets/common/items/weapons/starter_sword.ron b/assets/common/items/weapons/starter_sword.ron index 4f3f1b2506..ad3511c1e2 100644 --- a/assets/common/items/weapons/starter_sword.ron +++ b/assets/common/items/weapons/starter_sword.ron @@ -5,10 +5,6 @@ Item( ToolData ( kind: Sword(Rapier), equip_time_millis: 800, - attack_buildup_millis: 100, - attack_recover_millis: 500, - range: 3, - base_damage: 10, ) ), ) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index d7508f36f7..b8d3abee5f 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -10,14 +10,15 @@ pub enum CharacterAbility { BasicAttack { buildup_duration: Duration, recover_duration: Duration, + base_damage: u32, }, BasicBlock, Roll, ChargeAttack, TimedCombo { - tool: ToolData, buildup_duration: Duration, recover_duration: Duration, + base_damage: u32, }, } @@ -47,10 +48,12 @@ impl From for CharacterState { CharacterAbility::BasicAttack { buildup_duration, recover_duration, + base_damage, } => CharacterState::BasicAttack(basic_attack::Data { exhausted: false, buildup_duration, recover_duration, + base_damage, }), CharacterAbility::BasicBlock { .. } => CharacterState::BasicBlock, CharacterAbility::Roll { .. } => CharacterState::Roll(roll::Data { @@ -62,16 +65,16 @@ impl From for CharacterState { }) }, CharacterAbility::TimedCombo { - tool, buildup_duration, recover_duration, + base_damage, } => CharacterState::TimedCombo(timed_combo::Data { - tool, buildup_duration, recover_duration, stage: 0, stage_exhausted: false, stage_time_active: Duration::default(), + base_damage, }), } } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index bbc3242743..6c4ae39be9 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -29,7 +29,7 @@ pub enum CharacterState { /// Player is busy equipping or unequipping weapons Equipping(equipping::Data), /// Player is holding a weapon and can perform other actions - Wielding(wielding::Data), + Wielding, /// Player rushes forward and slams an enemy with their weapon ChargeAttack(charge_attack::Data), /// A dodge where player can roll @@ -47,7 +47,7 @@ pub enum CharacterState { impl CharacterState { pub fn is_wield(&self) -> bool { match self { - CharacterState::Wielding(_) + CharacterState::Wielding | CharacterState::BasicAttack(_) | CharacterState::TimedCombo(_) | CharacterState::BasicBlock => true, diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 9f07d6a3b3..e420f100b5 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -37,41 +37,37 @@ impl ToolData { use ToolKind::*; match self.kind { - Sword(_) => vec![TimedCombo { - buildup_duration: Duration::from_millis(500), - recover_duration: Duration::from_millis(1000), - tool: *self, + Sword(_) => vec![BasicAttack { + buildup_duration: Duration::from_millis(100), + recover_duration: Duration::from_millis(500), + base_damage: 60, }], Axe => vec![BasicAttack { - buildup_duration: Duration::from_millis(1000), - recover_duration: Duration::from_millis(500), + buildup_duration: Duration::from_millis(700), + recover_duration: Duration::from_millis(100), + base_damage: 80, }], Hammer => vec![BasicAttack { - buildup_duration: Duration::from_millis(1000), - recover_duration: Duration::from_millis(500), - }], - Bow => vec![BasicAttack { - buildup_duration: Duration::from_millis(1000), - recover_duration: Duration::from_millis(500), + buildup_duration: Duration::from_millis(700), + recover_duration: Duration::from_millis(300), + base_damage: 100, }], + Bow => vec![], Dagger => vec![BasicAttack { - buildup_duration: Duration::from_millis(1000), - recover_duration: Duration::from_millis(500), + buildup_duration: Duration::from_millis(100), + recover_duration: Duration::from_millis(400), + base_damage: 50, }], Staff => vec![BasicAttack { - buildup_duration: Duration::from_millis(1000), - recover_duration: Duration::from_millis(500), - }], - Shield => vec![BasicAttack { - buildup_duration: Duration::from_millis(1000), - recover_duration: Duration::from_millis(500), + buildup_duration: Duration::from_millis(400), + recover_duration: Duration::from_millis(300), + base_damage: 70, }], + Shield => vec![], Debug(kind) => match kind { Boost => vec![], Possess => vec![], }, - - _ => vec![], } } } @@ -125,18 +121,24 @@ pub enum Ingredient { pub struct ToolData { pub kind: ToolKind, equip_time_millis: u64, - attack_buildup_millis: u64, - attack_recover_millis: u64, - range: u32, - pub base_damage: u32, + // TODO: item specific abilities } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ItemKind { + /// Something wieldable Tool(ToolData), - Armor { kind: Armor, power: u32 }, - Consumable { kind: Consumable, effect: Effect }, - Utility { kind: Utility }, + Armor { + kind: Armor, + power: u32, + }, + Consumable { + kind: Consumable, + effect: Effect, + }, + Utility { + kind: Utility, + }, Ingredient(Ingredient), } diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index d60e2d45dd..d7e4fe9ebd 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -134,7 +134,7 @@ impl Stats { } // TODO: Delete this once stat points will be a thing - pub fn update_max_hp(&mut self) { self.health.set_maximum(27 + 15 * self.level.amount); } + pub fn update_max_hp(&mut self) { self.health.set_maximum(200 + 47 * self.level.amount); } } impl Stats { diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_attack.rs index 64846659ba..b81fba8de1 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -11,6 +11,8 @@ pub struct Data { pub buildup_duration: Duration, /// How long the state has until exiting pub recover_duration: Duration, + /// Base damage + pub base_damage: u32, /// Whether the attack can deal more damage pub exhausted: bool, } @@ -37,6 +39,7 @@ impl CharacterBehavior for Data { .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), recover_duration: self.recover_duration, + base_damage: self.base_damage, exhausted: false, }); } @@ -44,7 +47,7 @@ impl CharacterBehavior for Data { else if !self.exhausted { if let Some(tool) = unwrap_tool_data(data) { data.updater.insert(data.entity, Attacking { - base_damage: tool.base_damage, + base_damage: self.base_damage, applied: false, hit_count: 0, }); @@ -53,6 +56,7 @@ impl CharacterBehavior for Data { update.character = CharacterState::BasicAttack(Data { buildup_duration: self.buildup_duration, recover_duration: self.recover_duration, + base_damage: self.base_damage, exhausted: true, }); } @@ -64,13 +68,14 @@ impl CharacterBehavior for Data { .recover_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), + base_damage: self.base_damage, exhausted: true, }); } // Done else { if let Some(tool) = unwrap_tool_data(data) { - update.character = CharacterState::Wielding(wielding::Data { tool }); + update.character = CharacterState::Wielding; // Make sure attack component is removed data.updater.remove::(data.entity); } else { diff --git a/common/src/states/equipping.rs b/common/src/states/equipping.rs index d79be81b34..cc4b8cba09 100644 --- a/common/src/states/equipping.rs +++ b/common/src/states/equipping.rs @@ -31,7 +31,7 @@ impl CharacterBehavior for Data { if self.time_left == Duration::default() { // Wield delay has expired - update.character = CharacterState::Wielding(wielding::Data { tool: self.tool }); + update.character = CharacterState::Wielding; } else { // Wield delay hasn't expired yet // Update wield delay diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index 282d465b54..7d78d9b73f 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -18,6 +18,7 @@ impl CharacterBehavior for Data { local_events: VecDeque::new(), server_events: VecDeque::new(), }; + handle_move(data, &mut update); handle_jump(data, &mut update); handle_wield(data, &mut update); diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index 4467ce7173..9ee4ebe613 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -1,6 +1,5 @@ use crate::{ - comp::{Attacking, CharacterState, EnergySource, StateUpdate, ToolData}, - states::wielding, + comp::{Attacking, CharacterState, EnergySource, StateUpdate}, sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::{collections::VecDeque, time::Duration}; @@ -16,8 +15,8 @@ pub struct Data { pub recover_duration: Duration, /// Tracks how long current stage has been active pub stage_time_active: Duration, - /// `ToolData` to be sent to `Attacking` component - pub tool: ToolData, + /// Base damage + pub base_damage: u32, } impl CharacterBehavior for Data { @@ -44,17 +43,17 @@ impl CharacterBehavior for Data { if data.inputs.primary.is_just_pressed() { println!("Failed"); // They failed, go back to `Wielding` - update.character = CharacterState::Wielding(wielding::Data { tool: self.tool }); + update.character = CharacterState::Wielding; } // Keep updating else { update.character = CharacterState::TimedCombo(Data { - tool: self.tool, stage: self.stage, buildup_duration: self.buildup_duration, recover_duration: self.recover_duration, stage_exhausted: false, stage_time_active: new_stage_time_active, + base_damage: self.base_damage, }); } } @@ -62,18 +61,18 @@ impl CharacterBehavior for Data { else if !self.stage_exhausted { // Swing hits data.updater.insert(data.entity, Attacking { - base_damage: self.tool.base_damage, + base_damage: self.base_damage, applied: false, hit_count: 0, }); update.character = CharacterState::TimedCombo(Data { - tool: self.tool, stage: self.stage, buildup_duration: self.buildup_duration, recover_duration: self.recover_duration, stage_exhausted: true, stage_time_active: new_stage_time_active, + base_damage: self.base_damage, }); } // Swing recovery window @@ -87,12 +86,12 @@ impl CharacterBehavior for Data { if data.inputs.primary.is_just_pressed() { println!("Transition"); update.character = CharacterState::TimedCombo(Data { - tool: self.tool, stage: self.stage + 1, buildup_duration: self.buildup_duration, recover_duration: self.recover_duration, stage_exhausted: true, stage_time_active: Duration::default(), + base_damage: self.base_damage, }); } // Player didn't click this frame @@ -100,19 +99,19 @@ impl CharacterBehavior for Data { // Update state println!("Missed"); update.character = CharacterState::TimedCombo(Data { - tool: self.tool, stage: self.stage, buildup_duration: self.buildup_duration, recover_duration: self.recover_duration, stage_exhausted: true, stage_time_active: new_stage_time_active, + base_damage: self.base_damage, }); } } // Stage expired but missed transition to next stage else { // Back to `Wielding` - update.character = CharacterState::Wielding(wielding::Data { tool: self.tool }); + update.character = CharacterState::Wielding; // Make sure attack component is removed data.updater.remove::(data.entity); } @@ -121,12 +120,12 @@ impl CharacterBehavior for Data { else { println!("Success!"); // Back to `Wielding` - update.character = CharacterState::Wielding(wielding::Data { tool: self.tool }); + update.character = CharacterState::Wielding; // Make sure attack component is removed data.updater.remove::(data.entity); } - // Subtract energy on successful hit + // Grant energy on successful hit if let Some(attack) = data.attacking { if attack.applied && attack.hit_count > 0 { println!("Hit"); diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 27e60d9be7..6d2aaa491a 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -1,14 +1,11 @@ use super::utils::*; use crate::{ - comp::{StateUpdate, ToolData}, + comp::StateUpdate, sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::collections::VecDeque; -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct Data { - /// The weapon being wielded - pub tool: ToolData, -} + +pub struct Data; impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 2309e7a579..1217a98147 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -172,17 +172,17 @@ impl<'a> System<'a> for Sys { } let mut state_update = match j.character { - CharacterState::Idle => states::idle::Data::behavior(&states::idle::Data, &j), - CharacterState::Climb => states::climb::Data::behavior(&states::climb::Data, &j), - CharacterState::Glide => states::glide::Data::behavior(&states::glide::Data, &j), + CharacterState::Idle => states::idle::Data.behavior(&j), + CharacterState::Climb => states::climb::Data.behavior(&j), + CharacterState::Glide => states::glide::Data.behavior(&j), CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, &j), - CharacterState::BasicBlock => states::basic_block::Data::behavior(&states::basic_block::Data, &j), - CharacterState::Roll (data) => data.behavior(&j), - CharacterState::Wielding (data) => data.behavior(&j), - CharacterState::Equipping (data) => data.behavior(&j), - CharacterState::ChargeAttack (data) => data.behavior(&j), - CharacterState::TripleStrike (data) => data.behavior(&j), - CharacterState::BasicAttack (data) => data.behavior(&j), + CharacterState::BasicBlock => states::basic_block::Data.behavior(&j), + CharacterState::Roll(data) => data.behavior(&j), + CharacterState::Wielding => states::wielding::Data.behavior(&j), + CharacterState::Equipping(data) => data.behavior(&j), + CharacterState::ChargeAttack(data) => data.behavior(&j), + CharacterState::TripleStrike(data) => data.behavior(&j), + CharacterState::BasicAttack(data) => data.behavior(&j), CharacterState::TimedCombo(data) => data.behavior(&j), // Do not use default match. diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index f646795e9a..9bba2ee86c 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -215,7 +215,9 @@ impl<'a> System<'a> for Sys { loadout = comp::Loadout { active_item: Some(comp::ItemConfig { item: assets::load_expect_cloned("common.items.weapons.hammer_1"), - primary_ability: None, + primary_ability: None, /* TODO: when implementing this, make sure + * to adjust the base damage (see todo + * below) */ secondary_ability: None, block_ability: None, dodge_ability: None, @@ -228,14 +230,20 @@ impl<'a> System<'a> for Sys { } stats.update_max_hp(); + stats .health .set_to(stats.health.maximum(), comp::HealthSource::Revive); + + // TODO: This code sets an appropriate base_damage for the enemy. This doesn't + // work because the damage is now saved in an ability + /* if let Some(item::ItemKind::Tool(item::ToolData { base_damage, .. })) = &mut loadout.active_item.map(|i| i.item.kind) { *base_damage = stats.level.level() as u32 * 3; } + */ server_emitter.emit(ServerEvent::CreateNpc { pos: Pos(entity.pos), stats, From 6d0ec984c89cadf489a1a729b15c810c7f891cfb Mon Sep 17 00:00:00 2001 From: Imbris Date: Fri, 28 Feb 2020 00:25:16 -0500 Subject: [PATCH 081/326] maybe fix hotreload panic --- .gitignore | 5 ----- assets/voxygen/voxel/biped_large_center_manifest.ron | 2 +- assets/voxygen/voxel/biped_large_lateral_manifest.ron | 2 +- assets/voxygen/voxel/bird_medium_center_manifest.ron | 3 ++- assets/voxygen/voxel/bird_medium_lateral_manifest.ron | 2 +- assets/voxygen/voxel/critter_center_manifest.ron | 2 +- assets/voxygen/voxel/humanoid_armor_belt_manifest.ron | 2 +- assets/voxygen/voxel/humanoid_armor_chest_manifest.ron | 2 +- assets/voxygen/voxel/humanoid_armor_foot_manifest.ron | 2 +- assets/voxygen/voxel/humanoid_armor_hand_manifest.ron | 2 +- assets/voxygen/voxel/humanoid_armor_pants_manifest.ron | 2 +- assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron | 2 +- assets/voxygen/voxel/humanoid_head_manifest.ron | 2 +- assets/voxygen/voxel/quadruped_medium_central_manifest.ron | 2 +- assets/voxygen/voxel/quadruped_medium_lateral_manifest.ron | 2 +- assets/voxygen/voxel/quadruped_small_central_manifest.ron | 2 +- assets/voxygen/voxel/quadruped_small_lateral_manifest.ron | 2 +- 17 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 97d8de2fc1..f380e795cb 100644 --- a/.gitignore +++ b/.gitignore @@ -23,11 +23,6 @@ .project -# Vim - -**/*.swp -**/*.vi - # Veloren *.rar *.log diff --git a/assets/voxygen/voxel/biped_large_center_manifest.ron b/assets/voxygen/voxel/biped_large_center_manifest.ron index 9e8a1b70c6..880524ae39 100644 --- a/assets/voxygen/voxel/biped_large_center_manifest.ron +++ b/assets/voxygen/voxel/biped_large_center_manifest.ron @@ -27,4 +27,4 @@ center: ("npc.giant.female.torso_lower"), ) ), -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/biped_large_lateral_manifest.ron b/assets/voxygen/voxel/biped_large_lateral_manifest.ron index 0f05677a48..764872c8ef 100644 --- a/assets/voxygen/voxel/biped_large_lateral_manifest.ron +++ b/assets/voxygen/voxel/biped_large_lateral_manifest.ron @@ -67,4 +67,4 @@ lateral: ("npc.giant.female.foot_r"), ) ), -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/bird_medium_center_manifest.ron b/assets/voxygen/voxel/bird_medium_center_manifest.ron index 6951c0e7af..2d7b1ceebd 100644 --- a/assets/voxygen/voxel/bird_medium_center_manifest.ron +++ b/assets/voxygen/voxel/bird_medium_center_manifest.ron @@ -139,4 +139,5 @@ center: ("npc.eagle.female.tail"), ) ), -}) \ No newline at end of file +}) + diff --git a/assets/voxygen/voxel/bird_medium_lateral_manifest.ron b/assets/voxygen/voxel/bird_medium_lateral_manifest.ron index a934c5695e..26f5bdb9de 100644 --- a/assets/voxygen/voxel/bird_medium_lateral_manifest.ron +++ b/assets/voxygen/voxel/bird_medium_lateral_manifest.ron @@ -179,4 +179,4 @@ lateral: ("npc.eagle.female.leg_r"), ) ), -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/critter_center_manifest.ron b/assets/voxygen/voxel/critter_center_manifest.ron index 5f78275ad3..6c2ee8a5b7 100644 --- a/assets/voxygen/voxel/critter_center_manifest.ron +++ b/assets/voxygen/voxel/critter_center_manifest.ron @@ -263,4 +263,4 @@ center: ("npc.fungome.female.tail"), ), ), -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index 393fd07bad..b43bf5b3e1 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -7,4 +7,4 @@ vox_spec: ("armor.belt.cloth_turq", (-4.0, -3.5, -6.0)), color: None ) -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index 651e5364c3..7a064a4f7f 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -27,4 +27,4 @@ vox_spec: ("armor.chest.cloth_red_kimono", (-7.0, -3.5, 2.0)), color: None ) -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron index 77ccd35b65..c768042040 100644 --- a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron @@ -16,4 +16,4 @@ vox_spec: ("armor.foot.dark_jester-elf_shoe", (-2.5, -3.0, -9.0)), color: None ) -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron index 897d6a8a66..1ae362d168 100644 --- a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron @@ -19,4 +19,4 @@ color: None ) ) -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron index 3e7810448f..bb194d054a 100644 --- a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron @@ -23,4 +23,4 @@ vox_spec: ("armor.pants.cloth_red_kimono", (-5.0, -3.5, 1.0)), color: None ) -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index 7d4722990e..bbe758f142 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -30,4 +30,4 @@ color: None ) ) -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/humanoid_head_manifest.ron b/assets/voxygen/voxel/humanoid_head_manifest.ron index 9e67fcb95b..ea061ff7f2 100644 --- a/assets/voxygen/voxel/humanoid_head_manifest.ron +++ b/assets/voxygen/voxel/humanoid_head_manifest.ron @@ -266,4 +266,4 @@ Some(("figure.accessory.danari.horns-0", (4, 9, 8))),] ), // More here -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/quadruped_medium_central_manifest.ron b/assets/voxygen/voxel/quadruped_medium_central_manifest.ron index 8e3d3b12d6..b1d556b3d8 100644 --- a/assets/voxygen/voxel/quadruped_medium_central_manifest.ron +++ b/assets/voxygen/voxel/quadruped_medium_central_manifest.ron @@ -480,4 +480,4 @@ central: ("npc.tarasque.male.tail"), ), ), -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/quadruped_medium_lateral_manifest.ron b/assets/voxygen/voxel/quadruped_medium_lateral_manifest.ron index 8e7b0b65c6..69c104c2fa 100644 --- a/assets/voxygen/voxel/quadruped_medium_lateral_manifest.ron +++ b/assets/voxygen/voxel/quadruped_medium_lateral_manifest.ron @@ -287,4 +287,4 @@ lateral: ("npc.tarasque.female.foot_rb"), ), ), -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/quadruped_small_central_manifest.ron b/assets/voxygen/voxel/quadruped_small_central_manifest.ron index b2805684ba..5a48727736 100644 --- a/assets/voxygen/voxel/quadruped_small_central_manifest.ron +++ b/assets/voxygen/voxel/quadruped_small_central_manifest.ron @@ -251,4 +251,4 @@ central: ("npc.holladon.female.chest"), ), ), -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/quadruped_small_lateral_manifest.ron b/assets/voxygen/voxel/quadruped_small_lateral_manifest.ron index 5b102d6b11..17657d7b07 100644 --- a/assets/voxygen/voxel/quadruped_small_lateral_manifest.ron +++ b/assets/voxygen/voxel/quadruped_small_lateral_manifest.ron @@ -447,4 +447,4 @@ lateral: ("npc.holladon.female.foot_br"), ), ), -}) \ No newline at end of file +}) From 0e7f3a6b00c58dd1f0a33e419187ce7868da1968 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 7 Feb 2020 20:35:45 +0100 Subject: [PATCH 082/326] Update vol.rs --- voxygen/src/mesh/vol.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voxygen/src/mesh/vol.rs b/voxygen/src/mesh/vol.rs index 6c219898e9..c99ebe64d7 100644 --- a/voxygen/src/mesh/vol.rs +++ b/voxygen/src/mesh/vol.rs @@ -85,7 +85,7 @@ fn get_col_quad(dirs: &[Vec3], cols: &[[[Rgba; 3]; 3]; 3]) -> Vec4 0 { let col = Rgb::new(col.r, col.g, col.b).map(|e| e as f32); if Vec3::::from(primary_col).distance_squared(Vec3::from(col)) - < (0.25f32 * 256.0).powf(2.0) + < (0.00000001f32 * 256.0).powf(2.0) { color += col; total += 256.0; From 1b170f70c32e36bd354e4e8b08c08d9f3d6f7e4e Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 7 Feb 2020 20:53:38 +0100 Subject: [PATCH 083/326] Even less blending. --- voxygen/src/mesh/terrain.rs | 3 +-- voxygen/src/mesh/vol.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/voxygen/src/mesh/terrain.rs b/voxygen/src/mesh/terrain.rs index 50a76f1b55..362fb81408 100644 --- a/voxygen/src/mesh/terrain.rs +++ b/voxygen/src/mesh/terrain.rs @@ -20,8 +20,7 @@ trait Blendable { impl Blendable for BlockKind { fn is_blended(&self) -> bool { match self { - BlockKind::Leaves => false, - _ => true, + _ => false, } } } diff --git a/voxygen/src/mesh/vol.rs b/voxygen/src/mesh/vol.rs index c99ebe64d7..76979bf2e8 100644 --- a/voxygen/src/mesh/vol.rs +++ b/voxygen/src/mesh/vol.rs @@ -85,7 +85,7 @@ fn get_col_quad(dirs: &[Vec3], cols: &[[[Rgba; 3]; 3]; 3]) -> Vec4 0 { let col = Rgb::new(col.r, col.g, col.b).map(|e| e as f32); if Vec3::::from(primary_col).distance_squared(Vec3::from(col)) - < (0.00000001f32 * 256.0).powf(2.0) + < (0.025f32 * 256.0).powf(2.0) { color += col; total += 256.0; From 5a962771d9127caaa62abd989c90b7e8b127c8ba Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sat, 8 Feb 2020 20:24:24 +0100 Subject: [PATCH 084/326] assassin armour --- assets/voxygen/voxel/armor/belt/assa.vox | 3 ++ .../voxygen/voxel/armor/belt/cloth_black.vox | 3 ++ .../voxygen/voxel/armor/belt/cloth_blood.vox | 3 ++ .../voxygen/voxel/armor/belt/cloth_grey.vox | 3 ++ assets/voxygen/voxel/armor/chest/assa.vox | 3 ++ assets/voxygen/voxel/armor/foot/assa.vox | 3 ++ assets/voxygen/voxel/armor/pants/assa.vox | 3 ++ .../voxel/armor/shoulder/assa_left.vox | 3 ++ .../voxel/humanoid_armor_belt_manifest.ron | 16 +++++++- .../voxel/humanoid_armor_chest_manifest.ron | 4 ++ .../voxel/humanoid_armor_foot_manifest.ron | 4 ++ .../voxel/humanoid_armor_hand_manifest.ron | 10 +++++ .../voxel/humanoid_armor_pants_manifest.ron | 8 +++- .../humanoid_armor_shoulder_manifest.ron | 10 +++++ common/src/comp/body/humanoid.rs | 41 +++++++++++++++---- 15 files changed, 106 insertions(+), 11 deletions(-) create mode 100644 assets/voxygen/voxel/armor/belt/assa.vox create mode 100644 assets/voxygen/voxel/armor/belt/cloth_black.vox create mode 100644 assets/voxygen/voxel/armor/belt/cloth_blood.vox create mode 100644 assets/voxygen/voxel/armor/belt/cloth_grey.vox create mode 100644 assets/voxygen/voxel/armor/chest/assa.vox create mode 100644 assets/voxygen/voxel/armor/foot/assa.vox create mode 100644 assets/voxygen/voxel/armor/pants/assa.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/assa_left.vox diff --git a/assets/voxygen/voxel/armor/belt/assa.vox b/assets/voxygen/voxel/armor/belt/assa.vox new file mode 100644 index 0000000000..dffd8e6ffe --- /dev/null +++ b/assets/voxygen/voxel/armor/belt/assa.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6149f83d15faf914cd8286ba61e37cc14eeeb4a3ae3fd02e917afcdeca6f757d +size 1472 diff --git a/assets/voxygen/voxel/armor/belt/cloth_black.vox b/assets/voxygen/voxel/armor/belt/cloth_black.vox new file mode 100644 index 0000000000..025abd9ab0 --- /dev/null +++ b/assets/voxygen/voxel/armor/belt/cloth_black.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8900d6dc56512d531de0a31330d6f8e98a7982300e859a759c6d50221d48d58 +size 56019 diff --git a/assets/voxygen/voxel/armor/belt/cloth_blood.vox b/assets/voxygen/voxel/armor/belt/cloth_blood.vox new file mode 100644 index 0000000000..aada11a8f7 --- /dev/null +++ b/assets/voxygen/voxel/armor/belt/cloth_blood.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:55cab5d4e7af59ee51a9b84a9b1f463ec67e4b7dcf826190bd7841d5ec4a6498 +size 56019 diff --git a/assets/voxygen/voxel/armor/belt/cloth_grey.vox b/assets/voxygen/voxel/armor/belt/cloth_grey.vox new file mode 100644 index 0000000000..74eaecfe80 --- /dev/null +++ b/assets/voxygen/voxel/armor/belt/cloth_grey.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c789fb9004477fe3e1c18821d276e5461d0959375908d59c4ce043dc642cb64b +size 56019 diff --git a/assets/voxygen/voxel/armor/chest/assa.vox b/assets/voxygen/voxel/armor/chest/assa.vox new file mode 100644 index 0000000000..607897445b --- /dev/null +++ b/assets/voxygen/voxel/armor/chest/assa.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a71f201e177b9a04a40c6531ab9c5d823f786ef60eb762dce91b9e6bf9d00eb +size 2712 diff --git a/assets/voxygen/voxel/armor/foot/assa.vox b/assets/voxygen/voxel/armor/foot/assa.vox new file mode 100644 index 0000000000..881ec1a5de --- /dev/null +++ b/assets/voxygen/voxel/armor/foot/assa.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49178c027d6e9f20978786138fd76e0413057600d7094705686c1b2ea0a89e6d +size 1480 diff --git a/assets/voxygen/voxel/armor/pants/assa.vox b/assets/voxygen/voxel/armor/pants/assa.vox new file mode 100644 index 0000000000..c487e62091 --- /dev/null +++ b/assets/voxygen/voxel/armor/pants/assa.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5df651f1df9d57ebd10eaafe9c3bac8b882b2c77f9cec0c57323b5b220f8ef4e +size 1912 diff --git a/assets/voxygen/voxel/armor/shoulder/assa_left.vox b/assets/voxygen/voxel/armor/shoulder/assa_left.vox new file mode 100644 index 0000000000..3baf171a4c --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/assa_left.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c344696d618d8bd240abf353f69223bf83fed176000e357aa0e2f7c3de9079de +size 56011 diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index b43bf5b3e1..6e14eb515a 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -3,8 +3,20 @@ vox_spec: ("armor.belt.dark", (-4.0, -3.5, 2.0)), color: None ), - Cloth:( + TurqCloth:( vox_spec: ("armor.belt.cloth_turq", (-4.0, -3.5, -6.0)), color: None + ), + BloodCloth:( + vox_spec: ("armor.belt.cloth_blood", (-4.0, -3.5, -6.0)), + color: Some((29, 26, 33)) + ), + BlackCloth:( + vox_spec: ("armor.belt.cloth_black", (-4.0, -3.5, -6.0)), + color: Some((29, 26, 33)) + ), + Assassin:( + vox_spec: ("armor.belt.assa", (-5.0, -3.5, 2.0)), + color: None ) -}) +}) \ No newline at end of file diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index 7a064a4f7f..d17a52d081 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -23,6 +23,10 @@ vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), color: Some((29, 26, 33)) ), + Assassin: ( + vox_spec: ("armor.chest.assa", (-7.0, -3.5, 2.0)), + color: None + ), Kimono: ( vox_spec: ("armor.chest.cloth_red_kimono", (-7.0, -3.5, 2.0)), color: None diff --git a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron index c768042040..d95587b47d 100644 --- a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron @@ -8,6 +8,10 @@ vox_spec: ("armor.foot.dark-0", (-2.5, -3.5, -9.0)), color: None ), + Assassin: ( + vox_spec: ("armor.foot.assa", (-2.5, -3.5, -9.0)), + color: None + ), Sandal: ( vox_spec: ("armor.foot.cloth_sandals", (-2.5, -2.5, -9.0)), color: None diff --git a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron index 1ae362d168..b5b90c6cc4 100644 --- a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron @@ -9,6 +9,16 @@ color: None ) ), + Assassin: ( + left: ( + vox_spec: ("armor.hand.assa_left", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.assa_right", (-1.5, -1.5, -7.0)), + color: None + ) + ), Cloth: ( left: ( vox_spec: ("armor.hand.cloth_basic_left", (-1.5, -1.5, -7.0)), diff --git a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron index bb194d054a..bf1c7e6303 100644 --- a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron @@ -19,8 +19,12 @@ vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), color: Some((148, 52, 33)) ), + Assassin: ( + vox_spec: ("armor.pants.assa", (-5.0, -3.5, 1.0)), + color: None + ), Kimono: ( - vox_spec: ("armor.pants.cloth_red_kimono", (-5.0, -3.5, 1.0)), + vox_spec: ("armor.pants.cloth_red_kimono", (-5.0, -3.5, 0.0)), color: None ) -}) +}) \ No newline at end of file diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index bbe758f142..f259f51850 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -20,6 +20,16 @@ color: None ) ), + Assassin: ( + left: ( + vox_spec: ("armor.shoulder.assa_left", (-4.5, -3.0, 0.1)), + color: None + ), + right: ( + vox_spec: ("armor.empty", (-2.0, -3.5, 0.1)), + color: None + ) + ), Chain: ( left: ( vox_spec: ("armor.shoulder.chain_left-1", (-4.0, -3.5, 0.1)), diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index 557956e790..157812a9d9 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -487,8 +487,9 @@ pub enum Chest { Orange = 4, Midnight = 5, Kimono = 6, + Assassin = 7, } -pub const ALL_CHESTS: [Chest; 7] = [ +pub const ALL_CHESTS: [Chest; 8] = [ Chest::Blue, Chest::Brown, Chest::Dark, @@ -496,15 +497,25 @@ pub const ALL_CHESTS: [Chest; 7] = [ Chest::Orange, Chest::Midnight, Chest::Kimono, + Chest::Assassin, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Belt { Dark = 0, - Cloth = 1, + TurqCloth = 1, + BloodCloth = 2, + BlackCloth = 3, + Assassin = 4, } -pub const ALL_BELTS: [Belt; 2] = [Belt::Dark, Belt::Cloth]; +pub const ALL_BELTS: [Belt; 5] = [ + Belt::Dark, + Belt::TurqCloth, + Belt::BloodCloth, + Belt::BlackCloth, + Belt::Assassin, +]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] @@ -515,14 +526,16 @@ pub enum Pants { Green = 3, Orange = 4, Kimono = 5, + Assassin = 6, } -pub const ALL_PANTS: [Pants; 6] = [ +pub const ALL_PANTS: [Pants; 7] = [ Pants::Blue, Pants::Brown, Pants::Dark, Pants::Green, Pants::Orange, Pants::Kimono, + Pants::Assassin, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -530,8 +543,9 @@ pub const ALL_PANTS: [Pants; 6] = [ pub enum Hand { Bare = 0, Cloth = 1, + Assassin = 2, } -pub const ALL_HANDS: [Hand; 2] = [Hand::Bare, Hand::Cloth]; +pub const ALL_HANDS: [Hand; 3] = [Hand::Bare, Hand::Cloth, Hand::Assassin]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] @@ -540,8 +554,15 @@ pub enum Foot { Dark = 1, Sandal = 2, Jester = 3, + Assassin = 4, } -pub const ALL_FEET: [Foot; 4] = [Foot::Bare, Foot::Dark, Foot::Sandal, Foot::Jester]; +pub const ALL_FEET: [Foot; 5] = [ + Foot::Bare, + Foot::Dark, + Foot::Sandal, + Foot::Jester, + Foot::Assassin, +]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] @@ -549,8 +570,14 @@ pub enum Shoulder { None = 0, Brown1 = 1, Chain = 2, + Assassin = 3, } -pub const ALL_SHOULDERS: [Shoulder; 3] = [Shoulder::None, Shoulder::Brown1, Shoulder::Chain]; +pub const ALL_SHOULDERS: [Shoulder; 4] = [ + Shoulder::None, + Shoulder::Brown1, + Shoulder::Chain, + Shoulder::Assassin, +]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] From e80750bc531aa3d8ccd950d5d7f45044b4b9a74d Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 20 Feb 2020 15:30:47 +0100 Subject: [PATCH 085/326] plate chest armour --- assets/voxygen/voxel/armor/chest/assa.vox | 4 ++-- assets/voxygen/voxel/armor/chest/plate.vox | 3 +++ assets/voxygen/voxel/humanoid_armor_chest_manifest.ron | 6 +++++- common/src/comp/body/humanoid.rs | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 assets/voxygen/voxel/armor/chest/plate.vox diff --git a/assets/voxygen/voxel/armor/chest/assa.vox b/assets/voxygen/voxel/armor/chest/assa.vox index 607897445b..2535692379 100644 --- a/assets/voxygen/voxel/armor/chest/assa.vox +++ b/assets/voxygen/voxel/armor/chest/assa.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8a71f201e177b9a04a40c6531ab9c5d823f786ef60eb762dce91b9e6bf9d00eb -size 2712 +oid sha256:9e4a9785082e5cb46e1a0d1bb34961ea7a80e168d5d10bced4fb1ab31150a378 +size 57195 diff --git a/assets/voxygen/voxel/armor/chest/plate.vox b/assets/voxygen/voxel/armor/chest/plate.vox new file mode 100644 index 0000000000..d11968f267 --- /dev/null +++ b/assets/voxygen/voxel/armor/chest/plate.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:814763c1e4ad138f5de5ebb628dce3dc8f6f010c050052e993142754a8806668 +size 57227 diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index d17a52d081..1291114194 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -30,5 +30,9 @@ Kimono: ( vox_spec: ("armor.chest.cloth_red_kimono", (-7.0, -3.5, 2.0)), color: None + ), + Plate: ( + vox_spec: ("armor.chest.plate", (-7.0, -3.5, 2.0)), + color: None ) -}) +}) \ No newline at end of file diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index 157812a9d9..c1e526a8d7 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -488,8 +488,9 @@ pub enum Chest { Midnight = 5, Kimono = 6, Assassin = 7, + Plate = 8, } -pub const ALL_CHESTS: [Chest; 8] = [ +pub const ALL_CHESTS: [Chest; 9] = [ Chest::Blue, Chest::Brown, Chest::Dark, @@ -498,6 +499,7 @@ pub const ALL_CHESTS: [Chest; 8] = [ Chest::Midnight, Chest::Kimono, Chest::Assassin, + Chest::Plate, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] From e20feeeb0ce9868eab34ba286e77490a9023807c Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 26 Feb 2020 17:04:43 +0000 Subject: [PATCH 086/326] Added armour items and equipping of armour --- assets/common/items/armor/chest_plate.ron | 8 ++ assets/common/items/armor/pants_assassin.ron | 8 ++ assets/common/items/armor/pants_green.ron | 8 ++ common/src/comp/ability.rs | 8 +- common/src/comp/inventory/item.rs | 29 +++--- common/src/event.rs | 1 + common/src/states/equipping.rs | 6 +- common/src/states/utils.rs | 7 +- server/src/cmd.rs | 1 + server/src/events/entity_creation.rs | 7 +- server/src/events/inventory_manip.rs | 92 ++++++++++++++++++-- server/src/events/mod.rs | 3 +- server/src/state_ext.rs | 12 ++- server/src/sys/terrain.rs | 13 +++ voxygen/src/menu/char_selection/mod.rs | 13 +-- voxygen/src/scene/figure/cache.rs | 4 +- voxygen/src/scene/figure/load.rs | 2 +- voxygen/src/scene/figure/mod.rs | 4 +- voxygen/src/scene/simple.rs | 2 +- 19 files changed, 176 insertions(+), 52 deletions(-) create mode 100644 assets/common/items/armor/chest_plate.ron create mode 100644 assets/common/items/armor/pants_assassin.ron create mode 100644 assets/common/items/armor/pants_green.ron diff --git a/assets/common/items/armor/chest_plate.ron b/assets/common/items/armor/chest_plate.ron new file mode 100644 index 0000000000..5916cd5547 --- /dev/null +++ b/assets/common/items/armor/chest_plate.ron @@ -0,0 +1,8 @@ +Item( + name: "Iron Chestplate", + description: "Arrows to the stomach are soooo last update.", + kind: Armor( + kind: Chest(Plate), + stats: 20, + ), +) diff --git a/assets/common/items/armor/pants_assassin.ron b/assets/common/items/armor/pants_assassin.ron new file mode 100644 index 0000000000..0d71d8548f --- /dev/null +++ b/assets/common/items/armor/pants_assassin.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Pants", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Pants(Assassin), + stats: 20, + ), +) diff --git a/assets/common/items/armor/pants_green.ron b/assets/common/items/armor/pants_green.ron new file mode 100644 index 0000000000..5963443666 --- /dev/null +++ b/assets/common/items/armor/pants_green.ron @@ -0,0 +1,8 @@ +Item( + name: "Green Camo Pants", + description: "Perfect for hunting.", + kind: Armor( + kind: Pants(Green), + stats: 20, + ), +) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index b8d3abee5f..892997b21e 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -39,7 +39,13 @@ pub struct ItemConfig { pub struct Loadout { pub active_item: Option, pub second_item: Option, - // armor + + pub shoulder: Option, + pub chest: Option, + pub belt: Option, + pub hand: Option, + pub pants: Option, + pub foot: Option, } impl From for CharacterState { diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index e420f100b5..07e3e05dda 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -1,6 +1,6 @@ use crate::{ assets::{self, Asset}, - comp::CharacterAbility, + comp::{body::humanoid, CharacterAbility}, effect::Effect, terrain::{Block, BlockKind}, }; @@ -80,22 +80,17 @@ pub enum DebugKind { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Armor { - // TODO: Don't make armor be a body part. Wearing enemy's head is funny but also a creepy - // thing to do. - Helmet, - Shoulders, - Chestplate, - Belt, - Gloves, - Pants, - Boots, - Back, - Tabard, - Gem, - Necklace, + Shoulder(humanoid::Shoulder), + Chest(humanoid::Chest), + Belt(humanoid::Belt), + Hand(humanoid::Hand), + Pants(humanoid::Pants), + Foot(humanoid::Foot), } -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub type ArmorStats = u32; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Consumable { Apple, Cheese, @@ -124,13 +119,13 @@ pub struct ToolData { // TODO: item specific abilities } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ItemKind { /// Something wieldable Tool(ToolData), Armor { kind: Armor, - power: u32, + stats: ArmorStats, }, Consumable { kind: Consumable, diff --git a/common/src/event.rs b/common/src/event.rs index 14082fb9e2..754d23aa23 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -100,6 +100,7 @@ pub enum ServerEvent { CreateNpc { pos: comp::Pos, stats: comp::Stats, + loadout: comp::Loadout, body: comp::Body, agent: comp::Agent, alignment: comp::Alignment, diff --git a/common/src/states/equipping.rs b/common/src/states/equipping.rs index cc4b8cba09..9fac0bbd83 100644 --- a/common/src/states/equipping.rs +++ b/common/src/states/equipping.rs @@ -1,15 +1,12 @@ use super::utils::*; use crate::{ - comp::{CharacterState, StateUpdate, ToolData}, - states::wielding, + comp::{CharacterState, StateUpdate}, sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::{collections::VecDeque, time::Duration}; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Data { - /// The weapon being equipped - pub tool: ToolData, /// Time left before next state pub time_left: Duration, } @@ -40,7 +37,6 @@ impl CharacterBehavior for Data { .time_left .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), - tool: self.tool, }); } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 169611a8cc..9312256ea4 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -119,9 +119,8 @@ pub fn handle_wield(data: &JoinData, update: &mut StateUpdate) { /// If a tool is equipped, goes into Equipping state, otherwise goes to Idle pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { - if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| i.item.kind) { + if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) { update.character = CharacterState::Equipping(equipping::Data { - tool, time_left: tool.equip_time(), }); } else { @@ -253,8 +252,8 @@ pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { } } -pub fn unwrap_tool_data(data: &JoinData) -> Option { - if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| i.item.kind) { +pub fn unwrap_tool_data<'a>(data: &'a JoinData) -> Option<&'a ToolData> { + if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(tool) } else { None diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 44b68e42be..86fc5dc649 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -505,6 +505,7 @@ fn handle_spawn(server: &mut Server, entity: EcsEntity, args: String, action: &C .create_npc( pos, comp::Stats::new(get_npc_name(id).into(), body), + comp::Loadout::default(), body, ) .with(comp::Vel(vel)) diff --git a/server/src/events/entity_creation.rs b/server/src/events/entity_creation.rs index 642795c0cd..68ad0e345c 100644 --- a/server/src/events/entity_creation.rs +++ b/server/src/events/entity_creation.rs @@ -1,7 +1,7 @@ use crate::{sys, Server, StateExt}; use common::comp::{ - self, Agent, Alignment, Body, Gravity, LightEmitter, Pos, Projectile, Scale, Stats, Vel, - WaypointArea, + self, Agent, Alignment, Body, Gravity, LightEmitter, Loadout, Pos, Projectile, Scale, Stats, + Vel, WaypointArea, }; use specs::{Builder, Entity as EcsEntity, WorldExt}; use vek::{Rgb, Vec3}; @@ -24,6 +24,7 @@ pub fn handle_create_npc( server: &mut Server, pos: Pos, stats: Stats, + loadout: Loadout, body: Body, agent: Agent, alignment: Alignment, @@ -31,7 +32,7 @@ pub fn handle_create_npc( ) { server .state - .create_npc(pos, stats, body) + .create_npc(pos, stats, loadout, body) .with(agent) .with(scale) .with(alignment) diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index 25c9f277d4..153109a3cc 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -83,21 +83,97 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv } }, - comp::InventoryManip::Use(slot) => { + comp::InventoryManip::Use(slot_idx) => { let item_opt = state .ecs() .write_storage::() .get_mut(entity) - .and_then(|inv| inv.remove(slot)); + .and_then(|inv| inv.remove(slot_idx)); let mut event = comp::InventoryUpdateEvent::Used; if let Some(item) = item_opt { - match item.kind { - comp::ItemKind::Consumable { kind, effect } => { - event = comp::InventoryUpdateEvent::Consumed(kind); - state.apply_effect(entity, effect); + match &item.kind { + comp::ItemKind::Tool(tool) => { + if let Some(loadout) = + state.ecs().write_storage::().get_mut(entity) + { + // Insert old item into inventory + if let Some(old_item) = loadout.active_item.take() { + state + .ecs() + .write_storage::() + .get_mut(entity) + .map(|inv| inv.insert(slot_idx, old_item.item)); + } + + let mut abilities = tool.get_abilities(); + let mut ability_drain = abilities.drain(..); + let active_item = comp::ItemConfig { + item, + primary_ability: ability_drain.next(), + secondary_ability: ability_drain.next(), + block_ability: Some(comp::CharacterAbility::BasicBlock), + dodge_ability: Some(comp::CharacterAbility::Roll), + }; + loadout.active_item = Some(active_item); + } }, + + comp::ItemKind::Consumable { kind, effect } => { + event = comp::InventoryUpdateEvent::Consumed(*kind); + state.apply_effect(entity, *effect); + }, + + comp::ItemKind::Armor { kind, .. } => { + if let Some(loadout) = + state.ecs().write_storage::().get_mut(entity) + { + if let Some(comp::Body::Humanoid(body)) = + state.ecs().write_storage::().get_mut(entity) + { + use comp::item::Armor::*; + let slot = match kind.clone() { + Shoulder(shoulder) => { + body.shoulder = shoulder; + &mut loadout.shoulder + }, + Chest(chest) => { + body.chest = chest; + &mut loadout.chest + }, + Belt(belt) => { + body.belt = belt; + &mut loadout.belt + }, + Hand(hand) => { + body.hand = hand; + &mut loadout.hand + }, + Pants(pants) => { + body.pants = pants; + &mut loadout.pants + }, + Foot(foot) => { + body.foot = foot; + &mut loadout.foot + }, + }; + + // Insert old item into inventory + if let Some(old_item) = slot.take() { + state + .ecs() + .write_storage::() + .get_mut(entity) + .map(|inv| inv.insert(slot_idx, old_item)); + } + + *slot = Some(item); + } + } + }, + comp::ItemKind::Utility { kind } => match kind { comp::item::Utility::Collar => { let reinsert = if let Some(pos) = @@ -155,7 +231,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv .ecs() .write_storage::() .get_mut(entity) - .map(|inv| inv.insert(slot, item)); + .map(|inv| inv.insert(slot_idx, item)); } }, }, @@ -164,7 +240,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv .ecs() .write_storage::() .get_mut(entity) - .map(|inv| inv.insert(slot, item)); + .map(|inv| inv.insert(slot_idx, item)); }, } } diff --git a/server/src/events/mod.rs b/server/src/events/mod.rs index dd9f3b332c..d1a833cd79 100644 --- a/server/src/events/mod.rs +++ b/server/src/events/mod.rs @@ -76,11 +76,12 @@ impl Server { ServerEvent::CreateNpc { pos, stats, + loadout, body, agent, alignment, scale, - } => handle_create_npc(self, pos, stats, body, agent, alignment, scale), + } => handle_create_npc(self, pos, stats, loadout, body, agent, alignment, scale), ServerEvent::CreateWaypoint(pos) => handle_create_waypoint(self, pos), ServerEvent::ClientDisconnect(entity) => { frontend_events.push(handle_client_disconnect(self, entity)) diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index 61f64f1cb3..639c1c7e1d 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -17,6 +17,7 @@ pub trait StateExt { &mut self, pos: comp::Pos, stats: comp::Stats, + loadout: comp::Loadout, body: comp::Body, ) -> EcsEntityBuilder; fn create_object(&mut self, pos: comp::Pos, object: comp::object::Body) -> EcsEntityBuilder; @@ -81,6 +82,7 @@ impl StateExt for State { &mut self, pos: comp::Pos, stats: comp::Stats, + loadout: comp::Loadout, body: comp::Body, ) -> EcsEntityBuilder { self.ecs_mut() @@ -95,7 +97,7 @@ impl StateExt for State { .with(comp::Energy::new(500)) .with(comp::Gravity(1.0)) .with(comp::CharacterState::default()) - .with(comp::Loadout::default()) // TODO Give the poor npc something to do + .with(loadout) } /// Build a static object entity @@ -161,7 +163,7 @@ impl StateExt for State { self.write_component( entity, - if let Some(comp::ItemKind::Tool(tool)) = main.as_ref().map(|i| i.kind) { + if let Some(comp::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) { let mut abilities = tool.get_abilities(); let mut ability_drain = abilities.drain(..); comp::Loadout { @@ -173,6 +175,12 @@ impl StateExt for State { dodge_ability: Some(comp::CharacterAbility::Roll), }), second_item: None, + shoulder: None, + chest: None, + belt: None, + hand: None, + pants: None, + foot: None, } } else { comp::Loadout::default() diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index a17cb51747..9a0f4eec07 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -190,6 +190,12 @@ impl<'a> System<'a> for Sys { dodge_ability: None, }), second_item: None, + shoulder: None, + chest: None, + belt: None, + hand: None, + pants: None, + foot: None, }; let mut scale = 1.0; @@ -222,6 +228,12 @@ impl<'a> System<'a> for Sys { dodge_ability: None, }), second_item: None, + shoulder: None, + chest: None, + belt: None, + hand: None, + pants: None, + foot: None, }; stats.level.set_level(rand::thread_rng().gen_range(8, 15)); @@ -246,6 +258,7 @@ impl<'a> System<'a> for Sys { server_emitter.emit(ServerEvent::CreateNpc { pos: Pos(entity.pos), stats, + loadout, body, alignment, agent: comp::Agent::default().with_patrol_origin(entity.pos), diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index 5a35a42f01..4fb8b13041 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -112,15 +112,18 @@ impl PlayState for CharSelectionState { } // Render the scene. + let item = self + .char_selection_ui + .get_character_data() + .and_then(|data| data.tool) + .and_then(|tool| assets::load_cloned::(&tool).ok()); + let item_kind = item.map(|i| i.kind); + self.scene.render( global_state.window.renderer_mut(), self.client.borrow().get_tick(), humanoid_body.clone(), - self.char_selection_ui - .get_character_data() - .and_then(|data| data.tool) - .and_then(|tool| assets::load_cloned::(&tool).ok()) - .map(|i| i.kind), + item_kind.as_ref(), ); // Draw the UI to the screen. diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 8d576bb418..6ad7ae2c09 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -58,7 +58,7 @@ impl FigureModelCache { &mut self, renderer: &mut Renderer, body: Body, - item_kind: Option, + item_kind: Option<&ItemKind>, tick: u64, camera_mode: CameraMode, character_state: Option<&CharacterState>, @@ -70,7 +70,7 @@ impl FigureModelCache { let key = if item_kind.is_some() { FigureKey::Complex( body, - item_kind, + item_kind.cloned(), camera_mode, character_state.map(|cs| CharacterStateCacheKey::from(cs)), ) diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 44821d5ef5..1e66430818 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -534,7 +534,7 @@ impl HumArmorFootSpec { } } -pub fn mesh_main(item_kind: Option) -> Mesh { +pub fn mesh_main(item_kind: Option<&ItemKind>) -> Mesh { if let Some(item_kind) = item_kind { let (name, offset) = match item_kind { ItemKind::Tool(ToolData { kind, .. }) => match kind { diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 9d97b697e9..3e448704b1 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -386,7 +386,7 @@ impl FigureMgr { let active_item_kind = loadout .and_then(|l| l.active_item.as_ref()) - .map(|i| i.item.kind); + .map(|i| &i.item.kind); let active_tool_kind = if let Some(ItemKind::Tool(tool)) = active_item_kind { Some(tool.kind) } else { @@ -1348,7 +1348,7 @@ impl FigureMgr { }; let active_item_kind = loadout .and_then(|l| l.active_item.as_ref()) - .map(|i| i.item.kind); + .map(|i| &i.item.kind); let character_state = if is_player { character_state } else { None }; let FigureMgr { diff --git a/voxygen/src/scene/simple.rs b/voxygen/src/scene/simple.rs index 9547b82fb3..eaea94eedf 100644 --- a/voxygen/src/scene/simple.rs +++ b/voxygen/src/scene/simple.rs @@ -208,7 +208,7 @@ impl Scene { renderer: &mut Renderer, tick: u64, body: Option, - active_item_kind: Option, + active_item_kind: Option<&ItemKind>, ) { renderer.render_skybox(&self.skybox.model, &self.globals, &self.skybox.locals); From aa36082eed40a75c073dc81866632e97b18e63c5 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 27 Feb 2020 21:07:30 +0100 Subject: [PATCH 087/326] more armour --- assets/common/items/armor/chest_assassin.ron | 8 +++++ .../common/items/armor/shoulder_assassin.ron | 8 +++++ assets/voxygen/item_image_manifest.ron | 31 +++++++++++++++++++ assets/voxygen/voxel/armor/chest/plate.vox | 2 +- 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 assets/common/items/armor/chest_assassin.ron create mode 100644 assets/common/items/armor/shoulder_assassin.ron diff --git a/assets/common/items/armor/chest_assassin.ron b/assets/common/items/armor/chest_assassin.ron new file mode 100644 index 0000000000..9df179fb06 --- /dev/null +++ b/assets/common/items/armor/chest_assassin.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Chest", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Chest(Assassin), + stats: 20, + ), +) diff --git a/assets/common/items/armor/shoulder_assassin.ron b/assets/common/items/armor/shoulder_assassin.ron new file mode 100644 index 0000000000..819538cc5e --- /dev/null +++ b/assets/common/items/armor/shoulder_assassin.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Shoulder Guard", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Shoulder(Assassin), + stats: 20, + ), +) diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index 196dd36a54..d7fc51f8be 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -35,6 +35,37 @@ "element.icons.collar", (0.0, 0.0, 0.0), (-90.0, 180.0, 10.0), 1.3, ), + // Armor + // Assassin Set + Armor(Chest(Assassin)): VoxTrans( + "voxel.armor.pants.assa", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Pants(Assassin)): VoxTrans( + "voxel.armor.pants.assa", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Pants(Assassin)): VoxTrans( + "voxel.armor.belt.assa", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Pants(Assassin)): VoxTrans( + "voxel.armor.foot.assa", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Hand(Assassin)): VoxTrans( + "voxel.armor.hand.assa_left", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Shoulder(Assassin)): VoxTrans( + "voxel.armor.pants.assa", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + // Starting Armor - Plate + Armor(Chest(Plate)): VoxTrans( + "voxel.armor.chest.plate", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), // Consumables Consumable(Apple): VoxTrans( "element.icons.item_apple", diff --git a/assets/voxygen/voxel/armor/chest/plate.vox b/assets/voxygen/voxel/armor/chest/plate.vox index d11968f267..79466f4172 100644 --- a/assets/voxygen/voxel/armor/chest/plate.vox +++ b/assets/voxygen/voxel/armor/chest/plate.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:814763c1e4ad138f5de5ebb628dce3dc8f6f010c050052e993142754a8806668 +oid sha256:2d91415da84dba3e5a7c1c321b9728d80f1a9ca05ec8707bf39003b8b13033a1 size 57227 From e7780e5f5b68de7aaf1c379d68f18d4a4476d944 Mon Sep 17 00:00:00 2001 From: Pfauenauge Date: Sat, 29 Feb 2020 21:05:44 +0100 Subject: [PATCH 088/326] Update item_image_manifest.ron --- assets/voxygen/item_image_manifest.ron | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index d7fc51f8be..ce1251fcb6 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -38,18 +38,18 @@ // Armor // Assassin Set Armor(Chest(Assassin)): VoxTrans( - "voxel.armor.pants.assa", + "voxel.armor.chest.assa", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), Armor(Pants(Assassin)): VoxTrans( "voxel.armor.pants.assa", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), - Armor(Pants(Assassin)): VoxTrans( + Armor(Belt(Assassin)): VoxTrans( "voxel.armor.belt.assa", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), - Armor(Pants(Assassin)): VoxTrans( + Armor(Foot(Assassin)): VoxTrans( "voxel.armor.foot.assa", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), @@ -58,7 +58,7 @@ (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), Armor(Shoulder(Assassin)): VoxTrans( - "voxel.armor.pants.assa", + "voxel.armor.shoulder.assa", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), // Starting Armor - Plate From 0c49cd8596c5c57f3b885856dc494d1603806817 Mon Sep 17 00:00:00 2001 From: Pfauenauge Date: Mon, 2 Mar 2020 22:00:25 +0100 Subject: [PATCH 089/326] new assassin shoulder armor --- assets/voxygen/voxel/armor/chest/assa.vox | 4 ++-- assets/voxygen/voxel/armor/shoulder/assa_left.vox | 4 ++-- assets/voxygen/voxel/armor/shoulder/assa_right.vox | 3 +++ assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 assets/voxygen/voxel/armor/shoulder/assa_right.vox diff --git a/assets/voxygen/voxel/armor/chest/assa.vox b/assets/voxygen/voxel/armor/chest/assa.vox index 2535692379..2368550782 100644 --- a/assets/voxygen/voxel/armor/chest/assa.vox +++ b/assets/voxygen/voxel/armor/chest/assa.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9e4a9785082e5cb46e1a0d1bb34961ea7a80e168d5d10bced4fb1ab31150a378 -size 57195 +oid sha256:a2d7513d18f28cf272a585dbeda6669ae5a28ad84b945efbf13d7f4b6c639b9d +size 45819 diff --git a/assets/voxygen/voxel/armor/shoulder/assa_left.vox b/assets/voxygen/voxel/armor/shoulder/assa_left.vox index 3baf171a4c..590c2531a8 100644 --- a/assets/voxygen/voxel/armor/shoulder/assa_left.vox +++ b/assets/voxygen/voxel/armor/shoulder/assa_left.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c344696d618d8bd240abf353f69223bf83fed176000e357aa0e2f7c3de9079de -size 56011 +oid sha256:84b93b691e9179fa6e84be5e6aaaec68217a8fe71a4fa670e5544ffd4b04096c +size 44491 diff --git a/assets/voxygen/voxel/armor/shoulder/assa_right.vox b/assets/voxygen/voxel/armor/shoulder/assa_right.vox new file mode 100644 index 0000000000..7136338ccf --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/assa_right.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:195656b4b047b8c0095c86f00bc0c374c4e3b65fc610d4c74670a19aa07c228b +size 44491 diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index f259f51850..4652b8449f 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -26,7 +26,7 @@ color: None ), right: ( - vox_spec: ("armor.empty", (-2.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.assa_right", (-2.0, -3.5, 0.1)), color: None ) ), From 6cb68fabeaae9b2b26557bf4c9e7f424e3aaf4e7 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Tue, 3 Mar 2020 20:52:10 +0100 Subject: [PATCH 090/326] more assa armour parts --- assets/common/items/armor/belt_assassin.ron | 8 ++++++++ assets/common/items/armor/foot_assassin.ron | 8 ++++++++ assets/common/items/armor/hand_assassin.ron | 8 ++++++++ assets/voxygen/item_image_manifest.ron | 4 +++- assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron | 2 +- 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 assets/common/items/armor/belt_assassin.ron create mode 100644 assets/common/items/armor/foot_assassin.ron create mode 100644 assets/common/items/armor/hand_assassin.ron diff --git a/assets/common/items/armor/belt_assassin.ron b/assets/common/items/armor/belt_assassin.ron new file mode 100644 index 0000000000..c365499f9b --- /dev/null +++ b/assets/common/items/armor/belt_assassin.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Belt", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Belt(Assassin), + stats: 20, + ), +) diff --git a/assets/common/items/armor/foot_assassin.ron b/assets/common/items/armor/foot_assassin.ron new file mode 100644 index 0000000000..58c2d0d824 --- /dev/null +++ b/assets/common/items/armor/foot_assassin.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Boots", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Foot(Assassin), + stats: 20, + ), +) diff --git a/assets/common/items/armor/hand_assassin.ron b/assets/common/items/armor/hand_assassin.ron new file mode 100644 index 0000000000..1f80cc4ebc --- /dev/null +++ b/assets/common/items/armor/hand_assassin.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Gloves", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Hand(Assassin), + stats: 20, + ), +) diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index ce1251fcb6..f13cfe295b 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -58,7 +58,7 @@ (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), Armor(Shoulder(Assassin)): VoxTrans( - "voxel.armor.shoulder.assa", + "voxel.armor.shoulder.assa_left", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), // Starting Armor - Plate @@ -113,3 +113,5 @@ (0.0, -7.0, 0.0), (90.0, 90.0, 0.0), 1.6, ), }) + + diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index 4652b8449f..3e354070c7 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -22,7 +22,7 @@ ), Assassin: ( left: ( - vox_spec: ("armor.shoulder.assa_left", (-4.5, -3.0, 0.1)), + vox_spec: ("armor.shoulder.assa_left", (-4.0, -3.5, 0.1)), color: None ), right: ( From 913393963a690aa388280b715b06b66b23773847 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 5 Mar 2020 16:35:26 +0100 Subject: [PATCH 091/326] plate armour --- assets/common/items/armor/belt_plate-0.ron | 8 ++++++ ...hest_plate.ron => chest_plate_green-0.ron} | 0 assets/common/items/armor/foot_plate-0.ron | 8 ++++++ assets/common/items/armor/hand_plate-0.ron | 8 ++++++ .../items/armor/pants_plate_green-0.ron | 8 ++++++ .../common/items/armor/shoulder_plate-0.ron | 8 ++++++ assets/voxygen/item_image_manifest.ron | 26 ++++++++++++++++--- assets/voxygen/voxel/armor/belt/plate-0.vox | 3 +++ .../chest/{plate.vox => plate_green-0.vox} | 0 assets/voxygen/voxel/armor/foot/plate-0.vox | 3 +++ .../voxygen/voxel/armor/hand/plate_left-0.vox | 3 +++ .../voxel/armor/hand/plate_right-0.vox | 3 +++ assets/voxygen/voxel/armor/pants/plate-0.vox | 3 +++ .../voxel/armor/shoulder/plate_left-0.vox | 3 +++ .../voxel/armor/shoulder/plate_right-0.vox | 3 +++ .../voxel/humanoid_armor_belt_manifest.ron | 10 ++++++- .../voxel/humanoid_armor_chest_manifest.ron | 4 +-- .../voxel/humanoid_armor_foot_manifest.ron | 6 ++++- .../voxel/humanoid_armor_hand_manifest.ron | 12 ++++++++- .../voxel/humanoid_armor_pants_manifest.ron | 10 ++++++- .../humanoid_armor_shoulder_manifest.ron | 12 ++++++++- common/src/comp/body/humanoid.rs | 23 +++++++++++----- 22 files changed, 147 insertions(+), 17 deletions(-) create mode 100644 assets/common/items/armor/belt_plate-0.ron rename assets/common/items/armor/{chest_plate.ron => chest_plate_green-0.ron} (100%) create mode 100644 assets/common/items/armor/foot_plate-0.ron create mode 100644 assets/common/items/armor/hand_plate-0.ron create mode 100644 assets/common/items/armor/pants_plate_green-0.ron create mode 100644 assets/common/items/armor/shoulder_plate-0.ron create mode 100644 assets/voxygen/voxel/armor/belt/plate-0.vox rename assets/voxygen/voxel/armor/chest/{plate.vox => plate_green-0.vox} (100%) create mode 100644 assets/voxygen/voxel/armor/foot/plate-0.vox create mode 100644 assets/voxygen/voxel/armor/hand/plate_left-0.vox create mode 100644 assets/voxygen/voxel/armor/hand/plate_right-0.vox create mode 100644 assets/voxygen/voxel/armor/pants/plate-0.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/plate_left-0.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/plate_right-0.vox diff --git a/assets/common/items/armor/belt_plate-0.ron b/assets/common/items/armor/belt_plate-0.ron new file mode 100644 index 0000000000..c365499f9b --- /dev/null +++ b/assets/common/items/armor/belt_plate-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Belt", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Belt(Assassin), + stats: 20, + ), +) diff --git a/assets/common/items/armor/chest_plate.ron b/assets/common/items/armor/chest_plate_green-0.ron similarity index 100% rename from assets/common/items/armor/chest_plate.ron rename to assets/common/items/armor/chest_plate_green-0.ron diff --git a/assets/common/items/armor/foot_plate-0.ron b/assets/common/items/armor/foot_plate-0.ron new file mode 100644 index 0000000000..c365499f9b --- /dev/null +++ b/assets/common/items/armor/foot_plate-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Belt", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Belt(Assassin), + stats: 20, + ), +) diff --git a/assets/common/items/armor/hand_plate-0.ron b/assets/common/items/armor/hand_plate-0.ron new file mode 100644 index 0000000000..819538cc5e --- /dev/null +++ b/assets/common/items/armor/hand_plate-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Shoulder Guard", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Shoulder(Assassin), + stats: 20, + ), +) diff --git a/assets/common/items/armor/pants_plate_green-0.ron b/assets/common/items/armor/pants_plate_green-0.ron new file mode 100644 index 0000000000..5916cd5547 --- /dev/null +++ b/assets/common/items/armor/pants_plate_green-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Iron Chestplate", + description: "Arrows to the stomach are soooo last update.", + kind: Armor( + kind: Chest(Plate), + stats: 20, + ), +) diff --git a/assets/common/items/armor/shoulder_plate-0.ron b/assets/common/items/armor/shoulder_plate-0.ron new file mode 100644 index 0000000000..819538cc5e --- /dev/null +++ b/assets/common/items/armor/shoulder_plate-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Shoulder Guard", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Shoulder(Assassin), + stats: 20, + ), +) diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index f13cfe295b..7763dae1d1 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -47,7 +47,7 @@ ), Armor(Belt(Assassin)): VoxTrans( "voxel.armor.belt.assa", - (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.1, ), Armor(Foot(Assassin)): VoxTrans( "voxel.armor.foot.assa", @@ -62,8 +62,28 @@ (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), // Starting Armor - Plate - Armor(Chest(Plate)): VoxTrans( - "voxel.armor.chest.plate", + Armor(Chest(PlateGreen0)): VoxTrans( + "voxel.armor.chest.plate_green-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Pants((PlateGreen0)): VoxTrans( + "voxel.armor.pants.plate_green-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Belt(Plate0)): VoxTrans( + "voxel.armor.belt.plate-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.1, + ), + Armor(Foot(Plate0)): VoxTrans( + "voxel.armor.foot.plate-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Hand(Plate0)): VoxTrans( + "voxel.armor.hand.plate_left-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Shoulder(Plate0)): VoxTrans( + "voxel.armor.shoulder.plate_left-0", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), // Consumables diff --git a/assets/voxygen/voxel/armor/belt/plate-0.vox b/assets/voxygen/voxel/armor/belt/plate-0.vox new file mode 100644 index 0000000000..274d084e72 --- /dev/null +++ b/assets/voxygen/voxel/armor/belt/plate-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a080bd77583d9ecefbf1d0f22d83a9d30f3594ee6254af961643cf4ed2bf1b7a +size 1472 diff --git a/assets/voxygen/voxel/armor/chest/plate.vox b/assets/voxygen/voxel/armor/chest/plate_green-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/chest/plate.vox rename to assets/voxygen/voxel/armor/chest/plate_green-0.vox diff --git a/assets/voxygen/voxel/armor/foot/plate-0.vox b/assets/voxygen/voxel/armor/foot/plate-0.vox new file mode 100644 index 0000000000..50d3eae09b --- /dev/null +++ b/assets/voxygen/voxel/armor/foot/plate-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:610e5b351d62943f88893791bfe8ca20838fd3c3635219886033dba6032170f2 +size 1480 diff --git a/assets/voxygen/voxel/armor/hand/plate_left-0.vox b/assets/voxygen/voxel/armor/hand/plate_left-0.vox new file mode 100644 index 0000000000..17da189c5c --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/plate_left-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b73779f79d87c6126c9769a82fae95e05fca1ae603273a8d1b99a7d65a5cbbad +size 1240 diff --git a/assets/voxygen/voxel/armor/hand/plate_right-0.vox b/assets/voxygen/voxel/armor/hand/plate_right-0.vox new file mode 100644 index 0000000000..57d9f2747f --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/plate_right-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:401a93697104fbe414cdc04dc2e4d9767f540358c3ba64f3abb7263d444cbbc7 +size 1240 diff --git a/assets/voxygen/voxel/armor/pants/plate-0.vox b/assets/voxygen/voxel/armor/pants/plate-0.vox new file mode 100644 index 0000000000..6520bd653a --- /dev/null +++ b/assets/voxygen/voxel/armor/pants/plate-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70f97c30c4f7a4e0602ebcaccb1b248f618def4cf2a2d81b8d5d480813659d44 +size 1912 diff --git a/assets/voxygen/voxel/armor/shoulder/plate_left-0.vox b/assets/voxygen/voxel/armor/shoulder/plate_left-0.vox new file mode 100644 index 0000000000..023047b426 --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/plate_left-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db1ab248201355827dad3fc954354d67981629314bc74cfc1615ba684bd20c5d +size 1460 diff --git a/assets/voxygen/voxel/armor/shoulder/plate_right-0.vox b/assets/voxygen/voxel/armor/shoulder/plate_right-0.vox new file mode 100644 index 0000000000..023047b426 --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/plate_right-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db1ab248201355827dad3fc954354d67981629314bc74cfc1615ba684bd20c5d +size 1460 diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index 6e14eb515a..16ef6d7f37 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -18,5 +18,13 @@ Assassin:( vox_spec: ("armor.belt.assa", (-5.0, -3.5, 2.0)), color: None - ) + ), + Dark:( + vox_spec: ("armor.belt.plate-0", (-4.0, -3.5, 2.0)), + color: None + ), + Plate0:( + vox_spec: ("armor.belt.plate-0", (-4.0, -3.5, 2.0)), + color: None + ), }) \ No newline at end of file diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index 1291114194..873f515ec7 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -31,8 +31,8 @@ vox_spec: ("armor.chest.cloth_red_kimono", (-7.0, -3.5, 2.0)), color: None ), - Plate: ( - vox_spec: ("armor.chest.plate", (-7.0, -3.5, 2.0)), + PlateGreen0: ( + vox_spec: ("armor.chest.plate_green-0", (-7.0, -3.5, 2.0)), color: None ) }) \ No newline at end of file diff --git a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron index d95587b47d..915555b4db 100644 --- a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron @@ -19,5 +19,9 @@ Jester: ( vox_spec: ("armor.foot.dark_jester-elf_shoe", (-2.5, -3.0, -9.0)), color: None - ) + ), + Plate0: ( + vox_spec: ("armor.foot.plate-0", (-2.5, -3.5, -9.0)), + color: None + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron index b5b90c6cc4..44f365a5ea 100644 --- a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron @@ -28,5 +28,15 @@ vox_spec: ("armor.hand.cloth_basic_right", (-1.5, -1.5, -7.0)), color: None ) - ) + ), + Plate0: ( + left: ( + vox_spec: ("armor.hand.plate_left-0", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.plate_right-0", (-1.5, -1.5, -7.0)), + color: None + ) + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron index bf1c7e6303..de9daf63b3 100644 --- a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron @@ -26,5 +26,13 @@ Kimono: ( vox_spec: ("armor.pants.cloth_red_kimono", (-5.0, -3.5, 0.0)), color: None - ) + ), + Assassin: ( + vox_spec: ("armor.pants.plate-0", (-5.0, -3.5, 1.0)), + color: None + ), + PlateGreen0: ( + vox_spec: ("armor.pants.plate_green-0", (-5.0, -3.5, 1.0)), + color: None + ), }) \ No newline at end of file diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index 3e354070c7..ee90d42e87 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -39,5 +39,15 @@ vox_spec: ("armor.shoulder.chain_right-1", (-2.0, -3.5, 0.1)), color: None ) - ) + ), + Plate0: ( + left: ( + vox_spec: ("armor.shoulder.plate_left-0", (-4.0, -3.5, 0.1)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.plate_right-0", (-2.0, -3.5, 0.1)), + color: None + ) + ), }) diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index c1e526a8d7..a1ca449a6d 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -488,7 +488,7 @@ pub enum Chest { Midnight = 5, Kimono = 6, Assassin = 7, - Plate = 8, + PlateGreen0 = 8, } pub const ALL_CHESTS: [Chest; 9] = [ Chest::Blue, @@ -499,7 +499,7 @@ pub const ALL_CHESTS: [Chest; 9] = [ Chest::Midnight, Chest::Kimono, Chest::Assassin, - Chest::Plate, + Chest::PlateGreen0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -510,13 +510,15 @@ pub enum Belt { BloodCloth = 2, BlackCloth = 3, Assassin = 4, + Plate0 = 5, } -pub const ALL_BELTS: [Belt; 5] = [ +pub const ALL_BELTS: [Belt; 6] = [ Belt::Dark, Belt::TurqCloth, Belt::BloodCloth, Belt::BlackCloth, Belt::Assassin, + Belt::Plate0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -529,8 +531,9 @@ pub enum Pants { Orange = 4, Kimono = 5, Assassin = 6, + PlateGreen0 = 7, } -pub const ALL_PANTS: [Pants; 7] = [ +pub const ALL_PANTS: [Pants; 8] = [ Pants::Blue, Pants::Brown, Pants::Dark, @@ -538,6 +541,7 @@ pub const ALL_PANTS: [Pants; 7] = [ Pants::Orange, Pants::Kimono, Pants::Assassin, + Pants::PlateGreen0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -546,8 +550,9 @@ pub enum Hand { Bare = 0, Cloth = 1, Assassin = 2, + Plate0 = 3, } -pub const ALL_HANDS: [Hand; 3] = [Hand::Bare, Hand::Cloth, Hand::Assassin]; +pub const ALL_HANDS: [Hand; 4] = [Hand::Bare, Hand::Cloth, Hand::Assassin, Hand::Plate0]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] @@ -557,13 +562,15 @@ pub enum Foot { Sandal = 2, Jester = 3, Assassin = 4, + Plate0 = 5, } -pub const ALL_FEET: [Foot; 5] = [ +pub const ALL_FEET: [Foot; 6] = [ Foot::Bare, Foot::Dark, Foot::Sandal, Foot::Jester, Foot::Assassin, + Foot::Plate0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -573,12 +580,14 @@ pub enum Shoulder { Brown1 = 1, Chain = 2, Assassin = 3, + Plate0 = 4, } -pub const ALL_SHOULDERS: [Shoulder; 4] = [ +pub const ALL_SHOULDERS: [Shoulder; 5] = [ Shoulder::None, Shoulder::Brown1, Shoulder::Chain, Shoulder::Assassin, + Shoulder::Plate0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] From bf1c46d5962ecf67d41fa41796be7583bb13eb78 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 5 Mar 2020 18:18:17 +0100 Subject: [PATCH 092/326] item images --- assets/common/items/armor/belt_plate-0.ron | 6 +++--- .../items/armor/chest_plate_green-0.ron | 2 +- assets/common/items/armor/foot_plate-0.ron | 6 +++--- assets/common/items/armor/hand_plate-0.ron | 6 +++--- .../items/armor/pants_plate_green-0.ron | 6 +++--- .../common/items/armor/shoulder_plate-0.ron | 6 +++--- assets/voxygen/item_image_manifest.ron | 2 +- assets/voxygen/voxel/armor/belt/assa.vox | 2 +- assets/voxygen/voxel/armor/chest/assa.vox | 4 ++-- assets/voxygen/voxel/armor/foot/assa.vox | 4 ++-- assets/voxygen/voxel/armor/hand/assa_left.vox | 2 +- .../voxygen/voxel/armor/hand/assa_right.vox | 2 +- .../voxel/armor/hand/plate_right-0.vox | 4 ++-- assets/voxygen/voxel/armor/head/assa_mask.vox | 3 +++ assets/voxygen/voxel/armor/pants/assa.vox | 2 +- .../pants/{plate-0.vox => plate_green-0.vox} | 0 .../voxel/armor/shoulder/assa_left.vox | 4 ++-- .../voxel/armor/shoulder/assa_right.vox | 4 ++-- .../voxel/armor/shoulder/plate_right-0.vox | 4 ++-- .../voxel/humanoid_armor_belt_manifest.ron | 4 ++-- .../voxel/humanoid_armor_pants_manifest.ron | 6 +----- .../humanoid_armor_shoulder_manifest.ron | 20 +++++++++---------- common/src/comp/body/humanoid.rs | 20 ++++++++++++------- 23 files changed, 62 insertions(+), 57 deletions(-) create mode 100644 assets/voxygen/voxel/armor/head/assa_mask.vox rename assets/voxygen/voxel/armor/pants/{plate-0.vox => plate_green-0.vox} (100%) diff --git a/assets/common/items/armor/belt_plate-0.ron b/assets/common/items/armor/belt_plate-0.ron index c365499f9b..7246beb7a4 100644 --- a/assets/common/items/armor/belt_plate-0.ron +++ b/assets/common/items/armor/belt_plate-0.ron @@ -1,8 +1,8 @@ Item( - name: "Assassin Belt", - description: "Only the best for a member of the creed.", + name: "Iron Belt", + description: "WIP", kind: Armor( - kind: Belt(Assassin), + kind: Belt(Plate0), stats: 20, ), ) diff --git a/assets/common/items/armor/chest_plate_green-0.ron b/assets/common/items/armor/chest_plate_green-0.ron index 5916cd5547..a4d9916e63 100644 --- a/assets/common/items/armor/chest_plate_green-0.ron +++ b/assets/common/items/armor/chest_plate_green-0.ron @@ -2,7 +2,7 @@ Item( name: "Iron Chestplate", description: "Arrows to the stomach are soooo last update.", kind: Armor( - kind: Chest(Plate), + kind: Chest(PlateGreen0), stats: 20, ), ) diff --git a/assets/common/items/armor/foot_plate-0.ron b/assets/common/items/armor/foot_plate-0.ron index c365499f9b..f4f221147f 100644 --- a/assets/common/items/armor/foot_plate-0.ron +++ b/assets/common/items/armor/foot_plate-0.ron @@ -1,8 +1,8 @@ Item( - name: "Assassin Belt", - description: "Only the best for a member of the creed.", + name: "Iron Feet", + description: "WIP", kind: Armor( - kind: Belt(Assassin), + kind: Foot(Plate0), stats: 20, ), ) diff --git a/assets/common/items/armor/hand_plate-0.ron b/assets/common/items/armor/hand_plate-0.ron index 819538cc5e..8e27eee491 100644 --- a/assets/common/items/armor/hand_plate-0.ron +++ b/assets/common/items/armor/hand_plate-0.ron @@ -1,8 +1,8 @@ Item( - name: "Assassin Shoulder Guard", - description: "Only the best for a member of the creed.", + name: "Iron Handguards", + description: "WIP", kind: Armor( - kind: Shoulder(Assassin), + kind: Hand(Plate0), stats: 20, ), ) diff --git a/assets/common/items/armor/pants_plate_green-0.ron b/assets/common/items/armor/pants_plate_green-0.ron index 5916cd5547..131d87be51 100644 --- a/assets/common/items/armor/pants_plate_green-0.ron +++ b/assets/common/items/armor/pants_plate_green-0.ron @@ -1,8 +1,8 @@ Item( - name: "Iron Chestplate", - description: "Arrows to the stomach are soooo last update.", + name: "Iron Legguards", + description: "WIP", kind: Armor( - kind: Chest(Plate), + kind: Pants(PlateGreen0), stats: 20, ), ) diff --git a/assets/common/items/armor/shoulder_plate-0.ron b/assets/common/items/armor/shoulder_plate-0.ron index 819538cc5e..37bde3183d 100644 --- a/assets/common/items/armor/shoulder_plate-0.ron +++ b/assets/common/items/armor/shoulder_plate-0.ron @@ -1,8 +1,8 @@ Item( - name: "Assassin Shoulder Guard", - description: "Only the best for a member of the creed.", + name: "Iron Shoulderguards", + description: "A strong shoulder to lean on.", kind: Armor( - kind: Shoulder(Assassin), + kind: Shoulder(Plate0), stats: 20, ), ) diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index 7763dae1d1..3d8d53ce24 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -66,7 +66,7 @@ "voxel.armor.chest.plate_green-0", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), - Armor(Pants((PlateGreen0)): VoxTrans( + Armor(Pants(PlateGreen0)): VoxTrans( "voxel.armor.pants.plate_green-0", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), diff --git a/assets/voxygen/voxel/armor/belt/assa.vox b/assets/voxygen/voxel/armor/belt/assa.vox index dffd8e6ffe..e6285a27cf 100644 --- a/assets/voxygen/voxel/armor/belt/assa.vox +++ b/assets/voxygen/voxel/armor/belt/assa.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6149f83d15faf914cd8286ba61e37cc14eeeb4a3ae3fd02e917afcdeca6f757d +oid sha256:0ab185c2f3af358eb6f45d8ceb19d7df33417b13b327aae65ff1d296a7587e79 size 1472 diff --git a/assets/voxygen/voxel/armor/chest/assa.vox b/assets/voxygen/voxel/armor/chest/assa.vox index 2368550782..dc173f1cf0 100644 --- a/assets/voxygen/voxel/armor/chest/assa.vox +++ b/assets/voxygen/voxel/armor/chest/assa.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a2d7513d18f28cf272a585dbeda6669ae5a28ad84b945efbf13d7f4b6c639b9d -size 45819 +oid sha256:8ec2c2ec85bca46a9ae5db921064cd817cf29bf98080d186fd327256421f7a57 +size 2712 diff --git a/assets/voxygen/voxel/armor/foot/assa.vox b/assets/voxygen/voxel/armor/foot/assa.vox index 881ec1a5de..48dfb84f1a 100644 --- a/assets/voxygen/voxel/armor/foot/assa.vox +++ b/assets/voxygen/voxel/armor/foot/assa.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:49178c027d6e9f20978786138fd76e0413057600d7094705686c1b2ea0a89e6d -size 1480 +oid sha256:8596adda7d5f16aced46959050ee8135f72123a1943531fdda11c816a86db380 +size 55963 diff --git a/assets/voxygen/voxel/armor/hand/assa_left.vox b/assets/voxygen/voxel/armor/hand/assa_left.vox index b103659d78..2ee60e1f18 100644 --- a/assets/voxygen/voxel/armor/hand/assa_left.vox +++ b/assets/voxygen/voxel/armor/hand/assa_left.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d3c8d6c4226337c43cd1d5b8ab2f251c38ccb9357a524697b672c0e63bf7f41e +oid sha256:d981e3ab25371195bdb81ab260b41e6fd985130969b96068dc560ea0412fc49a size 1240 diff --git a/assets/voxygen/voxel/armor/hand/assa_right.vox b/assets/voxygen/voxel/armor/hand/assa_right.vox index 2bf33c0563..5bd9116e8c 100644 --- a/assets/voxygen/voxel/armor/hand/assa_right.vox +++ b/assets/voxygen/voxel/armor/hand/assa_right.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:38f226fd0c2425db70c294dbe3566138cd49e05fde6c09f3d972de4a88751741 +oid sha256:b9e41c15237da8a886002d03f1d01558672212de1e8f57b5df207db2d1dd0566 size 55723 diff --git a/assets/voxygen/voxel/armor/hand/plate_right-0.vox b/assets/voxygen/voxel/armor/hand/plate_right-0.vox index 57d9f2747f..9db01e9dc7 100644 --- a/assets/voxygen/voxel/armor/hand/plate_right-0.vox +++ b/assets/voxygen/voxel/armor/hand/plate_right-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:401a93697104fbe414cdc04dc2e4d9767f540358c3ba64f3abb7263d444cbbc7 -size 1240 +oid sha256:58457547228410c17d04ad5b60329aa282b02888217e6d840806448120b47d6b +size 55723 diff --git a/assets/voxygen/voxel/armor/head/assa_mask.vox b/assets/voxygen/voxel/armor/head/assa_mask.vox new file mode 100644 index 0000000000..07dac5e2f7 --- /dev/null +++ b/assets/voxygen/voxel/armor/head/assa_mask.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d088786a9c7c6ba623d637fa9d301c6565430449285cd9ad830a52be357bfa1 +size 1544 diff --git a/assets/voxygen/voxel/armor/pants/assa.vox b/assets/voxygen/voxel/armor/pants/assa.vox index c487e62091..0fd67628f4 100644 --- a/assets/voxygen/voxel/armor/pants/assa.vox +++ b/assets/voxygen/voxel/armor/pants/assa.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5df651f1df9d57ebd10eaafe9c3bac8b882b2c77f9cec0c57323b5b220f8ef4e +oid sha256:7db069a83bdb723c5057c975d5a31950ccd7a550d2145b22a681db13f05d5be2 size 1912 diff --git a/assets/voxygen/voxel/armor/pants/plate-0.vox b/assets/voxygen/voxel/armor/pants/plate_green-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/pants/plate-0.vox rename to assets/voxygen/voxel/armor/pants/plate_green-0.vox diff --git a/assets/voxygen/voxel/armor/shoulder/assa_left.vox b/assets/voxygen/voxel/armor/shoulder/assa_left.vox index 590c2531a8..ed416fed2f 100644 --- a/assets/voxygen/voxel/armor/shoulder/assa_left.vox +++ b/assets/voxygen/voxel/armor/shoulder/assa_left.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:84b93b691e9179fa6e84be5e6aaaec68217a8fe71a4fa670e5544ffd4b04096c -size 44491 +oid sha256:68b31a19a383d3157f6754987ea4f7284e8bbb7e16705500ab9c7774e1de7a51 +size 1384 diff --git a/assets/voxygen/voxel/armor/shoulder/assa_right.vox b/assets/voxygen/voxel/armor/shoulder/assa_right.vox index 7136338ccf..ad59092ec3 100644 --- a/assets/voxygen/voxel/armor/shoulder/assa_right.vox +++ b/assets/voxygen/voxel/armor/shoulder/assa_right.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:195656b4b047b8c0095c86f00bc0c374c4e3b65fc610d4c74670a19aa07c228b -size 44491 +oid sha256:05df36be9cf12a9bfca9fe5d0c83a4fdafab077a1dc834ec121dc1072ecdf9d2 +size 1384 diff --git a/assets/voxygen/voxel/armor/shoulder/plate_right-0.vox b/assets/voxygen/voxel/armor/shoulder/plate_right-0.vox index 023047b426..45022728e4 100644 --- a/assets/voxygen/voxel/armor/shoulder/plate_right-0.vox +++ b/assets/voxygen/voxel/armor/shoulder/plate_right-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db1ab248201355827dad3fc954354d67981629314bc74cfc1615ba684bd20c5d -size 1460 +oid sha256:44710553f64bdea121df4c2be97ae700d2216cde30623099517f2ea06121c29f +size 55943 diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index 16ef6d7f37..07d813cb04 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -20,11 +20,11 @@ color: None ), Dark:( - vox_spec: ("armor.belt.plate-0", (-4.0, -3.5, 2.0)), + vox_spec: ("armor.belt.dark", (-4.0, -3.5, 2.0)), color: None ), Plate0:( - vox_spec: ("armor.belt.plate-0", (-4.0, -3.5, 2.0)), + vox_spec: ("armor.belt.plate-0", (-5.0, -3.5, 2.0)), color: None ), }) \ No newline at end of file diff --git a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron index de9daf63b3..4ec93ad4bf 100644 --- a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron @@ -26,11 +26,7 @@ Kimono: ( vox_spec: ("armor.pants.cloth_red_kimono", (-5.0, -3.5, 0.0)), color: None - ), - Assassin: ( - vox_spec: ("armor.pants.plate-0", (-5.0, -3.5, 1.0)), - color: None - ), + ), PlateGreen0: ( vox_spec: ("armor.pants.plate_green-0", (-5.0, -3.5, 1.0)), color: None diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index ee90d42e87..bcbfeded1c 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -2,51 +2,51 @@ //This shouldn't be the none option, but what is? None: ( left: ( - vox_spec: ("armor.empty", (-3.0, -3.5, 0.1)), + vox_spec: ("armor.empty", (-3.0, -3.5, 1.0)), color: None ), right: ( - vox_spec: ("armor.empty", (-2.0, -3.5, 0.1)), + vox_spec: ("armor.empty", (-2.0, -3.5, 1.0)), color: None ) ), Brown1: ( left: ( - vox_spec: ("armor.shoulder.brown_left", (-3.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.brown_left", (-3.0, -3.5, 1.0)), color: None ), right: ( - vox_spec: ("armor.shoulder.brown_right", (-2.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.brown_right", (-2.0, -3.5, 1.0)), color: None ) ), Assassin: ( left: ( - vox_spec: ("armor.shoulder.assa_left", (-4.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.assa_left", (-4.0, -3.5, 1.0)), color: None ), right: ( - vox_spec: ("armor.shoulder.assa_right", (-2.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.assa_right", (-2.0, -3.5, 1.0)), color: None ) ), Chain: ( left: ( - vox_spec: ("armor.shoulder.chain_left-1", (-4.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.chain_left-1", (-4.0, -3.5, 1.0)), color: None ), right: ( - vox_spec: ("armor.shoulder.chain_right-1", (-2.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.chain_right-1", (-2.0, -3.5, 1.0)), color: None ) ), Plate0: ( left: ( - vox_spec: ("armor.shoulder.plate_left-0", (-4.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.plate_left-0", (-3.6, -3.5, 1.0)), color: None ), right: ( - vox_spec: ("armor.shoulder.plate_right-0", (-2.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.plate_right-0", (-2.6, -3.5, 1.0)), color: None ) ), diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index a1ca449a6d..57c8780d8c 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -125,7 +125,7 @@ impl<'a, SpeciesMeta: 'a> IntoIterator for &'a AllSpecies { } // Hair Colors -pub const DANARI_HAIR_COLORS: [(u8, u8, u8); 11] = [ +pub const DANARI_HAIR_COLORS: [(u8, u8, u8); 12] = [ (198, 169, 113), // Philosopher's Grey //(245, 232, 175), // Cream Blonde //(228, 208, 147), // Gold Blonde @@ -141,9 +141,10 @@ pub const DANARI_HAIR_COLORS: [(u8, u8, u8); 11] = [ (107, 32, 60), // Grape Purple (135, 38, 39), // Dark Red (88, 26, 29), // Wine Red - //(146, 32, 32), // Autumn Red + //(146, 32, 32), // Autumn Red + (20, 19, 17), // Black ]; -pub const DWARF_HAIR_COLORS: [(u8, u8, u8); 20] = [ +pub const DWARF_HAIR_COLORS: [(u8, u8, u8); 21] = [ (245, 232, 175), // Cream Blonde (228, 208, 147), // Gold Blonde (228, 223, 141), // Platinum Blonde @@ -164,8 +165,9 @@ pub const DWARF_HAIR_COLORS: [(u8, u8, u8); 20] = [ (163, 186, 192), // Matte Green (84, 139, 107), // Grass Green (48, 61, 52), // Dark Green + (20, 19, 17), // Black ]; -pub const ELF_HAIR_COLORS: [(u8, u8, u8); 23] = [ +pub const ELF_HAIR_COLORS: [(u8, u8, u8); 24] = [ (66, 83, 113), // Mysterious Blue (13, 76, 41), // Rainforest Green (245, 232, 175), // Cream Blonde @@ -189,8 +191,9 @@ pub const ELF_HAIR_COLORS: [(u8, u8, u8); 23] = [ (163, 186, 192), // Matte Green (84, 139, 107), // Grass Green (48, 61, 52), // Dark Green + (20, 19, 17), // Black ]; -pub const HUMAN_HAIR_COLORS: [(u8, u8, u8); 21] = [ +pub const HUMAN_HAIR_COLORS: [(u8, u8, u8); 22] = [ (245, 232, 175), // Cream Blonde (228, 208, 147), // Gold Blonde (228, 223, 141), // Platinum Blonde @@ -212,8 +215,9 @@ pub const HUMAN_HAIR_COLORS: [(u8, u8, u8); 21] = [ (163, 186, 192), // Matte Green (84, 139, 107), // Grass Green (48, 61, 52), // Dark Green + (20, 19, 17), // Black ]; -pub const ORC_HAIR_COLORS: [(u8, u8, u8); 10] = [ +pub const ORC_HAIR_COLORS: [(u8, u8, u8); 11] = [ (66, 66, 59), // Wise Grey //(107, 76, 51), // Oak Skin4 //(203, 154, 98), // Light Skin4 @@ -226,8 +230,9 @@ pub const ORC_HAIR_COLORS: [(u8, u8, u8); 10] = [ (135, 38, 39), // Dark Red (88, 26, 29), // Wine Red (66, 83, 113), // Mysterious Blue + (20, 19, 17), // Black ]; -pub const UNDEAD_HAIR_COLORS: [(u8, u8, u8); 21] = [ +pub const UNDEAD_HAIR_COLORS: [(u8, u8, u8); 22] = [ //(245, 232, 175), // Cream Blonde (228, 208, 147), // Gold Blonde //(228, 223, 141), // Platinum Blonde @@ -252,6 +257,7 @@ pub const UNDEAD_HAIR_COLORS: [(u8, u8, u8); 21] = [ (163, 186, 192), // Matte Green (84, 139, 107), // Grass Green (48, 61, 52), // Dark Green + (20, 19, 17), // Black ]; // Skin colors From 3738fe45f7c0088679178df79c5649c32704050a Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sun, 8 Mar 2020 00:53:49 +0100 Subject: [PATCH 093/326] better item desc --- assets/common/items/weapons/hammer_1.ron | 4 +++- assets/common/items/weapons/staff_1.ron | 4 +++- assets/common/items/weapons/starter_axe.ron | 4 +++- assets/common/items/weapons/starter_bow.ron | 4 +++- assets/common/items/weapons/starter_dagger.ron | 3 ++- assets/common/items/weapons/starter_hammer.ron | 4 +++- assets/common/items/weapons/starter_staff.ron | 4 +++- assets/common/items/weapons/starter_sword.ron | 4 +++- assets/voxygen/element/buttons/inv_tab.vox | 3 +++ 9 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 assets/voxygen/element/buttons/inv_tab.vox diff --git a/assets/common/items/weapons/hammer_1.ron b/assets/common/items/weapons/hammer_1.ron index caeaf8ad28..268cf1f7da 100644 --- a/assets/common/items/weapons/hammer_1.ron +++ b/assets/common/items/weapons/hammer_1.ron @@ -1,6 +1,8 @@ Item( name: "Crude Mallet", - description: "Breaks bones like sticks and stones.", + description: "Breaks bones like sticks and stones. + \n + Power: 20", kind: Tool( ToolData ( kind: Hammer, diff --git a/assets/common/items/weapons/staff_1.ron b/assets/common/items/weapons/staff_1.ron index f56cb59f42..4a66a40399 100644 --- a/assets/common/items/weapons/staff_1.ron +++ b/assets/common/items/weapons/staff_1.ron @@ -1,6 +1,8 @@ Item( name: "Humble Stick", - description: "Walking stick with a sharpened end.", + description: "Walking stick with a sharpened end. + + Power: 6", kind: Tool( ToolData ( kind: Staff, diff --git a/assets/common/items/weapons/starter_axe.ron b/assets/common/items/weapons/starter_axe.ron index adbb486de2..89a71e297c 100644 --- a/assets/common/items/weapons/starter_axe.ron +++ b/assets/common/items/weapons/starter_axe.ron @@ -1,6 +1,8 @@ Item( name: "Notched Axe", - description: "Every dent tells the story of a chopped tree.", + description: "Every dent tells the story of a chopped tree. + + Power: 15", kind: Tool( ToolData ( kind: Axe, diff --git a/assets/common/items/weapons/starter_bow.ron b/assets/common/items/weapons/starter_bow.ron index b265ef65da..14b11333a5 100644 --- a/assets/common/items/weapons/starter_bow.ron +++ b/assets/common/items/weapons/starter_bow.ron @@ -1,6 +1,8 @@ Item( name: "Uneven Bow", - description: "Someone carved his initials into it...", + description: "Someone carved his initials into it... + + Power: 15", kind: Tool( ToolData ( kind: Bow, diff --git a/assets/common/items/weapons/starter_dagger.ron b/assets/common/items/weapons/starter_dagger.ron index bb50379b52..8817c6865f 100644 --- a/assets/common/items/weapons/starter_dagger.ron +++ b/assets/common/items/weapons/starter_dagger.ron @@ -1,6 +1,7 @@ Item( name: "Sharp Kitchen Knife", - description: "Great for cutting meat.", + description: "Great for cutting meat. + Power: 15", kind: Tool( ToolData ( kind: Dagger, diff --git a/assets/common/items/weapons/starter_hammer.ron b/assets/common/items/weapons/starter_hammer.ron index 1d3aa1a05a..6242cfc7c1 100644 --- a/assets/common/items/weapons/starter_hammer.ron +++ b/assets/common/items/weapons/starter_hammer.ron @@ -1,6 +1,8 @@ Item( name: "Sturdy Old Hammer", - description: "'Property of...' The rest is missing. ", + description: "'Property of...' The rest is missing. + + Power: 15", kind: Tool( ToolData ( kind: Hammer, diff --git a/assets/common/items/weapons/starter_staff.ron b/assets/common/items/weapons/starter_staff.ron index e275179ded..2cf741181c 100644 --- a/assets/common/items/weapons/starter_staff.ron +++ b/assets/common/items/weapons/starter_staff.ron @@ -1,6 +1,8 @@ Item( name: "Gnarled Rod", - description: "Smells like resin and magic.", + description: "Smells like resin and magic. + + Power: 20", kind: Tool( ToolData ( kind: Staff, diff --git a/assets/common/items/weapons/starter_sword.ron b/assets/common/items/weapons/starter_sword.ron index ad3511c1e2..4429ac2850 100644 --- a/assets/common/items/weapons/starter_sword.ron +++ b/assets/common/items/weapons/starter_sword.ron @@ -1,6 +1,8 @@ Item( name: "Battered Sword", - description: "Held together by Rust and hope.", + description: "Held together by Rust and hope. + + Power: 15", kind: Tool( ToolData ( kind: Sword(Rapier), diff --git a/assets/voxygen/element/buttons/inv_tab.vox b/assets/voxygen/element/buttons/inv_tab.vox new file mode 100644 index 0000000000..dc60c1323b --- /dev/null +++ b/assets/voxygen/element/buttons/inv_tab.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab46da914aa73fd0a7aff023883cd5392d01f0609383d4c143d5c3680b65250a +size 57195 From caf415946337e23847b546617cdbce4e5c99d0bc Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Mon, 9 Mar 2020 22:54:36 +0100 Subject: [PATCH 094/326] UI changes --- assets/voxygen/element/buttons/close_btn.png | 3 ++ .../element/buttons/close_btn_hover.png | 3 ++ .../element/buttons/close_btn_press.png | 3 ++ assets/voxygen/element/misc_bg/inv_bg.png | 3 ++ assets/voxygen/element/misc_bg/inv_frame.png | 3 ++ voxygen/src/hud/bag.rs | 41 +++++++++++++------ voxygen/src/hud/img_ids.rs | 9 ++++ 7 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 assets/voxygen/element/buttons/close_btn.png create mode 100644 assets/voxygen/element/buttons/close_btn_hover.png create mode 100644 assets/voxygen/element/buttons/close_btn_press.png create mode 100644 assets/voxygen/element/misc_bg/inv_bg.png create mode 100644 assets/voxygen/element/misc_bg/inv_frame.png diff --git a/assets/voxygen/element/buttons/close_btn.png b/assets/voxygen/element/buttons/close_btn.png new file mode 100644 index 0000000000..1c2b271be8 --- /dev/null +++ b/assets/voxygen/element/buttons/close_btn.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31e49f8953cf6c4ec90b86b504b837e83955c22a2b254f4292497237b01a7a41 +size 470 diff --git a/assets/voxygen/element/buttons/close_btn_hover.png b/assets/voxygen/element/buttons/close_btn_hover.png new file mode 100644 index 0000000000..837ea7c6d8 --- /dev/null +++ b/assets/voxygen/element/buttons/close_btn_hover.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b5a5a2c23ac7a90c7a48b22d5785b343938aaca40ed17beef4eb923abd317578 +size 485 diff --git a/assets/voxygen/element/buttons/close_btn_press.png b/assets/voxygen/element/buttons/close_btn_press.png new file mode 100644 index 0000000000..965d99b0bf --- /dev/null +++ b/assets/voxygen/element/buttons/close_btn_press.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:37d07c311f9dd99b8d8af2cb0443c56bad4b1e8a701a4961139cf3eb091a60f7 +size 469 diff --git a/assets/voxygen/element/misc_bg/inv_bg.png b/assets/voxygen/element/misc_bg/inv_bg.png new file mode 100644 index 0000000000..381d68c74f --- /dev/null +++ b/assets/voxygen/element/misc_bg/inv_bg.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cea8c835ac9c4fc78fde2d6b076490be62fba53d335b86c91eb043ff1eb5d7fe +size 32940 diff --git a/assets/voxygen/element/misc_bg/inv_frame.png b/assets/voxygen/element/misc_bg/inv_frame.png new file mode 100644 index 0000000000..4af0373848 --- /dev/null +++ b/assets/voxygen/element/misc_bg/inv_frame.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea486f92be048030c0977ff28c8babcdca9ac975f1145b8cc4821c18ac2a109b +size 32490 diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 70e27498de..cb6061b047 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -8,7 +8,7 @@ use client::Client; use conrod_core::{ color, image, widget::{self, Button, Image, Rectangle}, - widget_ids, Color, Positionable, Sizeable, Widget, WidgetCommon, + widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, }; widget_ids! { @@ -26,6 +26,8 @@ widget_ids! { inv_slots[], items[], tooltip[], + bg, + bg_frame, } } @@ -125,6 +127,31 @@ impl<'a> Widget for Bag<'a> { .font_id(self.fonts.cyri.conrod_id) .desc_text_color(TEXT_COLOR); + // BG + + Image::new(self.imgs.inv_bg) + .w_h(424.0, 708.0) + .bottom_right_with_margins_on(ui.window, 60.0, 5.0) + .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.97))) + .set(state.ids.bg, ui); + Image::new(self.imgs.inv_frame) + .w_h(424.0, 708.0) + .middle_of(state.ids.bg) + .set(state.ids.bg_frame, ui); + + // Close button + if Button::image(self.imgs.close_btn) + .w_h(24.0, 25.0) + .hover_image(self.imgs.close_btn_hover) + .press_image(self.imgs.close_btn_press) + .top_right_with_margins_on(state.ids.bg, 0.0, 0.0) + .set(state.ids.bag_close, ui) + .was_clicked() + { + event = Some(Event::Close); + } + + /* // Bag parts Image::new(self.imgs.bag_bot) .w_h(58.0 * BAG_SCALE, 9.0 * BAG_SCALE) @@ -262,17 +289,7 @@ impl<'a> Widget for Bag<'a> { } } - // Close button - if Button::image(self.imgs.close_button) - .w_h(28.0, 28.0) - .hover_image(self.imgs.close_button_hover) - .press_image(self.imgs.close_button_press) - .top_right_with_margins_on(state.ids.bag_top, 0.0, 0.0) - .set(state.ids.bag_close, ui) - .was_clicked() - { - event = Some(Event::Close); - } + */ event } diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 8139982d88..8df4663310 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -251,6 +251,15 @@ image_ids! { ////////////////////////////////////////////////////////////////////////////////////////////////////// + // Close-Button + close_btn: "voxygen.element.buttons.close_btn", + close_btn_hover: "voxygen.element.buttons.close_btn_hover", + close_btn_press: "voxygen.element.buttons.close_btn_press", + + // Inventory + inv_bg: "voxygen.element.misc_bg.inv_bg", + inv_frame: "voxygen.element.misc_bg.inv_frame", + not_found:"voxygen.element.not_found", From dc88e33a63747fa7056080c997dbe0baf80f15a7 Mon Sep 17 00:00:00 2001 From: Imbris Date: Fri, 28 Feb 2020 00:25:16 -0500 Subject: [PATCH 095/326] maybe fix hotreload panic --- assets/voxygen/voxel/humanoid_armor_belt_manifest.ron | 2 +- assets/voxygen/voxel/humanoid_armor_chest_manifest.ron | 2 +- assets/voxygen/voxel/humanoid_armor_pants_manifest.ron | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index 07d813cb04..a9a546e6b1 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -27,4 +27,4 @@ vox_spec: ("armor.belt.plate-0", (-5.0, -3.5, 2.0)), color: None ), -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index 873f515ec7..0d2b41ea05 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -35,4 +35,4 @@ vox_spec: ("armor.chest.plate_green-0", (-7.0, -3.5, 2.0)), color: None ) -}) \ No newline at end of file +}) diff --git a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron index 4ec93ad4bf..9f9176231e 100644 --- a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron @@ -31,4 +31,4 @@ vox_spec: ("armor.pants.plate_green-0", (-5.0, -3.5, 1.0)), color: None ), -}) \ No newline at end of file +}) From 658b6465b2ae521aa6fdc1c40e498af464ab7eb7 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sat, 8 Feb 2020 20:24:24 +0100 Subject: [PATCH 096/326] assassin armour --- .../voxygen/voxel/humanoid_armor_shoulder_manifest.ron | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index bcbfeded1c..0ca9f739c8 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -30,6 +30,16 @@ color: None ) ), + Assassin: ( + left: ( + vox_spec: ("armor.shoulder.assa_left", (-4.5, -3.0, 0.1)), + color: None + ), + right: ( + vox_spec: ("armor.empty", (-2.0, -3.5, 0.1)), + color: None + ) + ), Chain: ( left: ( vox_spec: ("armor.shoulder.chain_left-1", (-4.0, -3.5, 1.0)), From 898150bd23b7a69245c81148761d1295b040cc17 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 20 Feb 2020 15:30:47 +0100 Subject: [PATCH 097/326] plate chest armour --- assets/voxygen/voxel/armor/chest/plate.vox | 3 +++ assets/voxygen/voxel/humanoid_armor_chest_manifest.ron | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 assets/voxygen/voxel/armor/chest/plate.vox diff --git a/assets/voxygen/voxel/armor/chest/plate.vox b/assets/voxygen/voxel/armor/chest/plate.vox new file mode 100644 index 0000000000..d11968f267 --- /dev/null +++ b/assets/voxygen/voxel/armor/chest/plate.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:814763c1e4ad138f5de5ebb628dce3dc8f6f010c050052e993142754a8806668 +size 57227 diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index 0d2b41ea05..873f515ec7 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -35,4 +35,4 @@ vox_spec: ("armor.chest.plate_green-0", (-7.0, -3.5, 2.0)), color: None ) -}) +}) \ No newline at end of file From 98e8c79b1c5b057c9bd3016f009fc3ebb8ad944f Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 26 Feb 2020 17:04:43 +0000 Subject: [PATCH 098/326] Added armour items and equipping of armour --- assets/common/items/armor/chest_plate.ron | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 assets/common/items/armor/chest_plate.ron diff --git a/assets/common/items/armor/chest_plate.ron b/assets/common/items/armor/chest_plate.ron new file mode 100644 index 0000000000..5916cd5547 --- /dev/null +++ b/assets/common/items/armor/chest_plate.ron @@ -0,0 +1,8 @@ +Item( + name: "Iron Chestplate", + description: "Arrows to the stomach are soooo last update.", + kind: Armor( + kind: Chest(Plate), + stats: 20, + ), +) From 2f3c67a76fcb5caeb2f204f0ae5f5b5c1197d68f Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 27 Feb 2020 21:07:30 +0100 Subject: [PATCH 099/326] more armour --- assets/voxygen/voxel/armor/chest/plate.vox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/voxygen/voxel/armor/chest/plate.vox b/assets/voxygen/voxel/armor/chest/plate.vox index d11968f267..79466f4172 100644 --- a/assets/voxygen/voxel/armor/chest/plate.vox +++ b/assets/voxygen/voxel/armor/chest/plate.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:814763c1e4ad138f5de5ebb628dce3dc8f6f010c050052e993142754a8806668 +oid sha256:2d91415da84dba3e5a7c1c321b9728d80f1a9ca05ec8707bf39003b8b13033a1 size 57227 From 077ae6628131a4f202537c8892c16a67b97ec190 Mon Sep 17 00:00:00 2001 From: Pfauenauge Date: Mon, 2 Mar 2020 22:00:25 +0100 Subject: [PATCH 100/326] new assassin shoulder armor --- assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index 0ca9f739c8..60dee872a9 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -36,7 +36,7 @@ color: None ), right: ( - vox_spec: ("armor.empty", (-2.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.assa_right", (-2.0, -3.5, 0.1)), color: None ) ), From bc34a7cce8e8c5c4c8d27dd851933fb6fd4c3629 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Tue, 3 Mar 2020 20:52:10 +0100 Subject: [PATCH 101/326] more assa armour parts --- assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index 60dee872a9..d8b92309e0 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -32,7 +32,7 @@ ), Assassin: ( left: ( - vox_spec: ("armor.shoulder.assa_left", (-4.5, -3.0, 0.1)), + vox_spec: ("armor.shoulder.assa_left", (-4.0, -3.5, 0.1)), color: None ), right: ( From 6e2015957af99ed9f96215f881662fdeca9fca94 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 5 Mar 2020 16:35:26 +0100 Subject: [PATCH 102/326] plate armour --- assets/common/items/armor/chest_plate.ron | 8 -------- assets/voxygen/voxel/armor/chest/plate.vox | 3 --- assets/voxygen/voxel/armor/pants/plate-0.vox | 3 +++ 3 files changed, 3 insertions(+), 11 deletions(-) delete mode 100644 assets/common/items/armor/chest_plate.ron delete mode 100644 assets/voxygen/voxel/armor/chest/plate.vox create mode 100644 assets/voxygen/voxel/armor/pants/plate-0.vox diff --git a/assets/common/items/armor/chest_plate.ron b/assets/common/items/armor/chest_plate.ron deleted file mode 100644 index 5916cd5547..0000000000 --- a/assets/common/items/armor/chest_plate.ron +++ /dev/null @@ -1,8 +0,0 @@ -Item( - name: "Iron Chestplate", - description: "Arrows to the stomach are soooo last update.", - kind: Armor( - kind: Chest(Plate), - stats: 20, - ), -) diff --git a/assets/voxygen/voxel/armor/chest/plate.vox b/assets/voxygen/voxel/armor/chest/plate.vox deleted file mode 100644 index 79466f4172..0000000000 --- a/assets/voxygen/voxel/armor/chest/plate.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2d91415da84dba3e5a7c1c321b9728d80f1a9ca05ec8707bf39003b8b13033a1 -size 57227 diff --git a/assets/voxygen/voxel/armor/pants/plate-0.vox b/assets/voxygen/voxel/armor/pants/plate-0.vox new file mode 100644 index 0000000000..6520bd653a --- /dev/null +++ b/assets/voxygen/voxel/armor/pants/plate-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70f97c30c4f7a4e0602ebcaccb1b248f618def4cf2a2d81b8d5d480813659d44 +size 1912 From db96930ad16f22936cdfe54a41a76d4a77579b20 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 5 Mar 2020 18:18:17 +0100 Subject: [PATCH 103/326] item images --- assets/voxygen/voxel/armor/pants/plate-0.vox | 3 --- assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 assets/voxygen/voxel/armor/pants/plate-0.vox diff --git a/assets/voxygen/voxel/armor/pants/plate-0.vox b/assets/voxygen/voxel/armor/pants/plate-0.vox deleted file mode 100644 index 6520bd653a..0000000000 --- a/assets/voxygen/voxel/armor/pants/plate-0.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:70f97c30c4f7a4e0602ebcaccb1b248f618def4cf2a2d81b8d5d480813659d44 -size 1912 diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index d8b92309e0..fb174f8ec3 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -32,11 +32,11 @@ ), Assassin: ( left: ( - vox_spec: ("armor.shoulder.assa_left", (-4.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.assa_left", (-4.0, -3.5, 1.0)), color: None ), right: ( - vox_spec: ("armor.shoulder.assa_right", (-2.0, -3.5, 0.1)), + vox_spec: ("armor.shoulder.assa_right", (-2.0, -3.5, 1.0)), color: None ) ), From 7b770645395cd52c526b2c56b565dd82c015accb Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 12 Mar 2020 20:01:24 +0100 Subject: [PATCH 104/326] mmap visuals --- assets/voxygen/element/frames/mmap.png | 3 ++ assets/voxygen/element/frames/mmap_closed.png | 3 ++ voxygen/src/hud/img_ids.rs | 34 +++++++++---------- 3 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 assets/voxygen/element/frames/mmap.png create mode 100644 assets/voxygen/element/frames/mmap_closed.png diff --git a/assets/voxygen/element/frames/mmap.png b/assets/voxygen/element/frames/mmap.png new file mode 100644 index 0000000000..3c287c5a4d --- /dev/null +++ b/assets/voxygen/element/frames/mmap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a84b2055496d40393a230b8dfa7517c43deefbe7273a0b58e71be758dd0052ee +size 811 diff --git a/assets/voxygen/element/frames/mmap_closed.png b/assets/voxygen/element/frames/mmap_closed.png new file mode 100644 index 0000000000..6eebc68757 --- /dev/null +++ b/assets/voxygen/element/frames/mmap_closed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59c96978315fc3f236573d16b84a6b2add774500ddae669fd1745bd1daa62718 +size 251 diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 8df4663310..8a29379af1 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -67,10 +67,6 @@ image_ids! { tab_small_open: "voxygen.element.frames.tab_small_open", tab_small_closed: "voxygen.element.frames.tab_small_closed", - // MiniMap - mmap_frame: "voxygen.element.frames.mmap", - mmap_frame_closed: "voxygen.element.frames.mmap_closed", - // Missing: Buff Frame Animation .gif ?! we could do animation in ui.maintain, or in shader? window_frame: "voxygen.element.frames.window2", @@ -169,20 +165,6 @@ image_ids! { checkbox_checked: "voxygen.element.buttons.checkbox.active", checkbox_checked_mo: "voxygen.element.buttons.checkbox.hover", - // Buttons - mmap_closed: "voxygen.element.buttons.button_mmap_closed", - mmap_closed_hover: "voxygen.element.buttons.button_mmap_closed_hover", - mmap_closed_press: "voxygen.element.buttons.button_mmap_closed_press", - mmap_open: "voxygen.element.buttons.button_mmap_open", - mmap_open_hover: "voxygen.element.buttons.button_mmap_open_hover", - mmap_open_press: "voxygen.element.buttons.button_mmap_open_press", - mmap_plus: "voxygen.element.buttons.min_plus.mmap_button-plus", - mmap_plus_hover: "voxygen.element.buttons.min_plus.mmap_button-plus_hover", - mmap_plus_press: "voxygen.element.buttons.min_plus.mmap_button-plus_press", - mmap_minus: "voxygen.element.buttons.min_plus.mmap_button-min", - mmap_minus_hover: "voxygen.element.buttons.min_plus.mmap_button-min_hover", - mmap_minus_press: "voxygen.element.buttons.min_plus.mmap_button-min_press", - // Grid grid: "voxygen.element.buttons.grid", grid_hover: "voxygen.element.buttons.grid", @@ -251,6 +233,22 @@ image_ids! { ////////////////////////////////////////////////////////////////////////////////////////////////////// + // MiniMap + mmap_frame: "voxygen.element.frames.mmap", + mmap_frame_closed: "voxygen.element.frames.mmap_closed", + mmap_closed: "voxygen.element.buttons.button_mmap_closed", + mmap_closed_hover: "voxygen.element.buttons.button_mmap_closed_hover", + mmap_closed_press: "voxygen.element.buttons.button_mmap_closed_press", + mmap_open: "voxygen.element.buttons.button_mmap_open", + mmap_open_hover: "voxygen.element.buttons.button_mmap_open_hover", + mmap_open_press: "voxygen.element.buttons.button_mmap_open_press", + mmap_plus: "voxygen.element.buttons.min_plus.mmap_button-plus", + mmap_plus_hover: "voxygen.element.buttons.min_plus.mmap_button-plus_hover", + mmap_plus_press: "voxygen.element.buttons.min_plus.mmap_button-plus_press", + mmap_minus: "voxygen.element.buttons.min_plus.mmap_button-min", + mmap_minus_hover: "voxygen.element.buttons.min_plus.mmap_button-min_hover", + mmap_minus_press: "voxygen.element.buttons.min_plus.mmap_button-min_press", + // Close-Button close_btn: "voxygen.element.buttons.close_btn", close_btn_hover: "voxygen.element.buttons.close_btn_hover", From 19bcbbbd9a3f81e6b177627d085baf01448f600b Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sat, 14 Mar 2020 12:38:52 +0100 Subject: [PATCH 105/326] minimap assets --- assets/voxygen/element/buttons/button_mmap_closed.png | 3 +++ assets/voxygen/element/buttons/button_mmap_closed_hover.png | 3 +++ assets/voxygen/element/buttons/button_mmap_closed_press.png | 3 +++ assets/voxygen/element/buttons/button_mmap_open.png | 3 +++ assets/voxygen/element/buttons/button_mmap_open_hover.png | 3 +++ assets/voxygen/element/buttons/button_mmap_open_press.png | 3 +++ assets/voxygen/element/buttons/min_plus/mmap_button-min.png | 3 +++ .../voxygen/element/buttons/min_plus/mmap_button-min_hover.png | 3 +++ .../voxygen/element/buttons/min_plus/mmap_button-min_press.png | 3 +++ assets/voxygen/element/buttons/min_plus/mmap_button-plus.png | 3 +++ .../element/buttons/min_plus/mmap_button-plus_hover.png | 3 +++ .../element/buttons/min_plus/mmap_button-plus_press.png | 3 +++ 12 files changed, 36 insertions(+) create mode 100644 assets/voxygen/element/buttons/button_mmap_closed.png create mode 100644 assets/voxygen/element/buttons/button_mmap_closed_hover.png create mode 100644 assets/voxygen/element/buttons/button_mmap_closed_press.png create mode 100644 assets/voxygen/element/buttons/button_mmap_open.png create mode 100644 assets/voxygen/element/buttons/button_mmap_open_hover.png create mode 100644 assets/voxygen/element/buttons/button_mmap_open_press.png create mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-min.png create mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png create mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png create mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-plus.png create mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png create mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png diff --git a/assets/voxygen/element/buttons/button_mmap_closed.png b/assets/voxygen/element/buttons/button_mmap_closed.png new file mode 100644 index 0000000000..ed7e72e3b2 --- /dev/null +++ b/assets/voxygen/element/buttons/button_mmap_closed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51583ab772bdfd10fd2414349a985edc5885711d1820132115fd926b51beec42 +size 236 diff --git a/assets/voxygen/element/buttons/button_mmap_closed_hover.png b/assets/voxygen/element/buttons/button_mmap_closed_hover.png new file mode 100644 index 0000000000..ed7e72e3b2 --- /dev/null +++ b/assets/voxygen/element/buttons/button_mmap_closed_hover.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51583ab772bdfd10fd2414349a985edc5885711d1820132115fd926b51beec42 +size 236 diff --git a/assets/voxygen/element/buttons/button_mmap_closed_press.png b/assets/voxygen/element/buttons/button_mmap_closed_press.png new file mode 100644 index 0000000000..ed7e72e3b2 --- /dev/null +++ b/assets/voxygen/element/buttons/button_mmap_closed_press.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51583ab772bdfd10fd2414349a985edc5885711d1820132115fd926b51beec42 +size 236 diff --git a/assets/voxygen/element/buttons/button_mmap_open.png b/assets/voxygen/element/buttons/button_mmap_open.png new file mode 100644 index 0000000000..329028799b --- /dev/null +++ b/assets/voxygen/element/buttons/button_mmap_open.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6bc4dfdf1411e68c2178fbc7db3b4f0d0d0c13d9aee6938be94dd21ccbb95749 +size 247 diff --git a/assets/voxygen/element/buttons/button_mmap_open_hover.png b/assets/voxygen/element/buttons/button_mmap_open_hover.png new file mode 100644 index 0000000000..329028799b --- /dev/null +++ b/assets/voxygen/element/buttons/button_mmap_open_hover.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6bc4dfdf1411e68c2178fbc7db3b4f0d0d0c13d9aee6938be94dd21ccbb95749 +size 247 diff --git a/assets/voxygen/element/buttons/button_mmap_open_press.png b/assets/voxygen/element/buttons/button_mmap_open_press.png new file mode 100644 index 0000000000..329028799b --- /dev/null +++ b/assets/voxygen/element/buttons/button_mmap_open_press.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6bc4dfdf1411e68c2178fbc7db3b4f0d0d0c13d9aee6938be94dd21ccbb95749 +size 247 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min.png new file mode 100644 index 0000000000..e6fe889a2c --- /dev/null +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90ceab9579ba55096e1e0539e3126f49932029004901702fdbadcc08bb988e29 +size 206 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png new file mode 100644 index 0000000000..e6fe889a2c --- /dev/null +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90ceab9579ba55096e1e0539e3126f49932029004901702fdbadcc08bb988e29 +size 206 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png new file mode 100644 index 0000000000..e6fe889a2c --- /dev/null +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90ceab9579ba55096e1e0539e3126f49932029004901702fdbadcc08bb988e29 +size 206 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus.png b/assets/voxygen/element/buttons/min_plus/mmap_button-plus.png new file mode 100644 index 0000000000..efdc3d5662 --- /dev/null +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-plus.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ffde7e0e2994b9889188d516679ff91d39b02fe98419fb100801b4366fdb13d3 +size 220 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png new file mode 100644 index 0000000000..2ece4a15f7 --- /dev/null +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:daf1d5dee847769cad782ba6c50b0e41db7dcc80705e3de1497d79275759a33a +size 226 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png new file mode 100644 index 0000000000..2ece4a15f7 --- /dev/null +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:daf1d5dee847769cad782ba6c50b0e41db7dcc80705e3de1497d79275759a33a +size 226 From 492db3ac5f6e0fb1ec7fb2ce278895a34886ea40 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sat, 14 Mar 2020 14:07:20 +0100 Subject: [PATCH 106/326] minimap position --- assets/voxygen/element/frames/mmap.png | 4 +-- assets/voxygen/element/frames/mmap_closed.png | 4 +-- voxygen/src/hud/minimap.rs | 25 ++++++++----------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/assets/voxygen/element/frames/mmap.png b/assets/voxygen/element/frames/mmap.png index 3c287c5a4d..eeb6cda693 100644 --- a/assets/voxygen/element/frames/mmap.png +++ b/assets/voxygen/element/frames/mmap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a84b2055496d40393a230b8dfa7517c43deefbe7273a0b58e71be758dd0052ee -size 811 +oid sha256:ce0c082da8b364ceb2c5fd36f68a2c66544716cbcb5413a16f27ef23d7c4b9e3 +size 658 diff --git a/assets/voxygen/element/frames/mmap_closed.png b/assets/voxygen/element/frames/mmap_closed.png index 6eebc68757..f3320a0157 100644 --- a/assets/voxygen/element/frames/mmap_closed.png +++ b/assets/voxygen/element/frames/mmap_closed.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:59c96978315fc3f236573d16b84a6b2add774500ddae669fd1745bd1daa62718 -size 251 +oid sha256:e645c34a9e861dff230ac37526cb6194beebd6327a5c23540ed8e41373e41c73 +size 257 diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index 7fd5190b32..b863cebd69 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -103,14 +103,15 @@ impl<'a> Widget for MiniMap<'a> { fn update(self, args: widget::UpdateArgs) -> Self::Event { let widget::UpdateArgs { state, ui, .. } = args; let zoom = state.zoom; + const SCALE: f64 = 1.0; if self.show.mini_map { Image::new(self.imgs.mmap_frame) - .w_h(100.0 * 3.0, 100.0 * 3.0) + .w_h(174.0 * SCALE, 190.0 * SCALE) .top_right_with_margins_on(ui.window, 5.0, 5.0) .set(state.ids.mmap_frame, ui); - Rectangle::fill_with([92.0 * 3.0, 82.0 * 3.0], color::TRANSPARENT) - .mid_top_with_margin_on(state.ids.mmap_frame, 13.0 * 3.0 + 3.0) + Rectangle::fill_with([170.0 * SCALE, 170.0 * SCALE], color::TRANSPARENT) + .mid_top_with_margin_on(state.ids.mmap_frame, 18.0 * SCALE) .set(state.ids.mmap_frame_bg, ui); // Map size @@ -138,7 +139,7 @@ impl<'a> Widget for MiniMap<'a> { let can_zoom_out = zoom > min_zoom; if Button::image(self.imgs.mmap_minus) - .w_h(100.0 * 0.30, 100.0 * 0.30) + .w_h(16.0 * SCALE, 18.0 * SCALE) .hover_image(self.imgs.mmap_minus_hover) .press_image(self.imgs.mmap_minus_press) .top_left_with_margins_on(state.ids.mmap_frame, 0.0, 0.0) @@ -153,10 +154,10 @@ impl<'a> Widget for MiniMap<'a> { // set_image_dims(zoom); } if Button::image(self.imgs.mmap_plus) - .w_h(100.0 * 0.30, 100.0 * 0.30) + .w_h(18.0 * SCALE, 18.0 * SCALE) .hover_image(self.imgs.mmap_plus_hover) .press_image(self.imgs.mmap_plus_press) - .right_from(state.ids.mmap_minus, 6.0) + .right_from(state.ids.mmap_minus, 0.0) .enabled(can_zoom_in) .set(state.ids.mmap_plus, ui) .was_clicked() @@ -195,7 +196,7 @@ impl<'a> Widget for MiniMap<'a> { // Map Image Image::new(world_map.source_north) .middle_of(state.ids.mmap_frame_bg) - .w_h(92.0 * 3.0, 82.0 * 3.0) + .w_h(170.0 * SCALE, 170.0 * SCALE) .parent(state.ids.mmap_frame_bg) .source_rectangle(rect_src) .set(state.ids.grid, ui); @@ -211,8 +212,8 @@ impl<'a> Widget for MiniMap<'a> { .set(state.ids.indicator, ui); } else { Image::new(self.imgs.mmap_frame_closed) - .w_h(100.0 * 2.0, 11.0 * 2.0) - .top_right_with_margins_on(ui.window, 5.0, 5.0) + .w_h(174.0 * SCALE, 18.0 * SCALE) + .top_right_with_margins_on(ui.window, 0.0, 0.0) .set(state.ids.mmap_frame, ui); } @@ -221,11 +222,7 @@ impl<'a> Widget for MiniMap<'a> { } else { self.imgs.mmap_closed }) - .wh(if self.show.mini_map { - [100.0 * 0.3; 2] - } else { - [100.0 * 0.2; 2] - }) + .w_h(18.0 * SCALE, 18.0 * SCALE) .hover_image(if self.show.mini_map { self.imgs.mmap_open_hover } else { From 817cd24d54b72c47453fbd0bd39a2400afbf9278 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sun, 15 Mar 2020 14:21:04 +0100 Subject: [PATCH 107/326] minimap scale --- voxygen/src/hud/minimap.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index b863cebd69..af19d5729a 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -103,11 +103,11 @@ impl<'a> Widget for MiniMap<'a> { fn update(self, args: widget::UpdateArgs) -> Self::Event { let widget::UpdateArgs { state, ui, .. } = args; let zoom = state.zoom; - const SCALE: f64 = 1.0; + const SCALE: f64 = 1.5; if self.show.mini_map { Image::new(self.imgs.mmap_frame) .w_h(174.0 * SCALE, 190.0 * SCALE) - .top_right_with_margins_on(ui.window, 5.0, 5.0) + .top_right_with_margins_on(ui.window, 0.0, 5.0) .set(state.ids.mmap_frame, ui); Rectangle::fill_with([170.0 * SCALE, 170.0 * SCALE], color::TRANSPARENT) @@ -296,15 +296,8 @@ impl<'a> Widget for MiniMap<'a> { // Title match self.client.current_chunk() { Some(chunk) => Text::new(chunk.meta().name()) - .mid_top_with_margin_on( - state.ids.mmap_frame, - if self.show.mini_map { 6.0 } else { 0.0 }, - ) - .font_size( - self.fonts - .cyri - .scale(if self.show.mini_map { 20 } else { 18 }), - ) + .mid_top_with_margin_on(state.ids.mmap_frame, 2.0) + .font_size(self.fonts.cyri.scale(18)) .font_id(self.fonts.cyri.conrod_id) .color(TEXT_COLOR) .set(state.ids.mmap_location, ui), From 1f78344d6f28b8962ee56c97b5829e06aae59fa5 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sun, 15 Mar 2020 19:44:47 +0100 Subject: [PATCH 108/326] Move equipment from loadout into body --- assets/common/items/armor/chest_assassin.ron | 8 - .../items/armor/chest_plate_green-0.ron | 8 - common/src/comp/ability.rs | 4 +- common/src/comp/body/humanoid.rs | 12 -- server/src/events/inventory_manip.rs | 58 +++---- voxygen/src/menu/char_selection/mod.rs | 10 +- voxygen/src/menu/char_selection/ui.rs | 59 +++++-- voxygen/src/scene/figure/cache.rs | 72 +++++---- voxygen/src/scene/figure/load.rs | 148 ++++++++++++++---- voxygen/src/scene/figure/mod.rs | 42 ++--- voxygen/src/scene/simple.rs | 6 +- 11 files changed, 258 insertions(+), 169 deletions(-) delete mode 100644 assets/common/items/armor/chest_assassin.ron delete mode 100644 assets/common/items/armor/chest_plate_green-0.ron diff --git a/assets/common/items/armor/chest_assassin.ron b/assets/common/items/armor/chest_assassin.ron deleted file mode 100644 index 9df179fb06..0000000000 --- a/assets/common/items/armor/chest_assassin.ron +++ /dev/null @@ -1,8 +0,0 @@ -Item( - name: "Assassin Chest", - description: "Only the best for a member of the creed.", - kind: Armor( - kind: Chest(Assassin), - stats: 20, - ), -) diff --git a/assets/common/items/armor/chest_plate_green-0.ron b/assets/common/items/armor/chest_plate_green-0.ron deleted file mode 100644 index a4d9916e63..0000000000 --- a/assets/common/items/armor/chest_plate_green-0.ron +++ /dev/null @@ -1,8 +0,0 @@ -Item( - name: "Iron Chestplate", - description: "Arrows to the stomach are soooo last update.", - kind: Armor( - kind: Chest(PlateGreen0), - stats: 20, - ), -) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 892997b21e..7dbe2fa18a 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -26,7 +26,7 @@ impl Component for CharacterAbility { type Storage = DenseVecStorage; } -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, Debug, Serialize, Deserialize)] pub struct ItemConfig { pub item: Item, pub primary_ability: Option, @@ -35,7 +35,7 @@ pub struct ItemConfig { pub dodge_ability: Option, } -#[derive(Clone, Default, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Hash, Default, Debug, Serialize, Deserialize)] pub struct Loadout { pub active_item: Option, pub second_item: Option, diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index 57c8780d8c..c3deb1232d 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -5,12 +5,6 @@ use vek::Rgb; pub struct Body { pub race: Race, pub body_type: BodyType, - pub chest: Chest, - pub belt: Belt, - pub pants: Pants, - pub hand: Hand, - pub foot: Foot, - pub shoulder: Shoulder, pub hair_style: u8, pub beard: u8, pub eyebrows: Eyebrows, @@ -33,12 +27,6 @@ impl Body { Self { race, body_type, - chest: *(&ALL_CHESTS).choose(rng).unwrap(), - belt: *(&ALL_BELTS).choose(rng).unwrap(), - pants: *(&ALL_PANTS).choose(rng).unwrap(), - hand: *(&ALL_HANDS).choose(rng).unwrap(), - foot: *(&ALL_FEET).choose(rng).unwrap(), - shoulder: *(&ALL_SHOULDERS).choose(rng).unwrap(), hair_style: rng.gen_range(0, race.num_hair_styles(body_type)), beard: rng.gen_range(0, race.num_beards(body_type)), eyebrows: *(&ALL_EYEBROWS).choose(rng).unwrap(), diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index 153109a3cc..7ac4795e93 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -129,48 +129,26 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv if let Some(loadout) = state.ecs().write_storage::().get_mut(entity) { - if let Some(comp::Body::Humanoid(body)) = - state.ecs().write_storage::().get_mut(entity) - { - use comp::item::Armor::*; - let slot = match kind.clone() { - Shoulder(shoulder) => { - body.shoulder = shoulder; - &mut loadout.shoulder - }, - Chest(chest) => { - body.chest = chest; - &mut loadout.chest - }, - Belt(belt) => { - body.belt = belt; - &mut loadout.belt - }, - Hand(hand) => { - body.hand = hand; - &mut loadout.hand - }, - Pants(pants) => { - body.pants = pants; - &mut loadout.pants - }, - Foot(foot) => { - body.foot = foot; - &mut loadout.foot - }, - }; + use comp::item::Armor::*; + let slot = match kind.clone() { + Shoulder(_) => &mut loadout.shoulder, + Chest(_) => &mut loadout.chest, + Belt(_) => &mut loadout.belt, + Hand(_) => &mut loadout.hand, + Pants(_) => &mut loadout.pants, + Foot(_) => &mut loadout.foot, + }; - // Insert old item into inventory - if let Some(old_item) = slot.take() { - state - .ecs() - .write_storage::() - .get_mut(entity) - .map(|inv| inv.insert(slot_idx, old_item)); - } - - *slot = Some(item); + // Insert old item into inventory + if let Some(old_item) = slot.take() { + state + .ecs() + .write_storage::() + .get_mut(entity) + .map(|inv| inv.insert(slot_idx, old_item)); } + + *slot = Some(item); } }, diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index 4fb8b13041..a8c767c9fc 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -112,18 +112,12 @@ impl PlayState for CharSelectionState { } // Render the scene. - let item = self - .char_selection_ui - .get_character_data() - .and_then(|data| data.tool) - .and_then(|tool| assets::load_cloned::(&tool).ok()); - let item_kind = item.map(|i| i.kind); - + let loadout = self.char_selection_ui.get_loadout(); self.scene.render( global_state.window.renderer_mut(), self.client.borrow().get_tick(), humanoid_body.clone(), - item_kind.as_ref(), + loadout, ); // Draw the UI to the screen. diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index 561381b271..e92ac24250 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -12,7 +12,7 @@ use crate::{ }; use client::Client; use common::{ - assets::load_expect, + assets::{load_expect, load_glob}, comp::{self, humanoid}, }; use conrod_core::{ @@ -22,6 +22,7 @@ use conrod_core::{ widget::{text_box::Event as TextBoxEvent, Button, Image, Rectangle, Scrollbar, Text, TextBox}, widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, UiCell, Widget, }; +use std::{borrow::Borrow, sync::Arc}; const STARTER_HAMMER: &str = "common.items.weapons.starter_hammer"; const STARTER_BOW: &str = "common.items.weapons.starter_bow"; @@ -251,6 +252,7 @@ pub enum Mode { Create { name: String, body: humanoid::Body, + loadout: comp::Loadout, tool: Option<&'static str>, }, } @@ -263,7 +265,7 @@ pub struct CharSelectionUi { fonts: ConrodVoxygenFonts, //character_creation: bool, info_content: InfoContent, - voxygen_i18n: std::sync::Arc, + voxygen_i18n: Arc, //deletion_confirmation: bool, /* pub character_name: String, @@ -317,7 +319,12 @@ impl CharSelectionUi { pub fn get_character_data(&self) -> Option { match &self.mode { Mode::Select(data) => data.clone(), - Mode::Create { name, body, tool } => Some(CharacterData { + Mode::Create { + name, + body, + loadout, + tool, + } => Some(CharacterData { name: name.clone(), body: comp::Body::Humanoid(body.clone()), tool: tool.map(|specifier| specifier.to_string()), @@ -325,6 +332,27 @@ impl CharSelectionUi { } } + pub fn get_loadout(&mut self) -> Option<&comp::Loadout> { + match &mut self.mode { + Mode::Select(_) => None, + Mode::Create { + name, + body, + loadout, + tool, + } => { + loadout.active_item = tool.map(|tool| comp::ItemConfig { + item: (*load_expect::(tool)).clone(), + primary_ability: None, + secondary_ability: None, + block_ability: None, + dodge_ability: None, + }); + Some(loadout) + }, + } + } + // TODO: Split this into multiple modules or functions. fn update_layout(&mut self, global_state: &mut GlobalState, client: &Client) -> Vec { let mut events = Vec::new(); @@ -646,13 +674,19 @@ impl CharSelectionUi { self.mode = Mode::Create { name: "Character Name".to_string(), body: humanoid::Body::random(), + loadout: comp::Loadout::default(), tool: Some(STARTER_SWORD), }; } }, // Character_Creation // ////////////////////////////////////////////////////////////////////// - Mode::Create { name, body, tool } => { + Mode::Create { + name, + body, + loadout, + tool, + } => { let mut to_select = false; // Back Button if Button::image(self.imgs.button) @@ -1266,20 +1300,27 @@ impl CharSelectionUi { .set(self.ids.beard_slider, ui_widgets); } // Chest - let current_chest = body.chest; + let armor = load_glob::("common.items.armor.chest.*") + .expect("Unable to load armor!"); if let Some(new_val) = char_slider( self.ids.beard_slider, self.voxygen_i18n.get("char_selection.chest_color"), self.ids.chest_text, - humanoid::ALL_CHESTS.len() - 1, - humanoid::ALL_CHESTS + armor.len() - 1, + armor .iter() - .position(|&c| c == current_chest) + .position(|c| { + loadout + .chest + .as_ref() + .map(|lc| lc == c.borrow()) + .unwrap_or_default() + }) .unwrap_or(0), self.ids.chest_slider, ui_widgets, ) { - body.chest = humanoid::ALL_CHESTS[new_val]; + loadout.chest = Some((*armor[new_val]).clone()); } // Pants /*let current_pants = body.pants; diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 6ad7ae2c09..5cf08e6cac 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -6,7 +6,7 @@ use crate::{ }; use common::{ assets::watch::ReloadIndicator, - comp::{Body, CharacterState, ItemKind}, + comp::{Body, CharacterState, ItemKind, Loadout}, }; use hashbrown::{hash_map::Entry, HashMap}; use std::{ @@ -19,7 +19,7 @@ enum FigureKey { Simple(Body), Complex( Body, - Option, + Option, CameraMode, Option, ), @@ -58,7 +58,7 @@ impl FigureModelCache { &mut self, renderer: &mut Renderer, body: Body, - item_kind: Option<&ItemKind>, + loadout: Option<&Loadout>, tick: u64, camera_mode: CameraMode, character_state: Option<&CharacterState>, @@ -67,10 +67,10 @@ impl FigureModelCache { for<'a> &'a common::comp::Body: std::convert::TryInto, Skel::Attr: Default, { - let key = if item_kind.is_some() { + let key = if loadout.is_some() { FigureKey::Complex( body, - item_kind.cloned(), + loadout.cloned(), camera_mode, character_state.map(|cs| CharacterStateCacheKey::from(cs)), ) @@ -106,6 +106,10 @@ impl FigureModelCache { let humanoid_armor_foot_spec = HumArmorFootSpec::load_watched(&mut self.manifest_indicator); + // TODO: This is bad code, maybe this method should return Option<_> + let default_loadout = Loadout::default(); + let loadout = loadout.unwrap_or(&default_loadout); + [ match camera_mode { CameraMode::ThirdPerson => { @@ -124,21 +128,21 @@ impl FigureModelCache { CameraMode::FirstPerson => None, }, match camera_mode { - CameraMode::ThirdPerson => { - Some(humanoid_armor_chest_spec.mesh_chest(&body)) - }, + CameraMode::ThirdPerson => Some( + humanoid_armor_chest_spec.mesh_chest(&body, loadout), + ), CameraMode::FirstPerson => None, }, match camera_mode { CameraMode::ThirdPerson => { - Some(humanoid_armor_belt_spec.mesh_belt(&body)) + Some(humanoid_armor_belt_spec.mesh_belt(&body, loadout)) }, CameraMode::FirstPerson => None, }, match camera_mode { - CameraMode::ThirdPerson => { - Some(humanoid_armor_pants_spec.mesh_pants(&body)) - }, + CameraMode::ThirdPerson => Some( + humanoid_armor_pants_spec.mesh_pants(&body, loadout), + ), CameraMode::FirstPerson => None, }, if camera_mode == CameraMode::FirstPerson @@ -148,34 +152,42 @@ impl FigureModelCache { { None } else { - Some(humanoid_armor_hand_spec.mesh_left_hand(&body)) + Some( + humanoid_armor_hand_spec.mesh_left_hand(&body, loadout), + ) }, if character_state.map(|cs| cs.is_dodge()).unwrap_or_default() { None } else { - Some(humanoid_armor_hand_spec.mesh_right_hand(&body)) - }, - match camera_mode { - CameraMode::ThirdPerson => { - Some(humanoid_armor_foot_spec.mesh_left_foot(&body)) - }, - CameraMode::FirstPerson => None, - }, - match camera_mode { - CameraMode::ThirdPerson => { - Some(humanoid_armor_foot_spec.mesh_right_foot(&body)) - }, - CameraMode::FirstPerson => None, + Some( + humanoid_armor_hand_spec + .mesh_right_hand(&body, loadout), + ) }, match camera_mode { CameraMode::ThirdPerson => Some( - humanoid_armor_shoulder_spec.mesh_left_shoulder(&body), + humanoid_armor_foot_spec.mesh_left_foot(&body, loadout), ), CameraMode::FirstPerson => None, }, match camera_mode { CameraMode::ThirdPerson => Some( - humanoid_armor_shoulder_spec.mesh_right_shoulder(&body), + humanoid_armor_foot_spec + .mesh_right_foot(&body, loadout), + ), + CameraMode::FirstPerson => None, + }, + match camera_mode { + CameraMode::ThirdPerson => Some( + humanoid_armor_shoulder_spec + .mesh_left_shoulder(&body, loadout), + ), + CameraMode::FirstPerson => None, + }, + match camera_mode { + CameraMode::ThirdPerson => Some( + humanoid_armor_shoulder_spec + .mesh_right_shoulder(&body, loadout), ), CameraMode::FirstPerson => None, }, @@ -187,7 +199,9 @@ impl FigureModelCache { }) .unwrap_or_default() { - Some(mesh_main(item_kind)) + Some(mesh_main( + loadout.active_item.as_ref().map(|i| &i.item.kind), + )) } else { None }, diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 1e66430818..94d98807d9 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -14,11 +14,11 @@ use common::{ Belt, Body, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder, Skin, }, - item::{ToolData, ToolKind}, + item::{Armor, ToolData, ToolKind}, object, quadruped_medium::{BodyType as QMBodyType, Species as QMSpecies}, quadruped_small::{BodyType as QSBodyType, Species as QSSpecies}, - Item, ItemKind, + Item, ItemKind, Loadout, }, figure::{DynaUnionizer, MatSegment, Material, Segment}, }; @@ -293,11 +293,21 @@ impl HumArmorShoulderSpec { .unwrap() } - pub fn mesh_left_shoulder(&self, body: &Body) -> Mesh { - let spec = match self.0.get(&body.shoulder) { + pub fn mesh_left_shoulder(&self, body: &Body, loadout: &Loadout) -> Mesh { + let shoulder = if let Some(ItemKind::Armor { + kind: Armor::Shoulder(shoulder), + .. + }) = loadout.shoulder.as_ref().map(|i| &i.kind) + { + shoulder + } else { + &Shoulder::None + }; + + let spec = match self.0.get(&shoulder) { Some(spec) => spec, None => { - error!("No shoulder specification exists for {:?}", body.shoulder); + error!("No shoulder specification exists for {:?}", shoulder); return load_mesh("not_found", Vec3::new(-3.0, -3.5, 0.1)); }, }; @@ -312,11 +322,21 @@ impl HumArmorShoulderSpec { generate_mesh(&shoulder_segment, Vec3::from(spec.left.vox_spec.1)) } - pub fn mesh_right_shoulder(&self, body: &Body) -> Mesh { - let spec = match self.0.get(&body.shoulder) { + pub fn mesh_right_shoulder(&self, body: &Body, loadout: &Loadout) -> Mesh { + let shoulder = if let Some(ItemKind::Armor { + kind: Armor::Shoulder(shoulder), + .. + }) = loadout.shoulder.as_ref().map(|i| &i.kind) + { + shoulder + } else { + &Shoulder::None + }; + + let spec = match self.0.get(&shoulder) { Some(spec) => spec, None => { - error!("No shoulder specification exists for {:?}", body.shoulder); + error!("No shoulder specification exists for {:?}", shoulder); return load_mesh("not_found", Vec3::new(-2.0, -3.5, 0.1)); }, }; @@ -338,11 +358,21 @@ impl HumArmorChestSpec { .unwrap() } - pub fn mesh_chest(&self, body: &Body) -> Mesh { - let spec = match self.0.get(&body.chest) { + pub fn mesh_chest(&self, body: &Body, loadout: &Loadout) -> Mesh { + let chest = if let Some(ItemKind::Armor { + kind: Armor::Chest(chest), + .. + }) = loadout.chest.as_ref().map(|i| &i.kind) + { + chest + } else { + &Chest::Blue + }; + + let spec = match self.0.get(&chest) { Some(spec) => spec, None => { - error!("No chest specification exists for {:?}", body.chest); + error!("No chest specification exists for {:?}", loadout.chest); return load_mesh("not_found", Vec3::new(-7.0, -3.5, 2.0)); }, }; @@ -381,11 +411,21 @@ impl HumArmorHandSpec { .unwrap() } - pub fn mesh_left_hand(&self, body: &Body) -> Mesh { - let spec = match self.0.get(&body.hand) { + pub fn mesh_left_hand(&self, body: &Body, loadout: &Loadout) -> Mesh { + let hand = if let Some(ItemKind::Armor { + kind: Armor::Hand(hand), + .. + }) = loadout.hand.as_ref().map(|i| &i.kind) + { + hand + } else { + &Hand::Bare + }; + + let spec = match self.0.get(&hand) { Some(spec) => spec, None => { - error!("No hand specification exists for {:?}", body.hand); + error!("No hand specification exists for {:?}", hand); return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0)); }, }; @@ -400,11 +440,21 @@ impl HumArmorHandSpec { generate_mesh(&hand_segment, Vec3::from(spec.left.vox_spec.1)) } - pub fn mesh_right_hand(&self, body: &Body) -> Mesh { - let spec = match self.0.get(&body.hand) { + pub fn mesh_right_hand(&self, body: &Body, loadout: &Loadout) -> Mesh { + let hand = if let Some(ItemKind::Armor { + kind: Armor::Hand(hand), + .. + }) = loadout.hand.as_ref().map(|i| &i.kind) + { + hand + } else { + &Hand::Bare + }; + + let spec = match self.0.get(&hand) { Some(spec) => spec, None => { - error!("No hand specification exists for {:?}", body.hand); + error!("No hand specification exists for {:?}", hand); return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0)); }, }; @@ -426,11 +476,21 @@ impl HumArmorBeltSpec { .unwrap() } - pub fn mesh_belt(&self, body: &Body) -> Mesh { - let spec = match self.0.get(&body.belt) { + pub fn mesh_belt(&self, body: &Body, loadout: &Loadout) -> Mesh { + let belt = if let Some(ItemKind::Armor { + kind: Armor::Belt(belt), + .. + }) = loadout.belt.as_ref().map(|i| &i.kind) + { + belt + } else { + &Belt::Dark + }; + + let spec = match self.0.get(&belt) { Some(spec) => spec, None => { - error!("No belt specification exists for {:?}", body.belt); + error!("No belt specification exists for {:?}", belt); return load_mesh("not_found", Vec3::new(-4.0, -3.5, 2.0)); }, }; @@ -452,11 +512,21 @@ impl HumArmorPantsSpec { .unwrap() } - pub fn mesh_pants(&self, body: &Body) -> Mesh { - let spec = match self.0.get(&body.pants) { + pub fn mesh_pants(&self, body: &Body, loadout: &Loadout) -> Mesh { + let pants = if let Some(ItemKind::Armor { + kind: Armor::Pants(pants), + .. + }) = loadout.pants.as_ref().map(|i| &i.kind) + { + pants + } else { + &Pants::Dark + }; + + let spec = match self.0.get(&pants) { Some(spec) => spec, None => { - error!("No pants specification exists for {:?}", body.pants); + error!("No pants specification exists for {:?}", pants); return load_mesh("not_found", Vec3::new(-5.0, -3.5, 1.0)); }, }; @@ -495,11 +565,21 @@ impl HumArmorFootSpec { .unwrap() } - pub fn mesh_left_foot(&self, body: &Body) -> Mesh { - let spec = match self.0.get(&body.foot) { + pub fn mesh_left_foot(&self, body: &Body, loadout: &Loadout) -> Mesh { + let foot = if let Some(ItemKind::Armor { + kind: Armor::Foot(foot), + .. + }) = loadout.foot.as_ref().map(|i| &i.kind) + { + foot + } else { + &Foot::Bare + }; + + let spec = match self.0.get(&foot) { Some(spec) => spec, None => { - error!("No foot specification exists for {:?}", body.foot); + error!("No foot specification exists for {:?}", foot); return load_mesh("not_found", Vec3::new(-2.5, -3.5, -9.0)); }, }; @@ -514,11 +594,21 @@ impl HumArmorFootSpec { generate_mesh(&foot_segment, Vec3::from(spec.vox_spec.1)) } - pub fn mesh_right_foot(&self, body: &Body) -> Mesh { - let spec = match self.0.get(&body.foot) { + pub fn mesh_right_foot(&self, body: &Body, loadout: &Loadout) -> Mesh { + let foot = if let Some(ItemKind::Armor { + kind: Armor::Foot(foot), + .. + }) = loadout.foot.as_ref().map(|i| &i.kind) + { + foot + } else { + &Foot::Bare + }; + + let spec = match self.0.get(&foot) { Some(spec) => spec, None => { - error!("No foot specification exists for {:?}", body.foot); + error!("No foot specification exists for {:?}", foot); return load_mesh("not_found", Vec3::new(-2.5, -3.5, -9.0)); }, }; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 3e448704b1..85a2ad6de6 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -400,7 +400,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, CameraMode::default(), None, @@ -580,7 +580,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, CameraMode::default(), None, @@ -661,7 +661,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, CameraMode::default(), None, @@ -744,7 +744,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, CameraMode::default(), None, @@ -819,7 +819,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, CameraMode::default(), None, @@ -894,7 +894,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, CameraMode::default(), None, @@ -969,7 +969,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, CameraMode::default(), None, @@ -1044,7 +1044,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, CameraMode::default(), None, @@ -1119,7 +1119,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, CameraMode::default(), None, @@ -1194,7 +1194,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, CameraMode::default(), None, @@ -1386,7 +1386,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, @@ -1402,7 +1402,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, @@ -1418,7 +1418,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, @@ -1434,7 +1434,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, @@ -1450,7 +1450,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, @@ -1466,7 +1466,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, @@ -1482,7 +1482,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, @@ -1498,7 +1498,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, @@ -1514,7 +1514,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, @@ -1530,7 +1530,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, @@ -1546,7 +1546,7 @@ impl FigureMgr { .get_or_create_model( renderer, *body, - active_item_kind, + loadout, tick, player_camera_mode, character_state, diff --git a/voxygen/src/scene/simple.rs b/voxygen/src/scene/simple.rs index eaea94eedf..112f9ba565 100644 --- a/voxygen/src/scene/simple.rs +++ b/voxygen/src/scene/simple.rs @@ -15,7 +15,7 @@ use crate::{ window::{Event, PressState}, }; use common::{ - comp::{humanoid, Body, ItemKind}, + comp::{humanoid, Body, ItemKind, Loadout}, terrain::BlockKind, vol::{BaseVol, ReadVol, Vox}, }; @@ -208,7 +208,7 @@ impl Scene { renderer: &mut Renderer, tick: u64, body: Option, - active_item_kind: Option<&ItemKind>, + loadout: Option<&Loadout>, ) { renderer.render_skybox(&self.skybox.model, &self.globals, &self.skybox.locals); @@ -218,7 +218,7 @@ impl Scene { .get_or_create_model( renderer, Body::Humanoid(body), - active_item_kind, + loadout, tick, CameraMode::default(), None, From db6099a62f8442a8d82a083bdaef3869d6df38e1 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sun, 15 Mar 2020 17:27:56 +0100 Subject: [PATCH 109/326] reenabled inventory slots --- assets/voxygen/element/buttons/inv_slot.png | 3 + .../voxygen/element/buttons/inv_slot_sel.png | 3 + assets/voxygen/element/icons/character.png | 3 + assets/voxygen/element/misc_bg/inv_bg.png | 4 +- assets/voxygen/element/misc_bg/inv_frame.png | 4 +- assets/voxygen/element/slider/scrollbar.png | 3 + assets/voxygen/i18n/en.ron | 4 ++ voxygen/src/hud/bag.rs | 65 +++++++++++++------ voxygen/src/hud/buttons.rs | 47 -------------- voxygen/src/hud/character_window.rs | 4 -- voxygen/src/hud/img_ids.rs | 15 +---- voxygen/src/hud/minimap.rs | 2 +- voxygen/src/hud/mod.rs | 5 ++ 13 files changed, 75 insertions(+), 87 deletions(-) create mode 100644 assets/voxygen/element/buttons/inv_slot.png create mode 100644 assets/voxygen/element/buttons/inv_slot_sel.png create mode 100644 assets/voxygen/element/icons/character.png create mode 100644 assets/voxygen/element/slider/scrollbar.png diff --git a/assets/voxygen/element/buttons/inv_slot.png b/assets/voxygen/element/buttons/inv_slot.png new file mode 100644 index 0000000000..0e90ce0d71 --- /dev/null +++ b/assets/voxygen/element/buttons/inv_slot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ce200dd3b21561d5ddafb2f0a7d22708495185f80aaf84cde4f9160a1494c56 +size 318 diff --git a/assets/voxygen/element/buttons/inv_slot_sel.png b/assets/voxygen/element/buttons/inv_slot_sel.png new file mode 100644 index 0000000000..add7f51049 --- /dev/null +++ b/assets/voxygen/element/buttons/inv_slot_sel.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b1cf070dec414799b192dfcbb2efc96ce04ff50a6f56bf8bd46548e9f0aaa31 +size 316 diff --git a/assets/voxygen/element/icons/character.png b/assets/voxygen/element/icons/character.png new file mode 100644 index 0000000000..06e65f3675 --- /dev/null +++ b/assets/voxygen/element/icons/character.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9e956d538c65f19b705804539b1554cc9216c118812d6cc80300762abeeb625 +size 1297 diff --git a/assets/voxygen/element/misc_bg/inv_bg.png b/assets/voxygen/element/misc_bg/inv_bg.png index 381d68c74f..1c11d8bae4 100644 --- a/assets/voxygen/element/misc_bg/inv_bg.png +++ b/assets/voxygen/element/misc_bg/inv_bg.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cea8c835ac9c4fc78fde2d6b076490be62fba53d335b86c91eb043ff1eb5d7fe -size 32940 +oid sha256:235f3af70c7e62c52213bb224cc0517f0a9121b3849c8774fc7ab2be095550dc +size 32928 diff --git a/assets/voxygen/element/misc_bg/inv_frame.png b/assets/voxygen/element/misc_bg/inv_frame.png index 4af0373848..37d211bcb5 100644 --- a/assets/voxygen/element/misc_bg/inv_frame.png +++ b/assets/voxygen/element/misc_bg/inv_frame.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ea486f92be048030c0977ff28c8babcdca9ac975f1145b8cc4821c18ac2a109b -size 32490 +oid sha256:c1b52a23d27bd2a30ee2493f76dbd226ff3c8c2a67058e95f45cd83fb94ec51a +size 33025 diff --git a/assets/voxygen/element/slider/scrollbar.png b/assets/voxygen/element/slider/scrollbar.png new file mode 100644 index 0000000000..bb606ae6cd --- /dev/null +++ b/assets/voxygen/element/slider/scrollbar.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:350b1c19bad4150ca3b4f3b50992bbac4b772ebf841c747c323b7007e47fda7e +size 519 diff --git a/assets/voxygen/i18n/en.ron b/assets/voxygen/i18n/en.ron index a9ab34bd68..de0078c0b5 100644 --- a/assets/voxygen/i18n/en.ron +++ b/assets/voxygen/i18n/en.ron @@ -190,6 +190,10 @@ Want to free your cursor to close this window? Press TAB! Enjoy your stay in the World of Veloren."#, + + // Inventory + "hud.bag.inventory": "'s Inventory", + // Settings "hud.settings.general": "General", "hud.settings.none": "None", "hud.settings.help_window": "Help Window", diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index cb6061b047..ba3bdbd85c 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -3,11 +3,15 @@ use super::{ item_imgs::{ItemImgs, ItemKey}, Event as HudEvent, TEXT_COLOR, }; -use crate::ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}; +use crate::{ + i18n::VoxygenLocalization, + ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, +}; use client::Client; +use common::comp::Stats; use conrod_core::{ color, image, - widget::{self, Button, Image, Rectangle}, + widget::{self, Button, Image, Rectangle, Text}, widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, }; @@ -28,6 +32,8 @@ widget_ids! { tooltip[], bg, bg_frame, + char_art, + inventory_title, } } @@ -43,6 +49,8 @@ pub struct Bag<'a> { rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, pulse: f32, + localized_strings: &'a std::sync::Arc, + stats: &'a Stats, } impl<'a> Bag<'a> { @@ -54,6 +62,8 @@ impl<'a> Bag<'a> { rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, pulse: f32, + localized_strings: &'a std::sync::Arc, + stats: &'a Stats, ) -> Self { Self { client, @@ -64,6 +74,8 @@ impl<'a> Bag<'a> { rot_imgs, tooltip_manager, pulse, + localized_strings, + stats, } } } @@ -106,7 +118,9 @@ impl<'a> Widget for Bag<'a> { Some(inv) => inv, None => return None, }; - + let exp_percentage = (self.stats.exp.current() as f64) / (self.stats.exp.maximum() as f64); + let exp_treshold = format!("{}/{}", self.stats.exp.current(), self.stats.exp.maximum()); + let level = (self.stats.level.level()).to_string(); // Tooltips let item_tooltip = Tooltip::new({ // Edge images [t, b, r, l] @@ -128,7 +142,6 @@ impl<'a> Widget for Bag<'a> { .desc_text_color(TEXT_COLOR); // BG - Image::new(self.imgs.inv_bg) .w_h(424.0, 708.0) .bottom_right_with_margins_on(ui.window, 60.0, 5.0) @@ -138,6 +151,17 @@ impl<'a> Widget for Bag<'a> { .w_h(424.0, 708.0) .middle_of(state.ids.bg) .set(state.ids.bg_frame, ui); + // Title + Text::new(&format!( + "{}{}", + &self.stats.name, + &self.localized_strings.get("hud.bag.inventory") + )) + .mid_top_with_margin_on(state.ids.bg_frame, 9.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(24)) + .color(TEXT_COLOR) + .set(state.ids.inventory_title, ui); // Close button if Button::image(self.imgs.close_btn) @@ -151,6 +175,17 @@ impl<'a> Widget for Bag<'a> { event = Some(Event::Close); } + // Char Pixel Art + Image::new(self.imgs.char_art) + .w_h(40.0, 37.0) + .top_left_with_margins_on(state.ids.bg, 4.0, 2.0) + .set(state.ids.char_art, ui); + + // Alignment for Grid + Rectangle::fill_with([360.0, 200.0], color::TRANSPARENT) + .bottom_left_with_margins_on(state.ids.bg_frame, 29.0, 44.0) + .scroll_kids_vertically() + .set(state.ids.inv_alignment, ui); /* // Bag parts Image::new(self.imgs.bag_bot) @@ -165,13 +200,7 @@ impl<'a> Widget for Bag<'a> { Image::new(self.imgs.bag_top) .w_h(58.0 * BAG_SCALE, 9.0 * BAG_SCALE) .up_from(state.ids.bag_mid, 0.0) - .set(state.ids.bag_top, ui); - - // Alignment for Grid - Rectangle::fill_with([56.0 * BAG_SCALE, mid_height], color::TRANSPARENT) - .top_left_with_margins_on(state.ids.bag_mid, 0.0, 3.0 * BAG_SCALE) - .scroll_kids_vertically() - .set(state.ids.inv_alignment, ui); + .set(state.ids.bag_top, ui);*/ // Create available inventory slot widgets if state.ids.inv_slots.len() < inventory.len() { @@ -197,8 +226,8 @@ impl<'a> Widget for Bag<'a> { // Display inventory contents for (i, item) in inventory.slots().iter().enumerate() { - let x = i % 5; - let y = i / 5; + let x = i % 9; + let y = i / 9; let is_selected = Some(i) == state.selected_slot; @@ -211,15 +240,15 @@ impl<'a> Widget for Bag<'a> { }) .top_left_with_margins_on( state.ids.inv_alignment, - 0.0 + y as f64 * (40.0 + 2.0), - 0.0 + x as f64 * (40.0 + 2.0), + 0.0 + y as f64 * (40.0), + 0.0 + x as f64 * (40.0), ) .wh(if is_selected { [40.0; 2] } else { [40.0; 2] }) - .image_color(if is_selected { + /*.image_color(if is_selected { color::WHITE } else { color::DARK_YELLOW - }); + })*/; let slot_widget_clicked = if let Some(item) = item { slot_widget @@ -289,8 +318,6 @@ impl<'a> Widget for Bag<'a> { } } - */ - event } } diff --git a/voxygen/src/hud/buttons.rs b/voxygen/src/hud/buttons.rs index 65c0a209c4..0bde14579f 100644 --- a/voxygen/src/hud/buttons.rs +++ b/voxygen/src/hud/buttons.rs @@ -11,8 +11,6 @@ widget_ids! { bag, bag_text, bag_show_map, - character_button, - character_button_bg, map_button, qlog_button, qlog_button_bg, @@ -169,15 +167,6 @@ impl<'a> Widget for Buttons<'a> { .w_h(28.0, 25.0) .left_from(state.ids.map_button, 10.0) .set(state.ids.spellbook_button_bg, ui); - Image::new(self.imgs.character_button) - .w_h(27.0, 25.0) - .left_from(state.ids.spellbook_button_bg, 10.0) - .set(state.ids.character_button_bg, ui); - Image::new(self.imgs.qlog_button) - .w_h(23.0, 25.0) - .left_from(state.ids.character_button_bg, 10.0) - .set(state.ids.qlog_button_bg, ui); - // Other Windows can only be accessed when `Settings` is closed. // Opening `Settings` will close all other Windows, including the `Bag`. // Opening the `Map` won't close the previously displayed windows. @@ -217,42 +206,6 @@ impl<'a> Widget for Buttons<'a> { { return Some(Event::ToggleSpell); } - - // 4 Char-Window - if Button::image(self.imgs.character_button) - .w_h(27.0, 25.0) - .left_from(state.ids.spellbook_button, 10.0) - .hover_image(self.imgs.character_hover) - .press_image(self.imgs.character_press) - .label("C") - .label_font_id(self.fonts.cyri.conrod_id) - .label_font_size(10) - .label_color(TEXT_COLOR) - .label_y(conrod_core::position::Relative::Scalar(-7.0)) - .label_x(conrod_core::position::Relative::Scalar(10.0)) - .set(state.ids.character_button, ui) - .was_clicked() - { - return Some(Event::ToggleCharacter); - } - - // 5 Quest-Log - if Button::image(self.imgs.qlog_button) - .w_h(23.0, 25.0) - .left_from(state.ids.character_button, 10.0) - .hover_image(self.imgs.qlog_hover) - .press_image(self.imgs.qlog_press) - .label("L") - .label_font_id(self.fonts.cyri.conrod_id) - .label_font_size(10) - .label_color(TEXT_COLOR) - .label_y(conrod_core::position::Relative::Scalar(-7.0)) - .label_x(conrod_core::position::Relative::Scalar(10.0)) - .set(state.ids.qlog_button, ui) - .was_clicked() - { - return Some(Event::ToggleQuest); - } } None diff --git a/voxygen/src/hud/character_window.rs b/voxygen/src/hud/character_window.rs index 48b460a16f..699fc9fada 100644 --- a/voxygen/src/hud/character_window.rs +++ b/voxygen/src/hud/character_window.rs @@ -98,10 +98,6 @@ impl<'a> CharacterWindow<'a> { } } -/*pub struct State { - ids: Ids, -}*/ - pub enum Event { Close, } diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 8a29379af1..f5df68929a 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -22,16 +22,6 @@ image_ids! { pub struct Imgs { - // Bag - bag_contents: "voxygen.element.frames.bag", - inv_grid: "voxygen.element.frames.inv_grid", - inv_slot: "voxygen.element.buttons.inv_slot", - inv_slot_sel: "voxygen.element.buttons.inv_slot_sel", - grid_inv: "voxygen.element.buttons.grid_inv", - bag_top: "voxygen.element.bag.top", - bag_mid: "voxygen.element.bag.mid", - bag_bot: "voxygen.element.bag.bot", - // Skillbar xp_bar_mid: "voxygen.element.skillbar.xp_bar_mid", xp_bar_left: "voxygen.element.skillbar.xp_bar_left", @@ -142,7 +132,6 @@ image_ids! { indicator_mmap_3: "voxygen.element.buttons.indicator_mmap_3", // Crosshair - crosshair_outer_round: "voxygen.element.misc_bg.crosshair_outer_1", crosshair_outer_round_edges: "voxygen.element.misc_bg.crosshair_outer_2", crosshair_outer_edges: "voxygen.element.misc_bg.crosshair_outer_3", @@ -153,7 +142,6 @@ image_ids! { crosshair_bg_pressed: "voxygen.element.misc_bg.crosshair_bg_pressed", // Checkboxes and Radio buttons - check: "voxygen.element.buttons.radio.inactive", check_mo: "voxygen.element.buttons.radio.inactive_hover", check_press: "voxygen.element.buttons.radio.press", @@ -257,6 +245,9 @@ image_ids! { // Inventory inv_bg: "voxygen.element.misc_bg.inv_bg", inv_frame: "voxygen.element.misc_bg.inv_frame", + char_art: "voxygen.element.icons.character", + inv_slot: "voxygen.element.buttons.inv_slot", + inv_slot_sel: "voxygen.element.buttons.inv_slot_sel", not_found:"voxygen.element.not_found", diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index af19d5729a..839dbdf462 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -213,7 +213,7 @@ impl<'a> Widget for MiniMap<'a> { } else { Image::new(self.imgs.mmap_frame_closed) .w_h(174.0 * SCALE, 18.0 * SCALE) - .top_right_with_margins_on(ui.window, 0.0, 0.0) + .top_right_with_margins_on(ui.window, 0.0, 5.0) .set(state.ids.mmap_frame, ui); } diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 0cf8986a7f..d1f527e2fb 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1636,6 +1636,9 @@ impl Hud { // Bag contents if self.show.bag { + let ecs = client.state().ecs(); + let stats = ecs.read_storage::(); + let player_stats = stats.get(client.entity()).unwrap(); match Bag::new( client, &self.imgs, @@ -1644,6 +1647,8 @@ impl Hud { &self.rot_imgs, tooltip_manager, self.pulse, + &self.voxygen_i18n, + &player_stats, ) .set(self.ids.bag, ui_widgets) { From 1e9f081f10250bbcf617851d66afa220ff78dbb0 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sun, 15 Mar 2020 19:53:58 +0100 Subject: [PATCH 110/326] include chest models --- assets/common/items/armor/chest/chest_assassin.ron | 8 ++++++++ assets/common/items/armor/chest/chest_plate_green-0.ron | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 assets/common/items/armor/chest/chest_assassin.ron create mode 100644 assets/common/items/armor/chest/chest_plate_green-0.ron diff --git a/assets/common/items/armor/chest/chest_assassin.ron b/assets/common/items/armor/chest/chest_assassin.ron new file mode 100644 index 0000000000..9df179fb06 --- /dev/null +++ b/assets/common/items/armor/chest/chest_assassin.ron @@ -0,0 +1,8 @@ +Item( + name: "Assassin Chest", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Chest(Assassin), + stats: 20, + ), +) diff --git a/assets/common/items/armor/chest/chest_plate_green-0.ron b/assets/common/items/armor/chest/chest_plate_green-0.ron new file mode 100644 index 0000000000..a4d9916e63 --- /dev/null +++ b/assets/common/items/armor/chest/chest_plate_green-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Iron Chestplate", + description: "Arrows to the stomach are soooo last update.", + kind: Armor( + kind: Chest(PlateGreen0), + stats: 20, + ), +) From 87acc01d48ab2e66d8fcc0b54492f1754125c0ee Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 16 Mar 2020 12:32:57 +0100 Subject: [PATCH 111/326] Readd ranged and debug boost. Add bouncing while running in first person --- client/src/lib.rs | 4 +- common/src/comp/ability.rs | 67 +++++++++----- common/src/comp/character_state.rs | 15 ++-- common/src/comp/inventory/item.rs | 45 ++++++++-- common/src/comp/projectile.rs | 6 +- common/src/states/basic_block.rs | 2 +- .../{basic_attack.rs => basic_melee.rs} | 37 ++++---- common/src/states/basic_ranged.rs | 87 +++++++++++++++++++ common/src/states/boost.rs | 59 +++++++++++++ common/src/states/charge_attack.rs | 2 +- common/src/states/climb.rs | 2 +- common/src/states/equipping.rs | 2 +- common/src/states/glide.rs | 2 +- common/src/states/idle.rs | 2 +- common/src/states/mod.rs | 5 +- common/src/states/roll.rs | 2 +- common/src/states/sit.rs | 2 +- common/src/states/timed_combo.rs | 2 +- common/src/states/triple_strike.rs | 2 +- common/src/states/utils.rs | 6 +- common/src/states/wielding.rs | 2 +- common/src/sys/character_behavior.rs | 4 +- common/src/sys/projectile.rs | 7 +- server/src/sys/entity_sync.rs | 10 +-- server/src/sys/sentinel.rs | 2 +- voxygen/src/hud/skillbar.rs | 4 +- voxygen/src/scene/figure/cache.rs | 28 +++--- voxygen/src/scene/figure/mod.rs | 20 ++++- voxygen/src/scene/mod.rs | 13 ++- 29 files changed, 336 insertions(+), 105 deletions(-) rename common/src/states/{basic_attack.rs => basic_melee.rs} (75%) create mode 100644 common/src/states/basic_ranged.rs create mode 100644 common/src/states/boost.rs diff --git a/client/src/lib.rs b/client/src/lib.rs index 56147e5fb7..0b97b35bc8 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -393,11 +393,11 @@ impl Client { { if last_character_states .get(entity) - .map(|&l| !client_character_state.equals(&l.0)) + .map(|l| !client_character_state.equals(&l.0)) .unwrap_or(true) { let _ = last_character_states - .insert(entity, comp::Last(*client_character_state)); + .insert(entity, comp::Last(client_character_state.clone())); } } } diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 7dbe2fa18a..04cb2a3ea2 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1,17 +1,27 @@ use crate::{ - comp::{CharacterState, Item, ToolData}, + comp::{Body, CharacterState, Item, Projectile, ToolData}, states::*, }; use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage}; use std::time::Duration; +use vek::vec::Vec3; -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] pub enum CharacterAbility { - BasicAttack { + BasicMelee { buildup_duration: Duration, recover_duration: Duration, base_damage: u32, }, + BasicRanged { + recover_duration: Duration, + projectile: Projectile, + projectile_body: Body, + }, + Boost { + duration: Duration, + only_up: bool, + }, BasicBlock, Roll, ChargeAttack, @@ -26,7 +36,7 @@ impl Component for CharacterAbility { type Storage = DenseVecStorage; } -#[derive(Clone, PartialEq, Eq, Hash, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] pub struct ItemConfig { pub item: Item, pub primary_ability: Option, @@ -35,7 +45,7 @@ pub struct ItemConfig { pub dodge_ability: Option, } -#[derive(Clone, PartialEq, Eq, Hash, Default, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Default, Debug, Serialize, Deserialize)] pub struct Loadout { pub active_item: Option, pub second_item: Option, @@ -48,39 +58,52 @@ pub struct Loadout { pub foot: Option, } -impl From for CharacterState { - fn from(ability: CharacterAbility) -> Self { +impl From<&CharacterAbility> for CharacterState { + fn from(ability: &CharacterAbility) -> Self { match ability { - CharacterAbility::BasicAttack { + CharacterAbility::BasicMelee { buildup_duration, recover_duration, base_damage, - } => CharacterState::BasicAttack(basic_attack::Data { + } => CharacterState::BasicMelee(basic_melee::Data { exhausted: false, - buildup_duration, - recover_duration, - base_damage, + buildup_duration: *buildup_duration, + recover_duration: *recover_duration, + base_damage: *base_damage, }), - CharacterAbility::BasicBlock { .. } => CharacterState::BasicBlock, - CharacterAbility::Roll { .. } => CharacterState::Roll(roll::Data { + CharacterAbility::BasicRanged { + recover_duration, + projectile, + projectile_body, + } => CharacterState::BasicRanged(basic_ranged::Data { + exhausted: false, + prepare_timer: Duration::default(), + recover_duration: *recover_duration, + projectile: projectile.clone(), + projectile_body: *projectile_body, + }), + CharacterAbility::Boost { duration, only_up } => CharacterState::Boost(boost::Data { + duration: *duration, + only_up: *only_up, + }), + CharacterAbility::BasicBlock => CharacterState::BasicBlock, + CharacterAbility::Roll => CharacterState::Roll(roll::Data { + remaining_duration: Duration::from_millis(600), + }), + CharacterAbility::ChargeAttack => CharacterState::ChargeAttack(charge_attack::Data { remaining_duration: Duration::from_millis(600), }), - CharacterAbility::ChargeAttack { .. } => { - CharacterState::ChargeAttack(charge_attack::Data { - remaining_duration: Duration::from_millis(600), - }) - }, CharacterAbility::TimedCombo { buildup_duration, recover_duration, base_damage, } => CharacterState::TimedCombo(timed_combo::Data { - buildup_duration, - recover_duration, + buildup_duration: *buildup_duration, + recover_duration: *recover_duration, stage: 0, stage_exhausted: false, stage_time_active: Duration::default(), - base_damage, + base_damage: *base_damage, }), } } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 6c4ae39be9..e741e0393a 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -18,7 +18,7 @@ pub struct StateUpdate { pub server_events: VecDeque, } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum CharacterState { Idle, Climb, @@ -34,8 +34,12 @@ pub enum CharacterState { ChargeAttack(charge_attack::Data), /// A dodge where player can roll Roll(roll::Data), - /// A basic attacking state - BasicAttack(basic_attack::Data), + /// A basic melee attack (e.g. sword) + BasicMelee(basic_melee::Data), + /// A basic ranged attack (e.g. bow) + BasicRanged(basic_ranged::Data), + /// A force will boost you into a direction for some duration + Boost(boost::Data), /// A three-stage attack where play must click at appropriate times /// to continue attack chain. TimedCombo(timed_combo::Data), @@ -48,7 +52,7 @@ impl CharacterState { pub fn is_wield(&self) -> bool { match self { CharacterState::Wielding - | CharacterState::BasicAttack(_) + | CharacterState::BasicMelee(_) | CharacterState::TimedCombo(_) | CharacterState::BasicBlock => true, _ => false, @@ -57,7 +61,8 @@ impl CharacterState { pub fn is_attack(&self) -> bool { match self { - CharacterState::BasicAttack(_) + CharacterState::BasicMelee(_) + | CharacterState::BasicRanged(_) | CharacterState::TimedCombo(_) | CharacterState::ChargeAttack(_) => true, _ => false, diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 07e3e05dda..7777bde801 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -1,6 +1,9 @@ use crate::{ assets::{self, Asset}, - comp::{body::humanoid, CharacterAbility}, + comp::{ + body::{humanoid, object}, + projectile, Body, CharacterAbility, HealthChange, HealthSource, Projectile, + }, effect::Effect, terrain::{Block, BlockKind}, }; @@ -37,35 +40,61 @@ impl ToolData { use ToolKind::*; match self.kind { - Sword(_) => vec![BasicAttack { + Sword(_) => vec![BasicMelee { buildup_duration: Duration::from_millis(100), recover_duration: Duration::from_millis(500), base_damage: 60, }], - Axe => vec![BasicAttack { + Axe => vec![BasicMelee { buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(100), base_damage: 80, }], - Hammer => vec![BasicAttack { + Hammer => vec![BasicMelee { buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(300), base_damage: 100, }], - Bow => vec![], - Dagger => vec![BasicAttack { + Bow => vec![BasicRanged { + projectile: Projectile { + hit_ground: vec![projectile::Effect::Stick], + hit_wall: vec![projectile::Effect::Stick], + hit_entity: vec![ + projectile::Effect::Damage(HealthChange { + // TODO: This should not be fixed (?) + amount: -30, + cause: HealthSource::Item, + }), + projectile::Effect::Vanish, + ], + time_left: Duration::from_secs(15), + owner: None, + }, + projectile_body: Body::Object(object::Body::Arrow), + recover_duration: Duration::from_millis(300), + }], + Dagger => vec![BasicMelee { buildup_duration: Duration::from_millis(100), recover_duration: Duration::from_millis(400), base_damage: 50, }], - Staff => vec![BasicAttack { + Staff => vec![BasicMelee { buildup_duration: Duration::from_millis(400), recover_duration: Duration::from_millis(300), base_damage: 70, }], Shield => vec![], Debug(kind) => match kind { - Boost => vec![], + DebugKind::Boost => vec![ + CharacterAbility::Boost { + duration: Duration::from_millis(100), + only_up: false, + }, + CharacterAbility::Boost { + duration: Duration::from_millis(100), + only_up: true, + }, + ], Possess => vec![], }, } diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 785c1e318d..27e997b08e 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -3,7 +3,7 @@ use specs::{Component, FlaggedStorage}; use specs_idvs::IDVStorage; use std::time::Duration; -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum Effect { Damage(comp::HealthChange), Vanish, @@ -11,15 +11,15 @@ pub enum Effect { Possess, } -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Projectile { - pub owner: Uid, // TODO: use SmallVec for these effects pub hit_ground: Vec, pub hit_wall: Vec, pub hit_entity: Vec, /// Time left until the projectile will despawn pub time_left: Duration, + pub owner: Option, } impl Component for Projectile { diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index efb78ad323..e238a488b5 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -18,7 +18,7 @@ impl CharacterBehavior for Data { vel: *data.vel, ori: *data.ori, energy: *data.energy, - character: *data.character, + character: data.character.clone(), local_events: VecDeque::new(), server_events: VecDeque::new(), }; diff --git a/common/src/states/basic_attack.rs b/common/src/states/basic_melee.rs similarity index 75% rename from common/src/states/basic_attack.rs rename to common/src/states/basic_melee.rs index b81fba8de1..25dbe9bd6b 100644 --- a/common/src/states/basic_attack.rs +++ b/common/src/states/basic_melee.rs @@ -1,6 +1,6 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, StateUpdate}, - states::{utils::*, wielding}, + states::utils::*, sys::character_behavior::*, }; use std::{collections::VecDeque, time::Duration}; @@ -24,16 +24,16 @@ impl CharacterBehavior for Data { vel: *data.vel, ori: *data.ori, energy: *data.energy, - character: *data.character, + character: data.character.clone(), local_events: VecDeque::new(), server_events: VecDeque::new(), }; handle_move(data, &mut update); - // Build up if self.buildup_duration != Duration::default() { - update.character = CharacterState::BasicAttack(Data { + // Build up + update.character = CharacterState::BasicMelee(Data { buildup_duration: self .buildup_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) @@ -42,9 +42,8 @@ impl CharacterBehavior for Data { base_damage: self.base_damage, exhausted: false, }); - } - // Hit attempt - else if !self.exhausted { + } else if !self.exhausted { + // Hit attempt if let Some(tool) = unwrap_tool_data(data) { data.updater.insert(data.entity, Attacking { base_damage: self.base_damage, @@ -53,16 +52,15 @@ impl CharacterBehavior for Data { }); } - update.character = CharacterState::BasicAttack(Data { + update.character = CharacterState::BasicMelee(Data { buildup_duration: self.buildup_duration, recover_duration: self.recover_duration, base_damage: self.base_damage, exhausted: true, }); - } - // Recovery - else if self.recover_duration != Duration::default() { - update.character = CharacterState::BasicAttack(Data { + } else if self.recover_duration != Duration::default() { + // Recovery + update.character = CharacterState::BasicMelee(Data { buildup_duration: self.buildup_duration, recover_duration: self .recover_duration @@ -71,16 +69,11 @@ impl CharacterBehavior for Data { base_damage: self.base_damage, exhausted: true, }); - } - // Done - else { - if let Some(tool) = unwrap_tool_data(data) { - update.character = CharacterState::Wielding; - // Make sure attack component is removed - data.updater.remove::(data.entity); - } else { - update.character = CharacterState::Idle; - } + } else { + // Done + update.character = CharacterState::Wielding; + // Make sure attack component is removed + data.updater.remove::(data.entity); } // Grant energy on successful hit diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs new file mode 100644 index 0000000000..533759d031 --- /dev/null +++ b/common/src/states/basic_ranged.rs @@ -0,0 +1,87 @@ +use crate::{ + comp::{Attacking, Body, CharacterState, EnergySource, Gravity, Projectile, StateUpdate}, + event::ServerEvent, + states::{utils::*, wielding}, + sys::character_behavior::*, +}; +use std::{collections::VecDeque, time::Duration}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Data { + /// How long we prepared the weapon already + pub prepare_timer: Duration, + /// How long the state has until exiting + pub recover_duration: Duration, + /// Projectile + pub projectile: Projectile, + /// Projectile + pub projectile_body: Body, + /// Whether the attack fired already + pub exhausted: bool, +} + +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: data.character.clone(), + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + + handle_move(data, &mut update); + handle_jump(data, &mut update); + + if !self.exhausted + && (data.inputs.primary.is_pressed() | data.inputs.secondary.is_pressed()) + { + // Prepare (draw the bow) + update.character = CharacterState::BasicRanged(Data { + prepare_timer: self.prepare_timer + Duration::from_secs_f32(data.dt.0), + recover_duration: self.recover_duration, + projectile: self.projectile.clone(), + projectile_body: self.projectile_body, + exhausted: false, + }); + } else if !self.exhausted { + // Fire + update.server_events.push_front(ServerEvent::Shoot { + entity: data.entity, + dir: data.inputs.look_dir, + body: self.projectile_body, + light: None, + projectile: self.projectile.clone(), + gravity: Some(Gravity(0.1)), + }); + + update.character = CharacterState::BasicRanged(Data { + prepare_timer: self.prepare_timer, + recover_duration: self.recover_duration, + projectile: self.projectile.clone(), + projectile_body: self.projectile_body, + exhausted: true, + }); + } else if self.recover_duration != Duration::default() { + // Recovery + update.character = CharacterState::BasicRanged(Data { + prepare_timer: self.prepare_timer, + recover_duration: self + .recover_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), + projectile: self.projectile.clone(), + projectile_body: self.projectile_body, + exhausted: true, + }); + return update; + } else { + // Done + update.character = CharacterState::Wielding; + } + + update + } +} diff --git a/common/src/states/boost.rs b/common/src/states/boost.rs new file mode 100644 index 0000000000..7acfd6bc80 --- /dev/null +++ b/common/src/states/boost.rs @@ -0,0 +1,59 @@ +use crate::{ + comp::{Attacking, CharacterState, EnergySource, StateUpdate}, + states::{utils::*, wielding}, + sys::character_behavior::*, +}; +use std::{collections::VecDeque, time::Duration}; + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Data { + /// How long the state has until exiting + pub duration: Duration, + pub only_up: bool, +} + +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: data.character.clone(), + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + + handle_move(data, &mut update); + + // Still going + if self.duration != Duration::default() { + if self.only_up { + update.vel.0.z = 30.0; + } else { + update.vel.0 = data.inputs.look_dir * 30.0; + } + update.character = CharacterState::Boost(Data { + duration: self + .duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), + only_up: self.only_up, + }); + } + // Done + else { + update.character = CharacterState::Wielding; + } + + // Grant energy on successful hit + if let Some(attack) = data.attacking { + if attack.applied && attack.hit_count > 0 { + data.updater.remove::(data.entity); + update.energy.change_by(100, EnergySource::HitEnemy); + } + } + + update + } +} diff --git a/common/src/states/charge_attack.rs b/common/src/states/charge_attack.rs index af479613b1..6c41e1ffeb 100644 --- a/common/src/states/charge_attack.rs +++ b/common/src/states/charge_attack.rs @@ -21,7 +21,7 @@ impl CharacterBehavior for Data { pos: *data.pos, vel: *data.vel, ori: *data.ori, - character: *data.character, + character: data.character.clone(), energy: *data.energy, local_events: VecDeque::new(), server_events: VecDeque::new(), diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 0bff46fdad..27f51c8da5 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -24,7 +24,7 @@ impl CharacterBehavior for Data { pos: *data.pos, vel: *data.vel, ori: *data.ori, - character: *data.character, + character: data.character.clone(), energy: *data.energy, local_events: VecDeque::new(), server_events: VecDeque::new(), diff --git a/common/src/states/equipping.rs b/common/src/states/equipping.rs index 9fac0bbd83..66506e39c8 100644 --- a/common/src/states/equipping.rs +++ b/common/src/states/equipping.rs @@ -14,7 +14,7 @@ pub struct Data { impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate { - character: *data.character, + character: data.character.clone(), pos: *data.pos, vel: *data.vel, ori: *data.ori, diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 78851f006a..4d7a73eddf 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -20,7 +20,7 @@ impl CharacterBehavior for Data { vel: *data.vel, ori: *data.ori, energy: *data.energy, - character: *data.character, + character: data.character.clone(), local_events: VecDeque::new(), server_events: VecDeque::new(), }; diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index 7d78d9b73f..76be0b8f67 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -10,7 +10,7 @@ pub struct Data; impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate { - character: *data.character, + character: data.character.clone(), pos: *data.pos, vel: *data.vel, ori: *data.ori, diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 3598c5f7fb..f66ee24ffe 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -1,6 +1,7 @@ -// Module declarations -pub mod basic_attack; pub mod basic_block; +pub mod basic_melee; +pub mod basic_ranged; +pub mod boost; pub mod charge_attack; pub mod climb; pub mod equipping; diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 8d57e56546..2d0795d95c 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -15,7 +15,7 @@ pub struct Data { impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate { - character: *data.character, + character: data.character.clone(), pos: *data.pos, vel: *data.vel, ori: *data.ori, diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index 407e176c01..487206094a 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -11,7 +11,7 @@ pub struct Data; impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate { - character: *data.character, + character: data.character.clone(), pos: *data.pos, vel: *data.vel, ori: *data.ori, diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index 7687852645..cd7cd7b9d9 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -26,7 +26,7 @@ impl CharacterBehavior for Data { vel: *data.vel, ori: *data.ori, energy: *data.energy, - character: *data.character, + character: data.character.clone(), local_events: VecDeque::new(), server_events: VecDeque::new(), }; diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index fd10f3ccb6..2fe224f265 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -33,7 +33,7 @@ impl CharacterBehavior for Data { vel: *data.vel, ori: *data.ori, energy: *data.energy, - character: *data.character, + character: data.character.clone(), local_events: VecDeque::new(), server_events: VecDeque::new(), }; diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 9312256ea4..85136661a6 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -195,7 +195,7 @@ pub fn attempt_primary_ability(data: &JoinData, update: &mut StateUpdate) { .loadout .active_item .as_ref() - .and_then(|i| i.primary_ability) + .and_then(|i| i.primary_ability.as_ref()) { update.character = ability.into(); } @@ -217,7 +217,7 @@ pub fn attempt_secondary_ability(data: &JoinData, update: &mut StateUpdate) { .loadout .active_item .as_ref() - .and_then(|i| i.secondary_ability) + .and_then(|i| i.secondary_ability.as_ref()) { update.character = ability.into(); } @@ -246,7 +246,7 @@ pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { .loadout .active_item .as_ref() - .and_then(|i| i.dodge_ability) + .and_then(|i| i.dodge_ability.as_ref()) { update.character = ability.into(); } diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 6d2aaa491a..07f5ba358c 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -10,7 +10,7 @@ pub struct Data; impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate { - character: *data.character, + character: data.character.clone(), pos: *data.pos, vel: *data.vel, ori: *data.ori, diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 1217a98147..ed2247749b 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -182,7 +182,9 @@ impl<'a> System<'a> for Sys { CharacterState::Equipping(data) => data.behavior(&j), CharacterState::ChargeAttack(data) => data.behavior(&j), CharacterState::TripleStrike(data) => data.behavior(&j), - CharacterState::BasicAttack(data) => data.behavior(&j), + CharacterState::BasicMelee(data) => data.behavior(&j), + CharacterState::BasicRanged(data) => data.behavior(&j), + CharacterState::Boost(data) => data.behavior(&j), CharacterState::TimedCombo(data) => data.behavior(&j), // Do not use default match. diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index 99c1cc42bf..168035a4ca 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -77,8 +77,11 @@ impl<'a> System<'a> for Sys { entity, cause: HealthSource::World, }), - projectile::Effect::Possess => server_emitter - .emit(ServerEvent::Possess(projectile.owner.into(), other)), + projectile::Effect::Possess => { + if let Some(owner) = projectile.owner { + server_emitter.emit(ServerEvent::Possess(owner.into(), other)); + } + }, _ => {}, } } diff --git a/server/src/sys/entity_sync.rs b/server/src/sys/entity_sync.rs index d32eb3e1d2..f9a5dcfe19 100644 --- a/server/src/sys/entity_sync.rs +++ b/server/src/sys/entity_sync.rs @@ -283,17 +283,17 @@ impl<'a> System<'a> for Sys { } } - if let Some(&character_state) = character_state { + if let Some(&character_state) = character_state.as_ref() { if last_character_state .get(entity) - .map(|&l| !character_state.equals(&l.0)) + .map(|l| !character_state.equals(&l.0)) .unwrap_or(true) { - let _ = last_character_state.insert(entity, Last(character_state)); + let _ = last_character_state.insert(entity, Last(character_state.clone())); send_msg( ServerMsg::EntityCharacterState { entity: uid.into(), - character_state, + character_state: character_state.clone(), }, entity, pos, @@ -367,7 +367,7 @@ pub fn send_initial_unsynced_components( if let Some(&ori) = ori { client.notify(ServerMsg::EntityOri { entity, ori }); } - if let Some(&character_state) = character_state { + if let Some(character_state) = character_state.cloned() { client.notify(ServerMsg::EntityCharacterState { entity, character_state, diff --git a/server/src/sys/sentinel.rs b/server/src/sys/sentinel.rs index 382e1aa27c..d9db6bbded 100644 --- a/server/src/sys/sentinel.rs +++ b/server/src/sys/sentinel.rs @@ -112,7 +112,7 @@ impl<'a> TrackedComps<'a> { .map(|c| comps.push(c.into())); self.character_state .get(entity) - .copied() + .cloned() .map(|c| comps.push(c.into())); EntityPackage { uid, comps } diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 98414df9a6..877132222d 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -543,7 +543,7 @@ impl<'a> Widget for Skillbar<'a> { // M1 Slot match self.character_state { - CharacterState::BasicAttack { .. } => { + CharacterState::BasicMelee { .. } => { if self.controller.primary.is_pressed() { let fade_pulse = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.6; //Animation timer; Image::new(self.imgs.skillbar_slot_big) @@ -654,7 +654,7 @@ impl<'a> Widget for Skillbar<'a> { .set(state.ids.m2_slot, ui); } },*/ - CharacterState::BasicAttack { .. } => { + CharacterState::BasicMelee { .. } => { let fade_pulse = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.6; //Animation timer; if self.controller.secondary.is_pressed() { Image::new(self.imgs.skillbar_slot_big) diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 5cf08e6cac..b8a00539a1 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -6,7 +6,7 @@ use crate::{ }; use common::{ assets::watch::ReloadIndicator, - comp::{Body, CharacterState, ItemKind, Loadout}, + comp::{Body, CharacterState, ItemKind, Loadout, ToolKind}, }; use hashbrown::{hash_map::Entry, HashMap}; use std::{ @@ -17,23 +17,26 @@ use std::{ #[derive(PartialEq, Eq, Hash, Clone)] enum FigureKey { Simple(Body), - Complex( - Body, - Option, - CameraMode, - Option, - ), + Complex(Body, CameraMode, Option), } #[derive(PartialEq, Eq, Hash, Clone)] -struct CharacterStateCacheKey { +struct CharacterCacheKey { state: Discriminant, // TODO: Can this be simplified? + active_tool: Option>, // TODO: Can this be simplified? } -impl From<&CharacterState> for CharacterStateCacheKey { - fn from(cs: &CharacterState) -> Self { +impl CharacterCacheKey { + fn from(cs: &CharacterState, loadout: &Loadout) -> Self { Self { state: discriminant(&cs), + active_tool: if let Some(ItemKind::Tool(tool)) = + loadout.active_item.as_ref().map(|i| &i.item.kind) + { + Some(discriminant(&tool.kind)) + } else { + None + }, } } } @@ -67,12 +70,11 @@ impl FigureModelCache { for<'a> &'a common::comp::Body: std::convert::TryInto, Skel::Attr: Default, { - let key = if loadout.is_some() { + let key = if let Some(loadout) = loadout { FigureKey::Complex( body, - loadout.cloned(), camera_mode, - character_state.map(|cs| CharacterStateCacheKey::from(cs)), + character_state.map(|cs| CharacterCacheKey::from(cs, loadout)), ) } else { FigureKey::Simple(body) diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 85a2ad6de6..50015d73ba 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -468,7 +468,25 @@ impl FigureMgr { skeleton_attr, ) }, - CharacterState::BasicAttack(_) => { + CharacterState::BasicMelee(_) => { + anim::character::AttackAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, + CharacterState::BasicRanged(_) => { + anim::character::AttackAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, + CharacterState::Boost(_) => { anim::character::AttackAnimation::update_skeleton( &target_base, (active_tool_kind, time), diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index c0c97ecf38..a5517e134c 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -188,6 +188,13 @@ impl Scene { .get(scene_data.player_entity) .map_or(false, |cs| cs.is_dodge()); + let player_running = scene_data + .state + .ecs() + .read_storage::() + .get(scene_data.player_entity) + .map_or(false, |v| v.0.magnitude_squared() > 0.5); + let player_scale = match scene_data .state .ecs() @@ -211,9 +218,11 @@ impl Scene { let up = match self.camera.get_mode() { CameraMode::FirstPerson => { if player_rolling { - player_scale * 0.8_f32 + player_scale * 0.8 + } else if player_running { + player_scale * 1.6 + (scene_data.state.get_time() as f32 * 17.0).sin() * 0.05 } else { - player_scale * 1.6_f32 + player_scale * 1.6 } }, CameraMode::ThirdPerson => 1.2, From 4195273cf984dba2d616226c42157361cac5995c Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 16 Mar 2020 13:19:51 +0100 Subject: [PATCH 112/326] Adjust first person camera and underwater wield orientation --- common/src/states/utils.rs | 5 ++++- common/src/sys/combat.rs | 2 +- voxygen/src/scene/camera.rs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 85136661a6..e3c36f1887 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -84,7 +84,10 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { }; // Set direction based on move direction when on the ground - let ori_dir = if update.character.is_attack() || update.character.is_block() { + let ori_dir = if update.character.is_wield() + || update.character.is_attack() + || update.character.is_block() + { Vec2::from(data.inputs.look_dir).normalized() } else { Vec2::from(update.vel.0) diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 0ee15f7211..f5ebc3e0ea 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -14,7 +14,7 @@ use vek::*; const BLOCK_EFFICIENCY: f32 = 0.9; const ATTACK_RANGE: f32 = 3.5; -const ATTACK_ANGLE: f32 = 45.0; +const ATTACK_ANGLE: f32 = 70.0; const BLOCK_ANGLE: f32 = 180.0; /// This system is responsible for handling accepted inputs like moving or diff --git a/voxygen/src/scene/camera.rs b/voxygen/src/scene/camera.rs index 9eb279d3c5..bb29781c25 100644 --- a/voxygen/src/scene/camera.rs +++ b/voxygen/src/scene/camera.rs @@ -6,7 +6,7 @@ use vek::*; const NEAR_PLANE: f32 = 0.5; const FAR_PLANE: f32 = 100000.0; -const FIRST_PERSON_INTERP_TIME: f32 = 0.05; +const FIRST_PERSON_INTERP_TIME: f32 = 0.1; const THIRD_PERSON_INTERP_TIME: f32 = 0.1; pub const MIN_ZOOM: f32 = 0.1; From 1279f7018422eb1b363aa980485857af9ba5fe1c Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 16 Mar 2020 13:40:14 +0100 Subject: [PATCH 113/326] Add shield item --- assets/common/items/weapons/shield_1.ron | 10 ++++++++++ assets/voxygen/item_image_manifest.ron | 2 +- common/src/comp/inventory/item.rs | 2 +- common/src/states/basic_block.rs | 4 +++- voxygen/src/scene/figure/load.rs | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 assets/common/items/weapons/shield_1.ron diff --git a/assets/common/items/weapons/shield_1.ron b/assets/common/items/weapons/shield_1.ron new file mode 100644 index 0000000000..23dd6b0ddb --- /dev/null +++ b/assets/common/items/weapons/shield_1.ron @@ -0,0 +1,10 @@ +Item( + name: "A Shield", + description: "Legends tell this item is useless.", + kind: Tool ( + ToolData ( + kind: Shield, + equip_time_millis: 400, + ) + ), +) diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index 3d8d53ce24..1705c5119c 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -29,7 +29,7 @@ ), Tool(Shield): VoxTrans( "voxel.weapon.shield.wood-0", - (0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4, + (0.0, 0.0, 0.0), (-90.0, 90.0, 0.0), 2.4, ), Utility(Collar): VoxTrans( "element.icons.collar", diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 7777bde801..fcad410845 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -83,7 +83,7 @@ impl ToolData { recover_duration: Duration::from_millis(300), base_damage: 70, }], - Shield => vec![], + Shield => vec![BasicBlock], Debug(kind) => match kind { DebugKind::Boost => vec![ CharacterAbility::Boost { diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index e238a488b5..7b95b934be 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -25,7 +25,9 @@ impl CharacterBehavior for Data { handle_move(&data, &mut update); - if !data.physics.on_ground || !data.inputs.secondary.is_pressed() { + if !data.physics.on_ground + || !(data.inputs.secondary.is_pressed() || data.inputs.primary.is_pressed()) + { attempt_wield(data, &mut update); } update diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 94d98807d9..158b389bb4 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -632,7 +632,7 @@ pub fn mesh_main(item_kind: Option<&ItemKind>) -> Mesh { ToolKind::Axe => ("weapon.axe.rusty_2h", Vec3::new(-1.5, -5.0, -4.0)), ToolKind::Hammer => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)), ToolKind::Dagger => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)), - ToolKind::Shield => ("weapon.axe.rusty_2h", Vec3::new(-2.5, -6.5, -2.0)), + ToolKind::Shield => ("weapon.shield.wood-0", Vec3::new(-2.5, -6.5, -2.0)), ToolKind::Bow => ("weapon.bow.simple-bow", Vec3::new(-1.0, -6.0, -2.0)), ToolKind::Staff => ("weapon.staff.wood-fire", Vec3::new(-1.0, -6.0, -3.0)), ToolKind::Debug(_) => ("weapon.debug_wand", Vec3::new(-1.5, -9.5, -4.0)), From 81591fcaf73d0d5f58568181105709081f22f004 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 16 Mar 2020 14:27:52 +0100 Subject: [PATCH 114/326] Make npcs attack again --- common/src/comp/inventory/item.rs | 14 ++++++ common/src/states/basic_melee.rs | 12 +++--- server/src/sys/terrain.rs | 72 ++++++++++++++++++++++--------- voxygen/src/anim/character/mod.rs | 2 + voxygen/src/anim/mod.rs | 2 + voxygen/src/hud/item_imgs.rs | 1 + voxygen/src/scene/figure/load.rs | 1 + 7 files changed, 76 insertions(+), 28 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index fcad410845..7c168b205a 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -29,6 +29,8 @@ pub enum ToolKind { Staff, Shield, Debug(DebugKind), + /// This is an placeholder item, it is used by non-humanoid npcs to attack + Empty, } impl ToolData { @@ -97,6 +99,7 @@ impl ToolData { ], Possess => vec![], }, + Empty => vec![], } } } @@ -182,6 +185,17 @@ impl Asset for Item { } impl Item { + pub fn empty() -> Self { + Self { + name: "Empty Item".to_owned(), + description: "This item may grant abilities, but is invisible".to_owned(), + kind: ItemKind::Tool(ToolData { + kind: ToolKind::Empty, + equip_time_millis: 0, + }), + } + } + pub fn name(&self) -> &str { &self.name } pub fn description(&self) -> &str { &self.description } diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 25dbe9bd6b..1f972e0594 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -44,13 +44,11 @@ impl CharacterBehavior for Data { }); } else if !self.exhausted { // Hit attempt - if let Some(tool) = unwrap_tool_data(data) { - data.updater.insert(data.entity, Attacking { - base_damage: self.base_damage, - applied: false, - hit_count: 0, - }); - } + data.updater.insert(data.entity, Attacking { + base_damage: self.base_damage, + applied: false, + hit_count: 0, + }); update.character = CharacterState::BasicMelee(Data { buildup_duration: self.buildup_duration, diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 9a0f4eec07..2224afd53d 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -2,7 +2,7 @@ use super::SysTimer; use crate::{chunk_generator::ChunkGenerator, client::Client, Tick}; use common::{ assets, - comp::{self, item, Player, Pos}, + comp::{self, item, CharacterAbility, Item, ItemConfig, Player, Pos}, event::{EventBus, ServerEvent}, generation::EntityKind, msg::ServerMsg, @@ -12,7 +12,7 @@ use common::{ }; use rand::{seq::SliceRandom, Rng}; use specs::{Join, Read, ReadStorage, System, Write, WriteExpect, WriteStorage}; -use std::sync::Arc; +use std::{sync::Arc, time::Duration}; use vek::*; /// This system will handle loading generated chunks and unloading @@ -181,22 +181,50 @@ impl<'a> System<'a> for Sys { .expect("SPAWN_NPCS is nonempty")( ); let mut stats = comp::Stats::new(name, body); - let mut loadout = comp::Loadout { - active_item: main.map(|item| comp::ItemConfig { - item, - primary_ability: None, - secondary_ability: None, - block_ability: None, - dodge_ability: None, - }), - second_item: None, - shoulder: None, - chest: None, - belt: None, - hand: None, - pants: None, - foot: None, - }; + + let mut loadout = + if let Some(comp::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) { + let mut abilities = tool.get_abilities(); + let mut ability_drain = abilities.drain(..); + + comp::Loadout { + active_item: main.map(|item| comp::ItemConfig { + item, + primary_ability: ability_drain.next(), + secondary_ability: ability_drain.next(), + block_ability: Some(comp::CharacterAbility::BasicBlock), + dodge_ability: Some(comp::CharacterAbility::Roll), + }), + second_item: None, + shoulder: None, + chest: None, + belt: None, + hand: None, + pants: None, + foot: None, + } + } else { + comp::Loadout { + active_item: Some(ItemConfig { + item: Item::empty(), + primary_ability: Some(CharacterAbility::BasicMelee { + buildup_duration: Duration::from_millis(50), + recover_duration: Duration::from_millis(50), + base_damage: 10, + }), + secondary_ability: None, + block_ability: None, + dodge_ability: None, + }), + second_item: None, + shoulder: None, + chest: None, + belt: None, + hand: None, + pants: None, + foot: None, + } + }; let mut scale = 1.0; @@ -220,9 +248,11 @@ impl<'a> System<'a> for Sys { loadout = comp::Loadout { active_item: Some(comp::ItemConfig { item: assets::load_expect_cloned("common.items.weapons.hammer_1"), - primary_ability: None, /* TODO: when implementing this, make sure - * to adjust the base damage (see todo - * below) */ + primary_ability: Some(CharacterAbility::BasicMelee { + buildup_duration: Duration::from_millis(800), + recover_duration: Duration::from_millis(200), + base_damage: 130, + }), secondary_ability: None, block_ability: None, dodge_ability: None, diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 1fb83a2cbb..952d8f149f 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -236,6 +236,7 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr { ToolKind::Bow => 0.0, ToolKind::Dagger => 0.0, ToolKind::Debug(_) => 0.0, + ToolKind::Empty => 0.0, }, weapon_y: match ToolKind::Hammer { ToolKind::Sword(_) => -1.25, @@ -246,6 +247,7 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr { ToolKind::Bow => -2.0, ToolKind::Dagger => -2.0, ToolKind::Debug(_) => 0.0, + ToolKind::Empty => 0.0, }, } } diff --git a/voxygen/src/anim/mod.rs b/voxygen/src/anim/mod.rs index df32446f5c..c09fbc3e97 100644 --- a/voxygen/src/anim/mod.rs +++ b/voxygen/src/anim/mod.rs @@ -176,6 +176,7 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr { ToolKind::Bow => 0.0, ToolKind::Dagger => 0.0, ToolKind::Debug(_) => 0.0, + ToolKind::Empty => 0.0, }, weapon_y: match ToolKind::Hammer { // TODO: Inventory @@ -187,6 +188,7 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr { ToolKind::Bow => -2.0, ToolKind::Dagger => -2.0, ToolKind::Debug(_) => 0.0, + ToolKind::Empty => 0.0, }, } } diff --git a/voxygen/src/hud/item_imgs.rs b/voxygen/src/hud/item_imgs.rs index c35db25eab..863a5b4e8c 100644 --- a/voxygen/src/hud/item_imgs.rs +++ b/voxygen/src/hud/item_imgs.rs @@ -19,6 +19,7 @@ pub enum ItemKey { Utility(Utility), Consumable(Consumable), Ingredient(Ingredient), + Empty, } impl From<&Item> for ItemKey { fn from(item: &Item) -> Self { diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 158b389bb4..2ecebb6cb3 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -636,6 +636,7 @@ pub fn mesh_main(item_kind: Option<&ItemKind>) -> Mesh { ToolKind::Bow => ("weapon.bow.simple-bow", Vec3::new(-1.0, -6.0, -2.0)), ToolKind::Staff => ("weapon.staff.wood-fire", Vec3::new(-1.0, -6.0, -3.0)), ToolKind::Debug(_) => ("weapon.debug_wand", Vec3::new(-1.5, -9.5, -4.0)), + ToolKind::Empty => return Mesh::new(), }, _ => return Mesh::new(), }; From d5db1f6ca0587758bbe2e313ca665ba183169e72 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 16 Mar 2020 16:34:53 +0100 Subject: [PATCH 115/326] Add dash ability to sword M2 --- common/src/comp/ability.rs | 15 +++++ common/src/comp/character_state.rs | 2 + common/src/comp/inventory/item.rs | 17 +++-- common/src/states/dash_melee.rs | 95 ++++++++++++++++++++++++++++ common/src/states/mod.rs | 1 + common/src/sys/character_behavior.rs | 1 + voxygen/src/scene/figure/mod.rs | 9 +++ 7 files changed, 135 insertions(+), 5 deletions(-) create mode 100644 common/src/states/dash_melee.rs diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 04cb2a3ea2..2faf68ce69 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -22,6 +22,11 @@ pub enum CharacterAbility { duration: Duration, only_up: bool, }, + DashMelee { + buildup_duration: Duration, + recover_duration: Duration, + base_damage: u32, + }, BasicBlock, Roll, ChargeAttack, @@ -86,6 +91,16 @@ impl From<&CharacterAbility> for CharacterState { duration: *duration, only_up: *only_up, }), + CharacterAbility::DashMelee { + buildup_duration, + recover_duration, + base_damage, + } => CharacterState::DashMelee(dash_melee::Data { + exhausted: false, + buildup_duration: *buildup_duration, + recover_duration: *recover_duration, + base_damage: *base_damage, + }), CharacterAbility::BasicBlock => CharacterState::BasicBlock, CharacterAbility::Roll => CharacterState::Roll(roll::Data { remaining_duration: Duration::from_millis(600), diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index e741e0393a..66edd98f7b 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -40,6 +40,8 @@ pub enum CharacterState { BasicRanged(basic_ranged::Data), /// A force will boost you into a direction for some duration Boost(boost::Data), + /// Dash forward and then attack + DashMelee(dash_melee::Data), /// A three-stage attack where play must click at appropriate times /// to continue attack chain. TimedCombo(timed_combo::Data), diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 7c168b205a..488944305c 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -42,11 +42,18 @@ impl ToolData { use ToolKind::*; match self.kind { - Sword(_) => vec![BasicMelee { - buildup_duration: Duration::from_millis(100), - recover_duration: Duration::from_millis(500), - base_damage: 60, - }], + Sword(_) => vec![ + BasicMelee { + buildup_duration: Duration::from_millis(100), + recover_duration: Duration::from_millis(500), + base_damage: 60, + }, + DashMelee { + buildup_duration: Duration::from_millis(500), + recover_duration: Duration::from_millis(500), + base_damage: 200, + }, + ], Axe => vec![BasicMelee { buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(100), diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs new file mode 100644 index 0000000000..a58eb31d62 --- /dev/null +++ b/common/src/states/dash_melee.rs @@ -0,0 +1,95 @@ +use crate::{ + comp::{Attacking, CharacterState, EnergySource, StateUpdate}, + states::utils::*, + sys::character_behavior::*, +}; +use std::{collections::VecDeque, time::Duration}; +use vek::Vec3; + +const DASH_SPEED: f32 = 19.0; + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub struct Data { + /// How long until state should deal damage + pub buildup_duration: Duration, + /// How long the state has until exiting + pub recover_duration: Duration, + /// Base damage + pub base_damage: u32, + /// Whether the attack can deal more damage + pub exhausted: bool, +} + +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + character: data.character.clone(), + local_events: VecDeque::new(), + server_events: VecDeque::new(), + }; + + if self.buildup_duration != Duration::default() && data.physics.touch_entity.is_none() { + // Build up (this will move you forward) + update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) + + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) + + 1.5 * data.inputs.move_dir.try_normalized().unwrap_or_default()) + .try_normalized() + .unwrap_or_default() + * DASH_SPEED; + + update.character = CharacterState::DashMelee(Data { + buildup_duration: self + .buildup_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), + recover_duration: self.recover_duration, + base_damage: self.base_damage, + exhausted: false, + }); + } else if !self.exhausted { + // Hit attempt + data.updater.insert(data.entity, Attacking { + base_damage: self.base_damage, + applied: false, + hit_count: 0, + }); + + update.character = CharacterState::DashMelee(Data { + buildup_duration: Duration::default(), + recover_duration: self.recover_duration, + base_damage: self.base_damage, + exhausted: true, + }); + } else if self.recover_duration != Duration::default() { + // Recovery + update.character = CharacterState::DashMelee(Data { + buildup_duration: self.buildup_duration, + recover_duration: self + .recover_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), + base_damage: self.base_damage, + exhausted: true, + }); + } else { + // Done + update.character = CharacterState::Wielding; + // Make sure attack component is removed + data.updater.remove::(data.entity); + } + + // Grant energy on successful hit + if let Some(attack) = data.attacking { + if attack.applied && attack.hit_count > 0 { + data.updater.remove::(data.entity); + update.energy.change_by(100, EnergySource::HitEnemy); + } + } + + update + } +} diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index f66ee24ffe..ecffe1b987 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -4,6 +4,7 @@ pub mod basic_ranged; pub mod boost; pub mod charge_attack; pub mod climb; +pub mod dash_melee; pub mod equipping; pub mod glide; pub mod idle; diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index ed2247749b..c235e78388 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -185,6 +185,7 @@ impl<'a> System<'a> for Sys { CharacterState::BasicMelee(data) => data.behavior(&j), CharacterState::BasicRanged(data) => data.behavior(&j), CharacterState::Boost(data) => data.behavior(&j), + CharacterState::DashMelee(data) => data.behavior(&j), CharacterState::TimedCombo(data) => data.behavior(&j), // Do not use default match. diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 50015d73ba..4d26413607 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -495,6 +495,15 @@ impl FigureMgr { skeleton_attr, ) }, + CharacterState::DashMelee(_) => { + anim::character::AttackAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, CharacterState::TimedCombo(s) => match s.stage { 0 | 2 => anim::character::AttackAnimation::update_skeleton( &target_base, From ab8b83f8d6781f8d2cf75ec6ff4b772afddc085e Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sun, 15 Mar 2020 21:33:51 +0100 Subject: [PATCH 116/326] more bag parts --- .../element/buttons/inv_tab_active.png | 3 + .../element/buttons/inv_tab_inactive.png | 3 + .../buttons/inv_tab_inactive_hover.png | 3 + .../buttons/inv_tab_inactive_press.png | 3 + voxygen/src/hud/bag.rs | 107 ++++++++++++++---- voxygen/src/hud/buttons.rs | 4 - voxygen/src/hud/img_ids.rs | 6 + voxygen/src/hud/mod.rs | 2 - 8 files changed, 100 insertions(+), 31 deletions(-) create mode 100644 assets/voxygen/element/buttons/inv_tab_active.png create mode 100644 assets/voxygen/element/buttons/inv_tab_inactive.png create mode 100644 assets/voxygen/element/buttons/inv_tab_inactive_hover.png create mode 100644 assets/voxygen/element/buttons/inv_tab_inactive_press.png diff --git a/assets/voxygen/element/buttons/inv_tab_active.png b/assets/voxygen/element/buttons/inv_tab_active.png new file mode 100644 index 0000000000..ce2804598a --- /dev/null +++ b/assets/voxygen/element/buttons/inv_tab_active.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a75353f7382969b8d780f8cc66066b1c7a36e8d5fa6b55c743207e4be5960f9 +size 272 diff --git a/assets/voxygen/element/buttons/inv_tab_inactive.png b/assets/voxygen/element/buttons/inv_tab_inactive.png new file mode 100644 index 0000000000..1dc0acd186 --- /dev/null +++ b/assets/voxygen/element/buttons/inv_tab_inactive.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ad7f5d7662ba295592272ed80281428e18b779021f0ae15d9485d88581be32b +size 340 diff --git a/assets/voxygen/element/buttons/inv_tab_inactive_hover.png b/assets/voxygen/element/buttons/inv_tab_inactive_hover.png new file mode 100644 index 0000000000..1dc0acd186 --- /dev/null +++ b/assets/voxygen/element/buttons/inv_tab_inactive_hover.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ad7f5d7662ba295592272ed80281428e18b779021f0ae15d9485d88581be32b +size 340 diff --git a/assets/voxygen/element/buttons/inv_tab_inactive_press.png b/assets/voxygen/element/buttons/inv_tab_inactive_press.png new file mode 100644 index 0000000000..1dc0acd186 --- /dev/null +++ b/assets/voxygen/element/buttons/inv_tab_inactive_press.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ad7f5d7662ba295592272ed80281428e18b779021f0ae15d9485d88581be32b +size 340 diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index ba3bdbd85c..81b1c3a4b3 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -12,15 +12,12 @@ use common::comp::Stats; use conrod_core::{ color, image, widget::{self, Button, Image, Rectangle, Text}, - widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, + widget_ids, Color, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon, }; widget_ids! { struct Ids { bag_close, - bag_top, - bag_mid, - bag_bot, inv_alignment, inv_grid_1, inv_grid_2, @@ -34,6 +31,13 @@ widget_ids! { bg_frame, char_art, inventory_title, + inventory_title_bg, + scrollbar_bg, + stats_button, + tab_1, + tab_2, + tab_3, + tab_4, } } @@ -84,10 +88,9 @@ pub struct State { ids: Ids, img_id_cache: Vec>, selected_slot: Option, + stats_show: bool, } -const BAG_SCALE: f64 = 4.0; - pub enum Event { HudEvent(HudEvent), Close, @@ -103,6 +106,7 @@ impl<'a> Widget for Bag<'a> { ids: Ids::new(id_gen), img_id_cache: Vec::new(), selected_slot: None, + stats_show: false, } } @@ -121,6 +125,7 @@ impl<'a> Widget for Bag<'a> { let exp_percentage = (self.stats.exp.current() as f64) / (self.stats.exp.maximum() as f64); let exp_treshold = format!("{}/{}", self.stats.exp.current(), self.stats.exp.maximum()); let level = (self.stats.level.level()).to_string(); + // Tooltips let item_tooltip = Tooltip::new({ // Edge images [t, b, r, l] @@ -159,7 +164,17 @@ impl<'a> Widget for Bag<'a> { )) .mid_top_with_margin_on(state.ids.bg_frame, 9.0) .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(24)) + .font_size(self.fonts.cyri.scale(22)) + .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) + .set(state.ids.inventory_title_bg, ui); + Text::new(&format!( + "{}{}", + &self.stats.name, + &self.localized_strings.get("hud.bag.inventory") + )) + .top_left_with_margins_on(state.ids.inventory_title_bg, 2.0, 2.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(22)) .color(TEXT_COLOR) .set(state.ids.inventory_title, ui); @@ -174,33 +189,75 @@ impl<'a> Widget for Bag<'a> { { event = Some(Event::Close); } + // Tabs + if Button::image(self.imgs.inv_tab_active) + .w_h(28.0, 44.0) + .bottom_left_with_margins_on(state.ids.bg, 172.0, 13.0) + .set(state.ids.tab_1, ui) + .was_clicked() + {} + if Button::image(self.imgs.inv_tab_inactive) + .w_h(28.0, 44.0) + .hover_image(self.imgs.inv_tab_inactive_hover) + .press_image(self.imgs.inv_tab_inactive_press) + .down_from(state.ids.tab_1, 0.0) + .with_tooltip(self.tooltip_manager, "Not yet Available", "", &item_tooltip) + .set(state.ids.tab_2, ui) + .was_clicked() + {} + if Button::image(self.imgs.inv_tab_inactive) + .w_h(28.0, 44.0) + .hover_image(self.imgs.inv_tab_inactive_hover) + .press_image(self.imgs.inv_tab_inactive_press) + .down_from(state.ids.tab_2, 0.0) + .with_tooltip(self.tooltip_manager, "Not yet Available", "", &item_tooltip) + .set(state.ids.tab_3, ui) + .was_clicked() + {} + if Button::image(self.imgs.inv_tab_inactive) + .w_h(28.0, 44.0) + .hover_image(self.imgs.inv_tab_inactive_hover) + .press_image(self.imgs.inv_tab_inactive_press) + .down_from(state.ids.tab_3, 0.0) + .with_tooltip(self.tooltip_manager, "Not yet Available", "", &item_tooltip) + .set(state.ids.tab_4, ui) + .was_clicked() + {} - // Char Pixel Art + // Scrollbar-BG + Image::new(self.imgs.scrollbar_bg) + .w_h(9.0, 173.0) + .bottom_right_with_margins_on(state.ids.bg_frame, 42.0, 3.0) + .set(state.ids.scrollbar_bg, ui); + + // Char Pixel-Art Image::new(self.imgs.char_art) .w_h(40.0, 37.0) .top_left_with_margins_on(state.ids.bg, 4.0, 2.0) .set(state.ids.char_art, ui); // Alignment for Grid - Rectangle::fill_with([360.0, 200.0], color::TRANSPARENT) + Rectangle::fill_with([362.0, 200.0], color::TRANSPARENT) .bottom_left_with_margins_on(state.ids.bg_frame, 29.0, 44.0) .scroll_kids_vertically() .set(state.ids.inv_alignment, ui); - /* - // Bag parts - Image::new(self.imgs.bag_bot) - .w_h(58.0 * BAG_SCALE, 9.0 * BAG_SCALE) - .bottom_right_with_margins_on(ui.window, 60.0, 5.0) - .set(state.ids.bag_bot, ui); - let mid_height = ((inventory.len() + 4) / 5) as f64 * 44.0; - Image::new(self.imgs.bag_mid) - .w_h(58.0 * BAG_SCALE, mid_height) - .up_from(state.ids.bag_bot, 0.0) - .set(state.ids.bag_mid, ui); - Image::new(self.imgs.bag_top) - .w_h(58.0 * BAG_SCALE, 9.0 * BAG_SCALE) - .up_from(state.ids.bag_mid, 0.0) - .set(state.ids.bag_top, ui);*/ + + // Stats Button + if Button::image(self.imgs.button) + .w_h(92.0, 22.0) + .mid_top_with_margin_on(state.ids.bg, 435.0) + .hover_image(self.imgs.button_hover) + .press_image(self.imgs.button_press) + .label(if state.stats_show { "Armor" } else { "Stats" }) + .label_y(conrod_core::position::Relative::Scalar(1.0)) + .label_color(TEXT_COLOR) + .label_font_size(self.fonts.cyri.scale(12)) + .label_font_id(self.fonts.cyri.conrod_id) + .set(state.ids.stats_button, ui) + .was_clicked() + { + //state.stats_show = !state.stats_show; + }; // Create available inventory slot widgets if state.ids.inv_slots.len() < inventory.len() { @@ -243,7 +300,7 @@ impl<'a> Widget for Bag<'a> { 0.0 + y as f64 * (40.0), 0.0 + x as f64 * (40.0), ) - .wh(if is_selected { [40.0; 2] } else { [40.0; 2] }) + .wh([40.0; 2]) /*.image_color(if is_selected { color::WHITE } else { diff --git a/voxygen/src/hud/buttons.rs b/voxygen/src/hud/buttons.rs index 0bde14579f..7cc9b7b0c2 100644 --- a/voxygen/src/hud/buttons.rs +++ b/voxygen/src/hud/buttons.rs @@ -12,8 +12,6 @@ widget_ids! { bag_text, bag_show_map, map_button, - qlog_button, - qlog_button_bg, settings_button, social_button, social_button_bg, @@ -63,8 +61,6 @@ pub enum Event { ToggleMap, ToggleSocial, ToggleSpell, - ToggleQuest, - ToggleCharacter, } impl<'a> Widget for Buttons<'a> { diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index f5df68929a..0f53593b6f 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -248,6 +248,12 @@ image_ids! { char_art: "voxygen.element.icons.character", inv_slot: "voxygen.element.buttons.inv_slot", inv_slot_sel: "voxygen.element.buttons.inv_slot_sel", + scrollbar_bg: "voxygen.element.slider.scrollbar", + inv_tab_active: "voxygen.element.buttons.inv_tab_active", + inv_tab_inactive: "voxygen.element.buttons.inv_tab_inactive", + inv_tab_inactive_hover: "voxygen.element.buttons.inv_tab_inactive", + inv_tab_inactive_press: "voxygen.element.buttons.inv_tab_inactive", + not_found:"voxygen.element.not_found", diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index d1f527e2fb..cc3506da85 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1611,10 +1611,8 @@ impl Hud { { Some(buttons::Event::ToggleBag) => self.show.toggle_bag(), Some(buttons::Event::ToggleSettings) => self.show.toggle_settings(), - Some(buttons::Event::ToggleCharacter) => self.show.toggle_char_window(), Some(buttons::Event::ToggleSocial) => self.show.toggle_social(), Some(buttons::Event::ToggleSpell) => self.show.toggle_spell(), - Some(buttons::Event::ToggleQuest) => self.show.toggle_quest(), Some(buttons::Event::ToggleMap) => self.show.toggle_map(), None => {}, } From b9f61d4e7a86933ecfd07a65bf42ab7c22351c74 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Mon, 16 Mar 2020 18:48:10 +0100 Subject: [PATCH 117/326] UI colourable in the code, stats window --- .../element/buttons/button_mmap_closed.png | 4 +- .../buttons/button_mmap_closed_hover.png | 4 +- .../buttons/button_mmap_closed_press.png | 4 +- .../element/buttons/button_mmap_open.png | 4 +- .../buttons/button_mmap_open_hover.png | 4 +- .../buttons/button_mmap_open_press.png | 4 +- .../element/buttons/inv_tab_active.png | 4 +- .../element/buttons/inv_tab_inactive.png | 4 +- .../buttons/min_plus/mmap_button-plus.png | 4 +- .../min_plus/mmap_button-plus_hover.png | 4 +- .../min_plus/mmap_button-plus_press.png | 4 +- .../element/frames/divider_charwindow.vox | 4 +- assets/voxygen/element/frames/mmap.png | 4 +- assets/voxygen/element/frames/mmap_closed.png | 4 +- assets/voxygen/element/frames/mmap_frame.png | 3 + assets/voxygen/element/misc_bg/charwindow.png | 4 +- assets/voxygen/element/misc_bg/inv_bg.png | 4 +- assets/voxygen/element/misc_bg/inv_frame.png | 4 +- assets/voxygen/element/misc_bg/inv_runes.png | 3 + assets/voxygen/element/misc_bg/inv_slots.png | 3 + assets/voxygen/element/slider/scrollbar.png | 4 +- voxygen/src/hud/bag.rs | 228 ++++++++++++------ voxygen/src/hud/character_window.rs | 10 - voxygen/src/hud/img_ids.rs | 3 + voxygen/src/hud/minimap.rs | 16 +- voxygen/src/hud/mod.rs | 12 + 26 files changed, 233 insertions(+), 117 deletions(-) create mode 100644 assets/voxygen/element/frames/mmap_frame.png create mode 100644 assets/voxygen/element/misc_bg/inv_runes.png create mode 100644 assets/voxygen/element/misc_bg/inv_slots.png diff --git a/assets/voxygen/element/buttons/button_mmap_closed.png b/assets/voxygen/element/buttons/button_mmap_closed.png index ed7e72e3b2..b6c98ef5d8 100644 --- a/assets/voxygen/element/buttons/button_mmap_closed.png +++ b/assets/voxygen/element/buttons/button_mmap_closed.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51583ab772bdfd10fd2414349a985edc5885711d1820132115fd926b51beec42 -size 236 +oid sha256:73c7c79a8803598a53977b35a7a1594b97a6b6e9eea9056b414392d3abb81e8e +size 256 diff --git a/assets/voxygen/element/buttons/button_mmap_closed_hover.png b/assets/voxygen/element/buttons/button_mmap_closed_hover.png index ed7e72e3b2..b6c98ef5d8 100644 --- a/assets/voxygen/element/buttons/button_mmap_closed_hover.png +++ b/assets/voxygen/element/buttons/button_mmap_closed_hover.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51583ab772bdfd10fd2414349a985edc5885711d1820132115fd926b51beec42 -size 236 +oid sha256:73c7c79a8803598a53977b35a7a1594b97a6b6e9eea9056b414392d3abb81e8e +size 256 diff --git a/assets/voxygen/element/buttons/button_mmap_closed_press.png b/assets/voxygen/element/buttons/button_mmap_closed_press.png index ed7e72e3b2..b6c98ef5d8 100644 --- a/assets/voxygen/element/buttons/button_mmap_closed_press.png +++ b/assets/voxygen/element/buttons/button_mmap_closed_press.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51583ab772bdfd10fd2414349a985edc5885711d1820132115fd926b51beec42 -size 236 +oid sha256:73c7c79a8803598a53977b35a7a1594b97a6b6e9eea9056b414392d3abb81e8e +size 256 diff --git a/assets/voxygen/element/buttons/button_mmap_open.png b/assets/voxygen/element/buttons/button_mmap_open.png index 329028799b..f175132005 100644 --- a/assets/voxygen/element/buttons/button_mmap_open.png +++ b/assets/voxygen/element/buttons/button_mmap_open.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6bc4dfdf1411e68c2178fbc7db3b4f0d0d0c13d9aee6938be94dd21ccbb95749 -size 247 +oid sha256:0ecd12bed8f6b7d33fb243e8a77c167685e34e85d0a9889dfa0d0c7045937526 +size 273 diff --git a/assets/voxygen/element/buttons/button_mmap_open_hover.png b/assets/voxygen/element/buttons/button_mmap_open_hover.png index 329028799b..f175132005 100644 --- a/assets/voxygen/element/buttons/button_mmap_open_hover.png +++ b/assets/voxygen/element/buttons/button_mmap_open_hover.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6bc4dfdf1411e68c2178fbc7db3b4f0d0d0c13d9aee6938be94dd21ccbb95749 -size 247 +oid sha256:0ecd12bed8f6b7d33fb243e8a77c167685e34e85d0a9889dfa0d0c7045937526 +size 273 diff --git a/assets/voxygen/element/buttons/button_mmap_open_press.png b/assets/voxygen/element/buttons/button_mmap_open_press.png index 329028799b..f175132005 100644 --- a/assets/voxygen/element/buttons/button_mmap_open_press.png +++ b/assets/voxygen/element/buttons/button_mmap_open_press.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6bc4dfdf1411e68c2178fbc7db3b4f0d0d0c13d9aee6938be94dd21ccbb95749 -size 247 +oid sha256:0ecd12bed8f6b7d33fb243e8a77c167685e34e85d0a9889dfa0d0c7045937526 +size 273 diff --git a/assets/voxygen/element/buttons/inv_tab_active.png b/assets/voxygen/element/buttons/inv_tab_active.png index ce2804598a..4619392a71 100644 --- a/assets/voxygen/element/buttons/inv_tab_active.png +++ b/assets/voxygen/element/buttons/inv_tab_active.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a75353f7382969b8d780f8cc66066b1c7a36e8d5fa6b55c743207e4be5960f9 -size 272 +oid sha256:641d77903cb71d36a99c9551e418d73ee6b2bf85039f3a6546aaea9770072e0e +size 305 diff --git a/assets/voxygen/element/buttons/inv_tab_inactive.png b/assets/voxygen/element/buttons/inv_tab_inactive.png index 1dc0acd186..159c2e45e1 100644 --- a/assets/voxygen/element/buttons/inv_tab_inactive.png +++ b/assets/voxygen/element/buttons/inv_tab_inactive.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4ad7f5d7662ba295592272ed80281428e18b779021f0ae15d9485d88581be32b -size 340 +oid sha256:2e46d4152a06998dabdc04112aa2fcd1706438ca08c6b48e45211c50f45b0ab9 +size 574 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus.png b/assets/voxygen/element/buttons/min_plus/mmap_button-plus.png index efdc3d5662..ebbeadf4a6 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-plus.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-plus.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ffde7e0e2994b9889188d516679ff91d39b02fe98419fb100801b4366fdb13d3 -size 220 +oid sha256:2447d95d379286fe65032dc8ff8cdce3ff33277837eb310826b61698735176cd +size 258 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png index 2ece4a15f7..ebbeadf4a6 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:daf1d5dee847769cad782ba6c50b0e41db7dcc80705e3de1497d79275759a33a -size 226 +oid sha256:2447d95d379286fe65032dc8ff8cdce3ff33277837eb310826b61698735176cd +size 258 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png index 2ece4a15f7..ebbeadf4a6 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:daf1d5dee847769cad782ba6c50b0e41db7dcc80705e3de1497d79275759a33a -size 226 +oid sha256:2447d95d379286fe65032dc8ff8cdce3ff33277837eb310826b61698735176cd +size 258 diff --git a/assets/voxygen/element/frames/divider_charwindow.vox b/assets/voxygen/element/frames/divider_charwindow.vox index 6c0d05b1e8..a09a43f111 100644 --- a/assets/voxygen/element/frames/divider_charwindow.vox +++ b/assets/voxygen/element/frames/divider_charwindow.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:01261b4c1122d200a2c633e1d02949b89d569e5bb4071005cdd57e173bfba238 -size 2000 +oid sha256:f75d7b8c3e4a8df8ff26a1db91bf9425762895e072962da08791ea04d575218f +size 55723 diff --git a/assets/voxygen/element/frames/mmap.png b/assets/voxygen/element/frames/mmap.png index eeb6cda693..9ea11136b5 100644 --- a/assets/voxygen/element/frames/mmap.png +++ b/assets/voxygen/element/frames/mmap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ce0c082da8b364ceb2c5fd36f68a2c66544716cbcb5413a16f27ef23d7c4b9e3 -size 658 +oid sha256:ad8ecb5ddc4d9e649bac26a15e28b4eb0af2f493c7a2304c87209a6c065f927c +size 8738 diff --git a/assets/voxygen/element/frames/mmap_closed.png b/assets/voxygen/element/frames/mmap_closed.png index f3320a0157..540d09fc78 100644 --- a/assets/voxygen/element/frames/mmap_closed.png +++ b/assets/voxygen/element/frames/mmap_closed.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e645c34a9e861dff230ac37526cb6194beebd6327a5c23540ed8e41373e41c73 -size 257 +oid sha256:3bdf04e0f5f0e2688f31bf367f18056ffb78560268cf70c26fb2109dcb071c6b +size 1021 diff --git a/assets/voxygen/element/frames/mmap_frame.png b/assets/voxygen/element/frames/mmap_frame.png new file mode 100644 index 0000000000..305ead4d7d --- /dev/null +++ b/assets/voxygen/element/frames/mmap_frame.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d7f3836e6a163c8540e61de5a56bb3dc11902d3e3628ee733d30727c53bffbe +size 1095 diff --git a/assets/voxygen/element/misc_bg/charwindow.png b/assets/voxygen/element/misc_bg/charwindow.png index 41d47b209c..5d64bb4dbe 100644 --- a/assets/voxygen/element/misc_bg/charwindow.png +++ b/assets/voxygen/element/misc_bg/charwindow.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:312e8e5ce70dff58ab12b91bf695071aee35890ddf9881d6c42db121df2c5d9f -size 2484 +oid sha256:f47a3a0744c93ad85d087e11e4a90f9ec2d721d7c2d8bf1c74bc461a9ef9a5dd +size 108690 diff --git a/assets/voxygen/element/misc_bg/inv_bg.png b/assets/voxygen/element/misc_bg/inv_bg.png index 1c11d8bae4..0c2c9ccf9a 100644 --- a/assets/voxygen/element/misc_bg/inv_bg.png +++ b/assets/voxygen/element/misc_bg/inv_bg.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:235f3af70c7e62c52213bb224cc0517f0a9121b3849c8774fc7ab2be095550dc -size 32928 +oid sha256:68aa80432b2ec6ff15179a5092b976b8938aa0fa2dba5248536b90ba4838ecd6 +size 58872 diff --git a/assets/voxygen/element/misc_bg/inv_frame.png b/assets/voxygen/element/misc_bg/inv_frame.png index 37d211bcb5..89371653eb 100644 --- a/assets/voxygen/element/misc_bg/inv_frame.png +++ b/assets/voxygen/element/misc_bg/inv_frame.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c1b52a23d27bd2a30ee2493f76dbd226ff3c8c2a67058e95f45cd83fb94ec51a -size 33025 +oid sha256:c7808b4b96dec90284b7add2e46cb1e59ca74e5ab6d06f343accf6e4dc45d029 +size 128362 diff --git a/assets/voxygen/element/misc_bg/inv_runes.png b/assets/voxygen/element/misc_bg/inv_runes.png new file mode 100644 index 0000000000..93e55cfc00 --- /dev/null +++ b/assets/voxygen/element/misc_bg/inv_runes.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c0af223eef9fad0b85de473a7195a5bd6301ad6767f114003c85d438b0cebee +size 24213 diff --git a/assets/voxygen/element/misc_bg/inv_slots.png b/assets/voxygen/element/misc_bg/inv_slots.png new file mode 100644 index 0000000000..ebe8db57fb --- /dev/null +++ b/assets/voxygen/element/misc_bg/inv_slots.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:caa6bf67dd75bba449c7279580e127d8385380b20f4668f8bed07b936b0d708f +size 38847 diff --git a/assets/voxygen/element/slider/scrollbar.png b/assets/voxygen/element/slider/scrollbar.png index bb606ae6cd..c28cf3123f 100644 --- a/assets/voxygen/element/slider/scrollbar.png +++ b/assets/voxygen/element/slider/scrollbar.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:350b1c19bad4150ca3b4f3b50992bbac4b772ebf841c747c323b7007e47fda7e -size 519 +oid sha256:8efa850c65905cb000300de86a33fdcad484f8a91fb532e12038be3493d9647a +size 468 diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 81b1c3a4b3..408d429bbc 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -1,7 +1,7 @@ use super::{ img_ids::{Imgs, ImgsRot}, item_imgs::{ItemImgs, ItemKey}, - Event as HudEvent, TEXT_COLOR, + Event as HudEvent, Show, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, XP_COLOR, }; use crate::{ i18n::VoxygenLocalization, @@ -38,6 +38,19 @@ widget_ids! { tab_2, tab_3, tab_4, + //Armor Slots + slots_bg, + //Stats + stats_alignment, + level, + exp_rectangle, + exp_progress_rectangle, + expbar, + exp, + divider, + statnames, + stats, + } } @@ -55,6 +68,7 @@ pub struct Bag<'a> { pulse: f32, localized_strings: &'a std::sync::Arc, stats: &'a Stats, + show: &'a Show, } impl<'a> Bag<'a> { @@ -68,6 +82,7 @@ impl<'a> Bag<'a> { pulse: f32, localized_strings: &'a std::sync::Arc, stats: &'a Stats, + show: &'a Show, ) -> Self { Self { client, @@ -80,6 +95,7 @@ impl<'a> Bag<'a> { pulse, localized_strings, stats, + show, } } } @@ -88,11 +104,11 @@ pub struct State { ids: Ids, img_id_cache: Vec>, selected_slot: Option, - stats_show: bool, } pub enum Event { HudEvent(HudEvent), + Stats, Close, } @@ -106,7 +122,6 @@ impl<'a> Widget for Bag<'a> { ids: Ids::new(id_gen), img_id_cache: Vec::new(), selected_slot: None, - stats_show: false, } } @@ -150,11 +165,12 @@ impl<'a> Widget for Bag<'a> { Image::new(self.imgs.inv_bg) .w_h(424.0, 708.0) .bottom_right_with_margins_on(ui.window, 60.0, 5.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.97))) + .color(Some(UI_MAIN)) .set(state.ids.bg, ui); Image::new(self.imgs.inv_frame) .w_h(424.0, 708.0) .middle_of(state.ids.bg) + .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.bg_frame, ui); // Title Text::new(&format!( @@ -189,45 +205,12 @@ impl<'a> Widget for Bag<'a> { { event = Some(Event::Close); } - // Tabs - if Button::image(self.imgs.inv_tab_active) - .w_h(28.0, 44.0) - .bottom_left_with_margins_on(state.ids.bg, 172.0, 13.0) - .set(state.ids.tab_1, ui) - .was_clicked() - {} - if Button::image(self.imgs.inv_tab_inactive) - .w_h(28.0, 44.0) - .hover_image(self.imgs.inv_tab_inactive_hover) - .press_image(self.imgs.inv_tab_inactive_press) - .down_from(state.ids.tab_1, 0.0) - .with_tooltip(self.tooltip_manager, "Not yet Available", "", &item_tooltip) - .set(state.ids.tab_2, ui) - .was_clicked() - {} - if Button::image(self.imgs.inv_tab_inactive) - .w_h(28.0, 44.0) - .hover_image(self.imgs.inv_tab_inactive_hover) - .press_image(self.imgs.inv_tab_inactive_press) - .down_from(state.ids.tab_2, 0.0) - .with_tooltip(self.tooltip_manager, "Not yet Available", "", &item_tooltip) - .set(state.ids.tab_3, ui) - .was_clicked() - {} - if Button::image(self.imgs.inv_tab_inactive) - .w_h(28.0, 44.0) - .hover_image(self.imgs.inv_tab_inactive_hover) - .press_image(self.imgs.inv_tab_inactive_press) - .down_from(state.ids.tab_3, 0.0) - .with_tooltip(self.tooltip_manager, "Not yet Available", "", &item_tooltip) - .set(state.ids.tab_4, ui) - .was_clicked() - {} // Scrollbar-BG Image::new(self.imgs.scrollbar_bg) .w_h(9.0, 173.0) .bottom_right_with_margins_on(state.ids.bg_frame, 42.0, 3.0) + .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.scrollbar_bg, ui); // Char Pixel-Art @@ -242,23 +225,89 @@ impl<'a> Widget for Bag<'a> { .scroll_kids_vertically() .set(state.ids.inv_alignment, ui); - // Stats Button - if Button::image(self.imgs.button) - .w_h(92.0, 22.0) - .mid_top_with_margin_on(state.ids.bg, 435.0) - .hover_image(self.imgs.button_hover) - .press_image(self.imgs.button_press) - .label(if state.stats_show { "Armor" } else { "Stats" }) - .label_y(conrod_core::position::Relative::Scalar(1.0)) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(12)) - .label_font_id(self.fonts.cyri.conrod_id) - .set(state.ids.stats_button, ui) - .was_clicked() - { - //state.stats_show = !state.stats_show; - }; + if !self.show.stats { + //Armor Slots + //Slots BG + Image::new(self.imgs.inv_runes) + .w_h(424.0, 708.0) + .middle_of(state.ids.bg) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.slots_bg, ui); + Image::new(self.imgs.inv_slots) + .w_h(424.0, 708.0) + .middle_of(state.ids.bg) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.slots_bg, ui); + } else { + // Stats + // Alignment for Stats + Rectangle::fill_with([418.0, 384.0], color::TRANSPARENT) + .mid_top_with_margin_on(state.ids.bg_frame, 48.0) + .scroll_kids_vertically() + .set(state.ids.stats_alignment, ui); + // Level + Text::new(&level) + .mid_top_with_margin_on(state.ids.stats_alignment, 10.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(30)) + .color(TEXT_COLOR) + .set(state.ids.level, ui); + // Exp-Bar Background + Rectangle::fill_with([170.0, 10.0], color::BLACK) + .mid_top_with_margin_on(state.ids.stats_alignment, 50.0) + .set(state.ids.exp_rectangle, ui); + + // Exp-Bar Progress + Rectangle::fill_with([170.0 * (exp_percentage), 6.0], XP_COLOR) // 0.8 = Experience percentage + .mid_left_with_margin_on(state.ids.expbar, 1.0) + .set(state.ids.exp_progress_rectangle, ui); + + // Exp-Bar Foreground Frame + Image::new(self.imgs.progress_frame) + .w_h(170.0, 10.0) + .middle_of(state.ids.exp_rectangle) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.expbar, ui); + + // Exp-Text + Text::new(&exp_treshold) + .mid_top_with_margin_on(state.ids.expbar, 10.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(15)) + .color(TEXT_COLOR) + .set(state.ids.exp, ui); + + // Divider + /*Image::new(self.imgs.divider) + .w_h(50.0, 5.0) + .mid_top_with_margin_on(state.ids.exp, 30.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.divider, ui);*/ + + // Stats + Text::new( + &self + .localized_strings + .get("character_window.character_stats"), + ) + .top_left_with_margins_on(state.ids.stats_alignment, 120.0, 150.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(16)) + .color(TEXT_COLOR) + .set(state.ids.statnames, ui); + + Text::new(&format!( + "{}\n\n{}\n\n{}", + self.stats.endurance, self.stats.fitness, self.stats.willpower + )) + .top_right_with_margins_on(state.ids.stats_alignment, 120.0, 150.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(16)) + .color(TEXT_COLOR) + .set(state.ids.stats, ui); + } + // Bag Slots // Create available inventory slot widgets if state.ids.inv_slots.len() < inventory.len() { state.update(|s| { @@ -301,11 +350,7 @@ impl<'a> Widget for Bag<'a> { 0.0 + x as f64 * (40.0), ) .wh([40.0; 2]) - /*.image_color(if is_selected { - color::WHITE - } else { - color::DARK_YELLOW - })*/; + .image_color(UI_MAIN); let slot_widget_clicked = if let Some(item) = item { slot_widget @@ -351,17 +396,10 @@ impl<'a> Widget for Bag<'a> { .unwrap_or(self.imgs.not_found); state.update(|s| s.img_id_cache[i] = Some((kind, id))); id - } + }, }) .wh(if is_selected { [32.0; 2] } else { [30.0; 2] }) - .middle_of(state.ids.inv_slots[i]) // TODO: Items need to be assigned to a certain slot and then placed like in this example - //.label("5x") // TODO: Quantity goes here... - //.label_font_id(self.fonts.opensans) - //.label_font_size(12) - //.label_x(Relative::Scalar(10.0)) - //.label_y(Relative::Scalar(-10.0)) - //.label_color(TEXT_COLOR) - //.parent(state.ids.inv_slots[i]) + .middle_of(state.ids.inv_slots[i]) .graphics_for(state.ids.inv_slots[i]) .set(state.ids.items[i], ui); } @@ -374,6 +412,60 @@ impl<'a> Widget for Bag<'a> { state.update(|s| s.selected_slot = None); } } + // Stats Button + if Button::image(self.imgs.button) + .w_h(92.0, 22.0) + .mid_top_with_margin_on(state.ids.bg, 435.0) + .hover_image(self.imgs.button_hover) + .press_image(self.imgs.button_press) + .label(if self.show.stats { "Armor" } else { "Stats" }) + .label_y(conrod_core::position::Relative::Scalar(1.0)) + .label_color(TEXT_COLOR) + .label_font_size(self.fonts.cyri.scale(12)) + .label_font_id(self.fonts.cyri.conrod_id) + .set(state.ids.stats_button, ui) + .was_clicked() + { + return Some(Event::Stats); + }; + // Tabs + if Button::image(self.imgs.inv_tab_active) + .w_h(28.0, 44.0) + .bottom_left_with_margins_on(state.ids.bg, 172.0, 13.0) + .image_color(UI_HIGHLIGHT_0) + .set(state.ids.tab_1, ui) + .was_clicked() + {} + if Button::image(self.imgs.inv_tab_inactive) + .w_h(28.0, 44.0) + .hover_image(self.imgs.inv_tab_inactive_hover) + .press_image(self.imgs.inv_tab_inactive_press) + .image_color(UI_HIGHLIGHT_0) + .down_from(state.ids.tab_1, 0.0) + .with_tooltip(self.tooltip_manager, "Not yet Available", "", &item_tooltip) + .set(state.ids.tab_2, ui) + .was_clicked() + {} + if Button::image(self.imgs.inv_tab_inactive) + .w_h(28.0, 44.0) + .hover_image(self.imgs.inv_tab_inactive_hover) + .press_image(self.imgs.inv_tab_inactive_press) + .down_from(state.ids.tab_2, 0.0) + .image_color(UI_HIGHLIGHT_0) + .with_tooltip(self.tooltip_manager, "Not yet Available", "", &item_tooltip) + .set(state.ids.tab_3, ui) + .was_clicked() + {} + if Button::image(self.imgs.inv_tab_inactive) + .w_h(28.0, 44.0) + .hover_image(self.imgs.inv_tab_inactive_hover) + .press_image(self.imgs.inv_tab_inactive_press) + .down_from(state.ids.tab_3, 0.0) + .image_color(UI_HIGHLIGHT_0) + .with_tooltip(self.tooltip_manager, "Not yet Available", "", &item_tooltip) + .set(state.ids.tab_4, ui) + .was_clicked() + {} event } diff --git a/voxygen/src/hud/character_window.rs b/voxygen/src/hud/character_window.rs index 699fc9fada..709c1cde76 100644 --- a/voxygen/src/hud/character_window.rs +++ b/voxygen/src/hud/character_window.rs @@ -335,16 +335,6 @@ impl<'a> Widget for CharacterWindow<'a> { .top_left_with_margins_on(state.charwindow_tab_bg, 7.0 * 4.0, 4.0 * 4.0) .set(state.charwindow_rectangle, ui); - // TODO: Add this back in when we have multiple tabs. - // Tab Button -> - // Button::image(self.imgs.charwindow_tab) - //.w_h(65.0, 23.0) - //.top_left_with_margins_on(state.charwindow_tab_bg, -18.0, 1.8) - //.label("Stats") - //.label_color(TEXT_COLOR) - //.label_font_size(14) - //.set(state.charwindow_tab1, ui); - // Level Text::new(&level) .mid_top_with_margin_on(state.charwindow_rectangle, 10.0) diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 0f53593b6f..4888ea1379 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -223,6 +223,7 @@ image_ids! { // MiniMap mmap_frame: "voxygen.element.frames.mmap", + mmap_frame_2: "voxygen.element.frames.mmap_frame", mmap_frame_closed: "voxygen.element.frames.mmap_closed", mmap_closed: "voxygen.element.buttons.button_mmap_closed", mmap_closed_hover: "voxygen.element.buttons.button_mmap_closed_hover", @@ -253,6 +254,8 @@ image_ids! { inv_tab_inactive: "voxygen.element.buttons.inv_tab_inactive", inv_tab_inactive_hover: "voxygen.element.buttons.inv_tab_inactive", inv_tab_inactive_press: "voxygen.element.buttons.inv_tab_inactive", + inv_slots: "voxygen.element.misc_bg.inv_slots", + inv_runes: "voxygen.element.misc_bg.inv_runes", diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index 839dbdf462..e9fe2b46fd 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -1,6 +1,6 @@ use super::{ img_ids::{Imgs, ImgsRot}, - Show, HP_COLOR, TEXT_COLOR, + Show, HP_COLOR, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, }; use crate::ui::{fonts::ConrodVoxygenFonts, img_ids}; use client::{self, Client}; @@ -17,6 +17,7 @@ use vek::*; widget_ids! { struct Ids { mmap_frame, + mmap_frame_2, mmap_frame_bg, mmap_location, mmap_button, @@ -108,10 +109,15 @@ impl<'a> Widget for MiniMap<'a> { Image::new(self.imgs.mmap_frame) .w_h(174.0 * SCALE, 190.0 * SCALE) .top_right_with_margins_on(ui.window, 0.0, 5.0) + .color(Some(UI_MAIN)) .set(state.ids.mmap_frame, ui); - + Image::new(self.imgs.mmap_frame_2) + .w_h(174.0 * SCALE, 190.0 * SCALE) + .middle_of(state.ids.mmap_frame) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.mmap_frame_2, ui); Rectangle::fill_with([170.0 * SCALE, 170.0 * SCALE], color::TRANSPARENT) - .mid_top_with_margin_on(state.ids.mmap_frame, 18.0 * SCALE) + .mid_top_with_margin_on(state.ids.mmap_frame_2, 18.0 * SCALE) .set(state.ids.mmap_frame_bg, ui); // Map size @@ -143,6 +149,7 @@ impl<'a> Widget for MiniMap<'a> { .hover_image(self.imgs.mmap_minus_hover) .press_image(self.imgs.mmap_minus_press) .top_left_with_margins_on(state.ids.mmap_frame, 0.0, 0.0) + .image_color(UI_HIGHLIGHT_0) .enabled(can_zoom_out) .set(state.ids.mmap_minus, ui) .was_clicked() @@ -158,6 +165,7 @@ impl<'a> Widget for MiniMap<'a> { .hover_image(self.imgs.mmap_plus_hover) .press_image(self.imgs.mmap_plus_press) .right_from(state.ids.mmap_minus, 0.0) + .image_color(UI_HIGHLIGHT_0) .enabled(can_zoom_in) .set(state.ids.mmap_plus, ui) .was_clicked() @@ -213,6 +221,7 @@ impl<'a> Widget for MiniMap<'a> { } else { Image::new(self.imgs.mmap_frame_closed) .w_h(174.0 * SCALE, 18.0 * SCALE) + .color(Some(UI_MAIN)) .top_right_with_margins_on(ui.window, 0.0, 5.0) .set(state.ids.mmap_frame, ui); } @@ -234,6 +243,7 @@ impl<'a> Widget for MiniMap<'a> { self.imgs.mmap_closed_press }) .top_right_with_margins_on(state.ids.mmap_frame, 0.0, 0.0) + .image_color(UI_HIGHLIGHT_0) .set(state.ids.mmap_button, ui) .was_clicked() { diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index cc3506da85..4512045572 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -67,6 +67,8 @@ const CRITICAL_HP_COLOR: Color = Color::Rgba(0.79, 0.19, 0.17, 1.0); const MANA_COLOR: Color = Color::Rgba(0.29, 0.62, 0.75, 0.9); //const FOCUS_COLOR: Color = Color::Rgba(1.0, 0.56, 0.04, 1.0); //const RAGE_COLOR: Color = Color::Rgba(0.5, 0.04, 0.13, 1.0); + +// Chat Colors const META_COLOR: Color = Color::Rgba(1.0, 1.0, 0.0, 1.0); const TELL_COLOR: Color = Color::Rgba(0.98, 0.71, 1.0, 1.0); const PRIVATE_COLOR: Color = Color::Rgba(1.0, 1.0, 0.0, 1.0); // Difference between private and tell? @@ -77,6 +79,12 @@ const GROUP_COLOR: Color = Color::Rgba(0.47, 0.84, 1.0, 1.0); const FACTION_COLOR: Color = Color::Rgba(0.24, 1.0, 0.48, 1.0); const KILL_COLOR: Color = Color::Rgba(1.0, 0.17, 0.17, 1.0); +// UI Color-Theme +const UI_MAIN: Color = Color::Rgba(0.61, 0.70, 0.70, 1.0); // Greenish Blue +//const UI_MAIN: Color = Color::Rgba(0.1, 0.1, 0.1, 0.97); // Dark +const UI_HIGHLIGHT_0: Color = Color::Rgba(0.79, 1.09, 1.09, 1.0); +//const UI_DARK_0: Color = Color::Rgba(0.25, 0.37, 0.37, 1.0); + /// Distance at which nametags are visible const NAMETAG_RANGE: f32 = 40.0; /// Time nametags stay visible after doing damage even if they are out of range @@ -285,6 +293,7 @@ pub struct Show { settings_tab: SettingsTab, social_tab: SocialTab, want_grab: bool, + stats: bool, } impl Show { fn bag(&mut self, open: bool) { @@ -507,6 +516,7 @@ impl Hud { social_tab: SocialTab::Online, want_grab: true, ingame: true, + stats: false, }, to_focus: None, never_show: false, @@ -1647,10 +1657,12 @@ impl Hud { self.pulse, &self.voxygen_i18n, &player_stats, + &self.show, ) .set(self.ids.bag, ui_widgets) { Some(bag::Event::HudEvent(event)) => events.push(event), + Some(bag::Event::Stats) => self.show.stats = !self.show.stats, Some(bag::Event::Close) => { self.show.bag(false); self.force_ungrab = true; From b3057add42edd1765162c0f162f8cd9337bd380b Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 16 Mar 2020 19:55:12 +0100 Subject: [PATCH 118/326] Smaller damage and health numbers --- common/src/comp/inventory/item.rs | 12 ++++++------ common/src/comp/stats.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 488944305c..708b31a7b4 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -46,23 +46,23 @@ impl ToolData { BasicMelee { buildup_duration: Duration::from_millis(100), recover_duration: Duration::from_millis(500), - base_damage: 60, + base_damage: 6, }, DashMelee { buildup_duration: Duration::from_millis(500), recover_duration: Duration::from_millis(500), - base_damage: 200, + base_damage: 20, }, ], Axe => vec![BasicMelee { buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(100), - base_damage: 80, + base_damage: 8, }], Hammer => vec![BasicMelee { buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(300), - base_damage: 100, + base_damage: 10, }], Bow => vec![BasicRanged { projectile: Projectile { @@ -85,12 +85,12 @@ impl ToolData { Dagger => vec![BasicMelee { buildup_duration: Duration::from_millis(100), recover_duration: Duration::from_millis(400), - base_damage: 50, + base_damage: 5, }], Staff => vec![BasicMelee { buildup_duration: Duration::from_millis(400), recover_duration: Duration::from_millis(300), - base_damage: 70, + base_damage: 7, }], Shield => vec![BasicBlock], Debug(kind) => match kind { diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index 27eb88f42b..cb43eb985d 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -134,7 +134,7 @@ impl Stats { } // TODO: Delete this once stat points will be a thing - pub fn update_max_hp(&mut self) { self.health.set_maximum(200 + 47 * self.level.amount); } + pub fn update_max_hp(&mut self) { self.health.set_maximum(21 + 3 * self.level.amount); } } impl Stats { From 2e41b59282a23e91afe16d174844a768e0ece84b Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Mon, 16 Mar 2020 19:56:15 +0100 Subject: [PATCH 119/326] removed character window and questlog --- assets/voxygen/element/misc_bg/inv_runes.png | 4 +- assets/voxygen/element/misc_bg/inv_slots.png | 4 +- voxygen/src/hud/bag.rs | 32 +- voxygen/src/hud/character_window.rs | 402 ------------------- voxygen/src/hud/mod.rs | 88 ---- voxygen/src/hud/quest.rs | 117 ------ voxygen/src/hud/social.rs | 15 +- voxygen/src/hud/spell.rs | 15 +- 8 files changed, 27 insertions(+), 650 deletions(-) delete mode 100644 voxygen/src/hud/character_window.rs delete mode 100644 voxygen/src/hud/quest.rs diff --git a/assets/voxygen/element/misc_bg/inv_runes.png b/assets/voxygen/element/misc_bg/inv_runes.png index 93e55cfc00..9410b0afd4 100644 --- a/assets/voxygen/element/misc_bg/inv_runes.png +++ b/assets/voxygen/element/misc_bg/inv_runes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9c0af223eef9fad0b85de473a7195a5bd6301ad6767f114003c85d438b0cebee -size 24213 +oid sha256:ba2d049b990ab3e8e4279b0cbc8540afb056f82d6c6a5cde7d4f6bfe3286cf50 +size 17340 diff --git a/assets/voxygen/element/misc_bg/inv_slots.png b/assets/voxygen/element/misc_bg/inv_slots.png index ebe8db57fb..34ea90649d 100644 --- a/assets/voxygen/element/misc_bg/inv_slots.png +++ b/assets/voxygen/element/misc_bg/inv_slots.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:caa6bf67dd75bba449c7279580e127d8385380b20f4668f8bed07b936b0d708f -size 38847 +oid sha256:1a46df2b937b1b4224e6912dcb6797e669ebe7aacec0f9fbc7b9eda371c1a7c1 +size 31400 diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 408d429bbc..73fd1d66e9 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -194,18 +194,6 @@ impl<'a> Widget for Bag<'a> { .color(TEXT_COLOR) .set(state.ids.inventory_title, ui); - // Close button - if Button::image(self.imgs.close_btn) - .w_h(24.0, 25.0) - .hover_image(self.imgs.close_btn_hover) - .press_image(self.imgs.close_btn_press) - .top_right_with_margins_on(state.ids.bg, 0.0, 0.0) - .set(state.ids.bag_close, ui) - .was_clicked() - { - event = Some(Event::Close); - } - // Scrollbar-BG Image::new(self.imgs.scrollbar_bg) .w_h(9.0, 173.0) @@ -229,13 +217,13 @@ impl<'a> Widget for Bag<'a> { //Armor Slots //Slots BG Image::new(self.imgs.inv_runes) - .w_h(424.0, 708.0) - .middle_of(state.ids.bg) + .w_h(424.0, 454.0) + .mid_top_with_margin_on(state.ids.bg, 0.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.slots_bg, ui); Image::new(self.imgs.inv_slots) - .w_h(424.0, 708.0) - .middle_of(state.ids.bg) + .w_h(424.0, 401.0) + .mid_top_with_margin_on(state.ids.bg, 57.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.slots_bg, ui); } else { @@ -466,7 +454,17 @@ impl<'a> Widget for Bag<'a> { .set(state.ids.tab_4, ui) .was_clicked() {} - + // Close button + if Button::image(self.imgs.close_btn) + .w_h(24.0, 25.0) + .hover_image(self.imgs.close_btn_hover) + .press_image(self.imgs.close_btn_press) + .top_right_with_margins_on(state.ids.bg, 0.0, 0.0) + .set(state.ids.bag_close, ui) + .was_clicked() + { + event = Some(Event::Close); + } event } } diff --git a/voxygen/src/hud/character_window.rs b/voxygen/src/hud/character_window.rs deleted file mode 100644 index 709c1cde76..0000000000 --- a/voxygen/src/hud/character_window.rs +++ /dev/null @@ -1,402 +0,0 @@ -use super::{img_ids::Imgs, Show, TEXT_COLOR, XP_COLOR}; -use crate::{i18n::VoxygenLocalization, ui::fonts::ConrodVoxygenFonts}; -use common::comp::Stats; -use conrod_core::{ - color, - widget::{self, Button, Image, Rectangle, Text}, - widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, -}; - -widget_ids! { - pub struct Ids { - charwindow, - charwindow_gradient, - charwindow_close, - charwindow_exp_progress_rectangle, - charwindow_exp_rectangle, - charwindow_frame, - content_align, - charwindow_rectangle, - charwindow_tab1, - charwindow_tab1_exp, - charwindow_tab1_expbar, - charwindow_tab1_level, - charwindow_tab1_statnames, - charwindow_tab1_stats, - charwindow_tab_bg, - charwindow_title, - window_3, - tab_bg, - tab_small_open, - tab_small_closed, - xp_charwindow, - divider, - head_bg, - shoulders_bg, - hands_bg, - belt_bg, - legs_bg, - feet_bg, - ring_r_bg, - ring_l_bg, - tabard_bg, - chest_bg, - back_bg, - gem_bg, - necklace_bg, - mainhand_bg, - offhand_bg, - charwindow_bg, - head_grid, - shoulders_grid, - hands_grid, - belt_grid, - legs_grid, - feet_grid, - ring_r_grid, - ring_l_grid, - tabard_grid, - chest_grid, - back_grid, - gem_grid, - necklace_grid, - mainhand_grid, - offhand_grid, - - - } -} - -#[derive(WidgetCommon)] -pub struct CharacterWindow<'a> { - _show: &'a Show, - imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - stats: &'a Stats, - localized_strings: &'a std::sync::Arc, - - #[conrod(common_builder)] - common: widget::CommonBuilder, -} - -impl<'a> CharacterWindow<'a> { - pub fn new( - _show: &'a Show, - stats: &'a Stats, - imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, - ) -> Self { - Self { - _show, - imgs, - fonts, - stats, - localized_strings, - common: widget::CommonBuilder::default(), - } - } -} - -pub enum Event { - Close, -} - -impl<'a> Widget for CharacterWindow<'a> { - type Event = Option; - type State = Ids; - type Style = (); - - fn init_state(&self, id_gen: widget::id::Generator) -> Self::State { Ids::new(id_gen) } - - fn style(&self) -> Self::Style { () } - - fn update(self, args: widget::UpdateArgs) -> Self::Event { - let widget::UpdateArgs { id, state, ui, .. } = args; - - let exp_percentage = (self.stats.exp.current() as f64) / (self.stats.exp.maximum() as f64); - let exp_treshold = format!("{}/{}", self.stats.exp.current(), self.stats.exp.maximum()); - let level = (self.stats.level.level()).to_string(); - - // Frame - Image::new(self.imgs.window_3) - .middle_of(id) - .top_left_with_margins_on(ui.window, 200.0, 215.0) - .w_h(103.0 * 4.0, 122.0 * 4.0) - .set(state.charwindow_frame, ui); - - // Icon - //Image::new(self.imgs.charwindow_icon) - //.w_h(40.0, 40.0) - //.top_left_with_margins_on(state.charwindow_frame, 4.0, 4.0) - //.set(state.charwindow_icon, ui); - - // X-Button - if Button::image(self.imgs.close_button) - .w_h(28.0, 28.0) - .hover_image(self.imgs.close_button_hover) - .press_image(self.imgs.close_button_press) - .top_right_with_margins_on(state.charwindow_frame, 0.0, 0.0) - .set(state.charwindow_close, ui) - .was_clicked() - { - return Some(Event::Close); - } - - // Title - // TODO: Use an actual character name. - Text::new( - &self - .localized_strings - .get("character_window.character_name"), - ) - .mid_top_with_margin_on(state.charwindow_frame, 6.0) - .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(14)) - .color(TEXT_COLOR) - .set(state.charwindow_title, ui); - - // Content Alignment - Rectangle::fill_with([95.0 * 4.0, 108.0 * 4.0], color::TRANSPARENT) - .mid_top_with_margin_on(state.charwindow_frame, 40.0) - .set(state.content_align, ui); - - // Gradient BG - Image::new(self.imgs.charwindow_gradient) - .w_h(95.0 * 4.0, 108.0 * 4.0) - .middle_of(state.content_align) - .set(state.charwindow_gradient, ui); - - // Contents - - // Head - Image::new(self.imgs.head_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .mid_top_with_margin_on(state.content_align, 5.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.head_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.head_bg) - .set(state.head_grid, ui); - - // Ring R - Image::new(self.imgs.ring_r_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .bottom_right_with_margins_on(state.content_align, 20.0, 20.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.ring_r_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.ring_r_bg) - .set(state.ring_r_grid, ui); - // Feet - Image::new(self.imgs.feet_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .up_from(state.ring_r_bg, 10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.feet_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.feet_bg) - .set(state.feet_grid, ui); - // Legs - Image::new(self.imgs.legs_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .up_from(state.feet_bg, 10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.legs_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.legs_bg) - .set(state.legs_grid, ui); - // Belt - Image::new(self.imgs.belt_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .up_from(state.legs_bg, 10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.belt_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.belt_bg) - .set(state.belt_grid, ui); - // Hands - Image::new(self.imgs.hands_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .up_from(state.belt_bg, 10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.hands_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.hands_bg) - .set(state.hands_grid, ui); - // Shoulders - Image::new(self.imgs.shoulders_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .up_from(state.hands_bg, 10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.shoulders_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.shoulders_bg) - .set(state.shoulders_grid, ui); - // Ring L - Image::new(self.imgs.ring_l_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .bottom_left_with_margins_on(state.content_align, 20.0, 20.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.ring_l_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.ring_l_bg) - .set(state.ring_l_grid, ui); - // Tabard - Image::new(self.imgs.tabard_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .up_from(state.ring_l_bg, 10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.tabard_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.tabard_bg) - .set(state.tabard_grid, ui); - // Chest - Image::new(self.imgs.chest_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .up_from(state.tabard_bg, 10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.chest_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.chest_bg) - .set(state.chest_grid, ui); - // Back - Image::new(self.imgs.back_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .up_from(state.chest_bg, 10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.back_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.back_bg) - .set(state.back_grid, ui); - // Gem - Image::new(self.imgs.gem_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .up_from(state.back_bg, 10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.gem_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.gem_bg) - .set(state.gem_grid, ui); - // Necklace - Image::new(self.imgs.necklace_bg) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .up_from(state.gem_bg, 10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.necklace_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 1.8, 28.0 * 1.8) - .middle_of(state.necklace_bg) - .set(state.necklace_grid, ui); - - // Weapon Main Hand - Image::new(self.imgs.mainhand_bg) - .w_h(28.0 * 2.2, 28.0 * 2.2) - .bottom_right_with_margins_on(state.ring_l_bg, 0.0, -115.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.mainhand_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 2.2, 28.0 * 2.2) - .middle_of(state.mainhand_bg) - .set(state.mainhand_grid, ui); - // Weapon Off-Hand - Image::new(self.imgs.offhand_bg) - .w_h(28.0 * 2.2, 28.0 * 2.2) - .bottom_left_with_margins_on(state.ring_r_bg, 0.0, -115.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.1))) - .set(state.offhand_bg, ui); - Button::image(self.imgs.grid) - .w_h(28.0 * 2.2, 28.0 * 2.2) - .middle_of(state.offhand_bg) - .set(state.offhand_grid, ui); - - // Stats Tab - - // Tab BG - Image::new(self.imgs.tab_bg) - .w_h(51.0 * 4.0, 115.0 * 4.0) - .top_left_with_margins_on(state.charwindow_frame, 28.0, -200.0) - .set(state.charwindow_tab_bg, ui); - - // Tab Rectangle - Rectangle::fill_with([45.0 * 4.0, 104.0 * 4.0], color::TRANSPARENT) - .top_left_with_margins_on(state.charwindow_tab_bg, 7.0 * 4.0, 4.0 * 4.0) - .set(state.charwindow_rectangle, ui); - - // Level - Text::new(&level) - .mid_top_with_margin_on(state.charwindow_rectangle, 10.0) - .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(30)) - .color(TEXT_COLOR) - .set(state.charwindow_tab1_level, ui); - - // Exp-Bar Background - Rectangle::fill_with([170.0, 10.0], color::BLACK) - .mid_top_with_margin_on(state.charwindow_rectangle, 50.0) - .set(state.charwindow_exp_rectangle, ui); - - // Exp-Bar Progress - Rectangle::fill_with([170.0 * (exp_percentage), 6.0], XP_COLOR) // 0.8 = Experience percentage - .mid_left_with_margin_on(state.charwindow_tab1_expbar, 1.0) - .set(state.charwindow_exp_progress_rectangle, ui); - - // Exp-Bar Foreground Frame - Image::new(self.imgs.progress_frame) - .w_h(170.0, 10.0) - .middle_of(state.charwindow_exp_rectangle) - .set(state.charwindow_tab1_expbar, ui); - - // Exp-Text - Text::new(&exp_treshold) - .mid_top_with_margin_on(state.charwindow_tab1_expbar, 10.0) - .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(15)) - .color(TEXT_COLOR) - .set(state.charwindow_tab1_exp, ui); - - // Divider - - Image::new(self.imgs.divider) - .w_h(38.0 * 4.0, 5.0 * 4.0) - .mid_top_with_margin_on(state.charwindow_tab1_exp, 30.0) - .set(state.divider, ui); - - // Stats - Text::new( - &self - .localized_strings - .get("character_window.character_stats"), - ) - .top_left_with_margins_on(state.charwindow_rectangle, 140.0, 5.0) - .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(16)) - .color(TEXT_COLOR) - .set(state.charwindow_tab1_statnames, ui); - - // TODO: Shows actual stat points. - Text::new(&format!( - "{}\n\n{}\n\n{}", - self.stats.endurance, self.stats.fitness, self.stats.willpower - )) - .top_right_with_margins_on(state.charwindow_rectangle, 140.0, 5.0) - .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(16)) - .color(TEXT_COLOR) - .set(state.charwindow_tab1_stats, ui); - - None - } -} diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 4512045572..395fb87927 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1,13 +1,11 @@ mod bag; mod buttons; -mod character_window; mod chat; mod esc_menu; mod img_ids; mod item_imgs; mod map; mod minimap; -mod quest; mod settings_window; mod skillbar; mod social; @@ -19,7 +17,6 @@ use std::time::Duration; use bag::Bag; use buttons::Buttons; -use character_window::CharacterWindow; use chat::Chat; use chrono::NaiveTime; use esc_menu::EscMenu; @@ -27,7 +24,6 @@ use img_ids::Imgs; use item_imgs::ItemImgs; use map::Map; use minimap::MiniMap; -use quest::Quest; use serde::{Deserialize, Serialize}; use settings_window::{SettingsTab, SettingsWindow}; use skillbar::Skillbar; @@ -283,8 +279,6 @@ pub struct Show { bag: bool, social: bool, spell: bool, - quest: bool, - character_window: bool, esc_menu: bool, open_windows: Windows, map: bool, @@ -309,30 +303,15 @@ impl Show { self.want_grab = true; } - fn character_window(&mut self, open: bool) { - self.character_window = open; - self.bag = false; - self.want_grab = !open; - } - fn social(&mut self, open: bool) { self.social = open; self.spell = false; - self.quest = false; self.want_grab = !open; } fn spell(&mut self, open: bool) { self.social = false; self.spell = open; - self.quest = false; - self.want_grab = !open; - } - - fn quest(&mut self, open: bool) { - self.social = false; - self.spell = false; - self.quest = open; self.want_grab = !open; } @@ -340,8 +319,6 @@ impl Show { fn toggle_mini_map(&mut self) { self.mini_map = !self.mini_map; } - fn toggle_char_window(&mut self) { self.character_window = !self.character_window } - fn settings(&mut self, open: bool) { self.open_windows = if open { Windows::Settings @@ -351,7 +328,6 @@ impl Show { self.bag = false; self.social = false; self.spell = false; - self.quest = false; self.want_grab = !open; } @@ -371,9 +347,7 @@ impl Show { || self.esc_menu || self.map || self.social - || self.quest || self.spell - || self.character_window || match self.open_windows { Windows::None => false, _ => true, @@ -383,9 +357,7 @@ impl Show { self.esc_menu = false; self.map = false; self.social = false; - self.quest = false; self.spell = false; - self.character_window = false; self.open_windows = Windows::None; self.want_grab = true; @@ -415,25 +387,16 @@ impl Show { fn toggle_social(&mut self) { self.social = !self.social; self.spell = false; - self.quest = false; } fn open_social_tab(&mut self, social_tab: SocialTab) { self.social_tab = social_tab; self.spell = false; - self.quest = false; } fn toggle_spell(&mut self) { self.spell = !self.spell; self.social = false; - self.quest = false; - } - - fn toggle_quest(&mut self) { - self.quest = !self.quest; - self.spell = false; - self.social = false; } } @@ -508,9 +471,7 @@ impl Hud { map: false, ui: true, social: false, - quest: false, spell: false, - character_window: false, mini_map: true, settings_tab: SettingsTab::Interface, social_tab: SocialTab::Online, @@ -1860,28 +1821,6 @@ impl Hud { } } - // Character Window - if self.show.character_window { - let ecs = client.state().ecs(); - let stats = ecs.read_storage::(); - let player_stats = stats.get(client.entity()).unwrap(); - match CharacterWindow::new( - &self.show, - &player_stats, - &self.imgs, - &self.fonts, - &self.voxygen_i18n, - ) - .set(self.ids.character_window, ui_widgets) - { - Some(character_window::Event::Close) => { - self.show.character_window(false); - self.force_ungrab = true; - }, - None => {}, - } - } - // Spellbook if self.show.spell { match Spell::new( @@ -1900,25 +1839,6 @@ impl Hud { None => {}, } } - - // Quest Log - if self.show.quest { - match Quest::new( - &self.show, - client, - &self.imgs, - &self.fonts, - &self.voxygen_i18n, - ) - .set(self.ids.quest, ui_widgets) - { - Some(quest::Event::Close) => { - self.show.quest(false); - self.force_ungrab = true; - }, - None => {}, - } - } // Map if self.show.map { match Map::new( @@ -2065,14 +1985,6 @@ impl Hud { self.show.toggle_bag(); true }, - GameInput::QuestLog => { - self.show.toggle_quest(); - true - }, - GameInput::CharacterWindow => { - self.show.toggle_char_window(); - true - }, GameInput::Social => { self.show.toggle_social(); true diff --git a/voxygen/src/hud/quest.rs b/voxygen/src/hud/quest.rs deleted file mode 100644 index 795abfd475..0000000000 --- a/voxygen/src/hud/quest.rs +++ /dev/null @@ -1,117 +0,0 @@ -use super::{img_ids::Imgs, Show, TEXT_COLOR}; -use crate::{i18n::VoxygenLocalization, ui::fonts::ConrodVoxygenFonts}; -use client::{self, Client}; -use conrod_core::{ - color, - widget::{self, Button, Image, Rectangle, Text}, - widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon, -}; - -widget_ids! { - pub struct Ids { - quest_frame, - quest_close, - quest_title, - frame, - content_align, - } -} - -#[derive(WidgetCommon)] -pub struct Quest<'a> { - _show: &'a Show, - _client: &'a Client, - - imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, - #[conrod(common_builder)] - common: widget::CommonBuilder, -} - -impl<'a> Quest<'a> { - pub fn new( - show: &'a Show, - _client: &'a Client, - imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, - ) -> Self { - Self { - _show: show, - imgs, - _client, - fonts, - localized_strings, - common: widget::CommonBuilder::default(), - } - } -} - -/*pub struct State { - ids: Ids, -}*/ - -pub enum Event { - Close, -} - -impl<'a> Widget for Quest<'a> { - type Event = Option; - type State = Ids; - type Style = (); - - fn init_state(&self, id_gen: widget::id::Generator) -> Self::State { Ids::new(id_gen) } - - fn style(&self) -> Self::Style { () } - - fn update(self, args: widget::UpdateArgs) -> Self::Event { - let widget::UpdateArgs { - id: _, state, ui, .. - } = args; - - if self._show.character_window { - Image::new(self.imgs.window_3) - .top_left_with_margins_on(ui.window, 200.0, 658.0) - .w_h(103.0 * 4.0, 122.0 * 4.0) - .set(state.quest_frame, ui); - } else { - Image::new(self.imgs.window_3) - .top_left_with_margins_on(ui.window, 200.0, 25.0) - .w_h(103.0 * 4.0, 122.0 * 4.0) - .set(state.quest_frame, ui); - } - - // X-Button - if Button::image(self.imgs.close_button) - .w_h(28.0, 28.0) - .hover_image(self.imgs.close_button_hover) - .press_image(self.imgs.close_button_press) - .top_right_with_margins_on(state.quest_frame, 0.0, 0.0) - .set(state.quest_close, ui) - .was_clicked() - { - return Some(Event::Close); - } - - // Title - // TODO: Use an actual character name. - Text::new(&self.localized_strings.get("hud.quests")) - .mid_top_with_margin_on(state.quest_frame, 6.0) - .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(14)) - .color(TEXT_COLOR) - .set(state.quest_title, ui); - - // Content Alignment - Rectangle::fill_with([95.0 * 4.0, 108.0 * 4.0], color::TRANSPARENT) - .mid_top_with_margin_on(state.quest_frame, 40.0) - .set(state.content_align, ui); - - // Contents - - // Frame - - None - } -} diff --git a/voxygen/src/hud/social.rs b/voxygen/src/hud/social.rs index fb57e8523e..4d6588246e 100644 --- a/voxygen/src/hud/social.rs +++ b/voxygen/src/hud/social.rs @@ -88,17 +88,10 @@ impl<'a> Widget for Social<'a> { let mut events = Vec::new(); - if self.show.character_window { - Image::new(self.imgs.window_3) - .top_left_with_margins_on(ui.window, 200.0, 658.0) - .w_h(103.0 * 4.0, 122.0 * 4.0) - .set(ids.social_frame, ui); - } else { - Image::new(self.imgs.window_3) - .top_left_with_margins_on(ui.window, 200.0, 25.0) - .w_h(103.0 * 4.0, 122.0 * 4.0) - .set(ids.social_frame, ui); - } + Image::new(self.imgs.window_3) + .top_left_with_margins_on(ui.window, 200.0, 25.0) + .w_h(103.0 * 4.0, 122.0 * 4.0) + .set(ids.social_frame, ui); // X-Button if Button::image(self.imgs.close_button) diff --git a/voxygen/src/hud/spell.rs b/voxygen/src/hud/spell.rs index ca49c4b30c..552c0c1074 100644 --- a/voxygen/src/hud/spell.rs +++ b/voxygen/src/hud/spell.rs @@ -74,17 +74,10 @@ impl<'a> Widget for Spell<'a> { id: _, state, ui, .. } = args; - if self._show.character_window { - Image::new(self.imgs.window_3) - .top_left_with_margins_on(ui.window, 200.0, 658.0) - .w_h(103.0 * 4.0, 122.0 * 4.0) - .set(state.spell_frame, ui); - } else { - Image::new(self.imgs.window_3) - .top_left_with_margins_on(ui.window, 200.0, 25.0) - .w_h(103.0 * 4.0, 122.0 * 4.0) - .set(state.spell_frame, ui); - } + Image::new(self.imgs.window_3) + .top_left_with_margins_on(ui.window, 200.0, 25.0) + .w_h(103.0 * 4.0, 122.0 * 4.0) + .set(state.spell_frame, ui); // X-Button if Button::image(self.imgs.close_button) From 11e4289f287ca00caad903201d6c055cd2fa2889 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Mon, 16 Mar 2020 20:50:01 +0100 Subject: [PATCH 120/326] small fixes --- assets/voxygen/element/buttons/min_plus/mmap_button-min.png | 4 ++-- assets/voxygen/element/buttons/min_plus/mmap_button-min.vox | 3 --- .../element/buttons/min_plus/mmap_button-min_hover.png | 4 ++-- .../element/buttons/min_plus/mmap_button-min_hover.vox | 3 --- .../element/buttons/min_plus/mmap_button-min_press.png | 4 ++-- .../element/buttons/min_plus/mmap_button-min_press.vox | 3 --- assets/voxygen/element/buttons/min_plus/mmap_button-plus.vox | 3 --- .../element/buttons/min_plus/mmap_button-plus_hover.vox | 3 --- .../element/buttons/min_plus/mmap_button-plus_press.vox | 3 --- assets/voxygen/element/misc_bg/charwindow.png | 3 --- voxygen/src/hud/img_ids.rs | 2 -- voxygen/src/menu/main/ui.rs | 2 +- 12 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-min.vox delete mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.vox delete mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-min_press.vox delete mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-plus.vox delete mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.vox delete mode 100644 assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.vox delete mode 100644 assets/voxygen/element/misc_bg/charwindow.png diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min.png index e6fe889a2c..fdfb9d5003 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:90ceab9579ba55096e1e0539e3126f49932029004901702fdbadcc08bb988e29 -size 206 +oid sha256:a763570725e6388d29512e0069cd8ca09a4867735380bb26d288fd303bb52805 +size 222 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min.vox b/assets/voxygen/element/buttons/min_plus/mmap_button-min.vox deleted file mode 100644 index 4846fc04d0..0000000000 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b32bf65b8f205ae1ece1a365cc115080954f81b4606c0ecdadc5348fcdc1a05e -size 58044 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png index e6fe889a2c..fdfb9d5003 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:90ceab9579ba55096e1e0539e3126f49932029004901702fdbadcc08bb988e29 -size 206 +oid sha256:a763570725e6388d29512e0069cd8ca09a4867735380bb26d288fd303bb52805 +size 222 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.vox b/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.vox deleted file mode 100644 index 2d4e5db864..0000000000 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:15d0cf0a74d08e6654d7afcbc9626089bafc83c499c75d77693867e5f3761835 -size 58044 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png index e6fe889a2c..fdfb9d5003 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:90ceab9579ba55096e1e0539e3126f49932029004901702fdbadcc08bb988e29 -size 206 +oid sha256:a763570725e6388d29512e0069cd8ca09a4867735380bb26d288fd303bb52805 +size 222 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.vox b/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.vox deleted file mode 100644 index 7c2d8b6e52..0000000000 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8f15fefed88aa5e069da1d496c92730cd3531ee81907450e301f81bc2ed03a7e -size 3560 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus.vox b/assets/voxygen/element/buttons/min_plus/mmap_button-plus.vox deleted file mode 100644 index 9503ce5391..0000000000 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-plus.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d6e5b5a9f78f8733a9e32f5b97a7d8f205ea157e91a2188eb47ccc8e0384aaa5 -size 58092 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.vox b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.vox deleted file mode 100644 index 4003eb833c..0000000000 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b7fcb6c6f2c6299fffec7569bbcb166b97078a185bd66f466754142c93b9d2b1 -size 58092 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.vox b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.vox deleted file mode 100644 index 4ed8343da5..0000000000 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:68463cf14fa559d584fcd49ebde24c9af724fb25724541e73b13d796382aea01 -size 58092 diff --git a/assets/voxygen/element/misc_bg/charwindow.png b/assets/voxygen/element/misc_bg/charwindow.png deleted file mode 100644 index 5d64bb4dbe..0000000000 --- a/assets/voxygen/element/misc_bg/charwindow.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f47a3a0744c93ad85d087e11e4a90f9ec2d721d7c2d8bf1c74bc461a9ef9a5dd -size 108690 diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 4888ea1379..6d6cdf548f 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -263,8 +263,6 @@ image_ids! { help:"voxygen.element.help", - charwindow_gradient:"voxygen.element.misc_bg.charwindow", - death_bg: "voxygen.background.death", hurt_bg: "voxygen.background.hurt", diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index 8832cc7e59..79df8719c5 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -459,7 +459,7 @@ impl MainMenuUi { }; } // Info Window - Rectangle::fill_with([550.0, 400.0], color::BLACK) + Rectangle::fill_with([550.0, 250.0], color::BLACK) .top_left_with_margins_on(ui_widgets.window, 40.0, 40.0) .color(Color::Rgba(0.0, 0.0, 0.0, 0.95)) .set(self.ids.info_frame, ui_widgets); From b040e18246cfd05ffcc6f4629362248d2c1743e8 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 16 Mar 2020 22:04:49 +0100 Subject: [PATCH 121/326] Fix body parts not changing --- .../voxel/humanoid_armor_chest_manifest.ron | 6 ++++- common/src/comp/body/humanoid.rs | 1 + server/src/sys/terrain.rs | 4 +-- voxygen/src/scene/figure/cache.rs | 26 ++++++++++++++----- voxygen/src/scene/figure/load.rs | 2 +- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index 873f515ec7..71e84fd00a 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -34,5 +34,9 @@ PlateGreen0: ( vox_spec: ("armor.chest.plate_green-0", (-7.0, -3.5, 2.0)), color: None + ), + None: ( + vox_spec: ("armor.chest.none", (-7.0, -3.5, 2.0)), + color: None ) -}) \ No newline at end of file +}) diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index c3deb1232d..00d550b3ba 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -483,6 +483,7 @@ pub enum Chest { Kimono = 6, Assassin = 7, PlateGreen0 = 8, + None = 9, } pub const ALL_CHESTS: [Chest; 9] = [ Chest::Blue, diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 2224afd53d..e705dea577 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -210,7 +210,7 @@ impl<'a> System<'a> for Sys { primary_ability: Some(CharacterAbility::BasicMelee { buildup_duration: Duration::from_millis(50), recover_duration: Duration::from_millis(50), - base_damage: 10, + base_damage: 1, }), secondary_ability: None, block_ability: None, @@ -251,7 +251,7 @@ impl<'a> System<'a> for Sys { primary_ability: Some(CharacterAbility::BasicMelee { buildup_duration: Duration::from_millis(800), recover_duration: Duration::from_millis(200), - base_damage: 130, + base_damage: 13, }), secondary_ability: None, block_ability: None, diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index b8a00539a1..a96d5825c3 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -6,7 +6,7 @@ use crate::{ }; use common::{ assets::watch::ReloadIndicator, - comp::{Body, CharacterState, ItemKind, Loadout, ToolKind}, + comp::{Body, CharacterState, Item, ItemKind, Loadout, ToolKind}, }; use hashbrown::{hash_map::Entry, HashMap}; use std::{ @@ -17,19 +17,25 @@ use std::{ #[derive(PartialEq, Eq, Hash, Clone)] enum FigureKey { Simple(Body), - Complex(Body, CameraMode, Option), + Complex(Body, CameraMode, CharacterCacheKey), } #[derive(PartialEq, Eq, Hash, Clone)] struct CharacterCacheKey { - state: Discriminant, // TODO: Can this be simplified? - active_tool: Option>, // TODO: Can this be simplified? + state: Option>, // TODO: Can this be simplified? + active_tool: Option>, + shoulder: Option, + chest: Option, + belt: Option, + hand: Option, + pants: Option, + foot: Option, } impl CharacterCacheKey { - fn from(cs: &CharacterState, loadout: &Loadout) -> Self { + fn from(cs: Option<&CharacterState>, loadout: &Loadout) -> Self { Self { - state: discriminant(&cs), + state: cs.map(|cs| discriminant(cs)), active_tool: if let Some(ItemKind::Tool(tool)) = loadout.active_item.as_ref().map(|i| &i.item.kind) { @@ -37,6 +43,12 @@ impl CharacterCacheKey { } else { None }, + shoulder: loadout.shoulder.clone(), + chest: loadout.chest.clone(), + belt: loadout.belt.clone(), + hand: loadout.hand.clone(), + pants: loadout.pants.clone(), + foot: loadout.foot.clone(), } } } @@ -74,7 +86,7 @@ impl FigureModelCache { FigureKey::Complex( body, camera_mode, - character_state.map(|cs| CharacterCacheKey::from(cs, loadout)), + CharacterCacheKey::from(character_state, loadout), ) } else { FigureKey::Simple(body) diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 2ecebb6cb3..fba6d5ee82 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -366,7 +366,7 @@ impl HumArmorChestSpec { { chest } else { - &Chest::Blue + &Chest::None }; let spec = match self.0.get(&chest) { From 7ded921ecc7381c64e5dfcc8d29f74603d59f56b Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Mon, 16 Mar 2020 22:58:19 +0100 Subject: [PATCH 122/326] more UI visuals --- .../min_plus/mmap_button-min_hover.png | 4 +- .../min_plus/mmap_button-min_press.png | 4 +- assets/voxygen/element/misc_bg/inv_bg_0.png | 3 + assets/voxygen/element/misc_bg/inv_bg_1.png | 3 + assets/voxygen/element/misc_bg/inv_runes.png | 4 +- assets/voxygen/i18n/en.ron | 4 +- voxygen/src/hud/bag.rs | 64 +++++++++++++++++-- voxygen/src/hud/img_ids.rs | 3 +- 8 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 assets/voxygen/element/misc_bg/inv_bg_0.png create mode 100644 assets/voxygen/element/misc_bg/inv_bg_1.png diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png index fdfb9d5003..89e0d5922e 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a763570725e6388d29512e0069cd8ca09a4867735380bb26d288fd303bb52805 -size 222 +oid sha256:bb34dc3409ec0cdc69820a995044881a15b884e4f21ee0dfa5e3b233d45ca64b +size 750 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png index fdfb9d5003..050b0ed017 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a763570725e6388d29512e0069cd8ca09a4867735380bb26d288fd303bb52805 -size 222 +oid sha256:3c8692d5b49c945d3bc9487241fd36fd19ed2651c7c806580c8650234cf90067 +size 738 diff --git a/assets/voxygen/element/misc_bg/inv_bg_0.png b/assets/voxygen/element/misc_bg/inv_bg_0.png new file mode 100644 index 0000000000..796bf67984 --- /dev/null +++ b/assets/voxygen/element/misc_bg/inv_bg_0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb15146cc53bf3060225f58f8a880d3ef22be23e305aa5106ba3d187e03b73a2 +size 126837 diff --git a/assets/voxygen/element/misc_bg/inv_bg_1.png b/assets/voxygen/element/misc_bg/inv_bg_1.png new file mode 100644 index 0000000000..f81c744864 --- /dev/null +++ b/assets/voxygen/element/misc_bg/inv_bg_1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c9347f7533c16a1dbf742fb397e7267e6b72f467676138c10153bd9778b845b1 +size 68382 diff --git a/assets/voxygen/element/misc_bg/inv_runes.png b/assets/voxygen/element/misc_bg/inv_runes.png index 9410b0afd4..bbc2d60f4f 100644 --- a/assets/voxygen/element/misc_bg/inv_runes.png +++ b/assets/voxygen/element/misc_bg/inv_runes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ba2d049b990ab3e8e4279b0cbc8540afb056f82d6c6a5cde7d4f6bfe3286cf50 -size 17340 +oid sha256:44ab3306cdf5e3267b3d6bbb837bea688eb78c36d223af2f6d606888a48bddff +size 58594 diff --git a/assets/voxygen/i18n/en.ron b/assets/voxygen/i18n/en.ron index de0078c0b5..76a819a277 100644 --- a/assets/voxygen/i18n/en.ron +++ b/assets/voxygen/i18n/en.ron @@ -192,7 +192,9 @@ Enjoy your stay in the World of Veloren."#, // Inventory - "hud.bag.inventory": "'s Inventory", + "hud.bag.inventory": "'s Inventory", + "hud.bag.stats": "'s Stats", + "hud.bag.exp": "Exp", // Settings "hud.settings.general": "General", "hud.settings.none": "None", diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 73fd1d66e9..f687dac683 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -138,7 +138,12 @@ impl<'a> Widget for Bag<'a> { None => return None, }; let exp_percentage = (self.stats.exp.current() as f64) / (self.stats.exp.maximum() as f64); - let exp_treshold = format!("{}/{}", self.stats.exp.current(), self.stats.exp.maximum()); + let exp_treshold = format!( + "{}/{} {}", + self.stats.exp.current(), + self.stats.exp.maximum(), + &self.localized_strings.get("hud.bag.exp") + ); let level = (self.stats.level.level()).to_string(); // Tooltips @@ -162,11 +167,15 @@ impl<'a> Widget for Bag<'a> { .desc_text_color(TEXT_COLOR); // BG - Image::new(self.imgs.inv_bg) - .w_h(424.0, 708.0) - .bottom_right_with_margins_on(ui.window, 60.0, 5.0) - .color(Some(UI_MAIN)) - .set(state.ids.bg, ui); + Image::new(if self.show.stats { + self.imgs.inv_bg_stats + } else { + self.imgs.inv_bg_armor + }) + .w_h(424.0, 708.0) + .bottom_right_with_margins_on(ui.window, 60.0, 5.0) + .color(Some(UI_MAIN)) + .set(state.ids.bg, ui); Image::new(self.imgs.inv_frame) .w_h(424.0, 708.0) .middle_of(state.ids.bg) @@ -214,12 +223,34 @@ impl<'a> Widget for Bag<'a> { .set(state.ids.inv_alignment, ui); if !self.show.stats { + // Title + Text::new(&format!( + "{}{}", + &self.stats.name, + &self.localized_strings.get("hud.bag.inventory") + )) + .mid_top_with_margin_on(state.ids.bg_frame, 9.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(22)) + .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) + .set(state.ids.inventory_title_bg, ui); + Text::new(&format!( + "{}{}", + &self.stats.name, + &self.localized_strings.get("hud.bag.inventory") + )) + .top_left_with_margins_on(state.ids.inventory_title_bg, 2.0, 2.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(22)) + .color(TEXT_COLOR) + .set(state.ids.inventory_title, ui); //Armor Slots //Slots BG Image::new(self.imgs.inv_runes) .w_h(424.0, 454.0) .mid_top_with_margin_on(state.ids.bg, 0.0) .color(Some(UI_HIGHLIGHT_0)) + .floating(true) .set(state.ids.slots_bg, ui); Image::new(self.imgs.inv_slots) .w_h(424.0, 401.0) @@ -228,6 +259,27 @@ impl<'a> Widget for Bag<'a> { .set(state.ids.slots_bg, ui); } else { // Stats + // Title + Text::new(&format!( + "{}{}", + &self.stats.name, + &self.localized_strings.get("hud.bag.stats") + )) + .mid_top_with_margin_on(state.ids.bg_frame, 9.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(22)) + .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) + .set(state.ids.inventory_title_bg, ui); + Text::new(&format!( + "{}{}", + &self.stats.name, + &self.localized_strings.get("hud.bag.stats") + )) + .top_left_with_margins_on(state.ids.inventory_title_bg, 2.0, 2.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(22)) + .color(TEXT_COLOR) + .set(state.ids.inventory_title, ui); // Alignment for Stats Rectangle::fill_with([418.0, 384.0], color::TRANSPARENT) .mid_top_with_margin_on(state.ids.bg_frame, 48.0) diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 6d6cdf548f..2c70bd4ab2 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -244,7 +244,8 @@ image_ids! { close_btn_press: "voxygen.element.buttons.close_btn_press", // Inventory - inv_bg: "voxygen.element.misc_bg.inv_bg", + inv_bg_armor: "voxygen.element.misc_bg.inv_bg_0", + inv_bg_stats: "voxygen.element.misc_bg.inv_bg_1", inv_frame: "voxygen.element.misc_bg.inv_frame", char_art: "voxygen.element.icons.character", inv_slot: "voxygen.element.buttons.inv_slot", From f32eb1db7517528fd6fc05dcf3c375f51f1be5dc Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 17 Mar 2020 14:15:39 +0100 Subject: [PATCH 123/326] fix dash attack angles, arrow damage and readd possession stick impl --- common/src/comp/character_state.rs | 3 +- common/src/comp/inventory/item.rs | 14 ++++++-- common/src/comp/stats.rs | 2 +- common/src/states/basic_melee.rs | 1 + common/src/states/basic_ranged.rs | 4 ++- common/src/states/dash_melee.rs | 1 + common/src/states/timed_combo.rs | 1 + common/src/sys/combat.rs | 2 +- server/src/events/interaction.rs | 56 +++++++++--------------------- 9 files changed, 39 insertions(+), 45 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 66edd98f7b..649e8934dc 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -100,9 +100,10 @@ impl Component for CharacterState { type Storage = FlaggedStorage>; } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Attacking { pub base_damage: u32, + pub max_angle: f32, pub applied: bool, pub hit_count: u32, } diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 708b31a7b4..16961c3005 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -71,7 +71,7 @@ impl ToolData { hit_entity: vec![ projectile::Effect::Damage(HealthChange { // TODO: This should not be fixed (?) - amount: -30, + amount: -3, cause: HealthSource::Item, }), projectile::Effect::Vanish, @@ -104,7 +104,17 @@ impl ToolData { only_up: true, }, ], - Possess => vec![], + Possess => vec![BasicRanged { + projectile: Projectile { + hit_ground: vec![projectile::Effect::Stick], + hit_wall: vec![projectile::Effect::Stick], + hit_entity: vec![projectile::Effect::Stick, projectile::Effect::Possess], + time_left: Duration::from_secs(10), + owner: None, + }, + projectile_body: Body::Object(object::Body::ArrowSnake), + recover_duration: Duration::from_millis(300), + }], }, Empty => vec![], } diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index cb43eb985d..e5e3e7e642 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -134,7 +134,7 @@ impl Stats { } // TODO: Delete this once stat points will be a thing - pub fn update_max_hp(&mut self) { self.health.set_maximum(21 + 3 * self.level.amount); } + pub fn update_max_hp(&mut self) { self.health.set_maximum(33 + 7 * self.level.amount); } } impl Stats { diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 1f972e0594..0c1a8d3ea1 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -46,6 +46,7 @@ impl CharacterBehavior for Data { // Hit attempt data.updater.insert(data.entity, Attacking { base_damage: self.base_damage, + max_angle: 75_f32.to_radians(), applied: false, hit_count: 0, }); diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index 533759d031..40412bb558 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -48,12 +48,14 @@ impl CharacterBehavior for Data { }); } else if !self.exhausted { // Fire + let mut projectile = self.projectile.clone(); + projectile.owner = Some(*data.uid); update.server_events.push_front(ServerEvent::Shoot { entity: data.entity, dir: data.inputs.look_dir, body: self.projectile_body, light: None, - projectile: self.projectile.clone(), + projectile, gravity: Some(Gravity(0.1)), }); diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index a58eb31d62..b72502d219 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -54,6 +54,7 @@ impl CharacterBehavior for Data { // Hit attempt data.updater.insert(data.entity, Attacking { base_damage: self.base_damage, + max_angle: 180_f32.to_radians(), applied: false, hit_count: 0, }); diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index cd7cd7b9d9..56be959851 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -61,6 +61,7 @@ impl CharacterBehavior for Data { // Swing hits data.updater.insert(data.entity, Attacking { base_damage: self.base_damage * (self.stage as u32 + 1), + max_angle: 75_f32.to_radians(), applied: false, hit_count: 0, }); diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index f5ebc3e0ea..f6cdb6ca3d 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -101,7 +101,7 @@ impl<'a> System<'a> for Sys { && !stats_b.is_dead // Spherical wedge shaped attack field && pos.0.distance_squared(pos_b.0) < (rad_b + scale * ATTACK_RANGE).powi(2) - && ori2.angle_between(pos_b2 - pos2) < ATTACK_ANGLE.to_radians() / 2.0 + (rad_b / pos2.distance(pos_b2)).atan() + && ori2.angle_between(pos_b2 - pos2) < attack.max_angle + (rad_b / pos2.distance(pos_b2)).atan() { // Weapon gives base damage let mut dmg = attack.base_damage; diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index 7d7e3fd124..e424554ab3 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -77,46 +77,24 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) { e ) }); - // Create inventory if it doesn't exist - { - let mut inventories = ecs.write_storage::(); - if let Some(inventory) = inventories.get_mut(possesse) { - inventory.push(assets::load_expect_cloned("common.items.debug.possess")); - } else { - inventories - .insert(possesse, comp::Inventory { - slots: vec![ - Some(assets::load_expect_cloned("common.items.debug.possess")), - None, - None, - None, - None, - None, - None, - None, - ], - }) - .err() - .map(|e| { - error!( - "Error inserting inventory component during possession: {:?}", - e - ) - }); - } - } - ecs.write_storage::() - .insert( - possesse, - comp::InventoryUpdate::new(comp::InventoryUpdateEvent::Possession), - ) - .err() - .map(|e| { - error!( - "Error inserting inventory update component during possession: {:?}", - e - ) + // Put possess item into loadout + let mut loadouts = ecs.write_storage::(); + let loadout = loadouts + .entry(possesse) + .expect("Could not read loadouts component while possessing") + .or_insert(comp::Loadout::default()); + + let item = assets::load_expect_cloned::("common.items.debug.possess"); + if let comp::ItemKind::Tool(tool) = item.kind { + loadout.active_item = Some(comp::ItemConfig { + item, + primary_ability: tool.get_abilities().get(0).cloned(), + secondary_ability: None, + block_ability: None, + dodge_ability: None, }); + } + // Move player component { let mut players = ecs.write_storage::(); From 3559252a5e50ad240c6b340eef7987b7aef1389f Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Tue, 17 Mar 2020 13:29:42 +0000 Subject: [PATCH 124/326] Nicer point lights --- assets/voxygen/shaders/include/light.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/voxygen/shaders/include/light.glsl b/assets/voxygen/shaders/include/light.glsl index e937535b78..1496dd2d42 100644 --- a/assets/voxygen/shaders/include/light.glsl +++ b/assets/voxygen/shaders/include/light.glsl @@ -25,7 +25,7 @@ vec3 illuminate(vec3 color, vec3 light, vec3 diffuse, vec3 ambience) { } float attenuation_strength(vec3 rpos) { - return 1.0 / (rpos.x * rpos.x + rpos.y * rpos.y + rpos.z * rpos.z); + return 1.0 / pow(rpos.x * rpos.x + rpos.y * rpos.y + rpos.z * rpos.z, 0.6); } vec3 light_at(vec3 wpos, vec3 wnorm) { From 19a09782a0bd6045e6b637da871b1ccd37fb010b Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 17 Mar 2020 15:01:41 +0100 Subject: [PATCH 125/326] Add ability requirements system --- common/src/comp/ability.rs | 28 +++++++++++++- common/src/comp/energy.rs | 3 +- common/src/states/utils.rs | 79 +++++++++++++------------------------- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 2faf68ce69..dc293fbc6c 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1,6 +1,7 @@ use crate::{ - comp::{Body, CharacterState, Item, Projectile, ToolData}, + comp::{Body, CharacterState, EnergySource, Item, Projectile, StateUpdate, ToolData}, states::*, + sys::character_behavior::JoinData, }; use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage}; use std::time::Duration; @@ -37,6 +38,31 @@ pub enum CharacterAbility { }, } +impl CharacterAbility { + pub fn test_requirements(&self, data: &JoinData, update: &mut StateUpdate) -> bool { + match self { + CharacterAbility::Roll => { + data.physics.on_ground + && !data.physics.in_fluid + && data.body.is_humanoid() + && update + .energy + .try_change_by(-200, EnergySource::Ability) + .is_ok() + }, + CharacterAbility::DashMelee { .. } => { + data.physics.on_ground + && !data.physics.in_fluid + && update + .energy + .try_change_by(-300, EnergySource::Ability) + .is_ok() + }, + _ => true, + } + } +} + impl Component for CharacterAbility { type Storage = DenseVecStorage; } diff --git a/common/src/comp/energy.rs b/common/src/comp/energy.rs index cb7fabee44..bbc481daca 100644 --- a/common/src/comp/energy.rs +++ b/common/src/comp/energy.rs @@ -11,8 +11,7 @@ pub struct Energy { #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub enum EnergySource { - CastSpell, - Roll, + Ability, Climb, LevelUp, HitEnemy, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index e3c36f1887..c039db1310 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -183,78 +183,53 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { } /// If `inputs.primary` is pressed and in `Wielding` state, -/// will attempt to go into `ability_pool.primary` +/// will attempt to go into `loadout.active_item.primary_ability` pub fn handle_primary_input(data: &JoinData, update: &mut StateUpdate) { if data.inputs.primary.is_pressed() { - if let CharacterState::Wielding { .. } = update.character { - attempt_primary_ability(data, update); + if let Some(ability) = data + .loadout + .active_item + .as_ref() + .and_then(|i| i.primary_ability.as_ref()) + .filter(|ability| ability.test_requirements(data, update)) + { + update.character = ability.into(); } } } -/// Attempts to go into `ability_pool.primary` if is `Some()` on `AbilityPool` -pub fn attempt_primary_ability(data: &JoinData, update: &mut StateUpdate) { - if let Some(ability) = data - .loadout - .active_item - .as_ref() - .and_then(|i| i.primary_ability.as_ref()) - { - update.character = ability.into(); - } -} - /// If `inputs.secondary` is pressed and in `Wielding` state, -/// will attempt to go into `ability_pool.secondary` +/// will attempt to go into `loadout.active_item.secondary_ability` pub fn handle_secondary_input(data: &JoinData, update: &mut StateUpdate) { if data.inputs.secondary.is_pressed() { - if let CharacterState::Wielding { .. } = update.character { - attempt_secondary_ability(data, update); + if let Some(ability) = data + .loadout + .active_item + .as_ref() + .and_then(|i| i.secondary_ability.as_ref()) + .filter(|ability| ability.test_requirements(data, update)) + { + update.character = ability.into(); } } } -/// Attempts to go into `ability_pool.secondary` if is `Some()` on `AbilityPool` -pub fn attempt_secondary_ability(data: &JoinData, update: &mut StateUpdate) { - if let Some(ability) = data - .loadout - .active_item - .as_ref() - .and_then(|i| i.secondary_ability.as_ref()) - { - update.character = ability.into(); - } -} - /// Checks that player can perform a dodge, then -/// attempts to go into `ability_pool.dodge` +/// attempts to go into `loadout.active_item.dodge_ability` pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { - if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { - if data.inputs.roll.is_pressed() - && data.physics.on_ground - && !data.physics.in_fluid - && data.body.is_humanoid() - && update - .energy - .try_change_by(-200, EnergySource::Roll) - .is_ok() + if data.inputs.roll.is_pressed() { + if let Some(ability) = data + .loadout + .active_item + .as_ref() + .and_then(|i| i.dodge_ability.as_ref()) + .filter(|ability| ability.test_requirements(data, update)) { - attempt_dodge_ability(data, update); + update.character = ability.into(); } } } -pub fn attempt_dodge_ability(data: &JoinData, update: &mut StateUpdate) { - if let Some(ability) = data - .loadout - .active_item - .as_ref() - .and_then(|i| i.dodge_ability.as_ref()) - { - update.character = ability.into(); - } -} - pub fn unwrap_tool_data<'a>(data: &'a JoinData) -> Option<&'a ToolData> { if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(tool) From 4580752e78e467805c86616cdaeabc7c02f62e48 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Tue, 17 Mar 2020 14:14:20 +0000 Subject: [PATCH 126/326] Fixed remaining pathfinding issues --- common/src/path.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/common/src/path.rs b/common/src/path.rs index 1d21b51819..edce17249e 100644 --- a/common/src/path.rs +++ b/common/src/path.rs @@ -218,8 +218,26 @@ where ]; DIRS.iter() - .map(move |dir| pos + dir) - .filter(move |pos| is_walkable(pos)) + .map(move |dir| (pos, dir)) + .filter(move |(pos, dir)| { + is_walkable(pos) + && ((dir.z < 1 + || vol + .get(pos + Vec3::unit_z() * 2) + .map(|b| !b.is_solid()) + .unwrap_or(true)) + && (dir.z < 2 + || vol + .get(pos + Vec3::unit_z() * 3) + .map(|b| !b.is_solid()) + .unwrap_or(true)) + && (dir.z > 0 + || vol + .get(pos + *dir + Vec3::unit_z() * 2) + .map(|b| !b.is_solid()) + .unwrap_or(true))) + }) + .map(move |(pos, dir)| pos + dir) .chain( DIAGONALS .iter() From 40910b28e4e72e680fa2c5113a1da116e063336f Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Tue, 17 Mar 2020 15:39:29 +0100 Subject: [PATCH 127/326] unclothed parts --- .../voxygen/voxel/armor/chest/chest_none.vox | 3 + assets/voxygen/voxel/armor/chest/none.vox | 3 - assets/voxygen/voxel/armor/foot/foot_none.vox | 3 + .../voxel/armor/hand/hand_left_none.vox | 3 + .../voxel/armor/hand/hand_right_none.vox | 3 + .../voxygen/voxel/armor/pants/pants_none.vox | 3 + .../voxel/humanoid_armor_belt_manifest.ron | 5 ++ .../voxel/humanoid_armor_chest_manifest.ron | 9 +-- .../voxel/humanoid_armor_foot_manifest.ron | 5 +- .../voxel/humanoid_armor_hand_manifest.ron | 4 +- .../voxel/humanoid_armor_pants_manifest.ron | 4 ++ common/src/comp/body/humanoid.rs | 59 ++++++++++--------- voxygen/src/scene/figure/load.rs | 2 +- 13 files changed, 66 insertions(+), 40 deletions(-) create mode 100644 assets/voxygen/voxel/armor/chest/chest_none.vox delete mode 100644 assets/voxygen/voxel/armor/chest/none.vox create mode 100644 assets/voxygen/voxel/armor/foot/foot_none.vox create mode 100644 assets/voxygen/voxel/armor/hand/hand_left_none.vox create mode 100644 assets/voxygen/voxel/armor/hand/hand_right_none.vox create mode 100644 assets/voxygen/voxel/armor/pants/pants_none.vox diff --git a/assets/voxygen/voxel/armor/chest/chest_none.vox b/assets/voxygen/voxel/armor/chest/chest_none.vox new file mode 100644 index 0000000000..d069a845bf --- /dev/null +++ b/assets/voxygen/voxel/armor/chest/chest_none.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0e68800bb3cb0397f590620f78ff8333fda650db5283ffa8ca9f4034d2b0397d +size 2600 diff --git a/assets/voxygen/voxel/armor/chest/none.vox b/assets/voxygen/voxel/armor/chest/none.vox deleted file mode 100644 index 81d8cd472d..0000000000 --- a/assets/voxygen/voxel/armor/chest/none.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4a9d575c5ff1c36714fe5a69ca6aad4eb2b16e4bcccfd924fc38e4c7ecbe94d5 -size 55915 diff --git a/assets/voxygen/voxel/armor/foot/foot_none.vox b/assets/voxygen/voxel/armor/foot/foot_none.vox new file mode 100644 index 0000000000..8b7ce6c7c0 --- /dev/null +++ b/assets/voxygen/voxel/armor/foot/foot_none.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4bbcaa4c986daea335e3178cf49fed844c536c30643c042d07c116832dc93e6b +size 1416 diff --git a/assets/voxygen/voxel/armor/hand/hand_left_none.vox b/assets/voxygen/voxel/armor/hand/hand_left_none.vox new file mode 100644 index 0000000000..f21b658e70 --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/hand_left_none.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9131c1364685750aa5a18b052be26ae0a08654a0cac99c006cf28d4bbae872d +size 1240 diff --git a/assets/voxygen/voxel/armor/hand/hand_right_none.vox b/assets/voxygen/voxel/armor/hand/hand_right_none.vox new file mode 100644 index 0000000000..ff3d290391 --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/hand_right_none.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d7a8e559f0930ac92047a8dc141766210f6a566ca20a87496a0449111eb0192 +size 1240 diff --git a/assets/voxygen/voxel/armor/pants/pants_none.vox b/assets/voxygen/voxel/armor/pants/pants_none.vox new file mode 100644 index 0000000000..c0297458bd --- /dev/null +++ b/assets/voxygen/voxel/armor/pants/pants_none.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b161523b19d3a236699e73930e108b8ac79efe6b71fbf9d8b5f63eaa23bd91dd +size 1880 diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index a9a546e6b1..7e149a2be8 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -1,4 +1,8 @@ ({ + None:( + vox_spec: ("armor.belt.belt-none", (-5.0, -3.5, 2.0)), + color: None + ), Dark:( vox_spec: ("armor.belt.dark", (-4.0, -3.5, 2.0)), color: None @@ -27,4 +31,5 @@ vox_spec: ("armor.belt.plate-0", (-5.0, -3.5, 2.0)), color: None ), + }) diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index 71e84fd00a..b819667456 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -1,4 +1,8 @@ ({ + None: ( + vox_spec: ("armor.chest.chest_none", (-7.0, -3.5, 2.0)), + color: None + ), Blue: ( vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), color: Some((44, 74, 109)) @@ -35,8 +39,5 @@ vox_spec: ("armor.chest.plate_green-0", (-7.0, -3.5, 2.0)), color: None ), - None: ( - vox_spec: ("armor.chest.none", (-7.0, -3.5, 2.0)), - color: None - ) + }) diff --git a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron index 915555b4db..b6c74b15a8 100644 --- a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron @@ -1,7 +1,6 @@ -({ - //This shouldn't be bare, but what is? +({ Bare: ( - vox_spec: ("armor.foot.cloth_sandals", (-2.5, -3.5, -9.0)), + vox_spec: ("armor.foot.foot_none", (-2.5, -3.5, -9.0)), color: None ), Dark: ( diff --git a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron index 44f365a5ea..15580d60a3 100644 --- a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron @@ -1,11 +1,11 @@ ({ Bare: ( left: ( - vox_spec: ("armor.hand.bare_left", (-1.5, -1.5, -7.0)), + vox_spec: ("armor.hand.hand_left_none", (-1.5, -1.5, -7.0)), color: None ), right: ( - vox_spec: ("armor.hand.bare_right", (-1.5, -1.5, -7.0)), + vox_spec: ("armor.hand.hand_right_none", (-1.5, -1.5, -7.0)), color: None ) ), diff --git a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron index 9f9176231e..c7f3e79e53 100644 --- a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron @@ -1,4 +1,8 @@ ({ + None: ( + vox_spec: ("armor.pants.pants_none", (-5.0, -3.5, 1.0)), + color: Some((28, 66, 109)) + ), Blue: ( vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), color: Some((28, 66, 109)) diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index 00d550b3ba..28f2a80603 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -474,18 +474,19 @@ pub const ALL_BODY_TYPES: [BodyType; 2] = [BodyType::Female, BodyType::Male]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Chest { - Blue = 0, - Brown = 1, - Dark = 2, - Green = 3, - Orange = 4, - Midnight = 5, - Kimono = 6, - Assassin = 7, - PlateGreen0 = 8, - None = 9, + None = 0, + Blue = 1, + Brown = 2, + Dark = 3, + Green = 4, + Orange = 5, + Midnight = 6, + Kimono = 7, + Assassin = 8, + PlateGreen0 = 9, } -pub const ALL_CHESTS: [Chest; 9] = [ +pub const ALL_CHESTS: [Chest; 10] = [ + Chest::None, Chest::Blue, Chest::Brown, Chest::Dark, @@ -500,14 +501,16 @@ pub const ALL_CHESTS: [Chest; 9] = [ #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Belt { - Dark = 0, - TurqCloth = 1, - BloodCloth = 2, - BlackCloth = 3, - Assassin = 4, - Plate0 = 5, + None = 0, + Dark = 1, + TurqCloth = 2, + BloodCloth = 3, + BlackCloth = 4, + Assassin = 5, + Plate0 = 6, } -pub const ALL_BELTS: [Belt; 6] = [ +pub const ALL_BELTS: [Belt; 7] = [ + Belt::None, Belt::Dark, Belt::TurqCloth, Belt::BloodCloth, @@ -519,16 +522,18 @@ pub const ALL_BELTS: [Belt; 6] = [ #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Pants { - Blue = 0, - Brown = 1, - Dark = 2, - Green = 3, - Orange = 4, - Kimono = 5, - Assassin = 6, - PlateGreen0 = 7, + None = 0, + Blue = 1, + Brown = 2, + Dark = 3, + Green = 4, + Orange = 5, + Kimono = 6, + Assassin = 7, + PlateGreen0 = 8, } -pub const ALL_PANTS: [Pants; 8] = [ +pub const ALL_PANTS: [Pants; 9] = [ + Pants::None, Pants::Blue, Pants::Brown, Pants::Dark, diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index fba6d5ee82..a2d886ec1f 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -520,7 +520,7 @@ impl HumArmorPantsSpec { { pants } else { - &Pants::Dark + &Pants::None }; let spec = match self.0.get(&pants) { From b9f6dfac77d269b795242e149fcd62453dfb7205 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Tue, 17 Mar 2020 16:07:20 +0100 Subject: [PATCH 128/326] fixes --- assets/voxygen/voxel/armor/belt/belt_none.vox | 3 +++ assets/voxygen/voxel/armor/chest/chest_none.vox | 4 ++-- assets/voxygen/voxel/armor/foot/foot_none.vox | 4 ++-- assets/voxygen/voxel/humanoid_armor_belt_manifest.ron | 2 +- voxygen/src/scene/figure/load.rs | 6 +++--- 5 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 assets/voxygen/voxel/armor/belt/belt_none.vox diff --git a/assets/voxygen/voxel/armor/belt/belt_none.vox b/assets/voxygen/voxel/armor/belt/belt_none.vox new file mode 100644 index 0000000000..aa27c2a7cb --- /dev/null +++ b/assets/voxygen/voxel/armor/belt/belt_none.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2be744a5ee964b6f325875424a32a121386a87f88c53cf61553b171c6ff9dad7 +size 1472 diff --git a/assets/voxygen/voxel/armor/chest/chest_none.vox b/assets/voxygen/voxel/armor/chest/chest_none.vox index d069a845bf..1e9089c6b0 100644 --- a/assets/voxygen/voxel/armor/chest/chest_none.vox +++ b/assets/voxygen/voxel/armor/chest/chest_none.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0e68800bb3cb0397f590620f78ff8333fda650db5283ffa8ca9f4034d2b0397d -size 2600 +oid sha256:aaf05edac3fb92fab781293452dd074f915763bc3650cf79c4dbf356da3cfb23 +size 57075 diff --git a/assets/voxygen/voxel/armor/foot/foot_none.vox b/assets/voxygen/voxel/armor/foot/foot_none.vox index 8b7ce6c7c0..8bb8442d00 100644 --- a/assets/voxygen/voxel/armor/foot/foot_none.vox +++ b/assets/voxygen/voxel/armor/foot/foot_none.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4bbcaa4c986daea335e3178cf49fed844c536c30643c042d07c116832dc93e6b -size 1416 +oid sha256:e7c2c8e06095499d1b72c17433fc401969166a7634e815965568b4c5326d63ea +size 55899 diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index 7e149a2be8..b0fb98ac76 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -1,6 +1,6 @@ ({ None:( - vox_spec: ("armor.belt.belt-none", (-5.0, -3.5, 2.0)), + vox_spec: ("armor.belt.belt_none", (-5.0, -3.5, 2.0)), color: None ), Dark:( diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index a2d886ec1f..fd3602df48 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -386,7 +386,7 @@ impl HumArmorChestSpec { ) }; - let bare_chest = graceful_load_mat_segment("armor.chest.none"); + let bare_chest = graceful_load_mat_segment("armor.empty"); let mut chest_armor = graceful_load_mat_segment(&spec.vox_spec.0); @@ -484,7 +484,7 @@ impl HumArmorBeltSpec { { belt } else { - &Belt::Dark + &Belt::None }; let spec = match self.0.get(&belt) { @@ -540,7 +540,7 @@ impl HumArmorPantsSpec { ) }; - let bare_pants = graceful_load_mat_segment("armor.pants.grayscale"); + let bare_pants = graceful_load_mat_segment("armor.empty"); let mut pants_armor = graceful_load_mat_segment(&spec.vox_spec.0); From 08b44db1fcbfbde2d30f0be247bf599f6edc4126 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 17 Mar 2020 16:01:12 +0100 Subject: [PATCH 129/326] Stop first person bounce in air --- voxygen/src/scene/mod.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index a5517e134c..947fcb3ed3 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -174,26 +174,27 @@ impl Scene { gamma: f32, ) { // Get player position. - let player_pos = scene_data - .state - .ecs() + let ecs = scene_data.state.ecs(); + + let player_pos = ecs .read_storage::() .get(scene_data.player_entity) .map_or(Vec3::zero(), |pos| pos.0); - let player_rolling = scene_data - .state - .ecs() + let player_rolling = ecs .read_storage::() .get(scene_data.player_entity) .map_or(false, |cs| cs.is_dodge()); - let player_running = scene_data - .state - .ecs() + let is_running = ecs .read_storage::() .get(scene_data.player_entity) - .map_or(false, |v| v.0.magnitude_squared() > 0.5); + .map(|v| v.0.magnitude_squared() > 0.5); + + let on_ground = ecs + .read_storage::() + .get(scene_data.player_entity) + .map(|p| p.on_ground); let player_scale = match scene_data .state @@ -219,7 +220,7 @@ impl Scene { CameraMode::FirstPerson => { if player_rolling { player_scale * 0.8 - } else if player_running { + } else if is_running.unwrap_or(false) && on_ground.unwrap_or(false) { player_scale * 1.6 + (scene_data.state.get_time() as f32 * 17.0).sin() * 0.05 } else { player_scale * 1.6 From d6929ae0ea60d3a6781ea68aa4633767858083b6 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 17 Mar 2020 16:22:34 +0100 Subject: [PATCH 130/326] Select newly created character automatically --- voxygen/src/menu/char_selection/ui.rs | 12 ++++++------ voxygen/src/meta.rs | 6 +++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index e92ac24250..f9cfa9efdd 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -720,12 +720,12 @@ impl CharSelectionUi { .set(self.ids.create_button, ui_widgets) .was_clicked() { - // TODO: Save character. - global_state.meta.add_character(CharacterData { - name: name.clone(), - body: comp::Body::Humanoid(body.clone()), - tool: tool.map(|tool| tool.to_string()), - }); + global_state.meta.selected_character = + global_state.meta.add_character(CharacterData { + name: name.clone(), + body: comp::Body::Humanoid(body.clone()), + tool: tool.map(|tool| tool.to_string()), + }); to_select = true; } // Character Name Input diff --git a/voxygen/src/meta.rs b/voxygen/src/meta.rs index bbfee9dd27..9e4cf29ac3 100644 --- a/voxygen/src/meta.rs +++ b/voxygen/src/meta.rs @@ -28,7 +28,11 @@ impl Meta { } } - pub fn add_character(&mut self, data: CharacterData) { self.characters.push(data); } + pub fn add_character(&mut self, data: CharacterData) -> usize { + self.characters.push(data); + // return new character's index + self.characters.len() - 1 + } pub fn load() -> Self { let path = Self::get_meta_path(); From 431974cf8eb10c3f62f7c452a3846b6f15bb7726 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Tue, 17 Mar 2020 17:02:50 +0100 Subject: [PATCH 131/326] test armor slot --- assets/voxygen/element/buttons/armor_slot.png | 3 ++ voxygen/src/hud/bag.rs | 54 +++++++++++++++++-- voxygen/src/hud/img_ids.rs | 1 + 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 assets/voxygen/element/buttons/armor_slot.png diff --git a/assets/voxygen/element/buttons/armor_slot.png b/assets/voxygen/element/buttons/armor_slot.png new file mode 100644 index 0000000000..2eb79d4449 --- /dev/null +++ b/assets/voxygen/element/buttons/armor_slot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a2fb5c403dced0781cff9dc7ea824a290178a114db9199e50cd762f8540f80c9 +size 2002 diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index f687dac683..c8348e4dd6 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -17,6 +17,7 @@ use conrod_core::{ widget_ids! { struct Ids { + test, bag_close, inv_alignment, inv_grid_1, @@ -38,8 +39,6 @@ widget_ids! { tab_2, tab_3, tab_4, - //Armor Slots - slots_bg, //Stats stats_alignment, level, @@ -50,7 +49,22 @@ widget_ids! { divider, statnames, stats, - + //Armor Slots + slots_bg, + head_bg, + neck_bg, + chest_bg, + shoulder_bg, + hands_bg, + pants_bg, + belt_bg, + ring-r_bg, + ring-l_bg, + foot_bg, + back_bg, + tabard_bg, + mainhand_bg, + offhand_bg, } } @@ -257,6 +271,40 @@ impl<'a> Widget for Bag<'a> { .mid_top_with_margin_on(state.ids.bg, 57.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.slots_bg, ui); + // Armor Slots + //Head + //Necklace + //Chest + Image::new(self.imgs.armor_slot) // different graphics for empty/non empty + .w_h(86.0, 86.0) + .mid_top_with_margin_on(state.ids.slots_bg, 162.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.chest_bg, ui); + Button::image(self.imgs.skull) + .w_h(80.0, 80.0) + .middle_of(state.ids.chest_bg) + .set(state.ids.test, ui); + //Shoulder + //Hands + //Belt + Image::new(self.imgs.armor_slot) + .w_h(44.0, 44.0) + .down_from(state.ids.chest_bg, 11.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.chest_bg, ui); + //Pants + Image::new(self.imgs.armor_slot) + .w_h(86.0, 86.0) + .down_from(state.ids.belt_bg, 11.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.pants_bg, ui); + //Ring-L + //Ring-R + //Foot + //Back + //Tabard + //Mainhand/Left-Slot + //Offhand/Right-Slot } else { // Stats // Title diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 2c70bd4ab2..bcdae37b80 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -257,6 +257,7 @@ image_ids! { inv_tab_inactive_press: "voxygen.element.buttons.inv_tab_inactive", inv_slots: "voxygen.element.misc_bg.inv_slots", inv_runes: "voxygen.element.misc_bg.inv_runes", + armor_slot: "voxygen.element.buttons.armor_slot", From 95eeb7e145e2b1cf064ad056d837d97291ebd26e Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Tue, 17 Mar 2020 16:37:39 +0000 Subject: [PATCH 132/326] Omitted unnecessary test --- common/src/path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/path.rs b/common/src/path.rs index edce17249e..85e8f174af 100644 --- a/common/src/path.rs +++ b/common/src/path.rs @@ -231,7 +231,7 @@ where .get(pos + Vec3::unit_z() * 3) .map(|b| !b.is_solid()) .unwrap_or(true)) - && (dir.z > 0 + && (dir.z >= 0 || vol .get(pos + *dir + Vec3::unit_z() * 2) .map(|b| !b.is_solid()) From 4741e4123088617807f3881b6ba4439f25238aef Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 17 Mar 2020 18:27:52 +0100 Subject: [PATCH 133/326] Add support for different models per weapon type --- assets/common/items/weapons/hammer_1.ron | 2 +- assets/common/items/weapons/shield_1.ron | 2 +- assets/common/items/weapons/staff_1.ron | 2 +- assets/common/items/weapons/starter_axe.ron | 2 +- assets/common/items/weapons/starter_bow.ron | 2 +- .../common/items/weapons/starter_dagger.ron | 2 +- .../common/items/weapons/starter_hammer.ron | 2 +- assets/common/items/weapons/starter_staff.ron | 6 +-- assets/voxygen/item_image_manifest.ron | 12 ++--- .../voxel/humanoid_main_weapon_manifest.ron | 42 ++++++++++++++++ common/src/comp/inventory/item.rs | 49 ++++++++++++++----- common/src/sys/agent.rs | 3 +- voxygen/src/anim/character/attack.rs | 12 ++--- voxygen/src/anim/character/block.rs | 12 ++--- voxygen/src/anim/character/blockidle.rs | 12 ++--- voxygen/src/anim/character/cidle.rs | 12 ++--- voxygen/src/anim/character/mod.rs | 28 +++++------ voxygen/src/anim/character/wield.rs | 12 ++--- voxygen/src/anim/mod.rs | 28 +++++------ voxygen/src/hud/bag.rs | 4 +- voxygen/src/hud/skillbar.rs | 40 +++++++-------- voxygen/src/scene/figure/cache.rs | 4 +- voxygen/src/scene/figure/load.rs | 49 ++++++++++++------- 23 files changed, 208 insertions(+), 131 deletions(-) create mode 100644 assets/voxygen/voxel/humanoid_main_weapon_manifest.ron diff --git a/assets/common/items/weapons/hammer_1.ron b/assets/common/items/weapons/hammer_1.ron index 268cf1f7da..9f31453a57 100644 --- a/assets/common/items/weapons/hammer_1.ron +++ b/assets/common/items/weapons/hammer_1.ron @@ -5,7 +5,7 @@ Item( Power: 20", kind: Tool( ToolData ( - kind: Hammer, + kind: Hammer(BasicHammer), equip_time_millis: 1000, ) ) diff --git a/assets/common/items/weapons/shield_1.ron b/assets/common/items/weapons/shield_1.ron index 23dd6b0ddb..8ad6d4f71b 100644 --- a/assets/common/items/weapons/shield_1.ron +++ b/assets/common/items/weapons/shield_1.ron @@ -3,7 +3,7 @@ Item( description: "Legends tell this item is useless.", kind: Tool ( ToolData ( - kind: Shield, + kind: Shield(BasicShield), equip_time_millis: 400, ) ), diff --git a/assets/common/items/weapons/staff_1.ron b/assets/common/items/weapons/staff_1.ron index 4a66a40399..6ad09d6635 100644 --- a/assets/common/items/weapons/staff_1.ron +++ b/assets/common/items/weapons/staff_1.ron @@ -5,7 +5,7 @@ Item( Power: 6", kind: Tool( ToolData ( - kind: Staff, + kind: Staff(BasicStaff), equip_time_millis: 800, ) ), diff --git a/assets/common/items/weapons/starter_axe.ron b/assets/common/items/weapons/starter_axe.ron index 89a71e297c..a534e2eaa4 100644 --- a/assets/common/items/weapons/starter_axe.ron +++ b/assets/common/items/weapons/starter_axe.ron @@ -5,7 +5,7 @@ Item( Power: 15", kind: Tool( ToolData ( - kind: Axe, + kind: Axe(BasicAxe), equip_time_millis: 1000, ) ), diff --git a/assets/common/items/weapons/starter_bow.ron b/assets/common/items/weapons/starter_bow.ron index 14b11333a5..33064b766b 100644 --- a/assets/common/items/weapons/starter_bow.ron +++ b/assets/common/items/weapons/starter_bow.ron @@ -5,7 +5,7 @@ Item( Power: 15", kind: Tool( ToolData ( - kind: Bow, + kind: Bow(BasicBow), equip_time_millis: 800, ) ), diff --git a/assets/common/items/weapons/starter_dagger.ron b/assets/common/items/weapons/starter_dagger.ron index 8817c6865f..bed9c3890b 100644 --- a/assets/common/items/weapons/starter_dagger.ron +++ b/assets/common/items/weapons/starter_dagger.ron @@ -4,7 +4,7 @@ Item( Power: 15", kind: Tool( ToolData ( - kind: Dagger, + kind: Dagger(BasicDagger), equip_time_millis: 300, ) ), diff --git a/assets/common/items/weapons/starter_hammer.ron b/assets/common/items/weapons/starter_hammer.ron index 6242cfc7c1..3e3a55f6e3 100644 --- a/assets/common/items/weapons/starter_hammer.ron +++ b/assets/common/items/weapons/starter_hammer.ron @@ -5,7 +5,7 @@ Item( Power: 15", kind: Tool( ToolData ( - kind: Hammer, + kind: Hammer(BasicHammer), equip_time_millis: 1000, ) ), diff --git a/assets/common/items/weapons/starter_staff.ron b/assets/common/items/weapons/starter_staff.ron index 2cf741181c..bc5d808ae3 100644 --- a/assets/common/items/weapons/starter_staff.ron +++ b/assets/common/items/weapons/starter_staff.ron @@ -5,12 +5,8 @@ Item( Power: 20", kind: Tool( ToolData ( - kind: Staff, + kind: Staff(BasicHammer), equip_time_millis: 800, - attack_buildup_millis: 400, - attack_recover_millis: 300, - range: 3, - base_damage: 10, ) ), ) diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index 1705c5119c..7ff7586d71 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -3,11 +3,11 @@ // VoxTrans(specifier, offset, (x_rot, y_rot, z_rot), zoom) ({ // Weapons - Tool(Bow): VoxTrans( + Tool(Bow(BasicBow)): VoxTrans( "voxel.weapon.bow.simple-bow", (0.0, 0.0, 0.0), (90.0, 90.0, 0.0), 1.0, ), - Tool(Dagger): VoxTrans( + Tool(Dagger(BasicDagger)): VoxTrans( "voxel.weapon.dagger.dagger_rusty", (0.0, 0.0, -4.0), (-120.0, 90.0, 0.0), 1.1, ), @@ -15,19 +15,19 @@ "voxel.weapon.sword.rusty_2h", (0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4, ), - Tool(Axe): VoxTrans( + Tool(Axe(BasicAxe)): VoxTrans( "voxel.weapon.axe.rusty_2h", (0.0, -8.0, 0.0), (-90.0, 90.0, 0.0), 2.0, ), - Tool(Hammer): VoxTrans( + Tool(Hammer(BasicHammer)): VoxTrans( "voxel.weapon.hammer.rusty_2h", (0.0, -8.0, 0.0), (-90.0, 90.0, 0.0), 2.0, ), - Tool(Staff): VoxTrans( + Tool(Staff(BasicStaff)): VoxTrans( "voxel.weapon.staff.wood-fire", (0.0, -9.0, 0.0), (90.0, 90.0, 0.0), 2.5, ), - Tool(Shield): VoxTrans( + Tool(Shield(BasicShield)): VoxTrans( "voxel.weapon.shield.wood-0", (0.0, 0.0, 0.0), (-90.0, 90.0, 0.0), 2.4, ), diff --git a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron new file mode 100644 index 0000000000..60871bc99f --- /dev/null +++ b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron @@ -0,0 +1,42 @@ +({ + Sword(Scimitar): ( + vox_spec: ("weapon.sword.rusty_2h", (-1.5, -6.5, -4.0)), + color: None + ), + Sword(Rapier): ( + vox_spec: ("weapon.sword.rusty_2h", (-1.5, -6.5, -4.0)), + color: None + ), + Axe(BasicAxe): ( + vox_spec: ("weapon.axe.rusty_2h", (-1.5, -5.0, -4.0)), + color: None + ), + Hammer(BasicHammer): ( + vox_spec: ("weapon.hammer.rusty_2h", (-2.5, -5.5, -4.0)), + color: None + ), + Dagger(BasicDagger): ( + vox_spec: ("weapon.hammer.rusty_2h", (-2.5, -5.5, -4.0)), // TODO + color: None + ), + Shield(BasicShield): ( + vox_spec: ("weapon.shield.wood-0", (-2.5, -6.5, -2.0)), + color: None + ), + Bow(BasicBow): ( + vox_spec: ("weapon.bow.simple-bow", (-1.0, -6.0, -2.0)), + color: None + ), + Staff(BasicStaff): ( + vox_spec: ("weapon.staff.wood-fire", (-1.0, -6.0, -3.0)), + color: None + ), + Debug(Boost): ( + vox_spec: ("weapon.debug_wand", (-1.5, -9.5, -4.0)), + color: None + ), + Debug(Possess): ( + vox_spec: ("weapon.debug_wand", (-1.5, -9.5, -4.0)), + color: None + ), +}) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 16961c3005..0b5d4c59e9 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -7,7 +7,6 @@ use crate::{ effect::Effect, terrain::{Block, BlockKind}, }; -//use rand::prelude::*; use rand::seq::SliceRandom; use specs::{Component, FlaggedStorage}; use specs_idvs::IDVStorage; @@ -18,16 +17,40 @@ pub enum SwordKind { Scimitar, Rapier, } +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum AxeKind { + BasicAxe, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum HammerKind { + BasicHammer, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum BowKind { + BasicBow, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum DaggerKind { + BasicDagger, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum StaffKind { + BasicStaff, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum ShieldKind { + BasicShield, +} #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ToolKind { Sword(SwordKind), - Axe, - Hammer, - Bow, - Dagger, - Staff, - Shield, + Axe(AxeKind), + Hammer(HammerKind), + Bow(BowKind), + Dagger(DaggerKind), + Staff(StaffKind), + Shield(ShieldKind), Debug(DebugKind), /// This is an placeholder item, it is used by non-humanoid npcs to attack Empty, @@ -54,17 +77,17 @@ impl ToolData { base_damage: 20, }, ], - Axe => vec![BasicMelee { + Axe(_) => vec![BasicMelee { buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(100), base_damage: 8, }], - Hammer => vec![BasicMelee { + Hammer(_) => vec![BasicMelee { buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(300), base_damage: 10, }], - Bow => vec![BasicRanged { + Bow(_) => vec![BasicRanged { projectile: Projectile { hit_ground: vec![projectile::Effect::Stick], hit_wall: vec![projectile::Effect::Stick], @@ -82,17 +105,17 @@ impl ToolData { projectile_body: Body::Object(object::Body::Arrow), recover_duration: Duration::from_millis(300), }], - Dagger => vec![BasicMelee { + Dagger(_) => vec![BasicMelee { buildup_duration: Duration::from_millis(100), recover_duration: Duration::from_millis(400), base_damage: 5, }], - Staff => vec![BasicMelee { + Staff(_) => vec![BasicMelee { buildup_duration: Duration::from_millis(400), recover_duration: Duration::from_millis(300), base_damage: 7, }], - Shield => vec![BasicBlock], + Shield(_) => vec![BasicBlock], Debug(kind) => match kind { DebugKind::Boost => vec![ CharacterAbility::Boost { diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index 9d8415ea28..fd7313af78 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -161,6 +161,8 @@ impl<'a> System<'a> for Sys { .copied() .unwrap_or(Alignment::Owned(*target)), ) { + inputs.look_dir = tgt_pos.0 - pos.0; + // Don't attack entities we are passive towards // TODO: This is here, it's a bit of a hack if let Some(alignment) = alignment { @@ -174,7 +176,6 @@ impl<'a> System<'a> for Sys { let dist_sqrd = pos.0.distance_squared(tgt_pos.0); if dist_sqrd < MIN_ATTACK_DIST.powf(2.0) { // Close-range attack - inputs.look_dir = tgt_pos.0 - pos.0; inputs.move_dir = Vec2::from(tgt_pos.0 - pos.0) .try_normalized() .unwrap_or(Vec2::unit_y()) diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index bdb84ef253..dea9736ebe 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -82,7 +82,7 @@ impl Animation for AttackAnimation { * Quaternion::rotation_z(1.4 + slow * 0.5); next.control.scale = Vec3::one(); }, - Some(ToolKind::Axe) => { + Some(ToolKind::Axe(_)) => { next.l_hand.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); next.l_hand.ori = Quaternion::rotation_z(-0.8) @@ -107,7 +107,7 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(0.0 + accel_med * -0.4); next.main.scale = Vec3::one(); }, - Some(ToolKind::Hammer) => { + Some(ToolKind::Hammer(_)) => { next.l_hand.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); next.l_hand.ori = Quaternion::rotation_z(-0.8) @@ -132,7 +132,7 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(0.0 + accel_med * -0.4); next.main.scale = Vec3::one(); }, - Some(ToolKind::Staff) => { + Some(ToolKind::Staff(_)) => { next.l_hand.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); next.l_hand.ori = Quaternion::rotation_z(-0.8) @@ -157,7 +157,7 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(0.0 + accel_med * -0.4); next.main.scale = Vec3::one(); }, - Some(ToolKind::Shield) => { + Some(ToolKind::Shield(_)) => { next.l_hand.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); next.l_hand.ori = Quaternion::rotation_z(-0.8) @@ -182,7 +182,7 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(0.0 + accel_med * -0.4); next.main.scale = Vec3::one(); }, - Some(ToolKind::Bow) => { + Some(ToolKind::Bow(_)) => { next.l_hand.offset = Vec3::new(-7.0, -2.0 + slow * 5.0, -1.0); next.l_hand.ori = Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_y(-0.3) @@ -203,7 +203,7 @@ impl Animation for AttackAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Dagger) => { + Some(ToolKind::Dagger(_)) => { next.l_hand.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); next.l_hand.ori = Quaternion::rotation_z(-0.8) diff --git a/voxygen/src/anim/character/block.rs b/voxygen/src/anim/character/block.rs index 4ed5e7d542..a9e58b8756 100644 --- a/voxygen/src/anim/character/block.rs +++ b/voxygen/src/anim/character/block.rs @@ -81,7 +81,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(-1.57); next.control.scale = Vec3::one(); }, - Some(ToolKind::Axe) => { + Some(ToolKind::Axe(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -106,7 +106,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Hammer) => { + Some(ToolKind::Hammer(_)) => { next.l_hand.offset = Vec3::new(-7.0, 3.5, 6.5); next.l_hand.ori = Quaternion::rotation_x(2.07) * Quaternion::rotation_y(0.0) @@ -127,7 +127,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(-0.85); next.main.scale = Vec3::one(); }, - Some(ToolKind::Staff) => { + Some(ToolKind::Staff(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -152,7 +152,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Shield) => { + Some(ToolKind::Shield(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -177,7 +177,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Bow) => { + Some(ToolKind::Bow(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -202,7 +202,7 @@ impl Animation for BlockAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Dagger) => { + Some(ToolKind::Dagger(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, diff --git a/voxygen/src/anim/character/blockidle.rs b/voxygen/src/anim/character/blockidle.rs index aa035383ac..0c7551b71b 100644 --- a/voxygen/src/anim/character/blockidle.rs +++ b/voxygen/src/anim/character/blockidle.rs @@ -80,7 +80,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(-1.57); next.control.scale = Vec3::one(); }, - Some(ToolKind::Axe) => { + Some(ToolKind::Axe(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -105,7 +105,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Hammer) => { + Some(ToolKind::Hammer(_)) => { next.l_hand.offset = Vec3::new(-7.0, 3.5 + wave_ultra_slow * 2.0, 6.5); next.l_hand.ori = Quaternion::rotation_x(2.07) * Quaternion::rotation_y(0.0) @@ -126,7 +126,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(-0.85); next.main.scale = Vec3::one(); }, - Some(ToolKind::Staff) => { + Some(ToolKind::Staff(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -151,7 +151,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Shield) => { + Some(ToolKind::Shield(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -176,7 +176,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Bow) => { + Some(ToolKind::Bow(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -201,7 +201,7 @@ impl Animation for BlockIdleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Dagger) => { + Some(ToolKind::Dagger(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, diff --git a/voxygen/src/anim/character/cidle.rs b/voxygen/src/anim/character/cidle.rs index d72262fb69..80613193cb 100644 --- a/voxygen/src/anim/character/cidle.rs +++ b/voxygen/src/anim/character/cidle.rs @@ -81,7 +81,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.0); next.control.scale = Vec3::one(); }, - Some(ToolKind::Axe) => { + Some(ToolKind::Axe(_)) => { next.l_hand.offset = Vec3::new( -6.5 + wave_ultra_slow_cos * 1.0, -0.5 + wave_ultra_slow_cos * 0.5, @@ -108,7 +108,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Hammer) => { + Some(ToolKind::Hammer(_)) => { next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); next.l_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1) * Quaternion::rotation_y(0.0) @@ -129,7 +129,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(wave_ultra_slow * 0.2); next.main.scale = Vec3::one(); }, - Some(ToolKind::Staff) => { + Some(ToolKind::Staff(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 1.0 + wave_ultra_slow_cos * 0.5, @@ -154,7 +154,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Shield) => { + Some(ToolKind::Shield(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, @@ -179,7 +179,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Bow) => { + Some(ToolKind::Bow(_)) => { next.l_hand.offset = Vec3::new( -1.0 + wave_ultra_slow_cos * 1.0, 3.0 + wave_ultra_slow_cos * 0.5, @@ -208,7 +208,7 @@ impl Animation for CidleAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Dagger) => { + Some(ToolKind::Dagger(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 3.5 + wave_ultra_slow_cos * 0.5, diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 952d8f149f..0fe9e9ac1a 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -227,25 +227,25 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr { (Danari, Male) => 0.0, (Danari, Female) => 0.0, }, - weapon_x: match ToolKind::Hammer { + weapon_x: match ToolKind::Empty { ToolKind::Sword(_) => 0.0, - ToolKind::Axe => 3.0, - ToolKind::Hammer => 0.0, - ToolKind::Shield => 3.0, - ToolKind::Staff => 3.0, - ToolKind::Bow => 0.0, - ToolKind::Dagger => 0.0, + ToolKind::Axe(_) => 3.0, + ToolKind::Hammer(_) => 0.0, + ToolKind::Shield(_) => 3.0, + ToolKind::Staff(_) => 3.0, + ToolKind::Bow(_) => 0.0, + ToolKind::Dagger(_) => 0.0, ToolKind::Debug(_) => 0.0, ToolKind::Empty => 0.0, }, - weapon_y: match ToolKind::Hammer { + weapon_y: match ToolKind::Empty { ToolKind::Sword(_) => -1.25, - ToolKind::Axe => 0.0, - ToolKind::Hammer => -2.0, - ToolKind::Shield => 0.0, - ToolKind::Staff => 0.0, - ToolKind::Bow => -2.0, - ToolKind::Dagger => -2.0, + ToolKind::Axe(_) => 0.0, + ToolKind::Hammer(_) => -2.0, + ToolKind::Shield(_) => 0.0, + ToolKind::Staff(_) => 0.0, + ToolKind::Bow(_) => -2.0, + ToolKind::Dagger(_) => -2.0, ToolKind::Debug(_) => 0.0, ToolKind::Empty => 0.0, }, diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index c050e7e03a..05cfaafdc6 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -44,7 +44,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.control.scale = Vec3::one(); }, - Some(ToolKind::Axe) => { + Some(ToolKind::Axe(_)) => { next.l_hand.offset = Vec3::new(-6.5, -0.5, 6.0); next.l_hand.ori = Quaternion::rotation_x(0.13) * Quaternion::rotation_z(-0.25); next.l_hand.scale = Vec3::one() * 1.01; @@ -63,7 +63,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Hammer) => { + Some(ToolKind::Hammer(_)) => { next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) * Quaternion::rotation_y(0.0) @@ -84,7 +84,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(wave * -0.25); next.main.scale = Vec3::one(); }, - Some(ToolKind::Staff) => { + Some(ToolKind::Staff(_)) => { next.l_hand.offset = Vec3::new( -6.0 + wave_ultra_slow_cos * 1.0, 1.0 + wave_ultra_slow_cos * 0.5, @@ -109,7 +109,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Shield) => { + Some(ToolKind::Shield(_)) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; @@ -126,7 +126,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Bow) => { + Some(ToolKind::Bow(_)) => { next.l_hand.offset = Vec3::new( -1.0 - wave_ultra_slow_cos * 1.0, 3.0 + wave_ultra_slow_cos * 0.5, @@ -155,7 +155,7 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); }, - Some(ToolKind::Dagger) => { + Some(ToolKind::Dagger(_)) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); next.l_hand.ori = Quaternion::rotation_x(-0.3); next.l_hand.scale = Vec3::one() * 1.01; diff --git a/voxygen/src/anim/mod.rs b/voxygen/src/anim/mod.rs index c09fbc3e97..5860306ecf 100644 --- a/voxygen/src/anim/mod.rs +++ b/voxygen/src/anim/mod.rs @@ -166,27 +166,27 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr { (Danari, Male) => 0.0, (Danari, Female) => 0.0, }, - weapon_x: match ToolKind::Hammer { + weapon_x: match ToolKind::Empty { // TODO: Inventory ToolKind::Sword(_) => 0.0, - ToolKind::Axe => 3.0, - ToolKind::Hammer => 0.0, - ToolKind::Shield => 3.0, - ToolKind::Staff => 3.0, - ToolKind::Bow => 0.0, - ToolKind::Dagger => 0.0, + ToolKind::Axe(_) => 3.0, + ToolKind::Hammer(_) => 0.0, + ToolKind::Shield(_) => 3.0, + ToolKind::Staff(_) => 3.0, + ToolKind::Bow(_) => 0.0, + ToolKind::Dagger(_) => 0.0, ToolKind::Debug(_) => 0.0, ToolKind::Empty => 0.0, }, - weapon_y: match ToolKind::Hammer { + weapon_y: match ToolKind::Empty { // TODO: Inventory ToolKind::Sword(_) => -1.25, - ToolKind::Axe => 0.0, - ToolKind::Hammer => -2.0, - ToolKind::Shield => 0.0, - ToolKind::Staff => 0.0, - ToolKind::Bow => -2.0, - ToolKind::Dagger => -2.0, + ToolKind::Axe(_) => 0.0, + ToolKind::Hammer(_) => -2.0, + ToolKind::Shield(_) => 0.0, + ToolKind::Staff(_) => 0.0, + ToolKind::Bow(_) => -2.0, + ToolKind::Dagger(_) => -2.0, ToolKind::Debug(_) => 0.0, ToolKind::Empty => 0.0, }, diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index c8348e4dd6..77af78dd3a 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -58,8 +58,8 @@ widget_ids! { hands_bg, pants_bg, belt_bg, - ring-r_bg, - ring-l_bg, + ring_r_bg, + ring_l_bg, foot_bg, back_bg, tabard_bg, diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 877132222d..70c5bdb576 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -586,8 +586,8 @@ impl<'a> Widget for Skillbar<'a> { .color( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => Some(BG_COLOR_2), - ToolKind::Staff => Some(BG_COLOR_2), + ToolKind::Bow(_) => Some(BG_COLOR_2), + ToolKind::Staff(_) => Some(BG_COLOR_2), _ => Some(BG_COLOR_2), }, _ => Some(BG_COLOR_2), @@ -599,10 +599,10 @@ impl<'a> Widget for Skillbar<'a> { match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { ToolKind::Sword(_) => self.imgs.twohsword_m1, - ToolKind::Hammer => self.imgs.twohhammer_m1, - ToolKind::Axe => self.imgs.twohaxe_m1, - ToolKind::Bow => self.imgs.bow_m1, - ToolKind::Staff => self.imgs.staff_m1, + ToolKind::Hammer(_) => self.imgs.twohhammer_m1, + ToolKind::Axe(_) => self.imgs.twohaxe_m1, + ToolKind::Bow(_) => self.imgs.bow_m1, + ToolKind::Staff(_) => self.imgs.staff_m1, ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m1, _ => self.imgs.twohaxe_m1, }, @@ -612,8 +612,8 @@ impl<'a> Widget for Skillbar<'a> { .w( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => 30.0 * scale, - ToolKind::Staff => 32.0 * scale, + ToolKind::Bow(_) => 30.0 * scale, + ToolKind::Staff(_) => 32.0 * scale, _ => 38.0 * scale, }, _ => 38.0 * scale, @@ -622,8 +622,8 @@ impl<'a> Widget for Skillbar<'a> { .h( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => 30.0 * scale, - ToolKind::Staff => 32.0 * scale, + ToolKind::Bow(_) => 30.0 * scale, + ToolKind::Staff(_) => 32.0 * scale, _ => 38.0 * scale, }, _ => 38.0 * scale, @@ -687,8 +687,8 @@ impl<'a> Widget for Skillbar<'a> { .color( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => Some(BG_COLOR_2), - ToolKind::Staff => Some(BG_COLOR_2), + ToolKind::Bow(_) => Some(BG_COLOR_2), + ToolKind::Staff(_) => Some(BG_COLOR_2), _ => Some(BG_COLOR_2), }, _ => Some(BG_COLOR_2), @@ -700,10 +700,10 @@ impl<'a> Widget for Skillbar<'a> { match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { ToolKind::Sword(_) => self.imgs.twohsword_m2, - ToolKind::Hammer => self.imgs.twohhammer_m2, - ToolKind::Axe => self.imgs.twohaxe_m2, - ToolKind::Bow => self.imgs.bow_m2, - ToolKind::Staff => self.imgs.staff_m2, + ToolKind::Hammer(_) => self.imgs.twohhammer_m2, + ToolKind::Axe(_) => self.imgs.twohaxe_m2, + ToolKind::Bow(_) => self.imgs.bow_m2, + ToolKind::Staff(_) => self.imgs.staff_m2, ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m2, _ => self.imgs.twohaxe_m2, }, @@ -713,8 +713,8 @@ impl<'a> Widget for Skillbar<'a> { .w( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => 30.0 * scale, - ToolKind::Staff => 30.0 * scale, + ToolKind::Bow(_) => 30.0 * scale, + ToolKind::Staff(_) => 30.0 * scale, _ => 38.0 * scale, }, _ => 38.0 * scale, @@ -723,8 +723,8 @@ impl<'a> Widget for Skillbar<'a> { .h( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow => 30.0 * scale, - ToolKind::Staff => 30.0 * scale, + ToolKind::Bow(_) => 30.0 * scale, + ToolKind::Staff(_) => 30.0 * scale, _ => 38.0 * scale, }, _ => 38.0 * scale, diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index a96d5825c3..90af923e3e 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -119,6 +119,8 @@ impl FigureModelCache { HumArmorPantsSpec::load_watched(&mut self.manifest_indicator); let humanoid_armor_foot_spec = HumArmorFootSpec::load_watched(&mut self.manifest_indicator); + let humanoid_main_weapon_spec = + HumMainWeaponSpec::load_watched(&mut self.manifest_indicator); // TODO: This is bad code, maybe this method should return Option<_> let default_loadout = Loadout::default(); @@ -213,7 +215,7 @@ impl FigureModelCache { }) .unwrap_or_default() { - Some(mesh_main( + Some(humanoid_main_weapon_spec.mesh_main_weapon( loadout.active_item.as_ref().map(|i| &i.item.kind), )) } else { diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index fd3602df48..75758fdbe1 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -243,6 +243,8 @@ pub struct HumArmorBeltSpec(HashMap); pub struct HumArmorPantsSpec(HashMap); #[derive(Serialize, Deserialize)] pub struct HumArmorFootSpec(HashMap); +#[derive(Serialize, Deserialize)] +pub struct HumMainWeaponSpec(HashMap); impl Asset for HumArmorShoulderSpec { const ENDINGS: &'static [&'static str] = &["ron"]; @@ -286,6 +288,13 @@ impl Asset for HumArmorFootSpec { Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor foot spec")) } } +impl Asset for HumMainWeaponSpec { + const ENDINGS: &'static [&'static str] = &["ron"]; + + fn parse(buf_reader: BufReader) -> Result { + Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid main weapon spec")) + } +} impl HumArmorShoulderSpec { pub fn load_watched(indicator: &mut ReloadIndicator) -> Arc { @@ -624,25 +633,29 @@ impl HumArmorFootSpec { } } -pub fn mesh_main(item_kind: Option<&ItemKind>) -> Mesh { - if let Some(item_kind) = item_kind { - let (name, offset) = match item_kind { - ItemKind::Tool(ToolData { kind, .. }) => match kind { - ToolKind::Sword(_) => ("weapon.sword.rusty_2h", Vec3::new(-1.5, -6.5, -4.0)), - ToolKind::Axe => ("weapon.axe.rusty_2h", Vec3::new(-1.5, -5.0, -4.0)), - ToolKind::Hammer => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)), - ToolKind::Dagger => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)), - ToolKind::Shield => ("weapon.shield.wood-0", Vec3::new(-2.5, -6.5, -2.0)), - ToolKind::Bow => ("weapon.bow.simple-bow", Vec3::new(-1.0, -6.0, -2.0)), - ToolKind::Staff => ("weapon.staff.wood-fire", Vec3::new(-1.0, -6.0, -3.0)), - ToolKind::Debug(_) => ("weapon.debug_wand", Vec3::new(-1.5, -9.5, -4.0)), - ToolKind::Empty => return Mesh::new(), - }, - _ => return Mesh::new(), +impl HumMainWeaponSpec { + pub fn load_watched(indicator: &mut ReloadIndicator) -> Arc { + assets::load_watched::("voxygen.voxel.humanoid_main_weapon_manifest", indicator) + .unwrap() + } + + pub fn mesh_main_weapon(&self, item_kind: Option<&ItemKind>) -> Mesh { + let tool_kind = if let Some(ItemKind::Tool(ToolData { kind, .. })) = item_kind { + kind + } else { + return Mesh::new(); }; - load_mesh(name, offset) - } else { - Mesh::new() + + let spec = match self.0.get(tool_kind) { + Some(spec) => spec, + None => { + error!("No hand specification exists for {:?}", tool_kind); + return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0)); + }, + }; + + let tool_kind_segment = graceful_load_segment(&spec.vox_spec.0); + generate_mesh(&tool_kind_segment, Vec3::from(spec.vox_spec.1)) } } From c9d09b8cdd319701523be7a0e0e0f01cae7053ac Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Tue, 17 Mar 2020 19:04:06 +0100 Subject: [PATCH 134/326] more slots --- assets/common/items/debug/boost.ron | 6 +--- assets/common/items/debug/possess.ron | 6 +--- voxygen/src/hud/bag.rs | 50 +++++++++++++++++++-------- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/assets/common/items/debug/boost.ron b/assets/common/items/debug/boost.ron index 6ff45a1d78..141b093d09 100644 --- a/assets/common/items/debug/boost.ron +++ b/assets/common/items/debug/boost.ron @@ -4,11 +4,7 @@ Item( kind: Tool( ToolData ( kind: Debug(Boost), - equip_time_millis: 0, - attack_buildup_millis: 0, - attack_recover_millis: 0, - range: 0, - base_damage: 0, + equip_time_millis: 0, ) ), ) diff --git a/assets/common/items/debug/possess.ron b/assets/common/items/debug/possess.ron index 4d223e4506..8e315cd5af 100644 --- a/assets/common/items/debug/possess.ron +++ b/assets/common/items/debug/possess.ron @@ -4,11 +4,7 @@ Item( kind: Tool( ToolData ( kind: Debug(Possess), - equip_time_millis: 0, - attack_buildup_millis: 0, - attack_recover_millis: 0, - range: 3, - base_damage: 10, + equip_time_millis: 0, ) ), ) diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index c8348e4dd6..6d49c4b720 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -16,7 +16,7 @@ use conrod_core::{ }; widget_ids! { - struct Ids { + pub struct Ids { test, bag_close, inv_alignment, @@ -58,8 +58,8 @@ widget_ids! { hands_bg, pants_bg, belt_bg, - ring-r_bg, - ring-l_bg, + ring_r_bg, + ring_l_bg, foot_bg, back_bg, tabard_bg, @@ -260,24 +260,34 @@ impl<'a> Widget for Bag<'a> { .set(state.ids.inventory_title, ui); //Armor Slots //Slots BG - Image::new(self.imgs.inv_runes) + /*Image::new(self.imgs.inv_runes) .w_h(424.0, 454.0) .mid_top_with_margin_on(state.ids.bg, 0.0) .color(Some(UI_HIGHLIGHT_0)) .floating(true) .set(state.ids.slots_bg, ui); Image::new(self.imgs.inv_slots) - .w_h(424.0, 401.0) - .mid_top_with_margin_on(state.ids.bg, 57.0) - .color(Some(UI_HIGHLIGHT_0)) - .set(state.ids.slots_bg, ui); + .w_h(424.0, 401.0) + .mid_top_with_margin_on(state.ids.bg, 57.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.slots_bg, ui);*/ // Armor Slots //Head + Image::new(self.imgs.armor_slot) + .w_h(45.0, 45.0) + .mid_top_with_margin_on(state.ids.bg_frame, 60.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.head_bg, ui); //Necklace + Image::new(self.imgs.armor_slot) + .w_h(45.0, 45.0) + .mid_bottom_with_margin_on(state.ids.head_bg, -55.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.neck_bg, ui); //Chest Image::new(self.imgs.armor_slot) // different graphics for empty/non empty - .w_h(86.0, 86.0) - .mid_top_with_margin_on(state.ids.slots_bg, 162.0) + .w_h(85.0, 85.0) + .mid_bottom_with_margin_on(state.ids.neck_bg, -95.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.chest_bg, ui); Button::image(self.imgs.skull) @@ -285,17 +295,27 @@ impl<'a> Widget for Bag<'a> { .middle_of(state.ids.chest_bg) .set(state.ids.test, ui); //Shoulder + Image::new(self.imgs.armor_slot) + .w_h(70.0, 70.0) + .bottom_left_with_margins_on(state.ids.chest_bg, 0.0, -80.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.belt_bg, ui); //Hands + Image::new(self.imgs.armor_slot) + .w_h(70.0, 70.0) + .bottom_right_with_margins_on(state.ids.chest_bg, 0.0, -80.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.hands_bg, ui); //Belt Image::new(self.imgs.armor_slot) - .w_h(44.0, 44.0) - .down_from(state.ids.chest_bg, 11.0) + .w_h(45.0, 45.0) + .mid_bottom_with_margin_on(state.ids.chest_bg, -55.0) .color(Some(UI_HIGHLIGHT_0)) - .set(state.ids.chest_bg, ui); + .set(state.ids.belt_bg, ui); //Pants Image::new(self.imgs.armor_slot) - .w_h(86.0, 86.0) - .down_from(state.ids.belt_bg, 11.0) + .w_h(85.0, 85.0) + .mid_bottom_with_margin_on(state.ids.belt_bg, -95.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.pants_bg, ui); //Ring-L From 04c8ed9a3cdb35d0671288b19539f98f4ea3b54b Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Tue, 17 Mar 2020 19:48:15 +0100 Subject: [PATCH 135/326] armour slot bgs --- voxygen/src/hud/bag.rs | 54 +++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 6d49c4b720..5fa7f565d7 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -299,7 +299,7 @@ impl<'a> Widget for Bag<'a> { .w_h(70.0, 70.0) .bottom_left_with_margins_on(state.ids.chest_bg, 0.0, -80.0) .color(Some(UI_HIGHLIGHT_0)) - .set(state.ids.belt_bg, ui); + .set(state.ids.shoulder_bg, ui); //Hands Image::new(self.imgs.armor_slot) .w_h(70.0, 70.0) @@ -318,13 +318,51 @@ impl<'a> Widget for Bag<'a> { .mid_bottom_with_margin_on(state.ids.belt_bg, -95.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.pants_bg, ui); - //Ring-L - //Ring-R - //Foot - //Back - //Tabard - //Mainhand/Left-Slot - //Offhand/Right-Slot + //Ring-L + Image::new(self.imgs.armor_slot) + .w_h(45.0, 45.0) + .bottom_right_with_margins_on(state.ids.shoulder_bg, -55.0, 0.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.ring_l_bg, ui); + //Ring-R + Image::new(self.imgs.armor_slot) + .w_h(45.0, 45.0) + .bottom_left_with_margins_on(state.ids.hands_bg, -55.0, 0.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.ring_r_bg, ui); + //Back + Image::new(self.imgs.armor_slot) + .w_h(45.0, 45.0) + .down_from(state.ids.ring_l_bg, 10.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.back_bg, ui); + //Foot + Image::new(self.imgs.armor_slot) + .w_h(45.0, 45.0) + .down_from(state.ids.ring_r_bg, 10.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.foot_bg, ui); + + //Tabard + + Image::new(self.imgs.armor_slot) + .w_h(70.0, 70.0) + .top_right_with_margins_on(state.ids.bg_frame, 80.5, 53.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.tabard_bg, ui); + + //Mainhand/Left-Slot + Image::new(self.imgs.armor_slot) + .w_h(85.0, 85.0) + .bottom_right_with_margins_on(state.ids.back_bg, -95.0, 0.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.mainhand_bg, ui); + //Offhand/Right-Slot + Image::new(self.imgs.armor_slot) + .w_h(85.0, 85.0) + .bottom_left_with_margins_on(state.ids.foot_bg, -95.0, 0.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.offhand_bg, ui); } else { // Stats // Title From 70511e0f4e6b13553ba75240964540b62cb42703 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Wed, 18 Mar 2020 01:43:55 +0100 Subject: [PATCH 136/326] background images --- assets/voxygen/element/icons/back.png | 3 + assets/voxygen/element/icons/belt.png | 3 + assets/voxygen/element/icons/chest.png | 3 + assets/voxygen/element/icons/feet.png | 3 + assets/voxygen/element/icons/hands.png | 3 + assets/voxygen/element/icons/head.png | 3 + assets/voxygen/element/icons/legs.png | 3 + assets/voxygen/element/icons/mainhand.png | 3 + assets/voxygen/element/icons/necklace.png | 3 + assets/voxygen/element/icons/offhand.png | 3 + assets/voxygen/element/icons/ring.png | 3 + assets/voxygen/element/icons/shoulders.png | 3 + assets/voxygen/element/icons/tabard.png | 3 + voxygen/src/hud/bag.rs | 109 +++++++++++++++++++-- voxygen/src/hud/img_ids.rs | 29 +++--- 15 files changed, 153 insertions(+), 24 deletions(-) create mode 100644 assets/voxygen/element/icons/back.png create mode 100644 assets/voxygen/element/icons/belt.png create mode 100644 assets/voxygen/element/icons/chest.png create mode 100644 assets/voxygen/element/icons/feet.png create mode 100644 assets/voxygen/element/icons/hands.png create mode 100644 assets/voxygen/element/icons/head.png create mode 100644 assets/voxygen/element/icons/legs.png create mode 100644 assets/voxygen/element/icons/mainhand.png create mode 100644 assets/voxygen/element/icons/necklace.png create mode 100644 assets/voxygen/element/icons/offhand.png create mode 100644 assets/voxygen/element/icons/ring.png create mode 100644 assets/voxygen/element/icons/shoulders.png create mode 100644 assets/voxygen/element/icons/tabard.png diff --git a/assets/voxygen/element/icons/back.png b/assets/voxygen/element/icons/back.png new file mode 100644 index 0000000000..46c6472b1f --- /dev/null +++ b/assets/voxygen/element/icons/back.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de53aa3a5c0833ec1ee9b89872a25643742aef22b70b2cc2ba5af4435a6714bf +size 1080 diff --git a/assets/voxygen/element/icons/belt.png b/assets/voxygen/element/icons/belt.png new file mode 100644 index 0000000000..5588b7fe24 --- /dev/null +++ b/assets/voxygen/element/icons/belt.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e10d69242cbb54530ca4353663d57f1abea4b997568b9335fd19dfe158b1bafe +size 935 diff --git a/assets/voxygen/element/icons/chest.png b/assets/voxygen/element/icons/chest.png new file mode 100644 index 0000000000..dde643eaef --- /dev/null +++ b/assets/voxygen/element/icons/chest.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b1bab917b7854f944d2c5c145a905a5dd8a610b7027e37c16919ab91d655a68 +size 981 diff --git a/assets/voxygen/element/icons/feet.png b/assets/voxygen/element/icons/feet.png new file mode 100644 index 0000000000..6aa78499fb --- /dev/null +++ b/assets/voxygen/element/icons/feet.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:003eeb041dd5cd61945c3f6c6bb54fecebbfb3d13a301d8a7786cc88df08af95 +size 974 diff --git a/assets/voxygen/element/icons/hands.png b/assets/voxygen/element/icons/hands.png new file mode 100644 index 0000000000..54156f1703 --- /dev/null +++ b/assets/voxygen/element/icons/hands.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43eba8f1c26e8211db134c22a8fe706558f9e2ea75a05db2a231745850f5f79e +size 1121 diff --git a/assets/voxygen/element/icons/head.png b/assets/voxygen/element/icons/head.png new file mode 100644 index 0000000000..afaefaf325 --- /dev/null +++ b/assets/voxygen/element/icons/head.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b1620570303bfcd672339b5f5b6460b2304d6c81d22cc0bf29865973c1fdf515 +size 1057 diff --git a/assets/voxygen/element/icons/legs.png b/assets/voxygen/element/icons/legs.png new file mode 100644 index 0000000000..169804cc10 --- /dev/null +++ b/assets/voxygen/element/icons/legs.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:34a8297f2434c36e95dbb9f9dffda318a2add3e1e0bde9dabbf6d986930a583b +size 959 diff --git a/assets/voxygen/element/icons/mainhand.png b/assets/voxygen/element/icons/mainhand.png new file mode 100644 index 0000000000..acb2159e6f --- /dev/null +++ b/assets/voxygen/element/icons/mainhand.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e6a942f3fbfa15c06cf547e05ef46bedb191e9f1192f1dfdd0e2051096dbd17 +size 608 diff --git a/assets/voxygen/element/icons/necklace.png b/assets/voxygen/element/icons/necklace.png new file mode 100644 index 0000000000..b410d9f49a --- /dev/null +++ b/assets/voxygen/element/icons/necklace.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8224a574cf07306249973ca3d8e6c31a43c0f3265dacc209bd824d71505b36a8 +size 741 diff --git a/assets/voxygen/element/icons/offhand.png b/assets/voxygen/element/icons/offhand.png new file mode 100644 index 0000000000..a5ba86c30e --- /dev/null +++ b/assets/voxygen/element/icons/offhand.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ea7336a0124db8df3b67c54b6db07373e141561589dcfc3d919b3b75a81efec +size 592 diff --git a/assets/voxygen/element/icons/ring.png b/assets/voxygen/element/icons/ring.png new file mode 100644 index 0000000000..d07b37cb5b --- /dev/null +++ b/assets/voxygen/element/icons/ring.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0574ad5eb1fec7b7984cf97cd584749943f2a3a65f707aee4ec10dbb630059f7 +size 2986 diff --git a/assets/voxygen/element/icons/shoulders.png b/assets/voxygen/element/icons/shoulders.png new file mode 100644 index 0000000000..eda0f24c51 --- /dev/null +++ b/assets/voxygen/element/icons/shoulders.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc6ce9769c94de6bea3533e8840c413e197472ae8e9ce57528fe2641a230eb26 +size 927 diff --git a/assets/voxygen/element/icons/tabard.png b/assets/voxygen/element/icons/tabard.png new file mode 100644 index 0000000000..783301dd6e --- /dev/null +++ b/assets/voxygen/element/icons/tabard.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d66d4191fa9166aebedafbc45723d0262cfab4fc5076f89f4ce775248d0a7bea +size 1056 diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 5fa7f565d7..2f0021174e 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -56,7 +56,7 @@ widget_ids! { chest_bg, shoulder_bg, hands_bg, - pants_bg, + legs_bg, belt_bg, ring_r_bg, ring_l_bg, @@ -65,6 +65,20 @@ widget_ids! { tabard_bg, mainhand_bg, offhand_bg, + head_ico, + neck_ico, + chest_ico, + shoulder_ico, + hands_ico, + legs_ico, + belt_ico, + ring_r_ico, + ring_l_ico, + foot_ico, + back_ico, + tabard_ico, + mainhand_ico, + offhand_ico, } } @@ -278,91 +292,168 @@ impl<'a> Widget for Bag<'a> { .mid_top_with_margin_on(state.ids.bg_frame, 60.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.head_bg, ui); + Button::image(self.imgs.head_bg) + .w_h(32.0, 40.0) + .image_color(UI_MAIN) + .middle_of(state.ids.head_bg) + .with_tooltip(self.tooltip_manager, "Helmet", "", &item_tooltip) + .set(state.ids.head_ico, ui); //Necklace Image::new(self.imgs.armor_slot) .w_h(45.0, 45.0) .mid_bottom_with_margin_on(state.ids.head_bg, -55.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.neck_bg, ui); + Button::image(self.imgs.necklace_bg) + .w_h(40.0, 31.0) + .image_color(UI_MAIN) + .middle_of(state.ids.neck_bg) + .with_tooltip(self.tooltip_manager, "Neck", "", &item_tooltip) + .set(state.ids.neck_ico, ui); //Chest Image::new(self.imgs.armor_slot) // different graphics for empty/non empty .w_h(85.0, 85.0) .mid_bottom_with_margin_on(state.ids.neck_bg, -95.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.chest_bg, ui); - Button::image(self.imgs.skull) - .w_h(80.0, 80.0) + Button::image(self.imgs.chest_bg) + .w_h(64.0, 42.0) + .image_color(UI_MAIN) .middle_of(state.ids.chest_bg) - .set(state.ids.test, ui); + .with_tooltip(self.tooltip_manager, "Chest", "", &item_tooltip) + .set(state.ids.chest_ico, ui); //Shoulder Image::new(self.imgs.armor_slot) .w_h(70.0, 70.0) .bottom_left_with_margins_on(state.ids.chest_bg, 0.0, -80.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.shoulder_bg, ui); + Button::image(self.imgs.shoulders_bg) + .w_h(60.0, 36.0) + .image_color(UI_MAIN) + .middle_of(state.ids.shoulder_bg) + .with_tooltip(self.tooltip_manager, "Shoulders", "", &item_tooltip) + .set(state.ids.shoulder_ico, ui); //Hands Image::new(self.imgs.armor_slot) .w_h(70.0, 70.0) .bottom_right_with_margins_on(state.ids.chest_bg, 0.0, -80.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.hands_bg, ui); + Button::image(self.imgs.hands_bg) + .w_h(55.0, 60.0) + .image_color(UI_MAIN) + .middle_of(state.ids.hands_bg) + .with_tooltip(self.tooltip_manager, "Hands", "", &item_tooltip) + .set(state.ids.hands_ico, ui); //Belt Image::new(self.imgs.armor_slot) .w_h(45.0, 45.0) .mid_bottom_with_margin_on(state.ids.chest_bg, -55.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.belt_bg, ui); - //Pants + Button::image(self.imgs.belt_bg) + .w_h(40.0, 23.0) + .image_color(UI_MAIN) + .middle_of(state.ids.belt_bg) + .with_tooltip(self.tooltip_manager, "Belt", "", &item_tooltip) + .set(state.ids.belt_ico, ui); + //Legs Image::new(self.imgs.armor_slot) .w_h(85.0, 85.0) .mid_bottom_with_margin_on(state.ids.belt_bg, -95.0) .color(Some(UI_HIGHLIGHT_0)) - .set(state.ids.pants_bg, ui); + .set(state.ids.legs_bg, ui); + Button::image(self.imgs.legs_bg) + .w_h(48.0, 70.0) + .image_color(UI_MAIN) + .middle_of(state.ids.legs_bg) + .with_tooltip(self.tooltip_manager, "Legs", "", &item_tooltip) + .set(state.ids.legs_ico, ui); //Ring-L Image::new(self.imgs.armor_slot) .w_h(45.0, 45.0) .bottom_right_with_margins_on(state.ids.shoulder_bg, -55.0, 0.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.ring_l_bg, ui); + Button::image(self.imgs.ring_l_bg) + .w_h(36.0, 40.0) + .image_color(UI_MAIN) + .middle_of(state.ids.ring_l_bg) + .with_tooltip(self.tooltip_manager, "Left Ring", "", &item_tooltip) + .set(state.ids.ring_l_ico, ui); //Ring-R Image::new(self.imgs.armor_slot) .w_h(45.0, 45.0) .bottom_left_with_margins_on(state.ids.hands_bg, -55.0, 0.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.ring_r_bg, ui); + Button::image(self.imgs.ring_r_bg) + .w_h(36.0, 40.0) + .image_color(UI_MAIN) + .middle_of(state.ids.ring_r_bg) + .with_tooltip(self.tooltip_manager, "Right Ring", "", &item_tooltip) + .set(state.ids.ring_r_ico, ui); //Back Image::new(self.imgs.armor_slot) .w_h(45.0, 45.0) .down_from(state.ids.ring_l_bg, 10.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.back_bg, ui); + Button::image(self.imgs.back_bg) + .w_h(33.0, 40.0) + .image_color(UI_MAIN) + .middle_of(state.ids.back_bg) + .with_tooltip(self.tooltip_manager, "Back", "", &item_tooltip) + .set(state.ids.back_ico, ui); //Foot Image::new(self.imgs.armor_slot) .w_h(45.0, 45.0) .down_from(state.ids.ring_r_bg, 10.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.foot_bg, ui); - + Button::image(self.imgs.feet_bg) + .w_h(32.0, 40.0) + .image_color(UI_MAIN) + .middle_of(state.ids.foot_bg) + .with_tooltip(self.tooltip_manager, "Feet", "", &item_tooltip) + .set(state.ids.foot_ico, ui); //Tabard - Image::new(self.imgs.armor_slot) .w_h(70.0, 70.0) .top_right_with_margins_on(state.ids.bg_frame, 80.5, 53.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.tabard_bg, ui); - + Button::image(self.imgs.tabard_bg) + .w_h(60.0, 60.0) + .image_color(UI_MAIN) + .middle_of(state.ids.tabard_bg) + .with_tooltip(self.tooltip_manager, "Tabard", "", &item_tooltip) + .set(state.ids.tabard_ico, ui); //Mainhand/Left-Slot Image::new(self.imgs.armor_slot) .w_h(85.0, 85.0) .bottom_right_with_margins_on(state.ids.back_bg, -95.0, 0.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.mainhand_bg, ui); + Button::image(self.imgs.mainhand_bg) + .w_h(75.0, 75.0) + .image_color(UI_MAIN) + .middle_of(state.ids.mainhand_bg) + .with_tooltip(self.tooltip_manager, "Mainhand", "", &item_tooltip) + .set(state.ids.mainhand_ico, ui); //Offhand/Right-Slot Image::new(self.imgs.armor_slot) .w_h(85.0, 85.0) .bottom_left_with_margins_on(state.ids.foot_bg, -95.0, 0.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.offhand_bg, ui); + Button::image(self.imgs.offhand_bg) + .w_h(75.0, 75.0) + .image_color(UI_MAIN) + .middle_of(state.ids.offhand_bg) + .with_tooltip(self.tooltip_manager, "Offhand", "", &item_tooltip) + .set(state.ids.offhand_ico, ui); } else { // Stats // Title diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index bcdae37b80..33f2697a8c 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -185,21 +185,6 @@ image_ids! { // Charwindow xp_charwindow: "voxygen.element.frames.xp_charwindow", divider: "voxygen.element.frames.divider_charwindow", - head_bg: "voxygen.element.icons.head", - shoulders_bg: "voxygen.element.icons.shoulders", - hands_bg: "voxygen.element.icons.hands", - belt_bg: "voxygen.element.icons.belt", - legs_bg: "voxygen.element.icons.legs", - feet_bg: "voxygen.element.icons.feet", - ring_r_bg: "voxygen.element.icons.ring", - ring_l_bg: "voxygen.element.icons.ring", - tabard_bg: "voxygen.element.icons.tabard", - chest_bg: "voxygen.element.icons.chest", - back_bg: "voxygen.element.icons.back", - gem_bg: "voxygen.element.icons.gem", - necklace_bg: "voxygen.element.icons.necklace", - mainhand_bg: "voxygen.element.icons.mainhand", - offhand_bg: "voxygen.element.icons.offhand", // Close button close_button: "voxygen.element.buttons.x", @@ -258,6 +243,20 @@ image_ids! { inv_slots: "voxygen.element.misc_bg.inv_slots", inv_runes: "voxygen.element.misc_bg.inv_runes", armor_slot: "voxygen.element.buttons.armor_slot", + head_bg: "voxygen.element.icons.head", + shoulders_bg: "voxygen.element.icons.shoulders", + hands_bg: "voxygen.element.icons.hands", + belt_bg: "voxygen.element.icons.belt", + legs_bg: "voxygen.element.icons.legs", + feet_bg: "voxygen.element.icons.feet", + ring_r_bg: "voxygen.element.icons.ring", + ring_l_bg: "voxygen.element.icons.ring", + tabard_bg: "voxygen.element.icons.tabard", + chest_bg: "voxygen.element.icons.chest", + back_bg: "voxygen.element.icons.back", + necklace_bg: "voxygen.element.icons.necklace", + mainhand_bg: "voxygen.element.icons.mainhand", + offhand_bg: "voxygen.element.icons.offhand", From 43bae5596197ee877be38eafb2807ab374c56d7c Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:05:36 +0100 Subject: [PATCH 137/326] coin/currency visuals --- assets/voxygen/element/icons/coin.png | 3 +++ voxygen/src/hud/bag.rs | 19 ++++++++++++++++--- voxygen/src/hud/img_ids.rs | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 assets/voxygen/element/icons/coin.png diff --git a/assets/voxygen/element/icons/coin.png b/assets/voxygen/element/icons/coin.png new file mode 100644 index 0000000000..d3be411bac --- /dev/null +++ b/assets/voxygen/element/icons/coin.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1741873b26a6da3d6fe309aab67db9a8d3c00ea2ef047b4ecf8672e6de70bc4 +size 440 diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 2f0021174e..efe3be5a2b 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -30,7 +30,9 @@ widget_ids! { tooltip[], bg, bg_frame, - char_art, + char_ico, + coin_ico, + currency_txt, inventory_title, inventory_title_bg, scrollbar_bg, @@ -173,6 +175,7 @@ impl<'a> Widget for Bag<'a> { &self.localized_strings.get("hud.bag.exp") ); let level = (self.stats.level.level()).to_string(); + let currency = 100; // Tooltips let item_tooltip = Tooltip::new({ @@ -242,8 +245,18 @@ impl<'a> Widget for Bag<'a> { Image::new(self.imgs.char_art) .w_h(40.0, 37.0) .top_left_with_margins_on(state.ids.bg, 4.0, 2.0) - .set(state.ids.char_art, ui); - + .set(state.ids.char_ico, ui); + // Coin Icon and Currency Text + Image::new(self.imgs.coin_ico) + .w_h(16.0 * 2.0, 17.0 * 2.0) + .bottom_left_with_margins_on(state.ids.bg_frame, 2.0, 43.0) + .set(state.ids.coin_ico, ui); + Text::new(&format!("{}", currency)) + .right_from(state.ids.coin_ico, 4.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(10)) + .color(Color::Rgba(0.87, 0.86, 0.55, 1.0)) + .set(state.ids.currency_txt, ui); // Alignment for Grid Rectangle::fill_with([362.0, 200.0], color::TRANSPARENT) .bottom_left_with_margins_on(state.ids.bg_frame, 29.0, 44.0) diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 33f2697a8c..cc4ca58dd4 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -229,6 +229,7 @@ image_ids! { close_btn_press: "voxygen.element.buttons.close_btn_press", // Inventory + coin_ico: "voxygen.element.icons.coin", inv_bg_armor: "voxygen.element.misc_bg.inv_bg_0", inv_bg_stats: "voxygen.element.misc_bg.inv_bg_1", inv_frame: "voxygen.element.misc_bg.inv_frame", From 1cb2022d3580b9171fef10b97ccfa4414ce17c8b Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Wed, 18 Mar 2020 19:51:48 +0100 Subject: [PATCH 138/326] UI visuals --- .../buttons/button_mmap_closed_hover.png | 4 +-- .../buttons/button_mmap_closed_press.png | 4 +-- .../buttons/button_mmap_open_hover.png | 4 +-- .../buttons/button_mmap_open_press.png | 4 +-- .../buttons/min_plus/mmap_button-min.png | 4 +-- .../min_plus/mmap_button-min_hover.png | 4 +-- .../min_plus/mmap_button-min_press.png | 4 +-- .../min_plus/mmap_button-plus_hover.png | 4 +-- .../min_plus/mmap_button-plus_press.png | 4 +-- voxygen/src/hud/bag.rs | 26 ++++++++++++------- 10 files changed, 35 insertions(+), 27 deletions(-) diff --git a/assets/voxygen/element/buttons/button_mmap_closed_hover.png b/assets/voxygen/element/buttons/button_mmap_closed_hover.png index b6c98ef5d8..c564026b15 100644 --- a/assets/voxygen/element/buttons/button_mmap_closed_hover.png +++ b/assets/voxygen/element/buttons/button_mmap_closed_hover.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:73c7c79a8803598a53977b35a7a1594b97a6b6e9eea9056b414392d3abb81e8e -size 256 +oid sha256:2e21e1e9419d01ffcdd9446fcfb84b75c87b00cdb4146b580dc0d0b6d7c4967e +size 251 diff --git a/assets/voxygen/element/buttons/button_mmap_closed_press.png b/assets/voxygen/element/buttons/button_mmap_closed_press.png index b6c98ef5d8..5279c1e65a 100644 --- a/assets/voxygen/element/buttons/button_mmap_closed_press.png +++ b/assets/voxygen/element/buttons/button_mmap_closed_press.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:73c7c79a8803598a53977b35a7a1594b97a6b6e9eea9056b414392d3abb81e8e -size 256 +oid sha256:67700122405403d71def32ad9121b3b6d636703be731e77a72b18d50672134f6 +size 261 diff --git a/assets/voxygen/element/buttons/button_mmap_open_hover.png b/assets/voxygen/element/buttons/button_mmap_open_hover.png index f175132005..4b2f90dc07 100644 --- a/assets/voxygen/element/buttons/button_mmap_open_hover.png +++ b/assets/voxygen/element/buttons/button_mmap_open_hover.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0ecd12bed8f6b7d33fb243e8a77c167685e34e85d0a9889dfa0d0c7045937526 -size 273 +oid sha256:7203aadbd31a2717fbfcab16cf27b7e89ad4e5ba398770c87e6d20d9c57e58b5 +size 265 diff --git a/assets/voxygen/element/buttons/button_mmap_open_press.png b/assets/voxygen/element/buttons/button_mmap_open_press.png index f175132005..23428bc6c0 100644 --- a/assets/voxygen/element/buttons/button_mmap_open_press.png +++ b/assets/voxygen/element/buttons/button_mmap_open_press.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0ecd12bed8f6b7d33fb243e8a77c167685e34e85d0a9889dfa0d0c7045937526 -size 273 +oid sha256:cc5ffdf4c5c251018510e05d6038d6e8698a87de3b19ab735fecca2b25bf5483 +size 266 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min.png index fdfb9d5003..0e59e30af5 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a763570725e6388d29512e0069cd8ca09a4867735380bb26d288fd303bb52805 -size 222 +oid sha256:0ac279d297cb9480128ef5c5eda66e78d21c88064fedc0065662e7997a92a2e2 +size 223 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png index 89e0d5922e..946ec005c6 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min_hover.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bb34dc3409ec0cdc69820a995044881a15b884e4f21ee0dfa5e3b233d45ca64b -size 750 +oid sha256:434e55754eda06ebc1cfac3b178ce0a9984a50b9841c532bbf1dcdf4ef66b82a +size 222 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png b/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png index 050b0ed017..7b60ce8897 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-min_press.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3c8692d5b49c945d3bc9487241fd36fd19ed2651c7c806580c8650234cf90067 -size 738 +oid sha256:6d3cff85f44a4302878353f07a587decc5de89dda11beb8d676212a3c9c7d52e +size 222 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png index ebbeadf4a6..0eb42f2400 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_hover.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2447d95d379286fe65032dc8ff8cdce3ff33277837eb310826b61698735176cd -size 258 +oid sha256:13489ec93e8261744a1d6c5ca766ebd3085789e8511172df4b7e5cf1bb920a22 +size 252 diff --git a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png index ebbeadf4a6..ae053311f0 100644 --- a/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png +++ b/assets/voxygen/element/buttons/min_plus/mmap_button-plus_press.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2447d95d379286fe65032dc8ff8cdce3ff33277837eb310826b61698735176cd -size 258 +oid sha256:e33cd41bb73bae11f0dd31b8465fcb97195842193b533e1a647ed0520b2d5a4d +size 263 diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index efe3be5a2b..671c19b758 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -32,6 +32,7 @@ widget_ids! { bg_frame, char_ico, coin_ico, + space_txt, currency_txt, inventory_title, inventory_title_bg, @@ -174,8 +175,11 @@ impl<'a> Widget for Bag<'a> { self.stats.exp.maximum(), &self.localized_strings.get("hud.bag.exp") ); + let space_used = 2; // TODO: Add functionality + let space_max = 999; + let bag_space = format!("{}/{}", space_used, space_max); let level = (self.stats.level.level()).to_string(); - let currency = 100; + let currency = 999999; // TODO: Add as a Stat maybe? // Tooltips let item_tooltip = Tooltip::new({ @@ -196,7 +200,6 @@ impl<'a> Widget for Bag<'a> { .title_text_color(TEXT_COLOR) .font_id(self.fonts.cyri.conrod_id) .desc_text_color(TEXT_COLOR); - // BG Image::new(if self.show.stats { self.imgs.inv_bg_stats @@ -233,14 +236,12 @@ impl<'a> Widget for Bag<'a> { .font_size(self.fonts.cyri.scale(22)) .color(TEXT_COLOR) .set(state.ids.inventory_title, ui); - // Scrollbar-BG Image::new(self.imgs.scrollbar_bg) .w_h(9.0, 173.0) .bottom_right_with_margins_on(state.ids.bg_frame, 42.0, 3.0) .color(Some(UI_HIGHLIGHT_0)) .set(state.ids.scrollbar_bg, ui); - // Char Pixel-Art Image::new(self.imgs.char_art) .w_h(40.0, 37.0) @@ -248,15 +249,22 @@ impl<'a> Widget for Bag<'a> { .set(state.ids.char_ico, ui); // Coin Icon and Currency Text Image::new(self.imgs.coin_ico) - .w_h(16.0 * 2.0, 17.0 * 2.0) + .w_h(16.0, 17.0) .bottom_left_with_margins_on(state.ids.bg_frame, 2.0, 43.0) .set(state.ids.coin_ico, ui); Text::new(&format!("{}", currency)) - .right_from(state.ids.coin_ico, 4.0) + .bottom_left_with_margins_on(state.ids.bg_frame, 6.0, 64.0) .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(10)) - .color(Color::Rgba(0.87, 0.86, 0.55, 1.0)) + .font_size(self.fonts.cyri.scale(14)) + .color(Color::Rgba(0.871, 0.863, 0.05, 1.0)) .set(state.ids.currency_txt, ui); + //Free Bag-Space + Text::new(&bag_space) + .bottom_right_with_margins_on(state.ids.bg_frame, 6.0, 43.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(14)) + .color(TEXT_COLOR) + .set(state.ids.space_txt, ui); // Alignment for Grid Rectangle::fill_with([362.0, 200.0], color::TRANSPARENT) .bottom_left_with_margins_on(state.ids.bg_frame, 29.0, 44.0) @@ -682,7 +690,7 @@ impl<'a> Widget for Bag<'a> { if Button::image(self.imgs.inv_tab_active) .w_h(28.0, 44.0) .bottom_left_with_margins_on(state.ids.bg, 172.0, 13.0) - .image_color(UI_HIGHLIGHT_0) + .image_color(UI_MAIN) .set(state.ids.tab_1, ui) .was_clicked() {} From 87c276b29265f77f8892031ca280cf38578000c9 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Wed, 18 Mar 2020 20:37:11 +0100 Subject: [PATCH 139/326] Add hard coded loot --- server/src/events/entity_manipulation.rs | 29 +++++++++++++++++++++++- voxygen/src/scene/figure/mod.rs | 4 ++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 022c17ce74..39dd2f738d 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -1,6 +1,7 @@ use crate::{client::Client, Server, SpawnPoint, StateExt}; use common::{ - comp::{self, HealthChange, HealthSource, Player, Stats}, + assets, + comp::{self, object, Body, HealthChange, HealthSource, Item, Player, Stats}, msg::ServerMsg, state::BlockChange, sync::{Uid, WorldSyncExt}, @@ -90,10 +91,36 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc .write_storage::() .insert(entity, comp::CharacterState::default()); } else { + // Replace npc with loot + let _ = state + .ecs() + .write_storage() + .insert(entity, Body::Object(object::Body::Pouch)); + let _ = state.ecs().write_storage().insert( + entity, + assets::load_expect_cloned::("common.items.cheese"), + ); + state.ecs().write_storage::().remove(entity); + state + .ecs() + .write_storage::() + .remove(entity); + state + .ecs() + .write_storage::() + .remove(entity); + state + .ecs() + .write_storage::() + .remove(entity); + + // TODO: Add Delete(time_left: Duration) component + /* // If not a player delete the entity if let Err(err) = state.delete_entity_recorded(entity) { error!("Failed to delete destroyed entity: {:?}", err); } + */ } } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 4d26413607..768b07ba80 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -1364,8 +1364,8 @@ impl FigureMgr { ecs.read_storage::().maybe(), ) .join() - // Don't render dead entities - .filter(|(_, _, _, _, stats, loadout, _)| stats.map_or(true, |s| !s.is_dead)) + // Don't render dead entities // Disabled to render corpses + //.filter(|(_, _, _, _, stats, loadout, _)| stats.map_or(true, |s| !s.is_dead)) { let is_player = entity == player_entity; let player_camera_mode = if is_player { From 4d9327cef536b0e80647a3683b455c062dfe3fff Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Wed, 18 Mar 2020 21:05:20 +0100 Subject: [PATCH 140/326] 2 weapons --- assets/common/items/weapons/starter_dagger.ron | 1 + assets/common/items/weapons/starter_staff.ron | 2 +- assets/common/items/weapons/starter_sword.ron | 2 +- assets/common/items/weapons/wood_sword.ron | 11 +++++++++++ assets/common/items/weapons/zweihander_sword_0.ron | 11 +++++++++++ .../voxygen/voxel/humanoid_main_weapon_manifest.ron | 10 +++++++++- common/src/comp/inventory/item.rs | 4 +++- 7 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 assets/common/items/weapons/wood_sword.ron create mode 100644 assets/common/items/weapons/zweihander_sword_0.ron diff --git a/assets/common/items/weapons/starter_dagger.ron b/assets/common/items/weapons/starter_dagger.ron index bed9c3890b..0a74a79c67 100644 --- a/assets/common/items/weapons/starter_dagger.ron +++ b/assets/common/items/weapons/starter_dagger.ron @@ -1,6 +1,7 @@ Item( name: "Sharp Kitchen Knife", description: "Great for cutting meat. + Power: 15", kind: Tool( ToolData ( diff --git a/assets/common/items/weapons/starter_staff.ron b/assets/common/items/weapons/starter_staff.ron index bc5d808ae3..16a1971dfa 100644 --- a/assets/common/items/weapons/starter_staff.ron +++ b/assets/common/items/weapons/starter_staff.ron @@ -5,7 +5,7 @@ Item( Power: 20", kind: Tool( ToolData ( - kind: Staff(BasicHammer), + kind: Staff(BasicStaff), equip_time_millis: 800, ) ), diff --git a/assets/common/items/weapons/starter_sword.ron b/assets/common/items/weapons/starter_sword.ron index 4429ac2850..c7094813ec 100644 --- a/assets/common/items/weapons/starter_sword.ron +++ b/assets/common/items/weapons/starter_sword.ron @@ -5,7 +5,7 @@ Item( Power: 15", kind: Tool( ToolData ( - kind: Sword(Rapier), + kind: Sword(BasicSword), equip_time_millis: 800, ) ), diff --git a/assets/common/items/weapons/wood_sword.ron b/assets/common/items/weapons/wood_sword.ron new file mode 100644 index 0000000000..26f0e33c93 --- /dev/null +++ b/assets/common/items/weapons/wood_sword.ron @@ -0,0 +1,11 @@ +Item( + name: "Wooden Training Sword", + description: " + Power: 15", + kind: Tool( + ToolData ( + kind: Sword(WoodTraining), + equip_time_millis: 800, + ) + ), +) diff --git a/assets/common/items/weapons/zweihander_sword_0.ron b/assets/common/items/weapons/zweihander_sword_0.ron new file mode 100644 index 0000000000..2220520918 --- /dev/null +++ b/assets/common/items/weapons/zweihander_sword_0.ron @@ -0,0 +1,11 @@ +Item( + name: "Wooden Training Sword", + description: " + Power: 15", + kind: Tool( + ToolData ( + kind: Sword(Zweihander0), + equip_time_millis: 800, + ) + ), +) diff --git a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron index 60871bc99f..e8cea5f74d 100644 --- a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron +++ b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron @@ -1,5 +1,5 @@ ({ - Sword(Scimitar): ( + Sword(BasicSword): ( vox_spec: ("weapon.sword.rusty_2h", (-1.5, -6.5, -4.0)), color: None ), @@ -7,6 +7,14 @@ vox_spec: ("weapon.sword.rusty_2h", (-1.5, -6.5, -4.0)), color: None ), + Sword(WoodTraining) + vox_spec: ("weapon.sword.wood_2h", (-1.5, -6.5, -4.0)), + color: None + ), + Sword(Zweihander0) + vox_spec: ("weapon.sword.zweihander_2h-0", (-1.5, -6.5, -4.0)), + color: None + ), Axe(BasicAxe): ( vox_spec: ("weapon.axe.rusty_2h", (-1.5, -5.0, -4.0)), color: None diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 0b5d4c59e9..8b9503bfdb 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -14,8 +14,10 @@ use std::{fs::File, io::BufReader, time::Duration, vec::Vec}; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum SwordKind { - Scimitar, + BasicSword, Rapier, + Zweihander0, + WoodTraining, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum AxeKind { From 038f65526914b9a7f87264da638ca66aea4d92fd Mon Sep 17 00:00:00 2001 From: timokoesters Date: Wed, 18 Mar 2020 21:12:55 +0100 Subject: [PATCH 141/326] fix pfau's broken commit --- assets/voxygen/voxel/humanoid_main_weapon_manifest.ron | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron index e8cea5f74d..80c022d1b7 100644 --- a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron +++ b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron @@ -7,11 +7,11 @@ vox_spec: ("weapon.sword.rusty_2h", (-1.5, -6.5, -4.0)), color: None ), - Sword(WoodTraining) + Sword(WoodTraining): ( vox_spec: ("weapon.sword.wood_2h", (-1.5, -6.5, -4.0)), color: None ), - Sword(Zweihander0) + Sword(Zweihander0): ( vox_spec: ("weapon.sword.zweihander_2h-0", (-1.5, -6.5, -4.0)), color: None ), From 1a484410ca3499040ceeff095d29ed880db46020 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 18 Mar 2020 17:00:07 -0400 Subject: [PATCH 142/326] Delete Vel and Ori on the client when they are removed on the server --- client/src/lib.rs | 34 ++---- common/src/msg/ecs_packet.rs | 15 +++ common/src/msg/server.rs | 19 +-- common/src/sync/mod.rs | 4 +- common/src/sync/packet.rs | 56 +++++++-- common/src/sync/sync_ext.rs | 36 +++--- server/src/lib.rs | 2 +- server/src/sys/entity_sync.rs | 216 +++++++++++++-------------------- server/src/sys/sentinel.rs | 28 +++-- server/src/sys/subscription.rs | 37 +++--- 10 files changed, 219 insertions(+), 228 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 0b97b35bc8..c6008fcc94 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -629,8 +629,15 @@ impl Client { ServerMsg::TimeOfDay(time_of_day) => { *self.state.ecs_mut().write_resource() = time_of_day; }, - ServerMsg::EcsSync(sync_package) => { - self.state.ecs_mut().apply_sync_package(sync_package); + ServerMsg::EntitySync(entity_sync_package) => { + self.state + .ecs_mut() + .apply_entity_sync_package(entity_sync_package); + }, + ServerMsg::CompSync(comp_sync_package) => { + self.state + .ecs_mut() + .apply_comp_sync_package(comp_sync_package); }, ServerMsg::CreateEntity(entity_package) => { self.state.ecs_mut().apply_entity_package(entity_package); @@ -667,29 +674,6 @@ impl Client { .allocate(entity_builder.entity, Some(client_uid)); self.entity = entity_builder.with(uid).build(); }, - ServerMsg::EntityPos { entity, pos } => { - if let Some(entity) = self.state.ecs().entity_from_uid(entity) { - self.state.write_component(entity, pos); - } - }, - ServerMsg::EntityVel { entity, vel } => { - if let Some(entity) = self.state.ecs().entity_from_uid(entity) { - self.state.write_component(entity, vel); - } - }, - ServerMsg::EntityOri { entity, ori } => { - if let Some(entity) = self.state.ecs().entity_from_uid(entity) { - self.state.write_component(entity, ori); - } - }, - ServerMsg::EntityCharacterState { - entity, - character_state, - } => { - if let Some(entity) = self.state.ecs().entity_from_uid(entity) { - self.state.write_component(entity, character_state); - } - }, ServerMsg::InventoryUpdate(inventory, event) => { match event { InventoryUpdateEvent::CollectFailed => { diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index 4034c6b953..31a80fa727 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -25,6 +25,9 @@ sum_type! { Loadout(comp::Loadout), Attacking(comp::Attacking), CharacterState(comp::CharacterState), + Pos(comp::Pos), + Vel(comp::Vel), + Ori(comp::Ori), } } // Automatically derive From for EcsCompPhantom @@ -49,6 +52,9 @@ sum_type! { Loadout(PhantomData), Attacking(PhantomData), CharacterState(PhantomData), + Pos(PhantomData), + Vel(PhantomData), + Ori(PhantomData), } } impl sync::CompPacket for EcsCompPacket { @@ -73,6 +79,9 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Loadout(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Attacking(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::CharacterState(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::Pos(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::Vel(comp) => sync::handle_insert(comp, entity, world), + EcsCompPacket::Ori(comp) => sync::handle_insert(comp, entity, world), } } @@ -95,6 +104,9 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Loadout(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Attacking(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::CharacterState(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::Pos(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::Vel(comp) => sync::handle_modify(comp, entity, world), + EcsCompPacket::Ori(comp) => sync::handle_modify(comp, entity, world), } } @@ -123,6 +135,9 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPhantom::CharacterState(_) => { sync::handle_remove::(entity, world) }, + EcsCompPhantom::Pos(_) => sync::handle_remove::(entity, world), + EcsCompPhantom::Vel(_) => sync::handle_remove::(entity, world), + EcsCompPhantom::Ori(_) => sync::handle_remove::(entity, world), } } } diff --git a/common/src/msg/server.rs b/common/src/msg/server.rs index c517eec665..5e6fecac33 100644 --- a/common/src/msg/server.rs +++ b/common/src/msg/server.rs @@ -46,25 +46,10 @@ pub enum ServerMsg { }, SetPlayerEntity(u64), TimeOfDay(state::TimeOfDay), - EcsSync(sync::SyncPackage), + EntitySync(sync::EntitySyncPackage), + CompSync(sync::CompSyncPackage), CreateEntity(sync::EntityPackage), DeleteEntity(u64), - EntityPos { - entity: u64, - pos: comp::Pos, - }, - EntityVel { - entity: u64, - vel: comp::Vel, - }, - EntityOri { - entity: u64, - ori: comp::Ori, - }, - EntityCharacterState { - entity: u64, - character_state: comp::CharacterState, - }, InventoryUpdate(comp::Inventory, comp::InventoryUpdateEvent), TerrainChunkUpdate { key: Vec2, diff --git a/common/src/sync/mod.rs b/common/src/sync/mod.rs index cce991d1df..914793c024 100644 --- a/common/src/sync/mod.rs +++ b/common/src/sync/mod.rs @@ -7,8 +7,8 @@ mod uid; // Reexports pub use packet::{ - handle_insert, handle_modify, handle_remove, CompPacket, EntityPackage, StatePackage, - SyncPackage, + handle_insert, handle_modify, handle_remove, CompPacket, CompSyncPackage, EntityPackage, + EntitySyncPackage, StatePackage, }; pub use sync_ext::WorldSyncExt; pub use track::UpdateTracker; diff --git a/common/src/sync/packet.rs b/common/src/sync/packet.rs index ef7a419c22..6c0f9c115b 100644 --- a/common/src/sync/packet.rs +++ b/common/src/sync/packet.rs @@ -23,18 +23,22 @@ pub trait CompPacket: Clone + Debug + Send + 'static { pub fn handle_insert(comp: C, entity: Entity, world: &World) { if let Err(err) = world.write_storage::().insert(entity, comp) { error!("Error inserting component: {:?}", err); - }; + } } /// Useful for implementing CompPacket trait pub fn handle_modify(comp: C, entity: Entity, world: &World) { - let _ = world + if world .write_storage::() .get_mut(entity) - .map(|c| *c = comp); + .map(|c| *c = comp) + .is_none() + { + error!("Error modifying synced component, it doesn't seem to exist"); + } } /// Useful for implementing CompPacket trait pub fn handle_remove(entity: Entity, world: &World) { - let _ = world.write_storage::().remove(entity); + world.write_storage::().remove(entity); } #[derive(Copy, Clone, Debug, Serialize, Deserialize)] @@ -81,12 +85,11 @@ impl StatePackage

{ } #[derive(Clone, Debug, Serialize, Deserialize)] -pub struct SyncPackage { - pub comp_updates: Vec<(u64, CompUpdateKind

)>, +pub struct EntitySyncPackage { pub created_entities: Vec, pub deleted_entities: Vec, } -impl SyncPackage

{ +impl EntitySyncPackage { pub fn new<'a>( uids: &ReadStorage<'a, Uid>, uid_tracker: &UpdateTracker, @@ -100,11 +103,48 @@ impl SyncPackage

{ .collect(); Self { - comp_updates: Vec::new(), created_entities, deleted_entities, } } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct CompSyncPackage { + // TODO: this can be made to take less space by clumping updates for the same entity together + pub comp_updates: Vec<(u64, CompUpdateKind

)>, +} + +impl CompSyncPackage

{ + pub fn new() -> Self { + Self { + comp_updates: Vec::new(), + } + } + + pub fn comp_inserted(&mut self, uid: Uid, comp: C) + where + P: From, + { + self.comp_updates + .push((uid.into(), CompUpdateKind::Inserted(comp.into()))); + } + + pub fn comp_modified(&mut self, uid: Uid, comp: C) + where + P: From, + { + self.comp_updates + .push((uid.into(), CompUpdateKind::Modified(comp.into()))); + } + + pub fn comp_removed(&mut self, uid: Uid) + where + P::Phantom: From>, + { + self.comp_updates + .push((uid.into(), CompUpdateKind::Removed(PhantomData::.into()))); + } pub fn with_component<'a, C: Component + Clone + Send + Sync>( mut self, diff --git a/common/src/sync/sync_ext.rs b/common/src/sync/sync_ext.rs index a84bdcb0b8..a8224b62a5 100644 --- a/common/src/sync/sync_ext.rs +++ b/common/src/sync/sync_ext.rs @@ -1,5 +1,7 @@ use super::{ - packet::{CompPacket, CompUpdateKind, EntityPackage, StatePackage, SyncPackage}, + packet::{ + CompPacket, CompSyncPackage, CompUpdateKind, EntityPackage, EntitySyncPackage, StatePackage, + }, track::UpdateTracker, uid::{Uid, UidAllocator}, }; @@ -27,7 +29,8 @@ pub trait WorldSyncExt { entity_package: EntityPackage

, ) -> specs::Entity; fn apply_state_package(&mut self, state_package: StatePackage

); - fn apply_sync_package(&mut self, package: SyncPackage

); + fn apply_entity_sync_package(&mut self, package: EntitySyncPackage); + fn apply_comp_sync_package(&mut self, package: CompSyncPackage

); } impl WorldSyncExt for specs::World { @@ -106,24 +109,30 @@ impl WorldSyncExt for specs::World { //self.maintain(); } - fn apply_sync_package(&mut self, package: SyncPackage

) { + fn apply_entity_sync_package(&mut self, package: EntitySyncPackage) { // Take ownership of the fields - let SyncPackage { - comp_updates, + let EntitySyncPackage { created_entities, deleted_entities, } = package; // Attempt to create entities - for entity_uid in created_entities { - create_entity_with_uid(self, entity_uid); - } + created_entities.into_iter().for_each(|uid| { + create_entity_with_uid(self, uid); + }); + // Attempt to delete entities that were marked for deletion + deleted_entities.into_iter().for_each(|uid| { + self.delete_entity_and_clear_from_uid_allocator(uid); + }); + } + + fn apply_comp_sync_package(&mut self, package: CompSyncPackage

) { // Update components - for (entity_uid, update) in comp_updates { + package.comp_updates.into_iter().for_each(|(uid, update)| { if let Some(entity) = self .read_resource::() - .retrieve_entity_internal(entity_uid) + .retrieve_entity_internal(uid) { match update { CompUpdateKind::Inserted(packet) => { @@ -137,12 +146,7 @@ impl WorldSyncExt for specs::World { }, } } - } - - // Attempt to delete entities that were marked for deletion - for entity_uid in deleted_entities { - self.delete_entity_and_clear_from_uid_allocator(entity_uid); - } + }); } } diff --git a/server/src/lib.rs b/server/src/lib.rs index 5d06f7498f..f4b2560393 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -468,7 +468,7 @@ impl Server { .notify(ServerMsg::InitialSync { // Send client their entity entity_package: TrackedComps::fetch(&self.state.ecs()) - .create_entity_package(entity), + .create_entity_package(entity, None, None, None), server_info: self.server_info.clone(), time_of_day: *self.state.ecs().read_resource(), world_map: (WORLD_SIZE.map(|e| e as u32), self.map.clone()), diff --git a/server/src/sys/entity_sync.rs b/server/src/sys/entity_sync.rs index f9a5dcfe19..d499a61ec4 100644 --- a/server/src/sys/entity_sync.rs +++ b/server/src/sys/entity_sync.rs @@ -11,7 +11,7 @@ use common::{ msg::ServerMsg, region::{Event as RegionEvent, RegionMap}, state::TimeOfDay, - sync::Uid, + sync::{CompSyncPackage, Uid}, }; use specs::{ Entities, Entity as EcsEntity, Join, Read, ReadExpect, ReadStorage, System, Write, WriteStorage, @@ -30,13 +30,11 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Pos>, ReadStorage<'a, Vel>, ReadStorage<'a, Ori>, - ReadStorage<'a, CharacterState>, ReadStorage<'a, Inventory>, ReadStorage<'a, RegionSubscription>, WriteStorage<'a, Last>, WriteStorage<'a, Last>, WriteStorage<'a, Last>, - WriteStorage<'a, Last>, WriteStorage<'a, Client>, WriteStorage<'a, ForceUpdate>, WriteStorage<'a, InventoryUpdate>, @@ -57,13 +55,11 @@ impl<'a> System<'a> for Sys { positions, velocities, orientations, - character_states, inventories, subscriptions, mut last_pos, mut last_vel, mut last_ori, - mut last_character_state, mut clients, mut force_updates, mut inventory_updates, @@ -116,22 +112,18 @@ impl<'a> System<'a> for Sys { continue; } let entity = entities.entity(*id); - if let Some((uid, pos, vel, ori, character_state)) = - uids.get(entity).and_then(|uid| { - positions.get(entity).map(|pos| { - ( - uid, - pos, - velocities.get(entity), - orientations.get(entity), - character_states.get(entity), - ) - }) + if let Some((uid, pos, vel, ori)) = uids.get(entity).and_then(|uid| { + positions.get(entity).map(|pos| { + (uid, pos, velocities.get(entity), orientations.get(entity)) }) - { - let create_msg = ServerMsg::CreateEntity( - tracked_comps.create_entity_package(entity), - ); + }) { + let create_msg = + ServerMsg::CreateEntity(tracked_comps.create_entity_package( + entity, + Some(*pos), + vel.copied(), + ori.copied(), + )); for (client, regions, client_entity, _) in &mut subscribers { if maybe_key .as_ref() @@ -141,14 +133,6 @@ impl<'a> System<'a> for Sys { && *client_entity != entity { client.notify(create_msg.clone()); - send_initial_unsynced_components( - client, - uid, - pos, - vel, - ori, - character_state, - ); } } } @@ -172,18 +156,19 @@ impl<'a> System<'a> for Sys { // Sync tracked components // Get deleted entities in this region from DeletedEntities - let sync_msg = ServerMsg::EcsSync( - trackers.create_sync_package( - &tracked_comps, - region.entities(), - deleted_entities - .take_deleted_in_region(key) - .unwrap_or_else(|| Vec::new()), - ), + let (entity_sync_package, comp_sync_package) = trackers.create_sync_packages( + &tracked_comps, + region.entities(), + deleted_entities + .take_deleted_in_region(key) + .unwrap_or_else(|| Vec::new()), ); - for (client, _, _, _) in &mut subscribers { - client.notify(sync_msg.clone()); - } + let entity_sync_msg = ServerMsg::EntitySync(entity_sync_package); + let comp_sync_msg = ServerMsg::CompSync(comp_sync_package); + subscribers.iter_mut().for_each(move |(client, _, _, _)| { + client.notify(entity_sync_msg.clone()); + client.notify(comp_sync_msg.clone()); + }); let mut send_msg = |msg: ServerMsg, entity: EcsEntity, @@ -191,117 +176,112 @@ impl<'a> System<'a> for Sys { force_update: Option<&ForceUpdate>, throttle: bool| { for (client, _, client_entity, client_pos) in &mut subscribers { - let update = if client_entity == &entity { + if if client_entity == &entity { // Don't send client physics updates about itself unless force update is set force_update.is_some() } else if !throttle { - // Update rate not thottled by distance + // Send the message if not throttling true } else { // Throttle update rate based on distance to client let distance_sq = client_pos.0.distance_squared(pos.0); + let id_staggered_tick = tick + entity.id() as u64; // More entities farther away so checks start there if distance_sq > 300.0f32.powi(2) { - (tick + entity.id() as u64) % 32 == 0 + id_staggered_tick % 32 == 0 } else if distance_sq > 250.0f32.powi(2) { - (tick + entity.id() as u64) % 16 == 0 + id_staggered_tick % 16 == 0 } else if distance_sq > 200.0f32.powi(2) { - (tick + entity.id() as u64) % 8 == 0 + id_staggered_tick % 8 == 0 } else if distance_sq > 150.0f32.powi(2) { - (tick + entity.id() as u64) % 4 == 0 + id_staggered_tick % 4 == 0 } else if distance_sq > 100.0f32.powi(2) { - (tick + entity.id() as u64) % 2 == 0 + id_staggered_tick % 2 == 0 } else { true // Closer than 100 blocks } - }; - - if update { + } { client.notify(msg.clone()); } } }; // Sync physics components - for (_, entity, &uid, &pos, maybe_vel, maybe_ori, character_state, force_update) in ( + for (_, entity, &uid, &pos, maybe_vel, maybe_ori, force_update) in ( region.entities(), &entities, &uids, &positions, velocities.maybe(), orientations.maybe(), - character_states.maybe(), force_updates.maybe(), ) .join() { + let mut comp_sync_package = CompSyncPackage::new(); + let mut throttle = true; // TODO: An entity that stoppped moving on a tick that it wasn't sent to the // player will never have it's position updated - if last_pos.get(entity).map(|&l| l.0 != pos).unwrap_or(true) { - let _ = last_pos.insert(entity, Last(pos)); - send_msg( - ServerMsg::EntityPos { - entity: uid.into(), - pos, - }, - entity, - pos, - force_update, - true, - ); + match last_pos.get(entity).map(|&l| l.0 != pos) { + Some(false) => {}, + Some(true) => { + let _ = last_pos.insert(entity, Last(pos)); + comp_sync_package.comp_modified(uid, pos); + }, + None => { + let _ = last_pos.insert(entity, Last(pos)); + throttle = false; + comp_sync_package.comp_inserted(uid, pos); + }, } if let Some(&vel) = maybe_vel { - if last_vel.get(entity).map(|&l| l.0 != vel).unwrap_or(true) { - let _ = last_vel.insert(entity, Last(vel)); - send_msg( - ServerMsg::EntityVel { - entity: uid.into(), - vel, - }, - entity, - pos, - force_update, - true, - ); + match last_vel.get(entity).map(|&l| l.0 != vel) { + Some(false) => {}, + Some(true) => { + let _ = last_vel.insert(entity, Last(vel)); + comp_sync_package.comp_modified(uid, vel); + }, + None => { + let _ = last_vel.insert(entity, Last(vel)); + throttle = false; + comp_sync_package.comp_inserted(uid, vel); + }, } + } else if last_vel.remove(entity).is_some() { + // Send removal message if Vel was removed + // Note: we don't have to handle this for position because the entity will be + // removed from the client by the region system + throttle = false; + comp_sync_package.comp_removed::(uid); } if let Some(&ori) = maybe_ori { - if last_ori.get(entity).map(|&l| l.0 != ori).unwrap_or(true) { - let _ = last_ori.insert(entity, Last(ori)); - send_msg( - ServerMsg::EntityOri { - entity: uid.into(), - ori, - }, - entity, - pos, - force_update, - true, - ); + match last_ori.get(entity).map(|&l| l.0 != ori) { + Some(false) => {}, + Some(true) => { + let _ = last_ori.insert(entity, Last(ori)); + comp_sync_package.comp_modified(uid, ori); + }, + None => { + let _ = last_ori.insert(entity, Last(ori)); + throttle = false; + comp_sync_package.comp_inserted(uid, ori); + }, } + } else if last_ori.remove(entity).is_some() { + // Send removal message if Ori was removed + throttle = false; + comp_sync_package.comp_removed::(uid); } - if let Some(&character_state) = character_state.as_ref() { - if last_character_state - .get(entity) - .map(|l| !character_state.equals(&l.0)) - .unwrap_or(true) - { - let _ = last_character_state.insert(entity, Last(character_state.clone())); - send_msg( - ServerMsg::EntityCharacterState { - entity: uid.into(), - character_state: character_state.clone(), - }, - entity, - pos, - force_update, - false, - ); - } - } + send_msg( + ServerMsg::CompSync(comp_sync_package), + entity, + pos, + force_update, + throttle, + ); } } @@ -350,27 +330,3 @@ impl<'a> System<'a> for Sys { timer.end(); } } - -pub fn send_initial_unsynced_components( - client: &mut Client, - uid: &Uid, - pos: &Pos, - vel: Option<&Vel>, - ori: Option<&Ori>, - character_state: Option<&CharacterState>, -) { - let entity = (*uid).into(); - client.notify(ServerMsg::EntityPos { entity, pos: *pos }); - if let Some(&vel) = vel { - client.notify(ServerMsg::EntityVel { entity, vel }); - } - if let Some(&ori) = ori { - client.notify(ServerMsg::EntityOri { entity, ori }); - } - if let Some(character_state) = character_state.cloned() { - client.notify(ServerMsg::EntityCharacterState { - entity, - character_state, - }); - } -} diff --git a/server/src/sys/sentinel.rs b/server/src/sys/sentinel.rs index d9db6bbded..9b388e61cd 100644 --- a/server/src/sys/sentinel.rs +++ b/server/src/sys/sentinel.rs @@ -2,10 +2,10 @@ use super::SysTimer; use common::{ comp::{ Body, CanBuild, CharacterState, Energy, Gravity, Item, LightEmitter, Loadout, Mass, - MountState, Mounting, Player, Scale, Stats, Sticky, + MountState, Mounting, Ori, Player, Pos, Scale, Stats, Sticky, Vel, }, msg::EcsCompPacket, - sync::{EntityPackage, SyncPackage, Uid, UpdateTracker, WorldSyncExt}, + sync::{CompSyncPackage, EntityPackage, EntitySyncPackage, Uid, UpdateTracker, WorldSyncExt}, }; use hashbrown::HashMap; use specs::{ @@ -55,7 +55,13 @@ pub struct TrackedComps<'a> { pub character_state: ReadStorage<'a, CharacterState>, } impl<'a> TrackedComps<'a> { - pub fn create_entity_package(&self, entity: EcsEntity) -> EntityPackage { + pub fn create_entity_package( + &self, + entity: EcsEntity, + pos: Option, + vel: Option, + ori: Option, + ) -> EntityPackage { let uid = self .uid .get(entity) @@ -114,6 +120,10 @@ impl<'a> TrackedComps<'a> { .get(entity) .cloned() .map(|c| comps.push(c.into())); + // Add untracked comps + pos.map(|c| comps.push(c.into())); + vel.map(|c| comps.push(c.into())); + ori.map(|c| comps.push(c.into())); EntityPackage { uid, comps } } @@ -138,13 +148,15 @@ pub struct ReadTrackers<'a> { pub character_state: ReadExpect<'a, UpdateTracker>, } impl<'a> ReadTrackers<'a> { - pub fn create_sync_package( + pub fn create_sync_packages( &self, comps: &TrackedComps, filter: impl Join + Copy, deleted_entities: Vec, - ) -> SyncPackage { - SyncPackage::new(&comps.uid, &self.uid, filter, deleted_entities) + ) -> (EntitySyncPackage, CompSyncPackage) { + let entity_sync_package = + EntitySyncPackage::new(&comps.uid, &self.uid, filter, deleted_entities); + let comp_sync_package = CompSyncPackage::new() .with_component(&comps.uid, &*self.body, &comps.body, filter) .with_component(&comps.uid, &*self.player, &comps.player, filter) .with_component(&comps.uid, &*self.stats, &comps.stats, filter) @@ -169,7 +181,9 @@ impl<'a> ReadTrackers<'a> { &*self.character_state, &comps.character_state, filter, - ) + ); + + (entity_sync_package, comp_sync_package) } } diff --git a/server/src/sys/subscription.rs b/server/src/sys/subscription.rs index f9de9609ba..07a8a15315 100644 --- a/server/src/sys/subscription.rs +++ b/server/src/sys/subscription.rs @@ -194,19 +194,16 @@ impl<'a> System<'a> for Sys { .join() .filter(|(_, _, _, _, _, _, e)| *e != client_entity) { - // Send message to create entity and tracked components + // Send message to create entity and tracked components and physics + // components client.notify(ServerMsg::CreateEntity( - tracked_comps.create_entity_package(entity), + tracked_comps.create_entity_package( + entity, + Some(*pos), + vel.copied(), + ori.copied(), + ), )); - // Send message to create physics components - super::entity_sync::send_initial_unsynced_components( - client, - uid, - pos, - vel, - ori, - character_state, - ); } } } @@ -253,19 +250,15 @@ pub fn initialize_region_subscription(world: &World, entity: specs::Entity) { ) .join() { - // Send message to create entity and tracked components + // Send message to create entity and tracked components and physics components client.notify(ServerMsg::CreateEntity( - tracked_comps.create_entity_package(entity), + tracked_comps.create_entity_package( + entity, + Some(*pos), + vel.copied(), + ori.copied(), + ), )); - // Send message to create physics components - super::entity_sync::send_initial_unsynced_components( - client, - uid, - pos, - vel, - ori, - character_state, - ); } } } From 509615c15be92864a6074d884ab12ad50638bc53 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Wed, 18 Mar 2020 23:09:58 +0100 Subject: [PATCH 143/326] npc armour --- .../common/items/armor/shoulder_leather-0.ron | 8 ++ assets/common/items/weapons/short_sword_0.ron | 11 +++ .../items/weapons/zweihander_sword_0.ron | 2 +- .../{brown_left.vox => leather_left-0.vox} | 0 .../{brown_right.vox => leather_right-0.vox} | 0 .../humanoid_armor_shoulder_manifest.ron | 10 +++ .../voxel/humanoid_main_weapon_manifest.ron | 4 + .../voxygen/voxel/weapon/sword/short_2h-0.vox | 3 + common/src/comp/body/humanoid.rs | 4 +- common/src/comp/inventory/item.rs | 1 + server/src/sys/terrain.rs | 86 ++++++++++++++----- 11 files changed, 105 insertions(+), 24 deletions(-) create mode 100644 assets/common/items/armor/shoulder_leather-0.ron create mode 100644 assets/common/items/weapons/short_sword_0.ron rename assets/voxygen/voxel/armor/shoulder/{brown_left.vox => leather_left-0.vox} (100%) rename assets/voxygen/voxel/armor/shoulder/{brown_right.vox => leather_right-0.vox} (100%) create mode 100644 assets/voxygen/voxel/weapon/sword/short_2h-0.vox diff --git a/assets/common/items/armor/shoulder_leather-0.ron b/assets/common/items/armor/shoulder_leather-0.ron new file mode 100644 index 0000000000..351beaff2a --- /dev/null +++ b/assets/common/items/armor/shoulder_leather-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Leather Pauldrons", + description: "", + kind: Armor( + kind: Shoulder(Leather0), + stats: 20, + ), +) diff --git a/assets/common/items/weapons/short_sword_0.ron b/assets/common/items/weapons/short_sword_0.ron new file mode 100644 index 0000000000..4ee3ca4da2 --- /dev/null +++ b/assets/common/items/weapons/short_sword_0.ron @@ -0,0 +1,11 @@ +Item( + name: "Vicious Gladius", + description: " + Power: 15", + kind: Tool( + ToolData ( + kind: Sword(Short0), + equip_time_millis: 800, + ) + ), +) diff --git a/assets/common/items/weapons/zweihander_sword_0.ron b/assets/common/items/weapons/zweihander_sword_0.ron index 2220520918..3703a16da1 100644 --- a/assets/common/items/weapons/zweihander_sword_0.ron +++ b/assets/common/items/weapons/zweihander_sword_0.ron @@ -1,5 +1,5 @@ Item( - name: "Wooden Training Sword", + name: "Sturdy Bihander", description: " Power: 15", kind: Tool( diff --git a/assets/voxygen/voxel/armor/shoulder/brown_left.vox b/assets/voxygen/voxel/armor/shoulder/leather_left-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/shoulder/brown_left.vox rename to assets/voxygen/voxel/armor/shoulder/leather_left-0.vox diff --git a/assets/voxygen/voxel/armor/shoulder/brown_right.vox b/assets/voxygen/voxel/armor/shoulder/leather_right-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/shoulder/brown_right.vox rename to assets/voxygen/voxel/armor/shoulder/leather_right-0.vox diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index fb174f8ec3..b7ecd2fa2f 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -60,4 +60,14 @@ color: None ) ), + Leather0: ( + left: ( + vox_spec: ("armor.shoulder.leather_left-0", (-3.6, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.leather_right-0", (-2.6, -3.5, 1.0)), + color: None + ) + ), }) diff --git a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron index 80c022d1b7..bbd70395a9 100644 --- a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron +++ b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron @@ -15,6 +15,10 @@ vox_spec: ("weapon.sword.zweihander_2h-0", (-1.5, -6.5, -4.0)), color: None ), + Sword(Short0): ( + vox_spec: ("weapon.sword.short_2h-0", (-1.5, -6.5, -4.0)), + color: None + ), Axe(BasicAxe): ( vox_spec: ("weapon.axe.rusty_2h", (-1.5, -5.0, -4.0)), color: None diff --git a/assets/voxygen/voxel/weapon/sword/short_2h-0.vox b/assets/voxygen/voxel/weapon/sword/short_2h-0.vox new file mode 100644 index 0000000000..291ca561c8 --- /dev/null +++ b/assets/voxygen/voxel/weapon/sword/short_2h-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df2356d9eea495f7d2975a664eaab89bbfd2cd2c04bd3c7cd8de87c59416eb5d +size 55992 diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index 28f2a80603..db884575b1 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -581,13 +581,15 @@ pub enum Shoulder { Chain = 2, Assassin = 3, Plate0 = 4, + Leather0 = 5, } -pub const ALL_SHOULDERS: [Shoulder; 5] = [ +pub const ALL_SHOULDERS: [Shoulder; 6] = [ Shoulder::None, Shoulder::Brown1, Shoulder::Chain, Shoulder::Assassin, Shoulder::Plate0, + Shoulder::Leather0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 8b9503bfdb..d4e7c7ff4b 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -18,6 +18,7 @@ pub enum SwordKind { Rapier, Zweihander0, WoodTraining, + Short0, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum AxeKind { diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index e705dea577..1f76674bbd 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -2,7 +2,7 @@ use super::SysTimer; use crate::{chunk_generator::ChunkGenerator, client::Client, Tick}; use common::{ assets, - comp::{self, item, CharacterAbility, Item, ItemConfig, Player, Pos}, + comp::{self, humanoid, item, CharacterAbility, Item, ItemConfig, Player, Pos}, event::{EventBus, ServerEvent}, generation::EntityKind, msg::ServerMsg, @@ -126,7 +126,9 @@ impl<'a> System<'a> for Sys { get_npc_name(&NPC_NAMES.humanoid, body.race) ), comp::Body::Humanoid(body), - Some(assets::load_expect_cloned("common.items.weapons.staff_1")), + Some(assets::load_expect_cloned( + "common.items.weapons.starter_axe", + )), comp::Alignment::Npc, ) }) as _, @@ -135,7 +137,9 @@ impl<'a> System<'a> for Sys { ( format!("{} Bandit", get_npc_name(&NPC_NAMES.humanoid, body.race)), comp::Body::Humanoid(body), - Some(assets::load_expect_cloned("common.items.weapons.staff_1")), + Some(assets::load_expect_cloned( + "common.items.weapons.short_sword_0", + )), comp::Alignment::Enemy, ) }) as _, @@ -196,12 +200,24 @@ impl<'a> System<'a> for Sys { dodge_ability: Some(comp::CharacterAbility::Roll), }), second_item: None, - shoulder: None, - chest: None, - belt: None, - hand: None, - pants: None, - foot: None, + shoulder: Some(assets::load_expect_cloned( + "common.items.armor.shoulder_plate-0", + )), + chest: Some(assets::load_expect_cloned( + "common.items.armor.chest.chest_plate_green-0", + )), + belt: Some(assets::load_expect_cloned( + "common.items.armor.belt_plate-0", + )), + hand: Some(assets::load_expect_cloned( + "common.items.armor.hand_plate-0", + )), + pants: Some(assets::load_expect_cloned( + "common.items.armor.pants_plate_green-0", + )), + foot: Some(assets::load_expect_cloned( + "common.items.armor.foot_plate-0", + )), } } else { comp::Loadout { @@ -217,12 +233,24 @@ impl<'a> System<'a> for Sys { dodge_ability: None, }), second_item: None, - shoulder: None, - chest: None, - belt: None, - hand: None, - pants: None, - foot: None, + shoulder: Some(assets::load_expect_cloned( + "common.items.armor.shoulder_leather-0", + )), + chest: Some(assets::load_expect_cloned( + "common.items.armor.chest.chest_plate_green-0", + )), + belt: Some(assets::load_expect_cloned( + "common.items.armor.belt_plate-0", + )), + hand: Some(assets::load_expect_cloned( + "common.items.armor.hand_plate-0", + )), + pants: Some(assets::load_expect_cloned( + "common.items.armor.pants_plate_green-0", + )), + foot: Some(assets::load_expect_cloned( + "common.items.armor.foot_plate-0", + )), } }; @@ -247,7 +275,9 @@ impl<'a> System<'a> for Sys { } loadout = comp::Loadout { active_item: Some(comp::ItemConfig { - item: assets::load_expect_cloned("common.items.weapons.hammer_1"), + item: assets::load_expect_cloned( + "common.items.weapons.zweihander_sword_0", + ), primary_ability: Some(CharacterAbility::BasicMelee { buildup_duration: Duration::from_millis(800), recover_duration: Duration::from_millis(200), @@ -258,12 +288,24 @@ impl<'a> System<'a> for Sys { dodge_ability: None, }), second_item: None, - shoulder: None, - chest: None, - belt: None, - hand: None, - pants: None, - foot: None, + shoulder: Some(assets::load_expect_cloned( + "common.items.armor.shoulder_plate-0", + )), + chest: Some(assets::load_expect_cloned( + "common.items.armor.chest.chest_plate_green-0", + )), + belt: Some(assets::load_expect_cloned( + "common.items.armor.belt_plate-0", + )), + hand: Some(assets::load_expect_cloned( + "common.items.armor.hand_plate-0", + )), + pants: Some(assets::load_expect_cloned( + "common.items.armor.pants_plate_green-0", + )), + foot: Some(assets::load_expect_cloned( + "common.items.armor.foot_plate-0", + )), }; stats.level.set_level(rand::thread_rng().gen_range(8, 15)); From 2b22b84a33219a738d886b782a68520f43c4c4a5 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 19 Mar 2020 11:00:28 +0100 Subject: [PATCH 144/326] Give bandits and travelers different armor --- server/src/sys/terrain.rs | 137 +++++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 60 deletions(-) diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 1f76674bbd..caa2087057 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -112,6 +112,7 @@ impl<'a> System<'a> for Sys { ) -> &'a str { &body_data.species[&species].generic } + const SPAWN_NPCS: &'static [fn() -> ( String, comp::Body, @@ -186,80 +187,96 @@ impl<'a> System<'a> for Sys { ); let mut stats = comp::Stats::new(name, body); - let mut loadout = + let active_item = if let Some(comp::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) { let mut abilities = tool.get_abilities(); let mut ability_drain = abilities.drain(..); - comp::Loadout { - active_item: main.map(|item| comp::ItemConfig { - item, - primary_ability: ability_drain.next(), - secondary_ability: ability_drain.next(), - block_ability: Some(comp::CharacterAbility::BasicBlock), - dodge_ability: Some(comp::CharacterAbility::Roll), - }), - second_item: None, - shoulder: Some(assets::load_expect_cloned( - "common.items.armor.shoulder_plate-0", - )), - chest: Some(assets::load_expect_cloned( - "common.items.armor.chest.chest_plate_green-0", - )), - belt: Some(assets::load_expect_cloned( - "common.items.armor.belt_plate-0", - )), - hand: Some(assets::load_expect_cloned( - "common.items.armor.hand_plate-0", - )), - pants: Some(assets::load_expect_cloned( - "common.items.armor.pants_plate_green-0", - )), - foot: Some(assets::load_expect_cloned( - "common.items.armor.foot_plate-0", - )), - } + main.map(|item| comp::ItemConfig { + item, + primary_ability: ability_drain.next(), + secondary_ability: ability_drain.next(), + block_ability: Some(comp::CharacterAbility::BasicBlock), + dodge_ability: Some(comp::CharacterAbility::Roll), + }) } else { - comp::Loadout { - active_item: Some(ItemConfig { - item: Item::empty(), - primary_ability: Some(CharacterAbility::BasicMelee { - buildup_duration: Duration::from_millis(50), - recover_duration: Duration::from_millis(50), - base_damage: 1, - }), - secondary_ability: None, - block_ability: None, - dodge_ability: None, + Some(ItemConfig { + item: Item::empty(), + primary_ability: Some(CharacterAbility::BasicMelee { + buildup_duration: Duration::from_millis(50), + recover_duration: Duration::from_millis(50), + base_damage: 1, }), - second_item: None, - shoulder: Some(assets::load_expect_cloned( - "common.items.armor.shoulder_leather-0", - )), - chest: Some(assets::load_expect_cloned( - "common.items.armor.chest.chest_plate_green-0", - )), - belt: Some(assets::load_expect_cloned( - "common.items.armor.belt_plate-0", - )), - hand: Some(assets::load_expect_cloned( - "common.items.armor.hand_plate-0", - )), - pants: Some(assets::load_expect_cloned( - "common.items.armor.pants_plate_green-0", - )), - foot: Some(assets::load_expect_cloned( - "common.items.armor.foot_plate-0", - )), - } + secondary_ability: None, + block_ability: None, + dodge_ability: None, + }) }; + let mut loadout = match alignment { + comp::Alignment::Npc => comp::Loadout { + active_item, + second_item: None, + shoulder: Some(assets::load_expect_cloned( + "common.items.armor.shoulder_plate-0", + )), + chest: Some(assets::load_expect_cloned( + "common.items.armor.chest.chest_plate_green-0", + )), + belt: Some(assets::load_expect_cloned( + "common.items.armor.belt_plate-0", + )), + hand: Some(assets::load_expect_cloned( + "common.items.armor.hand_plate-0", + )), + pants: Some(assets::load_expect_cloned( + "common.items.armor.pants_plate_green-0", + )), + foot: Some(assets::load_expect_cloned( + "common.items.armor.foot_plate-0", + )), + }, + comp::Alignment::Enemy => comp::Loadout { + active_item, + second_item: None, + shoulder: Some(assets::load_expect_cloned( + "common.items.armor.shoulder_leather-0", + )), + chest: Some(assets::load_expect_cloned( + "common.items.armor.chest.chest_plate_green-0", + )), + belt: Some(assets::load_expect_cloned( + "common.items.armor.belt_plate-0", + )), + hand: Some(assets::load_expect_cloned( + "common.items.armor.hand_plate-0", + )), + pants: Some(assets::load_expect_cloned( + "common.items.armor.pants_plate_green-0", + )), + foot: Some(assets::load_expect_cloned( + "common.items.armor.foot_plate-0", + )), + }, + _ => comp::Loadout { + active_item, + second_item: None, + shoulder: None, + chest: None, + belt: None, + hand: None, + pants: None, + foot: None, + }, + }; + let mut scale = 1.0; // TODO: Remove this and implement scaling or level depending on stuff like // species instead stats.level.set_level(rand::thread_rng().gen_range(1, 4)); + // Replace stuff if it's a boss if let EntityKind::Boss = entity.kind { if rand::random::() < 0.65 { let body_new = comp::humanoid::Body::random(); From d863e1223562f7c1b9c30fb9f3e6693ef00b97ec Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 19 Mar 2020 14:17:53 +0100 Subject: [PATCH 145/326] swift leather armour parts --- assets/common/items/armor/belt_leather-0.ron | 8 +++++ .../items/armor/chest/chest_leather-0.ron | 8 +++++ assets/common/items/armor/foot_leather-0.ron | 8 +++++ assets/common/items/armor/hand_leather-0.ron | 8 +++++ .../{pants_green.ron => pants_green-0.ron} | 4 +-- assets/common/items/armor/pants_leather-0.ron | 8 +++++ .../common/items/armor/shoulder_leather-1.ron | 8 +++++ assets/voxygen/voxel/armor/belt/leather-0.vox | 3 ++ .../voxygen/voxel/armor/chest/leather-0.vox | 3 ++ assets/voxygen/voxel/armor/foot/leather-0.vox | 3 ++ .../voxel/armor/hand/leather_left-0.vox | 3 ++ .../voxel/armor/hand/leather_right-0.vox | 3 ++ .../voxygen/voxel/armor/pants/leather-0.vox | 3 ++ .../voxel/armor/shoulder/leather_left-1.vox | 3 ++ .../voxel/armor/shoulder/leather_right-1.vox | 3 ++ .../voxel/humanoid_armor_belt_manifest.ron | 4 +++ .../voxel/humanoid_armor_chest_manifest.ron | 4 +++ .../voxel/humanoid_armor_foot_manifest.ron | 4 +++ .../voxel/humanoid_armor_hand_manifest.ron | 10 +++++++ .../voxel/humanoid_armor_pants_manifest.ron | 4 +++ .../humanoid_armor_shoulder_manifest.ron | 10 +++++++ common/src/comp/body/humanoid.rs | 29 +++++++++++++++---- server/src/sys/terrain.rs | 6 ++-- 23 files changed, 136 insertions(+), 11 deletions(-) create mode 100644 assets/common/items/armor/belt_leather-0.ron create mode 100644 assets/common/items/armor/chest/chest_leather-0.ron create mode 100644 assets/common/items/armor/foot_leather-0.ron create mode 100644 assets/common/items/armor/hand_leather-0.ron rename assets/common/items/armor/{pants_green.ron => pants_green-0.ron} (52%) create mode 100644 assets/common/items/armor/pants_leather-0.ron create mode 100644 assets/common/items/armor/shoulder_leather-1.ron create mode 100644 assets/voxygen/voxel/armor/belt/leather-0.vox create mode 100644 assets/voxygen/voxel/armor/chest/leather-0.vox create mode 100644 assets/voxygen/voxel/armor/foot/leather-0.vox create mode 100644 assets/voxygen/voxel/armor/hand/leather_left-0.vox create mode 100644 assets/voxygen/voxel/armor/hand/leather_right-0.vox create mode 100644 assets/voxygen/voxel/armor/pants/leather-0.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/leather_left-1.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/leather_right-1.vox diff --git a/assets/common/items/armor/belt_leather-0.ron b/assets/common/items/armor/belt_leather-0.ron new file mode 100644 index 0000000000..e69abba663 --- /dev/null +++ b/assets/common/items/armor/belt_leather-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Swift Belt", + description: "", + kind: Armor( + kind: Belt(Leather0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/chest/chest_leather-0.ron b/assets/common/items/armor/chest/chest_leather-0.ron new file mode 100644 index 0000000000..6741474946 --- /dev/null +++ b/assets/common/items/armor/chest/chest_leather-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Swift Chest", + description: "", + kind: Armor( + kind: Chest(Leather0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/foot_leather-0.ron b/assets/common/items/armor/foot_leather-0.ron new file mode 100644 index 0000000000..820516a5ef --- /dev/null +++ b/assets/common/items/armor/foot_leather-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Swift Boots", + description: "", + kind: Armor( + kind: Foot(Leather0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/hand_leather-0.ron b/assets/common/items/armor/hand_leather-0.ron new file mode 100644 index 0000000000..a2b322ba33 --- /dev/null +++ b/assets/common/items/armor/hand_leather-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Swift Gloves", + description: "Only the best for a member of the creed.", + kind: Armor( + kind: Hand(Leather0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/pants_green.ron b/assets/common/items/armor/pants_green-0.ron similarity index 52% rename from assets/common/items/armor/pants_green.ron rename to assets/common/items/armor/pants_green-0.ron index 5963443666..0ef1d3339c 100644 --- a/assets/common/items/armor/pants_green.ron +++ b/assets/common/items/armor/pants_green-0.ron @@ -1,6 +1,6 @@ Item( - name: "Green Camo Pants", - description: "Perfect for hunting.", + name: "Hunting Pants", + description: "", kind: Armor( kind: Pants(Green), stats: 20, diff --git a/assets/common/items/armor/pants_leather-0.ron b/assets/common/items/armor/pants_leather-0.ron new file mode 100644 index 0000000000..301505818b --- /dev/null +++ b/assets/common/items/armor/pants_leather-0.ron @@ -0,0 +1,8 @@ +Item( + name: "Swift Pants", + description: "", + kind: Armor( + kind: Pants(Leather0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/shoulder_leather-1.ron b/assets/common/items/armor/shoulder_leather-1.ron new file mode 100644 index 0000000000..19e15e40d7 --- /dev/null +++ b/assets/common/items/armor/shoulder_leather-1.ron @@ -0,0 +1,8 @@ +Item( + name: "Swift Shoulderpads", + description: "", + kind: Armor( + kind: Shoulder(Leather1), + stats: 20, + ), +) diff --git a/assets/voxygen/voxel/armor/belt/leather-0.vox b/assets/voxygen/voxel/armor/belt/leather-0.vox new file mode 100644 index 0000000000..e9a2e55758 --- /dev/null +++ b/assets/voxygen/voxel/armor/belt/leather-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b2e1e7b2dc1fbf34d262567d38aa55a4e71c690516d4d895a240b47786c709e +size 1472 diff --git a/assets/voxygen/voxel/armor/chest/leather-0.vox b/assets/voxygen/voxel/armor/chest/leather-0.vox new file mode 100644 index 0000000000..0b7da039d2 --- /dev/null +++ b/assets/voxygen/voxel/armor/chest/leather-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:942cd835b41b31f24848381a0e77df29aeb149fd90d6ef6835949964ede8bab7 +size 57211 diff --git a/assets/voxygen/voxel/armor/foot/leather-0.vox b/assets/voxygen/voxel/armor/foot/leather-0.vox new file mode 100644 index 0000000000..1fc89ddb1b --- /dev/null +++ b/assets/voxygen/voxel/armor/foot/leather-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85f32ee87cade27c5f8fe1ad748462f3f13559371bc4bd3cc0c47abbe7756cd1 +size 1480 diff --git a/assets/voxygen/voxel/armor/hand/leather_left-0.vox b/assets/voxygen/voxel/armor/hand/leather_left-0.vox new file mode 100644 index 0000000000..973ca21a3a --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/leather_left-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82d2fa6e7665eaedcf25ad4e3e42f761864535d0dc03d209855fe79bed4fe5d6 +size 1240 diff --git a/assets/voxygen/voxel/armor/hand/leather_right-0.vox b/assets/voxygen/voxel/armor/hand/leather_right-0.vox new file mode 100644 index 0000000000..c25d07754e --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/leather_right-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:694d9318e8ecebe9f8e6036f53c14733f8eeef8bb16746a0eff75425526cd1f3 +size 55723 diff --git a/assets/voxygen/voxel/armor/pants/leather-0.vox b/assets/voxygen/voxel/armor/pants/leather-0.vox new file mode 100644 index 0000000000..330bfe513f --- /dev/null +++ b/assets/voxygen/voxel/armor/pants/leather-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:218415ec556f4b15387ee3000291696de792a0393b037c8347a610810448e3e5 +size 1912 diff --git a/assets/voxygen/voxel/armor/shoulder/leather_left-1.vox b/assets/voxygen/voxel/armor/shoulder/leather_left-1.vox new file mode 100644 index 0000000000..9650993c12 --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/leather_left-1.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:27a5fcdacd90e3e5456d90a2399ed5444f32bf3d7812ffbee4c0433365565946 +size 1472 diff --git a/assets/voxygen/voxel/armor/shoulder/leather_right-1.vox b/assets/voxygen/voxel/armor/shoulder/leather_right-1.vox new file mode 100644 index 0000000000..4dec6634ce --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/leather_right-1.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8146c73f046f71bc9f501f1400ae8e9ee2702b5c746ebce54344b66b4a78255 +size 55955 diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index b0fb98ac76..424821de8e 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -31,5 +31,9 @@ vox_spec: ("armor.belt.plate-0", (-5.0, -3.5, 2.0)), color: None ), + Leather0:( + vox_spec: ("armor.belt.leather-0", (-5.0, -3.5, 2.0)), + color: None + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index b819667456..949b8b91a8 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -39,5 +39,9 @@ vox_spec: ("armor.chest.plate_green-0", (-7.0, -3.5, 2.0)), color: None ), + Leather0: ( + vox_spec: ("armor.chest.leather-0", (-7.0, -3.5, 2.0)), + color: None + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron index b6c74b15a8..dd320b7b84 100644 --- a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron @@ -23,4 +23,8 @@ vox_spec: ("armor.foot.plate-0", (-2.5, -3.5, -9.0)), color: None ), + Leather0: ( + vox_spec: ("armor.foot.leather-0", (-2.5, -3.5, -9.0)), + color: None + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron index 15580d60a3..d94053fea5 100644 --- a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron @@ -39,4 +39,14 @@ color: None ) ), + Leather0: ( + left: ( + vox_spec: ("armor.hand.leather_left-0", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.leather_right-0", (-1.5, -1.5, -7.0)), + color: None + ) + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron index c7f3e79e53..1c28203795 100644 --- a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron @@ -35,4 +35,8 @@ vox_spec: ("armor.pants.plate_green-0", (-5.0, -3.5, 1.0)), color: None ), + Leather0: ( + vox_spec: ("armor.pants.leather-0", (-5.0, -3.5, 1.0)), + color: None + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index b7ecd2fa2f..e76b6e0de1 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -69,5 +69,15 @@ vox_spec: ("armor.shoulder.leather_right-0", (-2.6, -3.5, 1.0)), color: None ) + ), + Leather1: ( + left: ( + vox_spec: ("armor.shoulder.leather_left-1", (-3.6, -4.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.leather_right-1", (-2.6, -4.5, 1.0)), + color: None + ) ), }) diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index db884575b1..12d83b9394 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -484,8 +484,9 @@ pub enum Chest { Kimono = 7, Assassin = 8, PlateGreen0 = 9, + Leather0 = 10, } -pub const ALL_CHESTS: [Chest; 10] = [ +pub const ALL_CHESTS: [Chest; 11] = [ Chest::None, Chest::Blue, Chest::Brown, @@ -496,6 +497,7 @@ pub const ALL_CHESTS: [Chest; 10] = [ Chest::Kimono, Chest::Assassin, Chest::PlateGreen0, + Chest::Leather0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -508,8 +510,9 @@ pub enum Belt { BlackCloth = 4, Assassin = 5, Plate0 = 6, + Leather0 = 7, } -pub const ALL_BELTS: [Belt; 7] = [ +pub const ALL_BELTS: [Belt; 8] = [ Belt::None, Belt::Dark, Belt::TurqCloth, @@ -517,6 +520,7 @@ pub const ALL_BELTS: [Belt; 7] = [ Belt::BlackCloth, Belt::Assassin, Belt::Plate0, + Belt::Leather0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -531,8 +535,9 @@ pub enum Pants { Kimono = 6, Assassin = 7, PlateGreen0 = 8, + Leather0 = 9, } -pub const ALL_PANTS: [Pants; 9] = [ +pub const ALL_PANTS: [Pants; 10] = [ Pants::None, Pants::Blue, Pants::Brown, @@ -542,6 +547,7 @@ pub const ALL_PANTS: [Pants; 9] = [ Pants::Kimono, Pants::Assassin, Pants::PlateGreen0, + Pants::Leather0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -551,8 +557,15 @@ pub enum Hand { Cloth = 1, Assassin = 2, Plate0 = 3, + Leather0 = 4, } -pub const ALL_HANDS: [Hand; 4] = [Hand::Bare, Hand::Cloth, Hand::Assassin, Hand::Plate0]; +pub const ALL_HANDS: [Hand; 5] = [ + Hand::Bare, + Hand::Cloth, + Hand::Assassin, + Hand::Plate0, + Hand::Leather0, +]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] @@ -563,14 +576,16 @@ pub enum Foot { Jester = 3, Assassin = 4, Plate0 = 5, + Leather0 = 6, } -pub const ALL_FEET: [Foot; 6] = [ +pub const ALL_FEET: [Foot; 7] = [ Foot::Bare, Foot::Dark, Foot::Sandal, Foot::Jester, Foot::Assassin, Foot::Plate0, + Foot::Leather0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -582,14 +597,16 @@ pub enum Shoulder { Assassin = 3, Plate0 = 4, Leather0 = 5, + Leather1 = 6, } -pub const ALL_SHOULDERS: [Shoulder; 6] = [ +pub const ALL_SHOULDERS: [Shoulder; 7] = [ Shoulder::None, Shoulder::Brown1, Shoulder::Chain, Shoulder::Assassin, Shoulder::Plate0, Shoulder::Leather0, + Shoulder::Leather1, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index caa2087057..d7681616b8 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -218,10 +218,10 @@ impl<'a> System<'a> for Sys { active_item, second_item: None, shoulder: Some(assets::load_expect_cloned( - "common.items.armor.shoulder_plate-0", + "common.items.armor.shoulder_leather-0", )), chest: Some(assets::load_expect_cloned( - "common.items.armor.chest.chest_plate_green-0", + "common.items.armor.chest.chest_leather-0", )), belt: Some(assets::load_expect_cloned( "common.items.armor.belt_plate-0", @@ -233,7 +233,7 @@ impl<'a> System<'a> for Sys { "common.items.armor.pants_plate_green-0", )), foot: Some(assets::load_expect_cloned( - "common.items.armor.foot_plate-0", + "common.items.armor.foot_leather-0", )), }, comp::Alignment::Enemy => comp::Loadout { From 449ae227303b4b536f2f64e3f9db63334ac88fcf Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 19 Mar 2020 14:30:50 +0100 Subject: [PATCH 146/326] Add inventory stacking --- common/src/comp/inventory/item.rs | 12 ++- common/src/comp/inventory/mod.rs | 151 ++++++++++++++++++++++++++- server/src/events/inventory_manip.rs | 6 +- voxygen/src/hud/item_imgs.rs | 4 +- 4 files changed, 166 insertions(+), 7 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index d4e7c7ff4b..b65a8d2adb 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -194,6 +194,8 @@ pub struct ToolData { // TODO: item specific abilities } +fn default_amount() -> u32 { 1 } + #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ItemKind { /// Something wieldable @@ -205,11 +207,19 @@ pub enum ItemKind { Consumable { kind: Consumable, effect: Effect, + #[serde(skip, default = "default_amount")] + amount: u32, }, Utility { kind: Utility, + #[serde(skip, default = "default_amount")] + amount: u32, + }, + Ingredient { + kind: Ingredient, + #[serde(skip, default = "default_amount")] + amount: u32, }, - Ingredient(Ingredient), } #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 78e818affb..5a724fff05 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -29,9 +29,105 @@ impl Inventory { pub fn len(&self) -> usize { self.slots.len() } + /// Adds a new item to the first fitting group of the inventory or starts a + /// new group. Returns the item again if no space was found. + pub fn push(&mut self, item: Item) -> Option { + match item.kind { + ItemKind::Tool(_) | ItemKind::Armor { .. } => self.add_to_first_empty(item), + ItemKind::Utility { + kind: item_kind, + amount: new_amount, + } => { + for slot in &mut self.slots { + if slot + .as_ref() + .map(|s| s.name() == item.name()) + .unwrap_or(false) + && slot + .as_ref() + .map(|s| s.description() == item.description()) + .unwrap_or(false) + { + if let Some(Item { + kind: ItemKind::Utility { kind, amount }, + .. + }) = slot + { + if item_kind == *kind { + *amount += new_amount; + return None; + } + } + } + } + // It didn't work + self.add_to_first_empty(item) + }, + ItemKind::Consumable { + kind: item_kind, + amount: new_amount, + .. + } => { + for slot in &mut self.slots { + if slot + .as_ref() + .map(|s| s.name() == item.name()) + .unwrap_or(false) + && slot + .as_ref() + .map(|s| s.description() == item.description()) + .unwrap_or(false) + { + if let Some(Item { + kind: ItemKind::Consumable { kind, amount, .. }, + .. + }) = slot + { + if item_kind == *kind { + *amount += new_amount; + return None; + } + } + } + } + // It didn't work + self.add_to_first_empty(item) + }, + ItemKind::Ingredient { + kind: item_kind, + amount: new_amount, + } => { + for slot in &mut self.slots { + if slot + .as_ref() + .map(|s| s.name() == item.name()) + .unwrap_or(false) + && slot + .as_ref() + .map(|s| s.description() == item.description()) + .unwrap_or(false) + { + if let Some(Item { + kind: ItemKind::Ingredient { kind, amount }, + .. + }) = slot + { + if item_kind == *kind { + *amount += new_amount; + return None; + } + } + } + } + // It didn't work + self.add_to_first_empty(item) + }, + } + } + /// Adds a new item to the first empty slot of the inventory. Returns the /// item again if no free slot was found. - pub fn push(&mut self, item: Item) -> Option { + fn add_to_first_empty(&mut self, item: Item) -> Option { match self.slots.iter_mut().find(|slot| slot.is_none()) { Some(slot) => { *slot = Some(item); @@ -123,6 +219,59 @@ impl Inventory { pub fn remove(&mut self, cell: usize) -> Option { self.slots.get_mut(cell).and_then(|item| item.take()) } + + /// Remove just one item from the slot + pub fn take(&mut self, cell: usize) -> Option { + if let Some(Some(item)) = self.slots.get_mut(cell) { + let mut return_item = item.clone(); + match &mut item.kind { + ItemKind::Tool(_) | ItemKind::Armor { .. } => self.remove(cell), + ItemKind::Utility { kind, amount } => { + if *amount <= 1 { + self.remove(cell) + } else { + *amount -= 1; + return_item.kind = ItemKind::Utility { + kind: *kind, + amount: 1, + }; + Some(return_item) + } + }, + ItemKind::Consumable { + kind, + amount, + effect, + } => { + if *amount <= 1 { + self.remove(cell) + } else { + *amount -= 1; + return_item.kind = ItemKind::Consumable { + kind: *kind, + effect: *effect, + amount: 1, + }; + Some(return_item) + } + }, + ItemKind::Ingredient { kind, amount } => { + if *amount <= 1 { + self.remove(cell) + } else { + *amount -= 1; + return_item.kind = ItemKind::Ingredient { + kind: *kind, + amount: 1, + }; + Some(return_item) + } + }, + } + } else { + None + } + } } impl Default for Inventory { diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index 7ac4795e93..2bf1fa0e6f 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -88,7 +88,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv .ecs() .write_storage::() .get_mut(entity) - .and_then(|inv| inv.remove(slot_idx)); + .and_then(|inv| inv.take(slot_idx)); let mut event = comp::InventoryUpdateEvent::Used; @@ -120,7 +120,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv } }, - comp::ItemKind::Consumable { kind, effect } => { + comp::ItemKind::Consumable { kind, effect, .. } => { event = comp::InventoryUpdateEvent::Consumed(*kind); state.apply_effect(entity, *effect); }, @@ -152,7 +152,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv } }, - comp::ItemKind::Utility { kind } => match kind { + comp::ItemKind::Utility { kind, .. } => match kind { comp::item::Utility::Collar => { let reinsert = if let Some(pos) = state.read_storage::().get(entity) diff --git a/voxygen/src/hud/item_imgs.rs b/voxygen/src/hud/item_imgs.rs index 863a5b4e8c..3344633615 100644 --- a/voxygen/src/hud/item_imgs.rs +++ b/voxygen/src/hud/item_imgs.rs @@ -26,9 +26,9 @@ impl From<&Item> for ItemKey { match &item.kind { ItemKind::Tool(ToolData { kind, .. }) => ItemKey::Tool(kind.clone()), ItemKind::Armor { kind, .. } => ItemKey::Armor(kind.clone()), - ItemKind::Utility { kind } => ItemKey::Utility(kind.clone()), + ItemKind::Utility { kind, .. } => ItemKey::Utility(kind.clone()), ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()), - ItemKind::Ingredient(kind) => ItemKey::Ingredient(kind.clone()), + ItemKind::Ingredient { kind, .. } => ItemKey::Ingredient(kind.clone()), } } } From 041277917b94669573527e2dccac5f3990bb31a0 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 19 Mar 2020 15:49:32 +0100 Subject: [PATCH 147/326] Update bag.rs --- voxygen/src/hud/bag.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 671c19b758..816d242e02 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -8,7 +8,7 @@ use crate::{ ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, }; use client::Client; -use common::comp::Stats; +use common::comp::{item, ItemKind, Stats}; use conrod_core::{ color, image, widget::{self, Button, Image, Rectangle, Text}, @@ -645,6 +645,17 @@ impl<'a> Widget for Bag<'a> { } // Item if let Some(kind) = item.as_ref().map(|i| ItemKey::from(i)) { + //Stack Size + /*if let Some(item) = item { + if let Some(amount) = match item.kind { + ItemKind::Tool { .. } | ItemKind::Armor { .. } => None, + ItemKind::Utility { amount, .. } + | ItemKind::Consumable { amount, .. } + | ItemKind::Ingredient { amount, .. } => Some(amount), + } { + println!("Amount: {}", amount); + } + }*/ Button::image(match &state.img_id_cache[i] { Some((cached_kind, id)) if cached_kind == &kind => *id, _ => { From 0bb0d5e7a6a8729b0a08711345a1fe7c91a296dd Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 19 Mar 2020 16:43:11 +0100 Subject: [PATCH 148/326] Update bag.rs --- voxygen/src/hud/bag.rs | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 816d242e02..1972b75f4d 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -27,6 +27,8 @@ widget_ids! { map_title, inv_slots[], items[], + amounts[], + amounts_bg[], tooltip[], bg, bg_frame, @@ -646,16 +648,6 @@ impl<'a> Widget for Bag<'a> { // Item if let Some(kind) = item.as_ref().map(|i| ItemKey::from(i)) { //Stack Size - /*if let Some(item) = item { - if let Some(amount) = match item.kind { - ItemKind::Tool { .. } | ItemKind::Armor { .. } => None, - ItemKind::Utility { amount, .. } - | ItemKind::Consumable { amount, .. } - | ItemKind::Ingredient { amount, .. } => Some(amount), - } { - println!("Amount: {}", amount); - } - }*/ Button::image(match &state.img_id_cache[i] { Some((cached_kind, id)) if cached_kind == &kind => *id, _ => { @@ -672,6 +664,32 @@ impl<'a> Widget for Bag<'a> { .graphics_for(state.ids.inv_slots[i]) .set(state.ids.items[i], ui); } + if let Some(item) = item { + if let Some(amount) = match item.kind { + ItemKind::Tool { .. } | ItemKind::Armor { .. } => None, + ItemKind::Utility { amount, .. } + | ItemKind::Consumable { amount, .. } + | ItemKind::Ingredient { amount, .. } => Some(amount), + } { + if amount > 0 { + // TODO This should be > 1 + Text::new(&format!("{}", &amount)) + .top_right_with_margins_on(state.ids.items[i], 10.0, 10.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(10)) + .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) + .floating(true) + .set(state.ids.amounts_bg[i], ui); + Text::new(&format!("{}", &amount)) + .top_right_with_margins_on(state.ids.inventory_title_bg, 2.0, 2.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(10)) + .color(TEXT_COLOR) + .floating(true) + .set(state.ids.amounts[i], ui); + } + } + } } // Drop selected item From 6c129c9b8d3c44e57f4741b3a00ef8b17b6a6c61 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 19 Mar 2020 16:51:50 +0100 Subject: [PATCH 149/326] Fix amounts out of range --- voxygen/src/hud/bag.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 1972b75f4d..eb1d08ec3d 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -583,6 +583,20 @@ impl<'a> Widget for Bag<'a> { .resize(inventory.len(), &mut ui.widget_id_generator()); }); } + if state.ids.amounts.len() < inventory.len() { + state.update(|s| { + s.ids + .amounts + .resize(inventory.len(), &mut ui.widget_id_generator()); + }); + } + if state.ids.amounts_bg.len() < inventory.len() { + state.update(|s| { + s.ids + .amounts_bg + .resize(inventory.len(), &mut ui.widget_id_generator()); + }); + } // Expand img id cache to the number of slots if state.img_id_cache.len() < inventory.len() { state.update(|s| { From 22652cfa37320946dafc7aeaa136ae233270c312 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 19 Mar 2020 17:01:58 +0100 Subject: [PATCH 150/326] Restore old boost stick behavior --- common/src/comp/inventory/item.rs | 4 ++-- common/src/states/boost.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index b65a8d2adb..0b5eb75450 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -122,11 +122,11 @@ impl ToolData { Debug(kind) => match kind { DebugKind::Boost => vec![ CharacterAbility::Boost { - duration: Duration::from_millis(100), + duration: Duration::from_millis(50), only_up: false, }, CharacterAbility::Boost { - duration: Duration::from_millis(100), + duration: Duration::from_millis(50), only_up: true, }, ], diff --git a/common/src/states/boost.rs b/common/src/states/boost.rs index 7acfd6bc80..7b060ed9cf 100644 --- a/common/src/states/boost.rs +++ b/common/src/states/boost.rs @@ -29,9 +29,9 @@ impl CharacterBehavior for Data { // Still going if self.duration != Duration::default() { if self.only_up { - update.vel.0.z = 30.0; + update.vel.0.z += 500.0 * data.dt.0; } else { - update.vel.0 = data.inputs.look_dir * 30.0; + update.vel.0 += data.inputs.look_dir * 500.0 * data.dt.0; } update.character = CharacterState::Boost(Data { duration: self From bb1b3ceabce9a3c003cbe0cf9d075a55c8d2744f Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 19 Mar 2020 17:44:13 +0100 Subject: [PATCH 151/326] Fix syncing amount --- common/src/comp/inventory/item.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 0b5eb75450..00c35348e3 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -207,17 +207,17 @@ pub enum ItemKind { Consumable { kind: Consumable, effect: Effect, - #[serde(skip, default = "default_amount")] + #[serde(default = "default_amount")] amount: u32, }, Utility { kind: Utility, - #[serde(skip, default = "default_amount")] + #[serde(default = "default_amount")] amount: u32, }, Ingredient { kind: Ingredient, - #[serde(skip, default = "default_amount")] + #[serde(default = "default_amount")] amount: u32, }, } From 49b0af10a9a8000300cc1eb1d5a864223f92e1d6 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 19 Mar 2020 17:47:37 +0100 Subject: [PATCH 152/326] Regular naming scheme for armor assets --- .../{belt_assassin.ron => belt/assassin.ron} | 0 .../leather_0.ron} | 0 .../{belt_plate-0.ron => belt/plate_0.ron} | 0 .../{chest_assassin.ron => assassin.ron} | 0 .../{chest_leather-0.ron => leather_0.ron} | 0 ...st_plate_green-0.ron => plate_green_0.ron} | 0 .../{foot_assassin.ron => foot/assassin.ron} | 0 .../leather_0.ron} | 0 .../{foot_plate-0.ron => foot/plate_0.ron} | 0 .../{hand_assassin.ron => hand/assassin.ron} | 0 .../leather_0.ron} | 0 .../{hand_plate-0.ron => hand/plate_0.ron} | 0 .../assassin.ron} | 0 .../{pants_green-0.ron => pants/green_0.ron} | 0 .../leather_0.ron} | 0 .../plate_green_0.ron} | 0 .../assassin.ron} | 0 .../leather_0.ron} | 0 .../leather_1.ron} | 0 .../plate_0.ron} | 0 server/src/sys/terrain.rs | 36 +++++++++---------- 21 files changed, 18 insertions(+), 18 deletions(-) rename assets/common/items/armor/{belt_assassin.ron => belt/assassin.ron} (100%) rename assets/common/items/armor/{belt_leather-0.ron => belt/leather_0.ron} (100%) rename assets/common/items/armor/{belt_plate-0.ron => belt/plate_0.ron} (100%) rename assets/common/items/armor/chest/{chest_assassin.ron => assassin.ron} (100%) rename assets/common/items/armor/chest/{chest_leather-0.ron => leather_0.ron} (100%) rename assets/common/items/armor/chest/{chest_plate_green-0.ron => plate_green_0.ron} (100%) rename assets/common/items/armor/{foot_assassin.ron => foot/assassin.ron} (100%) rename assets/common/items/armor/{foot_leather-0.ron => foot/leather_0.ron} (100%) rename assets/common/items/armor/{foot_plate-0.ron => foot/plate_0.ron} (100%) rename assets/common/items/armor/{hand_assassin.ron => hand/assassin.ron} (100%) rename assets/common/items/armor/{hand_leather-0.ron => hand/leather_0.ron} (100%) rename assets/common/items/armor/{hand_plate-0.ron => hand/plate_0.ron} (100%) rename assets/common/items/armor/{pants_assassin.ron => pants/assassin.ron} (100%) rename assets/common/items/armor/{pants_green-0.ron => pants/green_0.ron} (100%) rename assets/common/items/armor/{pants_leather-0.ron => pants/leather_0.ron} (100%) rename assets/common/items/armor/{pants_plate_green-0.ron => pants/plate_green_0.ron} (100%) rename assets/common/items/armor/{shoulder_assassin.ron => shoulder/assassin.ron} (100%) rename assets/common/items/armor/{shoulder_leather-0.ron => shoulder/leather_0.ron} (100%) rename assets/common/items/armor/{shoulder_leather-1.ron => shoulder/leather_1.ron} (100%) rename assets/common/items/armor/{shoulder_plate-0.ron => shoulder/plate_0.ron} (100%) diff --git a/assets/common/items/armor/belt_assassin.ron b/assets/common/items/armor/belt/assassin.ron similarity index 100% rename from assets/common/items/armor/belt_assassin.ron rename to assets/common/items/armor/belt/assassin.ron diff --git a/assets/common/items/armor/belt_leather-0.ron b/assets/common/items/armor/belt/leather_0.ron similarity index 100% rename from assets/common/items/armor/belt_leather-0.ron rename to assets/common/items/armor/belt/leather_0.ron diff --git a/assets/common/items/armor/belt_plate-0.ron b/assets/common/items/armor/belt/plate_0.ron similarity index 100% rename from assets/common/items/armor/belt_plate-0.ron rename to assets/common/items/armor/belt/plate_0.ron diff --git a/assets/common/items/armor/chest/chest_assassin.ron b/assets/common/items/armor/chest/assassin.ron similarity index 100% rename from assets/common/items/armor/chest/chest_assassin.ron rename to assets/common/items/armor/chest/assassin.ron diff --git a/assets/common/items/armor/chest/chest_leather-0.ron b/assets/common/items/armor/chest/leather_0.ron similarity index 100% rename from assets/common/items/armor/chest/chest_leather-0.ron rename to assets/common/items/armor/chest/leather_0.ron diff --git a/assets/common/items/armor/chest/chest_plate_green-0.ron b/assets/common/items/armor/chest/plate_green_0.ron similarity index 100% rename from assets/common/items/armor/chest/chest_plate_green-0.ron rename to assets/common/items/armor/chest/plate_green_0.ron diff --git a/assets/common/items/armor/foot_assassin.ron b/assets/common/items/armor/foot/assassin.ron similarity index 100% rename from assets/common/items/armor/foot_assassin.ron rename to assets/common/items/armor/foot/assassin.ron diff --git a/assets/common/items/armor/foot_leather-0.ron b/assets/common/items/armor/foot/leather_0.ron similarity index 100% rename from assets/common/items/armor/foot_leather-0.ron rename to assets/common/items/armor/foot/leather_0.ron diff --git a/assets/common/items/armor/foot_plate-0.ron b/assets/common/items/armor/foot/plate_0.ron similarity index 100% rename from assets/common/items/armor/foot_plate-0.ron rename to assets/common/items/armor/foot/plate_0.ron diff --git a/assets/common/items/armor/hand_assassin.ron b/assets/common/items/armor/hand/assassin.ron similarity index 100% rename from assets/common/items/armor/hand_assassin.ron rename to assets/common/items/armor/hand/assassin.ron diff --git a/assets/common/items/armor/hand_leather-0.ron b/assets/common/items/armor/hand/leather_0.ron similarity index 100% rename from assets/common/items/armor/hand_leather-0.ron rename to assets/common/items/armor/hand/leather_0.ron diff --git a/assets/common/items/armor/hand_plate-0.ron b/assets/common/items/armor/hand/plate_0.ron similarity index 100% rename from assets/common/items/armor/hand_plate-0.ron rename to assets/common/items/armor/hand/plate_0.ron diff --git a/assets/common/items/armor/pants_assassin.ron b/assets/common/items/armor/pants/assassin.ron similarity index 100% rename from assets/common/items/armor/pants_assassin.ron rename to assets/common/items/armor/pants/assassin.ron diff --git a/assets/common/items/armor/pants_green-0.ron b/assets/common/items/armor/pants/green_0.ron similarity index 100% rename from assets/common/items/armor/pants_green-0.ron rename to assets/common/items/armor/pants/green_0.ron diff --git a/assets/common/items/armor/pants_leather-0.ron b/assets/common/items/armor/pants/leather_0.ron similarity index 100% rename from assets/common/items/armor/pants_leather-0.ron rename to assets/common/items/armor/pants/leather_0.ron diff --git a/assets/common/items/armor/pants_plate_green-0.ron b/assets/common/items/armor/pants/plate_green_0.ron similarity index 100% rename from assets/common/items/armor/pants_plate_green-0.ron rename to assets/common/items/armor/pants/plate_green_0.ron diff --git a/assets/common/items/armor/shoulder_assassin.ron b/assets/common/items/armor/shoulder/assassin.ron similarity index 100% rename from assets/common/items/armor/shoulder_assassin.ron rename to assets/common/items/armor/shoulder/assassin.ron diff --git a/assets/common/items/armor/shoulder_leather-0.ron b/assets/common/items/armor/shoulder/leather_0.ron similarity index 100% rename from assets/common/items/armor/shoulder_leather-0.ron rename to assets/common/items/armor/shoulder/leather_0.ron diff --git a/assets/common/items/armor/shoulder_leather-1.ron b/assets/common/items/armor/shoulder/leather_1.ron similarity index 100% rename from assets/common/items/armor/shoulder_leather-1.ron rename to assets/common/items/armor/shoulder/leather_1.ron diff --git a/assets/common/items/armor/shoulder_plate-0.ron b/assets/common/items/armor/shoulder/plate_0.ron similarity index 100% rename from assets/common/items/armor/shoulder_plate-0.ron rename to assets/common/items/armor/shoulder/plate_0.ron diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index d7681616b8..0265f63311 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -218,44 +218,44 @@ impl<'a> System<'a> for Sys { active_item, second_item: None, shoulder: Some(assets::load_expect_cloned( - "common.items.armor.shoulder_leather-0", + "common.items.armor.shoulder.leather_0", )), chest: Some(assets::load_expect_cloned( - "common.items.armor.chest.chest_leather-0", + "common.items.armor.chest.leather_0", )), belt: Some(assets::load_expect_cloned( - "common.items.armor.belt_plate-0", + "common.items.armor.belt.plate_0", )), hand: Some(assets::load_expect_cloned( - "common.items.armor.hand_plate-0", + "common.items.armor.hand.plate_0", )), pants: Some(assets::load_expect_cloned( - "common.items.armor.pants_plate_green-0", + "common.items.armor.pants.plate_green_0", )), foot: Some(assets::load_expect_cloned( - "common.items.armor.foot_leather-0", + "common.items.armor.foot.leather_0", )), }, comp::Alignment::Enemy => comp::Loadout { active_item, second_item: None, shoulder: Some(assets::load_expect_cloned( - "common.items.armor.shoulder_leather-0", + "common.items.armor.shoulder.leather_0", )), chest: Some(assets::load_expect_cloned( - "common.items.armor.chest.chest_plate_green-0", + "common.items.armor.chest.plate_green_0", )), belt: Some(assets::load_expect_cloned( - "common.items.armor.belt_plate-0", + "common.items.armor.belt.plate_0", )), hand: Some(assets::load_expect_cloned( - "common.items.armor.hand_plate-0", + "common.items.armor.hand.plate_0", )), pants: Some(assets::load_expect_cloned( - "common.items.armor.pants_plate_green-0", + "common.items.armor.pants.plate_green_0", )), foot: Some(assets::load_expect_cloned( - "common.items.armor.foot_plate-0", + "common.items.armor.foot.plate_0", )), }, _ => comp::Loadout { @@ -306,22 +306,22 @@ impl<'a> System<'a> for Sys { }), second_item: None, shoulder: Some(assets::load_expect_cloned( - "common.items.armor.shoulder_plate-0", + "common.items.armor.shoulder.plate_0", )), chest: Some(assets::load_expect_cloned( - "common.items.armor.chest.chest_plate_green-0", + "common.items.armor.chest.plate_green_0", )), belt: Some(assets::load_expect_cloned( - "common.items.armor.belt_plate-0", + "common.items.armor.belt.plate_0", )), hand: Some(assets::load_expect_cloned( - "common.items.armor.hand_plate-0", + "common.items.armor.hand.plate_0", )), pants: Some(assets::load_expect_cloned( - "common.items.armor.pants_plate_green-0", + "common.items.armor.pants.plate_green_0", )), foot: Some(assets::load_expect_cloned( - "common.items.armor.foot_plate-0", + "common.items.armor.foot.plate_0", )), }; From 466b80e8a821f291504ed1009b2eb786de87269c Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 19 Mar 2020 18:11:45 +0100 Subject: [PATCH 153/326] added const tweaker --- Cargo.lock | 635 +++++++++++++++++++++++++++++++++++++++-- voxygen/Cargo.toml | 2 + voxygen/src/hud/bag.rs | 16 +- voxygen/src/main.rs | 2 + 4 files changed, 627 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22b3939864..7069f42f18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,6 +15,15 @@ dependencies = [ "const-random", ] +[[package]] +name = "ahash" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0989268a37e128d4d7a8028f1c60099430113fdbc70419010601ce51a228e4fe" +dependencies = [ + "const-random", +] + [[package]] name = "aho-corasick" version = "0.7.10" @@ -54,6 +63,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" +[[package]] +name = "anyhow" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "013a6e0a2cbe3d20f9c60b65458f7a7f7a5e636c5d0f45a5a6aee5d4b1f01785" + [[package]] name = "anymap" version = "0.12.1" @@ -123,6 +138,42 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97be891acc47ca214468e09425d02cef3af2c94d0d82081cd02061f996802f14" +[[package]] +name = "async-std" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "538ecb01eb64eecd772087e5b6f7540cbc917f047727339a472dafed2185b267" +dependencies = [ + "async-task", + "broadcaster", + "crossbeam-channel 0.4.2", + "crossbeam-deque", + "crossbeam-utils 0.7.2", + "futures-core", + "futures-io", + "futures-timer", + "kv-log-macro", + "log 0.4.8", + "memchr", + "mio", + "mio-uds", + "num_cpus", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "async-task" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ac2c016b079e771204030951c366db398864f5026f84a44dafb0ff20f02085d" +dependencies = [ + "libc", + "winapi 0.3.8", +] + [[package]] name = "atk-sys" version = "0.6.0" @@ -301,6 +352,20 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" +[[package]] +name = "broadcaster" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c972e21e0d055a36cf73e4daae870941fe7a8abcd5ac3396aab9e4c126bd87" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "futures-util", + "parking_lot 0.10.0", + "slab", +] + [[package]] name = "brotli-sys" version = "0.3.2" @@ -361,6 +426,17 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder 1.3.4", + "either", + "iovec", +] + [[package]] name = "bytes" version = "0.5.4" @@ -604,12 +680,50 @@ dependencies = [ "proc-macro-hack", ] +[[package]] +name = "const-tweaker" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe948a728bf50e79be7b41b197587318fbc17da0106e5d0f435e3a6b2b42226" +dependencies = [ + "anyhow", + "async-std", + "const-tweaker-attribute", + "dashmap", + "horrorshow", + "lazy_static", + "serde", + "tide", +] + +[[package]] +name = "const-tweaker-attribute" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c22ff357be06ddb217d230a62c3f3ed8ebd305e87df53789d27450f48c40f6a" +dependencies = [ + "darling", + "proc-macro2 1.0.9", + "quote 1.0.3", + "syn 1.0.16", +] + [[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "cookie" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5" +dependencies = [ + "time", + "url 1.7.2", +] + [[package]] name = "copypasta" version = "0.6.3" @@ -902,6 +1016,58 @@ dependencies = [ "petgraph", ] +[[package]] +name = "darling" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2 1.0.9", + "quote 1.0.3", + "strsim", + "syn 1.0.16", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote 1.0.3", + "syn 1.0.16", +] + +[[package]] +name = "dashmap" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010ef3f25ed5bb93505a3238d19957622190268640526aab07174c66ccf5d611" +dependencies = [ + "ahash 0.3.2", + "cfg-if", + "num_cpus", +] + +[[package]] +name = "data-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11c0346158a19b3627234e15596f5e465c360fcdb97d817bcb255e0510f5a788" + [[package]] name = "deflate" version = "0.7.20" @@ -1045,6 +1211,16 @@ dependencies = [ "termcolor", ] +[[package]] +name = "error-chain" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" +dependencies = [ + "backtrace", + "version_check 0.9.1", +] + [[package]] name = "euc" version = "0.3.0" @@ -1194,6 +1370,27 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +[[package]] +name = "futures" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" + +[[package]] +name = "futures" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.4" @@ -1201,6 +1398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -1209,6 +1407,27 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" +[[package]] +name = "futures-cpupool" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" +dependencies = [ + "futures 0.1.29", + "num_cpus", +] + +[[package]] +name = "futures-executor" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.4" @@ -1239,21 +1458,31 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" +[[package]] +name = "futures-timer" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" + [[package]] name = "futures-util" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" dependencies = [ + "futures 0.1.29", + "futures-channel", "futures-core", "futures-io", "futures-macro", + "futures-sink", "futures-task", "memchr", "pin-utils", "proc-macro-hack", "proc-macro-nested", "slab", + "tokio-io", ] [[package]] @@ -1697,22 +1926,40 @@ dependencies = [ "crc32fast", ] +[[package]] +name = "h2" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" +dependencies = [ + "byteorder 1.3.4", + "bytes 0.4.12", + "fnv", + "futures 0.1.29", + "http 0.1.21", + "indexmap", + "log 0.4.8", + "slab", + "string", + "tokio-io", +] + [[package]] name = "h2" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5c295d1c0c68e4e42003d75f908f5e16a1edd1cbe0b0d02e4dc2006a384f47" dependencies = [ - "bytes", + "bytes 0.5.4", "fnv", "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.0", "indexmap", "log 0.4.8", "slab", - "tokio", + "tokio 0.2.13", "tokio-util", ] @@ -1722,7 +1969,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" dependencies = [ - "ahash", + "ahash 0.2.18", "autocfg 0.1.7", "rayon", "serde", @@ -1753,31 +2000,85 @@ dependencies = [ "rayon", ] +[[package]] +name = "horrorshow" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad517632123d9c856735b04b02031b04dfb5ab1e69695bcfb96dee5e8804f0df" + [[package]] name = "hound" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a164bb2ceaeff4f42542bdb847c41517c78a60f5649671b2a07312b6e117549" +[[package]] +name = "http" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" +dependencies = [ + "bytes 0.4.12", + "fnv", + "itoa", +] + [[package]] name = "http" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b" dependencies = [ - "bytes", + "bytes 0.5.4", "fnv", "itoa", ] +[[package]] +name = "http-body" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "http 0.1.21", + "tokio-buf", +] + [[package]] name = "http-body" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" dependencies = [ - "bytes", - "http", + "bytes 0.5.4", + "http 0.2.0", +] + +[[package]] +name = "http-service" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9625f605ddfaf894bf78a544a7b8e31f562dc843654723a49892d9c7e75ac708" +dependencies = [ + "async-std", + "bytes 0.4.12", + "futures 0.3.4", + "http 0.1.21", + "pin-project-lite", +] + +[[package]] +name = "http-service-hyper" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33d5dae94e0fdb82f9524ea2f2b98458b3d8448526d8cc8beccb3d3fded8aff" +dependencies = [ + "futures 0.3.4", + "http 0.1.21", + "http-service", + "hyper 0.12.35", ] [[package]] @@ -1795,28 +2096,58 @@ dependencies = [ "quick-error", ] +[[package]] +name = "hyper" +version = "0.12.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "futures-cpupool", + "h2 0.1.26", + "http 0.1.21", + "http-body 0.1.0", + "httparse", + "iovec", + "itoa", + "log 0.4.8", + "net2", + "rustc_version", + "time", + "tokio 0.1.22", + "tokio-buf", + "tokio-executor", + "tokio-io", + "tokio-reactor", + "tokio-tcp", + "tokio-threadpool", + "tokio-timer", + "want 0.2.0", +] + [[package]] name = "hyper" version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7b15203263d1faa615f9337d79c1d37959439dc46c2b4faab33286fadc2a1c5" dependencies = [ - "bytes", + "bytes 0.5.4", "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.2.2", + "http 0.2.0", + "http-body 0.3.1", "httparse", "itoa", "log 0.4.8", "net2", "pin-project", "time", - "tokio", + "tokio 0.2.13", "tower-service", - "want", + "want 0.3.0", ] [[package]] @@ -1825,18 +2156,24 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac965ea399ec3a25ac7d13b8affd4b8f39325cca00858ddf5eb29b79e6b14b08" dependencies = [ - "bytes", + "bytes 0.5.4", "ct-logs", "futures-util", - "hyper", + "hyper 0.13.3", "log 0.4.8", "rustls", "rustls-native-certs", - "tokio", + "tokio 0.2.13", "tokio-rustls", "webpki", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.1.5" @@ -1998,6 +2335,15 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" +[[package]] +name = "kv-log-macro" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c54d9f465d530a752e6ebdc217e081a7a614b48cb200f6f0aee21ba6bc9aabb" +dependencies = [ + "log 0.4.8", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -2283,6 +2629,17 @@ dependencies = [ "slab", ] +[[package]] +name = "mio-uds" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" +dependencies = [ + "iovec", + "libc", + "mio", +] + [[package]] name = "miow" version = "0.2.1" @@ -2579,6 +2936,12 @@ dependencies = [ "byteorder 1.3.4", ] +[[package]] +name = "once_cell" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b" + [[package]] name = "oorandom" version = "11.1.0" @@ -2698,6 +3061,16 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "parking_lot" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" +dependencies = [ + "lock_api", + "parking_lot_core 0.7.0", +] + [[package]] name = "parking_lot_core" version = "0.2.14" @@ -2725,6 +3098,20 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "parking_lot_core" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "smallvec 1.2.0", + "winapi 0.3.8", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -3299,13 +3686,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02b81e49ddec5109a9dcfc5f2a317ff53377c915e9ae9d4f2fb50914b85614e2" dependencies = [ "base64 0.11.0", - "bytes", + "bytes 0.5.4", "encoding_rs", "futures-core", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.0", + "http-body 0.3.1", + "hyper 0.13.3", "hyper-rustls", "js-sys", "lazy_static", @@ -3318,7 +3705,7 @@ dependencies = [ "serde", "serde_urlencoded", "time", - "tokio", + "tokio 0.2.13", "tokio-rustls", "url 2.1.1", "wasm-bindgen", @@ -3397,6 +3784,12 @@ dependencies = [ "url 1.7.2", ] +[[package]] +name = "route-recognizer" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea509065eb0b3c446acdd0102f0d46567dc30902dc0be91d6552035d92b0f4f8" + [[package]] name = "rust-argon2" version = "0.6.1" @@ -3658,6 +4051,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_qs" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43eef44996bbe16e99ac720e1577eefa16f7b76b5172165c98ced20ae9903e1" +dependencies = [ + "data-encoding", + "error-chain", + "percent-encoding 1.0.1", + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.6.1" @@ -3903,6 +4308,21 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" +[[package]] +name = "string" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" +dependencies = [ + "bytes 0.4.12", +] + +[[package]] +name = "strsim" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" + [[package]] name = "sum_type" version = "0.2.0" @@ -4017,6 +4437,27 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "tide" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e619c99048ae107912703d0efeec4ff4fbff704f064e51d3eee614b28ea7b739" +dependencies = [ + "async-std", + "cookie", + "futures 0.3.4", + "http 0.1.21", + "http-service", + "http-service-hyper", + "log 0.4.8", + "mime 0.3.16", + "pin-project-lite", + "route-recognizer", + "serde", + "serde_json", + "serde_qs", +] + [[package]] name = "tiff" version = "0.3.1" @@ -4063,13 +4504,31 @@ dependencies = [ "serde_json", ] +[[package]] +name = "tokio" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "mio", + "num_cpus", + "tokio-current-thread", + "tokio-executor", + "tokio-io", + "tokio-reactor", + "tokio-threadpool", + "tokio-timer", +] + [[package]] name = "tokio" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa5e81d6bc4e67fe889d5783bd2a128ab2e0cfa487e0be16b6a8d177b101616" dependencies = [ - "bytes", + "bytes 0.5.4", "fnv", "iovec", "lazy_static", @@ -4080,6 +4539,67 @@ dependencies = [ "slab", ] +[[package]] +name = "tokio-buf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" +dependencies = [ + "bytes 0.4.12", + "either", + "futures 0.1.29", +] + +[[package]] +name = "tokio-current-thread" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" +dependencies = [ + "futures 0.1.29", + "tokio-executor", +] + +[[package]] +name = "tokio-executor" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" +dependencies = [ + "crossbeam-utils 0.7.2", + "futures 0.1.29", +] + +[[package]] +name = "tokio-io" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "log 0.4.8", +] + +[[package]] +name = "tokio-reactor" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" +dependencies = [ + "crossbeam-utils 0.7.2", + "futures 0.1.29", + "lazy_static", + "log 0.4.8", + "mio", + "num_cpus", + "parking_lot 0.9.0", + "slab", + "tokio-executor", + "tokio-io", + "tokio-sync", +] + [[package]] name = "tokio-rustls" version = "0.13.0" @@ -4088,22 +4608,75 @@ checksum = "4adb8b3e5f86b707f1b54e7c15b6de52617a823608ccda98a15d3a24222f265a" dependencies = [ "futures-core", "rustls", - "tokio", + "tokio 0.2.13", "webpki", ] +[[package]] +name = "tokio-sync" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" +dependencies = [ + "fnv", + "futures 0.1.29", +] + +[[package]] +name = "tokio-tcp" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" +dependencies = [ + "bytes 0.4.12", + "futures 0.1.29", + "iovec", + "mio", + "tokio-io", + "tokio-reactor", +] + +[[package]] +name = "tokio-threadpool" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" +dependencies = [ + "crossbeam-deque", + "crossbeam-queue 0.2.1", + "crossbeam-utils 0.7.2", + "futures 0.1.29", + "lazy_static", + "log 0.4.8", + "num_cpus", + "slab", + "tokio-executor", +] + +[[package]] +name = "tokio-timer" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" +dependencies = [ + "crossbeam-utils 0.7.2", + "futures 0.1.29", + "slab", + "tokio-executor", +] + [[package]] name = "tokio-util" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" dependencies = [ - "bytes", + "bytes 0.5.4", "futures-core", "futures-sink", "log 0.4.8", "pin-project-lite", - "tokio", + "tokio 0.2.13", ] [[package]] @@ -4390,6 +4963,7 @@ dependencies = [ "chrono", "conrod_core", "conrod_winit", + "const-tweaker", "cpal", "criterion", "crossbeam", @@ -4489,6 +5063,17 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" +dependencies = [ + "futures 0.1.29", + "log 0.4.8", + "try-lock", +] + [[package]] name = "want" version = "0.3.0" diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 21049a4c4c..5f77c47231 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -11,6 +11,7 @@ default-run = "veloren-voxygen" [features] gl = ["gfx_device_gl"] singleplayer = ["server"] +tweak = ["const_tweaker"] default = ["gl", "singleplayer", "msgbox"] @@ -67,6 +68,7 @@ bincode = "1.2" deunicode = "1.0" uvth = "3.1.1" authc = { git = "https://gitlab.com/veloren/auth.git", rev = "65571ade0d954a0e0bd995fdb314854ff146ab97" } +const_tweaker = { version = "0.2.1", optional = true } [target.'cfg(target_os = "macos")'.dependencies] dispatch = "0.1.4" diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index eb1d08ec3d..d6b55fd31a 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -145,6 +145,11 @@ pub enum Event { Close, } +#[const_tweaker::tweak(min = -10.0, max = 10.0, step = 1.0)] +const X: f64 = 0.0; +#[const_tweaker::tweak(min = -10.0, max = 10.0, step = 1.0)] +const Y: f64 = 0.0; + impl<'a> Widget for Bag<'a> { type Event = Option; type State = State; @@ -160,6 +165,11 @@ impl<'a> Widget for Bag<'a> { fn style(&self) -> Self::Style { () } + /*fn const_tweaker() { + // Initialize the web GUI at 'http://127.0.0.1:9938' + const_tweaker::run().expect("Could not run server"); + }*/ + fn update(self, args: widget::UpdateArgs) -> Self::Event { let widget::UpdateArgs { state, ui, .. } = args; @@ -688,14 +698,14 @@ impl<'a> Widget for Bag<'a> { if amount > 0 { // TODO This should be > 1 Text::new(&format!("{}", &amount)) - .top_right_with_margins_on(state.ids.items[i], 10.0, 10.0) + .top_right_with_margins_on(state.ids.items[i], *Y, *X) .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(10)) + .font_size(self.fonts.cyri.scale(14)) .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) .floating(true) .set(state.ids.amounts_bg[i], ui); Text::new(&format!("{}", &amount)) - .top_right_with_margins_on(state.ids.inventory_title_bg, 2.0, 2.0) + .bottom_left_with_margins_on(state.ids.amounts_bg[i], 2.0, 2.0) .font_id(self.fonts.cyri.conrod_id) .font_size(self.fonts.cyri.scale(10)) .color(TEXT_COLOR) diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index f2a091daf0..ae198ad636 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -17,6 +17,8 @@ use log::{debug, error}; use std::{mem, panic, str::FromStr}; fn main() { + #[cfg(feature = "tweak")] + const_tweaker::run().expect("Could not run server"); // Initialize logging. let term_log_level = std::env::var_os("VOXYGEN_LOG") .and_then(|env| env.to_str().map(|s| s.to_owned())) From e16bb66fb3fb05324ceb6fda6f0aac8403237bd9 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 19 Mar 2020 18:19:05 +0100 Subject: [PATCH 154/326] fix --- voxygen/Cargo.toml | 4 ++-- voxygen/src/hud/bag.rs | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 5f77c47231..0dfa722f6e 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -11,7 +11,7 @@ default-run = "veloren-voxygen" [features] gl = ["gfx_device_gl"] singleplayer = ["server"] -tweak = ["const_tweaker"] +tweak = ["const-tweaker"] default = ["gl", "singleplayer", "msgbox"] @@ -68,7 +68,7 @@ bincode = "1.2" deunicode = "1.0" uvth = "3.1.1" authc = { git = "https://gitlab.com/veloren/auth.git", rev = "65571ade0d954a0e0bd995fdb314854ff146ab97" } -const_tweaker = { version = "0.2.1", optional = true } +const-tweaker = { version = "0.2.1", optional = true } [target.'cfg(target_os = "macos")'.dependencies] dispatch = "0.1.4" diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index d6b55fd31a..d9ae386a48 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -165,11 +165,6 @@ impl<'a> Widget for Bag<'a> { fn style(&self) -> Self::Style { () } - /*fn const_tweaker() { - // Initialize the web GUI at 'http://127.0.0.1:9938' - const_tweaker::run().expect("Could not run server"); - }*/ - fn update(self, args: widget::UpdateArgs) -> Self::Event { let widget::UpdateArgs { state, ui, .. } = args; From 83be1226ef6c49fa7f3e7db3711488cbb8ce3050 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 19 Mar 2020 18:33:10 +0100 Subject: [PATCH 155/326] Set dash direction based on look_dir --- common/src/comp/ability.rs | 4 ++-- common/src/states/dash_melee.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index dc293fbc6c..3e93926b3a 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -51,8 +51,7 @@ impl CharacterAbility { .is_ok() }, CharacterAbility::DashMelee { .. } => { - data.physics.on_ground - && !data.physics.in_fluid + !data.physics.in_fluid && update .energy .try_change_by(-300, EnergySource::Ability) @@ -122,6 +121,7 @@ impl From<&CharacterAbility> for CharacterState { recover_duration, base_damage, } => CharacterState::DashMelee(dash_melee::Data { + initialize: true, exhausted: false, buildup_duration: *buildup_duration, recover_duration: *recover_duration, diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index b72502d219..8697df41d6 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -18,6 +18,7 @@ pub struct Data { pub base_damage: u32, /// Whether the attack can deal more damage pub exhausted: bool, + pub initialize: bool, } impl CharacterBehavior for Data { @@ -32,6 +33,10 @@ impl CharacterBehavior for Data { server_events: VecDeque::new(), }; + if self.initialize { + update.vel.0 = data.inputs.look_dir * 20.0; + } + if self.buildup_duration != Duration::default() && data.physics.touch_entity.is_none() { // Build up (this will move you forward) update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) @@ -49,6 +54,7 @@ impl CharacterBehavior for Data { recover_duration: self.recover_duration, base_damage: self.base_damage, exhausted: false, + initialize: false, }); } else if !self.exhausted { // Hit attempt @@ -64,6 +70,7 @@ impl CharacterBehavior for Data { recover_duration: self.recover_duration, base_damage: self.base_damage, exhausted: true, + initialize: false, }); } else if self.recover_duration != Duration::default() { // Recovery @@ -75,6 +82,7 @@ impl CharacterBehavior for Data { .unwrap_or_default(), base_damage: self.base_damage, exhausted: true, + initialize: false, }); } else { // Done From 3c0e070ed0b1a9067076dc7c7cecd09300165711 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 19 Mar 2020 19:33:59 +0100 Subject: [PATCH 156/326] stack numbers --- common/src/comp/inventory/mod.rs | 2 +- voxygen/src/hud/bag.rs | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 5a724fff05..8e923ab97e 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -277,7 +277,7 @@ impl Inventory { impl Default for Inventory { fn default() -> Inventory { let mut inventory = Inventory { - slots: vec![None; 25], + slots: vec![None; 27], }; inventory.push(assets::load_expect_cloned("common.items.cheese")); inventory.push(assets::load_expect_cloned("common.items.apple")); diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index d9ae386a48..61d92f114c 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -145,10 +145,8 @@ pub enum Event { Close, } -#[const_tweaker::tweak(min = -10.0, max = 10.0, step = 1.0)] -const X: f64 = 0.0; -#[const_tweaker::tweak(min = -10.0, max = 10.0, step = 1.0)] -const Y: f64 = 0.0; +//#[const_tweaker::tweak(min = -10.0, max = 10.0, step = 1.0)] +//const X: f64 = 10.0; impl<'a> Widget for Bag<'a> { type Event = Option; @@ -690,19 +688,19 @@ impl<'a> Widget for Bag<'a> { | ItemKind::Consumable { amount, .. } | ItemKind::Ingredient { amount, .. } => Some(amount), } { - if amount > 0 { - // TODO This should be > 1 + if amount > 1 { Text::new(&format!("{}", &amount)) - .top_right_with_margins_on(state.ids.items[i], *Y, *X) + .top_right_with_margins_on(state.ids.items[i], -4.0, 0.0) .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(14)) + .floating(true) + .font_size(self.fonts.cyri.scale(12)) .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) .floating(true) .set(state.ids.amounts_bg[i], ui); Text::new(&format!("{}", &amount)) .bottom_left_with_margins_on(state.ids.amounts_bg[i], 2.0, 2.0) .font_id(self.fonts.cyri.conrod_id) - .font_size(self.fonts.cyri.scale(10)) + .font_size(self.fonts.cyri.scale(12)) .color(TEXT_COLOR) .floating(true) .set(state.ids.amounts[i], ui); From 44d3f4c4ac6881e81ae7f166cc2339dfdb7043d7 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 19 Mar 2020 20:01:31 +0100 Subject: [PATCH 157/326] fix --- voxygen/src/hud/bag.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 61d92f114c..08d4041f90 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -698,7 +698,7 @@ impl<'a> Widget for Bag<'a> { .floating(true) .set(state.ids.amounts_bg[i], ui); Text::new(&format!("{}", &amount)) - .bottom_left_with_margins_on(state.ids.amounts_bg[i], 2.0, 2.0) + .bottom_left_with_margins_on(state.ids.amounts_bg[i], 1.0, 1.0) .font_id(self.fonts.cyri.conrod_id) .font_size(self.fonts.cyri.scale(12)) .color(TEXT_COLOR) From 26674390abc1b25709cac25b03998bd7bc3ea33c Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 19 Mar 2020 20:36:19 +0100 Subject: [PATCH 158/326] Hide player body after death --- server/src/events/entity_manipulation.rs | 1 + voxygen/src/scene/figure/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 39dd2f738d..29c9c606e5 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -100,6 +100,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc entity, assets::load_expect_cloned::("common.items.cheese"), ); + state.ecs().write_storage::().remove(entity); state.ecs().write_storage::().remove(entity); state .ecs() diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 768b07ba80..da537888b8 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -1364,8 +1364,8 @@ impl FigureMgr { ecs.read_storage::().maybe(), ) .join() - // Don't render dead entities // Disabled to render corpses - //.filter(|(_, _, _, _, stats, loadout, _)| stats.map_or(true, |s| !s.is_dead)) + // Don't render dead entities + .filter(|(_, _, _, _, stats, loadout, _)| stats.map_or(true, |s| !s.is_dead)) { let is_player = entity == player_entity; let player_camera_mode = if is_player { From 1e1ce2adbf9afe16620017eb0e209a20c29fb3e1 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 19 Mar 2020 20:57:36 +0100 Subject: [PATCH 159/326] Fix weapon not updating after swapping to a weapon of the same type --- voxygen/src/scene/figure/cache.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 90af923e3e..85becab458 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -23,7 +23,7 @@ enum FigureKey { #[derive(PartialEq, Eq, Hash, Clone)] struct CharacterCacheKey { state: Option>, // TODO: Can this be simplified? - active_tool: Option>, + active_tool: Option, shoulder: Option, chest: Option, belt: Option, @@ -39,7 +39,7 @@ impl CharacterCacheKey { active_tool: if let Some(ItemKind::Tool(tool)) = loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(discriminant(&tool.kind)) + Some(tool.kind) } else { None }, From 208245e82ebbe12bcca06ee28ff35f9c5fb7b660 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 19 Mar 2020 22:03:17 +0100 Subject: [PATCH 160/326] Make orientation not dependend on camera dir while wielded --- common/src/comp/character_state.rs | 4 ++++ common/src/states/dash_melee.rs | 1 + common/src/states/utils.rs | 10 ++-------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 649e8934dc..480f937afa 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -55,7 +55,10 @@ impl CharacterState { match self { CharacterState::Wielding | CharacterState::BasicMelee(_) + | CharacterState::BasicRanged(_) + | CharacterState::DashMelee(_) | CharacterState::TimedCombo(_) + | CharacterState::ChargeAttack(_) | CharacterState::BasicBlock => true, _ => false, } @@ -66,6 +69,7 @@ impl CharacterState { CharacterState::BasicMelee(_) | CharacterState::BasicRanged(_) | CharacterState::TimedCombo(_) + | CharacterState::DashMelee(_) | CharacterState::ChargeAttack(_) => true, _ => false, } diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 8697df41d6..e4d495ded2 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -35,6 +35,7 @@ impl CharacterBehavior for Data { if self.initialize { update.vel.0 = data.inputs.look_dir * 20.0; + update.ori.0 = update.vel.0; } if self.buildup_duration != Duration::default() && data.physics.touch_entity.is_none() { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index c039db1310..0ee196d5df 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -54,10 +54,7 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate) { } // Set direction based on move direction - let ori_dir = if update.character.is_wield() - || update.character.is_attack() - || update.character.is_block() - { + let ori_dir = if update.character.is_attack() || update.character.is_block() { Vec2::from(data.inputs.look_dir).normalized() } else { Vec2::from(data.inputs.move_dir) @@ -84,10 +81,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { }; // Set direction based on move direction when on the ground - let ori_dir = if update.character.is_wield() - || update.character.is_attack() - || update.character.is_block() - { + let ori_dir = if update.character.is_attack() || update.character.is_block() { Vec2::from(data.inputs.look_dir).normalized() } else { Vec2::from(update.vel.0) From 3145b26cd634db6d70faef5d3121d810939dbd7e Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Thu, 19 Mar 2020 22:36:40 +0100 Subject: [PATCH 161/326] item images --- assets/common/items/armor/hand/leather_0.ron | 2 +- assets/voxygen/item_image_manifest.ron | 51 +++++++++++++++++-- .../voxel/humanoid_main_weapon_manifest.ron | 2 +- common/src/comp/inventory/mod.rs | 2 +- voxygen/src/hud/bag.rs | 4 +- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/assets/common/items/armor/hand/leather_0.ron b/assets/common/items/armor/hand/leather_0.ron index a2b322ba33..8efe8a59f2 100644 --- a/assets/common/items/armor/hand/leather_0.ron +++ b/assets/common/items/armor/hand/leather_0.ron @@ -1,6 +1,6 @@ Item( name: "Swift Gloves", - description: "Only the best for a member of the creed.", + description: "Swift like the wind.", kind: Armor( kind: Hand(Leather0), stats: 20, diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index 7ff7586d71..c9e969ccbc 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -3,34 +3,54 @@ // VoxTrans(specifier, offset, (x_rot, y_rot, z_rot), zoom) ({ // Weapons + // Bows Tool(Bow(BasicBow)): VoxTrans( "voxel.weapon.bow.simple-bow", (0.0, 0.0, 0.0), (90.0, 90.0, 0.0), 1.0, ), + // Daggers Tool(Dagger(BasicDagger)): VoxTrans( "voxel.weapon.dagger.dagger_rusty", (0.0, 0.0, -4.0), (-120.0, 90.0, 0.0), 1.1, ), - Tool(Sword(Rapier)): VoxTrans( - "voxel.weapon.sword.rusty_2h", + // Swords + Tool(Sword(Short0)): VoxTrans( + "voxel.weapon.sword.short_2h-0", (0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4, ), + Tool(Sword(BasicSword)): VoxTrans( + "voxel.weapon.sword.weapon.sword.rusty_2h", + (0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4, + ), + Tool(Sword(Zweihander0)): VoxTrans( + "voxel.weapon.sword.zweihander_2h-0", + (0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4, + ), + Tool(Sword(WoodTraining)): VoxTrans( + "voxel.weapon.sword.wood_2h", + (0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4, + ), + // Axes Tool(Axe(BasicAxe)): VoxTrans( "voxel.weapon.axe.rusty_2h", (0.0, -8.0, 0.0), (-90.0, 90.0, 0.0), 2.0, ), + // Hammers Tool(Hammer(BasicHammer)): VoxTrans( "voxel.weapon.hammer.rusty_2h", (0.0, -8.0, 0.0), (-90.0, 90.0, 0.0), 2.0, ), + // Staffs Tool(Staff(BasicStaff)): VoxTrans( "voxel.weapon.staff.wood-fire", (0.0, -9.0, 0.0), (90.0, 90.0, 0.0), 2.5, ), + // Shields Tool(Shield(BasicShield)): VoxTrans( "voxel.weapon.shield.wood-0", (0.0, 0.0, 0.0), (-90.0, 90.0, 0.0), 2.4, ), + // Other Utility(Collar): VoxTrans( "element.icons.collar", (0.0, 0.0, 0.0), (-90.0, 180.0, 10.0), 1.3, @@ -86,6 +106,31 @@ "voxel.armor.shoulder.plate_left-0", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), + //Leather0 Armor + Armor(Chest(Leather0)): VoxTrans( + "voxel.armor.chest.leather-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Pants(Leather0)): VoxTrans( + "voxel.armor.pants.leather-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Belt(Leather0)): VoxTrans( + "voxel.armor.belt.leather-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.8, + ), + Armor(Foot(Leather0)): VoxTrans( + "voxel.armor.foot.leather-0", + (0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1, + ), + Armor(Hand(Leather0)): VoxTrans( + "voxel.armor.hand.leather_left-0", + (0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0, + ), + Armor(Shoulder(Leather1)): VoxTrans( + "voxel.armor.shoulder.leather_left-1", + (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, + ), // Consumables Consumable(Apple): VoxTrans( "element.icons.item_apple", @@ -133,5 +178,3 @@ (0.0, -7.0, 0.0), (90.0, 90.0, 0.0), 1.6, ), }) - - diff --git a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron index bbd70395a9..c043b845d3 100644 --- a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron +++ b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron @@ -16,7 +16,7 @@ color: None ), Sword(Short0): ( - vox_spec: ("weapon.sword.short_2h-0", (-1.5, -6.5, -4.0)), + vox_spec: ("weapon.sword.short_2h-0", (-2.0, -6.5, -1.0)), color: None ), Axe(BasicAxe): ( diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 8e923ab97e..db591f302f 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -277,7 +277,7 @@ impl Inventory { impl Default for Inventory { fn default() -> Inventory { let mut inventory = Inventory { - slots: vec![None; 27], + slots: vec![None; 200], }; inventory.push(assets::load_expect_cloned("common.items.cheese")); inventory.push(assets::load_expect_cloned("common.items.apple")); diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 08d4041f90..d8eb94ec6a 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -180,8 +180,8 @@ impl<'a> Widget for Bag<'a> { self.stats.exp.maximum(), &self.localized_strings.get("hud.bag.exp") ); - let space_used = 2; // TODO: Add functionality - let space_max = 999; + let space_used = 0; // TODO: Add functionality + let space_max = 0; let bag_space = format!("{}/{}", space_used, space_max); let level = (self.stats.level.level()).to_string(); let currency = 999999; // TODO: Add as a Stat maybe? From 0b7a57217829e19470cca8b970fd56834ce83f58 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Thu, 19 Mar 2020 15:40:03 -0700 Subject: [PATCH 162/326] update triple_strike --- common/src/comp/ability.rs | 11 ++++ common/src/comp/character_state.rs | 7 +++ common/src/comp/inventory/item.rs | 11 ++-- common/src/states/triple_strike.rs | 82 +++++++++++++++++++++++++++--- voxygen/src/scene/figure/mod.rs | 16 ++++++ 5 files changed, 114 insertions(+), 13 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 3e93926b3a..e631e197ad 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -36,6 +36,9 @@ pub enum CharacterAbility { recover_duration: Duration, base_damage: u32, }, + TripleStrike { + base_damage: u32, + }, } impl CharacterAbility { @@ -146,6 +149,14 @@ impl From<&CharacterAbility> for CharacterState { stage_time_active: Duration::default(), base_damage: *base_damage, }), + CharacterAbility::TripleStrike { base_damage } => { + CharacterState::TripleStrike(triple_strike::Data { + base_damage: *base_damage, + stage: 0, + stage_exhausted: false, + stage_time_active: Duration::default(), + }) + }, } } } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 480f937afa..7d0fb6cc9b 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -64,6 +64,13 @@ impl CharacterState { } } + pub fn can_swap(&self) -> bool { + match self { + CharacterState::Wielding => true, + _ => false, + } + } + pub fn is_attack(&self) -> bool { match self { CharacterState::BasicMelee(_) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 00c35348e3..4963218807 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -69,11 +69,12 @@ impl ToolData { match self.kind { Sword(_) => vec![ - BasicMelee { - buildup_duration: Duration::from_millis(100), - recover_duration: Duration::from_millis(500), - base_damage: 6, - }, + // BasicMelee { + // buildup_duration: Duration::from_millis(100), + // recover_duration: Duration::from_millis(500), + // base_damage: 6, + // }, + CharacterAbility::TripleStrike { base_damage: 7 }, DashMelee { buildup_duration: Duration::from_millis(500), recover_duration: Duration::from_millis(500), diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 2fe224f265..4dddbd629f 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -1,13 +1,16 @@ use crate::{ - comp::{StateUpdate, ToolData}, + comp::{Attacking, CharacterState, EnergySource, StateUpdate}, states::utils::*, sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::{collections::VecDeque, time::Duration}; +use vek::vec::Vec2; // In millis const STAGE_DURATION: u64 = 600; +const BASE_ACCEL: f32 = 200.0; +const BASE_SPEED: f32 = 250.0; /// ### A sequence of 3 incrementally increasing attacks. /// /// While holding down the `primary` button, perform a series of 3 attacks, @@ -17,13 +20,13 @@ const STAGE_DURATION: u64 = 600; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Data { /// The tool this state will read to handle damage, etc. - pub tool: ToolData, + pub base_damage: u32, /// `int` denoting what stage (of 3) the attack is in. pub stage: i8, /// How long current stage has been active pub stage_time_active: Duration, /// Whether current stage has exhausted its attack - stage_exhausted: bool, + pub stage_exhausted: bool, } impl CharacterBehavior for Data { @@ -38,7 +41,6 @@ impl CharacterBehavior for Data { server_events: VecDeque::new(), }; - let new_stage_exhausted = self.stage_exhausted; let new_stage_time_active = self .stage_time_active .checked_add(Duration::from_secs_f32(data.dt.0)) @@ -46,19 +48,83 @@ impl CharacterBehavior for Data { // If player stops holding input, if !data.inputs.primary.is_pressed() { - attempt_wield(data, &mut update); + // Done + update.character = CharacterState::Wielding; + // Make sure attack component is removed + data.updater.remove::(data.entity); return update; } if self.stage < 3 { if new_stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { // Move player forward while in first third of each stage - handle_move(data, &mut update); + // Move player according to move_dir + if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) { + update.vel.0 = + update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * BASE_ACCEL; + let mag2 = update.vel.0.magnitude_squared(); + if mag2 > BASE_SPEED.powf(2.0) { + update.vel.0 = update.vel.0.normalized() * BASE_SPEED; + } + }; + + update.character = CharacterState::TripleStrike(Data { + base_damage: self.base_damage, + stage: self.stage, + stage_time_active: new_stage_time_active, + stage_exhausted: false, + }); } else if new_stage_time_active > Duration::from_millis(STAGE_DURATION / 2) - && !new_stage_exhausted + && !self.stage_exhausted { + // Allow player to influence orientation a little + handle_move(data, &mut update); + // Try to deal damage in second half of stage - // TODO: deal damage + data.updater.insert(data.entity, Attacking { + base_damage: self.base_damage * (self.stage as u32 + 1), + max_angle: 180_f32.to_radians(), + applied: false, + hit_count: 0, + }); + + update.character = CharacterState::TripleStrike(Data { + base_damage: self.base_damage, + stage: self.stage, + stage_time_active: new_stage_time_active, + stage_exhausted: true, + }); + } else if new_stage_time_active > Duration::from_millis(STAGE_DURATION) { + // Allow player to influence orientation a little + handle_move(data, &mut update); + + update.character = CharacterState::TripleStrike(Data { + base_damage: self.base_damage, + stage: self.stage + 1, + stage_time_active: Duration::default(), + stage_exhausted: false, + }); + } else { + update.character = CharacterState::TripleStrike(Data { + base_damage: self.base_damage, + stage: self.stage, + stage_time_active: new_stage_time_active, + stage_exhausted: self.stage_exhausted, + }); + } + } else { + // Done + update.character = CharacterState::Wielding; + // Make sure attack component is removed + data.updater.remove::(data.entity); + } + + // Grant energy on successful hit + if let Some(attack) = data.attacking { + if attack.applied && attack.hit_count > 0 { + data.updater.remove::(data.entity); + update.energy.change_by(100, EnergySource::HitEnemy); + 4 } } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index da537888b8..aca487e7c2 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -504,6 +504,22 @@ impl FigureMgr { skeleton_attr, ) }, + CharacterState::TripleStrike(s) => match s.stage { + 0 | 2 => anim::character::AttackAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ), + _ => anim::character::ChargeAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ), + }, CharacterState::TimedCombo(s) => match s.stage { 0 | 2 => anim::character::AttackAnimation::update_skeleton( &target_base, From bb76cc37bd31577d8f8502ba032a02d8c6f222ae Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Thu, 19 Mar 2020 16:14:04 -0700 Subject: [PATCH 163/326] Oops --- common/src/states/triple_strike.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 4dddbd629f..ac1a7a14e8 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -124,7 +124,6 @@ impl CharacterBehavior for Data { if attack.applied && attack.hit_count > 0 { data.updater.remove::(data.entity); update.energy.change_by(100, EnergySource::HitEnemy); - 4 } } From 6094e4b017ff4563cc22d94cf5cf69d704368091 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 20 Mar 2020 01:11:02 +0100 Subject: [PATCH 164/326] added chest drops --- assets/common/items/armor/belt/leather_0.ron | 2 +- assets/common/items/armor/chest/leather_0.ron | 2 +- assets/common/items/armor/foot/leather_0.ron | 2 +- .../common/items/armor/shoulder/leather_1.ron | 2 +- assets/voxygen/element/icons/2hsword_m1.vox | 2 +- .../voxygen/element/icons/2hsword_slash.vox | 3 ++ assets/voxygen/item_image_manifest.ron | 18 ++++++---- .../voxel/humanoid_main_weapon_manifest.ron | 2 +- common/src/comp/inventory/item.rs | 13 +++++++ common/src/comp/inventory/mod.rs | 2 +- voxygen/src/hud/bag.rs | 2 +- voxygen/src/hud/skillbar.rs | 35 +++++++++++++------ 12 files changed, 60 insertions(+), 25 deletions(-) create mode 100644 assets/voxygen/element/icons/2hsword_slash.vox diff --git a/assets/common/items/armor/belt/leather_0.ron b/assets/common/items/armor/belt/leather_0.ron index e69abba663..8aa2663bee 100644 --- a/assets/common/items/armor/belt/leather_0.ron +++ b/assets/common/items/armor/belt/leather_0.ron @@ -1,6 +1,6 @@ Item( name: "Swift Belt", - description: "", + description: "Swift like the wind.", kind: Armor( kind: Belt(Leather0), stats: 20, diff --git a/assets/common/items/armor/chest/leather_0.ron b/assets/common/items/armor/chest/leather_0.ron index 6741474946..f96d7a01ac 100644 --- a/assets/common/items/armor/chest/leather_0.ron +++ b/assets/common/items/armor/chest/leather_0.ron @@ -1,6 +1,6 @@ Item( name: "Swift Chest", - description: "", + description: "Swift like the wind.", kind: Armor( kind: Chest(Leather0), stats: 20, diff --git a/assets/common/items/armor/foot/leather_0.ron b/assets/common/items/armor/foot/leather_0.ron index 820516a5ef..051aa7f6fc 100644 --- a/assets/common/items/armor/foot/leather_0.ron +++ b/assets/common/items/armor/foot/leather_0.ron @@ -1,6 +1,6 @@ Item( name: "Swift Boots", - description: "", + description: "Swift like the wind.", kind: Armor( kind: Foot(Leather0), stats: 20, diff --git a/assets/common/items/armor/shoulder/leather_1.ron b/assets/common/items/armor/shoulder/leather_1.ron index 19e15e40d7..990c15e135 100644 --- a/assets/common/items/armor/shoulder/leather_1.ron +++ b/assets/common/items/armor/shoulder/leather_1.ron @@ -1,6 +1,6 @@ Item( name: "Swift Shoulderpads", - description: "", + description: "Swift like the wind.", kind: Armor( kind: Shoulder(Leather1), stats: 20, diff --git a/assets/voxygen/element/icons/2hsword_m1.vox b/assets/voxygen/element/icons/2hsword_m1.vox index ea2a8e1eb9..fabf326482 100644 --- a/assets/voxygen/element/icons/2hsword_m1.vox +++ b/assets/voxygen/element/icons/2hsword_m1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dfd03c8de8d52353a54311ef539d0a03786929e1b0842e9806f389659d8faca2 +oid sha256:29883a92ce28f094ff146f942101ea0e6dd4882b42a18259d16636cf5d091b38 size 57621 diff --git a/assets/voxygen/element/icons/2hsword_slash.vox b/assets/voxygen/element/icons/2hsword_slash.vox new file mode 100644 index 0000000000..ea2a8e1eb9 --- /dev/null +++ b/assets/voxygen/element/icons/2hsword_slash.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfd03c8de8d52353a54311ef539d0a03786929e1b0842e9806f389659d8faca2 +size 57621 diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index c9e969ccbc..8d1c1a45a7 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -19,7 +19,7 @@ (0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4, ), Tool(Sword(BasicSword)): VoxTrans( - "voxel.weapon.sword.weapon.sword.rusty_2h", + "voxel.weapon.sword.rusty_2h", (0.0, 9.0, 0.0), (-90.0, 90.0, 0.0), 2.4, ), Tool(Sword(Zweihander0)): VoxTrans( @@ -67,15 +67,15 @@ ), Armor(Belt(Assassin)): VoxTrans( "voxel.armor.belt.assa", - (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.1, + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.8, ), Armor(Foot(Assassin)): VoxTrans( "voxel.armor.foot.assa", - (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + (0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1, ), Armor(Hand(Assassin)): VoxTrans( "voxel.armor.hand.assa_left", - (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + (0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0, ), Armor(Shoulder(Assassin)): VoxTrans( "voxel.armor.shoulder.assa_left", @@ -92,15 +92,15 @@ ), Armor(Belt(Plate0)): VoxTrans( "voxel.armor.belt.plate-0", - (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.1, + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.8, ), Armor(Foot(Plate0)): VoxTrans( "voxel.armor.foot.plate-0", - (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + (0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1, ), Armor(Hand(Plate0)): VoxTrans( "voxel.armor.hand.plate_left-0", - (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + (0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0, ), Armor(Shoulder(Plate0)): VoxTrans( "voxel.armor.shoulder.plate_left-0", @@ -130,6 +130,10 @@ Armor(Shoulder(Leather1)): VoxTrans( "voxel.armor.shoulder.leather_left-1", (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, + ), + Armor(Shoulder(Leather0)): VoxTrans( + "voxel.armor.shoulder.leather_left-0", + (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, ), // Consumables Consumable(Apple): VoxTrans( diff --git a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron index c043b845d3..89ccc89f0e 100644 --- a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron +++ b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron @@ -16,7 +16,7 @@ color: None ), Sword(Short0): ( - vox_spec: ("weapon.sword.short_2h-0", (-2.0, -6.5, -1.0)), + vox_spec: ("weapon.sword.short_2h-0", (-1.5, -6.5, -1.0)), color: None ), Axe(BasicAxe): ( diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 4963218807..6f522eb094 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -290,6 +290,19 @@ impl Item { "common.items.weapons.starter_hammer", "common.items.weapons.starter_bow", "common.items.weapons.starter_staff", + "common.items.armor.belt.plate_0", + "common.items.armor.belt.leather_0", + "common.items.armor.chest.plate_green_0", + "common.items.armor.chest.leather_0", + "common.items.armor.foot.plate_0", + "common.items.armor.foot.leather_0", + "common.items.armor.pants.plate_green_0", + "common.items.armor.belt.leather_0", + "common.items.armor.shoulder.plate_0", + "common.items.armor.shoulder.leather_1", + "common.items.armor.shoulder.leather_0", + "common.items.weapons.wood_sword", + "common.items.weapons.short_sword_0", ] .choose(&mut rand::thread_rng()) .unwrap(), // Can't fail diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index db591f302f..ad2d0f7e53 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -277,7 +277,7 @@ impl Inventory { impl Default for Inventory { fn default() -> Inventory { let mut inventory = Inventory { - slots: vec![None; 200], + slots: vec![None; 18], }; inventory.push(assets::load_expect_cloned("common.items.cheese")); inventory.push(assets::load_expect_cloned("common.items.apple")); diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index d8eb94ec6a..d2fe381091 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -184,7 +184,7 @@ impl<'a> Widget for Bag<'a> { let space_max = 0; let bag_space = format!("{}/{}", space_used, space_max); let level = (self.stats.level.level()).to_string(); - let currency = 999999; // TODO: Add as a Stat maybe? + let currency = 0; // TODO: Add as a Stat maybe? // Tooltips let item_tooltip = Tooltip::new({ diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 70c5bdb576..943190c11d 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -699,7 +699,7 @@ impl<'a> Widget for Skillbar<'a> { Button::image( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Sword(_) => self.imgs.twohsword_m2, + ToolKind::Sword(_) => self.imgs.charge, ToolKind::Hammer(_) => self.imgs.twohhammer_m2, ToolKind::Axe(_) => self.imgs.twohaxe_m2, ToolKind::Bow(_) => self.imgs.bow_m2, @@ -731,6 +731,21 @@ impl<'a> Widget for Skillbar<'a> { }, ) .middle_of(state.ids.m2_slot_bg) + .color( + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Sword(_) => { + if self.energy.current() as f64 >= 200.0 { + Color::Rgba(1.0, 1.0, 1.0, 1.0) + } else { + Color::Rgba(0.4, 0.4, 0.4, 1.0) + } + }, + _ => Color::Rgba(1.0, 1.0, 1.0, 1.0), + }, + _ => Color::Rgba(1.0, 1.0, 1.0, 1.0), + }, + ) .set(state.ids.m2_content, ui); //Slot 5 Image::new(self.imgs.skillbar_slot) @@ -808,15 +823,15 @@ impl<'a> Widget for Skillbar<'a> { .middle_of(state.ids.slot1) .set(state.ids.slot1_bg, ui); // TODO: Changeable slot image - Image::new(self.imgs.charge) - .w_h(18.0 * scale, 18.0 * scale) - .color(if self.energy.current() as f64 >= 200.0 { - Some(Color::Rgba(1.0, 1.0, 1.0, 1.0)) - } else { - Some(Color::Rgba(0.4, 0.4, 0.4, 1.0)) - }) - .middle_of(state.ids.slot1_bg) - .set(state.ids.slot1_icon, ui); + /*Image::new(self.imgs.charge) + .w_h(18.0 * scale, 18.0 * scale) + .color(if self.energy.current() as f64 >= 200.0 { + Some(Color::Rgba(1.0, 1.0, 1.0, 1.0)) + } else { + Some(Color::Rgba(0.4, 0.4, 0.4, 1.0)) + }) + .middle_of(state.ids.slot1_bg) + .set(state.ids.slot1_icon, ui);*/ // Slot 6 Image::new(self.imgs.skillbar_slot) .w_h(20.0 * scale, 20.0 * scale) From 93bea033d9778934b417232b2ba97e9e63ce5223 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Fri, 20 Mar 2020 01:27:54 -0400 Subject: [PATCH 165/326] axe, hammer proper wields --- voxygen/src/anim/character/attack.rs | 1 + voxygen/src/anim/character/mod.rs | 2 + voxygen/src/anim/character/stand.rs | 2 +- voxygen/src/anim/character/wield.rs | 70 ++++++++++++++-------------- 4 files changed, 38 insertions(+), 37 deletions(-) diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index dea9736ebe..dd853fda44 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -61,6 +61,7 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(decel * 0.08); next.shorts.scale = Vec3::one(); + match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 0fe9e9ac1a..c4560db4cb 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -120,6 +120,7 @@ pub struct SkeletonAttr { neck_right: f32, weapon_x: f32, weapon_y: f32, + } impl SkeletonAttr { pub fn calculate_scale(body: &comp::humanoid::Body) -> f32 { @@ -151,6 +152,7 @@ impl Default for SkeletonAttr { neck_right: 1.0, weapon_x: 1.0, weapon_y: 1.0, + } } } diff --git a/voxygen/src/anim/character/stand.rs b/voxygen/src/anim/character/stand.rs index c66afb21b4..ab2d67fea7 100644 --- a/voxygen/src/anim/character/stand.rs +++ b/voxygen/src/anim/character/stand.rs @@ -86,7 +86,7 @@ impl Animation for StandAnimation { next.main.offset = Vec3::new( -7.0 + skeleton_attr.weapon_x, -5.0 + skeleton_attr.weapon_y, - 18.0, + 15.0, ); next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); next.main.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 05cfaafdc6..f52587ae84 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -19,7 +19,7 @@ impl Animation for WieldAnimation { ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let wave_ultra_slow = (anim_time as f32 * 3.0 + PI).sin(); + let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); let wave = (anim_time as f32 * 1.0).sin(); @@ -45,44 +45,42 @@ impl Animation for WieldAnimation { next.control.scale = Vec3::one(); }, Some(ToolKind::Axe(_)) => { - next.l_hand.offset = Vec3::new(-6.5, -0.5, 6.0); - next.l_hand.ori = Quaternion::rotation_x(0.13) * Quaternion::rotation_z(-0.25); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(-3.0, 6.5, 6.0); - next.r_hand.ori = Quaternion::rotation_x(0.13) - * Quaternion::rotation_z(2.98) - * Quaternion::rotation_y(-0.50); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -5.0 + skeleton_attr.weapon_x, - 8.5 + skeleton_attr.weapon_y, - -0.5, - ); - next.main.ori = Quaternion::rotation_x(1.70) - * Quaternion::rotation_y(-0.25) - * Quaternion::rotation_z(0.0); + next.l_hand.offset = Vec3::new(-4.0, 3.0, 6.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(3.14 - 0.3) * Quaternion::rotation_y(-0.8); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(-2.5, 9.0, 4.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(3.14 - 0.3)* Quaternion::rotation_y(-0.8); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(-6.0, 10.0, -1.0); + next.main.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(-0.8); next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(0.0, 0.0, 0.0); + next.control.ori = Quaternion::rotation_x( wave_ultra_slow_cos * 0.1) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z( wave_ultra_slow * 0.1); + next.control.scale = Vec3::one(); }, Some(ToolKind::Hammer(_)) => { - next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); - next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); - next.r_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - 5.0 + skeleton_attr.weapon_x, - 8.75 + skeleton_attr.weapon_y, - -2.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(-1.27) - * Quaternion::rotation_z(wave * -0.25); + next.l_hand.offset = Vec3::new(-7.0, 4.6, 7.5); + next.l_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.32); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(8.0, 5.75, 4.0); + next.r_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.22); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(6.0, 7.0, 0.0); + next.main.ori = Quaternion::rotation_x(0.3) + * Quaternion::rotation_y(-1.35) + * Quaternion::rotation_z(1.57); next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(0.0, 0.0, 0.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.15) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.08); + next.control.scale = Vec3::one(); }, Some(ToolKind::Staff(_)) => { next.l_hand.offset = Vec3::new( @@ -196,7 +194,7 @@ impl Animation for WieldAnimation { _ => {}, } - next.torso.offset = Vec3::new(0.0, 0.0 + wave * -0.08, 0.1) * skeleton_attr.scaler; + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; From 50e96efe6bb6d3bbcb2ecb53a2a88b5ecef8703f Mon Sep 17 00:00:00 2001 From: jshipsey Date: Fri, 20 Mar 2020 02:38:53 -0400 Subject: [PATCH 166/326] hammer go smash --- voxygen/src/anim/character/attack.rs | 45 ++++++++++++++-------------- voxygen/src/anim/character/mod.rs | 2 -- voxygen/src/anim/character/wield.rs | 12 +++++--- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index dd853fda44..b866629bbf 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -23,6 +23,8 @@ impl Animation for AttackAnimation { let mut next = (*skeleton).clone(); let lab = 1.0; + let test = (anim_time as f32 * 16.0 * lab as f32).cos(); + let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); @@ -32,6 +34,10 @@ impl Animation for AttackAnimation { / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * lab as f32 * 12.4).sin()); + let slower = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0).sin()); next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, @@ -61,7 +67,6 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(decel * 0.08); next.shorts.scale = Vec3::one(); - match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { @@ -109,29 +114,23 @@ impl Animation for AttackAnimation { next.main.scale = Vec3::one(); }, Some(ToolKind::Hammer(_)) => { - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.offset = Vec3::new(0.0, 1.0, 5.0); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-6.0, 3.0, 5.0 + slower * 5.0); + next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(1.4 + 1.57); + next.control.scale = Vec3::one(); }, Some(ToolKind::Staff(_)) => { next.l_hand.offset = diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index c4560db4cb..0fe9e9ac1a 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -120,7 +120,6 @@ pub struct SkeletonAttr { neck_right: f32, weapon_x: f32, weapon_y: f32, - } impl SkeletonAttr { pub fn calculate_scale(body: &comp::humanoid::Body) -> f32 { @@ -152,7 +151,6 @@ impl Default for SkeletonAttr { neck_right: 1.0, weapon_x: 1.0, weapon_y: 1.0, - } } } diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index f52587ae84..713061f0bc 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -46,10 +46,14 @@ impl Animation for WieldAnimation { }, Some(ToolKind::Axe(_)) => { next.l_hand.offset = Vec3::new(-4.0, 3.0, 6.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(3.14 - 0.3) * Quaternion::rotation_y(-0.8); + next.l_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); next.l_hand.scale = Vec3::one() * 1.08; next.r_hand.offset = Vec3::new(-2.5, 9.0, 4.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(3.14 - 0.3)* Quaternion::rotation_y(-0.8); + next.r_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); next.r_hand.scale = Vec3::one() * 1.06; next.main.offset = Vec3::new(-6.0, 10.0, -1.0); next.main.ori = Quaternion::rotation_x(1.27) @@ -58,9 +62,9 @@ impl Animation for WieldAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(0.0, 0.0, 0.0); - next.control.ori = Quaternion::rotation_x( wave_ultra_slow_cos * 0.1) + next.control.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.1) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z( wave_ultra_slow * 0.1); + * Quaternion::rotation_z(wave_ultra_slow * 0.1); next.control.scale = Vec3::one(); }, Some(ToolKind::Hammer(_)) => { From b940cde5018b0c424a54df677b4059ce76b1f04d Mon Sep 17 00:00:00 2001 From: Songtronix Date: Fri, 20 Mar 2020 09:47:00 +0100 Subject: [PATCH 167/326] change(panic): mention the game version in panic --- voxygen/src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index f2a091daf0..d461267ecf 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -123,7 +123,7 @@ fn main() { and the events that led up to the panic as possible. \n\ Voxygen has logged information about the problem (including this \ - message) to the file {:#?}. Please include the contents of this \ + message) to the file {}. Please include the contents of this \ file in your bug report. \n\ > Error information\n\ @@ -131,13 +131,15 @@ fn main() { The information below is intended for developers and testers.\n\ \n\ Panic Payload: {:?}\n\ - PanicInfo: {}", - // TODO: Verify that this works + PanicInfo: {}\n\ + Game version: {} [{}]", Settings::get_settings_path() .join("voxygen-.log") .display(), reason, panic_info, + common::util::GIT_HASH.to_string(), + common::util::GIT_DATE.to_string() ); error!( From 835f3f5fe33c2a3ca8e5000be3df9dab54846072 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 20 Mar 2020 11:25:53 +0100 Subject: [PATCH 168/326] Arrows shouldn't turn into loot, staff shoots fireballs again --- common/src/comp/inventory/item.rs | 30 +++++++++++--- server/src/events/entity_manipulation.rs | 52 +++++++++++++----------- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 6f522eb094..6392756d71 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -114,11 +114,31 @@ impl ToolData { recover_duration: Duration::from_millis(400), base_damage: 5, }], - Staff(_) => vec![BasicMelee { - buildup_duration: Duration::from_millis(400), - recover_duration: Duration::from_millis(300), - base_damage: 7, - }], + Staff(_) => vec![ + BasicMelee { + buildup_duration: Duration::from_millis(400), + recover_duration: Duration::from_millis(300), + base_damage: 7, + }, + BasicRanged { + projectile: Projectile { + hit_ground: vec![projectile::Effect::Vanish], + hit_wall: vec![projectile::Effect::Vanish], + hit_entity: vec![ + projectile::Effect::Damage(HealthChange { + // TODO: This should not be fixed (?) + amount: -8, + cause: HealthSource::Item, + }), + projectile::Effect::Vanish, + ], + time_left: Duration::from_secs(5), + owner: None, + }, + projectile_body: Body::Object(object::Body::BoltFire), + recover_duration: Duration::from_millis(800), + }, + ], Shield(_) => vec![BasicBlock], Debug(kind) => match kind { DebugKind::Boost => vec![ diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 29c9c606e5..1de8f83dd7 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -91,29 +91,35 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc .write_storage::() .insert(entity, comp::CharacterState::default()); } else { - // Replace npc with loot - let _ = state - .ecs() - .write_storage() - .insert(entity, Body::Object(object::Body::Pouch)); - let _ = state.ecs().write_storage().insert( - entity, - assets::load_expect_cloned::("common.items.cheese"), - ); - state.ecs().write_storage::().remove(entity); - state.ecs().write_storage::().remove(entity); - state - .ecs() - .write_storage::() - .remove(entity); - state - .ecs() - .write_storage::() - .remove(entity); - state - .ecs() - .write_storage::() - .remove(entity); + if state.ecs().read_storage::().contains(entity) { + // Replace npc with loot + let _ = state + .ecs() + .write_storage() + .insert(entity, Body::Object(object::Body::Pouch)); + let _ = state.ecs().write_storage().insert( + entity, + assets::load_expect_cloned::("common.items.cheese"), + ); + state.ecs().write_storage::().remove(entity); + state.ecs().write_storage::().remove(entity); + state + .ecs() + .write_storage::() + .remove(entity); + state + .ecs() + .write_storage::() + .remove(entity); + state + .ecs() + .write_storage::() + .remove(entity); + } else { + if let Err(err) = state.delete_entity_recorded(entity) { + error!("Failed to delete destroyed entity: {:?}", err); + } + } // TODO: Add Delete(time_left: Duration) component /* From 4f1104a4176315eb649bb9698cae69c80ad825f7 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 20 Mar 2020 13:01:31 +0100 Subject: [PATCH 169/326] new loading screen bg --- assets/voxygen/background/bg_9.png | 3 +++ assets/voxygen/item_image_manifest.ron | 2 +- voxygen/src/menu/main/ui.rs | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 assets/voxygen/background/bg_9.png diff --git a/assets/voxygen/background/bg_9.png b/assets/voxygen/background/bg_9.png new file mode 100644 index 0000000000..9b1b455d0c --- /dev/null +++ b/assets/voxygen/background/bg_9.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:192ecc3b4f6d746d6033d1960b3a67ebea770fd8fb7e609633f2773ba62a576a +size 1518647 diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index 8d1c1a45a7..2d3b35706f 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -104,7 +104,7 @@ ), Armor(Shoulder(Plate0)): VoxTrans( "voxel.armor.shoulder.plate_left-0", - (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, ), //Leather0 Armor Armor(Chest(Leather0)): VoxTrans( diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index 79df8719c5..8732f36ac9 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -172,6 +172,7 @@ impl MainMenuUi { "voxygen.background.bg_6", "voxygen.background.bg_7", "voxygen.background.bg_8", + "voxygen.background.bg_9", ]; let mut rng = thread_rng(); From c630df7f9a705d42cae1ae88a763468b2527a4b5 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 20 Mar 2020 14:26:18 +0100 Subject: [PATCH 170/326] Ranged weapons now give xp on kill and also make enemies angry --- common/src/comp/inventory/item.rs | 4 ++-- common/src/comp/projectile.rs | 20 ++++++++++++++++++++ common/src/comp/stats.rs | 1 + common/src/states/basic_ranged.rs | 2 +- common/src/sys/agent.rs | 5 ++++- server/src/events/entity_manipulation.rs | 8 ++++++-- voxygen/src/ecs/sys/floater.rs | 7 +++---- 7 files changed, 37 insertions(+), 10 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 6392756d71..1a3898cf61 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -99,7 +99,7 @@ impl ToolData { projectile::Effect::Damage(HealthChange { // TODO: This should not be fixed (?) amount: -3, - cause: HealthSource::Item, + cause: HealthSource::Projectile { owner: None }, }), projectile::Effect::Vanish, ], @@ -128,7 +128,7 @@ impl ToolData { projectile::Effect::Damage(HealthChange { // TODO: This should not be fixed (?) amount: -8, - cause: HealthSource::Item, + cause: HealthSource::Projectile { owner: None }, }), projectile::Effect::Vanish, ], diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 27e997b08e..4c32bf0ee9 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -22,6 +22,26 @@ pub struct Projectile { pub owner: Option, } +impl Projectile { + pub fn set_owner(&mut self, new_owner: Uid) { + self.owner = Some(new_owner); + for e in self + .hit_ground + .iter_mut() + .chain(self.hit_wall.iter_mut()) + .chain(self.hit_entity.iter_mut()) + { + if let Effect::Damage(comp::HealthChange { + cause: comp::HealthSource::Projectile { owner, .. }, + .. + }) = e + { + *owner = Some(new_owner); + } + } + } +} + impl Component for Projectile { type Storage = FlaggedStorage>; } diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index e5e3e7e642..3e6d957fef 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -15,6 +15,7 @@ pub struct HealthChange { #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)] pub enum HealthSource { Attack { by: Uid }, // TODO: Implement weapon + Projectile { owner: Option }, Suicide, World, Revive, diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index 40412bb558..e8ce491676 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -49,7 +49,7 @@ impl CharacterBehavior for Data { } else if !self.exhausted { // Fire let mut projectile = self.projectile.clone(); - projectile.owner = Some(*data.uid); + projectile.set_owner(*data.uid); update.server_events.push_front(ServerEvent::Shoot { entity: data.entity, dir: data.inputs.look_dir, diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index fd7313af78..866bf00e5c 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -252,7 +252,10 @@ impl<'a> System<'a> for Sys { if let Some(stats) = stats.get(entity) { // Only if the attack was recent if stats.health.last_change.0 < 5.0 { - if let comp::HealthSource::Attack { by } = stats.health.last_change.1.cause { + if let comp::HealthSource::Attack { by } + | comp::HealthSource::Projectile { owner: Some(by) } = + stats.health.last_change.1.cause + { if !agent.activity.is_attack() { if let Some(attacker) = uid_allocator.retrieve_entity_internal(by.id()) { diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 1de8f83dd7..8d9de9215c 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -27,7 +27,9 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc // Chat message if let Some(player) = state.ecs().read_storage::().get(entity) { - let msg = if let HealthSource::Attack { by } = cause { + let msg = if let HealthSource::Attack { by } + | HealthSource::Projectile { owner: Some(by) } = cause + { state.ecs().entity_from_uid(by.into()).and_then(|attacker| { state .ecs() @@ -49,7 +51,9 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc // Give EXP to the killer if entity had stats let mut stats = state.ecs().write_storage::(); if let Some(entity_stats) = stats.get(entity).cloned() { - if let HealthSource::Attack { by } = cause { + if let HealthSource::Attack { by } | HealthSource::Projectile { owner: Some(by) } = + cause + { state.ecs().entity_from_uid(by.into()).map(|attacker| { if let Some(attacker_stats) = stats.get_mut(attacker) { // TODO: Discuss whether we should give EXP by Player diff --git a/voxygen/src/ecs/sys/floater.rs b/voxygen/src/ecs/sys/floater.rs index f9f05f5540..2c3e54a3dd 100644 --- a/voxygen/src/ecs/sys/floater.rs +++ b/voxygen/src/ecs/sys/floater.rs @@ -70,7 +70,7 @@ impl<'a> System<'a> for Sys { // (maybe health changes could be sent to the client as a list // of events) if match health.last_change.1.cause { - HealthSource::Attack { by } => { + HealthSource::Attack { by } | HealthSource::Projectile { owner: Some(by) } => { let by_me = my_uid.map_or(false, |&uid| by == uid); // If the attack was by me also reset this timer if by_me { @@ -80,11 +80,10 @@ impl<'a> System<'a> for Sys { }, HealthSource::Suicide => my_entity.0 == entity, HealthSource::World => my_entity.0 == entity, - HealthSource::Revive => false, - HealthSource::Command => true, HealthSource::LevelUp => my_entity.0 == entity, + HealthSource::Command => true, HealthSource::Item => true, - HealthSource::Unknown => false, + _ => false, } { hp_floater_list.floaters.push(HpFloater { timer: 0.0, From 68192738ee14d123577554093d84c0837fe6d715 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 20 Mar 2020 14:55:31 +0100 Subject: [PATCH 171/326] placement fix --- assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index e76b6e0de1..e0818d2729 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -62,11 +62,11 @@ ), Leather0: ( left: ( - vox_spec: ("armor.shoulder.leather_left-0", (-3.6, -3.5, 1.0)), + vox_spec: ("armor.shoulder.leather_left-0", (-3.2, -3.5, 1.0)), color: None ), right: ( - vox_spec: ("armor.shoulder.leather_right-0", (-2.6, -3.5, 1.0)), + vox_spec: ("armor.shoulder.leather_right-0", (-1.8, -3.5, 1.0)), color: None ) ), From 3ec2cc08b32bf38dd6cb63da221de09bb7a0237d Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 20 Mar 2020 15:05:40 +0100 Subject: [PATCH 172/326] Experimental tweeks to triplestrike --- common/src/comp/ability.rs | 4 -- common/src/comp/character_state.rs | 8 ++-- common/src/states/charge_attack.rs | 70 ---------------------------- common/src/states/mod.rs | 1 - common/src/states/triple_strike.rs | 8 +--- common/src/sys/character_behavior.rs | 1 - 6 files changed, 5 insertions(+), 87 deletions(-) delete mode 100644 common/src/states/charge_attack.rs diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index e631e197ad..de432913fa 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -30,7 +30,6 @@ pub enum CharacterAbility { }, BasicBlock, Roll, - ChargeAttack, TimedCombo { buildup_duration: Duration, recover_duration: Duration, @@ -134,9 +133,6 @@ impl From<&CharacterAbility> for CharacterState { CharacterAbility::Roll => CharacterState::Roll(roll::Data { remaining_duration: Duration::from_millis(600), }), - CharacterAbility::ChargeAttack => CharacterState::ChargeAttack(charge_attack::Data { - remaining_duration: Duration::from_millis(600), - }), CharacterAbility::TimedCombo { buildup_duration, recover_duration, diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 7d0fb6cc9b..7aea71d3aa 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{Energy, Ori, Pos, ToolData, Vel}, + comp::{Energy, Ori, Pos, Vel}, event::{LocalEvent, ServerEvent}, states::*, }; @@ -30,8 +30,6 @@ pub enum CharacterState { Equipping(equipping::Data), /// Player is holding a weapon and can perform other actions Wielding, - /// Player rushes forward and slams an enemy with their weapon - ChargeAttack(charge_attack::Data), /// A dodge where player can roll Roll(roll::Data), /// A basic melee attack (e.g. sword) @@ -57,8 +55,8 @@ impl CharacterState { | CharacterState::BasicMelee(_) | CharacterState::BasicRanged(_) | CharacterState::DashMelee(_) + | CharacterState::TripleStrike(_) | CharacterState::TimedCombo(_) - | CharacterState::ChargeAttack(_) | CharacterState::BasicBlock => true, _ => false, } @@ -77,7 +75,7 @@ impl CharacterState { | CharacterState::BasicRanged(_) | CharacterState::TimedCombo(_) | CharacterState::DashMelee(_) - | CharacterState::ChargeAttack(_) => true, + | CharacterState::TripleStrike(_) => true, _ => false, } } diff --git a/common/src/states/charge_attack.rs b/common/src/states/charge_attack.rs deleted file mode 100644 index 6c41e1ffeb..0000000000 --- a/common/src/states/charge_attack.rs +++ /dev/null @@ -1,70 +0,0 @@ -use super::utils::*; -use crate::{ - comp::{CharacterState::*, HealthChange, HealthSource, StateUpdate}, - event::ServerEvent, - sys::character_behavior::{CharacterBehavior, JoinData}, -}; -use std::{collections::VecDeque, time::Duration}; -use vek::Vec3; - -const CHARGE_SPEED: f32 = 20.0; - -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct Data { - /// How long the state has until exiting - pub remaining_duration: Duration, -} - -impl CharacterBehavior for Data { - fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - character: data.character.clone(), - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; - // Move player - update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) - + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) - + 1.5 * data.inputs.move_dir.try_normalized().unwrap_or_default()) - .try_normalized() - .unwrap_or_default() - * CHARGE_SPEED; - - // Check if hitting another entity - if let Some(uid_b) = data.physics.touch_entity { - // Send Damage event - update.server_events.push_front(ServerEvent::Damage { - uid: uid_b, - change: HealthChange { - amount: -20, - cause: HealthSource::Attack { by: *data.uid }, - }, - }); - - // Go back to wielding or idling - attempt_wield(data, &mut update); - return update; - } - - // Check if charge timed out or can't keep moving forward - if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0 - { - attempt_wield(data, &mut update); - return update; - } - - // Tick remaining-duration and keep charging - update.character = ChargeAttack(Data { - remaining_duration: self - .remaining_duration - .checked_sub(Duration::from_secs_f32(data.dt.0)) - .unwrap_or_default(), - }); - - update - } -} diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index ecffe1b987..1dcf09c211 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -2,7 +2,6 @@ pub mod basic_block; pub mod basic_melee; pub mod basic_ranged; pub mod boost; -pub mod charge_attack; pub mod climb; pub mod dash_melee; pub mod equipping; diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index ac1a7a14e8..9bbc7b285b 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -55,6 +55,8 @@ impl CharacterBehavior for Data { return update; } + handle_move(data, &mut update); + if self.stage < 3 { if new_stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { // Move player forward while in first third of each stage @@ -77,9 +79,6 @@ impl CharacterBehavior for Data { } else if new_stage_time_active > Duration::from_millis(STAGE_DURATION / 2) && !self.stage_exhausted { - // Allow player to influence orientation a little - handle_move(data, &mut update); - // Try to deal damage in second half of stage data.updater.insert(data.entity, Attacking { base_damage: self.base_damage * (self.stage as u32 + 1), @@ -95,9 +94,6 @@ impl CharacterBehavior for Data { stage_exhausted: true, }); } else if new_stage_time_active > Duration::from_millis(STAGE_DURATION) { - // Allow player to influence orientation a little - handle_move(data, &mut update); - update.character = CharacterState::TripleStrike(Data { base_damage: self.base_damage, stage: self.stage + 1, diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index c235e78388..d51cb719a7 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -180,7 +180,6 @@ impl<'a> System<'a> for Sys { CharacterState::Roll(data) => data.behavior(&j), CharacterState::Wielding => states::wielding::Data.behavior(&j), CharacterState::Equipping(data) => data.behavior(&j), - CharacterState::ChargeAttack(data) => data.behavior(&j), CharacterState::TripleStrike(data) => data.behavior(&j), CharacterState::BasicMelee(data) => data.behavior(&j), CharacterState::BasicRanged(data) => data.behavior(&j), From df858cb37027465aeff587c81980e9e8d6e55b5e Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 20 Mar 2020 15:45:36 +0100 Subject: [PATCH 173/326] Remove all warnings --- common/src/comp/ability.rs | 3 +-- common/src/states/basic_ranged.rs | 4 ++-- common/src/states/boost.rs | 2 +- common/src/states/dash_melee.rs | 1 - common/src/states/utils.rs | 2 +- common/src/sys/combat.rs | 1 - server/src/sys/entity_sync.rs | 4 ++-- server/src/sys/subscription.rs | 14 ++++---------- server/src/sys/terrain.rs | 2 +- voxygen/src/anim/character/attack.rs | 2 +- voxygen/src/hud/bag.rs | 2 +- voxygen/src/menu/char_selection/ui.rs | 12 ++---------- voxygen/src/scene/figure/load.rs | 2 +- voxygen/src/scene/figure/mod.rs | 10 +++------- voxygen/src/scene/simple.rs | 2 +- 15 files changed, 21 insertions(+), 42 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index de432913fa..a7894238a6 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1,11 +1,10 @@ use crate::{ - comp::{Body, CharacterState, EnergySource, Item, Projectile, StateUpdate, ToolData}, + comp::{Body, CharacterState, EnergySource, Item, Projectile, StateUpdate}, states::*, sys::character_behavior::JoinData, }; use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage}; use std::time::Duration; -use vek::vec::Vec3; #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] pub enum CharacterAbility { diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index e8ce491676..f2b9f3c73a 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -1,7 +1,7 @@ use crate::{ - comp::{Attacking, Body, CharacterState, EnergySource, Gravity, Projectile, StateUpdate}, + comp::{Body, CharacterState, Gravity, Projectile, StateUpdate}, event::ServerEvent, - states::{utils::*, wielding}, + states::utils::*, sys::character_behavior::*, }; use std::{collections::VecDeque, time::Duration}; diff --git a/common/src/states/boost.rs b/common/src/states/boost.rs index 7b060ed9cf..5f0f855557 100644 --- a/common/src/states/boost.rs +++ b/common/src/states/boost.rs @@ -1,6 +1,6 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, StateUpdate}, - states::{utils::*, wielding}, + states::utils::*, sys::character_behavior::*, }; use std::{collections::VecDeque, time::Duration}; diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index e4d495ded2..c52447218f 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -1,6 +1,5 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, StateUpdate}, - states::utils::*, sys::character_behavior::*, }; use std::{collections::VecDeque, time::Duration}; diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 0ee196d5df..67eac06545 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{CharacterState, EnergySource, ItemKind::Tool, StateUpdate, ToolData}, + comp::{CharacterState, ItemKind::Tool, StateUpdate, ToolData}, event::LocalEvent, states::*, sys::{character_behavior::JoinData, phys::GRAVITY}, diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index f6cdb6ca3d..7a910f20cd 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -14,7 +14,6 @@ use vek::*; const BLOCK_EFFICIENCY: f32 = 0.9; const ATTACK_RANGE: f32 = 3.5; -const ATTACK_ANGLE: f32 = 70.0; const BLOCK_ANGLE: f32 = 180.0; /// This system is responsible for handling accepted inputs like moving or diff --git a/server/src/sys/entity_sync.rs b/server/src/sys/entity_sync.rs index d499a61ec4..619458d61c 100644 --- a/server/src/sys/entity_sync.rs +++ b/server/src/sys/entity_sync.rs @@ -7,7 +7,7 @@ use crate::{ Tick, }; use common::{ - comp::{CharacterState, ForceUpdate, Inventory, InventoryUpdate, Last, Ori, Pos, Vel}, + comp::{ForceUpdate, Inventory, InventoryUpdate, Last, Ori, Pos, Vel}, msg::ServerMsg, region::{Event as RegionEvent, RegionMap}, state::TimeOfDay, @@ -112,7 +112,7 @@ impl<'a> System<'a> for Sys { continue; } let entity = entities.entity(*id); - if let Some((uid, pos, vel, ori)) = uids.get(entity).and_then(|uid| { + if let Some((_uid, pos, vel, ori)) = uids.get(entity).and_then(|uid| { positions.get(entity).map(|pos| { (uid, pos, velocities.get(entity), orientations.get(entity)) }) diff --git a/server/src/sys/subscription.rs b/server/src/sys/subscription.rs index 07a8a15315..36a2a64b9c 100644 --- a/server/src/sys/subscription.rs +++ b/server/src/sys/subscription.rs @@ -4,7 +4,7 @@ use super::{ }; use crate::client::{self, Client, RegionSubscription}; use common::{ - comp::{CharacterState, Ori, Player, Pos, Vel}, + comp::{Ori, Player, Pos, Vel}, msg::ServerMsg, region::{region_in_vd, regions_in_vd, Event as RegionEvent, RegionMap}, sync::Uid, @@ -29,7 +29,6 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Pos>, ReadStorage<'a, Vel>, ReadStorage<'a, Ori>, - ReadStorage<'a, CharacterState>, ReadStorage<'a, Player>, WriteStorage<'a, Client>, WriteStorage<'a, RegionSubscription>, @@ -47,7 +46,6 @@ impl<'a> System<'a> for Sys { positions, velocities, orientations, - character_states, players, mut clients, mut subscriptions, @@ -182,17 +180,15 @@ impl<'a> System<'a> for Sys { // already within the set of subscribed regions if subscription.regions.insert(key.clone()) { if let Some(region) = region_map.get(key) { - for (uid, pos, vel, ori, character_state, _, entity) in ( - &uids, + for (pos, vel, ori, _, entity) in ( &positions, velocities.maybe(), orientations.maybe(), - character_states.maybe(), region.entities(), &entities, ) .join() - .filter(|(_, _, _, _, _, _, e)| *e != client_entity) + .filter(|(_, _, _, _, e)| *e != client_entity) { // Send message to create entity and tracked components and physics // components @@ -239,12 +235,10 @@ pub fn initialize_region_subscription(world: &World, entity: specs::Entity) { let tracked_comps = TrackedComps::fetch(world); for key in ®ions { if let Some(region) = region_map.get(*key) { - for (uid, pos, vel, ori, character_state, _, entity) in ( - &tracked_comps.uid, + for (pos, vel, ori, _, entity) in ( &world.read_storage::(), // We assume all these entities have a position world.read_storage::().maybe(), world.read_storage::().maybe(), - world.read_storage::().maybe(), region.entities(), &world.entities(), ) diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 0265f63311..f47a4e7a08 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -2,7 +2,7 @@ use super::SysTimer; use crate::{chunk_generator::ChunkGenerator, client::Client, Tick}; use common::{ assets, - comp::{self, humanoid, item, CharacterAbility, Item, ItemConfig, Player, Pos}, + comp::{self, CharacterAbility, Item, ItemConfig, Player, Pos}, event::{EventBus, ServerEvent}, generation::EntityKind, msg::ServerMsg, diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index b866629bbf..767b6dfa9d 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -23,7 +23,7 @@ impl Animation for AttackAnimation { let mut next = (*skeleton).clone(); let lab = 1.0; - let test = (anim_time as f32 * 16.0 * lab as f32).cos(); + //let test = (anim_time as f32 * 16.0 * lab as f32).cos(); let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index d2fe381091..82db8367f5 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -8,7 +8,7 @@ use crate::{ ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, }; use client::Client; -use common::comp::{item, ItemKind, Stats}; +use common::comp::{ItemKind, Stats}; use conrod_core::{ color, image, widget::{self, Button, Image, Rectangle, Text}, diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index f9cfa9efdd..bbeeb524dc 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -320,10 +320,7 @@ impl CharSelectionUi { match &self.mode { Mode::Select(data) => data.clone(), Mode::Create { - name, - body, - loadout, - tool, + name, body, tool, .. } => Some(CharacterData { name: name.clone(), body: comp::Body::Humanoid(body.clone()), @@ -335,12 +332,7 @@ impl CharSelectionUi { pub fn get_loadout(&mut self) -> Option<&comp::Loadout> { match &mut self.mode { Mode::Select(_) => None, - Mode::Create { - name, - body, - loadout, - tool, - } => { + Mode::Create { loadout, tool, .. } => { loadout.active_item = tool.map(|tool| comp::ItemConfig { item: (*load_expect::(tool)).clone(), primary_ability: None, diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 75758fdbe1..e27532161e 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -18,7 +18,7 @@ use common::{ object, quadruped_medium::{BodyType as QMBodyType, Species as QMSpecies}, quadruped_small::{BodyType as QSBodyType, Species as QSSpecies}, - Item, ItemKind, Loadout, + ItemKind, Loadout, }, figure::{DynaUnionizer, MatSegment, Material, Segment}, }; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index aca487e7c2..49718623cd 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -20,8 +20,7 @@ use crate::{ }; use common::{ comp::{ - Body, CharacterState, ItemKind, Last, Loadout, Ori, PhysicsState, Pos, Scale, Stats, - ToolData, Vel, + Body, CharacterState, ItemKind, Last, Loadout, Ori, PhysicsState, Pos, Scale, Stats, Vel, }, state::State, terrain::TerrainChunk, @@ -1370,7 +1369,7 @@ impl FigureMgr { let character_state_storage = state.read_storage::(); let character_state = character_state_storage.get(player_entity); - for (entity, _, _, body, stats, loadout, _) in ( + for (entity, _, _, body, _, loadout, _) in ( &ecs.entities(), &ecs.read_storage::(), ecs.read_storage::().maybe(), @@ -1381,7 +1380,7 @@ impl FigureMgr { ) .join() // Don't render dead entities - .filter(|(_, _, _, _, stats, loadout, _)| stats.map_or(true, |s| !s.is_dead)) + .filter(|(_, _, _, _, stats, _, _)| stats.map_or(true, |s| !s.is_dead)) { let is_player = entity == player_entity; let player_camera_mode = if is_player { @@ -1389,9 +1388,6 @@ impl FigureMgr { } else { CameraMode::default() }; - let active_item_kind = loadout - .and_then(|l| l.active_item.as_ref()) - .map(|i| &i.item.kind); let character_state = if is_player { character_state } else { None }; let FigureMgr { diff --git a/voxygen/src/scene/simple.rs b/voxygen/src/scene/simple.rs index 112f9ba565..abb47585fc 100644 --- a/voxygen/src/scene/simple.rs +++ b/voxygen/src/scene/simple.rs @@ -15,7 +15,7 @@ use crate::{ window::{Event, PressState}, }; use common::{ - comp::{humanoid, Body, ItemKind, Loadout}, + comp::{humanoid, Body, Loadout}, terrain::BlockKind, vol::{BaseVol, ReadVol, Vox}, }; From 44ec09a8e7466ac3245fba1b0a9b74001fdb1b98 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 20 Mar 2020 17:15:09 +0100 Subject: [PATCH 174/326] Go to idle state when picking items up --- common/src/sys/controller.rs | 19 ++++++++++++++++--- voxygen/src/scene/mod.rs | 2 ++ voxygen/src/session.rs | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index 4a0e033651..9b3718d849 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{ControlEvent, Controller}, + comp::{CharacterState, ControlEvent, Controller}, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, sync::{Uid, UidAllocator}, @@ -22,15 +22,27 @@ impl<'a> System<'a> for Sys { Read<'a, EventBus>, Read<'a, DeltaTime>, WriteStorage<'a, Controller>, + WriteStorage<'a, CharacterState>, ReadStorage<'a, Uid>, ); fn run( &mut self, - (entities, uid_allocator, server_bus, _local_bus, _dt, mut controllers, uids): Self::SystemData, + ( + entities, + uid_allocator, + server_bus, + _local_bus, + _dt, + mut controllers, + mut character_states, + uids, + ): Self::SystemData, ) { let mut server_emitter = server_bus.emitter(); - for (entity, _uid, controller) in (&entities, &uids, &mut controllers).join() { + for (entity, _uid, controller, character_state) in + (&entities, &uids, &mut controllers, &mut character_states).join() + { let inputs = &mut controller.inputs; // Update `inputs.move_dir`. @@ -59,6 +71,7 @@ impl<'a> System<'a> for Sys { }, ControlEvent::Unmount => server_emitter.emit(ServerEvent::Unmount(entity)), ControlEvent::InventoryManip(manip) => { + *character_state = CharacterState::Idle; server_emitter.emit(ServerEvent::InventoryManip(entity, manip)) }, /*ControlEvent::Respawn => * server_emitter.emit(ServerEvent::Unmount(entity)), */ diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 947fcb3ed3..ae8bd95089 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -126,6 +126,8 @@ impl Scene { /// Set the block position that the player is interacting with pub fn set_select_pos(&mut self, pos: Option>) { self.select_pos = pos; } + pub fn select_pos(&self) -> Option> { self.select_pos } + /// Handle an incoming user input event (e.g.: cursor moved, key pressed, /// window closed). /// diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index d50203726b..64571ae644 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -269,7 +269,8 @@ impl PlayState for SessionState { } else { self.inputs.secondary.set_state(state); - if let Some(select_pos) = select_pos { + // Check for select_block that is highlighted + if let Some(select_pos) = self.scene.select_pos() { client.collect_block(select_pos); } } From 4153df66ea1aa62708c04f5b5baac9155d56e220 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 20 Mar 2020 20:52:32 +0100 Subject: [PATCH 175/326] stat icons, frame colours --- .../voxygen/element/frames/server_frame.vox | 4 +-- assets/voxygen/element/frames/window.vox | 4 +-- assets/voxygen/element/frames/window_3.vox | 4 +-- assets/voxygen/element/frames/window_4.vox | 4 +-- assets/voxygen/element/icons/endurance.png | 3 ++ assets/voxygen/element/icons/fitness.png | 3 ++ assets/voxygen/element/icons/willpower.png | 3 ++ voxygen/src/hud/bag.rs | 27 +++++++++++++--- voxygen/src/hud/img_ids.rs | 11 ++++--- voxygen/src/hud/social.rs | 7 ++++- voxygen/src/hud/spell.rs | 3 +- voxygen/src/menu/char_selection/ui.rs | 31 +++++++++---------- voxygen/src/menu/main/ui.rs | 4 +++ 13 files changed, 72 insertions(+), 36 deletions(-) create mode 100644 assets/voxygen/element/icons/endurance.png create mode 100644 assets/voxygen/element/icons/fitness.png create mode 100644 assets/voxygen/element/icons/willpower.png diff --git a/assets/voxygen/element/frames/server_frame.vox b/assets/voxygen/element/frames/server_frame.vox index a7b0744a2d..275e25e4b9 100644 --- a/assets/voxygen/element/frames/server_frame.vox +++ b/assets/voxygen/element/frames/server_frame.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:602bbe3f01982feda6c79da82b5000ed151da1e5e59be0f75f19c9bc7b86af66 -size 1624 +oid sha256:d64f764aa7ea65bf21201a7c0574486c7c73425ac94872cd4c5d27845f056029 +size 56107 diff --git a/assets/voxygen/element/frames/window.vox b/assets/voxygen/element/frames/window.vox index 9a9b5957b4..cc1ec0d0e2 100644 --- a/assets/voxygen/element/frames/window.vox +++ b/assets/voxygen/element/frames/window.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:67e0e42e279400c50f41c2fe8e0a3558885fa852f105c8c1eb38ec4c5eabd54e -size 153836 +oid sha256:3e00dce196b1454d243126fca7ce2b5ea3c1f23391a4debec2bd774cff6dc22d +size 208320 diff --git a/assets/voxygen/element/frames/window_3.vox b/assets/voxygen/element/frames/window_3.vox index af01983c4d..534f4fe15e 100644 --- a/assets/voxygen/element/frames/window_3.vox +++ b/assets/voxygen/element/frames/window_3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:664d22942cb76f938ea4b7b68efc18dc9e2305c3e667ab7ea5ad256b2b42cea0 -size 241316 +oid sha256:502eb49272f79935ccd309a53c67db691f64736e2aa18814e51f75e86a83e6cd +size 252692 diff --git a/assets/voxygen/element/frames/window_4.vox b/assets/voxygen/element/frames/window_4.vox index 6f69e5b24b..5ef43b401e 100644 --- a/assets/voxygen/element/frames/window_4.vox +++ b/assets/voxygen/element/frames/window_4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3e679e7e2147fb31fc03f3fcc26bd174e2334d6f8f10bdbba143e0d2b3114e2c -size 2440 +oid sha256:e1fd9cf331ae3bf6a45de507b5e28072fac2566a65086334dc0de7e1932ba5f8 +size 56924 diff --git a/assets/voxygen/element/icons/endurance.png b/assets/voxygen/element/icons/endurance.png new file mode 100644 index 0000000000..ede3667e9b --- /dev/null +++ b/assets/voxygen/element/icons/endurance.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6376aa744efcbb3acf5cb5e81ec271522185239c030a4071f6c67f3b15903f33 +size 550 diff --git a/assets/voxygen/element/icons/fitness.png b/assets/voxygen/element/icons/fitness.png new file mode 100644 index 0000000000..6e68775f5d --- /dev/null +++ b/assets/voxygen/element/icons/fitness.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f40b0799bff94dfd23f2b172e672d480a86a86363ad5ce4c969c97762f63d760 +size 697 diff --git a/assets/voxygen/element/icons/willpower.png b/assets/voxygen/element/icons/willpower.png new file mode 100644 index 0000000000..7bf2a8328c --- /dev/null +++ b/assets/voxygen/element/icons/willpower.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cada9e202c460f1b23eb267114fbbe0ea06daefd91010feff6fcb8dc28723b6f +size 784 diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 82db8367f5..902cd1cb50 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -14,6 +14,7 @@ use conrod_core::{ widget::{self, Button, Image, Rectangle, Text}, widget_ids, Color, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon, }; +//use const_tweaker::tweak; widget_ids! { pub struct Ids { @@ -84,6 +85,9 @@ widget_ids! { tabard_ico, mainhand_ico, offhand_ico, + end_ico, + fit_ico, + wp_ico, } } @@ -144,10 +148,10 @@ pub enum Event { Stats, Close, } - -//#[const_tweaker::tweak(min = -10.0, max = 10.0, step = 1.0)] -//const X: f64 = 10.0; - +/* +#[tweak(min = -100.0, max = 20.0, step = 1.0)] +const END_X: f64 = 10.0; +*/ impl<'a> Widget for Bag<'a> { type Event = Option; type State = State; @@ -559,6 +563,21 @@ impl<'a> Widget for Bag<'a> { .font_size(self.fonts.cyri.scale(16)) .color(TEXT_COLOR) .set(state.ids.statnames, ui); + Image::new(self.imgs.endurance_ico) + .w_h(30.0, 30.0) + .top_left_with_margins_on(state.ids.statnames, -10.0, -40.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.end_ico, ui); + Image::new(self.imgs.fitness_ico) + .w_h(30.0, 30.0) + .down_from(state.ids.end_ico, 10.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.fit_ico, ui); + Image::new(self.imgs.willpower_ico) + .w_h(30.0, 30.0) + .down_from(state.ids.fit_ico, 10.0) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.wp_ico, ui); Text::new(&format!( "{}\n\n{}\n\n{}", diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index cc4ca58dd4..32d025b463 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -187,9 +187,6 @@ image_ids! { divider: "voxygen.element.frames.divider_charwindow", // Close button - close_button: "voxygen.element.buttons.x", - close_button_hover: "voxygen.element.buttons.x_hover", - close_button_press: "voxygen.element.buttons.x_press", // Items @@ -227,6 +224,9 @@ image_ids! { close_btn: "voxygen.element.buttons.close_btn", close_btn_hover: "voxygen.element.buttons.close_btn_hover", close_btn_press: "voxygen.element.buttons.close_btn_press", + close_button: "voxygen.element.buttons.close_btn", + close_button_hover: "voxygen.element.buttons.close_btn_hover", + close_button_press: "voxygen.element.buttons.close_btn_press", // Inventory coin_ico: "voxygen.element.icons.coin", @@ -258,8 +258,9 @@ image_ids! { necklace_bg: "voxygen.element.icons.necklace", mainhand_bg: "voxygen.element.icons.mainhand", offhand_bg: "voxygen.element.icons.offhand", - - + willpower_ico: "voxygen.element.icons.willpower", + endurance_ico: "voxygen.element.icons.endurance", + fitness_ico: "voxygen.element.icons.fitness", not_found:"voxygen.element.not_found", diff --git a/voxygen/src/hud/social.rs b/voxygen/src/hud/social.rs index 4d6588246e..c278ec1963 100644 --- a/voxygen/src/hud/social.rs +++ b/voxygen/src/hud/social.rs @@ -1,4 +1,4 @@ -use super::{img_ids::Imgs, Show, TEXT_COLOR, TEXT_COLOR_3}; +use super::{img_ids::Imgs, Show, TEXT_COLOR, TEXT_COLOR_3, UI_MAIN}; use crate::{i18n::VoxygenLocalization, ui::fonts::ConrodVoxygenFonts}; use client::{self, Client}; @@ -90,6 +90,7 @@ impl<'a> Widget for Social<'a> { Image::new(self.imgs.window_3) .top_left_with_margins_on(ui.window, 200.0, 25.0) + .color(Some(UI_MAIN)) .w_h(103.0 * 4.0, 122.0 * 4.0) .set(ids.social_frame, ui); @@ -131,6 +132,7 @@ impl<'a> Widget for Social<'a> { Image::new(self.imgs.social_frame) .w_h(99.0 * 4.0, 100.0 * 4.0) .mid_bottom_of(ids.align) + .color(Some(UI_MAIN)) .set(ids.frame, ui); // Online Tab @@ -156,6 +158,7 @@ impl<'a> Widget for Social<'a> { .label_font_size(self.fonts.cyri.scale(14)) .label_font_id(self.fonts.cyri.conrod_id) .parent(ids.frame) + .color(UI_MAIN) .label_color(TEXT_COLOR) .set(ids.online_tab, ui) .was_clicked() @@ -222,6 +225,7 @@ impl<'a> Widget for Social<'a> { .label_font_size(self.fonts.cyri.scale(14)) .label_font_id(self.fonts.cyri.conrod_id) .parent(ids.frame) + .color(UI_MAIN) .label_color(TEXT_COLOR_3) .set(ids.friends_tab, ui) .was_clicked() @@ -253,6 +257,7 @@ impl<'a> Widget for Social<'a> { .parent(ids.frame) .label_font_size(self.fonts.cyri.scale(14)) .label_font_id(self.fonts.cyri.conrod_id) + .color(UI_MAIN) .label_color(TEXT_COLOR_3) .set(ids.faction_tab, ui) .was_clicked() diff --git a/voxygen/src/hud/spell.rs b/voxygen/src/hud/spell.rs index 552c0c1074..a35d4bf029 100644 --- a/voxygen/src/hud/spell.rs +++ b/voxygen/src/hud/spell.rs @@ -1,4 +1,4 @@ -use super::{img_ids::Imgs, Show, TEXT_COLOR}; +use super::{img_ids::Imgs, Show, TEXT_COLOR, UI_MAIN}; use crate::ui::fonts::ConrodVoxygenFonts; use conrod_core::{ color, @@ -77,6 +77,7 @@ impl<'a> Widget for Spell<'a> { Image::new(self.imgs.window_3) .top_left_with_margins_on(ui.window, 200.0, 25.0) .w_h(103.0 * 4.0, 122.0 * 4.0) + .color(Some(UI_MAIN)) .set(state.spell_frame, ui); // X-Button diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index bbeeb524dc..3963298e42 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -12,7 +12,7 @@ use crate::{ }; use client::Client; use common::{ - assets::{load_expect, load_glob}, + assets::load_expect, comp::{self, humanoid}, }; use conrod_core::{ @@ -22,7 +22,7 @@ use conrod_core::{ widget::{text_box::Event as TextBoxEvent, Button, Image, Rectangle, Scrollbar, Text, TextBox}, widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, UiCell, Widget, }; -use std::{borrow::Borrow, sync::Arc}; +use std::sync::Arc; const STARTER_HAMMER: &str = "common.items.weapons.starter_hammer"; const STARTER_BOW: &str = "common.items.weapons.starter_bow"; @@ -31,6 +31,10 @@ const STARTER_STAFF: &str = "common.items.weapons.starter_staff"; const STARTER_SWORD: &str = "common.items.weapons.starter_sword"; const STARTER_DAGGER: &str = "common.items.weapons.starter_dagger"; +// UI Color-Theme +const UI_MAIN: Color = Color::Rgba(0.61, 0.70, 0.70, 1.0); // Greenish Blue +//const UI_HIGHLIGHT_0: Color = Color::Rgba(0.79, 1.09, 1.09, 1.0); + widget_ids! { struct Ids { // Background and logo @@ -383,6 +387,7 @@ impl CharSelectionUi { Image::new(self.imgs.info_frame) .w_h(550.0, 150.0) .middle_of(self.ids.info_bg) + .color(Some(UI_MAIN)) .set(self.ids.info_frame, ui_widgets); Rectangle::fill_with([275.0, 150.0], color::TRANSPARENT) .bottom_left_with_margins_on(self.ids.info_frame, 0.0, 0.0) @@ -450,6 +455,7 @@ impl CharSelectionUi { .set(self.ids.server_frame_bg, ui_widgets); Image::new(self.imgs.server_frame) .w_h(400.0, 100.0) + .color(Some(UI_MAIN)) .middle_of(self.ids.server_frame_bg) .set(self.ids.server_frame, ui_widgets); @@ -460,6 +466,7 @@ impl CharSelectionUi { Image::new(self.imgs.charlist_frame) .w_h(400.0, 800.0) .middle_of(self.ids.charlist_bg) + .color(Some(UI_MAIN)) .set(self.ids.charlist_frame, ui_widgets); Rectangle::fill_with([386.0, 783.0], color::TRANSPARENT) .middle_of(self.ids.charlist_bg) @@ -469,7 +476,7 @@ impl CharSelectionUi { Scrollbar::y_axis(self.ids.charlist_alignment) .thickness(5.0) .auto_hide(true) - .rgba(0.0, 0.0, 0., 0.0) + .color(UI_MAIN) .set(self.ids.selection_scrollbar, ui_widgets); // Server Name Text::new(&client.server_info.name) @@ -757,6 +764,7 @@ impl CharSelectionUi { Image::new(self.imgs.charlist_frame) .w_h(400.0, ui_widgets.win_h - ui_widgets.win_h * 0.19) .middle_of(self.ids.creation_bg) + .color(Some(UI_MAIN)) .set(self.ids.charlist_frame, ui_widgets); Rectangle::fill_with( [386.0, ui_widgets.win_h - ui_widgets.win_h * 0.19], @@ -864,13 +872,6 @@ impl CharSelectionUi { "", &tooltip_human, ) - /*.tooltip_image( - if let humanoid::BodyType::Male = body.body_type { - self.imgs.human_m - } else { - self.imgs.human_f - }, - )*/ .set(self.ids.race_1, ui_widgets) .was_clicked() { @@ -1029,10 +1030,6 @@ impl CharSelectionUi { { *tool = Some(STARTER_HAMMER); } - // REMOVE THIS AFTER IMPLEMENTATION - /*Rectangle::fill_with([67.0, 67.0], color::rgba(0.0, 0.0, 0.0, 0.8)) - .middle_of(self.ids.hammer) - .set(self.ids.hammer_grey, ui_widgets);*/ // Bow Image::new(self.imgs.bow) @@ -1292,7 +1289,7 @@ impl CharSelectionUi { .set(self.ids.beard_slider, ui_widgets); } // Chest - let armor = load_glob::("common.items.armor.chest.*") + /*let armor = load_glob::("common.items.armor.chest.*") .expect("Unable to load armor!"); if let Some(new_val) = char_slider( self.ids.beard_slider, @@ -1313,7 +1310,7 @@ impl CharSelectionUi { ui_widgets, ) { loadout.chest = Some((*armor[new_val]).clone()); - } + }*/ // Pants /*let current_pants = body.pants; if let Some(new_val) = char_slider( @@ -1331,7 +1328,7 @@ impl CharSelectionUi { body.pants = humanoid::ALL_PANTS[new_val]; }*/ Rectangle::fill_with([20.0, 20.0], color::TRANSPARENT) - .down_from(self.ids.chest_slider, 15.0) + .down_from(self.ids.beard_slider, 15.0) .set(self.ids.space, ui_widgets); if to_select { diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index 8732f36ac9..ea427879c8 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -20,6 +20,10 @@ use conrod_core::{ use rand::{seq::SliceRandom, thread_rng}; use std::time::Duration; +// UI Color-Theme +/*const UI_MAIN: Color = Color::Rgba(0.61, 0.70, 0.70, 1.0); // Greenish Blue +const UI_HIGHLIGHT_0: Color = Color::Rgba(0.79, 1.09, 1.09, 1.0);*/ + widget_ids! { struct Ids { // Background and logo From 0cdb80427d96cb9b1649e531d537cda38f3859da Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Fri, 20 Mar 2020 15:03:29 -0700 Subject: [PATCH 176/326] better triple_strike --- common/src/comp/ability.rs | 1 + common/src/states/triple_strike.rs | 66 ++++++++++++++++++------------ common/src/states/utils.rs | 4 ++ voxygen/src/scene/figure/mod.rs | 9 +++- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index a7894238a6..a114326870 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -150,6 +150,7 @@ impl From<&CharacterAbility> for CharacterState { stage: 0, stage_exhausted: false, stage_time_active: Duration::default(), + should_transition: true, }) }, } diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 9bbc7b285b..41414796bb 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -10,7 +10,7 @@ use vek::vec::Vec2; const STAGE_DURATION: u64 = 600; const BASE_ACCEL: f32 = 200.0; -const BASE_SPEED: f32 = 250.0; +const BASE_SPEED: f32 = 25.0; /// ### A sequence of 3 incrementally increasing attacks. /// /// While holding down the `primary` button, perform a series of 3 attacks, @@ -27,6 +27,8 @@ pub struct Data { pub stage_time_active: Duration, /// Whether current stage has exhausted its attack pub stage_exhausted: bool, + /// Whether to go to next stage + pub should_transition: bool, } impl CharacterBehavior for Data { @@ -41,26 +43,28 @@ impl CharacterBehavior for Data { server_events: VecDeque::new(), }; - let new_stage_time_active = self + let stage_time_active = self .stage_time_active .checked_add(Duration::from_secs_f32(data.dt.0)) .unwrap_or(Duration::default()); + let mut should_transition = self.should_transition; + // If player stops holding input, if !data.inputs.primary.is_pressed() { - // Done - update.character = CharacterState::Wielding; - // Make sure attack component is removed - data.updater.remove::(data.entity); - return update; + // // Done + // update.character = CharacterState::Wielding; + // // Make sure attack component is removed + // data.updater.remove::(data.entity); + // return update; + + should_transition = false; } - handle_move(data, &mut update); - if self.stage < 3 { - if new_stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { + // Handling movement + if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { // Move player forward while in first third of each stage - // Move player according to move_dir if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) { update.vel.0 = update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * BASE_ACCEL; @@ -69,14 +73,12 @@ impl CharacterBehavior for Data { update.vel.0 = update.vel.0.normalized() * BASE_SPEED; } }; + } else { + handle_orientation(data, &mut update); + } - update.character = CharacterState::TripleStrike(Data { - base_damage: self.base_damage, - stage: self.stage, - stage_time_active: new_stage_time_active, - stage_exhausted: false, - }); - } else if new_stage_time_active > Duration::from_millis(STAGE_DURATION / 2) + // Handling attacking + if stage_time_active > Duration::from_millis(STAGE_DURATION / 2) && !self.stage_exhausted { // Try to deal damage in second half of stage @@ -90,22 +92,32 @@ impl CharacterBehavior for Data { update.character = CharacterState::TripleStrike(Data { base_damage: self.base_damage, stage: self.stage, - stage_time_active: new_stage_time_active, + stage_time_active, stage_exhausted: true, + should_transition, }); - } else if new_stage_time_active > Duration::from_millis(STAGE_DURATION) { - update.character = CharacterState::TripleStrike(Data { - base_damage: self.base_damage, - stage: self.stage + 1, - stage_time_active: Duration::default(), - stage_exhausted: false, - }); + } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { + if should_transition { + update.character = CharacterState::TripleStrike(Data { + base_damage: self.base_damage, + stage: self.stage + 1, + stage_time_active: Duration::default(), + stage_exhausted: false, + should_transition, + }); + } else { + // Done + update.character = CharacterState::Wielding; + // Make sure attack component is removed + data.updater.remove::(data.entity); + } } else { update.character = CharacterState::TripleStrike(Data { base_damage: self.base_damage, stage: self.stage, - stage_time_active: new_stage_time_active, + stage_time_active, stage_exhausted: self.stage_exhausted, + should_transition, }); } } else { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 67eac06545..a02d5ad99f 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -53,6 +53,10 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate) { } } + handle_orientation(data, update); +} + +pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate) { // Set direction based on move direction let ori_dir = if update.character.is_attack() || update.character.is_block() { Vec2::from(data.inputs.look_dir).normalized() diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 49718623cd..4f80df76f6 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -504,7 +504,14 @@ impl FigureMgr { ) }, CharacterState::TripleStrike(s) => match s.stage { - 0 | 2 => anim::character::AttackAnimation::update_skeleton( + 0 => anim::character::AttackAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ), + 1 => anim::character::AttackAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.state_time, From ae175e57f3d1639caccf946ce5b883973de07922 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Fri, 20 Mar 2020 15:20:14 -0700 Subject: [PATCH 177/326] Tweaking consts --- common/src/states/triple_strike.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 41414796bb..05971a2c0f 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -9,7 +9,8 @@ use vek::vec::Vec2; // In millis const STAGE_DURATION: u64 = 600; -const BASE_ACCEL: f32 = 200.0; +const INITIAL_ACCEL: f32 = 200.0; +const SECONDARY_ACCEL: f32 = 100.0; const BASE_SPEED: f32 = 25.0; /// ### A sequence of 3 incrementally increasing attacks. /// @@ -64,10 +65,16 @@ impl CharacterBehavior for Data { if self.stage < 3 { // Handling movement if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { + let adjusted_accel = if self.stage == 0 { + INITIAL_ACCEL + } else { + SECONDARY_ACCEL + }; + // Move player forward while in first third of each stage if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) { update.vel.0 = - update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * BASE_ACCEL; + update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * adjusted_accel; let mag2 = update.vel.0.magnitude_squared(); if mag2 > BASE_SPEED.powf(2.0) { update.vel.0 = update.vel.0.normalized() * BASE_SPEED; From a0785e693a68f9becb942073a9f2cdd304c03e8c Mon Sep 17 00:00:00 2001 From: jshipsey Date: Fri, 20 Mar 2020 18:54:27 -0400 Subject: [PATCH 178/326] shooting anim state, cast anim, small tweaks --- voxygen/src/anim/character/attack.rs | 45 ++--- voxygen/src/anim/character/mod.rs | 5 +- voxygen/src/anim/character/shoot.rs | 289 +++++++++++++++++++++++++++ voxygen/src/anim/character/wield.rs | 40 ++-- voxygen/src/scene/figure/mod.rs | 2 +- 5 files changed, 331 insertions(+), 50 deletions(-) create mode 100644 voxygen/src/anim/character/shoot.rs diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index 767b6dfa9d..cb74158a33 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -23,7 +23,6 @@ impl Animation for AttackAnimation { let mut next = (*skeleton).clone(); let lab = 1.0; - //let test = (anim_time as f32 * 16.0 * lab as f32).cos(); let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); @@ -114,9 +113,11 @@ impl Animation for AttackAnimation { next.main.scale = Vec3::one(); }, Some(ToolKind::Hammer(_)) => { - next.l_hand.offset = Vec3::new(0.0, 1.0, 5.0); + next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); + + //0,1,5 next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.04; + next.l_hand.scale = Vec3::one() * 1.05; next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); next.r_hand.ori = Quaternion::rotation_x(1.27); next.r_hand.scale = Vec3::one() * 1.05; @@ -133,29 +134,23 @@ impl Animation for AttackAnimation { next.control.scale = Vec3::one(); }, Some(ToolKind::Staff(_)) => { - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(0.0, 0.0, 10.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -4.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); + next.control.ori = Quaternion::rotation_x(-1.2) + * Quaternion::rotation_y(slow * 1.5) + * Quaternion::rotation_z(1.4 + slow * 0.5); + next.control.scale = Vec3::one(); }, Some(ToolKind::Shield(_)) => { next.l_hand.offset = diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 0fe9e9ac1a..7b1cd53ffb 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -9,6 +9,7 @@ pub mod idle; pub mod jump; pub mod roll; pub mod run; +pub mod shoot; pub mod sit; pub mod stand; pub mod swim; @@ -19,8 +20,8 @@ pub use self::{ attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, charge::ChargeAnimation, cidle::CidleAnimation, climb::ClimbAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, roll::RollAnimation, - run::RunAnimation, sit::SitAnimation, stand::StandAnimation, swim::SwimAnimation, - wield::WieldAnimation, + run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, stand::StandAnimation, + swim::SwimAnimation, wield::WieldAnimation, }; use super::{Bone, Skeleton}; diff --git a/voxygen/src/anim/character/shoot.rs b/voxygen/src/anim/character/shoot.rs new file mode 100644 index 0000000000..b47f308e29 --- /dev/null +++ b/voxygen/src/anim/character/shoot.rs @@ -0,0 +1,289 @@ +use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; +use common::comp::item::ToolKind; +use std::f32::consts::PI; +use vek::*; + +pub struct Input { + pub attack: bool, +} +pub struct ShootAnimation; + +impl Animation for ShootAnimation { + type Dependency = (Option, f64); + type Skeleton = CharacterSkeleton; + + fn update_skeleton( + skeleton: &Self::Skeleton, + (active_tool_kind, _global_time): Self::Dependency, + anim_time: f64, + rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + *rate = 1.0; + let mut next = (*skeleton).clone(); + + let lab = 1.0; + + let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); + let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); + let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); + + let quick = (((5.0) + / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 2.0).cos()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 2.0).cos()); + + let slow = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 12.4).sin()); + let slower = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0).sin()); + + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward - quick * 3.5, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(quick * 0.15) + * Quaternion::rotation_x(quick * 0.09) + * Quaternion::rotation_y(0.0); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0 - quick * 1.5, 7.0); + next.chest.ori = Quaternion::rotation_z(quick * 0.15) + * Quaternion::rotation_x(quick * 0.09) + * Quaternion::rotation_y(0.0); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0 - quick * 1.0, 5.0); + next.belt.ori = Quaternion::rotation_z(quick * 0.2) + * Quaternion::rotation_x(quick * 0.12) + * Quaternion::rotation_y(0.0); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, -quick * 0.5, 2.0); + next.shorts.ori = Quaternion::rotation_z(quick * 0.08) + * Quaternion::rotation_x(quick * 0.05) + * Quaternion::rotation_y(0.0); + next.shorts.scale = Vec3::one(); + + match active_tool_kind { + //TODO: Inventory + Some(ToolKind::Sword(_)) => { + next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); + next.control.ori = Quaternion::rotation_x(-1.2) + * Quaternion::rotation_y(slow * 1.5) + * Quaternion::rotation_z(1.4 + slow * 0.5); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Axe(_)) => { + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Hammer(_)) => { + next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); + + //0,1,5 + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-6.0, 3.0, 5.0 + slower * 5.0); + next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(1.4 + 1.57); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Staff(_)) => { + next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); + next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(1.8) + * Quaternion::rotation_y(0.5) + * Quaternion::rotation_z(-0.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(11.0, 9.0, 10.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(3.14 + 0.3) + * Quaternion::rotation_z(0.9); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0 - quick * 5.0); + next.control.ori = Quaternion::rotation_x(quick * 1.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(quick * 1.5); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Shield(_)) => { + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Bow(_)) => { + next.l_hand.offset = Vec3::new(-7.0, -2.0 + slow * 5.0, -1.0); + next.l_hand.ori = Quaternion::rotation_x(PI / 2.0) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(0.3); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(1.0, 8.0, 2.5); + next.r_hand.ori = Quaternion::rotation_x(PI / 2.0) + * Quaternion::rotation_y(0.3) + * Quaternion::rotation_z(0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new( + -4.0 + skeleton_attr.weapon_x, + 15.0 + skeleton_attr.weapon_y, + -4.0, + ); + next.main.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.4) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Dagger(_)) => { + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Debug(_)) => { + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + }, + _ => {}, + } + next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.1; + + next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.1; + + next.glider.offset = Vec3::new(0.0, 5.0, 0.0); + next.glider.ori = Quaternion::rotation_y(0.0); + next.glider.scale = Vec3::one() * 0.0; + + next.lantern.offset = Vec3::new(0.0, 0.0, 0.0); + next.lantern.ori = Quaternion::rotation_x(0.0); + next.lantern.scale = Vec3::one() * 0.0; + + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = + Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); + next + } +} diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 713061f0bc..c6ab5cefd4 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -87,29 +87,25 @@ impl Animation for WieldAnimation { next.control.scale = Vec3::one(); }, Some(ToolKind::Staff(_)) => { - next.l_hand.offset = Vec3::new( - -6.0 + wave_ultra_slow_cos * 1.0, - 1.0 + wave_ultra_slow_cos * 0.5, - 5.0 + wave_ultra_slow * 1.0, - ); - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.0; - next.r_hand.offset = Vec3::new( - -6.0 + wave_ultra_slow_cos * 1.0, - -1.5 + wave_ultra_slow_cos * 0.5, - -2.0 + wave_ultra_slow * 1.0, - ); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x + wave_ultra_slow_cos * 1.0, - 8.5 + skeleton_attr.weapon_y + wave_ultra_slow_cos * 0.5, - 17.0 + wave_ultra_slow * 1.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3 + PI) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); + next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); + next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(1.8) + * Quaternion::rotation_y(0.5) + * Quaternion::rotation_z(-0.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(11.0, 9.0, 10.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(3.14 + 0.3) + * Quaternion::rotation_z(0.9); next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); + next.control.scale = Vec3::one(); }, Some(ToolKind::Shield(_)) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 49718623cd..41b7e0e809 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -477,7 +477,7 @@ impl FigureMgr { ) }, CharacterState::BasicRanged(_) => { - anim::character::AttackAnimation::update_skeleton( + anim::character::ShootAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.state_time, From 08db4241695b401c01ad3209b533bb8fb0e91f30 Mon Sep 17 00:00:00 2001 From: Imbris Date: Fri, 20 Mar 2020 23:23:46 -0400 Subject: [PATCH 179/326] Add safe_slerp function that ensures that slerping returns non-NaN normalized values --- common/src/states/climb.rs | 16 +- common/src/states/dash_melee.rs | 4 +- common/src/states/glide.rs | 10 +- common/src/states/roll.rs | 10 +- common/src/states/utils.rs | 29 +-- common/src/sys/movement.rs | 261 --------------------------- common/src/util/color.rs | 141 +++++++++++++++ common/src/util/mod.rs | 199 ++++++++------------ voxygen/src/anim/mod.rs | 2 +- voxygen/src/ecs/sys/interpolation.rs | 10 +- voxygen/src/scene/figure/mod.rs | 40 +--- voxygen/src/scene/simple.rs | 1 - 12 files changed, 248 insertions(+), 475 deletions(-) delete mode 100644 common/src/sys/movement.rs create mode 100644 common/src/util/color.rs diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 27f51c8da5..314086ef6f 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -5,6 +5,7 @@ use crate::{ character_behavior::{CharacterBehavior, JoinData}, phys::GRAVITY, }, + util::safe_slerp, }; use std::collections::VecDeque; use vek::{ @@ -67,16 +68,11 @@ impl CharacterBehavior for Data { }; // Smooth orientation - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = vek::ops::Slerp::slerp( - update.ori.0, - ori_dir.into(), - if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, - ); - } + update.ori.0 = safe_slerp( + update.ori.0, + ori_dir.into(), + if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, + ); // Apply Vertical Climbing Movement if let (true, Some(_wall_dir)) = ( diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index c52447218f..7b1cdfd51a 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -1,6 +1,7 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, StateUpdate}, sys::character_behavior::*, + util::safe_slerp, }; use std::{collections::VecDeque, time::Duration}; use vek::Vec3; @@ -34,7 +35,6 @@ impl CharacterBehavior for Data { if self.initialize { update.vel.0 = data.inputs.look_dir * 20.0; - update.ori.0 = update.vel.0; } if self.buildup_duration != Duration::default() && data.physics.touch_entity.is_none() { @@ -99,6 +99,8 @@ impl CharacterBehavior for Data { } } + update.ori.0 = safe_slerp(update.ori.0, update.vel.0, 9.0 * data.dt.0); + update } } diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 4d7a73eddf..3f947399cc 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,9 +1,10 @@ use crate::{ comp::{CharacterState, StateUpdate}, sys::character_behavior::{CharacterBehavior, JoinData}, + util::safe_slerp, }; use std::collections::VecDeque; -use vek::{Vec2, Vec3}; +use vek::Vec2; // Gravity is 9.81 * 4, so this makes gravity equal to .15 const GLIDE_ANTIGRAV: f32 = crate::sys::phys::GRAVITY * 0.96; @@ -46,12 +47,7 @@ impl CharacterBehavior for Data { // Determine orientation vector from movement direction vector let ori_dir = Vec2::from(update.vel.0); - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 2.0 * data.dt.0); - } + update.ori.0 = safe_slerp(update.ori.0, ori_dir.into(), 2.0 * data.dt.0); // Apply Glide antigrav lift if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 2d0795d95c..e09405c8e1 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,6 +1,7 @@ use crate::{ comp::{CharacterState, StateUpdate}, sys::character_behavior::{CharacterBehavior, JoinData}, + util::safe_slerp, }; use std::{collections::VecDeque, time::Duration}; use vek::Vec3; @@ -33,14 +34,7 @@ impl CharacterBehavior for Data { * ROLL_SPEED; // Smooth orientation - if update.vel.0.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(update.vel.0).normalized()) - .magnitude_squared() - > 0.001 - { - update.ori.0 = - vek::ops::Slerp::slerp(update.ori.0, update.vel.0.into(), 9.0 * data.dt.0); - } + update.ori.0 = safe_slerp(update.ori.0, update.vel.0.into(), 9.0 * data.dt.0); if self.remaining_duration == Duration::default() { // Roll duration has expired diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index a02d5ad99f..bcf938470d 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -3,9 +3,10 @@ use crate::{ event::LocalEvent, states::*, sys::{character_behavior::JoinData, phys::GRAVITY}, + util::safe_slerp, }; use std::time::Duration; -use vek::vec::{Vec2, Vec3}; +use vek::vec::Vec2; pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; const BASE_HUMANOID_ACCEL: f32 = 100.0; @@ -59,18 +60,13 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate) { pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate) { // Set direction based on move direction let ori_dir = if update.character.is_attack() || update.character.is_block() { - Vec2::from(data.inputs.look_dir).normalized() + Vec2::from(data.inputs.look_dir) } else { Vec2::from(data.inputs.move_dir) }; // Smooth orientation - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 9.0 * data.dt.0); - } + update.ori.0 = safe_slerp(update.ori.0, ori_dir.into(), 9.0 * data.dt.0); } /// Updates components to move player as if theyre swimming @@ -86,21 +82,16 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { // Set direction based on move direction when on the ground let ori_dir = if update.character.is_attack() || update.character.is_block() { - Vec2::from(data.inputs.look_dir).normalized() + Vec2::from(data.inputs.look_dir) } else { Vec2::from(update.vel.0) }; - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = vek::ops::Slerp::slerp( - update.ori.0, - ori_dir.into(), - if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, - ); - } + update.ori.0 = safe_slerp( + update.ori.0, + ori_dir.into(), + if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, + ); // Force players to pulse jump button to swim up if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600)) diff --git a/common/src/sys/movement.rs b/common/src/sys/movement.rs deleted file mode 100644 index b0f41858f4..0000000000 --- a/common/src/sys/movement.rs +++ /dev/null @@ -1,261 +0,0 @@ -use super::phys::GRAVITY; -use crate::{ - comp::{ - ActionState, CharacterState, Controller, Energy, EnergySource, Mounting, MovementState::*, - Ori, PhysicsState, Pos, Stats, Vel, - }, - event::{EventBus, ServerEvent}, - state::DeltaTime, - sync::Uid, - terrain::TerrainGrid, -}; -use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage}; -use std::time::Duration; -use vek::*; - -pub const ROLL_DURATION: Duration = Duration::from_millis(600); - -const BASE_HUMANOID_ACCEL: f32 = 100.0; -const BASE_HUMANOID_SPEED: f32 = 120.0; -const BASE_HUMANOID_AIR_ACCEL: f32 = 15.0; -const BASE_HUMANOID_AIR_SPEED: f32 = 100.0; -const BASE_HUMANOID_WATER_ACCEL: f32 = 70.0; -const BASE_HUMANOID_WATER_SPEED: f32 = 120.0; -const BASE_HUMANOID_CLIMB_ACCEL: f32 = 10.0; -const ROLL_SPEED: f32 = 17.0; -const CHARGE_SPEED: f32 = 20.0; -const GLIDE_ACCEL: f32 = 15.0; -const GLIDE_SPEED: f32 = 45.0; -const BLOCK_ACCEL: f32 = 30.0; -const BLOCK_SPEED: f32 = 75.0; -// Gravity is 9.81 * 4, so this makes gravity equal to .15 -const GLIDE_ANTIGRAV: f32 = GRAVITY * 0.96; -const CLIMB_SPEED: f32 = 5.0; -const CLIMB_COST: i32 = 5; - -pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; - -/// # Movement System -/// #### Applies forces, calculates new positions and velocities,7 -/// #### based on Controller(Inputs) and CharacterState. -/// ---- -/// -/// **Writes:** -/// Pos, Vel, Ori -/// -/// **Reads:** -/// Uid, Stats, Controller, PhysicsState, CharacterState, Mounting -pub struct Sys; -impl<'a> System<'a> for Sys { - type SystemData = ( - Entities<'a>, - ReadExpect<'a, TerrainGrid>, - Read<'a, EventBus>, - Read<'a, DeltaTime>, - WriteStorage<'a, Pos>, - WriteStorage<'a, Vel>, - WriteStorage<'a, Ori>, - WriteStorage<'a, Energy>, - ReadStorage<'a, Uid>, - ReadStorage<'a, Stats>, - ReadStorage<'a, Controller>, - ReadStorage<'a, PhysicsState>, - ReadStorage<'a, CharacterState>, - ReadStorage<'a, Mounting>, - ); - - fn run( - &mut self, - ( - entities, - _terrain, - _server_bus, - dt, - mut positions, - mut velocities, - mut orientations, - mut energies, - uids, - stats, - controllers, - physics_states, - character_states, - mountings, - ): Self::SystemData, - ) { - // Apply movement inputs - for ( - _entity, - mut _pos, - mut vel, - mut ori, - mut energy, - _uid, - stats, - controller, - physics, - character, - mount, - ) in ( - &entities, - &mut positions, - &mut velocities, - &mut orientations, - &mut energies.restrict_mut(), - &uids, - &stats, - &controllers, - &physics_states, - &character_states, - mountings.maybe(), - ) - .join() - { - if stats.is_dead { - continue; - } - - if mount.is_some() { - continue; - } - - let inputs = &controller.inputs; - - if character.action.is_dodge() { - vel.0 = Vec3::new(0.0, 0.0, vel.0.z) - + (vel.0 * Vec3::new(1.0, 1.0, 0.0) - + 1.5 * inputs.move_dir.try_normalized().unwrap_or_default()) - .try_normalized() - .unwrap_or_default() - * ROLL_SPEED; - } else if character.action.is_charge() { - vel.0 = Vec3::new(0.0, 0.0, vel.0.z) - + (vel.0 * Vec3::new(1.0, 1.0, 0.0) - + 1.5 * inputs.move_dir.try_normalized().unwrap_or_default()) - .try_normalized() - .unwrap_or_default() - * CHARGE_SPEED; - } else if character.action.is_block() { - vel.0 += Vec2::broadcast(dt.0) - * inputs.move_dir - * match physics.on_ground { - true if vel.0.magnitude_squared() < BLOCK_SPEED.powf(2.0) => BLOCK_ACCEL, - _ => 0.0, - } - } else { - // Move player according to move_dir - vel.0 += Vec2::broadcast(dt.0) - * inputs.move_dir - * match (physics.on_ground, &character.movement) { - (true, Run) - if vel.0.magnitude_squared() - < (BASE_HUMANOID_SPEED + stats.fitness as f32 * 50.0).powf(2.0) => - { - BASE_HUMANOID_ACCEL - }, - (false, Climb) - if vel.0.magnitude_squared() < BASE_HUMANOID_SPEED.powf(2.0) => - { - BASE_HUMANOID_CLIMB_ACCEL - }, - (false, Glide) if vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) => { - GLIDE_ACCEL - }, - (false, Fall) | (false, Jump) - if vel.0.magnitude_squared() - < (BASE_HUMANOID_AIR_SPEED + stats.fitness as f32 * 10.0) - .powf(2.0) => - { - BASE_HUMANOID_AIR_ACCEL - }, - (false, Swim) - if vel.0.magnitude_squared() - < (BASE_HUMANOID_WATER_SPEED + stats.fitness as f32 * 30.0) - .powf(2.0) => - { - BASE_HUMANOID_WATER_ACCEL + stats.fitness as f32 * 10.0 - }, - _ => 0.0, - }; - } - - // Set direction based on move direction when on the ground - let ori_dir = if - //character.action.is_wield() || - character.action.is_attack() || character.action.is_block() { - Vec2::from(inputs.look_dir).normalized() - } else if let (Climb, Some(wall_dir)) = (character.movement, physics.on_wall) { - if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { - Vec2::from(wall_dir).normalized() - } else { - Vec2::from(inputs.move_dir) - } - } else if let Glide = character.movement { - // Note: non-gliding forces will also affect velocity and thus orientation - // producing potentially unexpected changes in direction - Vec2::from(vel.0) - } else { - if let ActionState::Roll { .. } = character.action { - // So can can't spin/slip around while rolling - Vec2::from(vel.0) - } else { - Vec2::from(inputs.move_dir) - } - }; - - if ori_dir.magnitude_squared() > 0.0001 - && (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - ori.0 = vek::ops::Slerp::slerp( - ori.0, - ori_dir.into(), - if physics.on_ground { 9.0 } else { 2.0 } * dt.0, - ); - } - - // Glide - if character.movement == Glide - && Vec2::::from(vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) - && vel.0.z < 0.0 - { - let lift = GLIDE_ANTIGRAV + vel.0.z.abs().powf(2.0) * 0.15; - vel.0.z += dt.0 - * lift - * (Vec2::::from(vel.0).magnitude() * 0.075) - .min(1.0) - .max(0.2); - } - - // Climb - if let (true, Some(_wall_dir)) = ( - character.movement == Climb && vel.0.z <= CLIMB_SPEED, - physics.on_wall, - ) { - if inputs.climb_down.is_pressed() && !inputs.climb.is_pressed() { - if energy - .get_mut_unchecked() - .try_change_by(-CLIMB_COST, EnergySource::Climb) - .is_ok() - { - vel.0 -= dt.0 * vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); - } - } else if inputs.climb.is_pressed() && !inputs.climb_down.is_pressed() { - if energy - .get_mut_unchecked() - .try_change_by(-CLIMB_COST, EnergySource::Climb) - .is_ok() - { - vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED).max(0.0); - } - } else { - vel.0.z = (vel.0.z - dt.0 * GRAVITY * 0.01).min(CLIMB_SPEED); - } - } - - if character.movement == Swim && inputs.jump.is_pressed() { - vel.0.z = (vel.0.z + dt.0 * GRAVITY * 1.25).min(BASE_HUMANOID_WATER_SPEED); - } - } - } -} diff --git a/common/src/util/color.rs b/common/src/util/color.rs new file mode 100644 index 0000000000..a1b91394da --- /dev/null +++ b/common/src/util/color.rs @@ -0,0 +1,141 @@ +use vek::{Mat3, Rgb, Rgba, Vec3}; + +#[inline(always)] +pub fn srgb_to_linear(col: Rgb) -> Rgb { + col.map(|c| { + if c <= 0.104 { + c * 0.08677088 + } else { + 0.012522878 * c + 0.682171111 * c * c + 0.305306011 * c * c * c + } + }) +} + +#[inline(always)] +pub fn linear_to_srgb(col: Rgb) -> Rgb { + col.map(|c| { + if c <= 0.0060 { + c * 11.500726 + } else { + let s1 = c.sqrt(); + let s2 = s1.sqrt(); + let s3 = s2.sqrt(); + 0.585122381 * s1 + 0.783140355 * s2 - 0.368262736 * s3 + } + }) +} + +#[inline(always)] +pub fn srgba_to_linear(col: Rgba) -> Rgba { + Rgba::from_translucent(srgb_to_linear(Rgb::from(col)), col.a) +} + +#[inline(always)] +pub fn linear_to_srgba(col: Rgba) -> Rgba { + Rgba::from_translucent(linear_to_srgb(Rgb::from(col)), col.a) +} + +/// Convert rgb to hsv. Expects rgb to be [0, 1]. +#[inline(always)] +pub fn rgb_to_hsv(rgb: Rgb) -> Vec3 { + let (r, g, b) = rgb.into_tuple(); + let (max, min, diff, add) = { + let (max, min, diff, add) = if r > g { + (r, g, g - b, 0.0) + } else { + (g, r, b - r, 2.0) + }; + if b > max { + (b, min, r - g, 4.0) + } else { + (max, b.min(min), diff, add) + } + }; + + let v = max; + let h = if max == min { + 0.0 + } else { + let mut h = 60.0 * (add + diff / (max - min)); + if h < 0.0 { + h += 360.0; + } + h + }; + let s = if max == 0.0 { 0.0 } else { (max - min) / max }; + + Vec3::new(h, s, v) +} + +/// Convert hsv to rgb. Expects h [0, 360], s [0, 1], v [0, 1] +#[inline(always)] +pub fn hsv_to_rgb(hsv: Vec3) -> Rgb { + let (h, s, v) = hsv.into_tuple(); + let c = s * v; + let h = h / 60.0; + let x = c * (1.0 - (h % 2.0 - 1.0).abs()); + let m = v - c; + + let (r, g, b) = if h >= 0.0 && h <= 1.0 { + (c, x, 0.0) + } else if h <= 2.0 { + (x, c, 0.0) + } else if h <= 3.0 { + (0.0, c, x) + } else if h <= 4.0 { + (0.0, x, c) + } else if h <= 5.0 { + (x, 0.0, c) + } else { + (c, 0.0, x) + }; + + Rgb::new(r + m, g + m, b + m) +} + +/// Convert linear rgb to CIExyY +#[inline(always)] +pub fn rgb_to_xyy(rgb: Rgb) -> Vec3 { + // XYZ + let xyz = Mat3::new( + 0.4124, 0.3576, 0.1805, 0.2126, 0.7152, 0.0722, 0.0193, 0.1192, 0.9504, + ) * Vec3::from(rgb); + + let sum = xyz.sum(); + Vec3::new(xyz.x / sum, xyz.y / sum, xyz.y) +} + +/// Convert to CIExyY to linear rgb +#[inline(always)] +pub fn xyy_to_rgb(xyy: Vec3) -> Rgb { + let xyz = Vec3::new( + xyy.z / xyy.y * xyy.x, + xyy.z, + xyy.z / xyy.y * (1.0 - xyy.x - xyy.y), + ); + + Rgb::from( + Mat3::new( + 3.2406, -1.5372, -0.4986, -0.9689, 1.8758, 0.0415, 0.0557, -0.2040, 1.0570, + ) * xyz, + ) +} + +// TO-DO: speed this up +#[inline(always)] +pub fn saturate_srgb(col: Rgb, value: f32) -> Rgb { + let mut hsv = rgb_to_hsv(srgb_to_linear(col)); + hsv.y *= 1.0 + value; + linear_to_srgb(hsv_to_rgb(hsv).map(|e| e.min(1.0).max(0.0))) +} + +/// Preserves the luma of one color while changing its chromaticty to match the +/// other +#[inline(always)] +pub fn chromify_srgb(luma: Rgb, chroma: Rgb) -> Rgb { + let l = rgb_to_xyy(srgb_to_linear(luma)).z; + let mut xyy = rgb_to_xyy(srgb_to_linear(chroma)); + xyy.z = l; + + linear_to_srgb(xyy_to_rgb(xyy).map(|e| e.min(1.0).max(0.0))) +} diff --git a/common/src/util/mod.rs b/common/src/util/mod.rs index cdd725a716..36ef3841e0 100644 --- a/common/src/util/mod.rs +++ b/common/src/util/mod.rs @@ -1,3 +1,5 @@ +mod color; + pub const GIT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/githash")); lazy_static::lazy_static! { @@ -5,144 +7,85 @@ lazy_static::lazy_static! { pub static ref GIT_DATE: &'static str = GIT_VERSION.split("/").nth(1).expect("failed to retrieve git_date!"); } -use vek::{Mat3, Rgb, Rgba, Vec3}; +pub use color::*; +/// Begone ye NaN's +/// Slerp two `Vec3`s skipping the slerp if their directions are very close +/// This avoids a case where `vek`s slerp produces NaN's +/// Additionally, it avoids unnecessary calculations if they are near identical +/// Assumes `from` is normalized and returns a normalized vector, but `to` +/// doesn't need to be normalized +// TODO: in some cases we might want to base the slerp rate on the magnitude of +// `to` for example when `to` is velocity and `from` is orientation #[inline(always)] -pub fn srgb_to_linear(col: Rgb) -> Rgb { - col.map(|c| { - if c <= 0.104 { - c * 0.08677088 - } else { - 0.012522878 * c + 0.682171111 * c * c + 0.305306011 * c * c * c +pub fn safe_slerp(from: vek::Vec3, to: vek::Vec3, factor: f32) -> vek::Vec3 { + use vek::Vec3; + + debug_assert!(!to.map(f32::is_nan).reduce_or()); + debug_assert!(!from.map(f32::is_nan).reduce_or()); + // Ensure from is normalized + #[cfg(debug_assertions)] + { + if { + let len_sq = from.magnitude_squared(); + len_sq < 0.999 || len_sq > 1.001 + } { + panic!("Called safe_slerp with unnormalized from: {:?}", from); } - }) -} + } -#[inline(always)] -pub fn linear_to_srgb(col: Rgb) -> Rgb { - col.map(|c| { - if c <= 0.0060 { - c * 11.500726 + let to = if to.magnitude_squared() > 0.001 { + to.normalized() + } else { + return from; + }; + + let dot = from.dot(to); + if dot > 0.999 { + // Close together, just use to + return to; + } + + let (from, to, factor) = if dot < -0.999 { + // Not linearly independent (slerp will fail since it doesn't check for this) + // Instead we will choose a midpoint and slerp from or to that depending on the + // factor + let mid_dir = if from.z > 0.999 { + // If vec's lie along the z-axis default to (1, 0, 0) as midpoint + Vec3::unit_x() } else { - let s1 = c.sqrt(); - let s2 = s1.sqrt(); - let s3 = s2.sqrt(); - 0.585122381 * s1 + 0.783140355 * s2 - 0.368262736 * s3 - } - }) -} - -#[inline(always)] -pub fn srgba_to_linear(col: Rgba) -> Rgba { - Rgba::from_translucent(srgb_to_linear(Rgb::from(col)), col.a) -} - -#[inline(always)] -pub fn linear_to_srgba(col: Rgba) -> Rgba { - Rgba::from_translucent(linear_to_srgb(Rgb::from(col)), col.a) -} - -/// Convert rgb to hsv. Expects rgb to be [0, 1]. -#[inline(always)] -pub fn rgb_to_hsv(rgb: Rgb) -> Vec3 { - let (r, g, b) = rgb.into_tuple(); - let (max, min, diff, add) = { - let (max, min, diff, add) = if r > g { - (r, g, g - b, 0.0) - } else { - (g, r, b - r, 2.0) + // Default to picking midpoint in the xy plane + Vec3::new(from.y, -from.x, 0.0).normalized() }; - if b > max { - (b, min, r - g, 4.0) + + if factor > 0.5 { + (mid_dir, to, factor * 2.0 - 1.0) } else { - (max, b.min(min), diff, add) + (from, mid_dir, factor * 2.0) } + } else { + (from, to, factor) }; - let v = max; - let h = if max == min { - 0.0 - } else { - let mut h = 60.0 * (add + diff / (max - min)); - if h < 0.0 { - h += 360.0; + let slerped = Vec3::slerp(from, to, factor); + let slerped_normalized = slerped.normalized(); + // Ensure normalization worked + // This should not be possible but I will leave it here for now just in case + // something was missed + #[cfg(debug_assertions)] + { + if { + let len_sq = slerped_normalized.magnitude_squared(); + len_sq < 0.999 || len_sq > 1.001 + } || slerped_normalized.map(f32::is_nan).reduce_or() + { + panic!( + "Failed to normalize {:?} produced from:\nslerp(\n {:?},\n {:?},\n \ + {:?},\n)\nWith result: {:?})", + slerped, from, to, factor, slerped_normalized + ); } - h - }; - let s = if max == 0.0 { 0.0 } else { (max - min) / max }; + } - Vec3::new(h, s, v) -} - -/// Convert hsv to rgb. Expects h [0, 360], s [0, 1], v [0, 1] -#[inline(always)] -pub fn hsv_to_rgb(hsv: Vec3) -> Rgb { - let (h, s, v) = hsv.into_tuple(); - let c = s * v; - let h = h / 60.0; - let x = c * (1.0 - (h % 2.0 - 1.0).abs()); - let m = v - c; - - let (r, g, b) = if h >= 0.0 && h <= 1.0 { - (c, x, 0.0) - } else if h <= 2.0 { - (x, c, 0.0) - } else if h <= 3.0 { - (0.0, c, x) - } else if h <= 4.0 { - (0.0, x, c) - } else if h <= 5.0 { - (x, 0.0, c) - } else { - (c, 0.0, x) - }; - - Rgb::new(r + m, g + m, b + m) -} - -/// Convert linear rgb to CIExyY -#[inline(always)] -pub fn rgb_to_xyy(rgb: Rgb) -> Vec3 { - // XYZ - let xyz = Mat3::new( - 0.4124, 0.3576, 0.1805, 0.2126, 0.7152, 0.0722, 0.0193, 0.1192, 0.9504, - ) * Vec3::from(rgb); - - let sum = xyz.sum(); - Vec3::new(xyz.x / sum, xyz.y / sum, xyz.y) -} - -/// Convert to CIExyY to linear rgb -#[inline(always)] -pub fn xyy_to_rgb(xyy: Vec3) -> Rgb { - let xyz = Vec3::new( - xyy.z / xyy.y * xyy.x, - xyy.z, - xyy.z / xyy.y * (1.0 - xyy.x - xyy.y), - ); - - Rgb::from( - Mat3::new( - 3.2406, -1.5372, -0.4986, -0.9689, 1.8758, 0.0415, 0.0557, -0.2040, 1.0570, - ) * xyz, - ) -} - -// TO-DO: speed this up -#[inline(always)] -pub fn saturate_srgb(col: Rgb, value: f32) -> Rgb { - let mut hsv = rgb_to_hsv(srgb_to_linear(col)); - hsv.y *= 1.0 + value; - linear_to_srgb(hsv_to_rgb(hsv).map(|e| e.min(1.0).max(0.0))) -} - -/// Preserves the luma of one color while changing its chromaticty to match the -/// other -#[inline(always)] -pub fn chromify_srgb(luma: Rgb, chroma: Rgb) -> Rgb { - let l = rgb_to_xyy(srgb_to_linear(luma)).z; - let mut xyy = rgb_to_xyy(srgb_to_linear(chroma)); - xyy.z = l; - - linear_to_srgb(xyy_to_rgb(xyy).map(|e| e.min(1.0).max(0.0))) + slerped_normalized } diff --git a/voxygen/src/anim/mod.rs b/voxygen/src/anim/mod.rs index 5860306ecf..bfe6b38b5d 100644 --- a/voxygen/src/anim/mod.rs +++ b/voxygen/src/anim/mod.rs @@ -44,7 +44,7 @@ impl Bone { // TODO: Make configurable. let factor = (15.0 * dt).min(1.0); self.offset += (target.offset - self.offset) * factor; - self.ori = vek::ops::Slerp::slerp(self.ori, target.ori, factor); + self.ori = vek::Slerp::slerp(self.ori, target.ori, factor); self.scale += (target.scale - self.scale) * factor; } } diff --git a/voxygen/src/ecs/sys/interpolation.rs b/voxygen/src/ecs/sys/interpolation.rs index 80ddfc6261..3d71af2601 100644 --- a/voxygen/src/ecs/sys/interpolation.rs +++ b/voxygen/src/ecs/sys/interpolation.rs @@ -2,6 +2,7 @@ use crate::ecs::comp::Interpolated; use common::{ comp::{Ori, Pos, Vel}, state::DeltaTime, + util::safe_slerp, }; use log::warn; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; @@ -29,14 +30,7 @@ impl<'a> System<'a> for Sys { // Update interpolation values if i.pos.distance_squared(pos.0) < 64.0 * 64.0 { i.pos = Lerp::lerp(i.pos, pos.0 + vel.0 * 0.03, 10.0 * dt.0); - let ori_interp = Slerp::slerp(i.ori, ori.0, 5.0 * dt.0); - // Check for NaNs - // TODO: why are we getting NaNs here! Zero-length ori vectors? - i.ori = if !ori_interp.map(|e| e.is_nan()).reduce_or() { - ori_interp - } else { - ori.0 - }; + i.ori = safe_slerp(i.ori, ori.0, 5.0 * dt.0); } else { i.pos = pos.0; i.ori = ori.0; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 96ef4a057e..c2cbbdd10e 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -12,6 +12,7 @@ use crate::{ object::ObjectSkeleton, quadruped_medium::QuadrupedMediumSkeleton, quadruped_small::QuadrupedSmallSkeleton, Animation, Skeleton, }, + ecs::comp::Interpolated, render::{Consts, FigureBoneData, FigureLocals, Globals, Light, Renderer, Shadow}, scene::{ camera::{Camera, CameraMode}, @@ -115,8 +116,8 @@ impl FigureMgr { for ( entity, pos, + interpolated, vel, - ori, scale, body, character, @@ -127,8 +128,8 @@ impl FigureMgr { ) in ( &ecs.entities(), &ecs.read_storage::(), + ecs.read_storage::().maybe(), &ecs.read_storage::(), - ecs.read_storage::().maybe(), ecs.read_storage::().maybe(), &ecs.read_storage::(), ecs.read_storage::().maybe(), @@ -139,7 +140,9 @@ impl FigureMgr { ) .join() { - let ori = ori.copied().unwrap_or(Ori(Vec3::unit_y())); + let (pos, ori) = interpolated + .map(|i| (Pos(i.pos), Ori(i.ori))) + .unwrap_or((*pos, Ori(Vec3::unit_y()))); // Don't process figures outside the vd let vd_frac = Vec2::from(pos.0 - player_pos) @@ -613,7 +616,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -694,7 +696,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -777,7 +778,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -852,7 +852,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -927,7 +926,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -1002,7 +1000,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -1077,7 +1074,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -1152,7 +1148,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -1227,7 +1222,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -1302,7 +1296,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -1322,7 +1315,6 @@ impl FigureMgr { state.update( renderer, pos.0, - vel.0, ori.0, scale, col, @@ -1678,8 +1670,6 @@ pub struct FigureState { locals: Consts, state_time: f64, skeleton: S, - pos: Vec3, - ori: Vec3, last_ori: Vec3, lpindex: u8, visible: bool, @@ -1694,8 +1684,6 @@ impl FigureState { locals: renderer.create_consts(&[FigureLocals::default()]).unwrap(), state_time: 0.0, skeleton, - pos: Vec3::zero(), - ori: Vec3::zero(), last_ori: Vec3::zero(), lpindex: 0, visible: false, @@ -1706,7 +1694,6 @@ impl FigureState { &mut self, renderer: &mut Renderer, pos: Vec3, - vel: Vec3, ori: Vec3, scale: f32, col: Rgba, @@ -1717,23 +1704,14 @@ impl FigureState { ) { self.visible = visible; self.lpindex = lpindex; + // What is going on here? + // (note: that ori is now the slerped ori) self.last_ori = Lerp::lerp(self.last_ori, ori, 15.0 * dt); - // Update interpolation values - // TODO: use values from Interpolated component instead of recalculating - if self.pos.distance_squared(pos) < 64.0 * 64.0 { - self.pos = Lerp::lerp(self.pos, pos + vel * 0.03, 10.0 * dt); - self.ori = Slerp::slerp(self.ori, ori, 5.0 * dt); - } else { - self.pos = pos; - self.ori = ori; - } - self.state_time += (dt * state_animation_rate) as f64; - // TODO: what are the interpolated ori values used for if not here??? let mat = Mat4::::identity() - * Mat4::translation_3d(self.pos) + * Mat4::translation_3d(pos) * Mat4::rotation_z(-ori.x.atan2(ori.y)) * Mat4::rotation_x(ori.z.atan2(Vec2::from(ori).magnitude())) * Mat4::scaling_3d(Vec3::from(0.8 * scale)); diff --git a/voxygen/src/scene/simple.rs b/voxygen/src/scene/simple.rs index abb47585fc..34aaec83e4 100644 --- a/voxygen/src/scene/simple.rs +++ b/voxygen/src/scene/simple.rs @@ -192,7 +192,6 @@ impl Scene { self.figure_state.update( renderer, Vec3::zero(), - Vec3::zero(), Vec3::new(self.char_ori.sin(), -self.char_ori.cos(), 0.0), 1.0, Rgba::broadcast(1.0), From 49986a0e09dd8ff09590ac0bd642a5fe6019e174 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sat, 21 Mar 2020 03:40:14 -0400 Subject: [PATCH 180/326] bow work --- voxygen/src/anim/character/attack.rs | 36 ++++++++++--------- voxygen/src/anim/character/shoot.rs | 46 ++++++++++++++---------- voxygen/src/anim/character/wield.rs | 52 ++++++++++++---------------- 3 files changed, 69 insertions(+), 65 deletions(-) diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index cb74158a33..767ee51b27 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -178,25 +178,27 @@ impl Animation for AttackAnimation { next.main.scale = Vec3::one(); }, Some(ToolKind::Bow(_)) => { - next.l_hand.offset = Vec3::new(-7.0, -2.0 + slow * 5.0, -1.0); - next.l_hand.ori = Quaternion::rotation_x(PI / 2.0) - * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(1.0, 8.0, 2.5); - next.r_hand.ori = Quaternion::rotation_x(PI / 2.0) + next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); + next.l_hand.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(3.0, -1.0, -6.0); + next.r_hand.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(3.0, 2.0, -13.0); + next.main.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.3) - * Quaternion::rotation_z(0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -4.0 + skeleton_attr.weapon_x, - 15.0 + skeleton_attr.weapon_y, - -4.0, - ); - next.main.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.4) - * Quaternion::rotation_z(0.0); + * Quaternion::rotation_z(-0.6); next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.control.scale = Vec3::one(); }, Some(ToolKind::Dagger(_)) => { next.l_hand.offset = diff --git a/voxygen/src/anim/character/shoot.rs b/voxygen/src/anim/character/shoot.rs index b47f308e29..acf28482ff 100644 --- a/voxygen/src/anim/character/shoot.rs +++ b/voxygen/src/anim/character/shoot.rs @@ -1,6 +1,5 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use common::comp::item::ToolKind; -use std::f32::consts::PI; use vek::*; pub struct Input { @@ -32,7 +31,6 @@ impl Animation for ShootAnimation { / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 2.0).cos()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * lab as f32 * 2.0).cos()); - let slow = (((5.0) / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) .sqrt()) @@ -41,6 +39,10 @@ impl Animation for ShootAnimation { / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * lab as f32 * 4.0).sin()); + let sloweralt = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).cos()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0).cos()); next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, @@ -184,25 +186,31 @@ impl Animation for ShootAnimation { next.main.scale = Vec3::one(); }, Some(ToolKind::Bow(_)) => { - next.l_hand.offset = Vec3::new(-7.0, -2.0 + slow * 5.0, -1.0); - next.l_hand.ori = Quaternion::rotation_x(PI / 2.0) - * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(1.0, 8.0, 2.5); - next.r_hand.ori = Quaternion::rotation_x(PI / 2.0) - * Quaternion::rotation_y(0.3) - * Quaternion::rotation_z(0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -4.0 + skeleton_attr.weapon_x, - 15.0 + skeleton_attr.weapon_y, - -4.0, + next.l_hand.offset = Vec3::new( + 1.0 - sloweralt * 2.0, + -4.0 - sloweralt * 7.0, + -1.0 + sloweralt * 6.0, ); - next.main.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.4) - * Quaternion::rotation_z(0.0); + next.l_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6 + sloweralt * 0.8) + * Quaternion::rotation_z(-0.3 + sloweralt * 0.9); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(3.0, -1.0, -5.0); + next.r_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(3.0, 2.0, -13.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.3) + * Quaternion::rotation_z(-0.6); next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x((sloweralt * 0.4).max(0.4)) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.control.scale = Vec3::one(); }, Some(ToolKind::Dagger(_)) => { next.l_hand.offset = diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index c6ab5cefd4..92516a4c69 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -61,10 +61,10 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(-0.8); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(0.0, 0.0, 0.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.1) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow * 0.1); + next.control.offset = Vec3::new(0.0, 0.0, -2.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.1 + 0.2) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(wave_ultra_slow * 0.1 - 0.5); next.control.scale = Vec3::one(); }, Some(ToolKind::Hammer(_)) => { @@ -125,33 +125,27 @@ impl Animation for WieldAnimation { next.main.scale = Vec3::one(); }, Some(ToolKind::Bow(_)) => { - next.l_hand.offset = Vec3::new( - -1.0 - wave_ultra_slow_cos * 1.0, - 3.0 + wave_ultra_slow_cos * 0.5, - 5.0 + wave_ultra_slow * 1.0, - ); - next.l_hand.ori = Quaternion::rotation_x(PI / 2.0) - * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new( - 1.0 + wave_ultra_slow_cos * 1.0, - 8.0 + wave_ultra_slow_cos * 0.5, - 2.5 + wave_ultra_slow * 1.0, - ); - next.r_hand.ori = Quaternion::rotation_x(PI / 2.0) + next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); + next.l_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(3.0, -1.0, -5.0); + next.r_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(3.0, 2.0, -13.0); + next.main.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.3) - * Quaternion::rotation_z(0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -4.0 + skeleton_attr.weapon_x + wave_ultra_slow_cos * 1.0, - 15.0 + skeleton_attr.weapon_y + wave_ultra_slow_cos * 0.5, - -4.0 + wave_ultra_slow * 1.0, - ); - next.main.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.4) - * Quaternion::rotation_z(0.0); + * Quaternion::rotation_z(-0.6); next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); + next.control.scale = Vec3::one(); }, Some(ToolKind::Dagger(_)) => { next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); From cb04df773679461212b46c9f1a46e0d75d50330d Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 21 Mar 2020 07:06:35 -0700 Subject: [PATCH 181/326] swim now uses handle_orientation fn --- common/src/states/triple_strike.rs | 2 +- common/src/states/utils.rs | 24 ++++-------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 05971a2c0f..ee312a7384 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -81,7 +81,7 @@ impl CharacterBehavior for Data { } }; } else { - handle_orientation(data, &mut update); + handle_orientation(data, &mut update, 10.0); } // Handling attacking diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index a02d5ad99f..1e6cb926cf 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -53,10 +53,10 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate) { } } - handle_orientation(data, update); + handle_orientation(data, update, 9.0); } -pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate) { +pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, strength: f32) { // Set direction based on move direction let ori_dir = if update.character.is_attack() || update.character.is_block() { Vec2::from(data.inputs.look_dir).normalized() @@ -69,7 +69,7 @@ pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate) { && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() > 0.001 { - update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 9.0 * data.dt.0); + update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), strength * data.dt.0); } } @@ -84,23 +84,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { 0.0 }; - // Set direction based on move direction when on the ground - let ori_dir = if update.character.is_attack() || update.character.is_block() { - Vec2::from(data.inputs.look_dir).normalized() - } else { - Vec2::from(update.vel.0) - }; - - if ori_dir.magnitude_squared() > 0.0001 - && (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared() - > 0.001 - { - update.ori.0 = vek::ops::Slerp::slerp( - update.ori.0, - ori_dir.into(), - if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, - ); - } + handle_orientation(data, update, if data.physics.on_ground { 9.0 } else { 2.0 }); // Force players to pulse jump button to swim up if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600)) From 7eaf6f664bfb856b00ced575f90fd7a29e3be542 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 21 Mar 2020 09:45:26 -0700 Subject: [PATCH 182/326] Fix water swimming jump velocity --- common/src/states/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index c6fb06da39..988cb5f514 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -86,7 +86,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600)) { update.vel.0.z = - (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(BASE_HUMANOID_WATER_SPEED); + (update.vel.0.z + data.dt.0 * GRAVITY * 2.25).min(BASE_HUMANOID_WATER_SPEED); } } From 180ec890609c9aecc9b5d12458967976b0ad60c9 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 21 Mar 2020 10:26:38 -0700 Subject: [PATCH 183/326] add SwapLoadout --- common/src/comp/controller.rs | 2 ++ common/src/states/utils.rs | 12 +++++++++++- voxygen/src/controller.rs | 3 +++ voxygen/src/session.rs | 24 +++++++++++++++++++++--- voxygen/src/settings.rs | 4 ++++ voxygen/src/window.rs | 4 ++++ 6 files changed, 45 insertions(+), 4 deletions(-) diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 8b88f488c4..52e718d974 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -125,6 +125,7 @@ pub struct ControllerInputs { pub wall_leap: Input, pub respawn: Input, pub toggle_wield: Input, + pub swap_loadout: Input, pub charge: Input, pub move_dir: Vec2, pub look_dir: Vec3, @@ -151,6 +152,7 @@ impl ControllerInputs { self.wall_leap.tick(dt); self.respawn.tick(dt); self.toggle_wield.tick(dt); + self.swap_loadout.tick(dt); self.charge.tick(dt); } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 988cb5f514..03b4b7b73e 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -129,7 +129,7 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { } } -/// Checks that player can `Glide` and updates `CharacterState` if so +/// Checks that player can Unwield and updates `CharacterState` if so pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) { if let CharacterState::Wielding { .. } = update.character { if data.inputs.toggle_wield.is_pressed() { @@ -138,6 +138,16 @@ pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) { } } +/// Checks that player can Swap and updates Loadout +pub fn handle_swap_loadout(data: &JoinData, update: &mut StateUpdate) { + if let CharacterState::Wielding { .. } = update.character { + if data.inputs.swap_loadout.is_pressed() { + //TODO + println!("YAH NAH"); + } + } +} + /// Checks that player can glide and updates `CharacterState` if so pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) { if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { diff --git a/voxygen/src/controller.rs b/voxygen/src/controller.rs index 77049acc21..2e6f8d8d3c 100644 --- a/voxygen/src/controller.rs +++ b/voxygen/src/controller.rs @@ -160,6 +160,9 @@ impl From<&crate::settings::GamepadSettings> for ControllerSettings { map.entry(settings.game_buttons.toggle_wield) .or_default() .push(GameInput::ToggleWield); + map.entry(settings.game_buttons.swap_loadout) + .or_default() + .push(GameInput::SwapLoadout); map.entry(settings.game_buttons.charge) .or_default() .push(GameInput::Charge); diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 64571ae644..5bee64ee03 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -319,6 +319,27 @@ impl PlayState for SessionState { Event::InputUpdate(GameInput::WallLeap, state) => { self.inputs.wall_leap.set_state(state) }, + // Event::InputUpdate(GameInput::ToggleWield, state) => { + // self.inputs.toggle_wield.set_state(state); + // }, + Event::InputUpdate(GameInput::ToggleWield, state) + | Event::InputUpdate(GameInput::SwapLoadout, state) => { + let mut client = self.client.borrow_mut(); + let entity = client.entity(); + let loadout = client + .state() + .read_storage::() + .get(entity) + .cloned(); + + if let Some(loadout) = loadout { + let mut new_loadout = loadout.clone(); + new_loadout.second_item = loadout.active_item; + new_loadout.active_item = loadout.second_item; + + client.state_mut().write_component(entity, new_loadout); + } + }, Event::InputUpdate(GameInput::Mount, true) => { let mut client = self.client.borrow_mut(); if client.is_mounted() { @@ -384,9 +405,6 @@ impl PlayState for SessionState { } } }, - Event::InputUpdate(GameInput::ToggleWield, state) => { - self.inputs.toggle_wield.set_state(state) - }, Event::InputUpdate(GameInput::Charge, state) => { self.inputs.charge.set_state(state); }, diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 78431b2dd1..d802c3dddd 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -50,6 +50,7 @@ pub struct ControlSettings { pub respawn: KeyMouse, pub interact: KeyMouse, pub toggle_wield: KeyMouse, + pub swap_loadout: KeyMouse, pub charge: KeyMouse, } @@ -100,6 +101,7 @@ impl Default for ControlSettings { respawn: KeyMouse::Key(VirtualKeyCode::Space), interact: KeyMouse::Mouse(MouseButton::Right), toggle_wield: KeyMouse::Key(VirtualKeyCode::T), + swap_loadout: KeyMouse::Key(VirtualKeyCode::LAlt), charge: KeyMouse::Key(VirtualKeyCode::Key1), } } @@ -183,6 +185,7 @@ pub mod con_settings { pub respawn: Button, pub interact: Button, pub toggle_wield: Button, + pub swap_loadout: Button, pub charge: Button, } @@ -268,6 +271,7 @@ pub mod con_settings { respawn: Button::Simple(GilButton::RightTrigger2), interact: Button::Simple(GilButton::LeftTrigger2), toggle_wield: Button::Simple(GilButton::DPadLeft), + swap_loadout: Button::Simple(GilButton::Unknown), charge: Button::Simple(GilButton::Unknown), } } diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index f052ec73a2..f614b280a0 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -49,6 +49,7 @@ pub enum GameInput { Interact, ToggleWield, Charge, + SwapLoadout, } /// Represents a key that the game menus recognise after input mapping @@ -455,6 +456,9 @@ impl Window { map.entry(settings.controls.toggle_wield) .or_default() .push(GameInput::ToggleWield); + map.entry(settings.controls.swap_loadout) + .or_default() + .push(GameInput::SwapLoadout); map.entry(settings.controls.charge) .or_default() .push(GameInput::Charge); From 3ae2b8de2ee2e1246e0d62a09450d56b53f633ee Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 21 Mar 2020 10:32:32 -0700 Subject: [PATCH 184/326] Remove excess code --- common/src/states/utils.rs | 10 ---------- voxygen/src/session.rs | 9 ++++----- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 03b4b7b73e..9e7db75345 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -138,16 +138,6 @@ pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) { } } -/// Checks that player can Swap and updates Loadout -pub fn handle_swap_loadout(data: &JoinData, update: &mut StateUpdate) { - if let CharacterState::Wielding { .. } = update.character { - if data.inputs.swap_loadout.is_pressed() { - //TODO - println!("YAH NAH"); - } - } -} - /// Checks that player can glide and updates `CharacterState` if so pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) { if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 5bee64ee03..f0e4be378d 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -319,11 +319,10 @@ impl PlayState for SessionState { Event::InputUpdate(GameInput::WallLeap, state) => { self.inputs.wall_leap.set_state(state) }, - // Event::InputUpdate(GameInput::ToggleWield, state) => { - // self.inputs.toggle_wield.set_state(state); - // }, - Event::InputUpdate(GameInput::ToggleWield, state) - | Event::InputUpdate(GameInput::SwapLoadout, state) => { + Event::InputUpdate(GameInput::ToggleWield, state) => { + self.inputs.toggle_wield.set_state(state); + }, + Event::InputUpdate(GameInput::SwapLoadout, state) => { let mut client = self.client.borrow_mut(); let entity = client.entity(); let loadout = client From 221f675217503dd5dd76b6b558c49cfe552bf20c Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sat, 21 Mar 2020 14:54:29 -0400 Subject: [PATCH 185/326] spin attack --- voxygen/src/anim/character/attack.rs | 12 + voxygen/src/anim/character/mod.rs | 3 +- voxygen/src/anim/character/spin.rs | 352 +++++++++++++++++++++++++++ voxygen/src/anim/character/wield.rs | 4 +- voxygen/src/scene/figure/mod.rs | 2 +- 5 files changed, 369 insertions(+), 4 deletions(-) create mode 100644 voxygen/src/anim/character/spin.rs diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index 767ee51b27..e5067ae661 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -24,6 +24,11 @@ impl Animation for AttackAnimation { let lab = 1.0; + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.32).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 10.32).sin()); + let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); @@ -86,6 +91,13 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(slow * 1.5) * Quaternion::rotation_z(1.4 + slow * 0.5); next.control.scale = Vec3::one(); + next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); + next.r_foot.scale = Vec3::one(); }, Some(ToolKind::Axe(_)) => { next.l_hand.offset = diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 7b1cd53ffb..6f62053a88 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -11,6 +11,7 @@ pub mod roll; pub mod run; pub mod shoot; pub mod sit; +pub mod spin; pub mod stand; pub mod swim; pub mod wield; @@ -20,7 +21,7 @@ pub use self::{ attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, charge::ChargeAnimation, cidle::CidleAnimation, climb::ClimbAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, roll::RollAnimation, - run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, stand::StandAnimation, + run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation,stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation, }; diff --git a/voxygen/src/anim/character/spin.rs b/voxygen/src/anim/character/spin.rs new file mode 100644 index 0000000000..1314f88ab9 --- /dev/null +++ b/voxygen/src/anim/character/spin.rs @@ -0,0 +1,352 @@ +use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; +use common::comp::item::ToolKind; +use std::f32::consts::PI; +use vek::*; + +pub struct Input { + pub attack: bool, +} +pub struct SpinAnimation; + +#[const_tweaker::tweak(min = -5.0, max = 5.0, step = 0.5)] +const WEP_X: f64 = 0.0; +#[const_tweaker::tweak(min = -5.0, max = 5.0, step = 0.5)] +const WEP_Y: f64 = 0.0; +#[const_tweaker::tweak(min = -5.0, max = 5.0, step = 0.5)] +const WEP_Z: f64 = 0.0; +impl Animation for SpinAnimation { + type Dependency = (Option, f64); + type Skeleton = CharacterSkeleton; + + fn update_skeleton( + skeleton: &Self::Skeleton, + (active_tool_kind, _global_time): Self::Dependency, + anim_time: f64, + rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + *rate = 1.0; + let mut next = (*skeleton).clone(); + + let lab = 1.0; + + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.32).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 10.32).sin()); + + let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); + let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); + let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); + let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin(); + + let spin = (anim_time as f32 * 2.8 * lab as f32).sin(); + let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin(); + + + + let spinner = (((5.0) + / (4.0+ 1.0 * ((anim_time as f32 * lab as f32 * 2.7).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 2.7).sin()); + + let slow = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 12.4).sin()); + let slower = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0).sin()); + + + + + match active_tool_kind { + //TODO: Inventory + Some(ToolKind::Sword(_)) => { + next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-4.5+ spinhalf * *WEP_X as f32, 11.0 + spinhalf * *WEP_Y as f32, 8.0 + spinhalf * *WEP_Z as f32); + next.control.ori = Quaternion::rotation_x(-1.7) + * Quaternion::rotation_y(0.2 + spin* -2.0) + * Quaternion::rotation_z(1.4 + spin* 0.1); + next.control.scale = Vec3::one(); + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * -0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * -0.25) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * 0.1) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * 0.1) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * 0.08) + * Quaternion::rotation_x(0.0 + decel * 0.08) + * Quaternion::rotation_y(decel * -0.08); + next.shorts.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = + Quaternion::rotation_z((spin * 7.0).max(0.3)) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + }, + Some(ToolKind::Axe(_)) => { + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = + Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + }, + Some(ToolKind::Hammer(_)) => { + next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); + + //0,1,5 + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-6.0, 3.0, 5.0 + slower * 5.0); + next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(1.4 + 1.57); + next.control.scale = Vec3::one(); + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = + Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + }, + Some(ToolKind::Staff(_)) => { + next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(0.0, 0.0, 10.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -4.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); + next.control.ori = Quaternion::rotation_x(-1.2) + * Quaternion::rotation_y(slow * 1.5) + * Quaternion::rotation_z(1.4 + slow * 0.5); + next.control.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = + Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + }, + Some(ToolKind::Shield(_)) => { + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = + Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + }, + Some(ToolKind::Bow(_)) => { + next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); + next.l_hand.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(3.0, -1.0, -6.0); + next.r_hand.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(3.0, 2.0, -13.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.3) + * Quaternion::rotation_z(-0.6); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.control.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = + Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + }, + Some(ToolKind::Dagger(_)) => { + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = + Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + }, + Some(ToolKind::Debug(_)) => { + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = + Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + }, + _ => {}, + } + next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); + next.r_foot.scale = Vec3::one(); + + next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.1; + + next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.1; + + next.glider.offset = Vec3::new(0.0, 5.0, 0.0); + next.glider.ori = Quaternion::rotation_y(0.0); + next.glider.scale = Vec3::one() * 0.0; + + next.lantern.offset = Vec3::new(0.0, 0.0, 0.0); + next.lantern.ori = Quaternion::rotation_x(0.0); + next.lantern.scale = Vec3::one() * 0.0; + + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); + next + } +} diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 92516a4c69..f99eb21f46 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -39,9 +39,9 @@ impl Animation for WieldAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(0.0) + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.15) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.08); next.control.scale = Vec3::one(); }, Some(ToolKind::Axe(_)) => { diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index c2cbbdd10e..13f04ded9b 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -514,7 +514,7 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ), - 1 => anim::character::AttackAnimation::update_skeleton( + 1 => anim::character::SpinAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.state_time, From 7857f2ba27e7c9d7702f079da98dad58af301873 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sat, 21 Mar 2020 20:23:22 +0100 Subject: [PATCH 186/326] 27 new armor asset files --- assets/voxygen/voxel/armor/belt/cloth_blue_0.vox | 3 +++ assets/voxygen/voxel/armor/belt/cloth_green_0.vox | 3 +++ assets/voxygen/voxel/armor/belt/cloth_purple_0.vox | 3 +++ assets/voxygen/voxel/armor/chest/cloth_blue_0.vox | 3 +++ assets/voxygen/voxel/armor/chest/cloth_green_0.vox | 3 +++ assets/voxygen/voxel/armor/chest/cloth_purple_0.vox | 3 +++ assets/voxygen/voxel/armor/foot/cloth_blue_0.vox | 3 +++ assets/voxygen/voxel/armor/foot/cloth_green_0.vox | 3 +++ assets/voxygen/voxel/armor/foot/cloth_purple_0.vox | 3 +++ assets/voxygen/voxel/armor/hand/cloth_blue_0_left.vox | 3 +++ assets/voxygen/voxel/armor/hand/cloth_blue_0_right.vox | 3 +++ assets/voxygen/voxel/armor/hand/cloth_green_left_0.vox | 3 +++ assets/voxygen/voxel/armor/hand/cloth_green_right_0.vox | 3 +++ assets/voxygen/voxel/armor/hand/cloth_purple_0_left.vox | 3 +++ assets/voxygen/voxel/armor/hand/cloth_purple_0_right.vox | 3 +++ assets/voxygen/voxel/armor/pants/cloth_blue_0.vox | 3 +++ assets/voxygen/voxel/armor/pants/cloth_green_0.vox | 3 +++ assets/voxygen/voxel/armor/pants/cloth_purple_0.vox | 3 +++ assets/voxygen/voxel/armor/shoulder/cloth_blue_left_0.vox | 3 +++ assets/voxygen/voxel/armor/shoulder/cloth_blue_right_0.vox | 3 +++ assets/voxygen/voxel/armor/shoulder/cloth_green_left_0.vox | 3 +++ assets/voxygen/voxel/armor/shoulder/cloth_green_right_0.vox | 3 +++ assets/voxygen/voxel/armor/shoulder/cloth_purple_left_0.vox | 3 +++ assets/voxygen/voxel/armor/shoulder/cloth_purple_right_0.vox | 3 +++ 24 files changed, 72 insertions(+) create mode 100644 assets/voxygen/voxel/armor/belt/cloth_blue_0.vox create mode 100644 assets/voxygen/voxel/armor/belt/cloth_green_0.vox create mode 100644 assets/voxygen/voxel/armor/belt/cloth_purple_0.vox create mode 100644 assets/voxygen/voxel/armor/chest/cloth_blue_0.vox create mode 100644 assets/voxygen/voxel/armor/chest/cloth_green_0.vox create mode 100644 assets/voxygen/voxel/armor/chest/cloth_purple_0.vox create mode 100644 assets/voxygen/voxel/armor/foot/cloth_blue_0.vox create mode 100644 assets/voxygen/voxel/armor/foot/cloth_green_0.vox create mode 100644 assets/voxygen/voxel/armor/foot/cloth_purple_0.vox create mode 100644 assets/voxygen/voxel/armor/hand/cloth_blue_0_left.vox create mode 100644 assets/voxygen/voxel/armor/hand/cloth_blue_0_right.vox create mode 100644 assets/voxygen/voxel/armor/hand/cloth_green_left_0.vox create mode 100644 assets/voxygen/voxel/armor/hand/cloth_green_right_0.vox create mode 100644 assets/voxygen/voxel/armor/hand/cloth_purple_0_left.vox create mode 100644 assets/voxygen/voxel/armor/hand/cloth_purple_0_right.vox create mode 100644 assets/voxygen/voxel/armor/pants/cloth_blue_0.vox create mode 100644 assets/voxygen/voxel/armor/pants/cloth_green_0.vox create mode 100644 assets/voxygen/voxel/armor/pants/cloth_purple_0.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/cloth_blue_left_0.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/cloth_blue_right_0.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/cloth_green_left_0.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/cloth_green_right_0.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/cloth_purple_left_0.vox create mode 100644 assets/voxygen/voxel/armor/shoulder/cloth_purple_right_0.vox diff --git a/assets/voxygen/voxel/armor/belt/cloth_blue_0.vox b/assets/voxygen/voxel/armor/belt/cloth_blue_0.vox new file mode 100644 index 0000000000..4402e9f2d1 --- /dev/null +++ b/assets/voxygen/voxel/armor/belt/cloth_blue_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:214ecba8428bf90de0e5a4703f028ce474b47121b29d5d786681c5e7081a7c71 +size 1480 diff --git a/assets/voxygen/voxel/armor/belt/cloth_green_0.vox b/assets/voxygen/voxel/armor/belt/cloth_green_0.vox new file mode 100644 index 0000000000..5bac822528 --- /dev/null +++ b/assets/voxygen/voxel/armor/belt/cloth_green_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bbfa2b6ff274de9fab0a7b910849d9059d9879a041166aeff7cfa8b95cdcecac +size 1480 diff --git a/assets/voxygen/voxel/armor/belt/cloth_purple_0.vox b/assets/voxygen/voxel/armor/belt/cloth_purple_0.vox new file mode 100644 index 0000000000..1aec2c1601 --- /dev/null +++ b/assets/voxygen/voxel/armor/belt/cloth_purple_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f038d665dec7532e904efc4a5c64f610e72a8ab3b526f254d5ad6c1d0b55f9d3 +size 1480 diff --git a/assets/voxygen/voxel/armor/chest/cloth_blue_0.vox b/assets/voxygen/voxel/armor/chest/cloth_blue_0.vox new file mode 100644 index 0000000000..fe27d36a65 --- /dev/null +++ b/assets/voxygen/voxel/armor/chest/cloth_blue_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5290d1fb4cc05689bc27b4cd5927809208ef93bbd7f2366c7c95c6d0a99d1a40 +size 2896 diff --git a/assets/voxygen/voxel/armor/chest/cloth_green_0.vox b/assets/voxygen/voxel/armor/chest/cloth_green_0.vox new file mode 100644 index 0000000000..54b8596052 --- /dev/null +++ b/assets/voxygen/voxel/armor/chest/cloth_green_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92e619fe8e555784f6bcf0ec8701741f7868a5b17ef005231bd53ce7343112b6 +size 2896 diff --git a/assets/voxygen/voxel/armor/chest/cloth_purple_0.vox b/assets/voxygen/voxel/armor/chest/cloth_purple_0.vox new file mode 100644 index 0000000000..61d9c3217e --- /dev/null +++ b/assets/voxygen/voxel/armor/chest/cloth_purple_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b97d4b71ec99918480672fd03135cb99276083e2570214b65813f7d399bfb195 +size 2896 diff --git a/assets/voxygen/voxel/armor/foot/cloth_blue_0.vox b/assets/voxygen/voxel/armor/foot/cloth_blue_0.vox new file mode 100644 index 0000000000..eb513adc8c --- /dev/null +++ b/assets/voxygen/voxel/armor/foot/cloth_blue_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57ec1ba7989c2a583b3ae38f940c0b8438e397cf0b4d09d43f0d75f6c7dce028 +size 1480 diff --git a/assets/voxygen/voxel/armor/foot/cloth_green_0.vox b/assets/voxygen/voxel/armor/foot/cloth_green_0.vox new file mode 100644 index 0000000000..31ebc3f794 --- /dev/null +++ b/assets/voxygen/voxel/armor/foot/cloth_green_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a343d79c14eb6101ece034a34f64cdd7f1272f4d5ffdda2b5896732bc2b7ae36 +size 1480 diff --git a/assets/voxygen/voxel/armor/foot/cloth_purple_0.vox b/assets/voxygen/voxel/armor/foot/cloth_purple_0.vox new file mode 100644 index 0000000000..9165d0ac45 --- /dev/null +++ b/assets/voxygen/voxel/armor/foot/cloth_purple_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a45bd1b8ecfcab47da779269ec6dcf67a7e99a0e75f6523167f6e27c946d1b1 +size 1480 diff --git a/assets/voxygen/voxel/armor/hand/cloth_blue_0_left.vox b/assets/voxygen/voxel/armor/hand/cloth_blue_0_left.vox new file mode 100644 index 0000000000..0f13f1967e --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/cloth_blue_0_left.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2facf25e29008eff1e95b7e2943ff96a776d8d8cff74c0fb9b68506a76c8b291 +size 55723 diff --git a/assets/voxygen/voxel/armor/hand/cloth_blue_0_right.vox b/assets/voxygen/voxel/armor/hand/cloth_blue_0_right.vox new file mode 100644 index 0000000000..f71e01b85a --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/cloth_blue_0_right.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f22d6fad1a1752016d79a0f9bbb305be31fb7209d5d5679126de612c68befff9 +size 1240 diff --git a/assets/voxygen/voxel/armor/hand/cloth_green_left_0.vox b/assets/voxygen/voxel/armor/hand/cloth_green_left_0.vox new file mode 100644 index 0000000000..23653e83c1 --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/cloth_green_left_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:961948a44f60d0422d340e03e8328271f28bd653342d1d49ad2db8c2f7d93de1 +size 55723 diff --git a/assets/voxygen/voxel/armor/hand/cloth_green_right_0.vox b/assets/voxygen/voxel/armor/hand/cloth_green_right_0.vox new file mode 100644 index 0000000000..83da1d86f6 --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/cloth_green_right_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de77fef40a136ed944b050fc0cff59dc78f043839f335ad4d578478b73d5b847 +size 55723 diff --git a/assets/voxygen/voxel/armor/hand/cloth_purple_0_left.vox b/assets/voxygen/voxel/armor/hand/cloth_purple_0_left.vox new file mode 100644 index 0000000000..8ffef537eb --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/cloth_purple_0_left.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:93dd0d8050e30b1349218efb63c2e669fa750da83156a6eded1395731b8e057d +size 55723 diff --git a/assets/voxygen/voxel/armor/hand/cloth_purple_0_right.vox b/assets/voxygen/voxel/armor/hand/cloth_purple_0_right.vox new file mode 100644 index 0000000000..148bae4f57 --- /dev/null +++ b/assets/voxygen/voxel/armor/hand/cloth_purple_0_right.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0fd8ff5b52d6d7f8a2d8967da1957d21012958714cce43f0a0105d90b76c3fe +size 1240 diff --git a/assets/voxygen/voxel/armor/pants/cloth_blue_0.vox b/assets/voxygen/voxel/armor/pants/cloth_blue_0.vox new file mode 100644 index 0000000000..8bd1fbf769 --- /dev/null +++ b/assets/voxygen/voxel/armor/pants/cloth_blue_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:016dfd8f53ffbc51cb49f097a55eb5f7f7f33c22a143f50ba1c9b48236b6c6dd +size 56723 diff --git a/assets/voxygen/voxel/armor/pants/cloth_green_0.vox b/assets/voxygen/voxel/armor/pants/cloth_green_0.vox new file mode 100644 index 0000000000..89cba3fc8d --- /dev/null +++ b/assets/voxygen/voxel/armor/pants/cloth_green_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:19c2a53716b89f3ed90078ce5e43eecaff3ebb86b2409b7b0f709224de421310 +size 56723 diff --git a/assets/voxygen/voxel/armor/pants/cloth_purple_0.vox b/assets/voxygen/voxel/armor/pants/cloth_purple_0.vox new file mode 100644 index 0000000000..455e0ef463 --- /dev/null +++ b/assets/voxygen/voxel/armor/pants/cloth_purple_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:872d7aafecb11c883d5f1771cc94224558724bc7f817f2ce605cdbc6b9bf2147 +size 56723 diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_blue_left_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_blue_left_0.vox new file mode 100644 index 0000000000..32e876ce57 --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/cloth_blue_left_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b41bf446f4612c3cd827940e1dc8595c5a623ce1afe31dfe9d028d7b777cf77a +size 1340 diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_blue_right_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_blue_right_0.vox new file mode 100644 index 0000000000..32e876ce57 --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/cloth_blue_right_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b41bf446f4612c3cd827940e1dc8595c5a623ce1afe31dfe9d028d7b777cf77a +size 1340 diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_green_left_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_green_left_0.vox new file mode 100644 index 0000000000..c2d056ebb5 --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/cloth_green_left_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36750ddf18297e5f1ef2c9b4afecb38ded31464c76b655491059b58d081f1873 +size 1340 diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_green_right_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_green_right_0.vox new file mode 100644 index 0000000000..c2d056ebb5 --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/cloth_green_right_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36750ddf18297e5f1ef2c9b4afecb38ded31464c76b655491059b58d081f1873 +size 1340 diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_purple_left_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_purple_left_0.vox new file mode 100644 index 0000000000..19a1ee8e9b --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/cloth_purple_left_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a386f52040323fb01893607aa815c45037143aa84e4b5c504175c0311bf2c45 +size 55823 diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_purple_right_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_purple_right_0.vox new file mode 100644 index 0000000000..69c3b1ea6c --- /dev/null +++ b/assets/voxygen/voxel/armor/shoulder/cloth_purple_right_0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d374ea5deb33c67c366ba76c960b7a7848d4126076ea44eb25dfc3dd10d4ab1 +size 1340 From 14f560f21b19fc25690676faafb7d7b797057f08 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sat, 21 Mar 2020 15:47:16 -0400 Subject: [PATCH 187/326] proper hammer smash, small tweaks --- voxygen/src/anim/character/attack.rs | 262 +++++++++++++++++++++++---- voxygen/src/anim/character/mod.rs | 4 +- voxygen/src/anim/character/spin.rs | 66 +++---- 3 files changed, 256 insertions(+), 76 deletions(-) diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index e5067ae661..51e8641271 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -25,9 +25,9 @@ impl Animation for AttackAnimation { let lab = 1.0; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.32).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 15.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 10.32).sin()); + * ((anim_time as f32 * lab as f32 * 15.0).sin()); let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); @@ -43,37 +43,36 @@ impl Animation for AttackAnimation { .sqrt()) * ((anim_time as f32 * lab as f32 * 4.0).sin()); - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * 0.8, - skeleton_attr.neck_height + 21.0, - ); - next.head.ori = Quaternion::rotation_z(decel * 0.25) - * Quaternion::rotation_x(0.0 + decel * 0.1) - * Quaternion::rotation_y(decel * -0.1); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * -0.2) - * Quaternion::rotation_x(0.0 + decel * -0.2) - * Quaternion::rotation_y(decel * 0.2); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.1) - * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.08) - * Quaternion::rotation_x(0.0 + decel * -0.08) - * Quaternion::rotation_y(decel * 0.08); - next.shorts.scale = Vec3::one(); - match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.04; @@ -91,15 +90,42 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(slow * 1.5) * Quaternion::rotation_z(1.4 + slow * 0.5); next.control.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 8.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); - next.l_foot.scale = Vec3::one(); + next.l_foot.offset = Vec3::new(-3.4, foot * 3.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -0.6); + next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 8.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); - next.r_foot.scale = Vec3::one(); + next.r_foot.offset = Vec3::new(3.4, foot * -3.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 0.6); + next.r_foot.scale = Vec3::one(); }, Some(ToolKind::Axe(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); next.l_hand.ori = Quaternion::rotation_z(-0.8) @@ -138,14 +164,68 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right + slower * 3.0, + -2.0 + skeleton_attr.neck_forward + slower * -3.0, + skeleton_attr.neck_height + 19.0, + ); + next.head.ori = Quaternion::rotation_z(slower * 0.25) + * Quaternion::rotation_x(0.0 + slower * 0.2) + * Quaternion::rotation_y(slower * 0.2); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.control.offset = Vec3::new(-6.0, 3.0, 5.0 + slower * 5.0); + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(slower * 0.2) + * Quaternion::rotation_x(0.0 + slower * 0.2) + * Quaternion::rotation_y(slower * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(slower * 0.1) + * Quaternion::rotation_x(0.0 + slower * 0.1) + * Quaternion::rotation_y(slower * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(slower * 0.08) + * Quaternion::rotation_x(0.0 + slower * 0.08) + * Quaternion::rotation_y(slower * 0.08); + next.shorts.scale = Vec3::one(); + + next.control.offset = Vec3::new(-6.0, 3.0, 8.0 + slower * 5.0); next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(1.4 + 1.57); next.control.scale = Vec3::one(); }, Some(ToolKind::Staff(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.05; @@ -165,6 +245,33 @@ impl Animation for AttackAnimation { next.control.scale = Vec3::one(); }, Some(ToolKind::Shield(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); next.l_hand.ori = Quaternion::rotation_z(-0.8) @@ -190,6 +297,33 @@ impl Animation for AttackAnimation { next.main.scale = Vec3::one(); }, Some(ToolKind::Bow(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); next.l_hand.ori = Quaternion::rotation_x(1.27) * Quaternion::rotation_y(-0.6) @@ -213,6 +347,33 @@ impl Animation for AttackAnimation { next.control.scale = Vec3::one(); }, Some(ToolKind::Dagger(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); next.l_hand.ori = Quaternion::rotation_z(-0.8) @@ -238,6 +399,33 @@ impl Animation for AttackAnimation { next.main.scale = Vec3::one(); }, Some(ToolKind::Debug(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); next.l_hand.ori = Quaternion::rotation_z(-0.8) diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 6f62053a88..12eac67dda 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -21,8 +21,8 @@ pub use self::{ attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, charge::ChargeAnimation, cidle::CidleAnimation, climb::ClimbAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, roll::RollAnimation, - run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation,stand::StandAnimation, - swim::SwimAnimation, wield::WieldAnimation, + run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, + stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation, }; use super::{Bone, Skeleton}; diff --git a/voxygen/src/anim/character/spin.rs b/voxygen/src/anim/character/spin.rs index 1314f88ab9..2f655ae173 100644 --- a/voxygen/src/anim/character/spin.rs +++ b/voxygen/src/anim/character/spin.rs @@ -8,12 +8,6 @@ pub struct Input { } pub struct SpinAnimation; -#[const_tweaker::tweak(min = -5.0, max = 5.0, step = 0.5)] -const WEP_X: f64 = 0.0; -#[const_tweaker::tweak(min = -5.0, max = 5.0, step = 0.5)] -const WEP_Y: f64 = 0.0; -#[const_tweaker::tweak(min = -5.0, max = 5.0, step = 0.5)] -const WEP_Z: f64 = 0.0; impl Animation for SpinAnimation { type Dependency = (Option, f64); type Skeleton = CharacterSkeleton; @@ -43,13 +37,6 @@ impl Animation for SpinAnimation { let spin = (anim_time as f32 * 2.8 * lab as f32).sin(); let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin(); - - - let spinner = (((5.0) - / (4.0+ 1.0 * ((anim_time as f32 * lab as f32 * 2.7).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 2.7).sin()); - let slow = (((5.0) / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) .sqrt()) @@ -59,9 +46,6 @@ impl Animation for SpinAnimation { .sqrt()) * ((anim_time as f32 * lab as f32 * 4.0).sin()); - - - match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { @@ -77,19 +61,19 @@ impl Animation for SpinAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-4.5+ spinhalf * *WEP_X as f32, 11.0 + spinhalf * *WEP_Y as f32, 8.0 + spinhalf * *WEP_Z as f32); + next.control.offset = Vec3::new(-4.5 + spinhalf * 4.0, 11.0, 8.0); next.control.ori = Quaternion::rotation_x(-1.7) - * Quaternion::rotation_y(0.2 + spin* -2.0) - * Quaternion::rotation_z(1.4 + spin* 0.1); + * Quaternion::rotation_y(0.2 + spin * -2.0) + * Quaternion::rotation_z(1.4 + spin * 0.1); next.control.scale = Vec3::one(); next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward + decel * -0.8, skeleton_attr.neck_height + 21.0, ); - next.head.ori = Quaternion::rotation_z(decel * -0.25) + next.head.ori = Quaternion::rotation_z(decel * -0.25) * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); + * Quaternion::rotation_y(decel * 0.1); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, 7.0); next.chest.ori = Quaternion::rotation_z(decel * 0.1) @@ -109,8 +93,9 @@ impl Animation for SpinAnimation { * Quaternion::rotation_y(decel * -0.08); next.shorts.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z((spin * 7.0).max(0.3)) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.ori = Quaternion::rotation_z((spin * 7.0).max(0.3)) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Axe(_)) => { @@ -143,8 +128,9 @@ impl Animation for SpinAnimation { * Quaternion::rotation_y(decel * 0.2); next.chest.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Hammer(_)) => { @@ -173,8 +159,9 @@ impl Animation for SpinAnimation { * Quaternion::rotation_y(decel * 0.2); next.chest.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Staff(_)) => { @@ -196,8 +183,9 @@ impl Animation for SpinAnimation { * Quaternion::rotation_z(1.4 + slow * 0.5); next.control.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Shield(_)) => { @@ -225,8 +213,9 @@ impl Animation for SpinAnimation { * Quaternion::rotation_y(0.0 + accel_med * -0.4); next.main.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Bow(_)) => { @@ -252,8 +241,9 @@ impl Animation for SpinAnimation { * Quaternion::rotation_z(0.0); next.control.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Dagger(_)) => { @@ -281,8 +271,9 @@ impl Animation for SpinAnimation { * Quaternion::rotation_y(0.0 + accel_med * -0.4); next.main.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Debug(_)) => { @@ -310,8 +301,9 @@ impl Animation for SpinAnimation { * Quaternion::rotation_y(0.0 + accel_med * -0.4); next.main.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, _ => {}, From 5361705ca7d61b6768328fdbd5433ebfe8f9459a Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sat, 21 Mar 2020 21:01:50 +0100 Subject: [PATCH 188/326] fix sfx --- common/src/event.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/event.rs b/common/src/event.rs index 754d23aa23..5122dd2677 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -1,5 +1,5 @@ use crate::{comp, sync::Uid}; -use comp::{item::ToolData, InventoryUpdateEvent}; +use comp::{item::ToolKind, InventoryUpdateEvent}; use parking_lot::Mutex; use serde::Deserialize; use specs::Entity as EcsEntity; @@ -40,8 +40,8 @@ pub enum SfxEvent { Fall, ExperienceGained, LevelUp, - Wield(ToolData), - Unwield(ToolData), + Wield(ToolKind), + Unwield(ToolKind), Inventory(InventoryUpdateEvent), } From 819c2767bcee2311de2622f948bf45b1b7294f13 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 21 Mar 2020 14:16:26 -0700 Subject: [PATCH 189/326] * move swap loadout to handle_swap_loadout util fn * impl From for StateUpdate --- common/src/comp/character_state.rs | 18 +++++++++++++++++- common/src/states/basic_block.rs | 11 +---------- common/src/states/basic_melee.rs | 12 ++---------- common/src/states/basic_ranged.rs | 12 ++---------- common/src/states/boost.rs | 12 ++---------- common/src/states/climb.rs | 11 +---------- common/src/states/dash_melee.rs | 12 ++---------- common/src/states/equipping.rs | 12 ++---------- common/src/states/glide.rs | 11 +---------- common/src/states/idle.rs | 11 +---------- common/src/states/roll.rs | 12 ++---------- common/src/states/sit.rs | 11 +---------- common/src/states/timed_combo.rs | 12 ++---------- common/src/states/triple_strike.rs | 12 ++---------- common/src/states/utils.rs | 12 ++++++++++++ common/src/states/wielding.rs | 12 ++---------- common/src/sys/character_behavior.rs | 23 ++++++++++++----------- voxygen/src/session.rs | 17 ++--------------- voxygen/src/settings.rs | 2 +- 19 files changed, 67 insertions(+), 168 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 7aea71d3aa..a51b3ba808 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,7 +1,8 @@ use crate::{ - comp::{Energy, Ori, Pos, Vel}, + comp::{Energy, Loadout, Ori, Pos, Vel}, event::{LocalEvent, ServerEvent}, states::*, + sys::character_behavior::JoinData, }; use serde::{Deserialize, Serialize}; use specs::{Component, FlaggedStorage, HashMapStorage, VecStorage}; @@ -14,10 +15,25 @@ pub struct StateUpdate { pub vel: Vel, pub ori: Ori, pub energy: Energy, + pub loadout: Loadout, pub local_events: VecDeque, pub server_events: VecDeque, } +impl From<&JoinData<'_>> for StateUpdate { + fn from(data: &JoinData) -> Self { + StateUpdate { + pos: *data.pos, + vel: *data.vel, + ori: *data.ori, + energy: *data.energy, + loadout: data.loadout.clone(), + character: data.character.clone(), + local_events: VecDeque::new(), + server_events: VecDeque::new(), + } + } +} #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum CharacterState { Idle, diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index 7b95b934be..06df786b6d 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -3,7 +3,6 @@ use crate::{ comp::StateUpdate, sys::character_behavior::{CharacterBehavior, JoinData}, }; -use std::collections::VecDeque; // const BLOCK_ACCEL: f32 = 30.0; // const BLOCK_SPEED: f32 = 75.0; @@ -13,15 +12,7 @@ pub struct Data; impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: data.character.clone(), - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); handle_move(&data, &mut update); diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 0c1a8d3ea1..e006a6b2da 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -3,7 +3,7 @@ use crate::{ states::utils::*, sys::character_behavior::*, }; -use std::{collections::VecDeque, time::Duration}; +use std::time::Duration; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Data { @@ -19,15 +19,7 @@ pub struct Data { impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: data.character.clone(), - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); handle_move(data, &mut update); diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index f2b9f3c73a..0fb2c699ca 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -4,7 +4,7 @@ use crate::{ states::utils::*, sys::character_behavior::*, }; -use std::{collections::VecDeque, time::Duration}; +use std::time::Duration; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Data { @@ -22,15 +22,7 @@ pub struct Data { impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: data.character.clone(), - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); handle_move(data, &mut update); handle_jump(data, &mut update); diff --git a/common/src/states/boost.rs b/common/src/states/boost.rs index 5f0f855557..c4b547eb17 100644 --- a/common/src/states/boost.rs +++ b/common/src/states/boost.rs @@ -3,7 +3,7 @@ use crate::{ states::utils::*, sys::character_behavior::*, }; -use std::{collections::VecDeque, time::Duration}; +use std::time::Duration; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Data { @@ -14,15 +14,7 @@ pub struct Data { impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: data.character.clone(), - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); handle_move(data, &mut update); diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 314086ef6f..c98a26dbfc 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -7,7 +7,6 @@ use crate::{ }, util::safe_slerp, }; -use std::collections::VecDeque; use vek::{ vec::{Vec2, Vec3}, Lerp, @@ -21,15 +20,7 @@ pub struct Data; impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - character: data.character.clone(), - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); if let Err(_) = update.energy.try_change_by(-5, EnergySource::Climb) { update.character = CharacterState::Idle {}; diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 7b1cdfd51a..2fbc2016e1 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -3,7 +3,7 @@ use crate::{ sys::character_behavior::*, util::safe_slerp, }; -use std::{collections::VecDeque, time::Duration}; +use std::time::Duration; use vek::Vec3; const DASH_SPEED: f32 = 19.0; @@ -23,15 +23,7 @@ pub struct Data { impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: data.character.clone(), - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); if self.initialize { update.vel.0 = data.inputs.look_dir * 20.0; diff --git a/common/src/states/equipping.rs b/common/src/states/equipping.rs index 66506e39c8..6f8e16b54b 100644 --- a/common/src/states/equipping.rs +++ b/common/src/states/equipping.rs @@ -3,7 +3,7 @@ use crate::{ comp::{CharacterState, StateUpdate}, sys::character_behavior::{CharacterBehavior, JoinData}, }; -use std::{collections::VecDeque, time::Duration}; +use std::time::Duration; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Data { @@ -13,15 +13,7 @@ pub struct Data { impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: data.character.clone(), - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); handle_move(&data, &mut update); handle_jump(&data, &mut update); diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 3f947399cc..01d3771dfa 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -3,7 +3,6 @@ use crate::{ sys::character_behavior::{CharacterBehavior, JoinData}, util::safe_slerp, }; -use std::collections::VecDeque; use vek::Vec2; // Gravity is 9.81 * 4, so this makes gravity equal to .15 @@ -16,15 +15,7 @@ pub struct Data; impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: data.character.clone(), - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); // If glide button isn't held or player is on ground, end glide if !data.inputs.glide.is_pressed() || data.physics.on_ground { diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index 76be0b8f67..17b07ebc5a 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -3,21 +3,12 @@ use crate::{ comp::StateUpdate, sys::character_behavior::{CharacterBehavior, JoinData}, }; -use std::collections::VecDeque; pub struct Data; impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: data.character.clone(), - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); handle_move(data, &mut update); handle_jump(data, &mut update); diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index e09405c8e1..6eed23d488 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -3,7 +3,7 @@ use crate::{ sys::character_behavior::{CharacterBehavior, JoinData}, util::safe_slerp, }; -use std::{collections::VecDeque, time::Duration}; +use std::time::Duration; use vek::Vec3; const ROLL_SPEED: f32 = 17.0; @@ -15,15 +15,7 @@ pub struct Data { impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: data.character.clone(), - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); // Update velocity update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index 487206094a..576a05fb88 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -3,22 +3,13 @@ use crate::{ comp::{CharacterState, StateUpdate}, sys::character_behavior::{CharacterBehavior, JoinData}, }; -use std::collections::VecDeque; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Data; impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: data.character.clone(), - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); handle_wield(data, &mut update); diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index 56be959851..0883f9c77a 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -2,7 +2,7 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, StateUpdate}, sys::character_behavior::{CharacterBehavior, JoinData}, }; -use std::{collections::VecDeque, time::Duration}; +use std::time::Duration; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Data { /// Denotes what stage (of 3) the attack is in @@ -21,15 +21,7 @@ pub struct Data { impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: data.character.clone(), - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); let new_stage_time_active = self .stage_time_active diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index ee312a7384..d8197f29ab 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -3,7 +3,7 @@ use crate::{ states::utils::*, sys::character_behavior::{CharacterBehavior, JoinData}, }; -use std::{collections::VecDeque, time::Duration}; +use std::time::Duration; use vek::vec::Vec2; // In millis @@ -34,15 +34,7 @@ pub struct Data { impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - character: data.character.clone(), - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update= StateUpdate::from(data); let stage_time_active = self .stage_time_active diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 9e7db75345..ba828a3cba 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -138,6 +138,18 @@ pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) { } } +/// Checks that player can Swap Weapons and updates `Loadout` if so +pub fn handle_swap_loadout(data: &JoinData, update: &mut StateUpdate) { + if let CharacterState::Wielding { .. } = update.character { + if data.inputs.swap_loadout.is_just_pressed() { + let mut new_loadout = data.loadout.clone(); + new_loadout.active_item = data.loadout.second_item.clone(); + new_loadout.second_item = data.loadout.active_item.clone(); + update.loadout = new_loadout; + } + } +} + /// Checks that player can glide and updates `CharacterState` if so pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) { if let CharacterState::Idle { .. } | CharacterState::Wielding { .. } = update.character { diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 07f5ba358c..7b0b008a5e 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -3,21 +3,12 @@ use crate::{ comp::StateUpdate, sys::character_behavior::{CharacterBehavior, JoinData}, }; -use std::collections::VecDeque; pub struct Data; impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate { - character: data.character.clone(), - pos: *data.pos, - vel: *data.vel, - ori: *data.ori, - energy: *data.energy, - local_events: VecDeque::new(), - server_events: VecDeque::new(), - }; + let mut update = StateUpdate::from(data); handle_move(&data, &mut update); handle_jump(&data, &mut update); @@ -25,6 +16,7 @@ impl CharacterBehavior for Data { handle_climb(&data, &mut update); handle_glide(&data, &mut update); handle_unwield(&data, &mut update); + handle_swap_loadout(&data, &mut update); handle_primary_input(&data, &mut update); handle_secondary_input(&data, &mut update); handle_dodge_input(&data, &mut update); diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index d51cb719a7..0edf904f4c 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -31,9 +31,9 @@ pub struct JoinData<'a> { pub inputs: &'a ControllerInputs, pub stats: &'a Stats, pub energy: &'a Energy, + pub loadout: &'a Loadout, pub body: &'a Body, pub physics: &'a PhysicsState, - pub loadout: &'a Loadout, pub attacking: Option<&'a Attacking>, pub updater: &'a LazyUpdate, } @@ -46,11 +46,11 @@ pub type JoinTuple<'a> = ( &'a mut Vel, &'a mut Ori, &'a mut Energy, + &'a mut Loadout, &'a Controller, &'a Stats, &'a Body, &'a PhysicsState, - &'a Loadout, Option<&'a Attacking>, ); @@ -64,12 +64,12 @@ impl<'a> JoinData<'a> { vel: j.4, ori: j.5, energy: j.6, - controller: j.7, - inputs: &j.7.inputs, - stats: j.8, - body: j.9, - physics: j.10, - loadout: j.11, + loadout: j.7, + controller: j.8, + inputs: &j.8.inputs, + stats: j.9, + body: j.10, + physics: j.11, attacking: j.12, updater, dt, @@ -98,11 +98,11 @@ impl<'a> System<'a> for Sys { WriteStorage<'a, Vel>, WriteStorage<'a, Ori>, WriteStorage<'a, Energy>, + WriteStorage<'a, Loadout>, ReadStorage<'a, Controller>, ReadStorage<'a, Stats>, ReadStorage<'a, Body>, ReadStorage<'a, PhysicsState>, - ReadStorage<'a, Loadout>, ReadStorage<'a, Attacking>, ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, @@ -122,11 +122,11 @@ impl<'a> System<'a> for Sys { mut velocities, mut orientations, mut energies, + mut loadouts, controllers, stats, bodies, physics_states, - loadouts, attacking_storage, uids, mountings, @@ -140,11 +140,11 @@ impl<'a> System<'a> for Sys { &mut velocities, &mut orientations, &mut energies, + &mut loadouts, &controllers, &stats, &bodies, &physics_states, - &loadouts, attacking_storage.maybe(), ) .join(); @@ -204,6 +204,7 @@ impl<'a> System<'a> for Sys { *tuple.4 = state_update.vel; *tuple.5 = state_update.ori; *tuple.6 = state_update.energy; + *tuple.7 = state_update.loadout; local_bus.emitter().append(&mut state_update.local_events); server_bus.emitter().append(&mut state_update.server_events); } diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index f0e4be378d..db427d26f5 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -323,21 +323,8 @@ impl PlayState for SessionState { self.inputs.toggle_wield.set_state(state); }, Event::InputUpdate(GameInput::SwapLoadout, state) => { - let mut client = self.client.borrow_mut(); - let entity = client.entity(); - let loadout = client - .state() - .read_storage::() - .get(entity) - .cloned(); - - if let Some(loadout) = loadout { - let mut new_loadout = loadout.clone(); - new_loadout.second_item = loadout.active_item; - new_loadout.active_item = loadout.second_item; - - client.state_mut().write_component(entity, new_loadout); - } + println!("{:?}", state); + self.inputs.swap_loadout.set_state(state); }, Event::InputUpdate(GameInput::Mount, true) => { let mut client = self.client.borrow_mut(); diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index d802c3dddd..86dccca346 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -101,7 +101,7 @@ impl Default for ControlSettings { respawn: KeyMouse::Key(VirtualKeyCode::Space), interact: KeyMouse::Mouse(MouseButton::Right), toggle_wield: KeyMouse::Key(VirtualKeyCode::T), - swap_loadout: KeyMouse::Key(VirtualKeyCode::LAlt), + swap_loadout: KeyMouse::Key(VirtualKeyCode::Q), charge: KeyMouse::Key(VirtualKeyCode::Key1), } } From c5378b70651c064423ac2075da0d1f5dade46562 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 21 Mar 2020 14:55:04 -0700 Subject: [PATCH 190/326] Better triple_strike handling --- common/src/comp/ability.rs | 1 + common/src/states/triple_strike.rs | 19 +++++++++++++++++-- voxygen/src/scene/figure/mod.rs | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index a114326870..3753ea55da 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -151,6 +151,7 @@ impl From<&CharacterAbility> for CharacterState { stage_exhausted: false, stage_time_active: Duration::default(), should_transition: true, + initialized: false, }) }, } diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index d8197f29ab..b5a930367f 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -30,11 +30,13 @@ pub struct Data { pub stage_exhausted: bool, /// Whether to go to next stage pub should_transition: bool, + /// Whether state has performed intialization logic + pub initialized: bool, } impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update= StateUpdate::from(data); + let mut update = StateUpdate::from(data); let stage_time_active = self .stage_time_active @@ -42,6 +44,7 @@ impl CharacterBehavior for Data { .unwrap_or(Duration::default()); let mut should_transition = self.should_transition; + let mut initialized = self.initialized; // If player stops holding input, if !data.inputs.primary.is_pressed() { @@ -54,11 +57,20 @@ impl CharacterBehavior for Data { should_transition = false; } + if !initialized { + update.ori.0 = data.inputs.look_dir.normalized(); + initialized = true; + } + if self.stage < 3 { // Handling movement if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { let adjusted_accel = if self.stage == 0 { - INITIAL_ACCEL + if data.physics.touch_entity.is_none() { + INITIAL_ACCEL + } else { + 0.0 + } } else { SECONDARY_ACCEL }; @@ -94,6 +106,7 @@ impl CharacterBehavior for Data { stage_time_active, stage_exhausted: true, should_transition, + initialized, }); } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { if should_transition { @@ -103,6 +116,7 @@ impl CharacterBehavior for Data { stage_time_active: Duration::default(), stage_exhausted: false, should_transition, + initialized, }); } else { // Done @@ -117,6 +131,7 @@ impl CharacterBehavior for Data { stage_time_active, stage_exhausted: self.stage_exhausted, should_transition, + initialized, }); } } else { diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 13f04ded9b..0944c8615b 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -507,7 +507,7 @@ impl FigureMgr { ) }, CharacterState::TripleStrike(s) => match s.stage { - 0 => anim::character::AttackAnimation::update_skeleton( + 0 => anim::character::ChargeAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.state_time, @@ -521,7 +521,7 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ), - _ => anim::character::ChargeAnimation::update_skeleton( + _ => anim::character::AttackAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.state_time, From b96d71a8c7aea8bca9fa3ec098b2b6cfeff71759 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 21 Mar 2020 15:06:42 -0700 Subject: [PATCH 191/326] Reset vel on triple_strike --- common/src/states/triple_strike.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index b5a930367f..9cf1b159de 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -4,7 +4,7 @@ use crate::{ sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::time::Duration; -use vek::vec::Vec2; +use vek::vec::{Vec2, Vec3}; // In millis const STAGE_DURATION: u64 = 600; @@ -59,20 +59,21 @@ impl CharacterBehavior for Data { if !initialized { update.ori.0 = data.inputs.look_dir.normalized(); + update.vel.0 = Vec3::zero(); initialized = true; } if self.stage < 3 { // Handling movement if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { - let adjusted_accel = if self.stage == 0 { - if data.physics.touch_entity.is_none() { + let adjusted_accel = if data.physics.touch_entity.is_none() { + if self.stage == 0 { INITIAL_ACCEL } else { - 0.0 + SECONDARY_ACCEL } } else { - SECONDARY_ACCEL + 0.0 }; // Move player forward while in first third of each stage From f3990859740e2dd414e24d4cb2d1c224ff728093 Mon Sep 17 00:00:00 2001 From: Imbris Date: Sat, 21 Mar 2020 18:48:03 -0400 Subject: [PATCH 192/326] Flip models for hands, shoulders, and feet of humanoids --- .../voxel/humanoid_armor_hand_manifest.ron | 10 +- .../humanoid_armor_shoulder_manifest.ron | 14 +- common/src/figure/mod.rs | 19 ++- voxygen/src/scene/figure/load.rs | 142 +++++++----------- 4 files changed, 83 insertions(+), 102 deletions(-) diff --git a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron index d94053fea5..5872dd0e77 100644 --- a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron @@ -1,7 +1,7 @@ ({ Bare: ( left: ( - vox_spec: ("armor.hand.hand_left_none", (-1.5, -1.5, -7.0)), + vox_spec: ("armor.hand.hand_right_none", (-1.5, -1.5, -7.0)), color: None ), right: ( @@ -11,7 +11,7 @@ ), Assassin: ( left: ( - vox_spec: ("armor.hand.assa_left", (-1.5, -1.5, -7.0)), + vox_spec: ("armor.hand.assa_right", (-1.5, -1.5, -7.0)), color: None ), right: ( @@ -21,7 +21,7 @@ ), Cloth: ( left: ( - vox_spec: ("armor.hand.cloth_basic_left", (-1.5, -1.5, -7.0)), + vox_spec: ("armor.hand.cloth_basic_right", (-1.5, -1.5, -7.0)), color: None ), right: ( @@ -31,7 +31,7 @@ ), Plate0: ( left: ( - vox_spec: ("armor.hand.plate_left-0", (-1.5, -1.5, -7.0)), + vox_spec: ("armor.hand.plate_right-0", (-1.5, -1.5, -7.0)), color: None ), right: ( @@ -41,7 +41,7 @@ ), Leather0: ( left: ( - vox_spec: ("armor.hand.leather_left-0", (-1.5, -1.5, -7.0)), + vox_spec: ("armor.hand.leather_right-0", (-1.5, -1.5, -7.0)), color: None ), right: ( diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index e0818d2729..d0551ad6d3 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -12,7 +12,7 @@ ), Brown1: ( left: ( - vox_spec: ("armor.shoulder.brown_left", (-3.0, -3.5, 1.0)), + vox_spec: ("armor.shoulder.brown_right", (-3.0, -3.5, 1.0)), color: None ), right: ( @@ -22,7 +22,7 @@ ), Assassin: ( left: ( - vox_spec: ("armor.shoulder.assa_left", (-4.0, -3.5, 1.0)), + vox_spec: ("armor.shoulder.assa_right", (-4.0, -3.5, 1.0)), color: None ), right: ( @@ -32,7 +32,7 @@ ), Assassin: ( left: ( - vox_spec: ("armor.shoulder.assa_left", (-4.0, -3.5, 1.0)), + vox_spec: ("armor.shoulder.assa_right", (-4.0, -3.5, 1.0)), color: None ), right: ( @@ -42,7 +42,7 @@ ), Chain: ( left: ( - vox_spec: ("armor.shoulder.chain_left-1", (-4.0, -3.5, 1.0)), + vox_spec: ("armor.shoulder.chain_right-1", (-4.0, -3.5, 1.0)), color: None ), right: ( @@ -52,7 +52,7 @@ ), Plate0: ( left: ( - vox_spec: ("armor.shoulder.plate_left-0", (-3.6, -3.5, 1.0)), + vox_spec: ("armor.shoulder.plate_right-0", (-3.6, -3.5, 1.0)), color: None ), right: ( @@ -62,7 +62,7 @@ ), Leather0: ( left: ( - vox_spec: ("armor.shoulder.leather_left-0", (-3.2, -3.5, 1.0)), + vox_spec: ("armor.shoulder.leather_right-0", (-3.2, -3.5, 1.0)), color: None ), right: ( @@ -72,7 +72,7 @@ ), Leather1: ( left: ( - vox_spec: ("armor.shoulder.leather_left-1", (-3.6, -4.5, 1.0)), + vox_spec: ("armor.shoulder.leather_right-1", (-3.6, -4.5, 1.0)), color: None ), right: ( diff --git a/common/src/figure/mod.rs b/common/src/figure/mod.rs index 4a3e6aa787..0be11c7bf6 100644 --- a/common/src/figure/mod.rs +++ b/common/src/figure/mod.rs @@ -149,10 +149,8 @@ impl MatSegment { _ => None, }) } -} -impl From<&DotVoxData> for MatSegment { - fn from(dot_vox_data: &DotVoxData) -> Self { + pub fn from_vox(dot_vox_data: &DotVoxData, flipped: bool) -> Self { if let Some(model) = dot_vox_data.models.get(0) { let palette = dot_vox_data .palette @@ -186,7 +184,16 @@ impl From<&DotVoxData> for MatSegment { }; vol.set( - Vec3::new(voxel.x, voxel.y, voxel.z).map(|e| i32::from(e)), + Vec3::new( + if flipped { + model.size.x as u8 - 1 - voxel.x + } else { + voxel.x + }, + voxel.y, + voxel.z, + ) + .map(|e| i32::from(e)), block, ) .unwrap(); @@ -198,3 +205,7 @@ impl From<&DotVoxData> for MatSegment { } } } + +impl From<&DotVoxData> for MatSegment { + fn from(dot_vox_data: &DotVoxData) -> Self { Self::from_vox(dot_vox_data, false) } +} diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index e27532161e..65b5dff155 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -21,6 +21,7 @@ use common::{ ItemKind, Loadout, }, figure::{DynaUnionizer, MatSegment, Material, Segment}, + vol::SizedVol, }; use dot_vox::DotVoxData; use hashbrown::HashMap; @@ -49,6 +50,9 @@ fn graceful_load_segment(mesh_name: &str) -> Segment { fn graceful_load_mat_segment(mesh_name: &str) -> MatSegment { MatSegment::from(graceful_load_vox(mesh_name).as_ref()) } +fn graceful_load_mat_segment_flipped(mesh_name: &str) -> MatSegment { + MatSegment::from_vox(graceful_load_vox(mesh_name).as_ref(), true) +} fn generate_mesh(segment: &Segment, offset: Vec3) -> Mesh { Meshable::::generate_mesh(segment, offset).0 @@ -302,7 +306,7 @@ impl HumArmorShoulderSpec { .unwrap() } - pub fn mesh_left_shoulder(&self, body: &Body, loadout: &Loadout) -> Mesh { + fn mesh_shoulder(&self, body: &Body, loadout: &Loadout, flipped: bool) -> Mesh { let shoulder = if let Some(ItemKind::Armor { kind: Armor::Shoulder(shoulder), .. @@ -322,42 +326,36 @@ impl HumArmorShoulderSpec { }; let shoulder_segment = color_segment( - graceful_load_mat_segment(&spec.left.vox_spec.0), + if flipped { + graceful_load_mat_segment_flipped(&spec.left.vox_spec.0) + } else { + graceful_load_mat_segment(&spec.right.vox_spec.0) + }, body.race.skin_color(body.skin), body.race.hair_color(body.hair_color), body.race.eye_color(body.eye_color), ); - generate_mesh(&shoulder_segment, Vec3::from(spec.left.vox_spec.1)) + // TODO: use this if we can + /*let mut offset = spec.vox_spec.1; + if flipped { + offset[0] = -(shoulder_segment.size().x as f32) - offset[0]; + }*/ + let offset = if flipped { + spec.left.vox_spec.1 + } else { + spec.right.vox_spec.1 + }; + + generate_mesh(&shoulder_segment, Vec3::from(offset)) + } + + pub fn mesh_left_shoulder(&self, body: &Body, loadout: &Loadout) -> Mesh { + self.mesh_shoulder(body, loadout, true) } pub fn mesh_right_shoulder(&self, body: &Body, loadout: &Loadout) -> Mesh { - let shoulder = if let Some(ItemKind::Armor { - kind: Armor::Shoulder(shoulder), - .. - }) = loadout.shoulder.as_ref().map(|i| &i.kind) - { - shoulder - } else { - &Shoulder::None - }; - - let spec = match self.0.get(&shoulder) { - Some(spec) => spec, - None => { - error!("No shoulder specification exists for {:?}", shoulder); - return load_mesh("not_found", Vec3::new(-2.0, -3.5, 0.1)); - }, - }; - - let shoulder_segment = color_segment( - graceful_load_mat_segment(&spec.right.vox_spec.0), - body.race.skin_color(body.skin), - body.race.hair_color(body.hair_color), - body.race.eye_color(body.eye_color), - ); - - generate_mesh(&shoulder_segment, Vec3::from(spec.right.vox_spec.1)) + self.mesh_shoulder(body, loadout, false) } } @@ -420,7 +418,7 @@ impl HumArmorHandSpec { .unwrap() } - pub fn mesh_left_hand(&self, body: &Body, loadout: &Loadout) -> Mesh { + fn mesh_hand(&self, body: &Body, loadout: &Loadout, flipped: bool) -> Mesh { let hand = if let Some(ItemKind::Armor { kind: Armor::Hand(hand), .. @@ -440,42 +438,31 @@ impl HumArmorHandSpec { }; let hand_segment = color_segment( - graceful_load_mat_segment(&spec.left.vox_spec.0), + if flipped { + graceful_load_mat_segment_flipped(&spec.left.vox_spec.0) + } else { + graceful_load_mat_segment(&spec.right.vox_spec.0) + }, body.race.skin_color(body.skin), body.race.hair_color(body.hair_color), body.race.eye_color(body.eye_color), ); - generate_mesh(&hand_segment, Vec3::from(spec.left.vox_spec.1)) + let offset = if flipped { + spec.left.vox_spec.1 + } else { + spec.right.vox_spec.1 + }; + + generate_mesh(&hand_segment, Vec3::from(offset)) + } + + pub fn mesh_left_hand(&self, body: &Body, loadout: &Loadout) -> Mesh { + self.mesh_hand(body, loadout, true) } pub fn mesh_right_hand(&self, body: &Body, loadout: &Loadout) -> Mesh { - let hand = if let Some(ItemKind::Armor { - kind: Armor::Hand(hand), - .. - }) = loadout.hand.as_ref().map(|i| &i.kind) - { - hand - } else { - &Hand::Bare - }; - - let spec = match self.0.get(&hand) { - Some(spec) => spec, - None => { - error!("No hand specification exists for {:?}", hand); - return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0)); - }, - }; - - let hand_segment = color_segment( - graceful_load_mat_segment(&spec.right.vox_spec.0), - body.race.skin_color(body.skin), - body.race.hair_color(body.hair_color), - body.race.eye_color(body.eye_color), - ); - - generate_mesh(&hand_segment, Vec3::from(spec.right.vox_spec.1)) + self.mesh_hand(body, loadout, false) } } @@ -574,7 +561,7 @@ impl HumArmorFootSpec { .unwrap() } - pub fn mesh_left_foot(&self, body: &Body, loadout: &Loadout) -> Mesh { + fn mesh_foot(&self, body: &Body, loadout: &Loadout, flipped: bool) -> Mesh { let foot = if let Some(ItemKind::Armor { kind: Armor::Foot(foot), .. @@ -594,7 +581,11 @@ impl HumArmorFootSpec { }; let foot_segment = color_segment( - graceful_load_mat_segment(&spec.vox_spec.0), + if flipped { + graceful_load_mat_segment_flipped(&spec.vox_spec.0) + } else { + graceful_load_mat_segment(&spec.vox_spec.0) + }, body.race.skin_color(body.skin), body.race.hair_color(body.hair_color), body.race.eye_color(body.eye_color), @@ -603,33 +594,12 @@ impl HumArmorFootSpec { generate_mesh(&foot_segment, Vec3::from(spec.vox_spec.1)) } + pub fn mesh_left_foot(&self, body: &Body, loadout: &Loadout) -> Mesh { + self.mesh_foot(body, loadout, true) + } + pub fn mesh_right_foot(&self, body: &Body, loadout: &Loadout) -> Mesh { - let foot = if let Some(ItemKind::Armor { - kind: Armor::Foot(foot), - .. - }) = loadout.foot.as_ref().map(|i| &i.kind) - { - foot - } else { - &Foot::Bare - }; - - let spec = match self.0.get(&foot) { - Some(spec) => spec, - None => { - error!("No foot specification exists for {:?}", foot); - return load_mesh("not_found", Vec3::new(-2.5, -3.5, -9.0)); - }, - }; - - let foot_segment = color_segment( - graceful_load_mat_segment(&spec.vox_spec.0), - body.race.skin_color(body.skin), - body.race.hair_color(body.hair_color), - body.race.eye_color(body.eye_color), - ); - - generate_mesh(&foot_segment, Vec3::from(spec.vox_spec.1)) + self.mesh_foot(body, loadout, false) } } From 862efb147c9b4b94963d81e4c772172557e00de9 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 21 Mar 2020 15:55:20 -0700 Subject: [PATCH 193/326] clean up based on pr review comment --- common/src/comp/ability.rs | 11 +++++++---- common/src/comp/controller.rs | 20 -------------------- common/src/event.rs | 22 +++++++++++++++++----- common/src/state.rs | 14 ++++++++------ common/src/states/triple_strike.rs | 6 ------ common/src/states/utils.rs | 16 ++++++++-------- common/src/sys/agent.rs | 1 + common/src/sys/character_behavior.rs | 22 ++++------------------ common/src/sys/combat.rs | 8 +------- 9 files changed, 46 insertions(+), 74 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 3753ea55da..ca4eee8547 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -3,7 +3,8 @@ use crate::{ states::*, sys::character_behavior::JoinData, }; -use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage}; +use specs::{Component, FlaggedStorage, HashMapStorage}; +use specs_idvs::IDVStorage; use std::time::Duration; #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] @@ -40,7 +41,9 @@ pub enum CharacterAbility { } impl CharacterAbility { - pub fn test_requirements(&self, data: &JoinData, update: &mut StateUpdate) -> bool { + /// Attempts to fulfill requirements, mutating `update` (taking energy) if + /// applicable. + pub fn requirements_paid(&self, data: &JoinData, update: &mut StateUpdate) -> bool { match self { CharacterAbility::Roll => { data.physics.on_ground @@ -64,7 +67,7 @@ impl CharacterAbility { } impl Component for CharacterAbility { - type Storage = DenseVecStorage; + type Storage = IDVStorage; } #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] @@ -159,5 +162,5 @@ impl From<&CharacterAbility> for CharacterState { } impl Component for Loadout { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 52e718d974..d174a46b0b 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -112,8 +112,6 @@ impl Default for Input { #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct ControllerInputs { - // When adding new inputs: - // 1. Add to tick() update pub primary: Input, pub secondary: Input, pub sit: Input, @@ -155,24 +153,6 @@ impl ControllerInputs { self.swap_loadout.tick(dt); self.charge.tick(dt); } - - /* - /// Updates `inputs.move_dir`. - pub fn update_move_dir(&mut self) { - self.move_dir = if self.move_dir.magnitude_squared() > 1.0 { - // Cap move_dir to 1 - self.move_dir.normalized() - } else { - self.move_dir - }; - } - - /// Updates `inputs.look_dir` - pub fn update_look_dir(&mut self) { - self.look_dir - .try_normalized() - .unwrap_or(self.move_dir.into()); - }*/ } impl Controller { diff --git a/common/src/event.rs b/common/src/event.rs index 5122dd2677..1fbadc8f69 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -46,16 +46,28 @@ pub enum SfxEvent { } pub enum LocalEvent { + /// Applies upward force to entity's `Vel` Jump(EcsEntity), - Knockback(EcsEntity), + /// Applies the `force` + implicit upward force, in `dir` direction to + /// `entity`'s `Vel` + KnockUp { + entity: EcsEntity, + dir: Vec3, + force: f32, + }, + /// Applies the `force`, in `dir` direction to `entity`'s `Vel` + ApplyForce { + entity: EcsEntity, + dir: Vec3, + force: f32, + }, + /// Applies leaping force to `entity`'s `Vel` away from `wall_dir` direction WallLeap { entity: EcsEntity, wall_dir: Vec3, }, - Boost { - entity: EcsEntity, - vel: Vec3, - }, + /// Applies `vel` velocity to `entity` + Boost { entity: EcsEntity, vel: Vec3 }, } pub enum ServerEvent { diff --git a/common/src/state.rs b/common/src/state.rs index 2ba2111184..d9e16b2907 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -351,7 +351,6 @@ impl State { let events = self.ecs.read_resource::>().recv_all(); for event in events { let mut velocities = self.ecs.write_storage::(); - let mut orientations = self.ecs.write_storage::(); let mut controllers = self.ecs.write_storage::(); match event { LocalEvent::Jump(entity) => { @@ -359,12 +358,15 @@ impl State { vel.0.z = HUMANOID_JUMP_ACCEL; } }, - LocalEvent::Knockback(entity) => { + LocalEvent::KnockUp { entity, dir, force } => { 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; - } + vel.0 = dir * force; + vel.0.z = HUMANOID_JUMP_ACCEL; + } + }, + LocalEvent::ApplyForce { entity, dir, force } => { + if let Some(vel) = velocities.get_mut(entity) { + vel.0 = dir * force; } }, LocalEvent::WallLeap { entity, wall_dir } => { diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 9cf1b159de..d71d5355f9 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -48,12 +48,6 @@ impl CharacterBehavior for Data { // If player stops holding input, if !data.inputs.primary.is_pressed() { - // // Done - // update.character = CharacterState::Wielding; - // // Make sure attack component is removed - // data.updater.remove::(data.entity); - // return update; - should_transition = false; } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index ba828a3cba..e79c1c186a 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -105,14 +105,14 @@ pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { time_left: tool.equip_time(), }); } else { - update.character = CharacterState::Idle {}; + update.character = CharacterState::Idle; }; } /// Checks that player can `Sit` and updates `CharacterState` if so pub fn handle_sit(data: &JoinData, update: &mut StateUpdate) { if data.inputs.sit.is_pressed() && data.physics.on_ground && data.body.is_humanoid() { - update.character = CharacterState::Sit {}; + update.character = CharacterState::Sit; } } @@ -125,7 +125,7 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { && data.body.is_humanoid() && update.energy.current() > 100 { - update.character = CharacterState::Climb {}; + update.character = CharacterState::Climb; } } @@ -133,7 +133,7 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) { if let CharacterState::Wielding { .. } = update.character { if data.inputs.toggle_wield.is_pressed() { - update.character = CharacterState::Idle {}; + update.character = CharacterState::Idle; } } } @@ -158,7 +158,7 @@ pub fn handle_glide(data: &JoinData, update: &mut StateUpdate) { && !data.physics.in_fluid && data.body.is_humanoid() { - update.character = CharacterState::Glide {}; + update.character = CharacterState::Glide; } } } @@ -181,7 +181,7 @@ pub fn handle_primary_input(data: &JoinData, update: &mut StateUpdate) { .active_item .as_ref() .and_then(|i| i.primary_ability.as_ref()) - .filter(|ability| ability.test_requirements(data, update)) + .filter(|ability| ability.requirements_paid(data, update)) { update.character = ability.into(); } @@ -197,7 +197,7 @@ pub fn handle_secondary_input(data: &JoinData, update: &mut StateUpdate) { .active_item .as_ref() .and_then(|i| i.secondary_ability.as_ref()) - .filter(|ability| ability.test_requirements(data, update)) + .filter(|ability| ability.requirements_paid(data, update)) { update.character = ability.into(); } @@ -213,7 +213,7 @@ pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { .active_item .as_ref() .and_then(|i| i.dodge_ability.as_ref()) - .filter(|ability| ability.test_requirements(data, update)) + .filter(|ability| ability.requirements_paid(data, update)) { update.character = ability.into(); } diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index 866bf00e5c..2c9186b26d 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -70,6 +70,7 @@ impl<'a> System<'a> for Sys { controller.reset(); + //TODO: Make npcs have valid `look_dir` during all activities let mut inputs = &mut controller.inputs; const AVG_FOLLOW_DIST: f32 = 6.0; diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 0edf904f4c..e82830066b 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -77,12 +77,9 @@ impl<'a> JoinData<'a> { } } -/// /// ## Character State System -/// #### Calls updates to `CharacterState`s. Acts on tuples of ( -/// `CharacterState`, `Pos`, `Vel`, and `Ori` ). -/// -/// _System forms `CharacterEntityData` tuples and passes those to `ActionState` -/// `update()` fn, then does the same for `MoveState` `update`_ +/// ## Character Behavior System +/// Passes `JoinData` to `CharacterState`'s `behavior` handler fn's. Recieves a +/// `StateUpdate` in return and performs updates to ECS Components from that. pub struct Sys; impl<'a> System<'a> for Sys { @@ -176,7 +173,7 @@ impl<'a> System<'a> for Sys { CharacterState::Climb => states::climb::Data.behavior(&j), CharacterState::Glide => states::glide::Data.behavior(&j), CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, &j), - CharacterState::BasicBlock => states::basic_block::Data.behavior(&j), + CharacterState::BasicBlock => states::basic_block::Data.behavior(&j), CharacterState::Roll(data) => data.behavior(&j), CharacterState::Wielding => states::wielding::Data.behavior(&j), CharacterState::Equipping(data) => data.behavior(&j), @@ -186,17 +183,6 @@ impl<'a> System<'a> for Sys { CharacterState::Boost(data) => data.behavior(&j), CharacterState::DashMelee(data) => data.behavior(&j), CharacterState::TimedCombo(data) => data.behavior(&j), - - // Do not use default match. - // _ => StateUpdate { - // character: *j.character, - // pos: *j.pos, - // vel: *j.vel, - // ori: *j.ori, - // energy: *j.energy, - // local_events: VecDeque::new(), - // server_events: VecDeque::new(), - // }, }; *tuple.2 = state_update.character; diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 7a910f20cd..e48272c36e 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -3,12 +3,10 @@ use crate::{ Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos, Scale, Stats, }, - event::{EventBus, LocalEvent, ServerEvent}, - state::DeltaTime, + event::{EventBus, ServerEvent}, sync::Uid, }; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; -// use std::time::Duration; use vek::*; const BLOCK_EFFICIENCY: f32 = 0.9; @@ -23,8 +21,6 @@ impl<'a> System<'a> for Sys { type SystemData = ( Entities<'a>, Read<'a, EventBus>, - Read<'a, EventBus>, - Read<'a, DeltaTime>, ReadStorage<'a, Uid>, ReadStorage<'a, Pos>, ReadStorage<'a, Ori>, @@ -41,8 +37,6 @@ impl<'a> System<'a> for Sys { ( entities, server_bus, - _local_bus, - _dt, uids, positions, orientations, From 366978f16ea5ca5e230aa2e7dae8f08cd585b365 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sat, 21 Mar 2020 16:04:45 -0700 Subject: [PATCH 194/326] remove CharacterAbility ecs component sync --- common/src/state.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/common/src/state.rs b/common/src/state.rs index d9e16b2907..1c7466e8bc 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -107,7 +107,6 @@ impl State { ecs.register_sync_marker(); // Register server -> all clients synced components. ecs.register::(); - ecs.register::(); ecs.register::(); ecs.register::(); ecs.register::(); From f6731dc770cbf0c73605417d2cd52c30f62bf5a7 Mon Sep 17 00:00:00 2001 From: Pfauenauge Date: Sun, 22 Mar 2020 00:20:49 +0100 Subject: [PATCH 195/326] cloth armor --- .../common/items/armor/belt/cloth_blue_0.ron | 8 ++++ .../common/items/armor/belt/cloth_green_0.ron | 8 ++++ .../items/armor/belt/cloth_purple_0.ron | 8 ++++ .../common/items/armor/chest/cloth_blue_0.ron | 8 ++++ .../items/armor/chest/cloth_green_0.ron | 8 ++++ .../items/armor/chest/cloth_purple_0.ron | 8 ++++ .../common/items/armor/foot/cloth_blue_0.ron | 8 ++++ .../common/items/armor/foot/cloth_green_0.ron | 8 ++++ .../items/armor/foot/cloth_purple_0.ron | 8 ++++ .../common/items/armor/hand/cloth_blue_0.ron | 8 ++++ .../common/items/armor/hand/cloth_green_0.ron | 8 ++++ .../items/armor/hand/cloth_purple_0.ron | 8 ++++ .../common/items/armor/pants/cloth_blue_0.ron | 8 ++++ .../items/armor/pants/cloth_green_0.ron | 8 ++++ .../items/armor/pants/cloth_purple_0.ron | 8 ++++ .../items/armor/shoulder/cloth_blue_0.ron | 8 ++++ .../items/armor/shoulder/cloth_green_0.ron | 8 ++++ .../items/armor/shoulder/cloth_purple_0.ron | 8 ++++ .../{cloth_blue_0.vox => cloth_blue-0.vox} | 0 .../{cloth_green_0.vox => cloth_green-0.vox} | 0 ...{cloth_purple_0.vox => cloth_purple-0.vox} | 0 .../{cloth_blue_0.vox => cloth_blue-0.vox} | 0 .../{cloth_green_0.vox => cloth_green-0.vox} | 0 ...{cloth_purple_0.vox => cloth_purple-0.vox} | 0 .../{cloth_blue_0.vox => cloth_blue-0.vox} | 0 .../{cloth_green_0.vox => cloth_green-0.vox} | 0 ...{cloth_purple_0.vox => cloth_purple-0.vox} | 0 ..._blue_0_left.vox => cloth_blue_left-0.vox} | 0 ...lue_0_right.vox => cloth_blue_right-0.vox} | 0 ...reen_left_0.vox => cloth_green_left-0.vox} | 0 ...en_right_0.vox => cloth_green_right-0.vox} | 0 ...ple_0_left.vox => cloth_purple_left-0.vox} | 0 ...e_0_right.vox => cloth_purple_right-0.vox} | 0 .../{cloth_blue_0.vox => cloth_blue-0.vox} | 0 .../{cloth_green_0.vox => cloth_green-0.vox} | 0 ...{cloth_purple_0.vox => cloth_purple-0.vox} | 0 ..._blue_left_0.vox => cloth_blue_left-0.vox} | 0 ...lue_right_0.vox => cloth_blue_right-0.vox} | 0 ...reen_left_0.vox => cloth_green_left-0.vox} | 0 ...en_right_0.vox => cloth_green_right-0.vox} | 0 ...ple_left_0.vox => cloth_purple_left-0.vox} | 0 ...e_right_0.vox => cloth_purple_right-0.vox} | 0 .../voxel/humanoid_armor_belt_manifest.ron | 12 +++++ .../voxel/humanoid_armor_chest_manifest.ron | 12 +++++ .../voxel/humanoid_armor_foot_manifest.ron | 12 +++++ .../voxel/humanoid_armor_hand_manifest.ron | 30 ++++++++++++ .../voxel/humanoid_armor_pants_manifest.ron | 12 +++++ .../humanoid_armor_shoulder_manifest.ron | 30 ++++++++++++ common/src/comp/body/humanoid.rs | 48 ++++++++++++++++--- 49 files changed, 294 insertions(+), 6 deletions(-) create mode 100644 assets/common/items/armor/belt/cloth_blue_0.ron create mode 100644 assets/common/items/armor/belt/cloth_green_0.ron create mode 100644 assets/common/items/armor/belt/cloth_purple_0.ron create mode 100644 assets/common/items/armor/chest/cloth_blue_0.ron create mode 100644 assets/common/items/armor/chest/cloth_green_0.ron create mode 100644 assets/common/items/armor/chest/cloth_purple_0.ron create mode 100644 assets/common/items/armor/foot/cloth_blue_0.ron create mode 100644 assets/common/items/armor/foot/cloth_green_0.ron create mode 100644 assets/common/items/armor/foot/cloth_purple_0.ron create mode 100644 assets/common/items/armor/hand/cloth_blue_0.ron create mode 100644 assets/common/items/armor/hand/cloth_green_0.ron create mode 100644 assets/common/items/armor/hand/cloth_purple_0.ron create mode 100644 assets/common/items/armor/pants/cloth_blue_0.ron create mode 100644 assets/common/items/armor/pants/cloth_green_0.ron create mode 100644 assets/common/items/armor/pants/cloth_purple_0.ron create mode 100644 assets/common/items/armor/shoulder/cloth_blue_0.ron create mode 100644 assets/common/items/armor/shoulder/cloth_green_0.ron create mode 100644 assets/common/items/armor/shoulder/cloth_purple_0.ron rename assets/voxygen/voxel/armor/belt/{cloth_blue_0.vox => cloth_blue-0.vox} (100%) rename assets/voxygen/voxel/armor/belt/{cloth_green_0.vox => cloth_green-0.vox} (100%) rename assets/voxygen/voxel/armor/belt/{cloth_purple_0.vox => cloth_purple-0.vox} (100%) rename assets/voxygen/voxel/armor/chest/{cloth_blue_0.vox => cloth_blue-0.vox} (100%) rename assets/voxygen/voxel/armor/chest/{cloth_green_0.vox => cloth_green-0.vox} (100%) rename assets/voxygen/voxel/armor/chest/{cloth_purple_0.vox => cloth_purple-0.vox} (100%) rename assets/voxygen/voxel/armor/foot/{cloth_blue_0.vox => cloth_blue-0.vox} (100%) rename assets/voxygen/voxel/armor/foot/{cloth_green_0.vox => cloth_green-0.vox} (100%) rename assets/voxygen/voxel/armor/foot/{cloth_purple_0.vox => cloth_purple-0.vox} (100%) rename assets/voxygen/voxel/armor/hand/{cloth_blue_0_left.vox => cloth_blue_left-0.vox} (100%) rename assets/voxygen/voxel/armor/hand/{cloth_blue_0_right.vox => cloth_blue_right-0.vox} (100%) rename assets/voxygen/voxel/armor/hand/{cloth_green_left_0.vox => cloth_green_left-0.vox} (100%) rename assets/voxygen/voxel/armor/hand/{cloth_green_right_0.vox => cloth_green_right-0.vox} (100%) rename assets/voxygen/voxel/armor/hand/{cloth_purple_0_left.vox => cloth_purple_left-0.vox} (100%) rename assets/voxygen/voxel/armor/hand/{cloth_purple_0_right.vox => cloth_purple_right-0.vox} (100%) rename assets/voxygen/voxel/armor/pants/{cloth_blue_0.vox => cloth_blue-0.vox} (100%) rename assets/voxygen/voxel/armor/pants/{cloth_green_0.vox => cloth_green-0.vox} (100%) rename assets/voxygen/voxel/armor/pants/{cloth_purple_0.vox => cloth_purple-0.vox} (100%) rename assets/voxygen/voxel/armor/shoulder/{cloth_blue_left_0.vox => cloth_blue_left-0.vox} (100%) rename assets/voxygen/voxel/armor/shoulder/{cloth_blue_right_0.vox => cloth_blue_right-0.vox} (100%) rename assets/voxygen/voxel/armor/shoulder/{cloth_green_left_0.vox => cloth_green_left-0.vox} (100%) rename assets/voxygen/voxel/armor/shoulder/{cloth_green_right_0.vox => cloth_green_right-0.vox} (100%) rename assets/voxygen/voxel/armor/shoulder/{cloth_purple_left_0.vox => cloth_purple_left-0.vox} (100%) rename assets/voxygen/voxel/armor/shoulder/{cloth_purple_right_0.vox => cloth_purple_right-0.vox} (100%) diff --git a/assets/common/items/armor/belt/cloth_blue_0.ron b/assets/common/items/armor/belt/cloth_blue_0.ron new file mode 100644 index 0000000000..8daff395d4 --- /dev/null +++ b/assets/common/items/armor/belt/cloth_blue_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Blue Linen Belt", + description: "Soft and warm", + kind: Armor( + kind: Belt(ClothBlue0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/belt/cloth_green_0.ron b/assets/common/items/armor/belt/cloth_green_0.ron new file mode 100644 index 0000000000..a43723aaf6 --- /dev/null +++ b/assets/common/items/armor/belt/cloth_green_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Green Linen Belt", + description: "Soft and warm", + kind: Armor( + kind: Belt(ClothGreen0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/belt/cloth_purple_0.ron b/assets/common/items/armor/belt/cloth_purple_0.ron new file mode 100644 index 0000000000..71c81db88f --- /dev/null +++ b/assets/common/items/armor/belt/cloth_purple_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Purple Linen Belt", + description: "Soft and warm", + kind: Armor( + kind: Belt(ClothPurple0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/chest/cloth_blue_0.ron b/assets/common/items/armor/chest/cloth_blue_0.ron new file mode 100644 index 0000000000..4a15fdf2dd --- /dev/null +++ b/assets/common/items/armor/chest/cloth_blue_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Blue Linen Chest", + description: "Soft and warm", + kind: Armor( + kind: Chest(ClothBlue0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/chest/cloth_green_0.ron b/assets/common/items/armor/chest/cloth_green_0.ron new file mode 100644 index 0000000000..ab0c087a54 --- /dev/null +++ b/assets/common/items/armor/chest/cloth_green_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Green Linen Chest", + description: "Soft and warm", + kind: Armor( + kind: Chest(ClothGreen0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/chest/cloth_purple_0.ron b/assets/common/items/armor/chest/cloth_purple_0.ron new file mode 100644 index 0000000000..65b2c2b338 --- /dev/null +++ b/assets/common/items/armor/chest/cloth_purple_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Purple Linen Chest", + description: "Soft and warm", + kind: Armor( + kind: Chest(ClothPurple0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/foot/cloth_blue_0.ron b/assets/common/items/armor/foot/cloth_blue_0.ron new file mode 100644 index 0000000000..5db06d6094 --- /dev/null +++ b/assets/common/items/armor/foot/cloth_blue_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Blue Linen Boots", + description: "Soft and warm", + kind: Armor( + kind: Foot(ClothBlue0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/foot/cloth_green_0.ron b/assets/common/items/armor/foot/cloth_green_0.ron new file mode 100644 index 0000000000..55c4f16a99 --- /dev/null +++ b/assets/common/items/armor/foot/cloth_green_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Green Linen Boots", + description: "Soft and warm", + kind: Armor( + kind: Foot(ClothGreen0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/foot/cloth_purple_0.ron b/assets/common/items/armor/foot/cloth_purple_0.ron new file mode 100644 index 0000000000..a94dbd78ae --- /dev/null +++ b/assets/common/items/armor/foot/cloth_purple_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Purple Linen Boots", + description: "Soft and warm", + kind: Armor( + kind: Foot(ClothPurple0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/hand/cloth_blue_0.ron b/assets/common/items/armor/hand/cloth_blue_0.ron new file mode 100644 index 0000000000..eb759506c4 --- /dev/null +++ b/assets/common/items/armor/hand/cloth_blue_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Blue Linen Wrists", + description: "WIP", + kind: Armor( + kind: Hand(ClothBlue0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/hand/cloth_green_0.ron b/assets/common/items/armor/hand/cloth_green_0.ron new file mode 100644 index 0000000000..486e106b56 --- /dev/null +++ b/assets/common/items/armor/hand/cloth_green_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Green Linen Wrists", + description: "WIP", + kind: Armor( + kind: Hand(ClothGreen0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/hand/cloth_purple_0.ron b/assets/common/items/armor/hand/cloth_purple_0.ron new file mode 100644 index 0000000000..57dbe378d0 --- /dev/null +++ b/assets/common/items/armor/hand/cloth_purple_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Purple Silk Wrists", + description: "WIP", + kind: Armor( + kind: Hand(ClothPurple0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/pants/cloth_blue_0.ron b/assets/common/items/armor/pants/cloth_blue_0.ron new file mode 100644 index 0000000000..ae40e9005b --- /dev/null +++ b/assets/common/items/armor/pants/cloth_blue_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Blue Linen Skirt", + description: "WIP", + kind: Armor( + kind: Belt(ClothBlue0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/pants/cloth_green_0.ron b/assets/common/items/armor/pants/cloth_green_0.ron new file mode 100644 index 0000000000..402a9fe954 --- /dev/null +++ b/assets/common/items/armor/pants/cloth_green_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Green Linen Skirt", + description: "WIP", + kind: Armor( + kind: Belt(ClothGreen0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/pants/cloth_purple_0.ron b/assets/common/items/armor/pants/cloth_purple_0.ron new file mode 100644 index 0000000000..a70280779f --- /dev/null +++ b/assets/common/items/armor/pants/cloth_purple_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Purple Linen Skirt", + description: "WIP", + kind: Armor( + kind: Belt(ClothPurple0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/shoulder/cloth_blue_0.ron b/assets/common/items/armor/shoulder/cloth_blue_0.ron new file mode 100644 index 0000000000..55246f765f --- /dev/null +++ b/assets/common/items/armor/shoulder/cloth_blue_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Blue Linen Coat", + description: "WIP", + kind: Armor( + kind: Belt(ClothBlue0), + stats: 20, + ), +) diff --git a/assets/common/items/armor/shoulder/cloth_green_0.ron b/assets/common/items/armor/shoulder/cloth_green_0.ron new file mode 100644 index 0000000000..899b3568b5 --- /dev/null +++ b/assets/common/items/armor/shoulder/cloth_green_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Green Linen Coat", + description: "WIP", + kind: Armor( + kind: Belt(ClothGreen0), + stats: 20, + ), +) \ No newline at end of file diff --git a/assets/common/items/armor/shoulder/cloth_purple_0.ron b/assets/common/items/armor/shoulder/cloth_purple_0.ron new file mode 100644 index 0000000000..bc89fea35c --- /dev/null +++ b/assets/common/items/armor/shoulder/cloth_purple_0.ron @@ -0,0 +1,8 @@ +Item( + name: "Purple Linen Coat", + description: "WIP", + kind: Armor( + kind: Belt(ClothPurple0), + stats: 20, + ), +) \ No newline at end of file diff --git a/assets/voxygen/voxel/armor/belt/cloth_blue_0.vox b/assets/voxygen/voxel/armor/belt/cloth_blue-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/belt/cloth_blue_0.vox rename to assets/voxygen/voxel/armor/belt/cloth_blue-0.vox diff --git a/assets/voxygen/voxel/armor/belt/cloth_green_0.vox b/assets/voxygen/voxel/armor/belt/cloth_green-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/belt/cloth_green_0.vox rename to assets/voxygen/voxel/armor/belt/cloth_green-0.vox diff --git a/assets/voxygen/voxel/armor/belt/cloth_purple_0.vox b/assets/voxygen/voxel/armor/belt/cloth_purple-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/belt/cloth_purple_0.vox rename to assets/voxygen/voxel/armor/belt/cloth_purple-0.vox diff --git a/assets/voxygen/voxel/armor/chest/cloth_blue_0.vox b/assets/voxygen/voxel/armor/chest/cloth_blue-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/chest/cloth_blue_0.vox rename to assets/voxygen/voxel/armor/chest/cloth_blue-0.vox diff --git a/assets/voxygen/voxel/armor/chest/cloth_green_0.vox b/assets/voxygen/voxel/armor/chest/cloth_green-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/chest/cloth_green_0.vox rename to assets/voxygen/voxel/armor/chest/cloth_green-0.vox diff --git a/assets/voxygen/voxel/armor/chest/cloth_purple_0.vox b/assets/voxygen/voxel/armor/chest/cloth_purple-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/chest/cloth_purple_0.vox rename to assets/voxygen/voxel/armor/chest/cloth_purple-0.vox diff --git a/assets/voxygen/voxel/armor/foot/cloth_blue_0.vox b/assets/voxygen/voxel/armor/foot/cloth_blue-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/foot/cloth_blue_0.vox rename to assets/voxygen/voxel/armor/foot/cloth_blue-0.vox diff --git a/assets/voxygen/voxel/armor/foot/cloth_green_0.vox b/assets/voxygen/voxel/armor/foot/cloth_green-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/foot/cloth_green_0.vox rename to assets/voxygen/voxel/armor/foot/cloth_green-0.vox diff --git a/assets/voxygen/voxel/armor/foot/cloth_purple_0.vox b/assets/voxygen/voxel/armor/foot/cloth_purple-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/foot/cloth_purple_0.vox rename to assets/voxygen/voxel/armor/foot/cloth_purple-0.vox diff --git a/assets/voxygen/voxel/armor/hand/cloth_blue_0_left.vox b/assets/voxygen/voxel/armor/hand/cloth_blue_left-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/hand/cloth_blue_0_left.vox rename to assets/voxygen/voxel/armor/hand/cloth_blue_left-0.vox diff --git a/assets/voxygen/voxel/armor/hand/cloth_blue_0_right.vox b/assets/voxygen/voxel/armor/hand/cloth_blue_right-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/hand/cloth_blue_0_right.vox rename to assets/voxygen/voxel/armor/hand/cloth_blue_right-0.vox diff --git a/assets/voxygen/voxel/armor/hand/cloth_green_left_0.vox b/assets/voxygen/voxel/armor/hand/cloth_green_left-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/hand/cloth_green_left_0.vox rename to assets/voxygen/voxel/armor/hand/cloth_green_left-0.vox diff --git a/assets/voxygen/voxel/armor/hand/cloth_green_right_0.vox b/assets/voxygen/voxel/armor/hand/cloth_green_right-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/hand/cloth_green_right_0.vox rename to assets/voxygen/voxel/armor/hand/cloth_green_right-0.vox diff --git a/assets/voxygen/voxel/armor/hand/cloth_purple_0_left.vox b/assets/voxygen/voxel/armor/hand/cloth_purple_left-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/hand/cloth_purple_0_left.vox rename to assets/voxygen/voxel/armor/hand/cloth_purple_left-0.vox diff --git a/assets/voxygen/voxel/armor/hand/cloth_purple_0_right.vox b/assets/voxygen/voxel/armor/hand/cloth_purple_right-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/hand/cloth_purple_0_right.vox rename to assets/voxygen/voxel/armor/hand/cloth_purple_right-0.vox diff --git a/assets/voxygen/voxel/armor/pants/cloth_blue_0.vox b/assets/voxygen/voxel/armor/pants/cloth_blue-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/pants/cloth_blue_0.vox rename to assets/voxygen/voxel/armor/pants/cloth_blue-0.vox diff --git a/assets/voxygen/voxel/armor/pants/cloth_green_0.vox b/assets/voxygen/voxel/armor/pants/cloth_green-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/pants/cloth_green_0.vox rename to assets/voxygen/voxel/armor/pants/cloth_green-0.vox diff --git a/assets/voxygen/voxel/armor/pants/cloth_purple_0.vox b/assets/voxygen/voxel/armor/pants/cloth_purple-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/pants/cloth_purple_0.vox rename to assets/voxygen/voxel/armor/pants/cloth_purple-0.vox diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_blue_left_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_blue_left-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/shoulder/cloth_blue_left_0.vox rename to assets/voxygen/voxel/armor/shoulder/cloth_blue_left-0.vox diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_blue_right_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_blue_right-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/shoulder/cloth_blue_right_0.vox rename to assets/voxygen/voxel/armor/shoulder/cloth_blue_right-0.vox diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_green_left_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_green_left-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/shoulder/cloth_green_left_0.vox rename to assets/voxygen/voxel/armor/shoulder/cloth_green_left-0.vox diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_green_right_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_green_right-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/shoulder/cloth_green_right_0.vox rename to assets/voxygen/voxel/armor/shoulder/cloth_green_right-0.vox diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_purple_left_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_purple_left-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/shoulder/cloth_purple_left_0.vox rename to assets/voxygen/voxel/armor/shoulder/cloth_purple_left-0.vox diff --git a/assets/voxygen/voxel/armor/shoulder/cloth_purple_right_0.vox b/assets/voxygen/voxel/armor/shoulder/cloth_purple_right-0.vox similarity index 100% rename from assets/voxygen/voxel/armor/shoulder/cloth_purple_right_0.vox rename to assets/voxygen/voxel/armor/shoulder/cloth_purple_right-0.vox diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index 424821de8e..8e73ed569c 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -35,5 +35,17 @@ vox_spec: ("armor.belt.leather-0", (-5.0, -3.5, 2.0)), color: None ), + ClothPurple0:( + vox_spec: ("armor.belt.cloth_purple_0", (-5.0, -3.5, 2.0)), + color: None + ), + ClothBlue0:( + vox_spec: ("armor.belt.cloth_blue_0", (-5.0, -3.5, 2.0)), + color: None + ), + ClothGreen0:( + vox_spec: ("armor.belt.cloth_purple_0", (-5.0, -3.5, 2.0)), + color: None + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index 949b8b91a8..c6fe492716 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -43,5 +43,17 @@ vox_spec: ("armor.chest.leather-0", (-7.0, -3.5, 2.0)), color: None ), + ClothPurple0:( + vox_spec: ("armor.chest.cloth_purple-0", (-7.0, -3.5, 2.0)), + color: None + ), + ClothBlue0:( + vox_spec: ("armor.chest.cloth_blue-0", (-7.0, -3.5, 2.0)), + color: None + ), + ClothGreen0:( + vox_spec: ("armor.chest.cloth_green-0", (-7.0, -3.5, 2.0)), + color: None + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron index dd320b7b84..a546c19310 100644 --- a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron @@ -27,4 +27,16 @@ vox_spec: ("armor.foot.leather-0", (-2.5, -3.5, -9.0)), color: None ), + ClothPurple0:( + vox_spec: ("armor.foot.cloth_purple_0", (-2.5, -3.5, -9.0)), + color: None + ), + ClothBlue0:( + vox_spec: ("armor.foot.cloth_purple_0", (-2.5, -3.5, -9.0)), + color: None + ), + ClothGreen0:( + vox_spec: ("armor.foot.cloth_purple_0", (-2.5, -3.5, -9.0)), + color: None + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron index 5872dd0e77..1005bbfcc3 100644 --- a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron @@ -49,4 +49,34 @@ color: None ) ), + ClothPurple0: ( + left: ( + vox_spec: ("armor.hand.cloth_purple_left-0", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.cloth_purple_right-0", (-1.5, -1.5, -7.0)), + color: None + ) + ), + ClothBlue0: ( + left: ( + vox_spec: ("armor.hand.cloth_blue_left-0", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.cloth_blue_right-0", (-1.5, -1.5, -7.0)), + color: None + ) + ), + ClothGreen0: ( + left: ( + vox_spec: ("armor.hand.cloth_green_left-0", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.cloth_green_right-0", (-1.5, -1.5, -7.0)), + color: None + ) + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron index 1c28203795..1b8d93ad57 100644 --- a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron @@ -39,4 +39,16 @@ vox_spec: ("armor.pants.leather-0", (-5.0, -3.5, 1.0)), color: None ), + ClothPurple0:( + vox_spec: ("armor.pants.cloth_purple_0", (-5.0, -3.5, 2.0)), + color: None + ), + ClothBlue0:( + vox_spec: ("armor.pants.cloth_blue_0", (-5.0, -3.5, 2.0)), + color: None + ), + ClothGreen0:( + vox_spec: ("armor.pants.cloth_purple_0", (-5.0, -3.5, 2.0)), + color: None + ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index d0551ad6d3..c099a12fd9 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -80,4 +80,34 @@ color: None ) ), + ClothPurple0: ( + left: ( + vox_spec: ("armor.shoulder.cloth_purple_left-0", (-3.2, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.cloth_purple_right-0", (-1.8, -3.5, 1.0)), + color: None + ) + ), + ClothBlue0: ( + left: ( + vox_spec: ("armor.shoulder.cloth_blue_left-0", (-3.2, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.cloth_blue_right-0", (-1.8, -3.5, 1.0)), + color: None + ) + ), + ClothGreen0: ( + left: ( + vox_spec: ("armor.shoulder.cloth_green_left-0", (-3.2, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.cloth_green_right-0", (-1.8, -3.5, 1.0)), + color: None + ) + ), }) diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index 12d83b9394..d271a19985 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -485,8 +485,11 @@ pub enum Chest { Assassin = 8, PlateGreen0 = 9, Leather0 = 10, + ClothPurple0 = 11, + ClothBlue0 = 12, + ClothGreen0 = 13, } -pub const ALL_CHESTS: [Chest; 11] = [ +pub const ALL_CHESTS: [Chest; 14] = [ Chest::None, Chest::Blue, Chest::Brown, @@ -498,6 +501,9 @@ pub const ALL_CHESTS: [Chest; 11] = [ Chest::Assassin, Chest::PlateGreen0, Chest::Leather0, + Chest::ClothPurple0, + Chest::ClothBlue0, + Chest::ClothGreen0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -511,8 +517,11 @@ pub enum Belt { Assassin = 5, Plate0 = 6, Leather0 = 7, + ClothPurple0 = 8, + ClothBlue0 = 9, + ClothGreen0 = 10, } -pub const ALL_BELTS: [Belt; 8] = [ +pub const ALL_BELTS: [Belt; 11] = [ Belt::None, Belt::Dark, Belt::TurqCloth, @@ -521,6 +530,9 @@ pub const ALL_BELTS: [Belt; 8] = [ Belt::Assassin, Belt::Plate0, Belt::Leather0, + Belt::ClothPurple0, + Belt::ClothBlue0, + Belt::ClothGreen0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -536,8 +548,11 @@ pub enum Pants { Assassin = 7, PlateGreen0 = 8, Leather0 = 9, + ClothPurple0 = 10, + ClothBlue0 = 11, + ClothGreen0 = 12, } -pub const ALL_PANTS: [Pants; 10] = [ +pub const ALL_PANTS: [Pants; 13] = [ Pants::None, Pants::Blue, Pants::Brown, @@ -548,6 +563,9 @@ pub const ALL_PANTS: [Pants; 10] = [ Pants::Assassin, Pants::PlateGreen0, Pants::Leather0, + Pants::ClothPurple0, + Pants::ClothBlue0, + Pants::ClothGreen0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -558,13 +576,19 @@ pub enum Hand { Assassin = 2, Plate0 = 3, Leather0 = 4, + ClothPurple0 = 5, + ClothBlue0 = 6, + ClothGreen0 = 7, } -pub const ALL_HANDS: [Hand; 5] = [ +pub const ALL_HANDS: [Hand; 8] = [ Hand::Bare, Hand::Cloth, Hand::Assassin, Hand::Plate0, Hand::Leather0, + Hand::ClothPurple0, + Hand::ClothBlue0, + Hand::ClothGreen0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -577,8 +601,11 @@ pub enum Foot { Assassin = 4, Plate0 = 5, Leather0 = 6, + ClothPurple0 = 7, + ClothBlue0 = 8, + ClothGreen0 = 9, } -pub const ALL_FEET: [Foot; 7] = [ +pub const ALL_FEET: [Foot; 10] = [ Foot::Bare, Foot::Dark, Foot::Sandal, @@ -586,6 +613,9 @@ pub const ALL_FEET: [Foot; 7] = [ Foot::Assassin, Foot::Plate0, Foot::Leather0, + Foot::ClothPurple0, + Foot::ClothBlue0, + Foot::ClothGreen0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -598,8 +628,11 @@ pub enum Shoulder { Plate0 = 4, Leather0 = 5, Leather1 = 6, + ClothPurple0 = 7, + ClothBlue0 = 8, + ClothGreen0 = 9, } -pub const ALL_SHOULDERS: [Shoulder; 7] = [ +pub const ALL_SHOULDERS: [Shoulder; 10] = [ Shoulder::None, Shoulder::Brown1, Shoulder::Chain, @@ -607,6 +640,9 @@ pub const ALL_SHOULDERS: [Shoulder; 7] = [ Shoulder::Plate0, Shoulder::Leather0, Shoulder::Leather1, + Shoulder::ClothPurple0, + Shoulder::ClothBlue0, + Shoulder::ClothGreen0, ]; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] From 32c85d1babd1d111301fd88ed96e61c5bfdd1bee Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 22 Mar 2020 00:11:24 -0400 Subject: [PATCH 196/326] axe attack --- voxygen/src/anim/character/attack.rs | 75 +++++++++++++++------------- voxygen/src/anim/character/wield.rs | 29 +++++++++-- 2 files changed, 63 insertions(+), 41 deletions(-) diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index 51e8641271..96dccc06d2 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -42,6 +42,10 @@ impl Animation for AttackAnimation { / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * lab as f32 * 4.0).sin()); + let slowax = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()); match active_tool_kind { //TODO: Inventory @@ -100,55 +104,54 @@ impl Animation for AttackAnimation { }, Some(ToolKind::Axe(_)) => { next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 21.0, + 0.0 + skeleton_attr.neck_right + slowax * 2.0, + -2.0 + skeleton_attr.neck_forward + slowax * -2.0, + skeleton_attr.neck_height + 19.0, ); - next.head.ori = Quaternion::rotation_z(decel * 0.25) - * Quaternion::rotation_x(0.0 + decel * 0.1) - * Quaternion::rotation_y(decel * -0.1); + next.head.ori = Quaternion::rotation_z(slowax * 0.25) + * Quaternion::rotation_x(0.0 + slowax * 0.2) + * Quaternion::rotation_y(slowax * 0.2); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * -0.2) - * Quaternion::rotation_x(0.0 + decel * -0.2) - * Quaternion::rotation_y(decel * 0.2); + next.chest.ori = Quaternion::rotation_z(slowax * 0.2) + * Quaternion::rotation_x(0.0 + slowax * 0.2) + * Quaternion::rotation_y(slowax * 0.2); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.1) - * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); + next.belt.ori = Quaternion::rotation_z(slowax * 0.1) + * Quaternion::rotation_x(0.0 + slowax * 0.1) + * Quaternion::rotation_y(slowax * 0.1); next.belt.scale = Vec3::one(); next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.08) - * Quaternion::rotation_x(0.0 + decel * -0.08) - * Quaternion::rotation_y(decel * 0.08); + next.belt.ori = Quaternion::rotation_z(slowax * 0.08) + * Quaternion::rotation_x(0.0 + slowax * 0.08) + * Quaternion::rotation_y(slowax * 0.08); next.shorts.scale = Vec3::one(); - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.offset = Vec3::new(-4.0, 3.0, 2.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(-2.5, 9.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(-6.0, 10.0, -5.0); + next.main.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(-0.8); next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(0.0, 0.0 + slowax * 8.2, 6.0); + next.control.ori = Quaternion::rotation_x(0.8) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(-0.7 + slowax * -1.9); + next.control.scale = Vec3::one(); }, Some(ToolKind::Hammer(_)) => { next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index f99eb21f46..1088a46ad8 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -1,6 +1,6 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use common::comp::item::ToolKind; -use std::f32::consts::PI; +use std::{f32::consts::PI, ops::Mul}; use vek::*; @@ -12,16 +12,20 @@ impl Animation for WieldAnimation { fn update_skeleton( skeleton: &Self::Skeleton, - (active_tool_kind, _velocity, _global_time): Self::Dependency, + (active_tool_kind, _velocity, global_time): Self::Dependency, anim_time: f64, _rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); + let lab = 1.0; let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); - + let long = (((5.0) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.66).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 0.66).sin()); let wave = (anim_time as f32 * 1.0).sin(); match active_tool_kind { //TODO: Inventory @@ -61,10 +65,10 @@ impl Animation for WieldAnimation { * Quaternion::rotation_z(-0.8); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(0.0, 0.0, -2.0); + next.control.offset = Vec3::new(0.0, 0.0, 0.0); next.control.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.1 + 0.2) * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(wave_ultra_slow * 0.1 - 0.5); + * Quaternion::rotation_z(wave_ultra_slow * 0.1 + 0.0); next.control.scale = Vec3::one(); }, Some(ToolKind::Hammer(_)) => { @@ -187,6 +191,21 @@ impl Animation for WieldAnimation { }, _ => {}, } + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 18.0) + .floor() + .mul(7331.0) + .sin() + * 0.2, + ((global_time + anim_time) as f32 / 18.0) + .floor() + .mul(1337.0) + .sin() + * 0.1, + ); + next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1) + * Quaternion::rotation_x(head_look.y + 0.0); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(0.0); From 41c424ac13fe5097f36a5cf47588afc6642a5ace Mon Sep 17 00:00:00 2001 From: Imbris Date: Sun, 22 Mar 2020 00:49:32 -0400 Subject: [PATCH 197/326] Optimized uses of emitters, cleanup --- .DS_Store | Bin 6148 -> 0 bytes assets/voxygen/i18n/en.ron | 2 +- client/src/lib.rs | 3 +-- common/src/comp/ability.rs | 2 +- common/src/comp/inventory/item.rs | 2 +- common/src/event.rs | 4 ++-- common/src/msg/ecs_packet.rs | 12 ------------ common/src/state.rs | 3 +-- common/src/sys/character_behavior.rs | 7 +++++-- common/src/sys/combat.rs | 5 +++-- server/src/cmd.rs | 2 +- server/src/sys/message.rs | 4 +++- server/src/sys/terrain.rs | 4 +++- .../src/audio/sfx/event_mapper/movement/mod.rs | 15 ++++++++------- .../src/audio/sfx/event_mapper/progression.rs | 3 +-- voxygen/src/scene/mod.rs | 6 +++++- 16 files changed, 36 insertions(+), 38 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 8cda30a1a4792f56e6be97fda60289fc9c97c759..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyH3L}6g`GgN|AsK#*8c=F|&j|gevincaS^ve!>5#;9oUf%wdSE;QLnMD=`ch$97Q?FF%-SOn* zKR52#Vzotsp$-ZJ1%d)!3dr{%ViAlj<_7hrgOxr45G(A~#b{p7ITA!4rLD?%Fe9p2}SAIIew(wp<;uf4hjSXd>() - .emitter() - .emit(SfxEventItem::at_player_position(SfxEvent::Inventory(event))); + .emit_now(SfxEventItem::at_player_position(SfxEvent::Inventory(event))); }, ServerMsg::TerrainChunkUpdate { key, chunk } => { if let Ok(chunk) = chunk { diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index ca4eee8547..c534ab701e 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -3,7 +3,7 @@ use crate::{ states::*, sys::character_behavior::JoinData, }; -use specs::{Component, FlaggedStorage, HashMapStorage}; +use specs::{Component, FlaggedStorage}; use specs_idvs::IDVStorage; use std::time::Duration; diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 1a3898cf61..69d363aa48 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -10,7 +10,7 @@ use crate::{ use rand::seq::SliceRandom; use specs::{Component, FlaggedStorage}; use specs_idvs::IDVStorage; -use std::{fs::File, io::BufReader, time::Duration, vec::Vec}; +use std::{fs::File, io::BufReader, time::Duration}; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum SwordKind { diff --git a/common/src/event.rs b/common/src/event.rs index 1fbadc8f69..39e8a63e23 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -144,7 +144,7 @@ impl EventBus { } } - pub fn emit(&self, event: E) { self.queue.lock().push_front(event); } + pub fn emit_now(&self, event: E) { self.queue.lock().push_back(event); } pub fn recv_all(&self) -> impl ExactSizeIterator { std::mem::replace(self.queue.lock().deref_mut(), VecDeque::new()).into_iter() @@ -157,7 +157,7 @@ pub struct Emitter<'a, E> { } impl<'a, E> Emitter<'a, E> { - pub fn emit(&mut self, event: E) { self.events.push_front(event); } + pub fn emit(&mut self, event: E) { self.events.push_back(event); } pub fn append(&mut self, other: &mut VecDeque) { self.events.append(other) } } diff --git a/common/src/msg/ecs_packet.rs b/common/src/msg/ecs_packet.rs index 31a80fa727..7c6c29aa38 100644 --- a/common/src/msg/ecs_packet.rs +++ b/common/src/msg/ecs_packet.rs @@ -21,9 +21,7 @@ sum_type! { Mass(comp::Mass), Gravity(comp::Gravity), Sticky(comp::Sticky), - CharacterAbility(comp::CharacterAbility), Loadout(comp::Loadout), - Attacking(comp::Attacking), CharacterState(comp::CharacterState), Pos(comp::Pos), Vel(comp::Vel), @@ -48,9 +46,7 @@ sum_type! { Mass(PhantomData), Gravity(PhantomData), Sticky(PhantomData), - CharacterAbility(PhantomData), Loadout(PhantomData), - Attacking(PhantomData), CharacterState(PhantomData), Pos(PhantomData), Vel(PhantomData), @@ -75,9 +71,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Mass(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Gravity(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_insert(comp, entity, world), - EcsCompPacket::CharacterAbility(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Loadout(comp) => sync::handle_insert(comp, entity, world), - EcsCompPacket::Attacking(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::CharacterState(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Pos(comp) => sync::handle_insert(comp, entity, world), EcsCompPacket::Vel(comp) => sync::handle_insert(comp, entity, world), @@ -100,9 +94,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPacket::Mass(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Gravity(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Sticky(comp) => sync::handle_modify(comp, entity, world), - EcsCompPacket::CharacterAbility(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Loadout(comp) => sync::handle_modify(comp, entity, world), - EcsCompPacket::Attacking(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::CharacterState(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Pos(comp) => sync::handle_modify(comp, entity, world), EcsCompPacket::Vel(comp) => sync::handle_modify(comp, entity, world), @@ -127,11 +119,7 @@ impl sync::CompPacket for EcsCompPacket { EcsCompPhantom::Mass(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Gravity(_) => sync::handle_remove::(entity, world), EcsCompPhantom::Sticky(_) => sync::handle_remove::(entity, world), - EcsCompPhantom::CharacterAbility(_) => { - sync::handle_remove::(entity, world) - }, EcsCompPhantom::Loadout(_) => sync::handle_remove::(entity, world), - EcsCompPhantom::Attacking(_) => sync::handle_remove::(entity, world), EcsCompPhantom::CharacterState(_) => { sync::handle_remove::(entity, world) }, diff --git a/common/src/state.rs b/common/src/state.rs index 1c7466e8bc..ede5f6252d 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -107,7 +107,6 @@ impl State { ecs.register_sync_marker(); // Register server -> all clients synced components. ecs.register::(); - ecs.register::(); ecs.register::(); ecs.register::(); ecs.register::(); @@ -121,7 +120,6 @@ impl State { ecs.register::(); ecs.register::(); ecs.register::(); - ecs.register::(); // Register components send from clients -> server ecs.register::(); @@ -150,6 +148,7 @@ impl State { ecs.register::(); ecs.register::(); ecs.register::(); + ecs.register::(); // Register synced resources used by the ECS. ecs.insert(TimeOfDay(0.0)); diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index e82830066b..ebccef6258 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -129,6 +129,9 @@ impl<'a> System<'a> for Sys { mountings, ): Self::SystemData, ) { + let mut server_emitter = server_bus.emitter(); + let mut local_emitter = local_bus.emitter(); + let mut join_iter = ( &entities, &uids, @@ -191,8 +194,8 @@ impl<'a> System<'a> for Sys { *tuple.5 = state_update.ori; *tuple.6 = state_update.energy; *tuple.7 = state_update.loadout; - local_bus.emitter().append(&mut state_update.local_events); - server_bus.emitter().append(&mut state_update.server_events); + local_emitter.append(&mut state_update.local_events); + server_emitter.append(&mut state_update.server_events); } } } diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index e48272c36e..dab3766b5a 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -48,6 +48,7 @@ impl<'a> System<'a> for Sys { character_states, ): Self::SystemData, ) { + let mut server_emitter = server_bus.emitter(); // Attacks for (entity, uid, pos, ori, scale_maybe, _, _attacker_stats, attack) in ( &entities, @@ -81,7 +82,7 @@ impl<'a> System<'a> for Sys { { // 2D versions let pos2 = Vec2::from(pos.0); - let pos_b2: Vec2 = Vec2::from(pos_b.0); + let pos_b2 = Vec2::::from(pos_b.0); let ori2 = Vec2::from(ori.0); // Scales @@ -106,7 +107,7 @@ impl<'a> System<'a> for Sys { dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as u32 } - server_bus.emitter().emit(ServerEvent::Damage { + server_emitter.emit(ServerEvent::Damage { uid: *uid_b, change: HealthChange { amount: -(dmg as i32), diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 86fc5dc649..a53247706d 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -836,7 +836,7 @@ fn handle_explosion(server: &mut Server, entity: EcsEntity, args: String, action .state .ecs() .read_resource::>() - .emit(ServerEvent::Explosion { pos: pos.0, radius }), + .emit_now(ServerEvent::Explosion { pos: pos.0, radius }), None => server.notify_client( entity, ServerMsg::private(String::from("You have no position!")), diff --git a/server/src/sys/message.rs b/server/src/sys/message.rs index 156e13b860..f6d5e95435 100644 --- a/server/src/sys/message.rs +++ b/server/src/sys/message.rs @@ -45,7 +45,7 @@ impl<'a> System<'a> for Sys { &mut self, ( entities, - server_emitter, + server_event_bus, time, terrain, mut timer, @@ -68,6 +68,8 @@ impl<'a> System<'a> for Sys { let time = time.0; + let mut server_emitter = server_event_bus.emitter(); + let mut new_chat_msgs = Vec::new(); // Player list to send new players. diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index f47a4e7a08..efe6265b93 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -38,7 +38,7 @@ impl<'a> System<'a> for Sys { fn run( &mut self, ( - server_emitter, + server_event_bus, tick, mut timer, mut chunk_generator, @@ -51,6 +51,8 @@ impl<'a> System<'a> for Sys { ) { timer.start(); + let mut server_emitter = server_event_bus.emitter(); + // Fetch any generated `TerrainChunk`s and insert them into the terrain. // Also, send the chunk data to anybody that is close by. 'insert_terrain_chunks: while let Some((key, res)) = chunk_generator.recv_new_chunk() { diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index 084dc47ea2..3b597445f0 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -47,6 +47,9 @@ impl MovementEventMapper { const SFX_DIST_LIMIT_SQR: f32 = 20000.0; let ecs = state.ecs(); + let sfx_event_bus = ecs.read_resource::>(); + let mut sfx_emitter = sfx_event_bus.emitter(); + let player_position = ecs .read_storage::() .get(player_entity) @@ -86,13 +89,11 @@ impl MovementEventMapper { // Check for SFX config entry for this movement if Self::should_emit(state, triggers.get_key_value(&mapped_event)) { - ecs.read_resource::>() - .emitter() - .emit(SfxEventItem::new( - mapped_event, - Some(pos.0), - Some(Self::get_volume_for_body_type(body)), - )); + sfx_emitter.emit(SfxEventItem::new( + mapped_event, + Some(pos.0), + Some(Self::get_volume_for_body_type(body)), + )); // Set the new previous entity state state.event = mapped_event; diff --git a/voxygen/src/audio/sfx/event_mapper/progression.rs b/voxygen/src/audio/sfx/event_mapper/progression.rs index 7c05db0360..01ab1cc82c 100644 --- a/voxygen/src/audio/sfx/event_mapper/progression.rs +++ b/voxygen/src/audio/sfx/event_mapper/progression.rs @@ -53,8 +53,7 @@ impl ProgressionEventMapper { if sfx_trigger_item.is_some() { ecs.read_resource::>() - .emitter() - .emit(SfxEventItem::at_player_position(mapped_event)); + .emit_now(SfxEventItem::at_player_position(mapped_event)); } } diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index ae8bd95089..d9d28d6e0f 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -35,6 +35,10 @@ const LIGHT_DIST_RADIUS: f32 = 64.0; // The distance beyond which lights may not const SHADOW_DIST_RADIUS: f32 = 8.0; const SHADOW_MAX_DIST: f32 = 96.0; // The distance beyond which shadows may not be visible +/// Above this speed is considered running +/// Used for first person camera effects +const RUNNING_THRESHOLD: f32 = 0.7; + struct Skybox { model: Model, locals: Consts, @@ -191,7 +195,7 @@ impl Scene { let is_running = ecs .read_storage::() .get(scene_data.player_entity) - .map(|v| v.0.magnitude_squared() > 0.5); + .map(|v| v.0.magnitude_squared() > RUNNING_THRESHOLD.powi(2)); let on_ground = ecs .read_storage::() From d8cbd15204e5b1f4c62447bbb8355603aa0f48e6 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 22 Mar 2020 12:44:32 +0000 Subject: [PATCH 198/326] Fix docker image for server-cli --- server-cli/Dockerfile | 4 +++- server-cli/docker-run.sh | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) delete mode 100755 server-cli/docker-run.sh diff --git a/server-cli/Dockerfile b/server-cli/Dockerfile index eacecc7846..1dcdbcac34 100644 --- a/server-cli/Dockerfile +++ b/server-cli/Dockerfile @@ -2,7 +2,9 @@ FROM debian:stable-slim ARG PROJECTNAME=server-cli -COPY ./server-cli/docker-run.sh /opt/docker-run.sh COPY ./veloren-server-cli /opt/veloren-server-cli COPY ./assets/common /opt/assets/common COPY ./assets/world /opt/assets/world + +WORKDIR /opt +CMD ["RUST_LOG=info,common=debug,common::net=info RUST_BACKTRACE=1 /opt/veloren-server-cli"] diff --git a/server-cli/docker-run.sh b/server-cli/docker-run.sh deleted file mode 100755 index e965090fdb..0000000000 --- a/server-cli/docker-run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cd /opt -RUST_LOG=info,common=debug,common::net=info RUST_BACKTRACE=1 /opt/veloren-server-cli From afa6e43dd5857e7251a4b2ddc0eb16a26c7f35ee Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 22 Mar 2020 05:45:39 -0700 Subject: [PATCH 199/326] * remove Component Trait from CharacterAbility --- common/src/comp/ability.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index c534ab701e..d2f0a56272 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -66,10 +66,6 @@ impl CharacterAbility { } } -impl Component for CharacterAbility { - type Storage = IDVStorage; -} - #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] pub struct ItemConfig { pub item: Item, From db8d89a4d9e9f49a5443ce4b3738f6b754ed33d4 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 22 Mar 2020 05:46:09 -0700 Subject: [PATCH 200/326] * rename CharacterState equals() -> same_variant() --- client/src/lib.rs | 2 +- common/src/comp/character_state.rs | 2 +- voxygen/src/scene/figure/mod.rs | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 5912f15674..9d2e4846d2 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -393,7 +393,7 @@ impl Client { { if last_character_states .get(entity) - .map(|l| !client_character_state.equals(&l.0)) + .map(|l| !client_character_state.same_variant(&l.0)) .unwrap_or(true) { let _ = last_character_states diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index a51b3ba808..7a9c08c499 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -111,7 +111,7 @@ impl CharacterState { } /// Compares for shallow equality (does not check internal struct equality) - pub fn equals(&self, other: &Self) -> bool { + pub fn same_variant(&self, other: &Self) -> bool { // Check if state is the same without looking at the inner data std::mem::discriminant(self) == std::mem::discriminant(other) } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 0944c8615b..de3fbdb816 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -418,7 +418,7 @@ impl FigureMgr { _ => continue, }; - if !character.equals(&last_character.0) { + if !character.same_variant(&last_character.0) { state.state_time = 0.0; } @@ -650,7 +650,7 @@ impl FigureMgr { _ => continue, }; - if !character.equals(&last_character.0) { + if !character.same_variant(&last_character.0) { state.state_time = 0.0; } @@ -730,7 +730,7 @@ impl FigureMgr { _ => continue, }; - if !character.equals(&last_character.0) { + if !character.same_variant(&last_character.0) { state.state_time = 0.0; } @@ -810,7 +810,7 @@ impl FigureMgr { _ => continue, }; - if !character.equals(&last_character.0) { + if !character.same_variant(&last_character.0) { state.state_time = 0.0; } @@ -884,7 +884,7 @@ impl FigureMgr { _ => continue, }; - if !character.equals(&last_character.0) { + if !character.same_variant(&last_character.0) { state.state_time = 0.0; } @@ -958,7 +958,7 @@ impl FigureMgr { _ => continue, }; - if !character.equals(&last_character.0) { + if !character.same_variant(&last_character.0) { state.state_time = 0.0; } @@ -1032,7 +1032,7 @@ impl FigureMgr { _ => continue, }; - if !character.equals(&last_character.0) { + if !character.same_variant(&last_character.0) { state.state_time = 0.0; } @@ -1106,7 +1106,7 @@ impl FigureMgr { _ => continue, }; - if !character.equals(&last_character.0) { + if !character.same_variant(&last_character.0) { state.state_time = 0.0; } @@ -1180,7 +1180,7 @@ impl FigureMgr { _ => continue, }; - if !character.equals(&last_character.0) { + if !character.same_variant(&last_character.0) { state.state_time = 0.0; } @@ -1254,7 +1254,7 @@ impl FigureMgr { _ => continue, }; - if !character.equals(&last_character.0) { + if !character.same_variant(&last_character.0) { state.state_time = 0.0; } From 5016b8da3aaeea7eccc3f9c6beec56f3768313a8 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 22 Mar 2020 05:49:48 -0700 Subject: [PATCH 201/326] consistent naming --- common/src/comp/inventory/item.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 69d363aa48..44113227de 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -74,7 +74,7 @@ impl ToolData { // recover_duration: Duration::from_millis(500), // base_damage: 6, // }, - CharacterAbility::TripleStrike { base_damage: 7 }, + TripleStrike { base_damage: 7 }, DashMelee { buildup_duration: Duration::from_millis(500), recover_duration: Duration::from_millis(500), From 61e2a986f225332e9568f4acdacc7ca437b11da3 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sun, 22 Mar 2020 14:38:21 +0100 Subject: [PATCH 202/326] item images --- .../common/items/armor/pants/cloth_blue_0.ron | 2 +- .../items/armor/pants/cloth_green_0.ron | 2 +- .../items/armor/pants/cloth_purple_0.ron | 2 +- .../items/armor/shoulder/cloth_blue_0.ron | 2 +- .../items/armor/shoulder/cloth_green_0.ron | 4 +- .../items/armor/shoulder/cloth_purple_0.ron | 4 +- assets/voxygen/item_image_manifest.ron | 99 +++++++++++++++++-- .../voxygen/voxel/armor/belt/cloth_blood.vox | 4 +- .../voxygen/voxel/armor/belt/cloth_blue-0.vox | 2 +- .../voxel/armor/belt/cloth_green-0.vox | 2 +- .../voxel/armor/belt/cloth_purple-0.vox | 2 +- .../voxel/armor/chest/cloth_blue-0.vox | 4 +- .../voxel/armor/chest/cloth_green-0.vox | 4 +- .../voxel/armor/chest/cloth_purple-0.vox | 4 +- .../voxel/armor/hand/cloth_blue_right-0.vox | 2 +- .../voxel/armor/hand/cloth_purple_right-0.vox | 4 +- .../voxel/armor/pants/cloth_blue-0.vox | 4 +- .../voxel/armor/pants/cloth_green-0.vox | 4 +- .../voxel/armor/pants/cloth_purple-0.vox | 4 +- .../voxygen/voxel/armor/pants/grayscale.vox | 4 +- .../voxel/humanoid_armor_belt_manifest.ron | 8 +- .../voxel/humanoid_armor_chest_manifest.ron | 8 +- .../voxel/humanoid_armor_foot_manifest.ron | 6 +- .../voxel/humanoid_armor_hand_manifest.ron | 6 +- .../voxel/humanoid_armor_pants_manifest.ron | 6 +- .../humanoid_armor_shoulder_manifest.ron | 2 +- common/src/comp/inventory/mod.rs | 58 ++++++++++- 27 files changed, 194 insertions(+), 59 deletions(-) diff --git a/assets/common/items/armor/pants/cloth_blue_0.ron b/assets/common/items/armor/pants/cloth_blue_0.ron index ae40e9005b..b8642e11d9 100644 --- a/assets/common/items/armor/pants/cloth_blue_0.ron +++ b/assets/common/items/armor/pants/cloth_blue_0.ron @@ -2,7 +2,7 @@ Item( name: "Blue Linen Skirt", description: "WIP", kind: Armor( - kind: Belt(ClothBlue0), + kind: Pants(ClothBlue0), stats: 20, ), ) diff --git a/assets/common/items/armor/pants/cloth_green_0.ron b/assets/common/items/armor/pants/cloth_green_0.ron index 402a9fe954..bbb60b2220 100644 --- a/assets/common/items/armor/pants/cloth_green_0.ron +++ b/assets/common/items/armor/pants/cloth_green_0.ron @@ -2,7 +2,7 @@ Item( name: "Green Linen Skirt", description: "WIP", kind: Armor( - kind: Belt(ClothGreen0), + kind: Pants(ClothGreen0), stats: 20, ), ) diff --git a/assets/common/items/armor/pants/cloth_purple_0.ron b/assets/common/items/armor/pants/cloth_purple_0.ron index a70280779f..d1b73cb4b0 100644 --- a/assets/common/items/armor/pants/cloth_purple_0.ron +++ b/assets/common/items/armor/pants/cloth_purple_0.ron @@ -2,7 +2,7 @@ Item( name: "Purple Linen Skirt", description: "WIP", kind: Armor( - kind: Belt(ClothPurple0), + kind: Pants(ClothPurple0), stats: 20, ), ) diff --git a/assets/common/items/armor/shoulder/cloth_blue_0.ron b/assets/common/items/armor/shoulder/cloth_blue_0.ron index 55246f765f..70bfcf1bb3 100644 --- a/assets/common/items/armor/shoulder/cloth_blue_0.ron +++ b/assets/common/items/armor/shoulder/cloth_blue_0.ron @@ -2,7 +2,7 @@ Item( name: "Blue Linen Coat", description: "WIP", kind: Armor( - kind: Belt(ClothBlue0), + kind: Shoulder(ClothBlue0), stats: 20, ), ) diff --git a/assets/common/items/armor/shoulder/cloth_green_0.ron b/assets/common/items/armor/shoulder/cloth_green_0.ron index 899b3568b5..79ff879ecc 100644 --- a/assets/common/items/armor/shoulder/cloth_green_0.ron +++ b/assets/common/items/armor/shoulder/cloth_green_0.ron @@ -2,7 +2,7 @@ Item( name: "Green Linen Coat", description: "WIP", kind: Armor( - kind: Belt(ClothGreen0), + kind: Shoulder(ClothGreen0), stats: 20, ), -) \ No newline at end of file +) diff --git a/assets/common/items/armor/shoulder/cloth_purple_0.ron b/assets/common/items/armor/shoulder/cloth_purple_0.ron index bc89fea35c..130a52c5ab 100644 --- a/assets/common/items/armor/shoulder/cloth_purple_0.ron +++ b/assets/common/items/armor/shoulder/cloth_purple_0.ron @@ -2,7 +2,7 @@ Item( name: "Purple Linen Coat", description: "WIP", kind: Armor( - kind: Belt(ClothPurple0), + kind: Shoulder(ClothPurple0), stats: 20, ), -) \ No newline at end of file +) diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index 2d3b35706f..7294505cb3 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -74,11 +74,11 @@ (0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1, ), Armor(Hand(Assassin)): VoxTrans( - "voxel.armor.hand.assa_left", + "voxel.armor.hand.assa_right", (0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0, ), Armor(Shoulder(Assassin)): VoxTrans( - "voxel.armor.shoulder.assa_left", + "voxel.armor.shoulder.assa_right", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), // Starting Armor - Plate @@ -99,15 +99,15 @@ (0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1, ), Armor(Hand(Plate0)): VoxTrans( - "voxel.armor.hand.plate_left-0", + "voxel.armor.hand.plate_right-0", (0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0, ), Armor(Shoulder(Plate0)): VoxTrans( - "voxel.armor.shoulder.plate_left-0", + "voxel.armor.shoulder.plate_right-0", (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, ), //Leather0 Armor - Armor(Chest(Leather0)): VoxTrans( + Armor(Chest(Leather0)): VoxTrans( "voxel.armor.chest.leather-0", (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, ), @@ -124,15 +124,98 @@ (0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1, ), Armor(Hand(Leather0)): VoxTrans( - "voxel.armor.hand.leather_left-0", + "voxel.armor.hand.leather_right-0", (0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0, ), Armor(Shoulder(Leather1)): VoxTrans( - "voxel.armor.shoulder.leather_left-1", + "voxel.armor.shoulder.leather_right-1", (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, ), Armor(Shoulder(Leather0)): VoxTrans( - "voxel.armor.shoulder.leather_left-0", + "voxel.armor.shoulder.leather_right-0", + (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, + ), + //Linen Cloth + Armor(Chest(ClothBlue0)): VoxTrans( + "voxel.armor.chest.cloth_blue-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Pants(ClothBlue0)): VoxTrans( + "voxel.armor.pants.cloth_blue-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Belt(ClothBlue0)): VoxTrans( + "voxel.armor.belt.cloth_blue-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.8, + ), + Armor(Foot(ClothBlue0)): VoxTrans( + "voxel.armor.foot.cloth_blue-0", + (0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1, + ), + Armor(Hand(ClothBlue0)): VoxTrans( + "voxel.armor.hand.cloth_blue_right-0", + (0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0, + ), + Armor(Shoulder(ClothBlue0)): VoxTrans( + "voxel.armor.shoulder.cloth_blue_right-0", + (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, + ), + ////////////// + Armor(Chest(ClothGreen0)): VoxTrans( + "voxel.armor.chest.cloth_green-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Pants(ClothGreen0)): VoxTrans( + "voxel.armor.pants.cloth_green-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Belt(ClothGreen0)): VoxTrans( + "voxel.armor.belt.cloth_green-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.8, + ), + Armor(Foot(ClothGreen0)): VoxTrans( + "voxel.armor.foot.cloth_green-0", + (0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1, + ), + Armor(Hand(ClothGreen0)): VoxTrans( + "voxel.armor.hand.cloth_green_right-0", + (0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0, + ), + Armor(Shoulder(Leather1)): VoxTrans( + "voxel.armor.shoulder.cloth_green_right-0", + (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, + ), + Armor(Shoulder(ClothGreen0)): VoxTrans( + "voxel.armor.shoulder.cloth_green_right-0", + (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, + ), + ////// + Armor(Chest(ClothPurple0)): VoxTrans( + "voxel.armor.chest.cloth_purple-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Pants(ClothPurple0)): VoxTrans( + "voxel.armor.pants.cloth_purple-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2, + ), + Armor(Belt(ClothPurple0)): VoxTrans( + "voxel.armor.belt.cloth_purple-0", + (0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.8, + ), + Armor(Foot(ClothPurple0)): VoxTrans( + "voxel.armor.foot.cloth_purple-0", + (0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1, + ), + Armor(Hand(ClothPurple0)): VoxTrans( + "voxel.armor.hand.cloth_purple_right-0", + (0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0, + ), + Armor(Shoulder(ClothPurple0)): VoxTrans( + "voxel.armor.shoulder.cloth_purple_right-1", + (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, + ), + Armor(Shoulder(ClothPurple0)): VoxTrans( + "voxel.armor.shoulder.cloth_purple_right-0", (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, ), // Consumables diff --git a/assets/voxygen/voxel/armor/belt/cloth_blood.vox b/assets/voxygen/voxel/armor/belt/cloth_blood.vox index aada11a8f7..6ceecc6bcc 100644 --- a/assets/voxygen/voxel/armor/belt/cloth_blood.vox +++ b/assets/voxygen/voxel/armor/belt/cloth_blood.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:55cab5d4e7af59ee51a9b84a9b1f463ec67e4b7dcf826190bd7841d5ec4a6498 -size 56019 +oid sha256:a7b0dc5700924993498e85da238575afe82560eb731f5325208010195ec59a3f +size 1536 diff --git a/assets/voxygen/voxel/armor/belt/cloth_blue-0.vox b/assets/voxygen/voxel/armor/belt/cloth_blue-0.vox index 4402e9f2d1..bbfffeddfa 100644 --- a/assets/voxygen/voxel/armor/belt/cloth_blue-0.vox +++ b/assets/voxygen/voxel/armor/belt/cloth_blue-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:214ecba8428bf90de0e5a4703f028ce474b47121b29d5d786681c5e7081a7c71 +oid sha256:0c9105cf4a36363c634305678e58da2e0caed456ac58ece7cc2f75073af1d1cb size 1480 diff --git a/assets/voxygen/voxel/armor/belt/cloth_green-0.vox b/assets/voxygen/voxel/armor/belt/cloth_green-0.vox index 5bac822528..881e668464 100644 --- a/assets/voxygen/voxel/armor/belt/cloth_green-0.vox +++ b/assets/voxygen/voxel/armor/belt/cloth_green-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bbfa2b6ff274de9fab0a7b910849d9059d9879a041166aeff7cfa8b95cdcecac +oid sha256:6947c00796247c7176aebff4d7b19c88416db20ce692245a864e1baaa9035350 size 1480 diff --git a/assets/voxygen/voxel/armor/belt/cloth_purple-0.vox b/assets/voxygen/voxel/armor/belt/cloth_purple-0.vox index 1aec2c1601..8671b16647 100644 --- a/assets/voxygen/voxel/armor/belt/cloth_purple-0.vox +++ b/assets/voxygen/voxel/armor/belt/cloth_purple-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f038d665dec7532e904efc4a5c64f610e72a8ab3b526f254d5ad6c1d0b55f9d3 +oid sha256:c5b5ff3e4c197686e9bae89cc776f13e3461fff9b168c68c570c4dccfc7c2d34 size 1480 diff --git a/assets/voxygen/voxel/armor/chest/cloth_blue-0.vox b/assets/voxygen/voxel/armor/chest/cloth_blue-0.vox index fe27d36a65..db4983e487 100644 --- a/assets/voxygen/voxel/armor/chest/cloth_blue-0.vox +++ b/assets/voxygen/voxel/armor/chest/cloth_blue-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5290d1fb4cc05689bc27b4cd5927809208ef93bbd7f2366c7c95c6d0a99d1a40 -size 2896 +oid sha256:86dae5747863ce7d6295579d615f9981f36cfabd90491135eae77b27ee4bc7d2 +size 2688 diff --git a/assets/voxygen/voxel/armor/chest/cloth_green-0.vox b/assets/voxygen/voxel/armor/chest/cloth_green-0.vox index 54b8596052..46c430dfa0 100644 --- a/assets/voxygen/voxel/armor/chest/cloth_green-0.vox +++ b/assets/voxygen/voxel/armor/chest/cloth_green-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:92e619fe8e555784f6bcf0ec8701741f7868a5b17ef005231bd53ce7343112b6 -size 2896 +oid sha256:d036f47008c035f4523819e53933cca39461eb3dd51cde6a0e591c6d3f6f2629 +size 2688 diff --git a/assets/voxygen/voxel/armor/chest/cloth_purple-0.vox b/assets/voxygen/voxel/armor/chest/cloth_purple-0.vox index 61d9c3217e..cc7af8ef79 100644 --- a/assets/voxygen/voxel/armor/chest/cloth_purple-0.vox +++ b/assets/voxygen/voxel/armor/chest/cloth_purple-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b97d4b71ec99918480672fd03135cb99276083e2570214b65813f7d399bfb195 -size 2896 +oid sha256:40b9e27d6ffa8129eae701e36a4e7e54ca864a1b8b47dc442eefe7ffb0bae9e7 +size 2688 diff --git a/assets/voxygen/voxel/armor/hand/cloth_blue_right-0.vox b/assets/voxygen/voxel/armor/hand/cloth_blue_right-0.vox index f71e01b85a..94db99996f 100644 --- a/assets/voxygen/voxel/armor/hand/cloth_blue_right-0.vox +++ b/assets/voxygen/voxel/armor/hand/cloth_blue_right-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f22d6fad1a1752016d79a0f9bbb305be31fb7209d5d5679126de612c68befff9 +oid sha256:a9778605e9bd050a5fd79c553ee4ae1a0d6dcdc68c582b22090cfef609cc0b2c size 1240 diff --git a/assets/voxygen/voxel/armor/hand/cloth_purple_right-0.vox b/assets/voxygen/voxel/armor/hand/cloth_purple_right-0.vox index 148bae4f57..8ffef537eb 100644 --- a/assets/voxygen/voxel/armor/hand/cloth_purple_right-0.vox +++ b/assets/voxygen/voxel/armor/hand/cloth_purple_right-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0fd8ff5b52d6d7f8a2d8967da1957d21012958714cce43f0a0105d90b76c3fe -size 1240 +oid sha256:93dd0d8050e30b1349218efb63c2e669fa750da83156a6eded1395731b8e057d +size 55723 diff --git a/assets/voxygen/voxel/armor/pants/cloth_blue-0.vox b/assets/voxygen/voxel/armor/pants/cloth_blue-0.vox index 8bd1fbf769..87d313fc19 100644 --- a/assets/voxygen/voxel/armor/pants/cloth_blue-0.vox +++ b/assets/voxygen/voxel/armor/pants/cloth_blue-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:016dfd8f53ffbc51cb49f097a55eb5f7f7f33c22a143f50ba1c9b48236b6c6dd -size 56723 +oid sha256:57c43b492bb31f704ee3f78b0b030fb4588916d78742b0b832cdab44a482beb2 +size 2312 diff --git a/assets/voxygen/voxel/armor/pants/cloth_green-0.vox b/assets/voxygen/voxel/armor/pants/cloth_green-0.vox index 89cba3fc8d..ebf4a2685d 100644 --- a/assets/voxygen/voxel/armor/pants/cloth_green-0.vox +++ b/assets/voxygen/voxel/armor/pants/cloth_green-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:19c2a53716b89f3ed90078ce5e43eecaff3ebb86b2409b7b0f709224de421310 -size 56723 +oid sha256:510460353bc946a9e2f224d88d388122099abfecbebf13a3f2a16dfddc8a1ce5 +size 2312 diff --git a/assets/voxygen/voxel/armor/pants/cloth_purple-0.vox b/assets/voxygen/voxel/armor/pants/cloth_purple-0.vox index 455e0ef463..88b068b5d5 100644 --- a/assets/voxygen/voxel/armor/pants/cloth_purple-0.vox +++ b/assets/voxygen/voxel/armor/pants/cloth_purple-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:872d7aafecb11c883d5f1771cc94224558724bc7f817f2ce605cdbc6b9bf2147 -size 56723 +oid sha256:91b30a998e7f395bef3f2adf8214f6a5b5c5f30b55807bb0c8fdc4d10c47b61a +size 2312 diff --git a/assets/voxygen/voxel/armor/pants/grayscale.vox b/assets/voxygen/voxel/armor/pants/grayscale.vox index 43c06d85a1..e3def7502b 100644 --- a/assets/voxygen/voxel/armor/pants/grayscale.vox +++ b/assets/voxygen/voxel/armor/pants/grayscale.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7d764227547e7dd1660ac5c39c4d9646f11c2c58efd8363702259b326e832a55 -size 56395 +oid sha256:7efe7e5563f5af4229118b9abb560f0e32472ae40416146bd5bbd12a99d66df5 +size 1912 diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index 8e73ed569c..24fbedd44c 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -36,16 +36,16 @@ color: None ), ClothPurple0:( - vox_spec: ("armor.belt.cloth_purple_0", (-5.0, -3.5, 2.0)), + vox_spec: ("armor.belt.cloth_purple-0", (-5.0, -3.5, 2.0)), color: None ), ClothBlue0:( - vox_spec: ("armor.belt.cloth_blue_0", (-5.0, -3.5, 2.0)), + vox_spec: ("armor.belt.cloth_blue-0", (-5.0, -3.5, 2.0)), color: None ), ClothGreen0:( - vox_spec: ("armor.belt.cloth_purple_0", (-5.0, -3.5, 2.0)), + vox_spec: ("armor.belt.cloth_green-0", (-5.0, -3.5, 2.0)), color: None ), - + }) diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index c6fe492716..c053c04cbd 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -44,16 +44,16 @@ color: None ), ClothPurple0:( - vox_spec: ("armor.chest.cloth_purple-0", (-7.0, -3.5, 2.0)), + vox_spec: ("armor.chest.cloth_purple-0", (-7.0, -3.5, 1.0)), color: None ), ClothBlue0:( - vox_spec: ("armor.chest.cloth_blue-0", (-7.0, -3.5, 2.0)), + vox_spec: ("armor.chest.cloth_blue-0", (-7.0, -3.5, 1.0)), color: None ), ClothGreen0:( - vox_spec: ("armor.chest.cloth_green-0", (-7.0, -3.5, 2.0)), + vox_spec: ("armor.chest.cloth_green-0", (-7.0, -3.5, 1.0)), color: None ), - + }) diff --git a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron index a546c19310..868541dc78 100644 --- a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron @@ -28,15 +28,15 @@ color: None ), ClothPurple0:( - vox_spec: ("armor.foot.cloth_purple_0", (-2.5, -3.5, -9.0)), + vox_spec: ("armor.foot.cloth_purple-0", (-2.5, -3.5, -9.0)), color: None ), ClothBlue0:( - vox_spec: ("armor.foot.cloth_purple_0", (-2.5, -3.5, -9.0)), + vox_spec: ("armor.foot.cloth_blue-0", (-2.5, -3.5, -9.0)), color: None ), ClothGreen0:( - vox_spec: ("armor.foot.cloth_purple_0", (-2.5, -3.5, -9.0)), + vox_spec: ("armor.foot.cloth_green-0", (-2.5, -3.5, -9.0)), color: None ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron index 1005bbfcc3..151a85f9a9 100644 --- a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron @@ -51,7 +51,7 @@ ), ClothPurple0: ( left: ( - vox_spec: ("armor.hand.cloth_purple_left-0", (-1.5, -1.5, -7.0)), + vox_spec: ("armor.hand.cloth_purple_right-0", (-1.5, -1.5, -7.0)), color: None ), right: ( @@ -61,7 +61,7 @@ ), ClothBlue0: ( left: ( - vox_spec: ("armor.hand.cloth_blue_left-0", (-1.5, -1.5, -7.0)), + vox_spec: ("armor.hand.cloth_blue_right-0", (-1.5, -1.5, -7.0)), color: None ), right: ( @@ -71,7 +71,7 @@ ), ClothGreen0: ( left: ( - vox_spec: ("armor.hand.cloth_green_left-0", (-1.5, -1.5, -7.0)), + vox_spec: ("armor.hand.cloth_green_right-0", (-1.5, -1.5, -7.0)), color: None ), right: ( diff --git a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron index 1b8d93ad57..56ae5d0c2d 100644 --- a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron @@ -40,15 +40,15 @@ color: None ), ClothPurple0:( - vox_spec: ("armor.pants.cloth_purple_0", (-5.0, -3.5, 2.0)), + vox_spec: ("armor.pants.cloth_purple-0", (-5.0, -3.5, 0.0)), color: None ), ClothBlue0:( - vox_spec: ("armor.pants.cloth_blue_0", (-5.0, -3.5, 2.0)), + vox_spec: ("armor.pants.cloth_blue-0", (-5.0, -3.5, 0.0)), color: None ), ClothGreen0:( - vox_spec: ("armor.pants.cloth_purple_0", (-5.0, -3.5, 2.0)), + vox_spec: ("armor.pants.cloth_green-0", (-5.0, -3.5, 0.0)), color: None ), }) diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index c099a12fd9..8b06beeeea 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -82,7 +82,7 @@ ), ClothPurple0: ( left: ( - vox_spec: ("armor.shoulder.cloth_purple_left-0", (-3.2, -3.5, 1.0)), + vox_spec: ("armor.shoulder.cloth_purple_right-0", (-3.2, -3.5, 1.0)), color: None ), right: ( diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index ad2d0f7e53..89a382354d 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -277,10 +277,62 @@ impl Inventory { impl Default for Inventory { fn default() -> Inventory { let mut inventory = Inventory { - slots: vec![None; 18], + slots: vec![None; 45], }; - inventory.push(assets::load_expect_cloned("common.items.cheese")); - inventory.push(assets::load_expect_cloned("common.items.apple")); + inventory.push(assets::load_expect_cloned( + "common.items.armor.chest.cloth_blue_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.belt.cloth_blue_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.foot.cloth_blue_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.hand.cloth_blue_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.pants.cloth_blue_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.shoulder.cloth_blue_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.chest.cloth_green_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.belt.cloth_green_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.foot.cloth_green_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.hand.cloth_green_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.pants.cloth_green_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.shoulder.cloth_green_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.chest.cloth_purple_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.belt.cloth_purple_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.foot.cloth_purple_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.hand.cloth_purple_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.pants.cloth_purple_0", + )); + inventory.push(assets::load_expect_cloned( + "common.items.armor.shoulder.cloth_purple_0", + )); inventory } } From 662f5b1037a26e9637ccf978f382582830a6c583 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sun, 22 Mar 2020 14:55:08 +0100 Subject: [PATCH 203/326] removed warnings and item test values --- common/src/comp/inventory/mod.rs | 58 ++------------------------- voxygen/src/menu/char_selection/ui.rs | 2 +- voxygen/src/scene/figure/load.rs | 1 - 3 files changed, 4 insertions(+), 57 deletions(-) diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 89a382354d..ad2d0f7e53 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -277,62 +277,10 @@ impl Inventory { impl Default for Inventory { fn default() -> Inventory { let mut inventory = Inventory { - slots: vec![None; 45], + slots: vec![None; 18], }; - inventory.push(assets::load_expect_cloned( - "common.items.armor.chest.cloth_blue_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.belt.cloth_blue_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.foot.cloth_blue_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.hand.cloth_blue_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.pants.cloth_blue_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.shoulder.cloth_blue_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.chest.cloth_green_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.belt.cloth_green_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.foot.cloth_green_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.hand.cloth_green_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.pants.cloth_green_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.shoulder.cloth_green_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.chest.cloth_purple_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.belt.cloth_purple_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.foot.cloth_purple_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.hand.cloth_purple_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.pants.cloth_purple_0", - )); - inventory.push(assets::load_expect_cloned( - "common.items.armor.shoulder.cloth_purple_0", - )); + inventory.push(assets::load_expect_cloned("common.items.cheese")); + inventory.push(assets::load_expect_cloned("common.items.apple")); inventory } } diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index 3963298e42..54db12eda6 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -683,7 +683,7 @@ impl CharSelectionUi { Mode::Create { name, body, - loadout, + loadout: _, tool, } => { let mut to_select = false; diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 65b5dff155..a2e51c48ab 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -21,7 +21,6 @@ use common::{ ItemKind, Loadout, }, figure::{DynaUnionizer, MatSegment, Material, Segment}, - vol::SizedVol, }; use dot_vox::DotVoxData; use hashbrown::HashMap; From 48b59775511fcada379910875563ec8f5df29a93 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 22 Mar 2020 14:56:14 +0000 Subject: [PATCH 204/326] add watchtower support and fix CMD in Dockerfile --- server-cli/Dockerfile | 2 +- server-cli/docker-compose.yml | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server-cli/Dockerfile b/server-cli/Dockerfile index 1dcdbcac34..ee9c4009a5 100644 --- a/server-cli/Dockerfile +++ b/server-cli/Dockerfile @@ -7,4 +7,4 @@ COPY ./assets/common /opt/assets/common COPY ./assets/world /opt/assets/world WORKDIR /opt -CMD ["RUST_LOG=info,common=debug,common::net=info RUST_BACKTRACE=1 /opt/veloren-server-cli"] +CMD [ "sh", "-c", "RUST_LOG=info,common=debug,common::net=info RUST_BACKTRACE=1 /opt/veloren-server-cli" ] diff --git a/server-cli/docker-compose.yml b/server-cli/docker-compose.yml index ba9badf7de..d4e52b364f 100644 --- a/server-cli/docker-compose.yml +++ b/server-cli/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.7" +version: "3.5" services: game-server: @@ -11,7 +11,14 @@ services: update_config: parallelism: 2 delay: 10s - order: stop-first + order: stop-first failure_action: rollback restart_policy: condition: on-failure + watchtower: + image: containrrr/watchtower + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /root/.docker/config.json:/config.json + command: --interval 30 --cleanup + From 387ab4a57efaabd8f80c125e6643ffb89a304a93 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sun, 22 Mar 2020 16:19:30 +0100 Subject: [PATCH 205/326] added new stuff to chests --- common/src/comp/inventory/item.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 44113227de..117a501845 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -321,8 +321,28 @@ impl Item { "common.items.armor.shoulder.plate_0", "common.items.armor.shoulder.leather_1", "common.items.armor.shoulder.leather_0", + "common.items.armor.hand.leather_0", + "common.items.armor.hand.plate_0", "common.items.weapons.wood_sword", "common.items.weapons.short_sword_0", + "common.items.armor.belt.cloth_blue_0", + "common.items.armor.chest.cloth_blue_0", + "common.items.armor.foot.cloth_blue_0", + "common.items.armor.pants.cloth_blue_0", + "common.items.armor.shoulder.cloth_blue_0", + "common.items.armor.hand.cloth_blue_0", + "common.items.armor.belt.cloth_green_0", + "common.items.armor.chest.cloth_green_0", + "common.items.armor.foot.cloth_green_0", + "common.items.armor.pants.cloth_green_0", + "common.items.armor.shoulder.cloth_green_0", + "common.items.armor.hand.cloth_green_0", + "common.items.armor.belt.cloth_purple_0", + "common.items.armor.chest.cloth_purple_0", + "common.items.armor.foot.cloth_purple_0", + "common.items.armor.pants.cloth_purple_0", + "common.items.armor.shoulder.cloth_purple_0", + "common.items.armor.hand.cloth_purple_0", ] .choose(&mut rand::thread_rng()) .unwrap(), // Can't fail From 0456d3cbed023b8e8994b97233113176d0a180dc Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sun, 22 Mar 2020 16:25:47 +0100 Subject: [PATCH 206/326] Better staff M1, random +1 damage, better attackrange,angle impl --- common/src/comp/ability.rs | 8 +++++++- common/src/comp/inventory/item.rs | 30 +++++++++++++++--------------- common/src/states/basic_melee.rs | 14 ++++++++++++-- common/src/states/climb.rs | 2 +- common/src/states/dash_melee.rs | 1 + common/src/sys/combat.rs | 18 +++++++++++++++--- server/src/sys/terrain.rs | 13 +++++++++---- 7 files changed, 60 insertions(+), 26 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index d2f0a56272..cd3c489900 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -13,6 +13,8 @@ pub enum CharacterAbility { buildup_duration: Duration, recover_duration: Duration, base_damage: u32, + range: f32, + max_angle: f32, }, BasicRanged { recover_duration: Duration, @@ -95,11 +97,15 @@ impl From<&CharacterAbility> for CharacterState { buildup_duration, recover_duration, base_damage, + range, + max_angle, } => CharacterState::BasicMelee(basic_melee::Data { exhausted: false, buildup_duration: *buildup_duration, recover_duration: *recover_duration, base_damage: *base_damage, + range: *range, + max_angle: *max_angle, }), CharacterAbility::BasicRanged { recover_duration, @@ -129,7 +135,7 @@ impl From<&CharacterAbility> for CharacterState { }), CharacterAbility::BasicBlock => CharacterState::BasicBlock, CharacterAbility::Roll => CharacterState::Roll(roll::Data { - remaining_duration: Duration::from_millis(600), + remaining_duration: Duration::from_millis(300), }), CharacterAbility::TimedCombo { buildup_duration, diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 117a501845..3b95c04e6f 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -68,28 +68,24 @@ impl ToolData { use ToolKind::*; match self.kind { - Sword(_) => vec![ - // BasicMelee { - // buildup_duration: Duration::from_millis(100), - // recover_duration: Duration::from_millis(500), - // base_damage: 6, - // }, - TripleStrike { base_damage: 7 }, - DashMelee { - buildup_duration: Duration::from_millis(500), - recover_duration: Duration::from_millis(500), - base_damage: 20, - }, - ], + Sword(_) => vec![TripleStrike { base_damage: 7 }, DashMelee { + buildup_duration: Duration::from_millis(500), + recover_duration: Duration::from_millis(500), + base_damage: 20, + }], Axe(_) => vec![BasicMelee { buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(100), base_damage: 8, + range: 3.5, + max_angle: 30.0, }], Hammer(_) => vec![BasicMelee { buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(300), base_damage: 10, + range: 3.5, + max_angle: 60.0, }], Bow(_) => vec![BasicRanged { projectile: Projectile { @@ -113,12 +109,16 @@ impl ToolData { buildup_duration: Duration::from_millis(100), recover_duration: Duration::from_millis(400), base_damage: 5, + range: 3.5, + max_angle: 60.0, }], Staff(_) => vec![ BasicMelee { - buildup_duration: Duration::from_millis(400), + buildup_duration: Duration::from_millis(0), recover_duration: Duration::from_millis(300), - base_damage: 7, + base_damage: 3, + range: 10.0, + max_angle: 45.0, }, BasicRanged { projectile: Projectile { diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index e006a6b2da..01778be4f4 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -5,7 +5,7 @@ use crate::{ }; use std::time::Duration; -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Data { /// How long until state should deal damage pub buildup_duration: Duration, @@ -13,6 +13,10 @@ pub struct Data { pub recover_duration: Duration, /// Base damage pub base_damage: u32, + /// Max range + pub range: f32, + /// Max angle (45.0 will give you a 90.0 angle window) + pub max_angle: f32, /// Whether the attack can deal more damage pub exhausted: bool, } @@ -32,13 +36,15 @@ impl CharacterBehavior for Data { .unwrap_or_default(), recover_duration: self.recover_duration, base_damage: self.base_damage, + range: self.range, + max_angle: self.max_angle, exhausted: false, }); } else if !self.exhausted { // Hit attempt data.updater.insert(data.entity, Attacking { base_damage: self.base_damage, - max_angle: 75_f32.to_radians(), + max_angle: self.max_angle.to_radians(), applied: false, hit_count: 0, }); @@ -47,6 +53,8 @@ impl CharacterBehavior for Data { buildup_duration: self.buildup_duration, recover_duration: self.recover_duration, base_damage: self.base_damage, + range: self.range, + max_angle: self.max_angle, exhausted: true, }); } else if self.recover_duration != Duration::default() { @@ -58,6 +66,8 @@ impl CharacterBehavior for Data { .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), base_damage: self.base_damage, + range: self.range, + max_angle: self.max_angle, exhausted: true, }); } else { diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index c98a26dbfc..c14326f7d4 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -22,7 +22,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - if let Err(_) = update.energy.try_change_by(-5, EnergySource::Climb) { + if let Err(_) = update.energy.try_change_by(-8, EnergySource::Climb) { update.character = CharacterState::Idle {}; } diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 2fbc2016e1..22223a66fa 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -27,6 +27,7 @@ impl CharacterBehavior for Data { if self.initialize { update.vel.0 = data.inputs.look_dir * 20.0; + update.ori.0 = data.vel.0.normalized(); } if self.buildup_duration != Duration::default() && data.physics.touch_entity.is_none() { diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index dab3766b5a..18bb3eb9fd 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos, Scale, - Stats, + Agent, Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos, + Scale, Stats, }, event::{EventBus, ServerEvent}, sync::Uid, @@ -25,6 +25,7 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Pos>, ReadStorage<'a, Ori>, ReadStorage<'a, Scale>, + ReadStorage<'a, Agent>, ReadStorage<'a, Controller>, ReadStorage<'a, Body>, ReadStorage<'a, Stats>, @@ -41,6 +42,7 @@ impl<'a> System<'a> for Sys { positions, orientations, scales, + agents, controllers, bodies, stats, @@ -50,12 +52,13 @@ impl<'a> System<'a> for Sys { ) { let mut server_emitter = server_bus.emitter(); // Attacks - for (entity, uid, pos, ori, scale_maybe, _, _attacker_stats, attack) in ( + for (entity, uid, pos, ori, scale_maybe, agent_maybe, _, _attacker_stats, attack) in ( &entities, &uids, &positions, &orientations, scales.maybe(), + agents.maybe(), &controllers, &stats, &mut attacking_storage, @@ -100,6 +103,15 @@ impl<'a> System<'a> for Sys { // Weapon gives base damage let mut dmg = attack.base_damage; + // NPCs do less damage: + if agent_maybe.is_some() { + dmg = (dmg / 2).max(1); + } + + if rand::random() { + dmg += 1; + } + // Block if character_b.is_block() && ori_b.0.angle_between(pos.0 - pos_b.0) < BLOCK_ANGLE.to_radians() / 2.0 diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index efe6265b93..557e9549c6 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -198,16 +198,19 @@ impl<'a> System<'a> for Sys { item, primary_ability: ability_drain.next(), secondary_ability: ability_drain.next(), - block_ability: Some(comp::CharacterAbility::BasicBlock), + block_ability: None, dodge_ability: Some(comp::CharacterAbility::Roll), }) } else { Some(ItemConfig { + // We need the empty item so npcs can attack item: Item::empty(), primary_ability: Some(CharacterAbility::BasicMelee { - buildup_duration: Duration::from_millis(50), - recover_duration: Duration::from_millis(50), - base_damage: 1, + buildup_duration: Duration::from_millis(0), + recover_duration: Duration::from_millis(300), + base_damage: 2, + range: 3.5, + max_angle: 60.0, }), secondary_ability: None, block_ability: None, @@ -301,6 +304,8 @@ impl<'a> System<'a> for Sys { buildup_duration: Duration::from_millis(800), recover_duration: Duration::from_millis(200), base_damage: 13, + range: 3.5, + max_angle: 60.0, }), secondary_ability: None, block_ability: None, From 0773524031a213c3e3d2fde8cad07363b9b3e39c Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 22 Mar 2020 11:55:28 -0400 Subject: [PATCH 207/326] wield idle, wield run --- voxygen/src/anim/character/attack.rs | 2 +- voxygen/src/anim/character/idlewield.rs | 247 ++++++++++++++++++++++++ voxygen/src/anim/character/mod.rs | 8 +- voxygen/src/anim/character/wield.rs | 43 ++++- voxygen/src/scene/figure/mod.rs | 60 +++--- 5 files changed, 326 insertions(+), 34 deletions(-) create mode 100644 voxygen/src/anim/character/idlewield.rs diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index 96dccc06d2..e78a317a70 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -106,7 +106,7 @@ impl Animation for AttackAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right + slowax * 2.0, -2.0 + skeleton_attr.neck_forward + slowax * -2.0, - skeleton_attr.neck_height + 19.0, + skeleton_attr.neck_height + 20.0, ); next.head.ori = Quaternion::rotation_z(slowax * 0.25) * Quaternion::rotation_x(0.0 + slowax * 0.2) diff --git a/voxygen/src/anim/character/idlewield.rs b/voxygen/src/anim/character/idlewield.rs new file mode 100644 index 0000000000..85e97f3794 --- /dev/null +++ b/voxygen/src/anim/character/idlewield.rs @@ -0,0 +1,247 @@ +use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; +use common::comp::item::ToolKind; +use std::{f32::consts::PI, ops::Mul}; + +use vek::*; + +pub struct IdleWieldAnimation; + +impl Animation for IdleWieldAnimation { + type Dependency = (Option, f32, f64); + type Skeleton = CharacterSkeleton; + + fn update_skeleton( + skeleton: &Self::Skeleton, + (active_tool_kind, _velocity, global_time): Self::Dependency, + anim_time: f64, + _rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + let _lab = 1.0; + let wave_slow_cos = (anim_time as f32 * 6.0 + PI).cos(); + let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); + let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); + + let wave = (anim_time as f32 * 1.0).sin(); + match active_tool_kind { + //TODO: Inventory + Some(ToolKind::Sword(_)) => { + next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0); + next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(1.25, -5.5, -8.0); + next.r_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 0.0, -6.0); + next.main.ori = Quaternion::rotation_x(-0.1) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.15) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.08); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Axe(_)) => { + next.l_hand.offset = Vec3::new(-4.0, 3.0, 6.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(-2.5, 9.0, 4.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(-6.0, 10.0, -1.0); + next.main.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(-0.8); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(0.0, 0.0, 0.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.1 + 0.2) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(wave_ultra_slow * 0.1 + 0.0); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Hammer(_)) => { + next.l_hand.offset = Vec3::new(-7.0, 4.6, 7.5); + next.l_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.32); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(8.0, 5.75, 4.0); + next.r_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.22); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(6.0, 7.0, 0.0); + next.main.ori = Quaternion::rotation_x(0.3) + * Quaternion::rotation_y(-1.35) + * Quaternion::rotation_z(1.57); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(0.0, 0.0, 0.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.15) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.08); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Staff(_)) => { + next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); + next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(1.8) + * Quaternion::rotation_y(0.5) + * Quaternion::rotation_z(-0.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(11.0, 9.0, 10.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(3.14 + 0.3) + * Quaternion::rotation_z(0.9); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Shield(_)) => { + next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new( + -6.0 + skeleton_attr.weapon_x, + 4.5 + skeleton_attr.weapon_y, + 0.0, + ); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Bow(_)) => { + next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); + next.l_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(3.0, -1.0, -5.0); + next.r_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(3.0, 2.0, -13.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.3) + * Quaternion::rotation_z(-0.6); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Dagger(_)) => { + next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new( + -6.0 + skeleton_attr.weapon_x, + 4.5 + skeleton_attr.weapon_y, + 0.0, + ); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Debug(_)) => { + next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); + next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); + next.r_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new( + 5.0 + skeleton_attr.weapon_x, + 8.75 + skeleton_attr.weapon_y, + -2.0, + ); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(-1.27) + * Quaternion::rotation_z(wave * -0.25); + next.main.scale = Vec3::one(); + }, + _ => {}, + } + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 10.0) + .floor() + .mul(7331.0) + .sin() + * 0.2, + ((global_time + anim_time) as f32 / 10.0) + .floor() + .mul(1337.0) + .sin() + * 0.1, + ); + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right + wave_slow_cos * 0.5, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 21.0 + wave_ultra_slow * 0.6, + ); + next.head.ori = + Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 7.0 + wave_ultra_slow * 0.5); + next.chest.ori = + Quaternion::rotation_y(wave_ultra_slow_cos * 0.04) * Quaternion::rotation_z(0.15); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 5.0 + wave_ultra_slow * 0.5); + next.belt.ori = + Quaternion::rotation_y(wave_ultra_slow_cos * 0.03) * Quaternion::rotation_z(0.22); + next.belt.scale = Vec3::one() * 1.02; + + next.shorts.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 2.0 + wave_ultra_slow * 0.5); + next.shorts.ori = Quaternion::rotation_z(0.3); + next.shorts.scale = Vec3::one(); + + next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0); + next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, 3.5, 8.0); + next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035); + next.r_foot.scale = Vec3::one(); + + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); + next + } +} diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 12eac67dda..6f1cd2978d 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -6,6 +6,7 @@ pub mod cidle; pub mod climb; pub mod gliding; pub mod idle; +pub mod idlewield; pub mod jump; pub mod roll; pub mod run; @@ -20,9 +21,10 @@ pub mod wield; pub use self::{ attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, charge::ChargeAnimation, cidle::CidleAnimation, climb::ClimbAnimation, - gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, roll::RollAnimation, - run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, - stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation, + gliding::GlidingAnimation, idle::IdleAnimation, idlewield::IdleWieldAnimation, + jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, + sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation, swim::SwimAnimation, + wield::WieldAnimation, }; use super::{Bone, Skeleton}; diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 1088a46ad8..a8a53bd307 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -20,6 +20,14 @@ impl Animation for WieldAnimation { let mut next = (*skeleton).clone(); let lab = 1.0; + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.32).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 1.32).sin()); + let short = (((5.0) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.32).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 1.32).sin()); let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); let long = (((5.0) @@ -192,23 +200,48 @@ impl Animation for WieldAnimation { _ => {}, } let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 18.0) + ((global_time + anim_time) as f32 / 6.0) .floor() .mul(7331.0) .sin() * 0.2, - ((global_time + anim_time) as f32 / 18.0) + ((global_time + anim_time) as f32 / 6.0) .floor() .mul(1337.0) .sin() * 0.1, ); + next.head.offset = Vec3::new( + 0.0, + -3.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 22.0 + short * 1.3, + ); next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1) - * Quaternion::rotation_x(head_look.y + 0.0); + * Quaternion::rotation_x(head_look.y + 0.35); next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(0.0); + next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1); + next.chest.ori = Quaternion::rotation_z(short * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 7.0 + short * 1.1); + next.belt.ori = Quaternion::rotation_z(short * 0.35); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 4.0 + short * 1.1); + next.shorts.ori = Quaternion::rotation_z(short * 0.6); + next.shorts.scale = Vec3::one(); + + next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); + next.r_foot.scale = Vec3::one(); + + next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(-0.2); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 0944c8615b..1cf52667b9 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -574,13 +574,23 @@ impl FigureMgr { ) }, CharacterState::Wielding { .. } => { - anim::character::WieldAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) + if vel.0.magnitude_squared() > 0.5 { + anim::character::WieldAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } else { + anim::character::IdleWieldAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } }, CharacterState::Glide { .. } => { anim::character::GlidingAnimation::update_skeleton( @@ -656,8 +666,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.001, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > 0.5, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => { @@ -736,8 +746,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.001, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > 0.5, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => { @@ -816,8 +826,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.001, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > 0.5, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::bird_medium::IdleAnimation::update_skeleton( @@ -890,8 +900,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.001, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > 0.5, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::fish_medium::IdleAnimation::update_skeleton( @@ -964,8 +974,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.001, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > 0.5, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::dragon::IdleAnimation::update_skeleton( @@ -1038,8 +1048,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.001, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > 0.5, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::critter::IdleAnimation::update_skeleton( @@ -1112,8 +1122,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.001, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > 0.5, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::bird_small::IdleAnimation::update_skeleton( @@ -1186,8 +1196,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.001, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > 0.5, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::fish_small::IdleAnimation::update_skeleton( @@ -1260,8 +1270,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.001, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > 0.5, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::biped_large::IdleAnimation::update_skeleton( From 1f363da248840f60b4f83c26db7a1b58f4ad67bf Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sun, 22 Mar 2020 18:51:23 +0100 Subject: [PATCH 208/326] small fixes, weapon models --- assets/voxygen/item_image_manifest.ron | 2 +- assets/voxygen/voxel/armor/hand/leather_right-0.vox | 4 ++-- assets/voxygen/voxel/weapon/axe/orc-0.vox | 3 +++ assets/voxygen/voxel/weapon/hammer/orc-0.vox | 3 +++ assets/voxygen/voxel/weapon/staff/orc-0.vox | 3 +++ 5 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 assets/voxygen/voxel/weapon/axe/orc-0.vox create mode 100644 assets/voxygen/voxel/weapon/hammer/orc-0.vox create mode 100644 assets/voxygen/voxel/weapon/staff/orc-0.vox diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index 7294505cb3..c0f91482e4 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -181,7 +181,7 @@ "voxel.armor.hand.cloth_green_right-0", (0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0, ), - Armor(Shoulder(Leather1)): VoxTrans( + Armor(Shoulder(ClothGreen0)): VoxTrans( "voxel.armor.shoulder.cloth_green_right-0", (0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2, ), diff --git a/assets/voxygen/voxel/armor/hand/leather_right-0.vox b/assets/voxygen/voxel/armor/hand/leather_right-0.vox index c25d07754e..e6c476e7f9 100644 --- a/assets/voxygen/voxel/armor/hand/leather_right-0.vox +++ b/assets/voxygen/voxel/armor/hand/leather_right-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:694d9318e8ecebe9f8e6036f53c14733f8eeef8bb16746a0eff75425526cd1f3 -size 55723 +oid sha256:2d4b55a00aa74cecb123bfacfd4a47047eb1bd321bea2c7d599226a67ca4e2f4 +size 1240 diff --git a/assets/voxygen/voxel/weapon/axe/orc-0.vox b/assets/voxygen/voxel/weapon/axe/orc-0.vox new file mode 100644 index 0000000000..f135b207e5 --- /dev/null +++ b/assets/voxygen/voxel/weapon/axe/orc-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:122f08460e44fbcc59e835e47c312ad22c2c2f41faf11f1eade23604080ae707 +size 1556 diff --git a/assets/voxygen/voxel/weapon/hammer/orc-0.vox b/assets/voxygen/voxel/weapon/hammer/orc-0.vox new file mode 100644 index 0000000000..f03ca4f4be --- /dev/null +++ b/assets/voxygen/voxel/weapon/hammer/orc-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ed85da5c6bdfb732f8668289abe16b91af608d128599e7471050800390c3c84 +size 1968 diff --git a/assets/voxygen/voxel/weapon/staff/orc-0.vox b/assets/voxygen/voxel/weapon/staff/orc-0.vox new file mode 100644 index 0000000000..803866fe57 --- /dev/null +++ b/assets/voxygen/voxel/weapon/staff/orc-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:659a247fc5db33cc65640e8d51c61de73ce17bc8ac40bc6d92331c45ca833207 +size 1392 From f3ca06aa71816a3eee350814d6009d16fa1c3ad3 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sun, 22 Mar 2020 20:39:50 +0100 Subject: [PATCH 209/326] feat: fireball explosions --- common/src/comp/ability.rs | 23 +++++++ common/src/comp/character_state.rs | 4 ++ common/src/comp/inventory/item.rs | 22 ++++--- common/src/comp/projectile.rs | 1 + common/src/event.rs | 3 +- common/src/states/cast_fireball.rs | 81 ++++++++++++++++++++++++ common/src/states/mod.rs | 1 + common/src/sys/character_behavior.rs | 1 + common/src/sys/projectile.rs | 28 +++++++- server/src/cmd.rs | 16 +++-- server/src/events/entity_manipulation.rs | 51 +++++++++++++-- server/src/events/mod.rs | 4 +- 12 files changed, 210 insertions(+), 25 deletions(-) create mode 100644 common/src/states/cast_fireball.rs diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index cd3c489900..40a9fb41c7 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -21,6 +21,11 @@ pub enum CharacterAbility { projectile: Projectile, projectile_body: Body, }, + CastFireball { + recover_duration: Duration, + projectile: Projectile, + projectile_body: Body, + }, Boost { duration: Duration, only_up: bool, @@ -63,6 +68,13 @@ impl CharacterAbility { .try_change_by(-300, EnergySource::Ability) .is_ok() }, + CharacterAbility::CastFireball { .. } => { + !data.physics.in_fluid + && update + .energy + .try_change_by(-500, EnergySource::Ability) + .is_ok() + }, _ => true, } } @@ -118,6 +130,17 @@ impl From<&CharacterAbility> for CharacterState { projectile: projectile.clone(), projectile_body: *projectile_body, }), + CharacterAbility::CastFireball { + recover_duration, + projectile, + projectile_body, + } => CharacterState::CastFireball(cast_fireball::Data { + exhausted: false, + prepare_timer: Duration::default(), + recover_duration: *recover_duration, + projectile: projectile.clone(), + projectile_body: *projectile_body, + }), CharacterAbility::Boost { duration, only_up } => CharacterState::Boost(boost::Data { duration: *duration, only_up: *only_up, diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 7a9c08c499..0fe75fbf4c 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -52,6 +52,8 @@ pub enum CharacterState { BasicMelee(basic_melee::Data), /// A basic ranged attack (e.g. bow) BasicRanged(basic_ranged::Data), + /// Cast a fireball + CastFireball(cast_fireball::Data), /// A force will boost you into a direction for some duration Boost(boost::Data), /// Dash forward and then attack @@ -70,6 +72,7 @@ impl CharacterState { CharacterState::Wielding | CharacterState::BasicMelee(_) | CharacterState::BasicRanged(_) + | CharacterState::CastFireball(_) | CharacterState::DashMelee(_) | CharacterState::TripleStrike(_) | CharacterState::TimedCombo(_) @@ -89,6 +92,7 @@ impl CharacterState { match self { CharacterState::BasicMelee(_) | CharacterState::BasicRanged(_) + | CharacterState::CastFireball(_) | CharacterState::TimedCombo(_) | CharacterState::DashMelee(_) | CharacterState::TripleStrike(_) => true, diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 3b95c04e6f..ed82aa1039 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -120,19 +120,21 @@ impl ToolData { range: 10.0, max_angle: 45.0, }, - BasicRanged { + CastFireball { projectile: Projectile { - hit_ground: vec![projectile::Effect::Vanish], - hit_wall: vec![projectile::Effect::Vanish], - hit_entity: vec![ - projectile::Effect::Damage(HealthChange { - // TODO: This should not be fixed (?) - amount: -8, - cause: HealthSource::Projectile { owner: None }, - }), + hit_ground: vec![ + projectile::Effect::Explode { power: 5.0 }, projectile::Effect::Vanish, ], - time_left: Duration::from_secs(5), + hit_wall: vec![ + projectile::Effect::Explode { power: 5.0 }, + projectile::Effect::Vanish, + ], + hit_entity: vec![ + projectile::Effect::Explode { power: 5.0 }, + projectile::Effect::Vanish, + ], + time_left: Duration::from_secs(20), owner: None, }, projectile_body: Body::Object(object::Body::BoltFire), diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 4c32bf0ee9..6f1982be33 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -6,6 +6,7 @@ use std::time::Duration; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum Effect { Damage(comp::HealthChange), + Explode { power: f32 }, Vanish, Stick, Possess, diff --git a/common/src/event.rs b/common/src/event.rs index 39e8a63e23..8192923c0c 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -73,7 +73,8 @@ pub enum LocalEvent { pub enum ServerEvent { Explosion { pos: Vec3, - radius: f32, + power: f32, + owner: Option, }, Damage { uid: Uid, diff --git a/common/src/states/cast_fireball.rs b/common/src/states/cast_fireball.rs new file mode 100644 index 0000000000..9887803309 --- /dev/null +++ b/common/src/states/cast_fireball.rs @@ -0,0 +1,81 @@ +use crate::{ + comp::{Body, CharacterState, Gravity, Projectile, StateUpdate}, + event::ServerEvent, + states::utils::*, + sys::character_behavior::*, +}; +use std::time::Duration; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Data { + /// How long we prepared the weapon already + pub prepare_timer: Duration, + /// How long the state has until exiting + pub recover_duration: Duration, + /// Projectile + pub projectile: Projectile, + /// Projectile + pub projectile_body: Body, + /// Whether the attack fired already + pub exhausted: bool, +} + +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + + handle_move(data, &mut update); + handle_jump(data, &mut update); + + if !self.exhausted + && (data.inputs.primary.is_pressed() | data.inputs.secondary.is_pressed()) + { + // Prepare (draw the bow) + update.character = CharacterState::CastFireball(Data { + prepare_timer: self.prepare_timer + Duration::from_secs_f32(data.dt.0), + recover_duration: self.recover_duration, + projectile: self.projectile.clone(), + projectile_body: self.projectile_body, + exhausted: false, + }); + } else if !self.exhausted { + // Fire + let mut projectile = self.projectile.clone(); + projectile.set_owner(*data.uid); + update.server_events.push_front(ServerEvent::Shoot { + entity: data.entity, + dir: data.inputs.look_dir, + body: self.projectile_body, + light: None, + projectile, + gravity: Some(Gravity(0.1)), + }); + + update.character = CharacterState::CastFireball(Data { + prepare_timer: self.prepare_timer, + recover_duration: self.recover_duration, + projectile: self.projectile.clone(), + projectile_body: self.projectile_body, + exhausted: true, + }); + } else if self.recover_duration != Duration::default() { + // Recovery + update.character = CharacterState::CastFireball(Data { + prepare_timer: self.prepare_timer, + recover_duration: self + .recover_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), + projectile: self.projectile.clone(), + projectile_body: self.projectile_body, + exhausted: true, + }); + return update; + } else { + // Done + update.character = CharacterState::Wielding; + } + + update + } +} diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 1dcf09c211..f249cc5638 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -2,6 +2,7 @@ pub mod basic_block; pub mod basic_melee; pub mod basic_ranged; pub mod boost; +pub mod cast_fireball; pub mod climb; pub mod dash_melee; pub mod equipping; diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index ebccef6258..8e9423510e 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -183,6 +183,7 @@ impl<'a> System<'a> for Sys { CharacterState::TripleStrike(data) => data.behavior(&j), CharacterState::BasicMelee(data) => data.behavior(&j), CharacterState::BasicRanged(data) => data.behavior(&j), + CharacterState::CastFireball(data) => data.behavior(&j), CharacterState::Boost(data) => data.behavior(&j), CharacterState::DashMelee(data) => data.behavior(&j), CharacterState::TimedCombo(data) => data.behavior(&j), diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index 168035a4ca..4a8b15dd7b 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{projectile, HealthSource, Ori, PhysicsState, Projectile, Vel}, + comp::{projectile, HealthSource, Ori, PhysicsState, Pos, Projectile, Vel}, event::{EventBus, ServerEvent}, state::DeltaTime, }; @@ -13,6 +13,7 @@ impl<'a> System<'a> for Sys { Entities<'a>, Read<'a, DeltaTime>, Read<'a, EventBus>, + ReadStorage<'a, Pos>, ReadStorage<'a, PhysicsState>, ReadStorage<'a, Vel>, WriteStorage<'a, Ori>, @@ -25,6 +26,7 @@ impl<'a> System<'a> for Sys { entities, dt, server_bus, + positions, physics_states, velocities, mut orientations, @@ -34,8 +36,9 @@ impl<'a> System<'a> for Sys { let mut server_emitter = server_bus.emitter(); // Attacks - for (entity, physics, ori, projectile) in ( + for (entity, pos, physics, ori, projectile) in ( &entities, + &positions, &physics_states, &mut orientations, &mut projectiles, @@ -46,6 +49,13 @@ impl<'a> System<'a> for Sys { if physics.on_ground { for effect in projectile.hit_ground.drain(..) { match effect { + projectile::Effect::Explode { power } => { + server_emitter.emit(ServerEvent::Explosion { + pos: pos.0, + power, + owner: projectile.owner, + }) + }, projectile::Effect::Vanish => server_emitter.emit(ServerEvent::Destroy { entity, cause: HealthSource::World, @@ -58,6 +68,13 @@ impl<'a> System<'a> for Sys { else if physics.on_wall.is_some() { for effect in projectile.hit_wall.drain(..) { match effect { + projectile::Effect::Explode { power } => { + server_emitter.emit(ServerEvent::Explosion { + pos: pos.0, + power, + owner: projectile.owner, + }) + }, projectile::Effect::Vanish => server_emitter.emit(ServerEvent::Destroy { entity, cause: HealthSource::World, @@ -73,6 +90,13 @@ impl<'a> System<'a> for Sys { projectile::Effect::Damage(change) => { server_emitter.emit(ServerEvent::Damage { uid: other, change }) }, + projectile::Effect::Explode { power } => { + server_emitter.emit(ServerEvent::Explosion { + pos: pos.0, + power, + owner: projectile.owner, + }) + }, projectile::Effect::Vanish => server_emitter.emit(ServerEvent::Destroy { entity, cause: HealthSource::World, diff --git a/server/src/cmd.rs b/server/src/cmd.rs index a53247706d..d8e0ac61fa 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -829,14 +829,18 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action: } fn handle_explosion(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) { - let radius = scan_fmt!(&args, action.arg_fmt, f32).unwrap_or(8.0); + let power = scan_fmt!(&args, action.arg_fmt, f32).unwrap_or(8.0); + let ecs = server.state.ecs(); match server.state.read_component_cloned::(entity) { - Some(pos) => server - .state - .ecs() - .read_resource::>() - .emit_now(ServerEvent::Explosion { pos: pos.0, radius }), + Some(pos) => { + ecs.read_resource::>() + .emit_now(ServerEvent::Explosion { + pos: pos.0, + power, + owner: ecs.read_storage::().get(entity).copied(), + }) + }, None => server.notify_client( entity, ServerMsg::private(String::from("You have no position!")), diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 8d9de9215c..1c22232a9f 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -9,8 +9,11 @@ use common::{ vol::{ReadVol, Vox}, }; use log::error; -use specs::{Entity as EcsEntity, WorldExt}; -use vek::Vec3; +use specs::{join::Join, Entity as EcsEntity, WorldExt}; +use vek::{Vec3, *}; + +const BLOCK_EFFICIENCY: f32 = 0.9; +const BLOCK_ANGLE: f32 = 180.0; pub fn handle_damage(server: &Server, uid: Uid, change: HealthChange) { let state = &server.state; @@ -189,7 +192,46 @@ pub fn handle_respawn(server: &Server, entity: EcsEntity) { } } -pub fn handle_explosion(server: &Server, pos: Vec3, radius: f32) { +pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Option) { + // Go through all other entities + let ecs = &server.state.ecs(); + for (b, uid_b, pos_b, ori_b, character_b, stats_b) in ( + &ecs.entities(), + &ecs.read_storage::(), + &ecs.read_storage::(), + &ecs.read_storage::(), + &ecs.read_storage::(), + &mut ecs.write_storage::(), + ) + .join() + { + // Check if it is a hit + if !stats_b.is_dead + // Spherical wedge shaped attack field + // RADIUS + && pos.distance_squared(pos_b.0) < 10_f32.powi(2) + { + // Weapon gives base damage + let mut dmg = power as u32 * 2; + + if rand::random() { + dmg += 1; + } + + // Block + if character_b.is_block() + && ori_b.0.angle_between(pos - pos_b.0) < BLOCK_ANGLE.to_radians() / 2.0 + { + dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as u32 + } + + stats_b.health.change_by(HealthChange { + amount: -(dmg as i32), + cause: HealthSource::Projectile { owner }, + }); + } + } + const RAYS: usize = 500; for _ in 0..RAYS { @@ -200,12 +242,11 @@ pub fn handle_explosion(server: &Server, pos: Vec3, radius: f32) { ) .normalized(); - let ecs = server.state.ecs(); let mut block_change = ecs.write_resource::(); let _ = ecs .read_resource::() - .ray(pos, pos + dir * radius) + .ray(pos, pos + dir * power) .until(|_| rand::random::() < 0.05) .for_each(|pos| block_change.set(pos, Block::empty())) .cast(); diff --git a/server/src/events/mod.rs b/server/src/events/mod.rs index d1a833cd79..22607c185a 100644 --- a/server/src/events/mod.rs +++ b/server/src/events/mod.rs @@ -45,7 +45,9 @@ impl Server { for event in events { match event { - ServerEvent::Explosion { pos, radius } => handle_explosion(&self, pos, radius), + ServerEvent::Explosion { pos, power, owner } => { + handle_explosion(&self, pos, power, owner) + }, ServerEvent::Shoot { entity, dir, From a5102832773ff422eea7882fd65bf0d988669ee1 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Sun, 22 Mar 2020 12:50:52 -0700 Subject: [PATCH 210/326] update triple_strike --- common/src/states/triple_strike.rs | 96 ++++++++++++++---------------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index d71d5355f9..a2a864e4ce 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -10,7 +10,6 @@ use vek::vec::{Vec2, Vec3}; const STAGE_DURATION: u64 = 600; const INITIAL_ACCEL: f32 = 200.0; -const SECONDARY_ACCEL: f32 = 100.0; const BASE_SPEED: f32 = 25.0; /// ### A sequence of 3 incrementally increasing attacks. /// @@ -57,15 +56,11 @@ impl CharacterBehavior for Data { initialized = true; } - if self.stage < 3 { - // Handling movement + // Handling movement + if self.stage == 0 { if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { let adjusted_accel = if data.physics.touch_entity.is_none() { - if self.stage == 0 { - INITIAL_ACCEL - } else { - SECONDARY_ACCEL - } + INITIAL_ACCEL } else { 0.0 }; @@ -82,58 +77,59 @@ impl CharacterBehavior for Data { } else { handle_orientation(data, &mut update, 10.0); } + } else { + handle_move(data, &mut update); + } - // Handling attacking - if stage_time_active > Duration::from_millis(STAGE_DURATION / 2) - && !self.stage_exhausted - { - // Try to deal damage in second half of stage - data.updater.insert(data.entity, Attacking { - base_damage: self.base_damage * (self.stage as u32 + 1), - max_angle: 180_f32.to_radians(), - applied: false, - hit_count: 0, - }); + // Handling attacking + if stage_time_active > Duration::from_millis(STAGE_DURATION / 2) && !self.stage_exhausted { + let dmg = match self.stage { + 1 => self.base_damage, + 2 => (self.base_damage as f32 * 1.5) as u32, + _ => self.base_damage / 2, + }; + // Try to deal damage in second half of stage + data.updater.insert(data.entity, Attacking { + base_damage: dmg, + max_angle: 180_f32.to_radians(), + applied: false, + hit_count: 0, + }); + + update.character = CharacterState::TripleStrike(Data { + base_damage: self.base_damage, + stage: self.stage, + stage_time_active, + stage_exhausted: true, + should_transition, + initialized, + }); + } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { + if should_transition { update.character = CharacterState::TripleStrike(Data { base_damage: self.base_damage, - stage: self.stage, - stage_time_active, - stage_exhausted: true, + stage: self.stage + 1, + stage_time_active: Duration::default(), + stage_exhausted: false, should_transition, initialized, }); - } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { - if should_transition { - update.character = CharacterState::TripleStrike(Data { - base_damage: self.base_damage, - stage: self.stage + 1, - stage_time_active: Duration::default(), - stage_exhausted: false, - should_transition, - initialized, - }); - } else { - // Done - update.character = CharacterState::Wielding; - // Make sure attack component is removed - data.updater.remove::(data.entity); - } } else { - update.character = CharacterState::TripleStrike(Data { - base_damage: self.base_damage, - stage: self.stage, - stage_time_active, - stage_exhausted: self.stage_exhausted, - should_transition, - initialized, - }); + // Done + update.character = CharacterState::Wielding; + // Make sure attack component is removed + data.updater.remove::(data.entity); } } else { - // Done - update.character = CharacterState::Wielding; - // Make sure attack component is removed - data.updater.remove::(data.entity); + update.character = CharacterState::TripleStrike(Data { + base_damage: self.base_damage, + stage: self.stage, + stage_time_active, + stage_exhausted: self.stage_exhausted, + should_transition, + initialized, + }); } // Grant energy on successful hit From 9cbbe0311f9afafa5faef733a2f4a6eb3cbb9528 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 22 Mar 2020 16:06:53 -0400 Subject: [PATCH 211/326] rewrote the whole stupid skeleton to work much smarter --- voxygen/src/anim/character/attack.rs | 69 ++-- voxygen/src/anim/character/charge.rs | 477 +++++++++++++++++++++--- voxygen/src/anim/character/climb.rs | 6 +- voxygen/src/anim/character/gliding.rs | 6 +- voxygen/src/anim/character/idle.rs | 6 +- voxygen/src/anim/character/idlewield.rs | 8 +- voxygen/src/anim/character/jump.rs | 6 +- voxygen/src/anim/character/mod.rs | 6 +- voxygen/src/anim/character/roll.rs | 6 +- voxygen/src/anim/character/run.rs | 6 +- voxygen/src/anim/character/shoot.rs | 18 +- voxygen/src/anim/character/sit.rs | 6 +- voxygen/src/anim/character/spin.rs | 14 +- voxygen/src/anim/character/stand.rs | 6 +- voxygen/src/anim/character/swim.rs | 6 +- voxygen/src/anim/character/wield.rs | 10 +- voxygen/src/scene/figure/mod.rs | 28 +- 17 files changed, 528 insertions(+), 156 deletions(-) diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index e78a317a70..736c595ae6 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -52,31 +52,28 @@ impl Animation for AttackAnimation { Some(ToolKind::Sword(_)) => { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * 0.8, - skeleton_attr.neck_height + 21.0, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 14.0, ); - next.head.ori = Quaternion::rotation_z(decel * 0.25) - * Quaternion::rotation_x(0.0 + decel * 0.1) - * Quaternion::rotation_y(decel * -0.1); + next.head.ori = Quaternion::rotation_z(slow * 0.08) + * Quaternion::rotation_x(0.0 + slow * 0.08) + * Quaternion::rotation_y(slow * -0.08); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * -0.2) - * Quaternion::rotation_x(0.0 + decel * -0.2) - * Quaternion::rotation_y(decel * 0.2); + next.chest.ori = Quaternion::rotation_z(slow * -0.2) + * Quaternion::rotation_x(0.0 + slow * -0.2) + * Quaternion::rotation_y(slow * 0.2); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.1) - * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = next.chest.ori * -0.2; next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.08) - * Quaternion::rotation_x(0.0 + decel * -0.08) - * Quaternion::rotation_y(decel * 0.08); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = next.chest.ori * -0.15; next.shorts.scale = Vec3::one(); + next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.04; @@ -106,7 +103,7 @@ impl Animation for AttackAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right + slowax * 2.0, -2.0 + skeleton_attr.neck_forward + slowax * -2.0, - skeleton_attr.neck_height + 20.0, + skeleton_attr.neck_height + 13.0, ); next.head.ori = Quaternion::rotation_z(slowax * 0.25) * Quaternion::rotation_x(0.0 + slowax * 0.2) @@ -119,16 +116,12 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(slowax * 0.2); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(slowax * 0.1) - * Quaternion::rotation_x(0.0 + slowax * 0.1) - * Quaternion::rotation_y(slowax * 0.1); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = next.chest.ori * -0.2; next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(slowax * 0.08) - * Quaternion::rotation_x(0.0 + slowax * 0.08) - * Quaternion::rotation_y(slowax * 0.08); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = next.chest.ori * -0.15; next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(-4.0, 3.0, 2.0); @@ -155,8 +148,6 @@ impl Animation for AttackAnimation { }, Some(ToolKind::Hammer(_)) => { next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); - - //0,1,5 next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.05; next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); @@ -170,7 +161,7 @@ impl Animation for AttackAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right + slower * 3.0, -2.0 + skeleton_attr.neck_forward + slower * -3.0, - skeleton_attr.neck_height + 19.0, + skeleton_attr.neck_height + 12.0, ); next.head.ori = Quaternion::rotation_z(slower * 0.25) * Quaternion::rotation_x(0.0 + slower * 0.2) @@ -183,16 +174,12 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(slower * 0.2); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(slower * 0.1) - * Quaternion::rotation_x(0.0 + slower * 0.1) - * Quaternion::rotation_y(slower * 0.1); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = next.chest.ori * -0.2; next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(slower * 0.08) - * Quaternion::rotation_x(0.0 + slower * 0.08) - * Quaternion::rotation_y(slower * 0.08); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = next.chest.ori * -0.15; next.shorts.scale = Vec3::one(); next.control.offset = Vec3::new(-6.0, 3.0, 8.0 + slower * 5.0); @@ -205,7 +192,7 @@ impl Animation for AttackAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward + decel * 0.8, - skeleton_attr.neck_height + 21.0, + skeleton_attr.neck_height + 14.0, ); next.head.ori = Quaternion::rotation_z(decel * 0.25) * Quaternion::rotation_x(0.0 + decel * 0.1) @@ -218,13 +205,13 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(decel * 0.2); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); next.belt.ori = Quaternion::rotation_z(decel * -0.1) * Quaternion::rotation_x(0.0 + decel * -0.1) * Quaternion::rotation_y(decel * 0.1); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); next.belt.ori = Quaternion::rotation_z(decel * -0.08) * Quaternion::rotation_x(0.0 + decel * -0.08) * Quaternion::rotation_y(decel * 0.08); @@ -305,8 +292,8 @@ impl Animation for AttackAnimation { -2.0 + skeleton_attr.neck_forward + decel * 0.8, skeleton_attr.neck_height + 21.0, ); - next.head.ori = Quaternion::rotation_z(decel * 0.25) - * Quaternion::rotation_x(0.0 + decel * 0.1) + next.head.ori = Quaternion::rotation_z(decel * -0.25) + * Quaternion::rotation_x(0.0 + decel * -0.1) * Quaternion::rotation_y(decel * -0.1); next.head.scale = Vec3::one() * skeleton_attr.head_scale; diff --git a/voxygen/src/anim/character/charge.rs b/voxygen/src/anim/character/charge.rs index fccf834c3e..fe13b51fe8 100644 --- a/voxygen/src/anim/character/charge.rs +++ b/voxygen/src/anim/character/charge.rs @@ -14,75 +14,455 @@ impl Animation for ChargeAnimation { fn update_skeleton( skeleton: &Self::Skeleton, - (_active_tool_kind, _global_time): Self::Dependency, + (active_tool_kind, _global_time): Self::Dependency, anim_time: f64, - _rate: &mut f32, + rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { + *rate = 1.0; let mut next = (*skeleton).clone(); - let wave_stop_quick = (anim_time as f32 * 8.0).min(PI / 2.0).sin(); + let lab = 1.0; + + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 15.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 15.0).sin()); + + let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); + let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); + let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); + let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin(); + + let slow = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 12.4).sin()); + let slower = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0).sin()); + let slowax = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()); + let constant = 8.0; let wave_cos = (((5.0) / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 2.4).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * constant as f32 * 1.5).sin()); - let wave_cos_dub = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 4.8).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * constant as f32 * 1.5).sin()); + next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, 5.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 19.0 + wave_cos * 2.0, ); - next.head.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 2.0); - next.chest.ori = Quaternion::rotation_x(-0.7) * Quaternion::rotation_z(-0.9); - next.chest.scale = Vec3::one(); + match active_tool_kind { + //TODO: Inventory + Some(ToolKind::Sword(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 12.0, + ); + next.head.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + wave_cos * 2.0); - next.belt.ori = Quaternion::rotation_x(-0.6) * Quaternion::rotation_z(-0.9); - next.belt.scale = Vec3::one(); + next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 2.0); + next.chest.ori = Quaternion::rotation_x(-0.7) * Quaternion::rotation_z(-0.9); + next.chest.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + wave_cos * 2.0); - next.shorts.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.9); - next.shorts.scale = Vec3::one(); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_x(0.1) * Quaternion::rotation_z(0.0); + next.belt.scale = Vec3::one(); - next.l_hand.offset = Vec3::new(-8.0, -7.5, 5.0); - next.l_hand.ori = Quaternion::rotation_z(0.5) - * Quaternion::rotation_x(wave_stop_quick * -1.5 + 0.5 + 1.57) - * Quaternion::rotation_y(-0.6); - next.l_hand.scale = Vec3::one() * 1.01; + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.0); + next.shorts.scale = Vec3::one(); - next.r_hand.offset = Vec3::new(-8.0, -8.0, 3.0); - next.r_hand.ori = Quaternion::rotation_z(0.5) - * Quaternion::rotation_x(wave_stop_quick * -1.5 + 0.5 + 1.57) - * Quaternion::rotation_y(-0.6); - next.r_hand.scale = Vec3::one() * 1.01; + next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, 0.0 + wave_cos * 1.0, 6.0 - wave_cos_dub * 0.7); - next.l_foot.ori = Quaternion::rotation_x(-0.0 - wave_cos * 0.8); - next.l_foot.scale = Vec3::one(); + next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 3.0); + next.control.ori = Quaternion::rotation_x(-1.2) + * Quaternion::rotation_y(slow * 1.5) + * Quaternion::rotation_z(1.4 + slow * 0.5); + next.control.scale = Vec3::one(); + next.l_foot.offset = Vec3::new(-3.4, foot * 3.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -0.6); + next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, 0.0 - wave_cos * 1.0, 6.0 - wave_cos_dub * 0.7); - next.r_foot.ori = Quaternion::rotation_x(-0.0 + wave_cos * 0.8); - next.r_foot.scale = Vec3::one(); + next.r_foot.offset = Vec3::new(3.4, foot * -3.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 0.6); + next.r_foot.scale = Vec3::one(); + }, + Some(ToolKind::Axe(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right + slowax * 2.0, + -2.0 + skeleton_attr.neck_forward + slowax * -2.0, + skeleton_attr.neck_height + 20.0, + ); + next.head.ori = Quaternion::rotation_z(slowax * 0.25) + * Quaternion::rotation_x(0.0 + slowax * 0.2) + * Quaternion::rotation_y(slowax * 0.2); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.main.offset = Vec3::new( - -8.0 + skeleton_attr.weapon_x, - 0.0 + skeleton_attr.weapon_y, - 5.0, - ); - next.main.ori = Quaternion::rotation_z(-0.0) - * Quaternion::rotation_x(wave_stop_quick * -1.5 + 0.7) - * Quaternion::rotation_y(-0.5); - next.main.scale = Vec3::one(); + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(slowax * 0.2) + * Quaternion::rotation_x(0.0 + slowax * 0.2) + * Quaternion::rotation_y(slowax * 0.2); + next.chest.scale = Vec3::one(); + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(slowax * 0.1) + * Quaternion::rotation_x(0.0 + slowax * 0.1) + * Quaternion::rotation_y(slowax * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(slowax * 0.08) + * Quaternion::rotation_x(0.0 + slowax * 0.08) + * Quaternion::rotation_y(slowax * 0.08); + next.shorts.scale = Vec3::one(); + + next.l_hand.offset = Vec3::new(-4.0, 3.0, 2.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(-2.5, 9.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(-6.0, 10.0, -5.0); + next.main.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(-0.8); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(0.0, 0.0 + slowax * 8.2, 6.0); + next.control.ori = Quaternion::rotation_x(0.8) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(-0.7 + slowax * -1.9); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Hammer(_)) => { + next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); + + //0,1,5 + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right + slower * 3.0, + -2.0 + skeleton_attr.neck_forward + slower * -3.0, + skeleton_attr.neck_height + 19.0, + ); + next.head.ori = Quaternion::rotation_z(slower * 0.25) + * Quaternion::rotation_x(0.0 + slower * 0.2) + * Quaternion::rotation_y(slower * 0.2); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(slower * 0.2) + * Quaternion::rotation_x(0.0 + slower * 0.2) + * Quaternion::rotation_y(slower * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(slower * 0.1) + * Quaternion::rotation_x(0.0 + slower * 0.1) + * Quaternion::rotation_y(slower * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(slower * 0.08) + * Quaternion::rotation_x(0.0 + slower * 0.08) + * Quaternion::rotation_y(slower * 0.08); + next.shorts.scale = Vec3::one(); + + next.control.offset = Vec3::new(-6.0, 3.0, 8.0 + slower * 5.0); + next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(1.4 + 1.57); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Staff(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); + next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(0.0, 0.0, 10.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -4.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); + next.control.ori = Quaternion::rotation_x(-1.2) + * Quaternion::rotation_y(slow * 1.5) + * Quaternion::rotation_z(1.4 + slow * 0.5); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Shield(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Bow(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); + next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); + next.l_hand.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(3.0, -1.0, -6.0); + next.r_hand.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(3.0, 2.0, -13.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.3) + * Quaternion::rotation_z(-0.6); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Dagger(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Debug(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward + decel * 0.8, + skeleton_attr.neck_height + 21.0, + ); + next.head.ori = Quaternion::rotation_z(decel * 0.25) + * Quaternion::rotation_x(0.0 + decel * 0.1) + * Quaternion::rotation_y(decel * -0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(decel * -0.2) + * Quaternion::rotation_x(0.0 + decel * -0.2) + * Quaternion::rotation_y(decel * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, 5.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.1) + * Quaternion::rotation_x(0.0 + decel * -0.1) + * Quaternion::rotation_y(decel * 0.1); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); + next.belt.ori = Quaternion::rotation_z(decel * -0.08) + * Quaternion::rotation_x(0.0 + decel * -0.08) + * Quaternion::rotation_y(decel * 0.08); + next.shorts.scale = Vec3::one(); + next.l_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); + next.l_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.l_hand.scale = Vec3::one() * 1.01; + + next.r_hand.offset = + Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.r_hand.scale = Vec3::one() * 1.01; + + next.main.offset = Vec3::new( + -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, + 8.0 + accel_fast * 3.0, + 0.0, + ); + next.main.ori = Quaternion::rotation_z(-0.8) + * Quaternion::rotation_x(0.0 + accel_med * -0.8) + * Quaternion::rotation_y(0.0 + accel_med * -0.4); + next.main.scale = Vec3::one(); + }, + _ => {}, + } next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); next.l_shoulder.ori = Quaternion::rotation_x(0.0); next.l_shoulder.scale = Vec3::one() * 1.1; @@ -104,10 +484,13 @@ impl Animation for ChargeAnimation { Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - next.control.offset = Vec3::new(0.0, 0.0, 0.0); - next.control.ori = Quaternion::rotation_x(0.0); - next.control.scale = Vec3::one(); + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); next } } diff --git a/voxygen/src/anim/character/climb.rs b/voxygen/src/anim/character/climb.rs index 8cb25ce70c..67fa4b810c 100644 --- a/voxygen/src/anim/character/climb.rs +++ b/voxygen/src/anim/character/climb.rs @@ -36,7 +36,7 @@ impl Animation for ClimbAnimation { next.head.offset = Vec3::new( 0.0, -1.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 18.5 + wave_cos * 1.3, + skeleton_attr.neck_height + 11.5 + wave_cos * 1.3, ); next.head.ori = Quaternion::rotation_z(wave * 0.1) * Quaternion::rotation_x(0.6) @@ -49,11 +49,11 @@ impl Animation for ClimbAnimation { * Quaternion::rotation_y(wave_test * -0.12); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 1.0, 3.5 + wave_cos * 1.1); + next.belt.offset = Vec3::new(0.0, 1.0, -3.5 + wave_cos * 1.1); next.belt.ori = Quaternion::rotation_z(wave_test * 0.25) * Quaternion::rotation_x(0.0); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 1.0, 1.0 + wave_cos * 1.1); + next.shorts.offset = Vec3::new(0.0, 1.0, -6.0 + wave_cos * 1.1); next.shorts.ori = Quaternion::rotation_z(wave_test * 0.25) * Quaternion::rotation_x(0.1) * Quaternion::rotation_y(wave_test * 0.10); diff --git a/voxygen/src/anim/character/gliding.rs b/voxygen/src/anim/character/gliding.rs index ab25059863..d58f0a1b5a 100644 --- a/voxygen/src/anim/character/gliding.rs +++ b/voxygen/src/anim/character/gliding.rs @@ -68,12 +68,12 @@ impl Animation for GlidingAnimation { next.chest.ori = Quaternion::rotation_z(wave_very_slow_cos * 0.2); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, -4.0); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); next.belt.ori = Quaternion::rotation_z(wave_very_slow_cos * 0.25); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, -7.0); - next.shorts.ori = Quaternion::rotation_z(wave_very_slow_cos * 0.25); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(wave_very_slow_cos * 0.35); next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new( diff --git a/voxygen/src/anim/character/idle.rs b/voxygen/src/anim/character/idle.rs index 57949cb125..810fe88151 100644 --- a/voxygen/src/anim/character/idle.rs +++ b/voxygen/src/anim/character/idle.rs @@ -36,7 +36,7 @@ impl Animation for IdleAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 21.0 + wave_ultra_slow * 0.1, + skeleton_attr.neck_height + 14.0 + wave_ultra_slow * 0.1, ); /*next.head.ori = Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs());*/ @@ -47,11 +47,11 @@ impl Animation for IdleAnimation { next.chest.ori = Quaternion::rotation_x(0.0); next.chest.scale = Vec3::one() + wave_ultra_slow_abs * 0.05; - next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + wave_ultra_slow * 0.1); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0 + wave_ultra_slow * 0.1); next.belt.ori = Quaternion::rotation_x(0.0); next.belt.scale = Vec3::one() + wave_ultra_slow_abs * 0.05; - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + wave_ultra_slow * 0.1); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0 + wave_ultra_slow * 0.1); next.shorts.ori = Quaternion::rotation_x(0.0); next.shorts.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/idlewield.rs b/voxygen/src/anim/character/idlewield.rs index 85e97f3794..2b7a9df755 100644 --- a/voxygen/src/anim/character/idlewield.rs +++ b/voxygen/src/anim/character/idlewield.rs @@ -201,9 +201,9 @@ impl Animation for IdleWieldAnimation { * 0.1, ); next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right + wave_slow_cos * 0.5, + 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 21.0 + wave_ultra_slow * 0.6, + skeleton_attr.neck_height + 14.0 + wave_ultra_slow * 0.1, ); next.head.ori = Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); @@ -214,12 +214,12 @@ impl Animation for IdleWieldAnimation { Quaternion::rotation_y(wave_ultra_slow_cos * 0.04) * Quaternion::rotation_z(0.15); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 5.0 + wave_ultra_slow * 0.5); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); next.belt.ori = Quaternion::rotation_y(wave_ultra_slow_cos * 0.03) * Quaternion::rotation_z(0.22); next.belt.scale = Vec3::one() * 1.02; - next.shorts.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 2.0 + wave_ultra_slow * 0.5); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); next.shorts.ori = Quaternion::rotation_z(0.3); next.shorts.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/jump.rs b/voxygen/src/anim/character/jump.rs index a06bad0f04..926adfee7a 100644 --- a/voxygen/src/anim/character/jump.rs +++ b/voxygen/src/anim/character/jump.rs @@ -25,7 +25,7 @@ impl Animation for JumpAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 21.0, + skeleton_attr.neck_height + 14.0, ); next.head.ori = Quaternion::rotation_x(0.25 + wave_stop * 0.1 + wave_slow * 0.04); next.head.scale = Vec3::one() * skeleton_attr.head_scale; @@ -34,11 +34,11 @@ impl Animation for JumpAnimation { next.chest.ori = Quaternion::rotation_z(0.0); next.chest.scale = Vec3::one() * 1.01; - next.belt.offset = Vec3::new(0.0, 0.0, 6.0); + next.belt.offset = Vec3::new(0.0, 0.0, -1.0); next.belt.ori = Quaternion::rotation_z(0.0); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 3.0); + next.shorts.offset = Vec3::new(0.0, 0.0, -4.0); next.shorts.ori = Quaternion::rotation_z(0.0); next.shorts.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 6f1cd2978d..29827d9620 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -73,10 +73,10 @@ impl Skeleton for CharacterSkeleton { let head_mat = self.head.compute_base_matrix(); [ - FigureBoneData::new(torso_mat * head_mat), + FigureBoneData::new(torso_mat * chest_mat * head_mat), FigureBoneData::new(torso_mat * chest_mat), - FigureBoneData::new(torso_mat * self.belt.compute_base_matrix()), - FigureBoneData::new(torso_mat * self.shorts.compute_base_matrix()), + FigureBoneData::new(torso_mat * chest_mat * self.belt.compute_base_matrix()), + FigureBoneData::new(torso_mat * chest_mat * self.shorts.compute_base_matrix()), FigureBoneData::new(torso_mat * chest_mat * control_mat * l_control_mat * l_hand_mat), FigureBoneData::new(torso_mat * chest_mat * control_mat * r_control_mat * r_hand_mat), FigureBoneData::new(torso_mat * self.l_foot.compute_base_matrix()), diff --git a/voxygen/src/anim/character/roll.rs b/voxygen/src/anim/character/roll.rs index 734f83ecd4..2357bfd180 100644 --- a/voxygen/src/anim/character/roll.rs +++ b/voxygen/src/anim/character/roll.rs @@ -42,7 +42,7 @@ impl Animation for RollAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 17.0 + wave_dub * -8.0, + skeleton_attr.neck_height + 12.0 + wave_dub * -8.0, ); next.head.ori = Quaternion::rotation_x(wave_dub * 0.4); next.head.scale = Vec3::one(); @@ -51,11 +51,11 @@ impl Animation for RollAnimation { next.chest.ori = Quaternion::rotation_x(wave_dub * 0.4); next.chest.scale = Vec3::one() * 1.01; - next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + wave_dub * -3.0); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0 + wave_dub * -3.0); next.belt.ori = Quaternion::rotation_x(0.0 + wave_dub * 0.4); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + wave_dub * -2.0); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0 + wave_dub * -2.0); next.shorts.ori = Quaternion::rotation_x(0.0 + wave_dub * 0.4); next.shorts.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index 35ad488bdb..93cfce5321 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -76,7 +76,7 @@ impl Animation for RunAnimation { next.head.offset = Vec3::new( 0.0, -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 20.0 + short * 1.3, + skeleton_attr.neck_height + 13.0 + short * 0.3, ); next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1) * Quaternion::rotation_x(head_look.y + 0.35); @@ -86,11 +86,11 @@ impl Animation for RunAnimation { next.chest.ori = Quaternion::rotation_z(short * 0.2); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + short * 1.1); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); next.belt.ori = Quaternion::rotation_z(short * 0.35); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + short * 1.1); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); next.shorts.ori = Quaternion::rotation_z(short * 0.6); next.shorts.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/shoot.rs b/voxygen/src/anim/character/shoot.rs index acf28482ff..2dabf92d94 100644 --- a/voxygen/src/anim/character/shoot.rs +++ b/voxygen/src/anim/character/shoot.rs @@ -46,8 +46,8 @@ impl Animation for ShootAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward - quick * 3.5, - skeleton_attr.neck_height + 21.0, + -2.0 + skeleton_attr.neck_forward - quick * 1.5, + skeleton_attr.neck_height + 14.0, ); next.head.ori = Quaternion::rotation_z(quick * 0.15) * Quaternion::rotation_x(quick * 0.09) @@ -55,21 +55,17 @@ impl Animation for ShootAnimation { next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0 - quick * 1.5, 7.0); - next.chest.ori = Quaternion::rotation_z(quick * 0.15) + next.chest.ori = Quaternion::rotation_z(quick * 0.35) * Quaternion::rotation_x(quick * 0.09) * Quaternion::rotation_y(0.0); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0 - quick * 1.0, 5.0); - next.belt.ori = Quaternion::rotation_z(quick * 0.2) - * Quaternion::rotation_x(quick * 0.12) - * Quaternion::rotation_y(0.0); + next.belt.offset = Vec3::new(0.0, 0.0 + quick * 1.0, -2.0); + next.belt.ori = next.chest.ori; next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, -quick * 0.5, 2.0); - next.shorts.ori = Quaternion::rotation_z(quick * 0.08) - * Quaternion::rotation_x(quick * 0.05) - * Quaternion::rotation_y(0.0); + next.shorts.offset = Vec3::new(0.0, quick * 1.0, -5.0); + next.shorts.ori = next.chest.ori; next.shorts.scale = Vec3::one(); match active_tool_kind { diff --git a/voxygen/src/anim/character/sit.rs b/voxygen/src/anim/character/sit.rs index c777bd71a3..0a4cad45ae 100644 --- a/voxygen/src/anim/character/sit.rs +++ b/voxygen/src/anim/character/sit.rs @@ -40,7 +40,7 @@ impl Animation for SitAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, wave_stop * -3.6 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 21.0 + wave_slow * 0.1 + wave_stop * -0.8, + skeleton_attr.neck_height + 14.0 + wave_slow * 0.1 + wave_stop * -0.8, ); next.head.ori = Quaternion::rotation_z(head_look.x + wave_ultra_slow * 0.2 - wave_slow * 0.1) @@ -57,11 +57,11 @@ impl Animation for SitAnimation { next.chest.ori = Quaternion::rotation_x(wave_stop * 0.15); next.chest.scale = Vec3::one() + wave_slow_abs * 0.05; - next.belt.offset = Vec3::new(0.0, wave_stop * 1.2, 5.0); + next.belt.offset = Vec3::new(0.0, wave_stop * 1.2, -2.0); next.belt.ori = Quaternion::rotation_x(wave_stop * 0.3); next.belt.scale = (Vec3::one() + wave_slow_abs * 0.05) * 1.02; - next.shorts.offset = Vec3::new(0.0, wave_stop * 2.5, 2.0 + wave_stop * 0.6); + next.shorts.offset = Vec3::new(0.0, wave_stop * 2.5, -5.0 + wave_stop * 0.6); next.shorts.ori = Quaternion::rotation_x(wave_stop * 0.6); next.shorts.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/spin.rs b/voxygen/src/anim/character/spin.rs index 2f655ae173..329d51dd41 100644 --- a/voxygen/src/anim/character/spin.rs +++ b/voxygen/src/anim/character/spin.rs @@ -69,7 +69,7 @@ impl Animation for SpinAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward + decel * -0.8, - skeleton_attr.neck_height + 21.0, + skeleton_attr.neck_height + 14.0, ); next.head.ori = Quaternion::rotation_z(decel * -0.25) * Quaternion::rotation_x(0.0 + decel * -0.1) @@ -81,16 +81,12 @@ impl Animation for SpinAnimation { * Quaternion::rotation_y(decel * -0.2); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(decel * 0.1) - * Quaternion::rotation_x(0.0 + decel * 0.1) - * Quaternion::rotation_y(decel * -0.1); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = next.chest.ori * -0.1; next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(decel * 0.08) - * Quaternion::rotation_x(0.0 + decel * 0.08) - * Quaternion::rotation_y(decel * -0.08); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.belt.ori = next.chest.ori * -0.08; next.shorts.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_z((spin * 7.0).max(0.3)) diff --git a/voxygen/src/anim/character/stand.rs b/voxygen/src/anim/character/stand.rs index ab2d67fea7..4528ad2b87 100644 --- a/voxygen/src/anim/character/stand.rs +++ b/voxygen/src/anim/character/stand.rs @@ -36,7 +36,7 @@ impl Animation for StandAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 21.0 + slow * 0.3, + skeleton_attr.neck_height + 14.0 + slow * 0.3, //21 ); next.head.ori = Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); @@ -46,11 +46,11 @@ impl Animation for StandAnimation { next.chest.ori = Quaternion::rotation_z(head_look.x * 0.6); next.chest.scale = Vec3::one() * 1.01; - next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + slow * 0.3); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0 + slow * 0.3); //5 next.belt.ori = Quaternion::rotation_z(head_look.x * 0.4); next.belt.scale = Vec3::one() + breathe * 0.05; - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + slow * 0.3); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0 + slow * 0.3); //2 next.shorts.ori = Quaternion::rotation_x(0.0); next.shorts.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/swim.rs b/voxygen/src/anim/character/swim.rs index eae0613728..001717afe3 100644 --- a/voxygen/src/anim/character/swim.rs +++ b/voxygen/src/anim/character/swim.rs @@ -53,7 +53,7 @@ impl Animation for SwimAnimation { next.head.offset = Vec3::new( 0.0, -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 21.0 + wave_cos * 1.3, + skeleton_attr.neck_height + 14.0 + wave_cos * 1.3, ); next.head.ori = Quaternion::rotation_z(head_look.x + wave * 0.1) * Quaternion::rotation_x(head_look.y + 0.35); @@ -63,11 +63,11 @@ impl Animation for SwimAnimation { next.chest.ori = Quaternion::rotation_z(wave * 0.2); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + wave_cos * 1.1); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0 + wave_cos * 1.1); next.belt.ori = Quaternion::rotation_z(wave * 0.35); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + wave_cos * 1.1); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0 + wave_cos * 1.1); next.shorts.ori = Quaternion::rotation_z(wave * 0.6); next.shorts.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index a8a53bd307..55c9db2257 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -214,7 +214,7 @@ impl Animation for WieldAnimation { next.head.offset = Vec3::new( 0.0, -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 22.0 + short * 1.3, + skeleton_attr.neck_height + 13.0 + short * 0.2, ); next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1) * Quaternion::rotation_x(head_look.y + 0.35); @@ -224,12 +224,12 @@ impl Animation for WieldAnimation { next.chest.ori = Quaternion::rotation_z(short * 0.2); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, 7.0 + short * 1.1); - next.belt.ori = Quaternion::rotation_z(short * 0.35); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_z(short * 0.15); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 4.0 + short * 1.1); - next.shorts.ori = Quaternion::rotation_z(short * 0.6); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(short * 0.4); next.shorts.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 219aeeb484..2579efcc9c 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -498,7 +498,7 @@ impl FigureMgr { ) }, CharacterState::DashMelee(_) => { - anim::character::AttackAnimation::update_skeleton( + anim::character::ChargeAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.state_time, @@ -507,7 +507,7 @@ impl FigureMgr { ) }, CharacterState::TripleStrike(s) => match s.stage { - 0 => anim::character::ChargeAnimation::update_skeleton( + 0 => anim::character::AttackAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.state_time, @@ -565,13 +565,23 @@ impl FigureMgr { ) }*/ CharacterState::Equipping { .. } => { - anim::character::WieldAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) + if vel.0.magnitude_squared() > 0.5 { + anim::character::WieldAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } else { + anim::character::IdleWieldAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } }, CharacterState::Wielding { .. } => { if vel.0.magnitude_squared() > 0.5 { From 0358caa1735c7a3b4b644d5fa58b48b6fd22151f Mon Sep 17 00:00:00 2001 From: Capucho Date: Sun, 22 Mar 2020 22:06:05 +0000 Subject: [PATCH 212/326] Fix the wrong logs directory being displayed on panic --- voxygen/src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index d461267ecf..43b6726ab6 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -133,7 +133,9 @@ fn main() { Panic Payload: {:?}\n\ PanicInfo: {}\n\ Game version: {} [{}]", - Settings::get_settings_path() + Settings::load() + .log + .logs_path .join("voxygen-.log") .display(), reason, From eddf3ec658fbf6f7691c886e712090b56e4b5ff6 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 22 Mar 2020 21:32:34 -0400 Subject: [PATCH 213/326] raised run anim speed 20% --- voxygen/src/anim/character/run.rs | 32 ++++++++++++++--------------- voxygen/src/anim/character/wield.rs | 14 ++++++------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index 93cfce5321..e1e60cc790 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -23,26 +23,26 @@ impl Animation for RunAnimation { let lab = 1.0; let long = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.66).sin()).powf(2.0 as f32))) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.8).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 0.66).sin()); + * ((anim_time as f32 * lab as f32 * 0.8).sin()); let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.32).sin()).powf(2.0 as f32))) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.32).sin()); + * ((anim_time as f32 * lab as f32 * 1.6).sin()); let shortalt = (((5.0) / (1.5 + 3.5 - * ((anim_time as f32 * lab as f32 * 1.32 + PI / 2.0).sin()).powf(2.0 as f32))) + * ((anim_time as f32 * lab as f32 * 1.6 + PI / 2.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.32 + PI / 2.0).sin()); + * ((anim_time as f32 * lab as f32 * 1.6 + PI / 2.0).sin()); let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.32).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.32).sin()); + * ((anim_time as f32 * lab as f32 * 1.6).sin()); let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0 / 2.0).sin(); @@ -78,26 +78,26 @@ impl Animation for RunAnimation { -3.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 13.0 + short * 0.3, ); - next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1) + next.head.ori = Quaternion::rotation_z(head_look.x + long * -0.1 - short * 0.3) * Quaternion::rotation_x(head_look.y + 0.35); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + short * 1.1); - next.chest.ori = Quaternion::rotation_z(short * 0.2); + next.chest.ori = Quaternion::rotation_z(short * 0.3); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = Quaternion::rotation_z(short * 0.35); + next.belt.ori = Quaternion::rotation_z(short * 0.25); next.belt.scale = Vec3::one(); next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(short * 0.6); + next.shorts.ori = Quaternion::rotation_z(short * 0.4); next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new( -6.0 + wave_stop * -1.0, - -0.25 + short * 2.0, - 5.0 + short * -1.5, + -0.25 + short * 3.0, + 4.0 + short * -1.5, ); next.l_hand.ori = Quaternion::rotation_x(0.8 + short * 1.2) * Quaternion::rotation_y(wave_stop * 0.1); @@ -105,8 +105,8 @@ impl Animation for RunAnimation { next.r_hand.offset = Vec3::new( 6.0 + wave_stop * 1.0, - -0.25 + short * -2.0, - 5.0 + short * 1.5, + -0.25 + short * -3.0, + 4.0 + short * 1.5, ); next.r_hand.ori = Quaternion::rotation_x(0.8 + short * -1.2) * Quaternion::rotation_y(wave_stop * -0.1); diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 55c9db2257..b6955c0eb9 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -21,19 +21,19 @@ impl Animation for WieldAnimation { let lab = 1.0; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.32).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.32).sin()); + * ((anim_time as f32 * lab as f32 * 1.6).sin()); let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.32).sin()).powf(2.0 as f32))) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.32).sin()); + * ((anim_time as f32 * lab as f32 * 1.6).sin()); let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); let long = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.66).sin()).powf(2.0 as f32))) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.8).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 0.66).sin()); + * ((anim_time as f32 * lab as f32 * 0.8).sin()); let wave = (anim_time as f32 * 1.0).sin(); match active_tool_kind { //TODO: Inventory @@ -216,7 +216,7 @@ impl Animation for WieldAnimation { -3.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 13.0 + short * 0.2, ); - next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1) + next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1 - short * 0.2) * Quaternion::rotation_x(head_look.y + 0.35); next.head.scale = Vec3::one() * skeleton_attr.head_scale; From 5194cef03a7655b9351edd1227afb7a3f1b67046 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 23 Mar 2020 12:50:08 +0100 Subject: [PATCH 214/326] Easier swimming, better damage calculation for explosions --- common/src/comp/character_state.rs | 1 + common/src/states/basic_melee.rs | 1 + common/src/states/dash_melee.rs | 3 +++ common/src/states/timed_combo.rs | 1 + common/src/states/triple_strike.rs | 1 + common/src/states/utils.rs | 5 ++--- common/src/sys/combat.rs | 2 +- server/src/events/entity_manipulation.rs | 6 ++++-- 8 files changed, 14 insertions(+), 6 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 0fe75fbf4c..efb5e01d33 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -132,6 +132,7 @@ impl Component for CharacterState { #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Attacking { pub base_damage: u32, + pub range: f32, pub max_angle: f32, pub applied: bool, pub hit_count: u32, diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 01778be4f4..f05e638912 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -44,6 +44,7 @@ impl CharacterBehavior for Data { // Hit attempt data.updater.insert(data.entity, Attacking { base_damage: self.base_damage, + range: self.range, max_angle: self.max_angle.to_radians(), applied: false, hit_count: 0, diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 22223a66fa..5d1d462a2c 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -1,5 +1,6 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, StateUpdate}, + states::utils::*, sys::character_behavior::*, util::safe_slerp, }; @@ -53,6 +54,7 @@ impl CharacterBehavior for Data { // Hit attempt data.updater.insert(data.entity, Attacking { base_damage: self.base_damage, + range: 3.5, max_angle: 180_f32.to_radians(), applied: false, hit_count: 0, @@ -67,6 +69,7 @@ impl CharacterBehavior for Data { }); } else if self.recover_duration != Duration::default() { // Recovery + handle_move(data, &mut update); update.character = CharacterState::DashMelee(Data { buildup_duration: self.buildup_duration, recover_duration: self diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index 0883f9c77a..ec50a25d2f 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -53,6 +53,7 @@ impl CharacterBehavior for Data { // Swing hits data.updater.insert(data.entity, Attacking { base_damage: self.base_damage * (self.stage as u32 + 1), + range: 3.5, max_angle: 75_f32.to_radians(), applied: false, hit_count: 0, diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index a2a864e4ce..f6b6ccebe6 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -92,6 +92,7 @@ impl CharacterBehavior for Data { // Try to deal damage in second half of stage data.updater.insert(data.entity, Attacking { base_damage: dmg, + range: 3.5, max_angle: 180_f32.to_radians(), applied: false, hit_count: 0, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index e79c1c186a..c2f35c222a 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -82,9 +82,8 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { handle_orientation(data, update, if data.physics.on_ground { 9.0 } else { 2.0 }); - // Force players to pulse jump button to swim up - if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600)) - { + // Swim + if data.inputs.jump.is_pressed() { update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 2.25).min(BASE_HUMANOID_WATER_SPEED); } diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 18bb3eb9fd..d8a9f2f467 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -97,7 +97,7 @@ impl<'a> System<'a> for Sys { if entity != b && !stats_b.is_dead // Spherical wedge shaped attack field - && pos.0.distance_squared(pos_b.0) < (rad_b + scale * ATTACK_RANGE).powi(2) + && pos.0.distance_squared(pos_b.0) < (rad_b + scale * attack.range).powi(2) && ori2.angle_between(pos_b2 - pos2) < attack.max_angle + (rad_b / pos2.distance(pos_b2)).atan() { // Weapon gives base damage diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 1c22232a9f..ab61740264 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -194,6 +194,7 @@ pub fn handle_respawn(server: &Server, entity: EcsEntity) { pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Option) { // Go through all other entities + let hit_range = 2.0 * power; let ecs = &server.state.ecs(); for (b, uid_b, pos_b, ori_b, character_b, stats_b) in ( &ecs.entities(), @@ -205,14 +206,15 @@ pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Opti ) .join() { + let distance_squared = pos.distance_squared(pos_b.0); // Check if it is a hit if !stats_b.is_dead // Spherical wedge shaped attack field // RADIUS - && pos.distance_squared(pos_b.0) < 10_f32.powi(2) + && distance_squared < hit_range.powi(2) { // Weapon gives base damage - let mut dmg = power as u32 * 2; + let mut dmg = ((1.0 - distance_squared / hit_range.powi(2)) * power * 5.0) as u32; if rand::random() { dmg += 1; From 0eebf945fef2a24f696e63869e37535d7c7e764d Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 23 Mar 2020 13:55:52 +0100 Subject: [PATCH 215/326] Glowing fireballs, no gravity --- common/src/comp/inventory/item.rs | 6 +++--- common/src/states/cast_fireball.rs | 9 ++++++--- common/src/states/utils.rs | 1 - common/src/sys/combat.rs | 2 -- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index ed82aa1039..0af04fcd93 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -123,15 +123,15 @@ impl ToolData { CastFireball { projectile: Projectile { hit_ground: vec![ - projectile::Effect::Explode { power: 5.0 }, + projectile::Effect::Explode { power: 1.5 }, projectile::Effect::Vanish, ], hit_wall: vec![ - projectile::Effect::Explode { power: 5.0 }, + projectile::Effect::Explode { power: 1.5 }, projectile::Effect::Vanish, ], hit_entity: vec![ - projectile::Effect::Explode { power: 5.0 }, + projectile::Effect::Explode { power: 1.5 }, projectile::Effect::Vanish, ], time_left: Duration::from_secs(20), diff --git a/common/src/states/cast_fireball.rs b/common/src/states/cast_fireball.rs index 9887803309..911562be72 100644 --- a/common/src/states/cast_fireball.rs +++ b/common/src/states/cast_fireball.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{Body, CharacterState, Gravity, Projectile, StateUpdate}, + comp::{Body, CharacterState, LightEmitter, Projectile, StateUpdate}, event::ServerEvent, states::utils::*, sys::character_behavior::*, @@ -46,9 +46,12 @@ impl CharacterBehavior for Data { entity: data.entity, dir: data.inputs.look_dir, body: self.projectile_body, - light: None, + light: Some(LightEmitter { + col: (0.0, 1.0, 0.3).into(), + ..Default::default() + }), projectile, - gravity: Some(Gravity(0.1)), + gravity: None, }); update.character = CharacterState::CastFireball(Data { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index c2f35c222a..a1747d017a 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -5,7 +5,6 @@ use crate::{ sys::{character_behavior::JoinData, phys::GRAVITY}, util::safe_slerp, }; -use std::time::Duration; use vek::vec::Vec2; pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index d8a9f2f467..9ddb10e45f 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -10,8 +10,6 @@ use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; use vek::*; const BLOCK_EFFICIENCY: f32 = 0.9; - -const ATTACK_RANGE: f32 = 3.5; const BLOCK_ANGLE: f32 = 180.0; /// This system is responsible for handling accepted inputs like moving or From c01cd62f5fa0b1843d4136677ae62daaf774dead Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 23 Mar 2020 14:18:05 +0100 Subject: [PATCH 216/326] Move meta.dat to ron, so we don't create memory allocation errors --- voxygen/src/meta.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/voxygen/src/meta.rs b/voxygen/src/meta.rs index 9e4cf29ac3..af884eee76 100644 --- a/voxygen/src/meta.rs +++ b/voxygen/src/meta.rs @@ -2,7 +2,7 @@ use common::comp; use directories::ProjectDirs; use log::warn; use serde_derive::{Deserialize, Serialize}; -use std::{fs, io, path::PathBuf}; +use std::{fs, io::Write, path::PathBuf}; #[derive(Clone, Debug, Serialize, Deserialize)] #[repr(C)] @@ -38,14 +38,14 @@ impl Meta { let path = Self::get_meta_path(); if let Ok(file) = fs::File::open(&path) { - match bincode::deserialize_from(file) { + match ron::de::from_reader(file) { Ok(s) => return s, Err(e) => { log::warn!("Failed to parse meta file! Fallback to default. {}", e); // Rename the corrupted settings file let mut new_path = path.to_owned(); new_path.pop(); - new_path.push("meta.invalid.dat"); + new_path.push("meta.invalid.ron"); if let Err(err) = std::fs::rename(path, new_path) { log::warn!("Failed to rename meta file. {}", err); } @@ -71,14 +71,16 @@ impl Meta { if let Some(dir) = path.parent() { fs::create_dir_all(dir)?; } - bincode::serialize_into(fs::File::create(path)?, self) - .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; + let mut meta_file = fs::File::create(path)?; + + let s: &str = &ron::ser::to_string_pretty(self, ron::ser::PrettyConfig::default()).unwrap(); + meta_file.write_all(s.as_bytes()).unwrap(); Ok(()) } pub fn get_meta_path() -> PathBuf { if let Some(val) = std::env::var_os("VOXYGEN_CONFIG") { - let meta = PathBuf::from(val).join("meta.dat"); + let meta = PathBuf::from(val).join("meta.ron"); if meta.exists() || meta.parent().map(|x| x.exists()).unwrap_or(false) { return meta; } @@ -87,6 +89,6 @@ impl Meta { let proj_dirs = ProjectDirs::from("net", "veloren", "voxygen") .expect("System's $HOME directory path not found!"); - proj_dirs.config_dir().join("meta").with_extension("dat") + proj_dirs.config_dir().join("meta").with_extension("ron") } } From 9d47fd8c3ea440d849f22b616752dcec9f8be37e Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 23 Mar 2020 18:13:14 +0100 Subject: [PATCH 217/326] Better explosions --- server/src/events/entity_manipulation.rs | 40 ++++++++++++++++++++---- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index ab61740264..4d17cc6b5c 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -10,7 +10,7 @@ use common::{ }; use log::error; use specs::{join::Join, Entity as EcsEntity, WorldExt}; -use vek::{Vec3, *}; +use vek::Vec3; const BLOCK_EFFICIENCY: f32 = 0.9; const BLOCK_ANGLE: f32 = 180.0; @@ -196,9 +196,7 @@ pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Opti // Go through all other entities let hit_range = 2.0 * power; let ecs = &server.state.ecs(); - for (b, uid_b, pos_b, ori_b, character_b, stats_b) in ( - &ecs.entities(), - &ecs.read_storage::(), + for (pos_b, ori_b, character_b, stats_b) in ( &ecs.read_storage::(), &ecs.read_storage::(), &ecs.read_storage::(), @@ -214,7 +212,7 @@ pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Opti && distance_squared < hit_range.powi(2) { // Weapon gives base damage - let mut dmg = ((1.0 - distance_squared / hit_range.powi(2)) * power * 5.0) as u32; + let mut dmg = ((1.0 - distance_squared / hit_range.powi(2)) * power * 10.0) as u32; if rand::random() { dmg += 1; @@ -236,6 +234,8 @@ pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Opti const RAYS: usize = 500; + // Color terrain + let mut touched_blocks = Vec::new(); for _ in 0..RAYS { let dir = Vec3::new( rand::random::() - 0.5, @@ -244,7 +244,35 @@ pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Opti ) .normalized(); - let mut block_change = ecs.write_resource::(); + let _ = ecs + .read_resource::() + .ray(pos, pos + dir * power * 2.5) + .until(|_| rand::random::() < 0.05) + .for_each(|pos| touched_blocks.push(pos)) + .cast(); + } + + let terrain = ecs.read_resource::(); + let mut block_change = ecs.write_resource::(); + for pos in touched_blocks { + if let Ok(block) = terrain.get(pos) { + if let Some(mut color) = block.get_color() { + color[0] /= 2; + color[1] /= 3; + color[2] /= 3; + block_change.set(pos, Block::new(block.kind(), color)); + } + } + } + + // Destroy terrain + for _ in 0..RAYS { + let dir = Vec3::new( + rand::random::() - 0.5, + rand::random::() - 0.5, + rand::random::() - 0.5, + ) + .normalized(); let _ = ecs .read_resource::() From fbb24e7c8a4798390389589c05481bf6141ede15 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 23 Mar 2020 22:52:35 +0100 Subject: [PATCH 218/326] Even better fireballs --- common/src/comp/inventory/item.rs | 6 +++--- common/src/states/cast_fireball.rs | 2 +- server/src/events/entity_manipulation.rs | 22 ++++++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 0af04fcd93..729eabda62 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -123,15 +123,15 @@ impl ToolData { CastFireball { projectile: Projectile { hit_ground: vec![ - projectile::Effect::Explode { power: 1.5 }, + projectile::Effect::Explode { power: 1.4 }, projectile::Effect::Vanish, ], hit_wall: vec![ - projectile::Effect::Explode { power: 1.5 }, + projectile::Effect::Explode { power: 1.4 }, projectile::Effect::Vanish, ], hit_entity: vec![ - projectile::Effect::Explode { power: 1.5 }, + projectile::Effect::Explode { power: 1.4 }, projectile::Effect::Vanish, ], time_left: Duration::from_secs(20), diff --git a/common/src/states/cast_fireball.rs b/common/src/states/cast_fireball.rs index 911562be72..d9e54e65a0 100644 --- a/common/src/states/cast_fireball.rs +++ b/common/src/states/cast_fireball.rs @@ -47,7 +47,7 @@ impl CharacterBehavior for Data { dir: data.inputs.look_dir, body: self.projectile_body, light: Some(LightEmitter { - col: (0.0, 1.0, 0.3).into(), + col: (0.72, 0.11, 0.11).into(), ..Default::default() }), projectile, diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 4d17cc6b5c..714d35933d 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -236,6 +236,7 @@ pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Opti // Color terrain let mut touched_blocks = Vec::new(); + let color_range = power * 2.7; for _ in 0..RAYS { let dir = Vec3::new( rand::random::() - 0.5, @@ -246,7 +247,7 @@ pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Opti let _ = ecs .read_resource::() - .ray(pos, pos + dir * power * 2.5) + .ray(pos, pos + dir * color_range) .until(|_| rand::random::() < 0.05) .for_each(|pos| touched_blocks.push(pos)) .cast(); @@ -254,13 +255,18 @@ pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Opti let terrain = ecs.read_resource::(); let mut block_change = ecs.write_resource::(); - for pos in touched_blocks { - if let Ok(block) = terrain.get(pos) { + for block_pos in touched_blocks { + if let Ok(block) = terrain.get(block_pos) { + let diff2 = block_pos.map(|b| b as f32).distance_squared(pos); + let fade = (1.0 - diff2 / color_range.powi(2)).max(0.0); if let Some(mut color) = block.get_color() { - color[0] /= 2; - color[1] /= 3; - color[2] /= 3; - block_change.set(pos, Block::new(block.kind(), color)); + let r = color[0] as f32 + (fade * (color[0] as f32 * 0.5 - color[0] as f32)); + let g = color[1] as f32 + (fade * (color[1] as f32 * 0.3 - color[1] as f32)); + let b = color[2] as f32 + (fade * (color[2] as f32 * 0.3 - color[2] as f32)); + color[0] = r as u8; + color[1] = g as u8; + color[2] = b as u8; + block_change.set(block_pos, Block::new(block.kind(), color)); } } } @@ -270,7 +276,7 @@ pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Opti let dir = Vec3::new( rand::random::() - 0.5, rand::random::() - 0.5, - rand::random::() - 0.5, + rand::random::() - 0.15, ) .normalized(); From 1c145e8d3a0a9f2f20edabfb0a85425fe62a7281 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 24 Mar 2020 00:23:21 +0100 Subject: [PATCH 219/326] Add inventory counter --- common/src/comp/inventory/mod.rs | 42 +++++++++++++++++++++++++++---- common/src/comp/inventory/test.rs | 5 ++++ voxygen/src/hud/bag.rs | 2 +- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index ad2d0f7e53..08bbcb0f04 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -14,6 +14,7 @@ pub const MAX_PICKUP_RANGE_SQR: f32 = 64.0; #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Inventory { pub slots: Vec>, + pub amount: u32, } /// Errors which the methods on `Inventory` produce @@ -29,10 +30,26 @@ impl Inventory { pub fn len(&self) -> usize { self.slots.len() } + pub fn recount_items(&mut self) { + self.amount = 0; + for item in self.slots.iter() { + if let Some(item) = item { + match item.kind { + ItemKind::Tool(_) | ItemKind::Armor { .. } => self.amount += 1, + ItemKind::Utility { amount, .. } + | ItemKind::Ingredient { amount, .. } + | ItemKind::Consumable { amount, .. } => { + self.amount += amount; + }, + } + } + } + } + /// Adds a new item to the first fitting group of the inventory or starts a /// new group. Returns the item again if no space was found. pub fn push(&mut self, item: Item) -> Option { - match item.kind { + let item = match item.kind { ItemKind::Tool(_) | ItemKind::Armor { .. } => self.add_to_first_empty(item), ItemKind::Utility { kind: item_kind, @@ -55,6 +72,7 @@ impl Inventory { { if item_kind == *kind { *amount += new_amount; + self.recount_items(); return None; } } @@ -85,6 +103,7 @@ impl Inventory { { if item_kind == *kind { *amount += new_amount; + self.recount_items(); return None; } } @@ -114,6 +133,7 @@ impl Inventory { { if item_kind == *kind { *amount += new_amount; + self.recount_items(); return None; } } @@ -122,19 +142,23 @@ impl Inventory { // It didn't work self.add_to_first_empty(item) }, - } + }; + self.recount_items(); + item } /// Adds a new item to the first empty slot of the inventory. Returns the /// item again if no free slot was found. fn add_to_first_empty(&mut self, item: Item) -> Option { - match self.slots.iter_mut().find(|slot| slot.is_none()) { + let item = match self.slots.iter_mut().find(|slot| slot.is_none()) { Some(slot) => { *slot = Some(item); None }, None => Some(item), - } + }; + self.recount_items(); + item } /// Add a series of items to inventory, returning any which do not fit as an @@ -150,6 +174,7 @@ impl Inventory { leftovers.push(item); } } + self.recount_items(); if leftovers.len() > 0 { Err(Error::Full(leftovers)) } else { @@ -187,6 +212,7 @@ impl Inventory { Some(slot) => { let old = slot.take(); *slot = Some(item); + self.recount_items(); Ok(old) }, None => Err(item), @@ -217,7 +243,9 @@ impl Inventory { /// Remove an item from the slot pub fn remove(&mut self, cell: usize) -> Option { - self.slots.get_mut(cell).and_then(|item| item.take()) + let item = self.slots.get_mut(cell).and_then(|item| item.take()); + self.recount_items(); + item } /// Remove just one item from the slot @@ -235,6 +263,7 @@ impl Inventory { kind: *kind, amount: 1, }; + self.recount_items(); Some(return_item) } }, @@ -252,6 +281,7 @@ impl Inventory { effect: *effect, amount: 1, }; + self.recount_items(); Some(return_item) } }, @@ -264,6 +294,7 @@ impl Inventory { kind: *kind, amount: 1, }; + self.recount_items(); Some(return_item) } }, @@ -278,6 +309,7 @@ impl Default for Inventory { fn default() -> Inventory { let mut inventory = Inventory { slots: vec![None; 18], + amount: 0, }; inventory.push(assets::load_expect_cloned("common.items.cheese")); inventory.push(assets::load_expect_cloned("common.items.apple")); diff --git a/common/src/comp/inventory/test.rs b/common/src/comp/inventory/test.rs index f2665d7cb5..51498159c2 100644 --- a/common/src/comp/inventory/test.rs +++ b/common/src/comp/inventory/test.rs @@ -15,6 +15,7 @@ fn create_default_count() { assert_eq!(Inventory::default().count(), 2) } fn push_full() { let mut inv = Inventory { slots: TEST_ITEMS.iter().map(|a| Some(a.clone())).collect(), + amount: 0, }; assert_eq!( inv.push(TEST_ITEMS[0].clone()).unwrap(), @@ -27,6 +28,7 @@ fn push_full() { fn push_all_full() { let mut inv = Inventory { slots: TEST_ITEMS.iter().map(|a| Some(a.clone())).collect(), + amount: 0, }; let Error::Full(leftovers) = inv .push_all(TEST_ITEMS.iter().map(|a| a.clone())) @@ -40,6 +42,7 @@ fn push_all_full() { fn push_unique_all_full() { let mut inv = Inventory { slots: TEST_ITEMS.iter().map(|a| Some(a.clone())).collect(), + amount: 0, }; inv.push_all_unique(TEST_ITEMS.iter().map(|a| a.clone())) .expect("Pushing unique items into an inventory that already contains them didn't work!"); @@ -51,6 +54,7 @@ fn push_unique_all_full() { fn push_all_empty() { let mut inv = Inventory { slots: vec![None, None], + amount: 0, }; inv.push_all(TEST_ITEMS.iter().map(|a| a.clone())) .expect("Pushing items into an empty inventory didn't work!"); @@ -62,6 +66,7 @@ fn push_all_empty() { fn push_all_unique_empty() { let mut inv = Inventory { slots: vec![None, None], + amount: 0, }; inv.push_all_unique(TEST_ITEMS.iter().map(|a| a.clone())) .expect( diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 902cd1cb50..1dfe29333c 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -184,7 +184,7 @@ impl<'a> Widget for Bag<'a> { self.stats.exp.maximum(), &self.localized_strings.get("hud.bag.exp") ); - let space_used = 0; // TODO: Add functionality + let space_used = inventory.amount; let space_max = 0; let bag_space = format!("{}/{}", space_used, space_max); let level = (self.stats.level.level()).to_string(); From 43d4e8aad2c85b1bc63186a5a71e5e1b5275a40b Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 24 Mar 2020 00:38:00 +0100 Subject: [PATCH 220/326] Better inventory counter --- common/src/comp/inventory/mod.rs | 9 +-------- voxygen/src/hud/bag.rs | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 08bbcb0f04..6b9f650a1c 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -34,14 +34,7 @@ impl Inventory { self.amount = 0; for item in self.slots.iter() { if let Some(item) = item { - match item.kind { - ItemKind::Tool(_) | ItemKind::Armor { .. } => self.amount += 1, - ItemKind::Utility { amount, .. } - | ItemKind::Ingredient { amount, .. } - | ItemKind::Consumable { amount, .. } => { - self.amount += amount; - }, - } + self.amount += 1; } } } diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 1dfe29333c..15fd1c0434 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -185,7 +185,7 @@ impl<'a> Widget for Bag<'a> { &self.localized_strings.get("hud.bag.exp") ); let space_used = inventory.amount; - let space_max = 0; + let space_max = inventory.slots.len(); let bag_space = format!("{}/{}", space_used, space_max); let level = (self.stats.level.level()).to_string(); let currency = 0; // TODO: Add as a Stat maybe? From 060ebbc861f5eb9f81cede44326d0328f2fc20d7 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Tue, 24 Mar 2020 01:11:14 +0100 Subject: [PATCH 221/326] healing sceptre --- assets/common/items/weapons/staff_nature.ron | 11 +++++++++++ assets/voxygen/item_image_manifest.ron | 4 ++++ .../voxygen/voxel/humanoid_main_weapon_manifest.ron | 4 ++++ common/src/comp/inventory/item.rs | 5 +++++ 4 files changed, 24 insertions(+) create mode 100644 assets/common/items/weapons/staff_nature.ron diff --git a/assets/common/items/weapons/staff_nature.ron b/assets/common/items/weapons/staff_nature.ron new file mode 100644 index 0000000000..d9961ef873 --- /dev/null +++ b/assets/common/items/weapons/staff_nature.ron @@ -0,0 +1,11 @@ +Item( + name: "Sceptre of Regeneration", + description: " Infused by the power of Nature. + Power: 25", + kind: Tool( + ToolData ( + kind: Staff(Sceptre), + equip_time_millis: 800, + ) + ), +) diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index c0f91482e4..ee846de0da 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -45,6 +45,10 @@ "voxel.weapon.staff.wood-fire", (0.0, -9.0, 0.0), (90.0, 90.0, 0.0), 2.5, ), + Tool(Staff(Sceptre)): VoxTrans( + "voxel.weapon.staff.wood-nature", + (0.0, -9.0, 0.0), (90.0, 90.0, 0.0), 2.5, + ), // Shields Tool(Shield(BasicShield)): VoxTrans( "voxel.weapon.shield.wood-0", diff --git a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron index 89ccc89f0e..5a689b103d 100644 --- a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron +++ b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron @@ -42,6 +42,10 @@ Staff(BasicStaff): ( vox_spec: ("weapon.staff.wood-fire", (-1.0, -6.0, -3.0)), color: None + ), + Staff(Sceptre): ( + vox_spec: ("weapon.staff.wood-nature", (-1.0, -6.0, -5.0)), + color: None ), Debug(Boost): ( vox_spec: ("weapon.debug_wand", (-1.5, -9.5, -4.0)), diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 729eabda62..c315a4c973 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -39,6 +39,7 @@ pub enum DaggerKind { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum StaffKind { BasicStaff, + Sceptre, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ShieldKind { @@ -113,6 +114,10 @@ impl ToolData { max_angle: 60.0, }], Staff(_) => vec![ + //Intended behaviour for the healing sceptre: M1 -> Heal a single target (not a + // projectile, just a heal for the target.) Optional: Green flash of the healed + // target. M2: Heal everyone around the caster, including the + // caster BasicMelee { buildup_duration: Duration::from_millis(0), recover_duration: Duration::from_millis(300), From 7f30ec3d559f3791487bc82fdd054ad74adba862 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Tue, 24 Mar 2020 01:31:14 +0100 Subject: [PATCH 222/326] colors for inventory space counter --- voxygen/src/hud/bag.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 15fd1c0434..0e8219f1ba 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -1,7 +1,8 @@ use super::{ img_ids::{Imgs, ImgsRot}, item_imgs::{ItemImgs, ItemKey}, - Event as HudEvent, Show, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, XP_COLOR, + Event as HudEvent, Show, CRITICAL_HP_COLOR, LOW_HP_COLOR, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, + XP_COLOR, }; use crate::{ i18n::VoxygenLocalization, @@ -187,6 +188,7 @@ impl<'a> Widget for Bag<'a> { let space_used = inventory.amount; let space_max = inventory.slots.len(); let bag_space = format!("{}/{}", space_used, space_max); + let bag_space_percentage = space_used as f32 / space_max as f32; let level = (self.stats.level.level()).to_string(); let currency = 0; // TODO: Add as a Stat maybe? @@ -272,7 +274,13 @@ impl<'a> Widget for Bag<'a> { .bottom_right_with_margins_on(state.ids.bg_frame, 6.0, 43.0) .font_id(self.fonts.cyri.conrod_id) .font_size(self.fonts.cyri.scale(14)) - .color(TEXT_COLOR) + .color(if bag_space_percentage < 0.8 { + TEXT_COLOR + } else if bag_space_percentage < 1.0 { + LOW_HP_COLOR + } else { + CRITICAL_HP_COLOR + }) .set(state.ids.space_txt, ui); // Alignment for Grid Rectangle::fill_with([362.0, 200.0], color::TRANSPARENT) From 7a4f0fa9ac588ff2411554897163584d4e11c53d Mon Sep 17 00:00:00 2001 From: jshipsey Date: Tue, 24 Mar 2020 00:24:31 -0400 Subject: [PATCH 223/326] climb fix, const tweak update, trying equip anims --- voxygen/Cargo.toml | 2 +- voxygen/src/anim/character/attack.rs | 12 +- voxygen/src/anim/character/climb.rs | 12 +- voxygen/src/anim/character/equip.rs | 254 ++++++++++++++++++++++++ voxygen/src/anim/character/idleequip.rs | 252 +++++++++++++++++++++++ voxygen/src/anim/character/mod.rs | 12 +- voxygen/src/anim/character/stand.rs | 8 +- voxygen/src/scene/figure/mod.rs | 13 +- 8 files changed, 541 insertions(+), 24 deletions(-) create mode 100644 voxygen/src/anim/character/equip.rs create mode 100644 voxygen/src/anim/character/idleequip.rs diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 0dfa722f6e..71bbaadc35 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -68,7 +68,7 @@ bincode = "1.2" deunicode = "1.0" uvth = "3.1.1" authc = { git = "https://gitlab.com/veloren/auth.git", rev = "65571ade0d954a0e0bd995fdb314854ff146ab97" } -const-tweaker = { version = "0.2.1", optional = true } +const-tweaker = { version = "0.2.4", optional = true } [target.'cfg(target_os = "macos")'.dependencies] dispatch = "0.1.4" diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index 736c595ae6..de331b7ccf 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -52,7 +52,7 @@ impl Animation for AttackAnimation { Some(ToolKind::Sword(_)) => { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward, + 0.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 14.0, ); next.head.ori = Quaternion::rotation_z(slow * 0.08) @@ -102,7 +102,7 @@ impl Animation for AttackAnimation { Some(ToolKind::Axe(_)) => { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right + slowax * 2.0, - -2.0 + skeleton_attr.neck_forward + slowax * -2.0, + 0.0 + skeleton_attr.neck_forward + slowax * -2.0, skeleton_attr.neck_height + 13.0, ); next.head.ori = Quaternion::rotation_z(slowax * 0.25) @@ -160,7 +160,7 @@ impl Animation for AttackAnimation { next.main.scale = Vec3::one(); next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right + slower * 3.0, - -2.0 + skeleton_attr.neck_forward + slower * -3.0, + 0.0 + skeleton_attr.neck_forward + slower * -3.0, skeleton_attr.neck_height + 12.0, ); next.head.ori = Quaternion::rotation_z(slower * 0.25) @@ -191,7 +191,7 @@ impl Animation for AttackAnimation { Some(ToolKind::Staff(_)) => { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * 0.8, + 0.0 + skeleton_attr.neck_forward + decel * 0.8, skeleton_attr.neck_height + 14.0, ); next.head.ori = Quaternion::rotation_z(decel * 0.25) @@ -237,7 +237,7 @@ impl Animation for AttackAnimation { Some(ToolKind::Shield(_)) => { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * 0.8, + 0.0 + skeleton_attr.neck_forward + decel * 0.8, skeleton_attr.neck_height + 21.0, ); next.head.ori = Quaternion::rotation_z(decel * 0.25) @@ -289,7 +289,7 @@ impl Animation for AttackAnimation { Some(ToolKind::Bow(_)) => { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * 0.8, + 0.0 + skeleton_attr.neck_forward + decel * 0.8, skeleton_attr.neck_height + 21.0, ); next.head.ori = Quaternion::rotation_z(decel * -0.25) diff --git a/voxygen/src/anim/character/climb.rs b/voxygen/src/anim/character/climb.rs index 67fa4b810c..fc738e4ff5 100644 --- a/voxygen/src/anim/character/climb.rs +++ b/voxygen/src/anim/character/climb.rs @@ -35,8 +35,8 @@ impl Animation for ClimbAnimation { next.head.offset = Vec3::new( 0.0, - -1.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 11.5 + wave_cos * 1.3, + -4.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 13.50 + wave_cos * 0.2, ); next.head.ori = Quaternion::rotation_z(wave * 0.1) * Quaternion::rotation_x(0.6) @@ -49,12 +49,12 @@ impl Animation for ClimbAnimation { * Quaternion::rotation_y(wave_test * -0.12); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 1.0, -3.5 + wave_cos * 1.1); - next.belt.ori = Quaternion::rotation_z(wave_test * 0.25) * Quaternion::rotation_x(0.0); + next.belt.offset = Vec3::new(0.0, 1.0, -2.0); + next.belt.ori = Quaternion::rotation_z(wave_test * 0.0) * Quaternion::rotation_x(0.0); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 1.0, -6.0 + wave_cos * 1.1); - next.shorts.ori = Quaternion::rotation_z(wave_test * 0.25) + next.shorts.offset = Vec3::new(0.0, 1.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(wave_test * 0.0) * Quaternion::rotation_x(0.1) * Quaternion::rotation_y(wave_test * 0.10); next.shorts.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/equip.rs b/voxygen/src/anim/character/equip.rs new file mode 100644 index 0000000000..35fb623223 --- /dev/null +++ b/voxygen/src/anim/character/equip.rs @@ -0,0 +1,254 @@ +use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; +use common::comp::item::ToolKind; +use std::{f32::consts::PI, ops::Mul}; + +use vek::*; + +pub struct EquipAnimation; + +impl Animation for EquipAnimation { + type Dependency = (Option, f32, f64); + type Skeleton = CharacterSkeleton; + + fn update_skeleton( + skeleton: &Self::Skeleton, + (active_tool_kind, _velocity, global_time): Self::Dependency, + anim_time: f64, + _rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + let lab = 1.0; + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 1.6).sin()); + let short = (((5.0) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 1.6).sin()); + let long = (((5.0) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.8).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 0.8).sin()); + + let equip_slow = 1.0 + (anim_time as f32 * 1.2 + PI).cos(); + let equip_slowa = 1.0 + (anim_time as f32 * 1.2 + PI / 4.0).cos(); + + let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); + let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); + + let wave = (anim_time as f32 * 1.0).sin(); + match active_tool_kind { + //TODO: Inventory + Some(ToolKind::Sword(_)) => { + next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0); + next.l_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(-0.2); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(1.25, -5.5, -8.0); + next.r_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 0.0, -6.0); + next.main.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = + Vec3::new(-3.0 + equip_slowa * -1.5, -5.0, 12.0 + equip_slow * 1.5); + next.control.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(2.5) + * Quaternion::rotation_z(1.57); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Axe(_)) => { + next.l_hand.offset = Vec3::new(-4.0, 3.0, 6.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(-2.5, 9.0, 4.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(-6.0, 10.0, -1.0); + next.main.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(-0.8); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(0.0, 0.0, 0.0); + next.control.ori = Quaternion::rotation_x(0.2) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(0.0); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Hammer(_)) => { + next.l_hand.offset = Vec3::new(-7.0 + 9.0, 4.6 + 1.5, 7.5 - 1.6); + next.l_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.32); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(8.0, 5.75, 4.0); + next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.22); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(6.0, 7.0, 0.0); + next.main.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(-1.35) + * Quaternion::rotation_z(1.57); + next.main.scale = Vec3::one(); + + next.control.offset = + Vec3::new(-3.0 + equip_slowa * -1.5, -12.0, 12.0 + equip_slow * 1.5); + next.control.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(1.35 + 2.5) + * Quaternion::rotation_z(0.0); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Staff(_)) => { + next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); + next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(1.8) + * Quaternion::rotation_y(0.5) + * Quaternion::rotation_z(-0.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(11.0, 9.0, 10.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(3.14 + 0.3) + * Quaternion::rotation_z(0.9); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Shield(_)) => { + next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new( + -6.0 + skeleton_attr.weapon_x, + 4.5 + skeleton_attr.weapon_y, + 0.0, + ); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Bow(_)) => { + next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); + next.l_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(3.0, -1.0, -5.0); + next.r_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(3.0, 2.0, -13.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.3) + * Quaternion::rotation_z(-0.6); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Dagger(_)) => { + next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new( + -6.0 + skeleton_attr.weapon_x, + 4.5 + skeleton_attr.weapon_y, + 0.0, + ); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Debug(_)) => { + next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); + next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); + next.r_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new( + 5.0 + skeleton_attr.weapon_x, + 8.75 + skeleton_attr.weapon_y, + -2.0, + ); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(-1.27) + * Quaternion::rotation_z(wave * -0.25); + next.main.scale = Vec3::one(); + }, + _ => {}, + } + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 6.0) + .floor() + .mul(7331.0) + .sin() + * 0.2, + ((global_time + anim_time) as f32 / 6.0) + .floor() + .mul(1337.0) + .sin() + * 0.1, + ); + next.head.offset = Vec3::new( + 0.0, + -3.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 13.0 + short * 0.2, + ); + next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1 - short * 0.2) + * Quaternion::rotation_x(head_look.y + 0.35); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1); + next.chest.ori = Quaternion::rotation_z(short * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_z(short * 0.15); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(short * 0.4); + next.shorts.scale = Vec3::one(); + + next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); + next.r_foot.scale = Vec3::one(); + + next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(-0.2); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + next + } +} diff --git a/voxygen/src/anim/character/idleequip.rs b/voxygen/src/anim/character/idleequip.rs new file mode 100644 index 0000000000..be36ef275c --- /dev/null +++ b/voxygen/src/anim/character/idleequip.rs @@ -0,0 +1,252 @@ +use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; +use common::comp::item::ToolKind; +use std::{f32::consts::PI, ops::Mul}; + +use vek::*; + +pub struct IdleEquipAnimation; + +impl Animation for IdleEquipAnimation { + type Dependency = (Option, f32, f64); + type Skeleton = CharacterSkeleton; + + fn update_skeleton( + skeleton: &Self::Skeleton, + (active_tool_kind, _velocity, global_time): Self::Dependency, + anim_time: f64, + _rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + let _lab = 1.0; + let wave_slow_cos = (anim_time as f32 * 6.0 + PI).cos(); + let equip_slow = 1.0 + (anim_time as f32 * 10.0 + PI).cos(); + let equip_slowa = 1.0 + (anim_time as f32 * 10.0 + PI / 4.0).cos(); + + let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); + let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); + + let wave = (anim_time as f32 * 1.0).sin(); + match active_tool_kind { + //TODO: Inventory + Some(ToolKind::Sword(_)) => { + next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0); + next.l_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(-0.2); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(1.25, -5.5, -8.0); + next.r_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 0.0, -6.0); + next.main.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = + Vec3::new(-3.0 + equip_slowa * -1.5, -5.0, 12.0 + equip_slow * 1.5); + next.control.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(2.5) + * Quaternion::rotation_z(1.57); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Axe(_)) => { + next.l_hand.offset = Vec3::new(-4.0, 3.0, 6.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(-2.5, 9.0, 4.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_z(3.14 - 0.3) + * Quaternion::rotation_y(-0.8); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(-6.0, 10.0, -1.0); + next.main.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(-0.8); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(0.0, 0.0, 0.0); + next.control.ori = Quaternion::rotation_x(0.2) + * Quaternion::rotation_y(-0.3) + * Quaternion::rotation_z(0.0); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Hammer(_)) => { + next.l_hand.offset = Vec3::new(-7.0 + 9.0, 4.6 + 1.5, 7.5 - 1.6); + next.l_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.32); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(8.0, 5.75, 4.0); + next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.22); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(6.0, 7.0, 0.0); + next.main.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(-1.35) + * Quaternion::rotation_z(1.57); + next.main.scale = Vec3::one(); + + next.control.offset = + Vec3::new(-3.0 + equip_slowa * -1.5, -12.0, 12.0 + equip_slow * 1.5); + next.control.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(1.35 + 2.5) + * Quaternion::rotation_z(0.0); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Staff(_)) => { + next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); + next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(1.8) + * Quaternion::rotation_y(0.5) + * Quaternion::rotation_z(-0.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(11.0, 9.0, 10.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(3.14 + 0.3) + * Quaternion::rotation_z(0.9); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Shield(_)) => { + next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new( + -6.0 + skeleton_attr.weapon_x, + 4.5 + skeleton_attr.weapon_y, + 0.0, + ); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Bow(_)) => { + next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); + next.l_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(3.0, -1.0, -5.0); + next.r_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(3.0, 2.0, -13.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.3) + * Quaternion::rotation_z(-0.6); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Dagger(_)) => { + next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); + next.l_hand.ori = Quaternion::rotation_x(-0.3); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); + next.r_hand.ori = Quaternion::rotation_x(-0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new( + -6.0 + skeleton_attr.weapon_x, + 4.5 + skeleton_attr.weapon_y, + 0.0, + ); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + }, + Some(ToolKind::Debug(_)) => { + next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); + next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); + next.r_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new( + 5.0 + skeleton_attr.weapon_x, + 8.75 + skeleton_attr.weapon_y, + -2.0, + ); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(-1.27) + * Quaternion::rotation_z(wave * -0.25); + next.main.scale = Vec3::one(); + }, + _ => {}, + } + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 10.0) + .floor() + .mul(7331.0) + .sin() + * 0.2, + ((global_time + anim_time) as f32 / 10.0) + .floor() + .mul(1337.0) + .sin() + * 0.1, + ); + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 14.0 + wave_ultra_slow * 0.1, + ); + next.head.ori = + Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 7.0 + wave_ultra_slow * 0.5); + next.chest.ori = + Quaternion::rotation_y(wave_ultra_slow_cos * 0.04) * Quaternion::rotation_z(0.15); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = + Quaternion::rotation_y(wave_ultra_slow_cos * 0.03) * Quaternion::rotation_z(0.22); + next.belt.scale = Vec3::one() * 1.02; + + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(0.3); + next.shorts.scale = Vec3::one(); + + next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0); + next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, 3.5, 8.0); + next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035); + next.r_foot.scale = Vec3::one(); + + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); + next + } +} diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 29827d9620..6d4beec894 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -4,8 +4,10 @@ pub mod blockidle; pub mod charge; pub mod cidle; pub mod climb; +pub mod equip; pub mod gliding; pub mod idle; +pub mod idleequip; pub mod idlewield; pub mod jump; pub mod roll; @@ -20,11 +22,11 @@ pub mod wield; // Reexports pub use self::{ attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, - charge::ChargeAnimation, cidle::CidleAnimation, climb::ClimbAnimation, - gliding::GlidingAnimation, idle::IdleAnimation, idlewield::IdleWieldAnimation, - jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, - sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation, swim::SwimAnimation, - wield::WieldAnimation, + charge::ChargeAnimation, cidle::CidleAnimation, climb::ClimbAnimation, equip::EquipAnimation, + gliding::GlidingAnimation, idle::IdleAnimation, idleequip::IdleEquipAnimation, + idlewield::IdleWieldAnimation, jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, + shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation, + swim::SwimAnimation, wield::WieldAnimation, }; use super::{Bone, Skeleton}; diff --git a/voxygen/src/anim/character/stand.rs b/voxygen/src/anim/character/stand.rs index 4528ad2b87..b26188efaf 100644 --- a/voxygen/src/anim/character/stand.rs +++ b/voxygen/src/anim/character/stand.rs @@ -46,12 +46,12 @@ impl Animation for StandAnimation { next.chest.ori = Quaternion::rotation_z(head_look.x * 0.6); next.chest.scale = Vec3::one() * 1.01; - next.belt.offset = Vec3::new(0.0, 0.0, -2.0 + slow * 0.3); //5 - next.belt.ori = Quaternion::rotation_z(head_look.x * 0.4); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); //5 + next.belt.ori = Quaternion::rotation_z(head_look.x * -0.1); next.belt.scale = Vec3::one() + breathe * 0.05; - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0 + slow * 0.3); //2 - next.shorts.ori = Quaternion::rotation_x(0.0); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); //2 + next.shorts.ori = Quaternion::rotation_x(head_look.x * -0.2); next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(-7.0, -0.25 + slow * 0.15, 5.0 + slow * 0.5); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 2579efcc9c..036c3ad62a 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -488,6 +488,15 @@ impl FigureMgr { skeleton_attr, ) }, + CharacterState::CastFireball(_) => { + anim::character::ShootAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, CharacterState::Boost(_) => { anim::character::AttackAnimation::update_skeleton( &target_base, @@ -566,7 +575,7 @@ impl FigureMgr { }*/ CharacterState::Equipping { .. } => { if vel.0.magnitude_squared() > 0.5 { - anim::character::WieldAnimation::update_skeleton( + anim::character::EquipAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, @@ -574,7 +583,7 @@ impl FigureMgr { skeleton_attr, ) } else { - anim::character::IdleWieldAnimation::update_skeleton( + anim::character::IdleEquipAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, From 99e7e1f78502e3b9b42c26597b4306e3eec7dab1 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 24 Mar 2020 13:59:53 +0100 Subject: [PATCH 224/326] Split staff into 3 abilities --- common/src/comp/ability.rs | 5 +++-- common/src/comp/controller.rs | 6 ++++++ common/src/comp/inventory/item.rs | 20 +++++++++++++++++- common/src/comp/inventory/mod.rs | 7 +------ common/src/states/basic_ranged.rs | 4 +--- common/src/states/cast_fireball.rs | 6 ++---- common/src/states/utils.rs | 29 +++++++++++++++++++-------- common/src/states/wielding.rs | 5 +++-- server/src/events/interaction.rs | 7 +++++-- server/src/events/inventory_manip.rs | 5 +++-- server/src/state_ext.rs | 5 +++-- server/src/sys/terrain.rs | 15 ++++++++------ voxygen/src/menu/char_selection/ui.rs | 5 +++-- voxygen/src/session.rs | 4 ++++ voxygen/src/settings.rs | 2 ++ voxygen/src/window.rs | 4 ++++ 16 files changed, 89 insertions(+), 40 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 40a9fb41c7..80d17119af 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -83,8 +83,9 @@ impl CharacterAbility { #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] pub struct ItemConfig { pub item: Item, - pub primary_ability: Option, - pub secondary_ability: Option, + pub ability1: Option, + pub ability2: Option, + pub ability3: Option, pub block_ability: Option, pub dodge_ability: Option, } diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index d174a46b0b..d34752271f 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -114,6 +114,7 @@ impl Default for Input { pub struct ControllerInputs { pub primary: Input, pub secondary: Input, + pub ability3: Input, pub sit: Input, pub jump: Input, pub roll: Input, @@ -141,6 +142,7 @@ impl ControllerInputs { pub fn tick(&mut self, dt: Duration) { self.primary.tick(dt); self.secondary.tick(dt); + self.ability3.tick(dt); self.sit.tick(dt); self.jump.tick(dt); self.roll.tick(dt); @@ -153,6 +155,10 @@ impl ControllerInputs { self.swap_loadout.tick(dt); self.charge.tick(dt); } + + pub fn holding_ability_key(&self) -> bool { + self.primary.is_pressed() || self.secondary.is_pressed() || self.ability3.is_pressed() + } } impl Controller { diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index c315a4c973..a74d0738fb 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -121,10 +121,28 @@ impl ToolData { BasicMelee { buildup_duration: Duration::from_millis(0), recover_duration: Duration::from_millis(300), - base_damage: 3, + base_damage: 1, range: 10.0, max_angle: 45.0, }, + BasicRanged { + projectile: Projectile { + hit_ground: vec![projectile::Effect::Vanish], + hit_wall: vec![projectile::Effect::Vanish], + hit_entity: vec![ + projectile::Effect::Damage(HealthChange { + // TODO: This should not be fixed (?) + amount: -2, + cause: HealthSource::Projectile { owner: None }, + }), + projectile::Effect::Vanish, + ], + time_left: Duration::from_secs(20), + owner: None, + }, + projectile_body: Body::Object(object::Body::BoltFire), + recover_duration: Duration::from_millis(500), + }, CastFireball { projectile: Projectile { hit_ground: vec![ diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 6b9f650a1c..8090ea39ac 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -31,12 +31,7 @@ impl Inventory { pub fn len(&self) -> usize { self.slots.len() } pub fn recount_items(&mut self) { - self.amount = 0; - for item in self.slots.iter() { - if let Some(item) = item { - self.amount += 1; - } - } + self.amount = self.slots.iter().filter(|i| i.is_some()).count() as u32; } /// Adds a new item to the first fitting group of the inventory or starts a diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index 0fb2c699ca..9b219e8ca4 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -27,9 +27,7 @@ impl CharacterBehavior for Data { handle_move(data, &mut update); handle_jump(data, &mut update); - if !self.exhausted - && (data.inputs.primary.is_pressed() | data.inputs.secondary.is_pressed()) - { + if !self.exhausted && data.inputs.holding_ability_key() { // Prepare (draw the bow) update.character = CharacterState::BasicRanged(Data { prepare_timer: self.prepare_timer + Duration::from_secs_f32(data.dt.0), diff --git a/common/src/states/cast_fireball.rs b/common/src/states/cast_fireball.rs index d9e54e65a0..50f5a5d5f6 100644 --- a/common/src/states/cast_fireball.rs +++ b/common/src/states/cast_fireball.rs @@ -27,10 +27,8 @@ impl CharacterBehavior for Data { handle_move(data, &mut update); handle_jump(data, &mut update); - if !self.exhausted - && (data.inputs.primary.is_pressed() | data.inputs.secondary.is_pressed()) - { - // Prepare (draw the bow) + if !self.exhausted && data.inputs.holding_ability_key() { + // Prepare update.character = CharacterState::CastFireball(Data { prepare_timer: self.prepare_timer + Duration::from_secs_f32(data.dt.0), recover_duration: self.recover_duration, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index a1747d017a..2f3d1b2857 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -170,15 +170,14 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { } } -/// If `inputs.primary` is pressed and in `Wielding` state, -/// will attempt to go into `loadout.active_item.primary_ability` -pub fn handle_primary_input(data: &JoinData, update: &mut StateUpdate) { +/// Will attempt to go into `loadout.active_item.ability1` +pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) { if data.inputs.primary.is_pressed() { if let Some(ability) = data .loadout .active_item .as_ref() - .and_then(|i| i.primary_ability.as_ref()) + .and_then(|i| i.ability1.as_ref()) .filter(|ability| ability.requirements_paid(data, update)) { update.character = ability.into(); @@ -186,15 +185,29 @@ pub fn handle_primary_input(data: &JoinData, update: &mut StateUpdate) { } } -/// If `inputs.secondary` is pressed and in `Wielding` state, -/// will attempt to go into `loadout.active_item.secondary_ability` -pub fn handle_secondary_input(data: &JoinData, update: &mut StateUpdate) { +/// Will attempt to go into `loadout.active_item.ability2` +pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) { if data.inputs.secondary.is_pressed() { if let Some(ability) = data .loadout .active_item .as_ref() - .and_then(|i| i.secondary_ability.as_ref()) + .and_then(|i| i.ability2.as_ref()) + .filter(|ability| ability.requirements_paid(data, update)) + { + update.character = ability.into(); + } + } +} + +/// Will attempt to go into `loadout.active_item.ability3` +pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) { + if data.inputs.ability3.is_pressed() { + if let Some(ability) = data + .loadout + .active_item + .as_ref() + .and_then(|i| i.ability3.as_ref()) .filter(|ability| ability.requirements_paid(data, update)) { update.character = ability.into(); diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 7b0b008a5e..7675f212da 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -17,8 +17,9 @@ impl CharacterBehavior for Data { handle_glide(&data, &mut update); handle_unwield(&data, &mut update); handle_swap_loadout(&data, &mut update); - handle_primary_input(&data, &mut update); - handle_secondary_input(&data, &mut update); + handle_ability1_input(&data, &mut update); + handle_ability2_input(&data, &mut update); + handle_ability3_input(&data, &mut update); handle_dodge_input(&data, &mut update); update diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index e424554ab3..95bd86430c 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -86,10 +86,13 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) { let item = assets::load_expect_cloned::("common.items.debug.possess"); if let comp::ItemKind::Tool(tool) = item.kind { + let mut abilities = tool.get_abilities(); + let mut ability_drain = abilities.drain(..); loadout.active_item = Some(comp::ItemConfig { item, - primary_ability: tool.get_abilities().get(0).cloned(), - secondary_ability: None, + ability1: ability_drain.next(), + ability2: ability_drain.next(), + ability3: ability_drain.next(), block_ability: None, dodge_ability: None, }); diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index 2bf1fa0e6f..82f7fa4ebd 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -111,8 +111,9 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv let mut ability_drain = abilities.drain(..); let active_item = comp::ItemConfig { item, - primary_ability: ability_drain.next(), - secondary_ability: ability_drain.next(), + ability1: ability_drain.next(), + ability2: ability_drain.next(), + ability3: ability_drain.next(), block_ability: Some(comp::CharacterAbility::BasicBlock), dodge_ability: Some(comp::CharacterAbility::Roll), }; diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index 639c1c7e1d..f2be33961b 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -169,8 +169,9 @@ impl StateExt for State { comp::Loadout { active_item: main.map(|item| comp::ItemConfig { item, - primary_ability: ability_drain.next(), - secondary_ability: ability_drain.next(), + ability1: ability_drain.next(), + ability2: ability_drain.next(), + ability3: ability_drain.next(), block_ability: Some(comp::CharacterAbility::BasicBlock), dodge_ability: Some(comp::CharacterAbility::Roll), }), diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 557e9549c6..aabf8a0f9f 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -196,8 +196,9 @@ impl<'a> System<'a> for Sys { main.map(|item| comp::ItemConfig { item, - primary_ability: ability_drain.next(), - secondary_ability: ability_drain.next(), + ability1: ability_drain.next(), + ability2: ability_drain.next(), + ability3: ability_drain.next(), block_ability: None, dodge_ability: Some(comp::CharacterAbility::Roll), }) @@ -205,14 +206,15 @@ impl<'a> System<'a> for Sys { Some(ItemConfig { // We need the empty item so npcs can attack item: Item::empty(), - primary_ability: Some(CharacterAbility::BasicMelee { + ability1: Some(CharacterAbility::BasicMelee { buildup_duration: Duration::from_millis(0), recover_duration: Duration::from_millis(300), base_damage: 2, range: 3.5, max_angle: 60.0, }), - secondary_ability: None, + ability2: None, + ability3: None, block_ability: None, dodge_ability: None, }) @@ -300,14 +302,15 @@ impl<'a> System<'a> for Sys { item: assets::load_expect_cloned( "common.items.weapons.zweihander_sword_0", ), - primary_ability: Some(CharacterAbility::BasicMelee { + ability1: Some(CharacterAbility::BasicMelee { buildup_duration: Duration::from_millis(800), recover_duration: Duration::from_millis(200), base_damage: 13, range: 3.5, max_angle: 60.0, }), - secondary_ability: None, + ability2: None, + ability3: None, block_ability: None, dodge_ability: None, }), diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index 54db12eda6..a1ff30d842 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -339,8 +339,9 @@ impl CharSelectionUi { Mode::Create { loadout, tool, .. } => { loadout.active_item = tool.map(|tool| comp::ItemConfig { item: (*load_expect::(tool)).clone(), - primary_ability: None, - secondary_ability: None, + ability1: None, + ability2: None, + ability3: None, block_ability: None, dodge_ability: None, }); diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index ce782655c8..3dce7ac89c 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -275,6 +275,10 @@ impl PlayState for SessionState { } } }, + + Event::InputUpdate(GameInput::Ability3, state) => { + self.inputs.ability3.set_state(state); + }, Event::InputUpdate(GameInput::Roll, state) => { let client = self.client.borrow(); if client diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 86dccca346..625657f50e 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -18,6 +18,7 @@ use std::{fs, io::prelude::*, path::PathBuf}; pub struct ControlSettings { pub primary: KeyMouse, pub secondary: KeyMouse, + pub ability3: KeyMouse, pub toggle_cursor: KeyMouse, pub escape: KeyMouse, pub enter: KeyMouse, @@ -69,6 +70,7 @@ impl Default for ControlSettings { Self { primary: KeyMouse::Mouse(MouseButton::Left), secondary: KeyMouse::Mouse(MouseButton::Right), + ability3: KeyMouse::Key(VirtualKeyCode::Key1), toggle_cursor: KeyMouse::Key(VirtualKeyCode::Tab), escape: KeyMouse::Key(VirtualKeyCode::Escape), enter: KeyMouse::Key(VirtualKeyCode::Return), diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index f614b280a0..8d89cc1330 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -16,6 +16,7 @@ use vek::*; pub enum GameInput { Primary, Secondary, + Ability3, ToggleCursor, MoveForward, MoveBack, @@ -360,6 +361,9 @@ impl Window { map.entry(settings.controls.secondary) .or_default() .push(GameInput::Secondary); + map.entry(settings.controls.ability3) + .or_default() + .push(GameInput::Ability3); map.entry(settings.controls.toggle_cursor) .or_default() .push(GameInput::ToggleCursor); From ea2500e7ab40e4f51ea05381a4f01ed5b174a7cd Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 24 Mar 2020 14:42:31 +0100 Subject: [PATCH 225/326] Add minimum prepare duration to fireball and bow --- Cargo.lock | 20 ++++++++++---------- common/src/comp/ability.rs | 7 ++++++- common/src/comp/inventory/item.rs | 12 ++++++++---- common/src/states/basic_ranged.rs | 9 ++++++++- common/src/states/cast_fireball.rs | 15 +++++++++------ 5 files changed, 41 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7069f42f18..a62f45c156 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -682,9 +682,9 @@ dependencies = [ [[package]] name = "const-tweaker" -version = "0.2.1" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe948a728bf50e79be7b41b197587318fbc17da0106e5d0f435e3a6b2b42226" +checksum = "b51e91181af416a58123da1cebf00d2e600296f358d0d69aa14df63956d2753e" dependencies = [ "anyhow", "async-std", @@ -698,9 +698,9 @@ dependencies = [ [[package]] name = "const-tweaker-attribute" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c22ff357be06ddb217d230a62c3f3ed8ebd305e87df53789d27450f48c40f6a" +checksum = "55cef233d59741e1a93f0363145fe412bd13f64df1827c6c5d709c9403e081fc" dependencies = [ "darling", "proc-macro2 1.0.9", @@ -2002,9 +2002,9 @@ dependencies = [ [[package]] name = "horrorshow" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad517632123d9c856735b04b02031b04dfb5ab1e69695bcfb96dee5e8804f0df" +checksum = "87ce7e0a1bc8e4489896abc94e5664e811a502a151bebfe113b3214fa181d3fb" [[package]] name = "hound" @@ -4022,18 +4022,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" +checksum = "e707fbbf255b8fc8c3b99abb91e7257a622caeb20a9818cbadbeeede4e0932ff" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" +checksum = "ac5d00fc561ba2724df6758a17de23df5914f20e41cb00f94d5b7ae42fffaff8" dependencies = [ "proc-macro2 1.0.9", "quote 1.0.3", diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 80d17119af..af44b056d5 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -17,11 +17,13 @@ pub enum CharacterAbility { max_angle: f32, }, BasicRanged { + prepare_duration: Duration, recover_duration: Duration, projectile: Projectile, projectile_body: Body, }, CastFireball { + prepare_duration: Duration, recover_duration: Duration, projectile: Projectile, projectile_body: Body, @@ -121,23 +123,26 @@ impl From<&CharacterAbility> for CharacterState { max_angle: *max_angle, }), CharacterAbility::BasicRanged { + prepare_duration, recover_duration, projectile, projectile_body, } => CharacterState::BasicRanged(basic_ranged::Data { exhausted: false, prepare_timer: Duration::default(), + prepare_duration: *prepare_duration, recover_duration: *recover_duration, projectile: projectile.clone(), projectile_body: *projectile_body, }), CharacterAbility::CastFireball { + prepare_duration, recover_duration, projectile, projectile_body, } => CharacterState::CastFireball(cast_fireball::Data { exhausted: false, - prepare_timer: Duration::default(), + prepare_duration: *prepare_duration, recover_duration: *recover_duration, projectile: projectile.clone(), projectile_body: *projectile_body, diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index a74d0738fb..8aa2cda5b1 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -89,6 +89,8 @@ impl ToolData { max_angle: 60.0, }], Bow(_) => vec![BasicRanged { + prepare_duration: Duration::from_millis(100), + recover_duration: Duration::from_millis(300), projectile: Projectile { hit_ground: vec![projectile::Effect::Stick], hit_wall: vec![projectile::Effect::Stick], @@ -104,7 +106,6 @@ impl ToolData { owner: None, }, projectile_body: Body::Object(object::Body::Arrow), - recover_duration: Duration::from_millis(300), }], Dagger(_) => vec![BasicMelee { buildup_duration: Duration::from_millis(100), @@ -126,6 +127,8 @@ impl ToolData { max_angle: 45.0, }, BasicRanged { + prepare_duration: Duration::from_millis(300), + recover_duration: Duration::from_millis(100), projectile: Projectile { hit_ground: vec![projectile::Effect::Vanish], hit_wall: vec![projectile::Effect::Vanish], @@ -141,9 +144,10 @@ impl ToolData { owner: None, }, projectile_body: Body::Object(object::Body::BoltFire), - recover_duration: Duration::from_millis(500), }, CastFireball { + prepare_duration: Duration::from_millis(800), + recover_duration: Duration::from_millis(300), projectile: Projectile { hit_ground: vec![ projectile::Effect::Explode { power: 1.4 }, @@ -161,7 +165,6 @@ impl ToolData { owner: None, }, projectile_body: Body::Object(object::Body::BoltFire), - recover_duration: Duration::from_millis(800), }, ], Shield(_) => vec![BasicBlock], @@ -177,6 +180,8 @@ impl ToolData { }, ], Possess => vec![BasicRanged { + prepare_duration: Duration::from_millis(300), + recover_duration: Duration::from_millis(300), projectile: Projectile { hit_ground: vec![projectile::Effect::Stick], hit_wall: vec![projectile::Effect::Stick], @@ -185,7 +190,6 @@ impl ToolData { owner: None, }, projectile_body: Body::Object(object::Body::ArrowSnake), - recover_duration: Duration::from_millis(300), }], }, Empty => vec![], diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index 9b219e8ca4..4301d0668b 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -8,6 +8,8 @@ use std::time::Duration; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Data { + /// How long we have to prepare the weapon + pub prepare_duration: Duration, /// How long we prepared the weapon already pub prepare_timer: Duration, /// How long the state has until exiting @@ -27,10 +29,13 @@ impl CharacterBehavior for Data { handle_move(data, &mut update); handle_jump(data, &mut update); - if !self.exhausted && data.inputs.holding_ability_key() { + if self.prepare_timer < self.prepare_duration + || !self.exhausted && data.inputs.holding_ability_key() + { // Prepare (draw the bow) update.character = CharacterState::BasicRanged(Data { prepare_timer: self.prepare_timer + Duration::from_secs_f32(data.dt.0), + prepare_duration: self.prepare_duration, recover_duration: self.recover_duration, projectile: self.projectile.clone(), projectile_body: self.projectile_body, @@ -51,6 +56,7 @@ impl CharacterBehavior for Data { update.character = CharacterState::BasicRanged(Data { prepare_timer: self.prepare_timer, + prepare_duration: self.prepare_duration, recover_duration: self.recover_duration, projectile: self.projectile.clone(), projectile_body: self.projectile_body, @@ -60,6 +66,7 @@ impl CharacterBehavior for Data { // Recovery update.character = CharacterState::BasicRanged(Data { prepare_timer: self.prepare_timer, + prepare_duration: self.prepare_duration, recover_duration: self .recover_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) diff --git a/common/src/states/cast_fireball.rs b/common/src/states/cast_fireball.rs index 50f5a5d5f6..7ebb9b28d8 100644 --- a/common/src/states/cast_fireball.rs +++ b/common/src/states/cast_fireball.rs @@ -8,8 +8,8 @@ use std::time::Duration; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Data { - /// How long we prepared the weapon already - pub prepare_timer: Duration, + /// How long we need to wait before we fire + pub prepare_duration: Duration, /// How long the state has until exiting pub recover_duration: Duration, /// Projectile @@ -27,10 +27,13 @@ impl CharacterBehavior for Data { handle_move(data, &mut update); handle_jump(data, &mut update); - if !self.exhausted && data.inputs.holding_ability_key() { + if self.prepare_duration != Duration::default() { // Prepare update.character = CharacterState::CastFireball(Data { - prepare_timer: self.prepare_timer + Duration::from_secs_f32(data.dt.0), + prepare_duration: self + .prepare_duration + .checked_sub(Duration::from_secs_f32(data.dt.0)) + .unwrap_or_default(), recover_duration: self.recover_duration, projectile: self.projectile.clone(), projectile_body: self.projectile_body, @@ -53,7 +56,7 @@ impl CharacterBehavior for Data { }); update.character = CharacterState::CastFireball(Data { - prepare_timer: self.prepare_timer, + prepare_duration: Duration::default(), recover_duration: self.recover_duration, projectile: self.projectile.clone(), projectile_body: self.projectile_body, @@ -62,7 +65,7 @@ impl CharacterBehavior for Data { } else if self.recover_duration != Duration::default() { // Recovery update.character = CharacterState::CastFireball(Data { - prepare_timer: self.prepare_timer, + prepare_duration: Duration::default(), recover_duration: self .recover_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) From 58585e081094662594be6a48965048c30642f0cf Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 24 Mar 2020 20:09:23 +0100 Subject: [PATCH 226/326] Better climbing, fireball impl --- common/src/comp/ability.rs | 24 ++------ common/src/comp/character_state.rs | 4 -- common/src/comp/inventory/item.rs | 6 +- common/src/states/cast_fireball.rs | 85 ---------------------------- common/src/states/climb.rs | 7 ++- common/src/states/mod.rs | 1 - common/src/sys/character_behavior.rs | 1 - voxygen/src/scene/figure/mod.rs | 9 --- 8 files changed, 14 insertions(+), 123 deletions(-) delete mode 100644 common/src/states/cast_fireball.rs diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index af44b056d5..ee9580abe0 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -17,12 +17,7 @@ pub enum CharacterAbility { max_angle: f32, }, BasicRanged { - prepare_duration: Duration, - recover_duration: Duration, - projectile: Projectile, - projectile_body: Body, - }, - CastFireball { + energy_cost: u32, prepare_duration: Duration, recover_duration: Duration, projectile: Projectile, @@ -70,11 +65,11 @@ impl CharacterAbility { .try_change_by(-300, EnergySource::Ability) .is_ok() }, - CharacterAbility::CastFireball { .. } => { + CharacterAbility::BasicRanged { energy_cost, .. } => { !data.physics.in_fluid && update .energy - .try_change_by(-500, EnergySource::Ability) + .try_change_by(-(*energy_cost as i32), EnergySource::Ability) .is_ok() }, _ => true, @@ -127,6 +122,7 @@ impl From<&CharacterAbility> for CharacterState { recover_duration, projectile, projectile_body, + energy_cost: _, } => CharacterState::BasicRanged(basic_ranged::Data { exhausted: false, prepare_timer: Duration::default(), @@ -135,18 +131,6 @@ impl From<&CharacterAbility> for CharacterState { projectile: projectile.clone(), projectile_body: *projectile_body, }), - CharacterAbility::CastFireball { - prepare_duration, - recover_duration, - projectile, - projectile_body, - } => CharacterState::CastFireball(cast_fireball::Data { - exhausted: false, - prepare_duration: *prepare_duration, - recover_duration: *recover_duration, - projectile: projectile.clone(), - projectile_body: *projectile_body, - }), CharacterAbility::Boost { duration, only_up } => CharacterState::Boost(boost::Data { duration: *duration, only_up: *only_up, diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index efb5e01d33..349de0564f 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -52,8 +52,6 @@ pub enum CharacterState { BasicMelee(basic_melee::Data), /// A basic ranged attack (e.g. bow) BasicRanged(basic_ranged::Data), - /// Cast a fireball - CastFireball(cast_fireball::Data), /// A force will boost you into a direction for some duration Boost(boost::Data), /// Dash forward and then attack @@ -72,7 +70,6 @@ impl CharacterState { CharacterState::Wielding | CharacterState::BasicMelee(_) | CharacterState::BasicRanged(_) - | CharacterState::CastFireball(_) | CharacterState::DashMelee(_) | CharacterState::TripleStrike(_) | CharacterState::TimedCombo(_) @@ -92,7 +89,6 @@ impl CharacterState { match self { CharacterState::BasicMelee(_) | CharacterState::BasicRanged(_) - | CharacterState::CastFireball(_) | CharacterState::TimedCombo(_) | CharacterState::DashMelee(_) | CharacterState::TripleStrike(_) => true, diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 8aa2cda5b1..7d4ea70906 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -89,6 +89,7 @@ impl ToolData { max_angle: 60.0, }], Bow(_) => vec![BasicRanged { + energy_cost: 0, prepare_duration: Duration::from_millis(100), recover_duration: Duration::from_millis(300), projectile: Projectile { @@ -127,6 +128,7 @@ impl ToolData { max_angle: 45.0, }, BasicRanged { + energy_cost: 0, prepare_duration: Duration::from_millis(300), recover_duration: Duration::from_millis(100), projectile: Projectile { @@ -145,7 +147,8 @@ impl ToolData { }, projectile_body: Body::Object(object::Body::BoltFire), }, - CastFireball { + BasicRanged { + energy_cost: 400, prepare_duration: Duration::from_millis(800), recover_duration: Duration::from_millis(300), projectile: Projectile { @@ -180,6 +183,7 @@ impl ToolData { }, ], Possess => vec![BasicRanged { + energy_cost: 0, prepare_duration: Duration::from_millis(300), recover_duration: Duration::from_millis(300), projectile: Projectile { diff --git a/common/src/states/cast_fireball.rs b/common/src/states/cast_fireball.rs deleted file mode 100644 index 7ebb9b28d8..0000000000 --- a/common/src/states/cast_fireball.rs +++ /dev/null @@ -1,85 +0,0 @@ -use crate::{ - comp::{Body, CharacterState, LightEmitter, Projectile, StateUpdate}, - event::ServerEvent, - states::utils::*, - sys::character_behavior::*, -}; -use std::time::Duration; - -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct Data { - /// How long we need to wait before we fire - pub prepare_duration: Duration, - /// How long the state has until exiting - pub recover_duration: Duration, - /// Projectile - pub projectile: Projectile, - /// Projectile - pub projectile_body: Body, - /// Whether the attack fired already - pub exhausted: bool, -} - -impl CharacterBehavior for Data { - fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - - handle_move(data, &mut update); - handle_jump(data, &mut update); - - if self.prepare_duration != Duration::default() { - // Prepare - update.character = CharacterState::CastFireball(Data { - prepare_duration: self - .prepare_duration - .checked_sub(Duration::from_secs_f32(data.dt.0)) - .unwrap_or_default(), - recover_duration: self.recover_duration, - projectile: self.projectile.clone(), - projectile_body: self.projectile_body, - exhausted: false, - }); - } else if !self.exhausted { - // Fire - let mut projectile = self.projectile.clone(); - projectile.set_owner(*data.uid); - update.server_events.push_front(ServerEvent::Shoot { - entity: data.entity, - dir: data.inputs.look_dir, - body: self.projectile_body, - light: Some(LightEmitter { - col: (0.72, 0.11, 0.11).into(), - ..Default::default() - }), - projectile, - gravity: None, - }); - - update.character = CharacterState::CastFireball(Data { - prepare_duration: Duration::default(), - recover_duration: self.recover_duration, - projectile: self.projectile.clone(), - projectile_body: self.projectile_body, - exhausted: true, - }); - } else if self.recover_duration != Duration::default() { - // Recovery - update.character = CharacterState::CastFireball(Data { - prepare_duration: Duration::default(), - recover_duration: self - .recover_duration - .checked_sub(Duration::from_secs_f32(data.dt.0)) - .unwrap_or_default(), - projectile: self.projectile.clone(), - projectile_body: self.projectile_body, - exhausted: true, - }); - return update; - } else { - // Done - update.character = CharacterState::Wielding; - } - - update - } -} diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index c14326f7d4..91fbaf87fb 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -26,8 +26,11 @@ impl CharacterBehavior for Data { update.character = CharacterState::Idle {}; } - // If no wall is in front of character ... - if data.physics.on_wall.is_none() || data.physics.on_ground { + // If no wall is in front of character or we stopped holding space: + if data.physics.on_wall.is_none() + || data.physics.on_ground + || !data.inputs.jump.is_pressed() + { if data.inputs.jump.is_pressed() { // They've climbed atop something, give them a boost update diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index f249cc5638..1dcf09c211 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -2,7 +2,6 @@ pub mod basic_block; pub mod basic_melee; pub mod basic_ranged; pub mod boost; -pub mod cast_fireball; pub mod climb; pub mod dash_melee; pub mod equipping; diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 8e9423510e..ebccef6258 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -183,7 +183,6 @@ impl<'a> System<'a> for Sys { CharacterState::TripleStrike(data) => data.behavior(&j), CharacterState::BasicMelee(data) => data.behavior(&j), CharacterState::BasicRanged(data) => data.behavior(&j), - CharacterState::CastFireball(data) => data.behavior(&j), CharacterState::Boost(data) => data.behavior(&j), CharacterState::DashMelee(data) => data.behavior(&j), CharacterState::TimedCombo(data) => data.behavior(&j), diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 036c3ad62a..91e0860c82 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -488,15 +488,6 @@ impl FigureMgr { skeleton_attr, ) }, - CharacterState::CastFireball(_) => { - anim::character::ShootAnimation::update_skeleton( - &target_base, - (active_tool_kind, time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) - }, CharacterState::Boost(_) => { anim::character::AttackAnimation::update_skeleton( &target_base, From f0ce0888100effc669c2a207d5cd5995953a0ae1 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 24 Mar 2020 20:31:54 +0100 Subject: [PATCH 227/326] Add lights and gravity again --- common/src/comp/ability.rs | 10 +++++++++- common/src/comp/inventory/item.rs | 19 ++++++++++++++++++- common/src/states/basic_ranged.rs | 16 +++++++++++----- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index ee9580abe0..908c844911 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1,5 +1,7 @@ use crate::{ - comp::{Body, CharacterState, EnergySource, Item, Projectile, StateUpdate}, + comp::{ + Body, CharacterState, EnergySource, Gravity, Item, LightEmitter, Projectile, StateUpdate, + }, states::*, sys::character_behavior::JoinData, }; @@ -22,6 +24,8 @@ pub enum CharacterAbility { recover_duration: Duration, projectile: Projectile, projectile_body: Body, + projectile_light: Option, + projectile_gravity: Option, }, Boost { duration: Duration, @@ -122,6 +126,8 @@ impl From<&CharacterAbility> for CharacterState { recover_duration, projectile, projectile_body, + projectile_light, + projectile_gravity, energy_cost: _, } => CharacterState::BasicRanged(basic_ranged::Data { exhausted: false, @@ -130,6 +136,8 @@ impl From<&CharacterAbility> for CharacterState { recover_duration: *recover_duration, projectile: projectile.clone(), projectile_body: *projectile_body, + projectile_light: *projectile_light, + projectile_gravity: *projectile_gravity, }), CharacterAbility::Boost { duration, only_up } => CharacterState::Boost(boost::Data { duration: *duration, diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 7d4ea70906..608341b3f2 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -2,7 +2,8 @@ use crate::{ assets::{self, Asset}, comp::{ body::{humanoid, object}, - projectile, Body, CharacterAbility, HealthChange, HealthSource, Projectile, + projectile, Body, CharacterAbility, Gravity, HealthChange, HealthSource, LightEmitter, + Projectile, }, effect::Effect, terrain::{Block, BlockKind}, @@ -107,6 +108,8 @@ impl ToolData { owner: None, }, projectile_body: Body::Object(object::Body::Arrow), + projectile_light: None, + projectile_gravity: Some(Gravity(0.1)), }], Dagger(_) => vec![BasicMelee { buildup_duration: Duration::from_millis(100), @@ -146,6 +149,12 @@ impl ToolData { owner: None, }, projectile_body: Body::Object(object::Body::BoltFire), + projectile_light: Some(LightEmitter { + col: (0.72, 0.11, 0.11).into(), + ..Default::default() + }), + + projectile_gravity: None, }, BasicRanged { energy_cost: 400, @@ -168,6 +177,12 @@ impl ToolData { owner: None, }, projectile_body: Body::Object(object::Body::BoltFire), + projectile_light: Some(LightEmitter { + col: (0.72, 0.11, 0.11).into(), + ..Default::default() + }), + + projectile_gravity: None, }, ], Shield(_) => vec![BasicBlock], @@ -194,6 +209,8 @@ impl ToolData { owner: None, }, projectile_body: Body::Object(object::Body::ArrowSnake), + projectile_light: None, + projectile_gravity: None, }], }, Empty => vec![], diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index 4301d0668b..25c965785d 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{Body, CharacterState, Gravity, Projectile, StateUpdate}, + comp::{Body, CharacterState, Gravity, LightEmitter, Projectile, StateUpdate}, event::ServerEvent, states::utils::*, sys::character_behavior::*, @@ -14,10 +14,10 @@ pub struct Data { pub prepare_timer: Duration, /// How long the state has until exiting pub recover_duration: Duration, - /// Projectile pub projectile: Projectile, - /// Projectile pub projectile_body: Body, + pub projectile_light: Option, + pub projectile_gravity: Option, /// Whether the attack fired already pub exhausted: bool, } @@ -39,6 +39,8 @@ impl CharacterBehavior for Data { recover_duration: self.recover_duration, projectile: self.projectile.clone(), projectile_body: self.projectile_body, + projectile_light: self.projectile_light, + projectile_gravity: self.projectile_gravity, exhausted: false, }); } else if !self.exhausted { @@ -49,9 +51,9 @@ impl CharacterBehavior for Data { entity: data.entity, dir: data.inputs.look_dir, body: self.projectile_body, - light: None, projectile, - gravity: Some(Gravity(0.1)), + light: self.projectile_light, + gravity: self.projectile_gravity, }); update.character = CharacterState::BasicRanged(Data { @@ -60,6 +62,8 @@ impl CharacterBehavior for Data { recover_duration: self.recover_duration, projectile: self.projectile.clone(), projectile_body: self.projectile_body, + projectile_light: self.projectile_light, + projectile_gravity: self.projectile_gravity, exhausted: true, }); } else if self.recover_duration != Duration::default() { @@ -73,6 +77,8 @@ impl CharacterBehavior for Data { .unwrap_or_default(), projectile: self.projectile.clone(), projectile_body: self.projectile_body, + projectile_light: self.projectile_light, + projectile_gravity: self.projectile_gravity, exhausted: true, }); return update; From 2117bb05d093ec82c6d9684babc48764f4d51af4 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 24 Mar 2020 22:03:11 +0100 Subject: [PATCH 228/326] Healing staff --- common/src/comp/ability.rs | 15 ++++++++++--- common/src/comp/character_state.rs | 2 +- common/src/comp/inventory/item.rs | 36 ++++++++++++++++++++++-------- common/src/states/basic_melee.rs | 12 +++++----- common/src/states/dash_melee.rs | 2 +- common/src/states/timed_combo.rs | 2 +- common/src/states/triple_strike.rs | 2 +- common/src/sys/combat.rs | 15 ++++++++----- server/src/sys/terrain.rs | 6 +++-- 9 files changed, 63 insertions(+), 29 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 908c844911..eb8cd665e0 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -12,9 +12,10 @@ use std::time::Duration; #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] pub enum CharacterAbility { BasicMelee { + energy_cost: u32, buildup_duration: Duration, recover_duration: Duration, - base_damage: u32, + base_healthchange: i32, range: f32, max_angle: f32, }, @@ -69,6 +70,13 @@ impl CharacterAbility { .try_change_by(-300, EnergySource::Ability) .is_ok() }, + CharacterAbility::BasicMelee { energy_cost, .. } => { + !data.physics.in_fluid + && update + .energy + .try_change_by(-(*energy_cost as i32), EnergySource::Ability) + .is_ok() + }, CharacterAbility::BasicRanged { energy_cost, .. } => { !data.physics.in_fluid && update @@ -110,14 +118,15 @@ impl From<&CharacterAbility> for CharacterState { CharacterAbility::BasicMelee { buildup_duration, recover_duration, - base_damage, + base_healthchange, range, max_angle, + energy_cost: _, } => CharacterState::BasicMelee(basic_melee::Data { exhausted: false, buildup_duration: *buildup_duration, recover_duration: *recover_duration, - base_damage: *base_damage, + base_healthchange: *base_healthchange, range: *range, max_angle: *max_angle, }), diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 349de0564f..851fe75f54 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -127,7 +127,7 @@ impl Component for CharacterState { #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Attacking { - pub base_damage: u32, + pub base_healthchange: i32, pub range: f32, pub max_angle: f32, pub applied: bool, diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 608341b3f2..9c051b8b6c 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -76,16 +76,18 @@ impl ToolData { base_damage: 20, }], Axe(_) => vec![BasicMelee { + energy_cost: 0, buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(100), - base_damage: 8, + base_healthchange: -8, range: 3.5, max_angle: 30.0, }], Hammer(_) => vec![BasicMelee { + energy_cost: 0, buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(300), - base_damage: 10, + base_healthchange: -10, range: 3.5, max_angle: 60.0, }], @@ -112,21 +114,19 @@ impl ToolData { projectile_gravity: Some(Gravity(0.1)), }], Dagger(_) => vec![BasicMelee { + energy_cost: 0, buildup_duration: Duration::from_millis(100), recover_duration: Duration::from_millis(400), - base_damage: 5, + base_healthchange: -5, range: 3.5, max_angle: 60.0, }], - Staff(_) => vec![ - //Intended behaviour for the healing sceptre: M1 -> Heal a single target (not a - // projectile, just a heal for the target.) Optional: Green flash of the healed - // target. M2: Heal everyone around the caster, including the - // caster + Staff(StaffKind::BasicStaff) => vec![ BasicMelee { + energy_cost: 0, buildup_duration: Duration::from_millis(0), recover_duration: Duration::from_millis(300), - base_damage: 1, + base_healthchange: -1, range: 10.0, max_angle: 45.0, }, @@ -185,6 +185,24 @@ impl ToolData { projectile_gravity: None, }, ], + Staff(StaffKind::Sceptre) => vec![ + BasicMelee { + energy_cost: 0, + buildup_duration: Duration::from_millis(0), + recover_duration: Duration::from_millis(300), + base_healthchange: -1, + range: 10.0, + max_angle: 45.0, + }, + BasicMelee { + energy_cost: 350, + buildup_duration: Duration::from_millis(0), + recover_duration: Duration::from_millis(1000), + base_healthchange: 15, + range: 10.0, + max_angle: 45.0, + }, + ], Shield(_) => vec![BasicBlock], Debug(kind) => match kind { DebugKind::Boost => vec![ diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index f05e638912..0b46200640 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -11,8 +11,8 @@ pub struct Data { pub buildup_duration: Duration, /// How long the state has until exiting pub recover_duration: Duration, - /// Base damage - pub base_damage: u32, + /// Base damage (negative) or healing (positive) + pub base_healthchange: i32, /// Max range pub range: f32, /// Max angle (45.0 will give you a 90.0 angle window) @@ -35,7 +35,7 @@ impl CharacterBehavior for Data { .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), recover_duration: self.recover_duration, - base_damage: self.base_damage, + base_healthchange: self.base_healthchange, range: self.range, max_angle: self.max_angle, exhausted: false, @@ -43,7 +43,7 @@ impl CharacterBehavior for Data { } else if !self.exhausted { // Hit attempt data.updater.insert(data.entity, Attacking { - base_damage: self.base_damage, + base_healthchange: self.base_healthchange, range: self.range, max_angle: self.max_angle.to_radians(), applied: false, @@ -53,7 +53,7 @@ impl CharacterBehavior for Data { update.character = CharacterState::BasicMelee(Data { buildup_duration: self.buildup_duration, recover_duration: self.recover_duration, - base_damage: self.base_damage, + base_healthchange: self.base_healthchange, range: self.range, max_angle: self.max_angle, exhausted: true, @@ -66,7 +66,7 @@ impl CharacterBehavior for Data { .recover_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), - base_damage: self.base_damage, + base_healthchange: self.base_healthchange, range: self.range, max_angle: self.max_angle, exhausted: true, diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 5d1d462a2c..2783b8278f 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -53,7 +53,7 @@ impl CharacterBehavior for Data { } else if !self.exhausted { // Hit attempt data.updater.insert(data.entity, Attacking { - base_damage: self.base_damage, + base_healthchange: -(self.base_damage as i32), range: 3.5, max_angle: 180_f32.to_radians(), applied: false, diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index ec50a25d2f..781f859dc9 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -52,7 +52,7 @@ impl CharacterBehavior for Data { else if !self.stage_exhausted { // Swing hits data.updater.insert(data.entity, Attacking { - base_damage: self.base_damage * (self.stage as u32 + 1), + base_healthchange: -((self.base_damage * (self.stage as u32 + 1)) as i32), range: 3.5, max_angle: 75_f32.to_radians(), applied: false, diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index f6b6ccebe6..7add9a345e 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -91,7 +91,7 @@ impl CharacterBehavior for Data { // Try to deal damage in second half of stage data.updater.insert(data.entity, Attacking { - base_damage: dmg, + base_healthchange: -(dmg as i32), range: 3.5, max_angle: 180_f32.to_radians(), applied: false, diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 9ddb10e45f..f37133bfc3 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -99,28 +99,33 @@ impl<'a> System<'a> for Sys { && ori2.angle_between(pos_b2 - pos2) < attack.max_angle + (rad_b / pos2.distance(pos_b2)).atan() { // Weapon gives base damage - let mut dmg = attack.base_damage; + let mut healthchange = attack.base_healthchange; // NPCs do less damage: if agent_maybe.is_some() { - dmg = (dmg / 2).max(1); + if healthchange > 0 { + healthchange = (healthchange / 2).max(1); + } + if healthchange < 0 { + healthchange = (healthchange / 2).min(-1); + } } if rand::random() { - dmg += 1; + healthchange = (healthchange as f32 * 1.2) as i32; } // Block if character_b.is_block() && ori_b.0.angle_between(pos.0 - pos_b.0) < BLOCK_ANGLE.to_radians() / 2.0 { - dmg = (dmg as f32 * (1.0 - BLOCK_EFFICIENCY)) as u32 + healthchange = (healthchange as f32 * (1.0 - BLOCK_EFFICIENCY)) as i32 } server_emitter.emit(ServerEvent::Damage { uid: *uid_b, change: HealthChange { - amount: -(dmg as i32), + amount: healthchange, cause: HealthSource::Attack { by: *uid }, }, }); diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index aabf8a0f9f..bb5a58661f 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -207,9 +207,10 @@ impl<'a> System<'a> for Sys { // We need the empty item so npcs can attack item: Item::empty(), ability1: Some(CharacterAbility::BasicMelee { + energy_cost: 0, buildup_duration: Duration::from_millis(0), recover_duration: Duration::from_millis(300), - base_damage: 2, + base_healthchange: -2, range: 3.5, max_angle: 60.0, }), @@ -303,9 +304,10 @@ impl<'a> System<'a> for Sys { "common.items.weapons.zweihander_sword_0", ), ability1: Some(CharacterAbility::BasicMelee { + energy_cost: 0, buildup_duration: Duration::from_millis(800), recover_duration: Duration::from_millis(200), - base_damage: 13, + base_healthchange: -13, range: 3.5, max_angle: 60.0, }), From 7851a407b145ce84054db6390000f33c8535730b Mon Sep 17 00:00:00 2001 From: Capucho Date: Tue, 24 Mar 2020 21:41:59 +0000 Subject: [PATCH 229/326] Fix the cursor lagging behind on password field --- Cargo.lock | 6 +++--- voxygen/Cargo.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22b3939864..18e18ac0b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -557,7 +557,7 @@ dependencies = [ [[package]] name = "conrod_core" version = "0.63.0" -source = "git+https://gitlab.com/veloren/conrod.git?branch=hide_text#92925b122dfed139169c7d7687b3ca15c0cb5a2e" +source = "git+https://gitlab.com/veloren/conrod.git?branch=capucho/hide_text_cursor_fix#e8a5b312ba0e3ab64efe54985d203137a34cd17d" dependencies = [ "conrod_derive", "copypasta", @@ -572,7 +572,7 @@ dependencies = [ [[package]] name = "conrod_derive" version = "0.63.0" -source = "git+https://gitlab.com/veloren/conrod.git?branch=hide_text#92925b122dfed139169c7d7687b3ca15c0cb5a2e" +source = "git+https://gitlab.com/veloren/conrod.git?branch=capucho/hide_text_cursor_fix#e8a5b312ba0e3ab64efe54985d203137a34cd17d" dependencies = [ "proc-macro2 0.4.30", "quote 0.6.13", @@ -582,7 +582,7 @@ dependencies = [ [[package]] name = "conrod_winit" version = "0.63.0" -source = "git+https://gitlab.com/veloren/conrod.git?branch=hide_text#92925b122dfed139169c7d7687b3ca15c0cb5a2e" +source = "git+https://gitlab.com/veloren/conrod.git?branch=capucho/hide_text_cursor_fix#e8a5b312ba0e3ab64efe54985d203137a34cd17d" [[package]] name = "const-random" diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 21049a4c4c..49cf4c60bf 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -24,8 +24,8 @@ gfx_device_gl = { version = "0.16.2", optional = true } gfx_window_glutin = "0.31.0" glutin = "0.21.1" winit = { version = "0.19.4", features = ["serde"] } -conrod_core = { git = "https://gitlab.com/veloren/conrod.git", branch = "hide_text" } -conrod_winit = { git = "https://gitlab.com/veloren/conrod.git", branch = "hide_text" } +conrod_core = { git = "https://gitlab.com/veloren/conrod.git", branch = "capucho/hide_text_cursor_fix" } +conrod_winit = { git = "https://gitlab.com/veloren/conrod.git", branch = "capucho/hide_text_cursor_fix" } euc = "0.3.0" # ECS From 7f02f5e7d26cf8b183e7586d6dc926f409c7c8a7 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Tue, 24 Mar 2020 23:03:57 +0100 Subject: [PATCH 230/326] Npcs can't be healed anymore --- common/src/sys/combat.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index f37133bfc3..ee6a12f46c 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -104,9 +104,8 @@ impl<'a> System<'a> for Sys { // NPCs do less damage: if agent_maybe.is_some() { if healthchange > 0 { - healthchange = (healthchange / 2).max(1); - } - if healthchange < 0 { + healthchange = 0; + } else if healthchange < 0 { healthchange = (healthchange / 2).min(-1); } } From 550dd144bc3298ad1ad53cfa6c4f4ea40cd4f07d Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Wed, 25 Mar 2020 01:41:43 +0100 Subject: [PATCH 231/326] new icon art --- assets/voxygen/element/icons/fire_bolt_1.png | 3 ++ assets/voxygen/element/icons/fire_spell_0.png | 3 ++ assets/voxygen/element/icons/heal_0.png | 3 ++ assets/voxygen/element/misc_bg/map_bg.png | 3 ++ assets/voxygen/element/misc_bg/map_frame.png | 3 ++ voxygen/src/hud/img_ids.rs | 9 +++- voxygen/src/hud/mod.rs | 1 + voxygen/src/hud/skillbar.rs | 49 +++++++++++++------ 8 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 assets/voxygen/element/icons/fire_bolt_1.png create mode 100644 assets/voxygen/element/icons/fire_spell_0.png create mode 100644 assets/voxygen/element/icons/heal_0.png create mode 100644 assets/voxygen/element/misc_bg/map_bg.png create mode 100644 assets/voxygen/element/misc_bg/map_frame.png diff --git a/assets/voxygen/element/icons/fire_bolt_1.png b/assets/voxygen/element/icons/fire_bolt_1.png new file mode 100644 index 0000000000..7839441a2a --- /dev/null +++ b/assets/voxygen/element/icons/fire_bolt_1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b0de03fc395a2136232308a43c9426e871f1855fd7040f107c0d21c544bc9791 +size 777 diff --git a/assets/voxygen/element/icons/fire_spell_0.png b/assets/voxygen/element/icons/fire_spell_0.png new file mode 100644 index 0000000000..dab7f87c07 --- /dev/null +++ b/assets/voxygen/element/icons/fire_spell_0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fcd5b65b0295b8467b90712d8a7d4ccab5bef8de8e1a24234f9628459ba8c746 +size 695 diff --git a/assets/voxygen/element/icons/heal_0.png b/assets/voxygen/element/icons/heal_0.png new file mode 100644 index 0000000000..bac626be04 --- /dev/null +++ b/assets/voxygen/element/icons/heal_0.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e68b8d6a36b444e17797015e439ed711b865f53a1992762139db2228ca25b686 +size 730 diff --git a/assets/voxygen/element/misc_bg/map_bg.png b/assets/voxygen/element/misc_bg/map_bg.png new file mode 100644 index 0000000000..f39100060f --- /dev/null +++ b/assets/voxygen/element/misc_bg/map_bg.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:19aa98947164b02fc3613cb875e50e02da97f084450881da7644d05e03987b9c +size 22768 diff --git a/assets/voxygen/element/misc_bg/map_frame.png b/assets/voxygen/element/misc_bg/map_frame.png new file mode 100644 index 0000000000..2992f2e7bb --- /dev/null +++ b/assets/voxygen/element/misc_bg/map_frame.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9dfc85c0c89230e6df821acafd6abb9968c2c1dca200709d1723f1a38e6f3d88 +size 11275 diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 32d025b463..9a1ffd7d18 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -117,7 +117,6 @@ image_ids! { flyingrod_m2: "voxygen.element.icons.debug_wand_m2", charge: "voxygen.element.icons.skill_charge_3", - // Icons flower: "voxygen.element.icons.item_flower", grass: "voxygen.element.icons.item_grass", @@ -203,6 +202,10 @@ image_ids! { ////////////////////////////////////////////////////////////////////////////////////////////////////// + // Map + map_bg: "voxygen.element.misc_bg.map_bg", + map_frame: "voxygen.element.misc_bg.map_frame", + // MiniMap mmap_frame: "voxygen.element.frames.mmap", mmap_frame_2: "voxygen.element.frames.mmap_frame", @@ -271,7 +274,9 @@ image_ids! { banner_top: "voxygen.element.frames.banner_top", - + // Icons + fire_spell_1: "voxygen.element.icons.fire_spell_0", + heal_0: "voxygen.element.icons.heal_0", // Buttons button: "voxygen.element.buttons.button", diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 395fb87927..13e7ff3476 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -56,6 +56,7 @@ const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0); const MENU_BG: Color = Color::Rgba(0.0, 0.0, 0.0, 0.4); //const TEXT_COLOR_2: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0); const TEXT_COLOR_3: Color = Color::Rgba(1.0, 1.0, 1.0, 0.1); +const BLACK: Color = Color::Rgba(0.0, 0.0, 0.0, 0.98); //const BG_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 0.8); const HP_COLOR: Color = Color::Rgba(0.33, 0.63, 0.0, 1.0); const LOW_HP_COLOR: Color = Color::Rgba(0.93, 0.59, 0.03, 1.0); diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 943190c11d..c8fa8ea2f4 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -1,6 +1,6 @@ use super::{ - img_ids::Imgs, BarNumbers, ShortcutNumbers, XpBar, CRITICAL_HP_COLOR, HP_COLOR, LOW_HP_COLOR, - MANA_COLOR, TEXT_COLOR, XP_COLOR, + img_ids::Imgs, BarNumbers, ShortcutNumbers, XpBar, BLACK, CRITICAL_HP_COLOR, HP_COLOR, + LOW_HP_COLOR, MANA_COLOR, TEXT_COLOR, XP_COLOR, }; use crate::{ i18n::{i18n_asset_key, VoxygenLocalization}, @@ -10,7 +10,7 @@ use crate::{ use common::{ assets::load_expect, comp::{ - item::{DebugKind, ToolData, ToolKind}, + item::{DebugKind, StaffKind, ToolData, ToolKind}, CharacterState, ControllerInputs, Energy, ItemKind, Loadout, Stats, }, }; @@ -19,7 +19,11 @@ use conrod_core::{ widget::{self, Button, Image, Rectangle, Text}, widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, }; -use std::time::{Duration, Instant}; +//use const_tweaker::tweak; +use std::time::{Duration, Instant}; // <- REMOVE THIS BEFORE MERGE! + +/*#[tweak(min = 0.5, max = 1.0, step = 0.01)] +const ALPHA: f32 = 0.90;*/ widget_ids! { struct Ids { @@ -703,6 +707,7 @@ impl<'a> Widget for Skillbar<'a> { ToolKind::Hammer(_) => self.imgs.twohhammer_m2, ToolKind::Axe(_) => self.imgs.twohaxe_m2, ToolKind::Bow(_) => self.imgs.bow_m2, + ToolKind::Staff(StaffKind::Sceptre) => self.imgs.heal_0, ToolKind::Staff(_) => self.imgs.staff_m2, ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m2, _ => self.imgs.twohaxe_m2, @@ -819,19 +824,35 @@ impl<'a> Widget for Skillbar<'a> { } Image::new(self.imgs.skillbar_slot_bg) .w_h(19.5 * scale, 19.5 * scale) - .color(Some(BG_COLOR)) + .color( + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Staff(StaffKind::BasicStaff) => Some(BLACK), + _ => Some(BG_COLOR), + }, + _ => Some(BG_COLOR), + }, + ) .middle_of(state.ids.slot1) .set(state.ids.slot1_bg, ui); // TODO: Changeable slot image - /*Image::new(self.imgs.charge) - .w_h(18.0 * scale, 18.0 * scale) - .color(if self.energy.current() as f64 >= 200.0 { - Some(Color::Rgba(1.0, 1.0, 1.0, 1.0)) - } else { - Some(Color::Rgba(0.4, 0.4, 0.4, 1.0)) - }) - .middle_of(state.ids.slot1_bg) - .set(state.ids.slot1_icon, ui);*/ + match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { + Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + ToolKind::Staff(StaffKind::BasicStaff) => { + Image::new(self.imgs.fire_spell_1) + .w_h(18.0 * scale, 18.0 * scale) + .color(if self.energy.current() as f64 >= 500.0 { + Some(Color::Rgba(1.0, 1.0, 1.0, 1.0)) + } else { + Some(Color::Rgba(0.4, 0.4, 0.4, 1.0)) + }) + .middle_of(state.ids.slot1_bg) + .set(state.ids.slot1_icon, ui); + }, + _ => {}, + }, + _ => {}, + } // Slot 6 Image::new(self.imgs.skillbar_slot) .w_h(20.0 * scale, 20.0 * scale) From a6537ed69b3f3761a945d1a3d3894bc42dee3778 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Wed, 25 Mar 2020 00:15:06 -0400 Subject: [PATCH 232/326] starting foot movement with attacks, clearing some dead code --- voxygen/src/anim/character/attack.rs | 107 +++++-- voxygen/src/anim/character/charge.rs | 386 +----------------------- voxygen/src/anim/character/cidle.rs | 285 ----------------- voxygen/src/anim/character/crun.rs | 175 ----------- voxygen/src/anim/character/equip.rs | 88 ++++-- voxygen/src/anim/character/idleequip.rs | 252 ---------------- voxygen/src/anim/character/mod.rs | 6 +- voxygen/src/anim/character/shoot.rs | 198 +++--------- voxygen/src/anim/character/sneak.rs | 147 --------- voxygen/src/scene/figure/mod.rs | 22 +- 10 files changed, 208 insertions(+), 1458 deletions(-) delete mode 100644 voxygen/src/anim/character/cidle.rs delete mode 100644 voxygen/src/anim/character/crun.rs delete mode 100644 voxygen/src/anim/character/idleequip.rs delete mode 100644 voxygen/src/anim/character/sneak.rs diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index de331b7ccf..d209f5fa22 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -9,12 +9,12 @@ pub struct Input { pub struct AttackAnimation; impl Animation for AttackAnimation { - type Dependency = (Option, f64); + type Dependency = (Option, f32, f64); type Skeleton = CharacterSkeleton; fn update_skeleton( skeleton: &Self::Skeleton, - (active_tool_kind, _global_time): Self::Dependency, + (active_tool_kind, velocity, _global_time): Self::Dependency, anim_time: f64, rate: &mut f32, skeleton_attr: &SkeletonAttr, @@ -25,10 +25,9 @@ impl Animation for AttackAnimation { let lab = 1.0; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 15.0).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 13.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 15.0).sin()); - + * ((anim_time as f32 * lab as f32 * 13.0).sin()); let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); @@ -52,7 +51,7 @@ impl Animation for AttackAnimation { Some(ToolKind::Sword(_)) => { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - 0.0 + skeleton_attr.neck_forward, + -2.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 14.0, ); next.head.ori = Quaternion::rotation_z(slow * 0.08) @@ -91,13 +90,18 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(slow * 1.5) * Quaternion::rotation_z(1.4 + slow * 0.5); next.control.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, foot * 3.0, 8.0); + next.l_foot.offset = Vec3::new(-3.4, foot * 3.0 + slow * -5.0, 8.0); next.l_foot.ori = Quaternion::rotation_x(foot * -0.6); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, foot * -3.0, 8.0); + next.r_foot.offset = Vec3::new(3.4, foot * -3.0 + slow * 5.0, 8.0); next.r_foot.ori = Quaternion::rotation_x(foot * 0.6); next.r_foot.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Axe(_)) => { next.head.offset = Vec3::new( @@ -145,6 +149,11 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(-0.3) * Quaternion::rotation_z(-0.7 + slowax * -1.9); next.control.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Hammer(_)) => { next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); @@ -159,13 +168,13 @@ impl Animation for AttackAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right + slower * 3.0, - 0.0 + skeleton_attr.neck_forward + slower * -3.0, + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 12.0, ); - next.head.ori = Quaternion::rotation_z(slower * 0.25) - * Quaternion::rotation_x(0.0 + slower * 0.2) - * Quaternion::rotation_y(slower * 0.2); + next.head.ori = Quaternion::rotation_z(slower * 0.05) + * Quaternion::rotation_x(0.0 + slower * 0.05) + * Quaternion::rotation_y(slower * 0.05); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, 7.0); @@ -181,12 +190,53 @@ impl Animation for AttackAnimation { next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); next.shorts.ori = next.chest.ori * -0.15; next.shorts.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + if velocity > 0.5 { + next.l_foot.offset = Vec3::new(-3.4, foot * -2.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -0.4) + * Quaternion::rotation_z((slower * 0.6).max(0.0)); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, foot * 2.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 0.4) + * Quaternion::rotation_z((slower * 0.6).max(0.0)); + next.r_foot.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.15); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + } else { + next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0 + (slower * 2.5).max(0.0)); + next.l_foot.ori = Quaternion::rotation_x(slower * -0.2 - 0.2) + * Quaternion::rotation_z((slower * 1.0).max(0.0)); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, 3.5 - slower * 2.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(slower * 0.1) + * Quaternion::rotation_z((slower * 0.5).max(0.0)); + next.r_foot.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + } next.control.offset = Vec3::new(-6.0, 3.0, 8.0 + slower * 5.0); next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(1.4 + 1.57); next.control.scale = Vec3::one(); + + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Staff(_)) => { next.head.offset = Vec3::new( @@ -233,6 +283,11 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(slow * 1.5) * Quaternion::rotation_z(1.4 + slow * 0.5); next.control.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Shield(_)) => { next.head.offset = Vec3::new( @@ -285,6 +340,11 @@ impl Animation for AttackAnimation { * Quaternion::rotation_x(0.0 + accel_med * -0.8) * Quaternion::rotation_y(0.0 + accel_med * -0.4); next.main.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Bow(_)) => { next.head.offset = Vec3::new( @@ -335,6 +395,11 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.control.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Dagger(_)) => { next.head.offset = Vec3::new( @@ -387,6 +452,11 @@ impl Animation for AttackAnimation { * Quaternion::rotation_x(0.0 + accel_med * -0.8) * Quaternion::rotation_y(0.0 + accel_med * -0.4); next.main.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, Some(ToolKind::Debug(_)) => { next.head.offset = Vec3::new( @@ -439,9 +509,15 @@ impl Animation for AttackAnimation { * Quaternion::rotation_x(0.0 + accel_med * -0.8) * Quaternion::rotation_y(0.0 + accel_med * -0.4); next.main.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, _ => {}, } + next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); next.l_shoulder.ori = Quaternion::rotation_x(0.0); next.l_shoulder.scale = Vec3::one() * 1.1; @@ -458,11 +534,6 @@ impl Animation for AttackAnimation { next.lantern.ori = Quaternion::rotation_x(0.0); next.lantern.scale = Vec3::one() * 0.0; - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); next.l_control.ori = Quaternion::rotation_x(0.0); next.l_control.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/charge.rs b/voxygen/src/anim/character/charge.rs index fe13b51fe8..ea7d2d34ad 100644 --- a/voxygen/src/anim/character/charge.rs +++ b/voxygen/src/anim/character/charge.rs @@ -1,6 +1,5 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use common::comp::item::ToolKind; -use std::f32::consts::PI; use vek::*; pub struct Input { @@ -21,7 +20,7 @@ impl Animation for ChargeAnimation { ) -> Self::Skeleton { *rate = 1.0; let mut next = (*skeleton).clone(); - + let constant = 8.0; let lab = 1.0; let foot = (((5.0) @@ -29,36 +28,18 @@ impl Animation for ChargeAnimation { .sqrt()) * ((anim_time as f32 * lab as f32 * 15.0).sin()); - let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); - let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); - let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); - let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin(); - let slow = (((5.0) / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * lab as f32 * 12.4).sin()); - let slower = (((5.0) - / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 4.0).sin()); - let slowax = (((5.0) - / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()); - let constant = 8.0; let wave_cos = (((5.0) / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 2.4).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * constant as f32 * 1.5).sin()); - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - 5.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 19.0 + wave_cos * 2.0, - ); + match active_tool_kind { //TODO: Inventory @@ -98,9 +79,9 @@ impl Animation for ChargeAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 3.0); - next.control.ori = Quaternion::rotation_x(-1.2) - * Quaternion::rotation_y(slow * 1.5) - * Quaternion::rotation_z(1.4 + slow * 0.5); + next.control.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(1.4 + slow * 0.1); next.control.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, foot * 3.0, 8.0); next.l_foot.ori = Quaternion::rotation_x(foot * -0.6); @@ -109,360 +90,17 @@ impl Animation for ChargeAnimation { next.r_foot.offset = Vec3::new(3.4, foot * -3.0, 8.0); next.r_foot.ori = Quaternion::rotation_x(foot * 0.6); next.r_foot.scale = Vec3::one(); - }, - Some(ToolKind::Axe(_)) => { - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right + slowax * 2.0, - -2.0 + skeleton_attr.neck_forward + slowax * -2.0, - skeleton_attr.neck_height + 20.0, - ); - next.head.ori = Quaternion::rotation_z(slowax * 0.25) - * Quaternion::rotation_x(0.0 + slowax * 0.2) - * Quaternion::rotation_y(slowax * 0.2); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(slowax * 0.2) - * Quaternion::rotation_x(0.0 + slowax * 0.2) - * Quaternion::rotation_y(slowax * 0.2); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(slowax * 0.1) - * Quaternion::rotation_x(0.0 + slowax * 0.1) - * Quaternion::rotation_y(slowax * 0.1); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(slowax * 0.08) - * Quaternion::rotation_x(0.0 + slowax * 0.08) - * Quaternion::rotation_y(slowax * 0.08); - next.shorts.scale = Vec3::one(); - - next.l_hand.offset = Vec3::new(-4.0, 3.0, 2.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_z(3.14 - 0.3) - * Quaternion::rotation_y(-0.8); - next.l_hand.scale = Vec3::one() * 1.08; - next.r_hand.offset = Vec3::new(-2.5, 9.0, 0.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_z(3.14 - 0.3) - * Quaternion::rotation_y(-0.8); - next.r_hand.scale = Vec3::one() * 1.06; - next.main.offset = Vec3::new(-6.0, 10.0, -5.0); - next.main.ori = Quaternion::rotation_x(1.27) - * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(-0.8); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(0.0, 0.0 + slowax * 8.2, 6.0); - next.control.ori = Quaternion::rotation_x(0.8) - * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(-0.7 + slowax * -1.9); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Hammer(_)) => { - next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); - - //0,1,5 - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 6.0, -1.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right + slower * 3.0, - -2.0 + skeleton_attr.neck_forward + slower * -3.0, - skeleton_attr.neck_height + 19.0, - ); - next.head.ori = Quaternion::rotation_z(slower * 0.25) - * Quaternion::rotation_x(0.0 + slower * 0.2) - * Quaternion::rotation_y(slower * 0.2); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(slower * 0.2) - * Quaternion::rotation_x(0.0 + slower * 0.2) - * Quaternion::rotation_y(slower * 0.2); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(slower * 0.1) - * Quaternion::rotation_x(0.0 + slower * 0.1) - * Quaternion::rotation_y(slower * 0.1); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(slower * 0.08) - * Quaternion::rotation_x(0.0 + slower * 0.08) - * Quaternion::rotation_y(slower * 0.08); - next.shorts.scale = Vec3::one(); - - next.control.offset = Vec3::new(-6.0, 3.0, 8.0 + slower * 5.0); - next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(1.4 + 1.57); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Staff(_)) => { - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * 0.8, - skeleton_attr.neck_height + 21.0, - ); - next.head.ori = Quaternion::rotation_z(decel * 0.25) - * Quaternion::rotation_x(0.0 + decel * 0.1) - * Quaternion::rotation_y(decel * -0.1); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * -0.2) - * Quaternion::rotation_x(0.0 + decel * -0.2) - * Quaternion::rotation_y(decel * 0.2); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.1) - * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.08) - * Quaternion::rotation_x(0.0 + decel * -0.08) - * Quaternion::rotation_y(decel * 0.08); - next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(0.0, 0.0, 10.0); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 6.0, -4.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); - next.control.ori = Quaternion::rotation_x(-1.2) - * Quaternion::rotation_y(slow * 1.5) - * Quaternion::rotation_z(1.4 + slow * 0.5); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Shield(_)) => { - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * 0.8, - skeleton_attr.neck_height + 21.0, - ); - next.head.ori = Quaternion::rotation_z(decel * 0.25) - * Quaternion::rotation_x(0.0 + decel * 0.1) - * Quaternion::rotation_y(decel * -0.1); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * -0.2) - * Quaternion::rotation_x(0.0 + decel * -0.2) - * Quaternion::rotation_y(decel * 0.2); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.1) - * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.08) - * Quaternion::rotation_x(0.0 + decel * -0.08) - * Quaternion::rotation_y(decel * 0.08); - next.shorts.scale = Vec3::one(); - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Bow(_)) => { - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * 0.8, - skeleton_attr.neck_height + 21.0, - ); - next.head.ori = Quaternion::rotation_z(decel * 0.25) - * Quaternion::rotation_x(0.0 + decel * 0.1) - * Quaternion::rotation_y(decel * -0.1); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * -0.2) - * Quaternion::rotation_x(0.0 + decel * -0.2) - * Quaternion::rotation_y(decel * 0.2); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.1) - * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.08) - * Quaternion::rotation_x(0.0 + decel * -0.08) - * Quaternion::rotation_y(decel * 0.08); - next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); - next.l_hand.ori = Quaternion::rotation_x(1.27) - * Quaternion::rotation_y(-0.6) - * Quaternion::rotation_z(-0.3); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(3.0, -1.0, -6.0); - next.r_hand.ori = Quaternion::rotation_x(1.27) - * Quaternion::rotation_y(-0.6) - * Quaternion::rotation_z(-0.3); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(3.0, 2.0, -13.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.3) - * Quaternion::rotation_z(-0.6); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Dagger(_)) => { - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * 0.8, - skeleton_attr.neck_height + 21.0, - ); - next.head.ori = Quaternion::rotation_z(decel * 0.25) - * Quaternion::rotation_x(0.0 + decel * 0.1) - * Quaternion::rotation_y(decel * -0.1); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * -0.2) - * Quaternion::rotation_x(0.0 + decel * -0.2) - * Quaternion::rotation_y(decel * 0.2); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.1) - * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.08) - * Quaternion::rotation_x(0.0 + decel * -0.08) - * Quaternion::rotation_y(decel * 0.08); - next.shorts.scale = Vec3::one(); - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Debug(_)) => { - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * 0.8, - skeleton_attr.neck_height + 21.0, - ); - next.head.ori = Quaternion::rotation_z(decel * 0.25) - * Quaternion::rotation_x(0.0 + decel * 0.1) - * Quaternion::rotation_y(decel * -0.1); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * -0.2) - * Quaternion::rotation_x(0.0 + decel * -0.2) - * Quaternion::rotation_y(decel * 0.2); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.1) - * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.08) - * Quaternion::rotation_x(0.0 + decel * -0.08) - * Quaternion::rotation_y(decel * 0.08); - next.shorts.scale = Vec3::one(); - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); }, _ => {}, } + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 12.0, + ); + next.head.ori = Quaternion::rotation_x(0.5); + next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); next.l_shoulder.ori = Quaternion::rotation_x(0.0); next.l_shoulder.scale = Vec3::one() * 1.1; diff --git a/voxygen/src/anim/character/cidle.rs b/voxygen/src/anim/character/cidle.rs deleted file mode 100644 index 80613193cb..0000000000 --- a/voxygen/src/anim/character/cidle.rs +++ /dev/null @@ -1,285 +0,0 @@ -use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; - -use common::comp::item::ToolKind; -use std::{f32::consts::PI, ops::Mul}; -use vek::*; - -pub struct Input { - pub attack: bool, -} -pub struct CidleAnimation; - -impl Animation for CidleAnimation { - type Dependency = (Option, f64); - type Skeleton = CharacterSkeleton; - - fn update_skeleton( - skeleton: &Self::Skeleton, - (active_tool_kind, global_time): Self::Dependency, - anim_time: f64, - _rate: &mut f32, - skeleton_attr: &SkeletonAttr, - ) -> Self::Skeleton { - let mut next = (*skeleton).clone(); - - let wave_ultra_slow = (anim_time as f32 * 0.5 + PI).sin(); - let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); - let wave_slow_cos = (anim_time as f32 * 6.0 + PI).cos(); - let wave_slow = (anim_time as f32 * 6.0 + PI).sin(); - - let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 1.5) - .floor() - .mul(7331.0) - .sin() - * 0.3, - ((global_time + anim_time) as f32 / 1.5) - .floor() - .mul(1337.0) - .sin() - * 0.15, - ); - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right + wave_slow_cos * 0.5, - -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 21.0 + wave_ultra_slow * 0.6, - ); - next.head.ori = - Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 7.0 + wave_ultra_slow * 0.5); - next.chest.ori = Quaternion::rotation_y(wave_ultra_slow_cos * 0.04); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 5.0 + wave_ultra_slow * 0.5); - next.belt.ori = Quaternion::rotation_y(wave_ultra_slow_cos * 0.03); - next.belt.scale = Vec3::one() * 1.02; - - next.shorts.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 2.0 + wave_ultra_slow * 0.5); - next.shorts.ori = Quaternion::rotation_x(0.0); - next.shorts.scale = Vec3::one(); - - match active_tool_kind { - //TODO: Inventory - Some(ToolKind::Sword(_)) => { - next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0); - next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2); - next.l_hand.scale = Vec3::one() * 1.04; - next.r_hand.offset = Vec3::new(1.25, -5.5, -8.0); - next.r_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 0.0, -6.0); - next.main.ori = Quaternion::rotation_x(-0.1) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Axe(_)) => { - next.l_hand.offset = Vec3::new( - -6.5 + wave_ultra_slow_cos * 1.0, - -0.5 + wave_ultra_slow_cos * 0.5, - 6.0 + wave_ultra_slow * 1.0, - ); - next.l_hand.ori = Quaternion::rotation_x(0.13) * Quaternion::rotation_z(-0.25); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new( - -3.0 + wave_ultra_slow_cos * 1.0, - 6.5 + wave_ultra_slow_cos * 0.5, - 6.0 + wave_ultra_slow * 1.0, - ); - next.r_hand.ori = Quaternion::rotation_x(0.13) - * Quaternion::rotation_z(2.98) - * Quaternion::rotation_y(-0.50); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -5.0 + skeleton_attr.weapon_x + wave_ultra_slow_cos * 1.0, - 8.5 + skeleton_attr.weapon_y + wave_ultra_slow_cos * 0.5, - -0.5 + wave_ultra_slow * 1.0, - ); - next.main.ori = Quaternion::rotation_x(1.70) - * Quaternion::rotation_y(-0.25) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Hammer(_)) => { - next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); - next.l_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); - next.r_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - 5.0 + skeleton_attr.weapon_x, - 8.75 + skeleton_attr.weapon_y, - -2.5, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(-1.27) - * Quaternion::rotation_z(wave_ultra_slow * 0.2); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Staff(_)) => { - next.l_hand.offset = Vec3::new( - -6.0 + wave_ultra_slow_cos * 1.0, - 1.0 + wave_ultra_slow_cos * 0.5, - 5.0 + wave_ultra_slow * 1.0, - ); - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.0; - next.r_hand.offset = Vec3::new( - -6.0 + wave_ultra_slow_cos * 1.0, - -1.5 + wave_ultra_slow_cos * 0.5, - -2.0 + wave_ultra_slow * 1.0, - ); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x + wave_ultra_slow_cos * 1.0, - 8.5 + skeleton_attr.weapon_y + wave_ultra_slow_cos * 0.5, - 17.0 + wave_ultra_slow * 1.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3 + PI) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Shield(_)) => { - next.l_hand.offset = Vec3::new( - -6.0 + wave_ultra_slow_cos * 1.0, - 3.5 + wave_ultra_slow_cos * 0.5, - 0.0 + wave_ultra_slow * 1.0, - ); - next.l_hand.ori = Quaternion::rotation_x(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new( - -6.0 + wave_ultra_slow_cos * 1.0, - 3.0 + wave_ultra_slow_cos * 0.5, - -2.0 + wave_ultra_slow * 1.0, - ); - next.r_hand.ori = Quaternion::rotation_x(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x + wave_ultra_slow_cos * 1.0, - 4.5 + skeleton_attr.weapon_y + wave_ultra_slow_cos * 0.5, - 0.0 + wave_ultra_slow * 1.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Bow(_)) => { - next.l_hand.offset = Vec3::new( - -1.0 + wave_ultra_slow_cos * 1.0, - 3.0 + wave_ultra_slow_cos * 0.5, - 5.0 + wave_ultra_slow * 1.0, - ); - next.l_hand.ori = Quaternion::rotation_x(PI / 2.0) - * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new( - 1.0 + wave_ultra_slow_cos * 1.0, - 8.0 + wave_ultra_slow_cos * 0.5, - 2.5 + wave_ultra_slow * 1.0, - ); - next.r_hand.ori = Quaternion::rotation_x(PI / 2.0) - * Quaternion::rotation_y(0.3) - * Quaternion::rotation_z(0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -4.0 + skeleton_attr.weapon_x + wave_ultra_slow_cos * 1.0, - 15.0 + skeleton_attr.weapon_y + wave_ultra_slow_cos * 0.5, - -4.0 + wave_ultra_slow * 1.0, - ); - next.main.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.4) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Dagger(_)) => { - next.l_hand.offset = Vec3::new( - -6.0 + wave_ultra_slow_cos * 1.0, - 3.5 + wave_ultra_slow_cos * 0.5, - 0.0 + wave_ultra_slow * 1.0, - ); - next.l_hand.ori = Quaternion::rotation_x(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x, - 4.5 + skeleton_attr.weapon_y, - 0.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Debug(_)) => { - next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); - next.l_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); - next.r_hand.ori = Quaternion::rotation_x(1.27 + wave_ultra_slow * -0.1) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - 5.0 + skeleton_attr.weapon_x, - 8.75 + skeleton_attr.weapon_y, - -2.5, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(-1.27) - * Quaternion::rotation_z(wave_ultra_slow * 0.2); - next.main.scale = Vec3::one(); - }, - _ => {}, - } - next.l_foot.offset = Vec3::new(-3.4, -1.5, 8.0 + wave_slow * 0.2); - next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.015); - next.l_foot.scale = Vec3::one(); - - next.r_foot.offset = Vec3::new(3.4, 3.0, 8.0 + wave_slow_cos * 0.2); - next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.015); - next.r_foot.scale = Vec3::one(); - - next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 5.0); - next.l_shoulder.ori = Quaternion::rotation_x(0.0); - next.l_shoulder.scale = Vec3::one() * 1.1; - - next.r_shoulder.offset = Vec3::new(5.0, 0.0, 5.0); - next.r_shoulder.ori = Quaternion::rotation_x(0.0); - next.r_shoulder.scale = Vec3::one() * 1.1; - - next.glider.offset = Vec3::new(0.0, 5.0, 0.0); - next.glider.ori = Quaternion::rotation_y(0.0); - next.glider.scale = Vec3::one() * 0.0; - - next.lantern.offset = Vec3::new(0.0, 0.0, 0.0); - next.lantern.ori = Quaternion::rotation_x(0.0); - next.lantern.scale = Vec3::one() * 0.0; - - next.torso.offset = Vec3::new(0.0, -0.2, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - - next - } -} diff --git a/voxygen/src/anim/character/crun.rs b/voxygen/src/anim/character/crun.rs deleted file mode 100644 index fe28dc3770..0000000000 --- a/voxygen/src/anim/character/crun.rs +++ /dev/null @@ -1,175 +0,0 @@ -use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; -use common::comp::item::ToolKind; -use std::{f32::consts::PI, ops::Mul}; -use vek::*; - -pub struct WieldAnimation; - -impl Animation for WieldAnimation { - type Dependency = (f32, f64); - type Skeleton = CharacterSkeleton; - - fn update_skeleton( - skeleton: &Self::Skeleton, - (velocity, global_time): Self::Dependency, - anim_time: f64, - rate: &mut f32, - skeleton_attr: &SkeletonAttr, - ) -> Self::Skeleton { - let mut next = (*skeleton).clone(); - - let wave = (anim_time as f32 * 12.0).sin(); - let wave_cos = (anim_time as f32 * 12.0).cos(); - let wave_diff = (anim_time as f32 * 12.0 + PI / 2.0).sin(); - let wave_cos_dub = (anim_time as f32 * 24.0).cos(); - let wave_stop = (anim_time as f32 * 5.0).min(PI / 2.0).sin(); - - let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 2.0) - .floor() - .mul(7331.0) - .sin() - * 0.2, - ((global_time + anim_time) as f32 / 2.0) - .floor() - .mul(1337.0) - .sin() - * 0.1, - ); - - match ToolKind::Bow { - //TODO: Inventory - Some(ToolKind::Sword(_)) => { - next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0); - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.04; - next.r_hand.offset = Vec3::new(0.0, -6.0, -8.0); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 0.0, -6.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-8.0, 4.0, 6.0); - next.control.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.control.scale = Vec3::one(); - }, - ToolKind::Axe => { - next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.weapon.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x, - 4.5 + skeleton_attr.weapon_y, - 0.0, - ); - next.weapon.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.weapon.scale = Vec3::one(); - }, - ToolKind::Hammer => { - next.l_hand.offset = Vec3::new(-7.0, 8.25, 3.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(-1.2) - * Quaternion::rotation_z(wave * -0.25); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(7.0, 7.0, -1.5); - next.r_hand.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(-1.2) - * Quaternion::rotation_z(wave * -0.25); - next.r_hand.scale = Vec3::one() * 1.01; - next.weapon.offset = Vec3::new( - 5.0 + skeleton_attr.weapon_x, - 8.75 + skeleton_attr.weapon_y, - -2.0, - ); - next.weapon.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(-1.2) - * Quaternion::rotation_z(wave * -0.25); - next.weapon.scale = Vec3::one(); - }, - ToolKind::Staff => { - next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.weapon.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x, - 4.5 + skeleton_attr.weapon_y, - 0.0, - ); - next.weapon.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.weapon.scale = Vec3::one(); - }, - ToolKind::SwordShield => { - next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.weapon.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x, - 4.5 + skeleton_attr.weapon_y, - 0.0, - ); - next.weapon.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.weapon.scale = Vec3::one(); - }, - ToolKind::Bow => { - next.l_hand.offset = Vec3::new(-4.0, 5.0, 0.0); - next.l_hand.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(-1.9) - * Quaternion::rotation_z(0.85); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(2.0, 8.0, -3.5); - next.r_hand.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(-1.7) - * Quaternion::rotation_z(0.85); - next.r_hand.scale = Vec3::one() * 1.01; - next.weapon.offset = Vec3::new( - 9.0 + skeleton_attr.weapon_x, - 10.0 + skeleton_attr.weapon_y, - -3.0, - ); - next.weapon.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(-1.7) - * Quaternion::rotation_z(0.85 + 3.14); - next.weapon.scale = Vec3::one(); - }, - ToolKind::Daggers => { - next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.weapon.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x, - 4.5 + skeleton_attr.weapon_y, - 0.0, - ); - next.weapon.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.weapon.scale = Vec3::one(); - }, - } - - next - } -} diff --git a/voxygen/src/anim/character/equip.rs b/voxygen/src/anim/character/equip.rs index 35fb623223..0d13df9c37 100644 --- a/voxygen/src/anim/character/equip.rs +++ b/voxygen/src/anim/character/equip.rs @@ -12,33 +12,31 @@ impl Animation for EquipAnimation { fn update_skeleton( skeleton: &Self::Skeleton, - (active_tool_kind, _velocity, global_time): Self::Dependency, + (active_tool_kind, velocity, global_time): Self::Dependency, anim_time: f64, - _rate: &mut f32, + rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { + *rate = 1.0; let mut next = (*skeleton).clone(); + let lab = 1.0; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.6).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.6).sin()); + * ((anim_time as f32 * lab as f32 * 10.6).sin()); let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 10.6).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.6).sin()); - let long = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.8).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 0.8).sin()); + * ((anim_time as f32 * lab as f32 * 10.6).sin()); - let equip_slow = 1.0 + (anim_time as f32 * 1.2 + PI).cos(); - let equip_slowa = 1.0 + (anim_time as f32 * 1.2 + PI / 4.0).cos(); + let equip_slow = 1.0 + (anim_time as f32 * 12.0 + PI).cos(); + let equip_slowa = 1.0 + (anim_time as f32 * 12.0 + PI / 4.0).cos(); - let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); - let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); + let wave_ultra_slow = (anim_time as f32 * 10.0 + PI).sin(); + let wave_ultra_slow_cos = (anim_time as f32 * 30.0 + PI).cos(); - let wave = (anim_time as f32 * 1.0).sin(); + let wave = (anim_time as f32 * 10.0).sin(); match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { @@ -217,15 +215,25 @@ impl Animation for EquipAnimation { .sin() * 0.1, ); + + + + if velocity > 0.5 { next.head.offset = Vec3::new( 0.0, -3.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 13.0 + short * 0.2, ); - next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1 - short * 0.2) + next.head.ori = Quaternion::rotation_z(head_look.x- short * 0.2) * Quaternion::rotation_x(head_look.y + 0.35); next.head.scale = Vec3::one() * skeleton_attr.head_scale; + next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); + next.l_foot.scale = Vec3::one(); + next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); + next.r_foot.scale = Vec3::one(); next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1); next.chest.ori = Quaternion::rotation_z(short * 0.2); next.chest.scale = Vec3::one(); @@ -238,17 +246,45 @@ impl Animation for EquipAnimation { next.shorts.ori = Quaternion::rotation_z(short * 0.4); next.shorts.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); - next.l_foot.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(-0.2); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); - next.r_foot.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(-0.2); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - next + } else { + next.head.offset = Vec3::new( + 0.0, + -3.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 13.0 + short * 0.2, + ); + next.head.ori = Quaternion::rotation_z(head_look.x) + * Quaternion::rotation_x(head_look.y); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0); + next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, 3.5, 8.0); + next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035); + next.r_foot.scale = Vec3::one(); + + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(0.0); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_z(0.0); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(0.0); + next.shorts.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + } + next + } } diff --git a/voxygen/src/anim/character/idleequip.rs b/voxygen/src/anim/character/idleequip.rs deleted file mode 100644 index be36ef275c..0000000000 --- a/voxygen/src/anim/character/idleequip.rs +++ /dev/null @@ -1,252 +0,0 @@ -use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; -use common::comp::item::ToolKind; -use std::{f32::consts::PI, ops::Mul}; - -use vek::*; - -pub struct IdleEquipAnimation; - -impl Animation for IdleEquipAnimation { - type Dependency = (Option, f32, f64); - type Skeleton = CharacterSkeleton; - - fn update_skeleton( - skeleton: &Self::Skeleton, - (active_tool_kind, _velocity, global_time): Self::Dependency, - anim_time: f64, - _rate: &mut f32, - skeleton_attr: &SkeletonAttr, - ) -> Self::Skeleton { - let mut next = (*skeleton).clone(); - let _lab = 1.0; - let wave_slow_cos = (anim_time as f32 * 6.0 + PI).cos(); - let equip_slow = 1.0 + (anim_time as f32 * 10.0 + PI).cos(); - let equip_slowa = 1.0 + (anim_time as f32 * 10.0 + PI / 4.0).cos(); - - let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); - let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); - - let wave = (anim_time as f32 * 1.0).sin(); - match active_tool_kind { - //TODO: Inventory - Some(ToolKind::Sword(_)) => { - next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0); - next.l_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(-0.2); - next.l_hand.scale = Vec3::one() * 1.04; - next.r_hand.offset = Vec3::new(1.25, -5.5, -8.0); - next.r_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.3); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 0.0, -6.0); - next.main.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - - next.control.offset = - Vec3::new(-3.0 + equip_slowa * -1.5, -5.0, 12.0 + equip_slow * 1.5); - next.control.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(2.5) - * Quaternion::rotation_z(1.57); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Axe(_)) => { - next.l_hand.offset = Vec3::new(-4.0, 3.0, 6.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_z(3.14 - 0.3) - * Quaternion::rotation_y(-0.8); - next.l_hand.scale = Vec3::one() * 1.08; - next.r_hand.offset = Vec3::new(-2.5, 9.0, 4.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_z(3.14 - 0.3) - * Quaternion::rotation_y(-0.8); - next.r_hand.scale = Vec3::one() * 1.06; - next.main.offset = Vec3::new(-6.0, 10.0, -1.0); - next.main.ori = Quaternion::rotation_x(1.27) - * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(-0.8); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(0.0, 0.0, 0.0); - next.control.ori = Quaternion::rotation_x(0.2) - * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(0.0); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Hammer(_)) => { - next.l_hand.offset = Vec3::new(-7.0 + 9.0, 4.6 + 1.5, 7.5 - 1.6); - next.l_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.32); - next.l_hand.scale = Vec3::one() * 1.08; - next.r_hand.offset = Vec3::new(8.0, 5.75, 4.0); - next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.22); - next.r_hand.scale = Vec3::one() * 1.06; - next.main.offset = Vec3::new(6.0, 7.0, 0.0); - next.main.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(-1.35) - * Quaternion::rotation_z(1.57); - next.main.scale = Vec3::one(); - - next.control.offset = - Vec3::new(-3.0 + equip_slowa * -1.5, -12.0, 12.0 + equip_slow * 1.5); - next.control.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(1.35 + 2.5) - * Quaternion::rotation_z(0.0); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Staff(_)) => { - next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); - next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0); - next.r_hand.ori = Quaternion::rotation_x(1.8) - * Quaternion::rotation_y(0.5) - * Quaternion::rotation_z(-0.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(11.0, 9.0, 10.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(3.14 + 0.3) - * Quaternion::rotation_z(0.9); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Shield(_)) => { - next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x, - 4.5 + skeleton_attr.weapon_y, - 0.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Bow(_)) => { - next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); - next.l_hand.ori = Quaternion::rotation_x(1.20) - * Quaternion::rotation_y(-0.6) - * Quaternion::rotation_z(-0.3); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(3.0, -1.0, -5.0); - next.r_hand.ori = Quaternion::rotation_x(1.20) - * Quaternion::rotation_y(-0.6) - * Quaternion::rotation_z(-0.3); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(3.0, 2.0, -13.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.3) - * Quaternion::rotation_z(-0.6); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Dagger(_)) => { - next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x, - 4.5 + skeleton_attr.weapon_y, - 0.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Debug(_)) => { - next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); - next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); - next.r_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - 5.0 + skeleton_attr.weapon_x, - 8.75 + skeleton_attr.weapon_y, - -2.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(-1.27) - * Quaternion::rotation_z(wave * -0.25); - next.main.scale = Vec3::one(); - }, - _ => {}, - } - let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 10.0) - .floor() - .mul(7331.0) - .sin() - * 0.2, - ((global_time + anim_time) as f32 / 10.0) - .floor() - .mul(1337.0) - .sin() - * 0.1, - ); - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 14.0 + wave_ultra_slow * 0.1, - ); - next.head.ori = - Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 7.0 + wave_ultra_slow * 0.5); - next.chest.ori = - Quaternion::rotation_y(wave_ultra_slow_cos * 0.04) * Quaternion::rotation_z(0.15); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = - Quaternion::rotation_y(wave_ultra_slow_cos * 0.03) * Quaternion::rotation_z(0.22); - next.belt.scale = Vec3::one() * 1.02; - - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(0.3); - next.shorts.scale = Vec3::one(); - - next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0); - next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2); - next.l_foot.scale = Vec3::one(); - - next.r_foot.offset = Vec3::new(3.4, 3.5, 8.0); - next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035); - next.r_foot.scale = Vec3::one(); - - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - - next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); - next.l_control.ori = Quaternion::rotation_x(0.0); - next.l_control.scale = Vec3::one(); - - next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); - next.r_control.ori = Quaternion::rotation_x(0.0); - next.r_control.scale = Vec3::one(); - next - } -} diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 6d4beec894..35c62523f6 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -2,12 +2,10 @@ pub mod attack; pub mod block; pub mod blockidle; pub mod charge; -pub mod cidle; pub mod climb; pub mod equip; pub mod gliding; pub mod idle; -pub mod idleequip; pub mod idlewield; pub mod jump; pub mod roll; @@ -22,8 +20,8 @@ pub mod wield; // Reexports pub use self::{ attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, - charge::ChargeAnimation, cidle::CidleAnimation, climb::ClimbAnimation, equip::EquipAnimation, - gliding::GlidingAnimation, idle::IdleAnimation, idleequip::IdleEquipAnimation, + charge::ChargeAnimation, climb::ClimbAnimation, equip::EquipAnimation, + gliding::GlidingAnimation, idle::IdleAnimation, idlewield::IdleWieldAnimation, jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation, diff --git a/voxygen/src/anim/character/shoot.rs b/voxygen/src/anim/character/shoot.rs index 2dabf92d94..2e4bfdd978 100644 --- a/voxygen/src/anim/character/shoot.rs +++ b/voxygen/src/anim/character/shoot.rs @@ -2,43 +2,34 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use common::comp::item::ToolKind; use vek::*; -pub struct Input { - pub attack: bool, -} pub struct ShootAnimation; impl Animation for ShootAnimation { - type Dependency = (Option, f64); + type Dependency = (Option, f32, f64); type Skeleton = CharacterSkeleton; fn update_skeleton( skeleton: &Self::Skeleton, - (active_tool_kind, _global_time): Self::Dependency, + (active_tool_kind, velocity, _global_time): Self::Dependency, anim_time: f64, rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { *rate = 1.0; + let mut next = (*skeleton).clone(); let lab = 1.0; - let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); - let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); - let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 15.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 15.0).sin()); let quick = (((5.0) / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 2.0).cos()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * lab as f32 * 2.0).cos()); - let slow = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 12.4).sin()); - let slower = (((5.0) - / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 4.0).sin()); let sloweralt = (((5.0) / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).cos()).powf(2.0 as f32))) .sqrt()) @@ -70,71 +61,6 @@ impl Animation for ShootAnimation { match active_tool_kind { //TODO: Inventory - Some(ToolKind::Sword(_)) => { - next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.04; - next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 6.0, -1.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); - next.control.ori = Quaternion::rotation_x(-1.2) - * Quaternion::rotation_y(slow * 1.5) - * Quaternion::rotation_z(1.4 + slow * 0.5); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Axe(_)) => { - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Hammer(_)) => { - next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); - - //0,1,5 - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 6.0, -1.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-6.0, 3.0, 5.0 + slower * 5.0); - next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(1.4 + 1.57); - next.control.scale = Vec3::one(); - }, Some(ToolKind::Staff(_)) => { next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); @@ -156,31 +82,6 @@ impl Animation for ShootAnimation { * Quaternion::rotation_z(quick * 1.5); next.control.scale = Vec3::one(); }, - Some(ToolKind::Shield(_)) => { - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); - }, Some(ToolKind::Bow(_)) => { next.l_hand.offset = Vec3::new( 1.0 - sloweralt * 2.0, @@ -208,58 +109,38 @@ impl Animation for ShootAnimation { * Quaternion::rotation_z(0.0); next.control.scale = Vec3::one(); }, - Some(ToolKind::Dagger(_)) => { - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Debug(_)) => { - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); - }, _ => {}, } + if velocity > 0.5 { + next.l_foot.offset = Vec3::new(-3.4, foot * -2.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -0.4); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, foot * 2.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 0.4); + next.r_foot.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(-0.15) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + } else { + next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0 + (quick * 2.5).max(0.0)); + next.l_foot.ori = Quaternion::rotation_x(quick * -0.2 - 0.2) + * Quaternion::rotation_z((quick * 1.0).max(0.0)); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, 3.5 - quick * 2.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(quick * 0.1) + * Quaternion::rotation_z((quick * 0.5).max(0.0)); + next.r_foot.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + } + next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); next.l_shoulder.ori = Quaternion::rotation_x(0.0); next.l_shoulder.scale = Vec3::one() * 1.1; @@ -276,11 +157,6 @@ impl Animation for ShootAnimation { next.lantern.ori = Quaternion::rotation_x(0.0); next.lantern.scale = Vec3::one() * 0.0; - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); next.l_control.ori = Quaternion::rotation_x(0.0); next.l_control.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/sneak.rs b/voxygen/src/anim/character/sneak.rs deleted file mode 100644 index 8872add2fb..0000000000 --- a/voxygen/src/anim/character/sneak.rs +++ /dev/null @@ -1,147 +0,0 @@ -use super::{ - super::{Animation, }, - CharacterSkeleton,SkeletonAttr -}; -use std::f32::consts::PI; -use std::ops::Mul; -use vek::*; - -pub struct SneakAnimation; - -impl Animation for SneakAnimation { - type Skeleton = CharacterSkeleton; - type Dependency = (Vec3, Vec3, Vec3, f64); - - fn update_skeleton( - skeleton: &Self::Skeleton, - (velocity, orientation, last_ori, global_time): Self::Dependency, - anim_time: f64, - rate: &mut f32, - skeleton_attr: &SkeletonAttr, - ) -> Self::Skeleton { - let mut next = (*skeleton).clone(); - - let speed = Vec2::::from(velocity).magnitude(); - *rate = speed; - - let constant = 1.0; - let wave = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 1.2).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * constant as f32 * 1.2).sin()); - let wavecos = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 1.2).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * constant as f32 * 1.2).cos()); - let wave_cos = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 2.4).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * constant as f32 * 1.5).sin()); - let wave_cos_dub = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 4.8).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * constant as f32 * 1.5).sin()); - let wave_slow = (anim_time as f32 * 0.1).sin(); - let wave_diff = (anim_time as f32 * 0.6).sin(); - let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0).sin(); - let head_look = Vec2::new( - ((global_time + anim_time) as f32 * 0.25) - .floor() - .mul(7331.0) - .sin() - * 0.4, - ((global_time + anim_time) as f32 * 0.25) - .floor() - .mul(1337.0) - .sin() - * 0.2, - ); - - let ori = Vec2::from(orientation); - let last_ori = Vec2::from(last_ori); - - let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) - .map(|m| m > 0.001 && m.is_finite()) - .reduce_and() - && ori.angle_between(last_ori).is_finite() - { - ori.angle_between(last_ori).min(0.5) - * last_ori.determine_side(Vec2::zero(), ori).signum() - } else { - 0.0 - } * 1.3; - - next.head.offset = Vec3::new( - 0.0, - 0.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 16.0, - ); - next.head.ori = Quaternion::rotation_z(head_look.x + wave * 0.1) - * Quaternion::rotation_x(head_look.y + 0.05); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0, -1.5, 3.0 + wave_slow * 2.0); - next.chest.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(wave * 0.15); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, 1.5 + wave_cos * 0.3); - next.belt.ori = Quaternion::rotation_x(-0.1) * Quaternion::rotation_z(wave * 0.25); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 1.0, -1.0 + wave_cos * 0.3); - next.shorts.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(wave * 0.4); - next.shorts.scale = Vec3::one(); - - next.l_hand.offset = Vec3::new(-5.0 + wave_stop * -0.5, 2.25, 4.0 - wave * 1.0); - next.l_hand.ori = - Quaternion::rotation_x(1.5 + wave_cos * 0.1) * Quaternion::rotation_y(wave_stop * 0.1); - next.l_hand.scale = Vec3::one(); - - next.r_hand.offset = Vec3::new(5.0 + wave_stop * 0.5, 2.25, 4.0 + wave * 1.0); - next.r_hand.ori = Quaternion::rotation_x(1.5 + wave_cos * -0.1) - * Quaternion::rotation_y(wave_stop * -0.1); - next.r_hand.scale = Vec3::one(); - - next.l_foot.offset = Vec3::new(-3.4, 5.0 + wave * -3.0, 4.0); - next.l_foot.ori = Quaternion::rotation_x(-0.8 + wavecos * 0.15); - next.l_foot.scale = Vec3::one(); - - next.r_foot.offset = Vec3::new(3.4, 5.0 + wave * 3.0, 4.0); - next.r_foot.ori = Quaternion::rotation_x(-0.8 - wavecos * 0.15); - next.r_foot.scale = Vec3::one(); - - next.main.offset = Vec3::new( - -7.0 + skeleton_attr.weapon_x, - -5.0 + skeleton_attr.weapon_y, - 15.0, - ); - next.main.ori = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_cos * 0.25); - next.main.scale = Vec3::one(); - - next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); - next.l_shoulder.ori = Quaternion::rotation_x(wavecos * 0.05); - next.l_shoulder.scale = Vec3::one() * 1.1; - - next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7); - next.r_shoulder.ori = Quaternion::rotation_x(wave * 0.05); - next.r_shoulder.scale = Vec3::one() * 1.1; - - next.glider.offset = Vec3::new(0.0, 5.0, 0.0); - next.glider.ori = Quaternion::rotation_y(0.0); - next.glider.scale = Vec3::one() * 0.0; - - next.lantern.offset = Vec3::new(0.0, 5.0, 0.0); - next.lantern.ori = Quaternion::rotation_y(0.0); - next.lantern.scale = Vec3::one() * 0.0; - - next.torso.offset = Vec3::new(0.0, 0.3 + wave * -0.08, 0.4) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_x(wave_stop * speed * -0.03 + wave_diff * speed * -0.005) - * Quaternion::rotation_y(tilt); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - - next - } -} diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 91e0860c82..446f91e181 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -473,7 +473,7 @@ impl FigureMgr { CharacterState::BasicMelee(_) => { anim::character::AttackAnimation::update_skeleton( &target_base, - (active_tool_kind, time), + (active_tool_kind, vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -482,7 +482,7 @@ impl FigureMgr { CharacterState::BasicRanged(_) => { anim::character::ShootAnimation::update_skeleton( &target_base, - (active_tool_kind, time), + (active_tool_kind, vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -491,7 +491,7 @@ impl FigureMgr { CharacterState::Boost(_) => { anim::character::AttackAnimation::update_skeleton( &target_base, - (active_tool_kind, time), + (active_tool_kind, vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -509,7 +509,7 @@ impl FigureMgr { CharacterState::TripleStrike(s) => match s.stage { 0 => anim::character::AttackAnimation::update_skeleton( &target_base, - (active_tool_kind, time), + (active_tool_kind, vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -523,7 +523,7 @@ impl FigureMgr { ), _ => anim::character::AttackAnimation::update_skeleton( &target_base, - (active_tool_kind, time), + (active_tool_kind, vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -532,7 +532,7 @@ impl FigureMgr { CharacterState::TimedCombo(s) => match s.stage { 0 | 2 => anim::character::AttackAnimation::update_skeleton( &target_base, - (active_tool_kind, time), + (active_tool_kind, vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -565,7 +565,6 @@ impl FigureMgr { ) }*/ CharacterState::Equipping { .. } => { - if vel.0.magnitude_squared() > 0.5 { anim::character::EquipAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), @@ -573,15 +572,6 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ) - } else { - anim::character::IdleEquipAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) - } }, CharacterState::Wielding { .. } => { if vel.0.magnitude_squared() > 0.5 { From 047f6b8a01566fce847badd2f8c5b8695402f9be Mon Sep 17 00:00:00 2001 From: jshipsey Date: Wed, 25 Mar 2020 01:22:07 -0400 Subject: [PATCH 233/326] fixed swimming, better charge --- voxygen/src/anim/character/attack.rs | 23 ++- voxygen/src/anim/character/charge.rs | 28 ++-- voxygen/src/anim/character/equip.rs | 76 +++++----- voxygen/src/anim/character/jump.rs | 2 +- voxygen/src/anim/character/mod.rs | 8 +- voxygen/src/anim/character/run.rs | 2 +- voxygen/src/anim/character/spin.rs | 207 --------------------------- voxygen/src/anim/character/stand.rs | 2 +- voxygen/src/anim/character/swim.rs | 115 ++++++++------- voxygen/src/scene/figure/mod.rs | 16 +-- 10 files changed, 134 insertions(+), 345 deletions(-) diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/attack.rs index d209f5fa22..ca41ed49b0 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/attack.rs @@ -34,9 +34,9 @@ impl Animation for AttackAnimation { let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin(); let slow = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) + / (0.6 + 4.4 * ((anim_time as f32 * lab as f32 * 11.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 12.4).sin()); + * ((anim_time as f32 * lab as f32 * 11.0).sin()); let slower = (((5.0) / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) .sqrt()) @@ -462,11 +462,9 @@ impl Animation for AttackAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward + decel * 0.8, - skeleton_attr.neck_height + 21.0, + skeleton_attr.neck_height + 14.0, ); - next.head.ori = Quaternion::rotation_z(decel * 0.25) - * Quaternion::rotation_x(0.0 + decel * 0.1) - * Quaternion::rotation_y(decel * -0.1); + next.head.ori = Quaternion::rotation_x(0.0); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, 7.0); @@ -475,17 +473,14 @@ impl Animation for AttackAnimation { * Quaternion::rotation_y(decel * 0.2); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, 5.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.1) - * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_x(0.0); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, 2.0); - next.belt.ori = Quaternion::rotation_z(decel * -0.08) - * Quaternion::rotation_x(0.0 + decel * -0.08) - * Quaternion::rotation_y(decel * 0.08); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.belt.ori = Quaternion::rotation_x(0.0); next.shorts.scale = Vec3::one(); + next.l_hand.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); next.l_hand.ori = Quaternion::rotation_z(-0.8) diff --git a/voxygen/src/anim/character/charge.rs b/voxygen/src/anim/character/charge.rs index ea7d2d34ad..945cb41cd5 100644 --- a/voxygen/src/anim/character/charge.rs +++ b/voxygen/src/anim/character/charge.rs @@ -24,23 +24,20 @@ impl Animation for ChargeAnimation { let lab = 1.0; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 15.0).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 25.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 15.0).sin()); + * ((anim_time as f32 * lab as f32 * 25.0).sin()); let slow = (((5.0) / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * lab as f32 * 12.4).sin()); - let wave_cos = (((5.0) / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 2.4).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * constant as f32 * 1.5).sin()); - - match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { @@ -58,12 +55,12 @@ impl Animation for ChargeAnimation { next.chest.ori = Quaternion::rotation_x(-0.7) * Quaternion::rotation_z(-0.9); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = Quaternion::rotation_x(0.1) * Quaternion::rotation_z(0.0); + next.belt.offset = Vec3::new(0.0, 1.0, -1.0); + next.belt.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.2); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.0); + next.shorts.offset = Vec3::new(0.0, 3.0, -3.0); + next.shorts.ori = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3); next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); @@ -78,19 +75,18 @@ impl Animation for ChargeAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 3.0); + next.control.offset = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0); next.control.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(1.4 + slow * 0.1); + * Quaternion::rotation_z(1.4 + slow * 0.2); next.control.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, foot * 3.0, 8.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -0.6); + next.l_foot.offset = Vec3::new(-1.4, foot * 3.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, foot * -3.0, 8.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 0.6); + next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 3.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 0.4 - 0.8); next.r_foot.scale = Vec3::one(); - }, _ => {}, } diff --git a/voxygen/src/anim/character/equip.rs b/voxygen/src/anim/character/equip.rs index 0d13df9c37..5792e05043 100644 --- a/voxygen/src/anim/character/equip.rs +++ b/voxygen/src/anim/character/equip.rs @@ -216,17 +216,15 @@ impl Animation for EquipAnimation { * 0.1, ); - - if velocity > 0.5 { - next.head.offset = Vec3::new( - 0.0, - -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 13.0 + short * 0.2, - ); - next.head.ori = Quaternion::rotation_z(head_look.x- short * 0.2) - * Quaternion::rotation_x(head_look.y + 0.35); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; + next.head.offset = Vec3::new( + 0.0, + -3.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 13.0 + short * 0.2, + ); + next.head.ori = Quaternion::rotation_z(head_look.x - short * 0.2) + * Quaternion::rotation_x(head_look.y + 0.35); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0); next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); next.l_foot.scale = Vec3::one(); @@ -234,32 +232,30 @@ impl Animation for EquipAnimation { next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.0); next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); next.r_foot.scale = Vec3::one(); - next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1); - next.chest.ori = Quaternion::rotation_z(short * 0.2); - next.chest.scale = Vec3::one(); + next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1); + next.chest.ori = Quaternion::rotation_z(short * 0.2); + next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = Quaternion::rotation_z(short * 0.15); - next.belt.scale = Vec3::one(); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_z(short * 0.15); + next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(short * 0.4); - next.shorts.scale = Vec3::one(); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(short * 0.4); + next.shorts.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(-0.2); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - - } else { - next.head.offset = Vec3::new( - 0.0, - -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 13.0 + short * 0.2, - ); - next.head.ori = Quaternion::rotation_z(head_look.x) - * Quaternion::rotation_x(head_look.y); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; + next.head.offset = Vec3::new( + 0.0, + -3.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 13.0 + short * 0.2, + ); + next.head.ori = + Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0); next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2); next.l_foot.scale = Vec3::one(); @@ -268,23 +264,21 @@ impl Animation for EquipAnimation { next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035); next.r_foot.scale = Vec3::one(); + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(0.0); + next.chest.scale = Vec3::one(); - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(0.0); - next.chest.scale = Vec3::one(); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_z(0.0); + next.belt.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = Quaternion::rotation_z(0.0); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(0.0); - next.shorts.scale = Vec3::one(); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(0.0); + next.shorts.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; } - next - + next } } diff --git a/voxygen/src/anim/character/jump.rs b/voxygen/src/anim/character/jump.rs index 926adfee7a..aecb9b8116 100644 --- a/voxygen/src/anim/character/jump.rs +++ b/voxygen/src/anim/character/jump.rs @@ -76,7 +76,7 @@ impl Animation for JumpAnimation { next.r_shoulder.ori = Quaternion::rotation_x(-wave_stop_alt * 0.3); next.r_shoulder.scale = Vec3::one() * 1.1; - next.glider.offset = Vec3::new(0.0, 5.0, 0.0); + next.glider.offset = Vec3::new(0.0, 0.0, 10.0); next.glider.ori = Quaternion::rotation_y(0.0); next.glider.scale = Vec3::one() * 0.0; diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 35c62523f6..89e2f823ad 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -21,10 +21,10 @@ pub mod wield; pub use self::{ attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, charge::ChargeAnimation, climb::ClimbAnimation, equip::EquipAnimation, - gliding::GlidingAnimation, idle::IdleAnimation, - idlewield::IdleWieldAnimation, jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, - shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation, - swim::SwimAnimation, wield::WieldAnimation, + gliding::GlidingAnimation, idle::IdleAnimation, idlewield::IdleWieldAnimation, + jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, + sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation, swim::SwimAnimation, + wield::WieldAnimation, }; use super::{Bone, Skeleton}; diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index e1e60cc790..79dd2bdce5 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -128,7 +128,7 @@ impl Animation for RunAnimation { next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15); next.r_shoulder.scale = Vec3::one() * 1.1; - next.glider.offset = Vec3::new(0.0, 5.0, 0.0); + next.glider.offset = Vec3::new(0.0, 0.0, 10.0); next.glider.ori = Quaternion::rotation_y(0.0); next.glider.scale = Vec3::one() * 0.0; diff --git a/voxygen/src/anim/character/spin.rs b/voxygen/src/anim/character/spin.rs index 329d51dd41..7fff173f0b 100644 --- a/voxygen/src/anim/character/spin.rs +++ b/voxygen/src/anim/character/spin.rs @@ -94,214 +94,7 @@ impl Animation for SpinAnimation { * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }, - Some(ToolKind::Axe(_)) => { - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * -0.2) - * Quaternion::rotation_x(0.0 + decel * -0.2) - * Quaternion::rotation_y(decel * 0.2); - next.chest.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - }, - Some(ToolKind::Hammer(_)) => { - next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); - - //0,1,5 - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 6.0, -1.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-6.0, 3.0, 5.0 + slower * 5.0); - next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(1.4 + 1.57); - next.control.scale = Vec3::one(); - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * -0.2) - * Quaternion::rotation_x(0.0 + decel * -0.2) - * Quaternion::rotation_y(decel * 0.2); - next.chest.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - }, - Some(ToolKind::Staff(_)) => { - next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(0.0, 0.0, 10.0); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 6.0, -4.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); - next.control.ori = Quaternion::rotation_x(-1.2) - * Quaternion::rotation_y(slow * 1.5) - * Quaternion::rotation_z(1.4 + slow * 0.5); - next.control.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - }, - Some(ToolKind::Shield(_)) => { - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - }, - Some(ToolKind::Bow(_)) => { - next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); - next.l_hand.ori = Quaternion::rotation_x(1.27) - * Quaternion::rotation_y(-0.6) - * Quaternion::rotation_z(-0.3); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(3.0, -1.0, -6.0); - next.r_hand.ori = Quaternion::rotation_x(1.27) - * Quaternion::rotation_y(-0.6) - * Quaternion::rotation_z(-0.3); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(3.0, 2.0, -13.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.3) - * Quaternion::rotation_z(-0.6); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.control.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - }, - Some(ToolKind::Dagger(_)) => { - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - }, - Some(ToolKind::Debug(_)) => { - next.l_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0); - next.l_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.l_hand.scale = Vec3::one() * 1.01; - - next.r_hand.offset = - Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.r_hand.scale = Vec3::one() * 1.01; - - next.main.offset = Vec3::new( - -8.0 + accel_slow * 10.0 + skeleton_attr.weapon_x, - 8.0 + accel_fast * 3.0, - 0.0, - ); - next.main.ori = Quaternion::rotation_z(-0.8) - * Quaternion::rotation_x(0.0 + accel_med * -0.8) - * Quaternion::rotation_y(0.0 + accel_med * -0.4); - next.main.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - }, _ => {}, } next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 8.0); diff --git a/voxygen/src/anim/character/stand.rs b/voxygen/src/anim/character/stand.rs index b26188efaf..b82658edb6 100644 --- a/voxygen/src/anim/character/stand.rs +++ b/voxygen/src/anim/character/stand.rs @@ -79,7 +79,7 @@ impl Animation for StandAnimation { next.r_shoulder.ori = Quaternion::rotation_x(0.0); next.r_shoulder.scale = (Vec3::one() + breathe * -0.05) * 1.15; - next.glider.offset = Vec3::new(0.0, 5.0, 0.0); + next.glider.offset = Vec3::new(0.0, 0.0, 10.0); next.glider.ori = Quaternion::rotation_y(0.0); next.glider.scale = Vec3::one() * 0.0; diff --git a/voxygen/src/anim/character/swim.rs b/voxygen/src/anim/character/swim.rs index 001717afe3..f67d609572 100644 --- a/voxygen/src/anim/character/swim.rs +++ b/voxygen/src/anim/character/swim.rs @@ -6,101 +6,112 @@ use vek::*; pub struct SwimAnimation; impl Animation for SwimAnimation { - type Dependency = (Option, f32, f32, f64); + type Dependency = (Option, Vec3, f32, f64); type Skeleton = CharacterSkeleton; fn update_skeleton( skeleton: &Self::Skeleton, - (_active_tool_kind, velocity, orientation, global_time): Self::Dependency, + (_active_tool_kind, velocity, _orientation, global_time): Self::Dependency, anim_time: f64, - _rate: &mut f32, + rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let wave = (anim_time as f32 * velocity * 1.2).sin(); - let wave_cos = (anim_time as f32 * velocity * 1.2).cos(); + let speed = Vec2::::from(velocity).magnitude(); + *rate = speed; + + let lab = 1.0; + let long = (((5.0) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.8).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 0.8).sin()); + + let short = (((5.0) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 1.6).sin()); + + let shortalt = (((5.0) + / (1.5 + + 3.5 + * ((anim_time as f32 * lab as f32 * 1.6 + PI / 2.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 1.6 + PI / 2.0).sin()); + + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 1.6).sin()); + + let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0 / 2.0).sin(); - let wave_diff = (anim_time as f32 * velocity * 0.6).sin(); - let wave_cos_dub = (anim_time as f32 * velocity * 2.4).cos(); - let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0).sin(); let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 2.0) + ((global_time + anim_time) as f32 / 18.0) .floor() .mul(7331.0) .sin() * 0.2, - ((global_time + anim_time) as f32 / 2.0) + ((global_time + anim_time) as f32 / 18.0) .floor() .mul(1337.0) .sin() * 0.1, ); - let vel = Vec2::from(velocity); - let ori = (Vec2::from(orientation)).normalized(); - - let _tilt = if Vec2::new(ori, vel) - .map(|v| Vec2::::from(v).magnitude_squared()) - .reduce_partial_min() - > 0.001 - { - vel.normalized().dot(ori.normalized()).min(1.0).acos() - } else { - 0.0 - }; - next.head.offset = Vec3::new( 0.0, -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 14.0 + wave_cos * 1.3, + skeleton_attr.neck_height + 13.0 + short * 0.3, ); - next.head.ori = Quaternion::rotation_z(head_look.x + wave * 0.1) + next.head.ori = Quaternion::rotation_z(head_look.x + long * -0.1 - short * 0.3) * Quaternion::rotation_x(head_look.y + 0.35); next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 1.1); - next.chest.ori = Quaternion::rotation_z(wave * 0.2); + next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + short * 1.1); + next.chest.ori = Quaternion::rotation_z(short * 0.3); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, -2.0 + wave_cos * 1.1); - next.belt.ori = Quaternion::rotation_z(wave * 0.35); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_z(short * 0.25); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0 + wave_cos * 1.1); - next.shorts.ori = Quaternion::rotation_z(wave * 0.6); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(short * 0.4); next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new( - -6.0 + wave_cos_dub * 1.0, - -0.25 + wave_cos * 5.0, - 5.0 - wave * 1.5, + -6.0 + wave_stop * -1.0, + -0.25 + short * 3.0, + 4.0 + short * -1.5, ); - next.l_hand.ori = Quaternion::rotation_x(wave_cos * 0.8); + next.l_hand.ori = + Quaternion::rotation_x(0.8 + short * 1.2) * Quaternion::rotation_y(wave_stop * 0.1); next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new( - 6.0 - wave_cos_dub * 1.0, - -0.25 - wave_cos * 5.0, - 5.0 + wave * 1.5, + 6.0 + wave_stop * 1.0, + -0.25 + short * -3.0, + 4.0 + short * 1.5, ); - next.r_hand.ori = Quaternion::rotation_x(wave_cos * -0.8); + next.r_hand.ori = + Quaternion::rotation_x(0.8 + short * -1.2) * Quaternion::rotation_y(wave_stop * -0.1); next.r_hand.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, 0.0 + wave_cos * 1.0, 6.0 - wave_cos_dub * 0.7); - next.l_foot.ori = Quaternion::rotation_x(-0.0 - wave_cos * 1.5); + next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 6.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, 0.0 - wave_cos * 1.0, 6.0 - wave_cos_dub * 0.7); - next.r_foot.ori = Quaternion::rotation_x(-0.0 + wave_cos * 1.5); + next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 6.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); next.r_foot.scale = Vec3::one(); - next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); - next.l_shoulder.ori = Quaternion::rotation_x(wave_cos * 0.15); + next.l_shoulder.offset = Vec3::new(-5.0, -1.0, 4.7); + next.l_shoulder.ori = Quaternion::rotation_x(short * 0.15); next.l_shoulder.scale = Vec3::one() * 1.1; - next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7); - next.r_shoulder.ori = Quaternion::rotation_x(wave * 0.15); + next.r_shoulder.offset = Vec3::new(5.0, -1.0, 4.7); + next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15); next.r_shoulder.scale = Vec3::one() * 1.1; next.glider.offset = Vec3::new(0.0, 5.0, 0.0); @@ -110,10 +121,9 @@ impl Animation for SwimAnimation { next.main.offset = Vec3::new( -7.0 + skeleton_attr.weapon_x, -5.0 + skeleton_attr.weapon_y, - 18.0, + 15.0, ); - next.main.ori = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_cos * 0.25); + next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + short * 0.25); next.main.scale = Vec3::one(); next.second.offset = Vec3::new( @@ -128,9 +138,9 @@ impl Animation for SwimAnimation { next.lantern.ori = Quaternion::rotation_y(0.0); next.lantern.scale = Vec3::one() * 0.0; - next.torso.offset = Vec3::new(0.0, -0.2 + wave * -0.08, 0.4) * skeleton_attr.scaler; + next.torso.offset = Vec3::new(0.0, -0.3 + shortalt * -0.065, 0.4) * skeleton_attr.scaler; next.torso.ori = - Quaternion::rotation_x(wave_stop * velocity * -0.06 + wave_diff * velocity * -0.005) + Quaternion::rotation_x(wave_stop * speed * -0.05 + wave_stop * speed * -0.005) * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; @@ -145,6 +155,7 @@ impl Animation for SwimAnimation { next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); next.r_control.ori = Quaternion::rotation_x(0.0); next.r_control.scale = Vec3::one(); + next } } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 446f91e181..e5745bcc48 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -454,7 +454,7 @@ impl FigureMgr { // Swim (_, _, true) => anim::character::SwimAnimation::update_skeleton( &CharacterSkeleton::new(), - (active_tool_kind, vel.0.magnitude(), ori.0.magnitude(), time), + (active_tool_kind, vel.0, ori.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -565,13 +565,13 @@ impl FigureMgr { ) }*/ CharacterState::Equipping { .. } => { - anim::character::EquipAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) + anim::character::EquipAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) }, CharacterState::Wielding { .. } => { if vel.0.magnitude_squared() > 0.5 { From c7d9b5ae0f86c37fb48027a11f87dfa32236495d Mon Sep 17 00:00:00 2001 From: jshipsey Date: Wed, 25 Mar 2020 01:29:55 -0400 Subject: [PATCH 234/326] fixed critter animation --- voxygen/src/anim/character/spin.rs | 12 ------------ voxygen/src/anim/critter/idle.rs | 6 +++--- voxygen/src/anim/critter/run.rs | 2 +- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/voxygen/src/anim/character/spin.rs b/voxygen/src/anim/character/spin.rs index 7fff173f0b..b9b19f7dcb 100644 --- a/voxygen/src/anim/character/spin.rs +++ b/voxygen/src/anim/character/spin.rs @@ -29,23 +29,11 @@ impl Animation for SpinAnimation { .sqrt()) * ((anim_time as f32 * lab as f32 * 10.32).sin()); - let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); - let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); - let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin(); let spin = (anim_time as f32 * 2.8 * lab as f32).sin(); let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin(); - let slow = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 12.4).sin()); - let slower = (((5.0) - / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 4.0).sin()); - match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { diff --git a/voxygen/src/anim/critter/idle.rs b/voxygen/src/anim/critter/idle.rs index cefa1f1401..fe9827bb4c 100644 --- a/voxygen/src/anim/critter/idle.rs +++ b/voxygen/src/anim/critter/idle.rs @@ -41,9 +41,9 @@ impl Animation for IdleAnimation { next.chest.offset = Vec3::new( 0.0, skeleton_attr.chest.0, - skeleton_attr.chest.1 + wave * 1.0, + skeleton_attr.chest.1 + wave * 0.3, ) / 18.0; - next.chest.ori = Quaternion::rotation_y(wave_slow * 0.2); + next.chest.ori = Quaternion::rotation_y(wave_slow * 0.06); next.chest.scale = Vec3::one() / 18.0; next.feet_f.offset = Vec3::new(0.0, skeleton_attr.feet_f.0, skeleton_attr.feet_f.1) / 18.0; @@ -56,7 +56,7 @@ impl Animation for IdleAnimation { next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0 + wave * 1.0, skeleton_attr.tail.1) / 18.0; - next.tail.ori = Quaternion::rotation_y(wave_slow * 0.25); + next.tail.ori = Quaternion::rotation_y(wave_slow * 0.05); next.tail.scale = Vec3::one() / 18.0; next diff --git a/voxygen/src/anim/critter/run.rs b/voxygen/src/anim/critter/run.rs index 23710a901e..a2918c958e 100644 --- a/voxygen/src/anim/critter/run.rs +++ b/voxygen/src/anim/critter/run.rs @@ -44,7 +44,7 @@ impl Animation for RunAnimation { next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0 + wave * 1.0, skeleton_attr.tail.1) / 18.0; - next.tail.ori = Quaternion::rotation_y(wave_slow * 0.25); + next.tail.ori = Quaternion::rotation_y(wave_slow * 0.08); next.tail.scale = Vec3::one() / 18.0; next From 2897e898c26111cf2d9d2731ffb44095af57828f Mon Sep 17 00:00:00 2001 From: Imbris Date: Sun, 22 Mar 2020 16:33:33 -0400 Subject: [PATCH 235/326] move character state component to section reflecting its current sync strategy --- common/src/state.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/src/state.rs b/common/src/state.rs index ede5f6252d..4efc494917 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -120,12 +120,12 @@ impl State { ecs.register::(); ecs.register::(); ecs.register::(); + ecs.register::(); // Register components send from clients -> server ecs.register::(); // Register components send directly from server -> all but one client - ecs.register::(); ecs.register::(); // Register components synced from client -> server -> all other clients @@ -139,7 +139,6 @@ impl State { ecs.register::>(); ecs.register::>(); ecs.register::>(); - ecs.register::>(); ecs.register::(); ecs.register::(); ecs.register::(); From 37ec191021b85d4d96626604e1816cab52ad3e15 Mon Sep 17 00:00:00 2001 From: Adam Whitehurst Date: Mon, 23 Mar 2020 10:13:44 -0700 Subject: [PATCH 236/326] update controller tick fn --- common/src/comp/controller.rs | 121 ++++++++++++++++------------------ common/src/comp/mod.rs | 3 +- common/src/sys/controller.rs | 15 ++++- voxygen/src/session.rs | 2 - 4 files changed, 69 insertions(+), 72 deletions(-) diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index d34752271f..2a0b8b966d 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -15,81 +15,73 @@ pub enum ControlEvent { //Respawn, } -/// The various states an input can be in -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub enum InputState { - Pressed, - Unpressed, -} - /// Whether a key is pressed or unpressed /// and how long it has been in that state #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Input { /// Should not be pub because duration should /// always be reset when state is updated - state: InputState, + state: bool, /// Should only be updated by npc agents /// through appropriate fn duration: Duration, - /// Turned off first tick after switching states - just_changed: bool, - /// Set when `set_state` is called. Needed so - /// tick after change doesn't immediately unset `just_changed` - dirty: bool, + /// How many update ticks the button has been in its current state for + ticks_held: u32, } impl Input { - fn tick(&mut self, dt: Duration) { + fn tick(&mut self, old: Input, dt: Duration) { // Increase how long input has been in current state self.duration = self.duration.checked_add(dt).unwrap_or_default(); - if self.dirty { - // Unset dirty first tick after changing into current state - self.dirty = false; - } else { - // Otherwise, just changed is always false - self.just_changed = false; - } + + match (self.is_pressed(), old.is_pressed()) { + (false, true) | (true, false) => { + println!("{:?}", self); + self.duration = Duration::default(); + self.ticks_held = 1; + println!("{:?}", self); + }, + (_, _) => { + self.ticks_held += 1; + println!("____"); + }, + }; } - /// Whether input is in `InputState::Pressed` state - pub fn is_pressed(&self) -> bool { self.state == InputState::Pressed } + /// Whether input is being pressed down + pub fn is_pressed(&self) -> bool { self.state == true } - /// Whether it's the first frame this input has been in - /// its current state - pub fn is_just_pressed(&self) -> bool { self.just_changed && self.is_pressed() } + /// Whether it's the first frame this input has been pressed + pub fn is_just_pressed(&self) -> bool { self.is_pressed() && self.ticks_held == 1 } - /// Whether input has been in current state longer than + /// Whether it's the first frame this input has been unpressed + pub fn is_just_unpressed(&self) -> bool { !self.is_pressed() && self.ticks_held == 1 } + + /// Whether input has been pressed longer than /// `DEFAULT_HOLD_DURATION` pub fn is_held_down(&self) -> bool { self.is_pressed() && self.duration >= DEFAULT_HOLD_DURATION } - /// Whether input has been pressed for longer than `threshold` - pub fn is_long_press(&self, threshold: Duration) -> bool { + /// Whether input has been unpressed longer than + /// `DEFAULT_HOLD_DURATION` + pub fn is_held_up(&self) -> bool { + !self.is_pressed() && self.duration >= DEFAULT_HOLD_DURATION + } + + /// Whether input has been pressed for longer than `threshold` duration + pub fn held_for_dur(&self, threshold: Duration) -> bool { self.is_pressed() && self.duration >= threshold } - /// Handles logic of updating state of Input - pub fn set_state(&mut self, new_state: bool) { - // Only update if state switches - match (self.is_pressed(), new_state) { - (false, true) => { - self.just_changed = true; - self.dirty = true; - self.state = InputState::Pressed; - self.duration = Duration::default(); - }, - (true, false) => { - self.just_changed = true; - self.dirty = true; - self.state = InputState::Unpressed; - self.duration = Duration::default(); - }, - (_, _) => {}, - }; + /// Whether input has been pressed for longer than `count` number of ticks + pub fn held_for_ticks(&self, count: u32) -> bool { + self.is_pressed() && self.ticks_held >= count } + /// Handles logic of updating state of Input + pub fn set_state(&mut self, new_state: bool) { self.state = new_state; } + /// Increases `input::duration` by `dur` pub fn inc_dur(&mut self, dur: Duration) { self.duration = self.duration.checked_add(dur).unwrap_or_default(); @@ -102,10 +94,9 @@ impl Input { impl Default for Input { fn default() -> Self { Self { - state: InputState::Unpressed, + state: false, duration: Duration::default(), - just_changed: false, - dirty: false, + ticks_held: 0, } } } @@ -139,21 +130,21 @@ pub struct Controller { impl ControllerInputs { /// Updates all inputs, accounting for delta time - pub fn tick(&mut self, dt: Duration) { - self.primary.tick(dt); - self.secondary.tick(dt); - self.ability3.tick(dt); - self.sit.tick(dt); - self.jump.tick(dt); - self.roll.tick(dt); - self.glide.tick(dt); - self.climb.tick(dt); - self.climb_down.tick(dt); - self.wall_leap.tick(dt); - self.respawn.tick(dt); - self.toggle_wield.tick(dt); - self.swap_loadout.tick(dt); - self.charge.tick(dt); + pub fn calculate_change(&mut self, old: ControllerInputs, dt: Duration) { + self.primary.tick(old.primary, dt); + self.secondary.tick(old.secondary, dt); + self.ability3.tick(old.ability3, dt); + self.sit.tick(old.sit, dt); + self.jump.tick(old.jump, dt); + self.roll.tick(old.roll, dt); + self.glide.tick(old.glide, dt); + self.climb.tick(old.climb, dt); + self.climb_down.tick(old.climb_down, dt); + self.wall_leap.tick(old.wall_leap, dt); + self.respawn.tick(old.respawn, dt); + self.toggle_wield.tick(old.toggle_wield, dt); + self.swap_loadout.tick(old.swap_loadout, dt); + self.charge.tick(old.charge, dt); } pub fn holding_ability_key(&self) -> bool { diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 6d35af056f..f053f5f5cc 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -25,8 +25,7 @@ pub use body::{ }; pub use character_state::{Attacking, CharacterState, StateUpdate}; pub use controller::{ - ControlEvent, Controller, ControllerInputs, Input, InputState, InventoryManip, MountState, - Mounting, + ControlEvent, Controller, ControllerInputs, Input, InventoryManip, MountState, Mounting, }; pub use energy::{Energy, EnergySource}; pub use inputs::CanBuild; diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index 9b3718d849..8617f7cf7a 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -8,6 +8,7 @@ use specs::{ saveload::{Marker, MarkerAllocator}, Entities, Join, Read, ReadStorage, System, WriteStorage, }; +use std::time::Duration; // const CHARGE_COST: i32 = 200; // const ROLL_COST: i32 = 30; @@ -33,15 +34,23 @@ impl<'a> System<'a> for Sys { uid_allocator, server_bus, _local_bus, - _dt, + read_dt, mut controllers, mut character_states, uids, ): Self::SystemData, ) { let mut server_emitter = server_bus.emitter(); - for (entity, _uid, controller, character_state) in - (&entities, &uids, &mut controllers, &mut character_states).join() + let dt = Duration::from_secs_f32(read_dt.0); + + for (entity, _uid, controller, character_state) in ( + &entities, + &uids, + &mut controllers, + // &last_controllers, + &mut character_states, + ) + .join() { let inputs = &mut controller.inputs; diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 3dce7ac89c..00e5bceb2b 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -75,7 +75,6 @@ impl SessionState { impl SessionState { /// Tick the session (and the client attached to it). fn tick(&mut self, dt: Duration) -> Result { - self.inputs.tick(dt); for event in self.client.borrow_mut().tick( self.inputs.clone(), dt, @@ -327,7 +326,6 @@ impl PlayState for SessionState { self.inputs.toggle_wield.set_state(state); }, Event::InputUpdate(GameInput::SwapLoadout, state) => { - println!("{:?}", state); self.inputs.swap_loadout.set_state(state); }, Event::InputUpdate(GameInput::Mount, true) => { From 6ba158b7e1848ee1dc3041e076d710495eaf3ea0 Mon Sep 17 00:00:00 2001 From: Imbris Date: Tue, 24 Mar 2020 03:38:16 -0400 Subject: [PATCH 237/326] Input handling changes --- client/src/lib.rs | 61 +++++++++-- common/src/comp/controller.rs | 147 ++++++++++++++++++--------- common/src/comp/mod.rs | 3 +- common/src/msg/client.rs | 1 + common/src/states/climb.rs | 79 ++++++++------ common/src/states/dash_melee.rs | 2 +- common/src/states/idle.rs | 21 +++- common/src/states/sit.rs | 20 +++- common/src/states/utils.rs | 31 ++---- common/src/states/wielding.rs | 23 ++++- common/src/sys/character_behavior.rs | 90 +++++++++++----- common/src/sys/controller.rs | 29 +++--- server/src/sys/message.rs | 23 ++++- voxygen/src/key_state.rs | 22 ++++ voxygen/src/session.rs | 52 +++++++--- 15 files changed, 426 insertions(+), 178 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 9d2e4846d2..5606d415ab 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -15,7 +15,8 @@ pub use specs::{ use byteorder::{ByteOrder, LittleEndian}; use common::{ comp::{ - self, ControlEvent, Controller, ControllerInputs, InventoryManip, InventoryUpdateEvent, + self, ControlAction, ControlEvent, Controller, ControllerInputs, InventoryManip, + InventoryUpdateEvent, }, event::{EventBus, SfxEvent, SfxEventItem}, msg::{ @@ -31,7 +32,7 @@ use common::{ }; use hashbrown::HashMap; use image::DynamicImage; -use log::warn; +use log::{error, warn}; use std::{ net::SocketAddr, sync::Arc, @@ -288,6 +289,38 @@ impl Client { .send_message(ClientMsg::ControlEvent(ControlEvent::Unmount)); } + pub fn respawn(&mut self) { + if self + .state + .ecs() + .read_storage::() + .get(self.entity) + .map_or(false, |s| s.is_dead) + { + self.postbox + .send_message(ClientMsg::ControlEvent(ControlEvent::Respawn)); + } + } + + pub fn swap_loadout(&mut self) { self.control_action(ControlAction::SwapLoadout); } + + pub fn toggle_wield(&mut self) { self.control_action(ControlAction::ToggleWield); } + + pub fn toggle_sit(&mut self) { self.control_action(ControlAction::ToggleSit); } + + fn control_action(&mut self, control_action: ControlAction) { + if let Some(controller) = self + .state + .ecs() + .write_storage::() + .get_mut(self.entity) + { + controller.actions.push(control_action); + } + self.postbox + .send_message(ClientMsg::ControlAction(control_action)); + } + pub fn view_distance(&self) -> Option { self.view_distance } pub fn loaded_distance(&self) -> f32 { self.loaded_distance } @@ -371,10 +404,26 @@ impl Client { // 1) Handle input from frontend. // Pass character actions from frontend input to the player's entity. if let ClientState::Character = self.client_state { - self.state.write_component(self.entity, Controller { - inputs: inputs.clone(), - events: Vec::new(), - }); + if let Err(err) = self + .state + .ecs() + .write_storage::() + .entry(self.entity) + .map(|entry| { + entry + .or_insert_with(|| Controller { + inputs: inputs.clone(), + events: Vec::new(), + actions: Vec::new(), + }) + .inputs = inputs.clone(); + }) + { + error!( + "Couldn't access controller component on client entity: {:?}", + err + ); + } self.postbox .send_message(ClientMsg::ControllerInputs(inputs)); } diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 2a0b8b966d..87d9e1577f 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -12,7 +12,21 @@ pub enum ControlEvent { Mount(Uid), Unmount, InventoryManip(InventoryManip), - //Respawn, + Respawn, +} + +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +pub enum ControlAction { + SwapLoadout, + ToggleWield, + ToggleSit, +} + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +enum Freshness { + New, + TickedOnce, + Old, } /// Whether a key is pressed or unpressed @@ -21,41 +35,50 @@ pub enum ControlEvent { pub struct Input { /// Should not be pub because duration should /// always be reset when state is updated - state: bool, + pressed: bool, /// Should only be updated by npc agents /// through appropriate fn duration: Duration, - /// How many update ticks the button has been in its current state for - ticks_held: u32, + /// How fresh is the last change to the input state + freshness: Freshness, } impl Input { - fn tick(&mut self, old: Input, dt: Duration) { + fn tick(&mut self, dt: Duration) { // Increase how long input has been in current state self.duration = self.duration.checked_add(dt).unwrap_or_default(); + self.tick_freshness(); + } - match (self.is_pressed(), old.is_pressed()) { - (false, true) | (true, false) => { - println!("{:?}", self); - self.duration = Duration::default(); - self.ticks_held = 1; - println!("{:?}", self); - }, - (_, _) => { - self.ticks_held += 1; - println!("____"); - }, + fn tick_freshness(&mut self) { + self.freshness = match self.freshness { + Freshness::New => Freshness::TickedOnce, + Freshness::TickedOnce => Freshness::Old, + Freshness::Old => Freshness::Old, }; } + /// Update input with newer version + /// Used to update inputs with input recieved from clients + pub fn update_with_new(&mut self, new: Self) { + if self.pressed != new.pressed { + self.freshness = Freshness::New; + } + + self.pressed = new.pressed; + self.duration = new.duration; + } + /// Whether input is being pressed down - pub fn is_pressed(&self) -> bool { self.state == true } + pub fn is_pressed(&self) -> bool { self.pressed } /// Whether it's the first frame this input has been pressed - pub fn is_just_pressed(&self) -> bool { self.is_pressed() && self.ticks_held == 1 } + pub fn is_just_pressed(&self) -> bool { self.is_pressed() && self.freshness != Freshness::Old } /// Whether it's the first frame this input has been unpressed - pub fn is_just_unpressed(&self) -> bool { !self.is_pressed() && self.ticks_held == 1 } + pub fn is_just_unpressed(&self) -> bool { + !self.is_pressed() && self.freshness != Freshness::Old + } /// Whether input has been pressed longer than /// `DEFAULT_HOLD_DURATION` @@ -74,49 +97,52 @@ impl Input { self.is_pressed() && self.duration >= threshold } - /// Whether input has been pressed for longer than `count` number of ticks - pub fn held_for_ticks(&self, count: u32) -> bool { - self.is_pressed() && self.ticks_held >= count + /// Handles logic of updating state of Input + pub fn set_state(&mut self, pressed: bool) { + if self.pressed != pressed { + self.pressed = pressed; + self.duration = Duration::default(); + self.freshness = Freshness::New; + } } - /// Handles logic of updating state of Input - pub fn set_state(&mut self, new_state: bool) { self.state = new_state; } - - /// Increases `input::duration` by `dur` + /// Increases `input.duration` by `dur` pub fn inc_dur(&mut self, dur: Duration) { self.duration = self.duration.checked_add(dur).unwrap_or_default(); } - /// Returns `input::duration` + /// Returns `input.duration` pub fn get_dur(&self) -> Duration { self.duration } } impl Default for Input { fn default() -> Self { Self { - state: false, + pressed: false, duration: Duration::default(), - ticks_held: 0, + freshness: Freshness::New, } } } +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +pub enum Climb { + Up, + Down, + Hold, +} + #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct ControllerInputs { pub primary: Input, pub secondary: Input, pub ability3: Input, - pub sit: Input, pub jump: Input, pub roll: Input, pub glide: Input, - pub climb: Input, - pub climb_down: Input, pub wall_leap: Input, - pub respawn: Input, - pub toggle_wield: Input, - pub swap_loadout: Input, pub charge: Input, + pub climb: Option, pub move_dir: Vec2, pub look_dir: Vec3, } @@ -126,25 +152,46 @@ pub struct Controller { pub inputs: ControllerInputs, // TODO: consider SmallVec pub events: Vec, + pub actions: Vec, } impl ControllerInputs { /// Updates all inputs, accounting for delta time - pub fn calculate_change(&mut self, old: ControllerInputs, dt: Duration) { - self.primary.tick(old.primary, dt); - self.secondary.tick(old.secondary, dt); - self.ability3.tick(old.ability3, dt); - self.sit.tick(old.sit, dt); - self.jump.tick(old.jump, dt); - self.roll.tick(old.roll, dt); - self.glide.tick(old.glide, dt); - self.climb.tick(old.climb, dt); - self.climb_down.tick(old.climb_down, dt); - self.wall_leap.tick(old.wall_leap, dt); - self.respawn.tick(old.respawn, dt); - self.toggle_wield.tick(old.toggle_wield, dt); - self.swap_loadout.tick(old.swap_loadout, dt); - self.charge.tick(old.charge, dt); + pub fn tick(&mut self, dt: Duration) { + self.primary.tick(dt); + self.secondary.tick(dt); + self.ability3.tick(dt); + self.jump.tick(dt); + self.roll.tick(dt); + self.glide.tick(dt); + self.wall_leap.tick(dt); + self.charge.tick(dt); + } + + pub fn tick_freshness(&mut self) { + self.primary.tick_freshness(); + self.secondary.tick_freshness(); + self.ability3.tick_freshness(); + self.jump.tick_freshness(); + self.roll.tick_freshness(); + self.glide.tick_freshness(); + self.wall_leap.tick_freshness(); + self.charge.tick_freshness(); + } + + /// Updates Controller inputs with new version received from the client + pub fn update_with_new(&mut self, new: Self) { + self.primary.update_with_new(new.primary); + self.secondary.update_with_new(new.secondary); + self.ability3.update_with_new(new.ability3); + self.jump.update_with_new(new.jump); + self.roll.update_with_new(new.roll); + self.glide.update_with_new(new.glide); + self.wall_leap.update_with_new(new.wall_leap); + self.charge.update_with_new(new.charge); + self.climb = new.climb; + self.move_dir = new.move_dir; + self.look_dir = new.look_dir; } pub fn holding_ability_key(&self) -> bool { diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index f053f5f5cc..63ee953011 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -25,7 +25,8 @@ pub use body::{ }; pub use character_state::{Attacking, CharacterState, StateUpdate}; pub use controller::{ - ControlEvent, Controller, ControllerInputs, Input, InventoryManip, MountState, Mounting, + Climb, ControlAction, ControlEvent, Controller, ControllerInputs, Input, InventoryManip, + MountState, Mounting, }; pub use energy::{Energy, EnergySource}; pub use inputs::CanBuild; diff --git a/common/src/msg/client.rs b/common/src/msg/client.rs index 2b2ec63f33..970208cc23 100644 --- a/common/src/msg/client.rs +++ b/common/src/msg/client.rs @@ -18,6 +18,7 @@ pub enum ClientMsg { Spectate, ControllerInputs(comp::ControllerInputs), ControlEvent(comp::ControlEvent), + ControlAction(comp::ControlAction), SetViewDistance(u32), BreakBlock(Vec3), PlaceBlock(Vec3, Block), diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 91fbaf87fb..5beb746345 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{CharacterState, EnergySource, StateUpdate}, + comp::{CharacterState, Climb, EnergySource, StateUpdate}, event::LocalEvent, sys::{ character_behavior::{CharacterBehavior, JoinData}, @@ -22,15 +22,8 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - if let Err(_) = update.energy.try_change_by(-8, EnergySource::Climb) { - update.character = CharacterState::Idle {}; - } - - // If no wall is in front of character or we stopped holding space: - if data.physics.on_wall.is_none() - || data.physics.on_ground - || !data.inputs.jump.is_pressed() - { + // If no wall is in front of character or we stopped climbing; + if data.physics.on_wall.is_none() || data.physics.on_ground || data.inputs.climb.is_none() { if data.inputs.jump.is_pressed() { // They've climbed atop something, give them a boost update @@ -50,13 +43,35 @@ impl CharacterBehavior for Data { 0.0 }; + // Expend energy if climbing + let energy_use = match data.inputs.climb { + Some(Climb::Up) | Some(Climb::Down) => 8, + Some(Climb::Hold) => data + .physics + .on_wall + .map(|wall_dir| { + // Calculate velocity perpendicular to the wall + let vel = update.vel.0; + let perp_vel = + vel - wall_dir * vel.dot(wall_dir) / wall_dir.magnitude_squared(); + // Enegry cost based on magnitude of this velocity + (perp_vel.magnitude() * 8.0) as i32 + }) + // Note: this is currently unreachable + .unwrap_or(0), + // Note: this is currently unreachable + None => 0, + }; + if let Err(_) = update + .energy + .try_change_by(-energy_use, EnergySource::Climb) + { + update.character = CharacterState::Idle {}; + } + // Set orientation direction based on wall direction let ori_dir = if let Some(wall_dir) = data.physics.on_wall { - if Vec2::::from(wall_dir).magnitude_squared() > 0.001 { - Vec2::from(wall_dir).normalized() - } else { - Vec2::from(update.vel.0) - } + Vec2::from(wall_dir) } else { Vec2::from(update.vel.0) }; @@ -69,23 +84,27 @@ impl CharacterBehavior for Data { ); // Apply Vertical Climbing Movement - if let (true, Some(_wall_dir)) = ( - (data.inputs.climb.is_pressed() | data.inputs.climb_down.is_pressed()) - && update.vel.0.z <= CLIMB_SPEED, + if let (Some(climb), true, Some(_wall_dir)) = ( + data.inputs.climb, + update.vel.0.z <= CLIMB_SPEED, data.physics.on_wall, ) { - if data.inputs.climb_down.is_pressed() && !data.inputs.climb.is_pressed() { - update.vel.0 -= - data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); - } else if data.inputs.climb.is_pressed() && !data.inputs.climb_down.is_pressed() { - update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); - } else { - update.vel.0.z = update.vel.0.z + data.dt.0 * GRAVITY * 1.5; - update.vel.0 = Lerp::lerp( - update.vel.0, - Vec3::zero(), - 30.0 * data.dt.0 / (1.0 - update.vel.0.z.min(0.0) * 5.0), - ); + match climb { + Climb::Down => { + update.vel.0 -= + data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); + }, + Climb::Up => { + update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); + }, + Climb::Hold => { + update.vel.0.z = update.vel.0.z + data.dt.0 * GRAVITY * 1.5; + update.vel.0 = Lerp::lerp( + update.vel.0, + Vec3::zero(), + 30.0 * data.dt.0 / (1.0 - update.vel.0.z.min(0.0) * 5.0), + ); + }, } } diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 2783b8278f..1b69eeb987 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -28,7 +28,7 @@ impl CharacterBehavior for Data { if self.initialize { update.vel.0 = data.inputs.look_dir * 20.0; - update.ori.0 = data.vel.0.normalized(); + update.ori.0 = Vec3::from(data.vel.0.xy()).normalized(); } if self.buildup_duration != Duration::default() && data.physics.touch_entity.is_none() { diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index 17b07ebc5a..0355ddbe5a 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -12,12 +12,29 @@ impl CharacterBehavior for Data { handle_move(data, &mut update); handle_jump(data, &mut update); - handle_wield(data, &mut update); - handle_sit(data, &mut update); + handle_primary_wield(data, &mut update); handle_climb(data, &mut update); handle_glide(data, &mut update); handle_dodge_input(data, &mut update); update } + + fn toggle_wield(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_wield(data, &mut update); + update + } + + fn toggle_sit(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_sit(data, &mut update); + update + } + + fn swap_loadout(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_swap_loadout(data, &mut update); + update + } } diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index 576a05fb88..ad919a3993 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -11,16 +11,26 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_wield(data, &mut update); + handle_primary_wield(data, &mut update); // Try to Fall/Stand up/Move - if !data.physics.on_ground - || data.inputs.sit.is_just_pressed() - || data.inputs.move_dir.magnitude_squared() > 0.0 - { + if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 { update.character = CharacterState::Idle; } update } + + fn toggle_wield(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_wield(data, &mut update); + update + } + + fn toggle_sit(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + // Try to Fall/Stand up/Move + update.character = CharacterState::Idle; + update + } } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 2f3d1b2857..d886081424 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -90,7 +90,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { /// First checks whether `primary` input is pressed, then /// attempts to go into Equipping state, otherwise Idle -pub fn handle_wield(data: &JoinData, update: &mut StateUpdate) { +pub fn handle_primary_wield(data: &JoinData, update: &mut StateUpdate) { if data.inputs.primary.is_pressed() { attempt_wield(data, update); } @@ -108,15 +108,15 @@ pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { } /// Checks that player can `Sit` and updates `CharacterState` if so -pub fn handle_sit(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.sit.is_pressed() && data.physics.on_ground && data.body.is_humanoid() { +pub fn attempt_sit(data: &JoinData, update: &mut StateUpdate) { + if data.physics.on_ground && data.body.is_humanoid() { update.character = CharacterState::Sit; } } /// Checks that player can `Climb` and updates `CharacterState` if so pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { - if (data.inputs.climb.is_pressed() || data.inputs.climb_down.is_pressed()) + if data.inputs.climb.is_some() && data.physics.on_wall.is_some() && !data.physics.on_ground //&& update.vel.0.z < 0.0 @@ -127,25 +127,12 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { } } -/// Checks that player can Unwield and updates `CharacterState` if so -pub fn handle_unwield(data: &JoinData, update: &mut StateUpdate) { - if let CharacterState::Wielding { .. } = update.character { - if data.inputs.toggle_wield.is_pressed() { - update.character = CharacterState::Idle; - } - } -} - /// Checks that player can Swap Weapons and updates `Loadout` if so -pub fn handle_swap_loadout(data: &JoinData, update: &mut StateUpdate) { - if let CharacterState::Wielding { .. } = update.character { - if data.inputs.swap_loadout.is_just_pressed() { - let mut new_loadout = data.loadout.clone(); - new_loadout.active_item = data.loadout.second_item.clone(); - new_loadout.second_item = data.loadout.active_item.clone(); - update.loadout = new_loadout; - } - } +pub fn attempt_swap_loadout(data: &JoinData, update: &mut StateUpdate) { + let mut new_loadout = data.loadout.clone(); + new_loadout.active_item = data.loadout.second_item.clone(); + new_loadout.second_item = data.loadout.active_item.clone(); + update.loadout = new_loadout; } /// Checks that player can glide and updates `CharacterState` if so diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 7675f212da..74ca337cda 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -1,6 +1,6 @@ use super::utils::*; use crate::{ - comp::StateUpdate, + comp::{CharacterState, StateUpdate}, sys::character_behavior::{CharacterBehavior, JoinData}, }; @@ -12,11 +12,8 @@ impl CharacterBehavior for Data { handle_move(&data, &mut update); handle_jump(&data, &mut update); - handle_sit(&data, &mut update); handle_climb(&data, &mut update); handle_glide(&data, &mut update); - handle_unwield(&data, &mut update); - handle_swap_loadout(&data, &mut update); handle_ability1_input(&data, &mut update); handle_ability2_input(&data, &mut update); handle_ability3_input(&data, &mut update); @@ -24,4 +21,22 @@ impl CharacterBehavior for Data { update } + + fn toggle_sit(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_sit(data, &mut update); + update + } + + fn toggle_wield(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + update.character = CharacterState::Idle; + update + } + + fn swap_loadout(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_swap_loadout(data, &mut update); + update + } } diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index ebccef6258..729e4be506 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - Attacking, Body, CharacterState, Controller, ControllerInputs, Energy, Loadout, Mounting, - Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, + Attacking, Body, CharacterState, ControlAction, Controller, ControllerInputs, Energy, + Loadout, Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -15,6 +15,17 @@ use specs::{Entities, Entity, Join, LazyUpdate, Read, ReadStorage, System, Write pub trait CharacterBehavior { fn behavior(&self, data: &JoinData) -> StateUpdate; + // Impl these to provide behavior for these inputs + fn swap_loadout(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } + fn toggle_wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } + fn toggle_sit(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } + fn handle_event(&self, data: &JoinData, event: ControlAction) -> StateUpdate { + match event { + ControlAction::SwapLoadout => self.swap_loadout(data), + ControlAction::ToggleWield => self.toggle_wield(data), + ControlAction::ToggleSit => self.toggle_sit(data), + } + } // fn init(data: &JoinData) -> CharacterState; } @@ -47,13 +58,22 @@ pub type JoinTuple<'a> = ( &'a mut Ori, &'a mut Energy, &'a mut Loadout, - &'a Controller, + &'a mut Controller, &'a Stats, &'a Body, &'a PhysicsState, Option<&'a Attacking>, ); +fn incorporate_update(tuple: &mut JoinTuple, state_update: StateUpdate) { + *tuple.2 = state_update.character; + *tuple.3 = state_update.pos; + *tuple.4 = state_update.vel; + *tuple.5 = state_update.ori; + *tuple.6 = state_update.energy; + *tuple.7 = state_update.loadout; +} + impl<'a> JoinData<'a> { fn new(j: &'a JoinTuple<'a>, updater: &'a LazyUpdate, dt: &'a DeltaTime) -> Self { Self { @@ -96,7 +116,7 @@ impl<'a> System<'a> for Sys { WriteStorage<'a, Ori>, WriteStorage<'a, Energy>, WriteStorage<'a, Loadout>, - ReadStorage<'a, Controller>, + WriteStorage<'a, Controller>, ReadStorage<'a, Stats>, ReadStorage<'a, Body>, ReadStorage<'a, PhysicsState>, @@ -120,7 +140,7 @@ impl<'a> System<'a> for Sys { mut orientations, mut energies, mut loadouts, - controllers, + mut controllers, stats, bodies, physics_states, @@ -141,7 +161,7 @@ impl<'a> System<'a> for Sys { &mut orientations, &mut energies, &mut loadouts, - &controllers, + &mut controllers, &stats, &bodies, &physics_states, @@ -149,28 +169,49 @@ impl<'a> System<'a> for Sys { ) .join(); - while let Some(tuple) = join_iter.next() { - let j = JoinData::new(&tuple, &updater, &dt); - let inputs = &j.inputs; - + while let Some(mut tuple) = join_iter.next() { // Being dead overrides all other states - if j.stats.is_dead { - // Only options: click respawn - // prevent instant-respawns (i.e. player was holding attack) - // by disallowing while input is held down - if inputs.respawn.is_pressed() && !inputs.respawn.is_held_down() { - server_bus.emitter().emit(ServerEvent::Respawn(j.entity)); - } - // Or do nothing - return; + if tuple.9.is_dead { + // Do nothing + continue; } // If mounted, character state is controlled by mount // TODO: Make mounting a state - if let Some(Mounting(_)) = mountings.get(j.entity) { + if let Some(Mounting(_)) = mountings.get(tuple.0) { *tuple.2 = CharacterState::Sit {}; - return; + continue; } + let actions = std::mem::replace(&mut tuple.8.actions, Vec::new()); + for action in actions { + let j = JoinData::new(&tuple, &updater, &dt); + let mut state_update = match j.character { + CharacterState::Idle => states::idle::Data.handle_event(&j, action), + CharacterState::Climb => states::climb::Data.handle_event(&j, action), + CharacterState::Glide => states::glide::Data.handle_event(&j, action), + CharacterState::Sit => { + states::sit::Data::handle_event(&states::sit::Data, &j, action) + }, + CharacterState::BasicBlock => { + states::basic_block::Data.handle_event(&j, action) + }, + CharacterState::Roll(data) => data.handle_event(&j, action), + CharacterState::Wielding => states::wielding::Data.handle_event(&j, action), + CharacterState::Equipping(data) => data.handle_event(&j, action), + CharacterState::TripleStrike(data) => data.handle_event(&j, action), + CharacterState::BasicMelee(data) => data.handle_event(&j, action), + CharacterState::BasicRanged(data) => data.handle_event(&j, action), + CharacterState::Boost(data) => data.handle_event(&j, action), + CharacterState::DashMelee(data) => data.handle_event(&j, action), + CharacterState::TimedCombo(data) => data.handle_event(&j, action), + }; + local_emitter.append(&mut state_update.local_events); + server_emitter.append(&mut state_update.server_events); + incorporate_update(&mut tuple, state_update); + } + + let j = JoinData::new(&tuple, &updater, &dt); + let mut state_update = match j.character { CharacterState::Idle => states::idle::Data.behavior(&j), CharacterState::Climb => states::climb::Data.behavior(&j), @@ -188,14 +229,9 @@ impl<'a> System<'a> for Sys { CharacterState::TimedCombo(data) => data.behavior(&j), }; - *tuple.2 = state_update.character; - *tuple.3 = state_update.pos; - *tuple.4 = state_update.vel; - *tuple.5 = state_update.ori; - *tuple.6 = state_update.energy; - *tuple.7 = state_update.loadout; local_emitter.append(&mut state_update.local_events); server_emitter.append(&mut state_update.server_events); + incorporate_update(&mut tuple, state_update); } } } diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index 8617f7cf7a..c92522b1b5 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -8,7 +8,6 @@ use specs::{ saveload::{Marker, MarkerAllocator}, Entities, Join, Read, ReadStorage, System, WriteStorage, }; -use std::time::Duration; // const CHARGE_COST: i32 = 200; // const ROLL_COST: i32 = 30; @@ -34,25 +33,27 @@ impl<'a> System<'a> for Sys { uid_allocator, server_bus, _local_bus, - read_dt, + _dt, mut controllers, mut character_states, uids, ): Self::SystemData, ) { let mut server_emitter = server_bus.emitter(); - let dt = Duration::from_secs_f32(read_dt.0); - for (entity, _uid, controller, character_state) in ( - &entities, - &uids, - &mut controllers, - // &last_controllers, - &mut character_states, - ) - .join() + for (entity, _uid, controller, character_state) in + (&entities, &uids, &mut controllers, &mut character_states).join() { - let inputs = &mut controller.inputs; + let mut inputs = &mut controller.inputs; + + // Note(imbris): I avoided incrementing the duration with inputs.tick() because + // this is being done manually in voxygen right now so it would double up on + // speed of time. + // Perhaphs the duration aspects of inputs could be + // calculated exclusively on the server (since the client can't be + // trusted anyway). It needs to be considered if these calculations + // being on the client are critical for responsiveness/client-side prediction. + inputs.tick_freshness(); // Update `inputs.move_dir`. inputs.move_dir = if inputs.move_dir.magnitude_squared() > 1.0 { @@ -82,8 +83,8 @@ impl<'a> System<'a> for Sys { ControlEvent::InventoryManip(manip) => { *character_state = CharacterState::Idle; server_emitter.emit(ServerEvent::InventoryManip(entity, manip)) - }, /*ControlEvent::Respawn => - * server_emitter.emit(ServerEvent::Unmount(entity)), */ + }, + ControlEvent::Respawn => server_emitter.emit(ServerEvent::Respawn(entity)), } } } diff --git a/server/src/sys/message.rs b/server/src/sys/message.rs index f6d5e95435..c43d565dbf 100644 --- a/server/src/sys/message.rs +++ b/server/src/sys/message.rs @@ -1,7 +1,7 @@ use super::SysTimer; use crate::{auth_provider::AuthProvider, client::Client, CLIENT_TIMEOUT}; use common::{ - comp::{Admin, CanBuild, Controller, ForceUpdate, Ori, Player, Pos, Stats, Vel}, + comp::{Admin, CanBuild, ControlEvent, Controller, ForceUpdate, Ori, Player, Pos, Stats, Vel}, event::{EventBus, ServerEvent}, msg::{ validate_chat_msg, ChatMsgValidationError, ClientMsg, ClientState, PlayerListUpdate, @@ -208,7 +208,7 @@ impl<'a> System<'a> for Sys { }, ClientState::Character => { if let Some(controller) = controllers.get_mut(entity) { - controller.inputs = inputs; + controller.inputs.update_with_new(inputs); } }, ClientState::Pending => {}, @@ -220,12 +220,31 @@ impl<'a> System<'a> for Sys { client.error_state(RequestStateError::Impossible) }, ClientState::Character => { + // Skip respawn if client entity is alive + if let &ControlEvent::Respawn = &event { + if stats.get(entity).map_or(true, |s| !s.is_dead) { + continue; + } + } if let Some(controller) = controllers.get_mut(entity) { controller.events.push(event); } }, ClientState::Pending => {}, }, + ClientMsg::ControlAction(event) => match client.client_state { + ClientState::Connected + | ClientState::Registered + | ClientState::Spectator => { + client.error_state(RequestStateError::Impossible) + }, + ClientState::Character => { + if let Some(controller) = controllers.get_mut(entity) { + controller.actions.push(event); + } + }, + ClientState::Pending => {}, + }, ClientMsg::ChatMsg { message } => match client.client_state { ClientState::Connected => client.error_state(RequestStateError::Impossible), ClientState::Registered diff --git a/voxygen/src/key_state.rs b/voxygen/src/key_state.rs index e07474e0db..61b86128ae 100644 --- a/voxygen/src/key_state.rs +++ b/voxygen/src/key_state.rs @@ -5,6 +5,12 @@ pub struct KeyState { pub left: bool, pub up: bool, pub down: bool, + pub climb_up: bool, + pub climb_down: bool, + pub toggle_wield: bool, + pub toggle_sit: bool, + pub swap_loadout: bool, + pub respawn: bool, pub analog_matrix: Vec2, } @@ -15,6 +21,12 @@ impl KeyState { left: false, up: false, down: false, + climb_up: false, + climb_down: false, + toggle_wield: false, + toggle_sit: false, + swap_loadout: false, + respawn: false, analog_matrix: Vec2::zero(), } } @@ -35,4 +47,14 @@ impl KeyState { dir.normalized() } } + + pub fn climb(&self) -> Option { + use common::comp::Climb; + match (self.climb_up, self.climb_down) { + (true, false) => Some(Climb::Up), + (false, true) => Some(Climb::Down), + (true, true) => Some(Climb::Hold), + (false, false) => None, + } + } } diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 00e5bceb2b..3964a5778c 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -75,6 +75,8 @@ impl SessionState { impl SessionState { /// Tick the session (and the client attached to it). fn tick(&mut self, dt: Duration) -> Result { + self.inputs.tick(dt); + for event in self.client.borrow_mut().tick( self.inputs.clone(), dt, @@ -297,15 +299,25 @@ impl PlayState for SessionState { self.inputs.roll.set_state(state); } }, - Event::InputUpdate(GameInput::Respawn, state) => { - self.inputs.respawn.set_state(state); - }, + Event::InputUpdate(GameInput::Respawn, state) + if state != self.key_state.respawn => + { + self.key_state.respawn = state; + if state { + self.client.borrow_mut().respawn(); + } + } Event::InputUpdate(GameInput::Jump, state) => { self.inputs.jump.set_state(state); }, - Event::InputUpdate(GameInput::Sit, state) => { - self.inputs.sit.set_state(state); - }, + Event::InputUpdate(GameInput::Sit, state) + if state != self.key_state.toggle_sit => + { + self.key_state.toggle_sit = state; + if state { + self.client.borrow_mut().toggle_sit(); + } + } Event::InputUpdate(GameInput::MoveForward, state) => self.key_state.up = state, Event::InputUpdate(GameInput::MoveBack, state) => self.key_state.down = state, Event::InputUpdate(GameInput::MoveLeft, state) => self.key_state.left = state, @@ -314,20 +326,30 @@ impl PlayState for SessionState { self.inputs.glide.set_state(state); }, Event::InputUpdate(GameInput::Climb, state) => { - self.inputs.climb.set_state(state) + self.key_state.climb_up = state; }, Event::InputUpdate(GameInput::ClimbDown, state) => { - self.inputs.climb_down.set_state(state) + self.key_state.climb_down = state; }, Event::InputUpdate(GameInput::WallLeap, state) => { self.inputs.wall_leap.set_state(state) }, - Event::InputUpdate(GameInput::ToggleWield, state) => { - self.inputs.toggle_wield.set_state(state); - }, - Event::InputUpdate(GameInput::SwapLoadout, state) => { - self.inputs.swap_loadout.set_state(state); - }, + Event::InputUpdate(GameInput::ToggleWield, state) + if state != self.key_state.toggle_wield => + { + self.key_state.toggle_wield = state; + if state { + self.client.borrow_mut().toggle_wield(); + } + } + Event::InputUpdate(GameInput::SwapLoadout, state) + if state != self.key_state.swap_loadout => + { + self.key_state.swap_loadout = state; + if state { + self.client.borrow_mut().swap_loadout(); + } + } Event::InputUpdate(GameInput::Mount, true) => { let mut client = self.client.borrow_mut(); if client.is_mounted() { @@ -427,6 +449,8 @@ impl PlayState for SessionState { self.inputs.look_dir = cam_dir; + self.inputs.climb = self.key_state.climb(); + // Runs if either in a multiplayer server or the singleplayer server is unpaused if global_state.singleplayer.is_none() || !global_state.singleplayer.as_ref().unwrap().is_paused() From 3889ec729273b9de4e0257cf97ee5a1c04b5179b Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 25 Mar 2020 01:37:09 -0400 Subject: [PATCH 238/326] climbing tweaks, fix triple strike overflow, fix Last not registered --- client/src/lib.rs | 5 +++ common/src/comp/ability.rs | 2 +- common/src/states/climb.rs | 17 ++------ common/src/states/triple_strike.rs | 63 +++++++++++++++++------------- server/src/lib.rs | 1 - voxygen/src/scene/figure/mod.rs | 49 +++++++++++++---------- 6 files changed, 73 insertions(+), 64 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 5606d415ab..7b4bb8dd8b 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -113,6 +113,11 @@ impl Client { // Initialize `State` let mut state = State::default(); + // Client-only components + state + .ecs_mut() + .register::>(); + let entity = state.ecs_mut().apply_entity_package(entity_package); *state.ecs_mut().write_resource() = time_of_day; diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index eb8cd665e0..0d2538aea5 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -182,7 +182,7 @@ impl From<&CharacterAbility> for CharacterState { CharacterAbility::TripleStrike { base_damage } => { CharacterState::TripleStrike(triple_strike::Data { base_damage: *base_damage, - stage: 0, + stage: triple_strike::Stage::First, stage_exhausted: false, stage_time_active: Duration::default(), should_transition: true, diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 5beb746345..4614fe6721 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -46,19 +46,7 @@ impl CharacterBehavior for Data { // Expend energy if climbing let energy_use = match data.inputs.climb { Some(Climb::Up) | Some(Climb::Down) => 8, - Some(Climb::Hold) => data - .physics - .on_wall - .map(|wall_dir| { - // Calculate velocity perpendicular to the wall - let vel = update.vel.0; - let perp_vel = - vel - wall_dir * vel.dot(wall_dir) / wall_dir.magnitude_squared(); - // Enegry cost based on magnitude of this velocity - (perp_vel.magnitude() * 8.0) as i32 - }) - // Note: this is currently unreachable - .unwrap_or(0), + Some(Climb::Hold) => 1, // Note: this is currently unreachable None => 0, }; @@ -98,7 +86,8 @@ impl CharacterBehavior for Data { update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); }, Climb::Hold => { - update.vel.0.z = update.vel.0.z + data.dt.0 * GRAVITY * 1.5; + // Antigrav + update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.5).min(CLIMB_SPEED); update.vel.0 = Lerp::lerp( update.vel.0, Vec3::zero(), diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 7add9a345e..92b09c0309 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -11,6 +11,14 @@ const STAGE_DURATION: u64 = 600; const INITIAL_ACCEL: f32 = 200.0; const BASE_SPEED: f32 = 25.0; + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub enum Stage { + First, + Second, + Third, +} + /// ### A sequence of 3 incrementally increasing attacks. /// /// While holding down the `primary` button, perform a series of 3 attacks, @@ -21,8 +29,8 @@ const BASE_SPEED: f32 = 25.0; pub struct Data { /// The tool this state will read to handle damage, etc. pub base_damage: u32, - /// `int` denoting what stage (of 3) the attack is in. - pub stage: i8, + /// What stage (of 3) the attack is in. + pub stage: Stage, /// How long current stage has been active pub stage_time_active: Duration, /// Whether current stage has exhausted its attack @@ -42,22 +50,17 @@ impl CharacterBehavior for Data { .checked_add(Duration::from_secs_f32(data.dt.0)) .unwrap_or(Duration::default()); - let mut should_transition = self.should_transition; - let mut initialized = self.initialized; + // If player stops holding input, don't go to the next stage + let should_transition = data.inputs.primary.is_pressed() && self.should_transition; - // If player stops holding input, - if !data.inputs.primary.is_pressed() { - should_transition = false; - } - - if !initialized { + if !self.initialized { update.ori.0 = data.inputs.look_dir.normalized(); update.vel.0 = Vec3::zero(); - initialized = true; } + let initialized = true; // Handling movement - if self.stage == 0 { + if let Stage::First = self.stage { if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { let adjusted_accel = if data.physics.touch_entity.is_none() { INITIAL_ACCEL @@ -65,7 +68,7 @@ impl CharacterBehavior for Data { 0.0 }; - // Move player forward while in first third of each stage + // Move player forward while in first third of first stage if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) { update.vel.0 = update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * adjusted_accel; @@ -82,11 +85,13 @@ impl CharacterBehavior for Data { } // Handling attacking - if stage_time_active > Duration::from_millis(STAGE_DURATION / 2) && !self.stage_exhausted { + update.character = if stage_time_active > Duration::from_millis(STAGE_DURATION / 2) + && !self.stage_exhausted + { let dmg = match self.stage { - 1 => self.base_damage, - 2 => (self.base_damage as f32 * 1.5) as u32, - _ => self.base_damage / 2, + Stage::First => self.base_damage / 2, + Stage::Second => self.base_damage, + Stage::Third => (self.base_damage as f32 * 1.5) as u32, }; // Try to deal damage in second half of stage @@ -98,40 +103,44 @@ impl CharacterBehavior for Data { hit_count: 0, }); - update.character = CharacterState::TripleStrike(Data { + CharacterState::TripleStrike(Data { base_damage: self.base_damage, stage: self.stage, stage_time_active, stage_exhausted: true, should_transition, initialized, - }); + }) } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { if should_transition { - update.character = CharacterState::TripleStrike(Data { + CharacterState::TripleStrike(Data { base_damage: self.base_damage, - stage: self.stage + 1, + stage: match self.stage { + Stage::First => Stage::Second, + Stage::Second => Stage::Third, + Stage::Third => Stage::First, + }, stage_time_active: Duration::default(), stage_exhausted: false, should_transition, initialized, - }); + }) } else { - // Done - update.character = CharacterState::Wielding; // Make sure attack component is removed data.updater.remove::(data.entity); + // Done + CharacterState::Wielding } } else { - update.character = CharacterState::TripleStrike(Data { + CharacterState::TripleStrike(Data { base_damage: self.base_damage, stage: self.stage, stage_time_active, stage_exhausted: self.stage_exhausted, should_transition, initialized, - }); - } + }) + }; // Grant energy on successful hit if let Some(attack) = data.attacking { diff --git a/server/src/lib.rs b/server/src/lib.rs index f4b2560393..177e909733 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -83,7 +83,6 @@ impl Server { pub fn new(settings: ServerSettings) -> Result { let mut state = State::default(); state.ecs_mut().insert(EventBus::::default()); - // TODO: anything but this state .ecs_mut() .insert(AuthProvider::new(settings.auth_server_address.clone())); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index e5745bcc48..d64eeb148f 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -24,6 +24,7 @@ use common::{ Body, CharacterState, ItemKind, Last, Loadout, Ori, PhysicsState, Pos, Scale, Stats, Vel, }, state::State, + states::triple_strike, terrain::TerrainChunk, vol::RectRasterableVol, }; @@ -507,27 +508,33 @@ impl FigureMgr { ) }, CharacterState::TripleStrike(s) => match s.stage { - 0 => anim::character::AttackAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ), - 1 => anim::character::SpinAnimation::update_skeleton( - &target_base, - (active_tool_kind, time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ), - _ => anim::character::AttackAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ), + triple_strike::Stage::First => { + anim::character::AttackAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, + triple_strike::Stage::Second => { + anim::character::SpinAnimation::update_skeleton( + &target_base, + (active_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, + triple_strike::Stage::Third => { + anim::character::AttackAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, }, CharacterState::TimedCombo(s) => match s.stage { 0 | 2 => anim::character::AttackAnimation::update_skeleton( From 70481631539a4310764004c60a78a007f4ffca6c Mon Sep 17 00:00:00 2001 From: Capucho Date: Wed, 25 Mar 2020 12:51:43 +0000 Subject: [PATCH 239/326] Fixed Some minor bugs on the password field --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 18e18ac0b9..72c53ca4d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -557,7 +557,7 @@ dependencies = [ [[package]] name = "conrod_core" version = "0.63.0" -source = "git+https://gitlab.com/veloren/conrod.git?branch=capucho/hide_text_cursor_fix#e8a5b312ba0e3ab64efe54985d203137a34cd17d" +source = "git+https://gitlab.com/veloren/conrod.git?branch=capucho/hide_text_cursor_fix#df3a5d8098687fb0addf6fdf7c9ad2ac8794997f" dependencies = [ "conrod_derive", "copypasta", @@ -572,7 +572,7 @@ dependencies = [ [[package]] name = "conrod_derive" version = "0.63.0" -source = "git+https://gitlab.com/veloren/conrod.git?branch=capucho/hide_text_cursor_fix#e8a5b312ba0e3ab64efe54985d203137a34cd17d" +source = "git+https://gitlab.com/veloren/conrod.git?branch=capucho/hide_text_cursor_fix#df3a5d8098687fb0addf6fdf7c9ad2ac8794997f" dependencies = [ "proc-macro2 0.4.30", "quote 0.6.13", @@ -582,7 +582,7 @@ dependencies = [ [[package]] name = "conrod_winit" version = "0.63.0" -source = "git+https://gitlab.com/veloren/conrod.git?branch=capucho/hide_text_cursor_fix#e8a5b312ba0e3ab64efe54985d203137a34cd17d" +source = "git+https://gitlab.com/veloren/conrod.git?branch=capucho/hide_text_cursor_fix#df3a5d8098687fb0addf6fdf7c9ad2ac8794997f" [[package]] name = "const-random" From 857652ee2377fce77c0acd35659f0ecb01c56f1d Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 25 Mar 2020 07:24:55 -0700 Subject: [PATCH 240/326] Update triple_strike: * add knockback * prevent infinite repeat * more dashes --- common/src/comp/character_state.rs | 1 + common/src/states/basic_melee.rs | 1 + common/src/states/dash_melee.rs | 1 + common/src/states/timed_combo.rs | 1 + common/src/states/triple_strike.rs | 70 ++++++++++++++++-------------- common/src/states/utils.rs | 8 ++-- common/src/sys/combat.rs | 12 ++++- 7 files changed, 57 insertions(+), 37 deletions(-) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 851fe75f54..36bc0fe8c0 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -132,6 +132,7 @@ pub struct Attacking { pub max_angle: f32, pub applied: bool, pub hit_count: u32, + pub knockback: f32, } impl Component for Attacking { diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 0b46200640..03e7851b0d 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -48,6 +48,7 @@ impl CharacterBehavior for Data { max_angle: self.max_angle.to_radians(), applied: false, hit_count: 0, + knockback: 0.0, }); update.character = CharacterState::BasicMelee(Data { diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 1b69eeb987..c027b9f113 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -58,6 +58,7 @@ impl CharacterBehavior for Data { max_angle: 180_f32.to_radians(), applied: false, hit_count: 0, + knockback: 0.0, }); update.character = CharacterState::DashMelee(Data { diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs index 781f859dc9..5d0a873dcb 100644 --- a/common/src/states/timed_combo.rs +++ b/common/src/states/timed_combo.rs @@ -57,6 +57,7 @@ impl CharacterBehavior for Data { max_angle: 75_f32.to_radians(), applied: false, hit_count: 0, + knockback: 0.0, }); update.character = CharacterState::TimedCombo(Data { diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 92b09c0309..01b12be422 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -60,28 +60,26 @@ impl CharacterBehavior for Data { let initialized = true; // Handling movement - if let Stage::First = self.stage { - if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { - let adjusted_accel = if data.physics.touch_entity.is_none() { - INITIAL_ACCEL - } else { - 0.0 - }; - // Move player forward while in first third of first stage - if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) { - update.vel.0 = - update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * adjusted_accel; - let mag2 = update.vel.0.magnitude_squared(); - if mag2 > BASE_SPEED.powf(2.0) { - update.vel.0 = update.vel.0.normalized() * BASE_SPEED; - } - }; - } else { - handle_orientation(data, &mut update, 10.0); - } + if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { + let adjusted_accel = match (self.stage, data.physics.touch_entity.is_none()) { + (Stage::First, true) => INITIAL_ACCEL, + (Stage::Second, true) => INITIAL_ACCEL * 0.75, + (Stage::Third, true) => INITIAL_ACCEL * 0.75, + (_, _) => 0.0, + }; + + // Move player forward while in first third of first stage + if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) { + update.vel.0 = + update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * adjusted_accel; + let mag2 = update.vel.0.magnitude_squared(); + if mag2 > BASE_SPEED.powf(2.0) { + update.vel.0 = update.vel.0.normalized() * BASE_SPEED; + } + }; } else { - handle_move(data, &mut update); + handle_orientation(data, &mut update, 10.0); } // Handling attacking @@ -101,6 +99,7 @@ impl CharacterBehavior for Data { max_angle: 180_f32.to_radians(), applied: false, hit_count: 0, + knockback: 7.0, }); CharacterState::TripleStrike(Data { @@ -113,18 +112,25 @@ impl CharacterBehavior for Data { }) } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { if should_transition { - CharacterState::TripleStrike(Data { - base_damage: self.base_damage, - stage: match self.stage { - Stage::First => Stage::Second, - Stage::Second => Stage::Third, - Stage::Third => Stage::First, - }, - stage_time_active: Duration::default(), - stage_exhausted: false, - should_transition, - initialized, - }) + if let Stage::Third = self.stage { + // Make sure attack component is removed + data.updater.remove::(data.entity); + // Done + CharacterState::Wielding + } else { + CharacterState::TripleStrike(Data { + base_damage: self.base_damage, + stage: match self.stage { + Stage::First => Stage::Second, + Stage::Second => Stage::Third, + Stage::Third => Stage::First, + }, + stage_time_active: Duration::default(), + stage_exhausted: false, + should_transition, + initialized, + }) + } } else { // Make sure attack component is removed data.updater.remove::(data.entity); diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index d886081424..9829670ea8 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -159,7 +159,7 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { /// Will attempt to go into `loadout.active_item.ability1` pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.primary.is_pressed() { + if data.inputs.primary.is_just_pressed() { if let Some(ability) = data .loadout .active_item @@ -174,7 +174,7 @@ pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) { /// Will attempt to go into `loadout.active_item.ability2` pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.secondary.is_pressed() { + if data.inputs.secondary.is_just_pressed() { if let Some(ability) = data .loadout .active_item @@ -189,7 +189,7 @@ pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) { /// Will attempt to go into `loadout.active_item.ability3` pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.ability3.is_pressed() { + if data.inputs.ability3.is_just_pressed() { if let Some(ability) = data .loadout .active_item @@ -205,7 +205,7 @@ pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) { /// Checks that player can perform a dodge, then /// attempts to go into `loadout.active_item.dodge_ability` pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.roll.is_pressed() { + if data.inputs.roll.is_just_pressed() { if let Some(ability) = data .loadout .active_item diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index ee6a12f46c..c7413f311f 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -3,7 +3,7 @@ use crate::{ Agent, Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos, Scale, Stats, }, - event::{EventBus, ServerEvent}, + event::{EventBus, LocalEvent, ServerEvent}, sync::Uid, }; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; @@ -19,6 +19,7 @@ impl<'a> System<'a> for Sys { type SystemData = ( Entities<'a>, Read<'a, EventBus>, + Read<'a, EventBus>, ReadStorage<'a, Uid>, ReadStorage<'a, Pos>, ReadStorage<'a, Ori>, @@ -36,6 +37,7 @@ impl<'a> System<'a> for Sys { ( entities, server_bus, + local_bus, uids, positions, orientations, @@ -49,6 +51,7 @@ impl<'a> System<'a> for Sys { ): Self::SystemData, ) { let mut server_emitter = server_bus.emitter(); + let mut local_emitter = local_bus.emitter(); // Attacks for (entity, uid, pos, ori, scale_maybe, agent_maybe, _, _attacker_stats, attack) in ( &entities, @@ -128,6 +131,13 @@ impl<'a> System<'a> for Sys { cause: HealthSource::Attack { by: *uid }, }, }); + if attack.knockback != 0.0 { + local_emitter.emit(LocalEvent::KnockUp { + entity: b, + dir: ori.0, + force: attack.knockback, + }); + } attack.hit_count += 1; } } From 964256541e4b761763560eb2ba17a59997ce5ff0 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 25 Mar 2020 07:58:26 -0700 Subject: [PATCH 241/326] batter loadout swap logic --- common/src/states/utils.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 9829670ea8..4397e5ab22 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -128,11 +128,13 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { } /// Checks that player can Swap Weapons and updates `Loadout` if so -pub fn attempt_swap_loadout(data: &JoinData, update: &mut StateUpdate) { - let mut new_loadout = data.loadout.clone(); - new_loadout.active_item = data.loadout.second_item.clone(); - new_loadout.second_item = data.loadout.active_item.clone(); - update.loadout = new_loadout; +pub fn attempt_swap_loadout(_data: &JoinData, update: &mut StateUpdate) { + if update.loadout.second_item.is_some() { + std::mem::swap( + &mut update.loadout.active_item, + &mut update.loadout.second_item, + ); + } } /// Checks that player can glide and updates `CharacterState` if so From 8b05dda1d9fd9fd85a4d46e5819cef233f8351ee Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Wed, 25 Mar 2020 16:47:48 +0100 Subject: [PATCH 242/326] assset cleanup, transparency, new icons --- assets/common/items/apple.ron | 4 +- assets/common/items/cheese.ron | 4 +- assets/common/items/mushroom.ron | 4 +- assets/common/items/potion_minor.ron | 4 +- assets/common/items/velorite.ron | 6 ++- assets/common/items/veloritefrag.ron | 6 ++- assets/voxygen/element/icons/2haxe_m1.png | 3 ++ assets/voxygen/element/icons/2haxe_m1.vox | 3 -- assets/voxygen/element/icons/2haxe_m2.png | 3 ++ assets/voxygen/element/icons/2haxe_m2.vox | 3 -- assets/voxygen/element/icons/2hhammer_m1.png | 3 ++ assets/voxygen/element/icons/2hhammer_m1.vox | 3 -- assets/voxygen/element/icons/2hhammer_m2.png | 3 ++ assets/voxygen/element/icons/2hhammer_m2.vox | 3 -- assets/voxygen/element/icons/2hsword_m1.png | 3 ++ assets/voxygen/element/icons/2hsword_m1.vox | 3 -- assets/voxygen/element/icons/2hsword_m2.png | 3 ++ assets/voxygen/element/icons/2hsword_m2.vox | 3 -- .../voxygen/element/icons/2hsword_slash.png | 3 ++ .../voxygen/element/icons/2hsword_slash.vox | 3 -- assets/voxygen/element/icons/back.vox | 3 -- assets/voxygen/element/icons/belt.vox | 3 -- assets/voxygen/element/icons/bow_m1.png | 3 ++ assets/voxygen/element/icons/bow_m1.vox | 3 -- assets/voxygen/element/icons/chest.vox | 3 -- assets/voxygen/element/icons/collar.png | 3 ++ assets/voxygen/element/icons/collar.vox | 3 -- .../voxygen/element/icons/debug_wand_m1.png | 3 ++ .../voxygen/element/icons/debug_wand_m1.vox | 3 -- .../voxygen/element/icons/debug_wand_m2.png | 3 ++ .../voxygen/element/icons/debug_wand_m2.vox | 3 -- assets/voxygen/element/icons/feet.vox | 3 -- assets/voxygen/element/icons/gem.vox | 3 -- assets/voxygen/element/icons/hands.vox | 3 -- assets/voxygen/element/icons/head.vox | 3 -- assets/voxygen/element/icons/item_flower.png | 3 -- .../voxygen/element/icons/item_mushroom.vox | 3 -- assets/voxygen/element/icons/legs.vox | 3 -- assets/voxygen/element/icons/mainhand.vox | 3 -- assets/voxygen/element/icons/necklace.vox | 3 -- assets/voxygen/element/icons/offhand.vox | 3 -- assets/voxygen/element/icons/ring.vox | 3 -- assets/voxygen/element/icons/shoulders.vox | 3 -- assets/voxygen/element/icons/skill_charge.vox | 3 -- .../voxygen/element/icons/skill_charge_2.png | 3 ++ .../voxygen/element/icons/skill_charge_2.vox | 3 -- .../voxygen/element/icons/skill_charge_3.png | 3 ++ .../voxygen/element/icons/skill_charge_3.vox | 3 -- .../voxygen/element/icons/skill_slice_2.png | 3 ++ .../voxygen/element/icons/skill_slice_2.vox | 3 -- assets/voxygen/element/icons/skull.png | 3 ++ assets/voxygen/element/icons/skull.vox | 3 -- assets/voxygen/element/icons/skull_2.png | 3 ++ assets/voxygen/element/icons/skull_2.vox | 3 -- assets/voxygen/element/icons/staff_m1.png | 3 ++ assets/voxygen/element/icons/staff_m1.vox | 3 -- assets/voxygen/element/icons/staff_m2.png | 3 ++ assets/voxygen/element/icons/staff_m2.vox | 3 -- assets/voxygen/element/icons/tabard.vox | 3 -- assets/voxygen/item_image_manifest.ron | 4 +- common/src/comp/inventory/item.rs | 1 + voxygen/src/hud/img_ids.rs | 35 +++++++++-------- voxygen/src/hud/skillbar.rs | 38 +++++++++++-------- 63 files changed, 118 insertions(+), 147 deletions(-) create mode 100644 assets/voxygen/element/icons/2haxe_m1.png delete mode 100644 assets/voxygen/element/icons/2haxe_m1.vox create mode 100644 assets/voxygen/element/icons/2haxe_m2.png delete mode 100644 assets/voxygen/element/icons/2haxe_m2.vox create mode 100644 assets/voxygen/element/icons/2hhammer_m1.png delete mode 100644 assets/voxygen/element/icons/2hhammer_m1.vox create mode 100644 assets/voxygen/element/icons/2hhammer_m2.png delete mode 100644 assets/voxygen/element/icons/2hhammer_m2.vox create mode 100644 assets/voxygen/element/icons/2hsword_m1.png delete mode 100644 assets/voxygen/element/icons/2hsword_m1.vox create mode 100644 assets/voxygen/element/icons/2hsword_m2.png delete mode 100644 assets/voxygen/element/icons/2hsword_m2.vox create mode 100644 assets/voxygen/element/icons/2hsword_slash.png delete mode 100644 assets/voxygen/element/icons/2hsword_slash.vox delete mode 100644 assets/voxygen/element/icons/back.vox delete mode 100644 assets/voxygen/element/icons/belt.vox create mode 100644 assets/voxygen/element/icons/bow_m1.png delete mode 100644 assets/voxygen/element/icons/bow_m1.vox delete mode 100644 assets/voxygen/element/icons/chest.vox create mode 100644 assets/voxygen/element/icons/collar.png delete mode 100644 assets/voxygen/element/icons/collar.vox create mode 100644 assets/voxygen/element/icons/debug_wand_m1.png delete mode 100644 assets/voxygen/element/icons/debug_wand_m1.vox create mode 100644 assets/voxygen/element/icons/debug_wand_m2.png delete mode 100644 assets/voxygen/element/icons/debug_wand_m2.vox delete mode 100644 assets/voxygen/element/icons/feet.vox delete mode 100644 assets/voxygen/element/icons/gem.vox delete mode 100644 assets/voxygen/element/icons/hands.vox delete mode 100644 assets/voxygen/element/icons/head.vox delete mode 100644 assets/voxygen/element/icons/item_flower.png delete mode 100644 assets/voxygen/element/icons/item_mushroom.vox delete mode 100644 assets/voxygen/element/icons/legs.vox delete mode 100644 assets/voxygen/element/icons/mainhand.vox delete mode 100644 assets/voxygen/element/icons/necklace.vox delete mode 100644 assets/voxygen/element/icons/offhand.vox delete mode 100644 assets/voxygen/element/icons/ring.vox delete mode 100644 assets/voxygen/element/icons/shoulders.vox delete mode 100644 assets/voxygen/element/icons/skill_charge.vox create mode 100644 assets/voxygen/element/icons/skill_charge_2.png delete mode 100644 assets/voxygen/element/icons/skill_charge_2.vox create mode 100644 assets/voxygen/element/icons/skill_charge_3.png delete mode 100644 assets/voxygen/element/icons/skill_charge_3.vox create mode 100644 assets/voxygen/element/icons/skill_slice_2.png delete mode 100644 assets/voxygen/element/icons/skill_slice_2.vox create mode 100644 assets/voxygen/element/icons/skull.png delete mode 100644 assets/voxygen/element/icons/skull.vox create mode 100644 assets/voxygen/element/icons/skull_2.png delete mode 100644 assets/voxygen/element/icons/skull_2.vox create mode 100644 assets/voxygen/element/icons/staff_m1.png delete mode 100644 assets/voxygen/element/icons/staff_m1.vox create mode 100644 assets/voxygen/element/icons/staff_m2.png delete mode 100644 assets/voxygen/element/icons/staff_m2.vox delete mode 100644 assets/voxygen/element/icons/tabard.vox diff --git a/assets/common/items/apple.ron b/assets/common/items/apple.ron index 46c20763ad..7179502e22 100644 --- a/assets/common/items/apple.ron +++ b/assets/common/items/apple.ron @@ -1,6 +1,8 @@ Item( name: "Apple", - description: "Red and juicy.", + description: "Red and juicy. + +Restores 20 Health.", kind: Consumable( kind: Apple, effect: Health(( diff --git a/assets/common/items/cheese.ron b/assets/common/items/cheese.ron index 00a2e124f5..6e0bbe751e 100644 --- a/assets/common/items/cheese.ron +++ b/assets/common/items/cheese.ron @@ -1,6 +1,8 @@ Item( name: "Dwarven Cheese", - description: "Aromatic and nutritious.", + description: "Aromatic and nutritious. + +Restores 40 Health.", kind: Consumable( kind: Cheese, effect: Health(( diff --git a/assets/common/items/mushroom.ron b/assets/common/items/mushroom.ron index 04d300329e..09702079e9 100644 --- a/assets/common/items/mushroom.ron +++ b/assets/common/items/mushroom.ron @@ -1,6 +1,8 @@ Item( name: "Mushroom", - description: "Hopefully this one is not poisonous.", + description: "Hopefully this one is not poisonous. + +Restores 10 Health.", kind: Consumable( kind: Mushroom, effect: Health(( diff --git a/assets/common/items/potion_minor.ron b/assets/common/items/potion_minor.ron index ab3f5c1110..aaf0b948c9 100644 --- a/assets/common/items/potion_minor.ron +++ b/assets/common/items/potion_minor.ron @@ -1,6 +1,8 @@ Item( name: "Minor Potion", - description: "Restores a small amount of Health.", + description: "Restores a small amount of Health. + +Restores 50 Health.", kind: Consumable( kind: PotionMinor, effect: Health(( diff --git a/assets/common/items/velorite.ron b/assets/common/items/velorite.ron index 342a743847..2cefef40b0 100644 --- a/assets/common/items/velorite.ron +++ b/assets/common/items/velorite.ron @@ -1,8 +1,10 @@ Item( name: "Velorite", - description: "Just a slight touch makes you feel the knowledge of ancient times.", + description: "Just a slight touch makes you feel the knowledge of ancient times. + +Increases Exp by 20.", kind: Consumable( kind: Velorite, - effect: Xp(50), + effect: Xp(20), ), ) diff --git a/assets/common/items/veloritefrag.ron b/assets/common/items/veloritefrag.ron index 417eca94b4..d29abf6a4f 100644 --- a/assets/common/items/veloritefrag.ron +++ b/assets/common/items/veloritefrag.ron @@ -1,8 +1,10 @@ Item( name: "Velorite Fragment", - description: "Small runes sparkle on its surface.", + description: "Small runes sparkle on its surface. + +Increases Exp by 10.", kind: Consumable( kind: VeloriteFrag, - effect: Xp(20), + effect: Xp(10), ), ) diff --git a/assets/voxygen/element/icons/2haxe_m1.png b/assets/voxygen/element/icons/2haxe_m1.png new file mode 100644 index 0000000000..5b26cd998a --- /dev/null +++ b/assets/voxygen/element/icons/2haxe_m1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bddd94d15a337c957883c58d8c0cc437f59c1adab9cadd083d3bbaeedc4540be +size 947 diff --git a/assets/voxygen/element/icons/2haxe_m1.vox b/assets/voxygen/element/icons/2haxe_m1.vox deleted file mode 100644 index 0acae649d4..0000000000 --- a/assets/voxygen/element/icons/2haxe_m1.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:30285d002357f18544456a063c66549e804075979a9f4c5e120eab2bf58923f5 -size 57713 diff --git a/assets/voxygen/element/icons/2haxe_m2.png b/assets/voxygen/element/icons/2haxe_m2.png new file mode 100644 index 0000000000..3a4718ad2d --- /dev/null +++ b/assets/voxygen/element/icons/2haxe_m2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7967e73c1aad20878c3a72c3763a5500b2d147d09ec052351d7bb700866e2246 +size 708 diff --git a/assets/voxygen/element/icons/2haxe_m2.vox b/assets/voxygen/element/icons/2haxe_m2.vox deleted file mode 100644 index 7df7f10fed..0000000000 --- a/assets/voxygen/element/icons/2haxe_m2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:95af09926041808154892286e0f0088783c24bc43e45bb00d717921cc29ec4e9 -size 57937 diff --git a/assets/voxygen/element/icons/2hhammer_m1.png b/assets/voxygen/element/icons/2hhammer_m1.png new file mode 100644 index 0000000000..522767626c --- /dev/null +++ b/assets/voxygen/element/icons/2hhammer_m1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1cd9bde2284656bd1b44856098cd32dd02f51d1bc233fc7658d71ae57e6468f2 +size 597 diff --git a/assets/voxygen/element/icons/2hhammer_m1.vox b/assets/voxygen/element/icons/2hhammer_m1.vox deleted file mode 100644 index 691b8df6f2..0000000000 --- a/assets/voxygen/element/icons/2hhammer_m1.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6bbd371eedd0710e05a13e894edd9a3d13e209ace6df0f27fda344fc110a944b -size 57721 diff --git a/assets/voxygen/element/icons/2hhammer_m2.png b/assets/voxygen/element/icons/2hhammer_m2.png new file mode 100644 index 0000000000..143311f155 --- /dev/null +++ b/assets/voxygen/element/icons/2hhammer_m2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a87e8d141f83e135f42e9d3b6b0c8b1d961506d8f8e28398e67c6a84d998411 +size 806 diff --git a/assets/voxygen/element/icons/2hhammer_m2.vox b/assets/voxygen/element/icons/2hhammer_m2.vox deleted file mode 100644 index dfbcfa3460..0000000000 --- a/assets/voxygen/element/icons/2hhammer_m2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e32dd1e339f933a80e701e3fdf997a1b9e361083059a1e301d2324091c9ff4e1 -size 57809 diff --git a/assets/voxygen/element/icons/2hsword_m1.png b/assets/voxygen/element/icons/2hsword_m1.png new file mode 100644 index 0000000000..1b36b8a46f --- /dev/null +++ b/assets/voxygen/element/icons/2hsword_m1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f442cb6ef061bfee9e66168b9c32e5bdb7e59fde790c0be31f93785857779e6f +size 784 diff --git a/assets/voxygen/element/icons/2hsword_m1.vox b/assets/voxygen/element/icons/2hsword_m1.vox deleted file mode 100644 index fabf326482..0000000000 --- a/assets/voxygen/element/icons/2hsword_m1.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:29883a92ce28f094ff146f942101ea0e6dd4882b42a18259d16636cf5d091b38 -size 57621 diff --git a/assets/voxygen/element/icons/2hsword_m2.png b/assets/voxygen/element/icons/2hsword_m2.png new file mode 100644 index 0000000000..d54cda0e92 --- /dev/null +++ b/assets/voxygen/element/icons/2hsword_m2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b7a2ab9fac21eade39278def1c4e76ce793737c6bd3f4d55037a930ad304e34 +size 929 diff --git a/assets/voxygen/element/icons/2hsword_m2.vox b/assets/voxygen/element/icons/2hsword_m2.vox deleted file mode 100644 index d62b2b3b40..0000000000 --- a/assets/voxygen/element/icons/2hsword_m2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:131cba637ca168a8fa1f3d5fba6e163323d5ff3968dca00d7839366142fa3c4b -size 58366 diff --git a/assets/voxygen/element/icons/2hsword_slash.png b/assets/voxygen/element/icons/2hsword_slash.png new file mode 100644 index 0000000000..18d36aef24 --- /dev/null +++ b/assets/voxygen/element/icons/2hsword_slash.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b827aa50558455a6ba821e4f032d45ae04d7bfdcecd2597fc1cb6c0b0e6d1973 +size 782 diff --git a/assets/voxygen/element/icons/2hsword_slash.vox b/assets/voxygen/element/icons/2hsword_slash.vox deleted file mode 100644 index ea2a8e1eb9..0000000000 --- a/assets/voxygen/element/icons/2hsword_slash.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:dfd03c8de8d52353a54311ef539d0a03786929e1b0842e9806f389659d8faca2 -size 57621 diff --git a/assets/voxygen/element/icons/back.vox b/assets/voxygen/element/icons/back.vox deleted file mode 100644 index a9f8eee678..0000000000 --- a/assets/voxygen/element/icons/back.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f0fed53b953e06948cf233f3d4f3f27bac06c12f1b9c1687e1b47a3f66d5bc35 -size 62604 diff --git a/assets/voxygen/element/icons/belt.vox b/assets/voxygen/element/icons/belt.vox deleted file mode 100644 index 49d0bff7cb..0000000000 --- a/assets/voxygen/element/icons/belt.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aa92f8ffc54d7838fa7bb90ff76df7a9e67d95bcbf1c339b7563f5e7b57befe1 -size 61268 diff --git a/assets/voxygen/element/icons/bow_m1.png b/assets/voxygen/element/icons/bow_m1.png new file mode 100644 index 0000000000..b9cb8af63d --- /dev/null +++ b/assets/voxygen/element/icons/bow_m1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff1b52d259aafa8384e05dc5ae2ca3dcd7a88c7a4456149cc7a37e9e0c106ad5 +size 808 diff --git a/assets/voxygen/element/icons/bow_m1.vox b/assets/voxygen/element/icons/bow_m1.vox deleted file mode 100644 index 1ec968f5d3..0000000000 --- a/assets/voxygen/element/icons/bow_m1.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e0575beddb81670abd9e2cd8571b0d21bd902756f0b321ffa5b3433bc96da480 -size 61545 diff --git a/assets/voxygen/element/icons/chest.vox b/assets/voxygen/element/icons/chest.vox deleted file mode 100644 index e7593a2382..0000000000 --- a/assets/voxygen/element/icons/chest.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3446d88d65fd7bdbb5b195dbe45809a56c27e527c59360a4be32795c4f034f0d -size 61612 diff --git a/assets/voxygen/element/icons/collar.png b/assets/voxygen/element/icons/collar.png new file mode 100644 index 0000000000..a24983860c --- /dev/null +++ b/assets/voxygen/element/icons/collar.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78eb78fef1639b035869ee1de1fed5ccc86caf1199651ce8881afc10f8d737d2 +size 506 diff --git a/assets/voxygen/element/icons/collar.vox b/assets/voxygen/element/icons/collar.vox deleted file mode 100644 index 92b3346340..0000000000 --- a/assets/voxygen/element/icons/collar.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f8d5ce0e89923fa33ab1cb169ff7cab414c863956b6b7620bd4a6b82409af3e5 -size 58948 diff --git a/assets/voxygen/element/icons/debug_wand_m1.png b/assets/voxygen/element/icons/debug_wand_m1.png new file mode 100644 index 0000000000..ae496eec91 --- /dev/null +++ b/assets/voxygen/element/icons/debug_wand_m1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca52786d85797896195c075c1bc91c22f2c87d6a9e64f08dac65d3da3e91e48b +size 839 diff --git a/assets/voxygen/element/icons/debug_wand_m1.vox b/assets/voxygen/element/icons/debug_wand_m1.vox deleted file mode 100644 index cbb55307e3..0000000000 --- a/assets/voxygen/element/icons/debug_wand_m1.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8d1dc3cc5efc9e9a6278af9fef4894abd7a3e99635b518d063c54f39d64b55e4 -size 58630 diff --git a/assets/voxygen/element/icons/debug_wand_m2.png b/assets/voxygen/element/icons/debug_wand_m2.png new file mode 100644 index 0000000000..c0b53ecf35 --- /dev/null +++ b/assets/voxygen/element/icons/debug_wand_m2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50277d1222dd1b25ded80edc443830deb74db368a66dac5c0398112b9e4618cb +size 900 diff --git a/assets/voxygen/element/icons/debug_wand_m2.vox b/assets/voxygen/element/icons/debug_wand_m2.vox deleted file mode 100644 index 91bb7626c9..0000000000 --- a/assets/voxygen/element/icons/debug_wand_m2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7b58de07685de2a912cd7f11cd627af86d19d7efb060b2b92d74f74031b12a5f -size 59241 diff --git a/assets/voxygen/element/icons/feet.vox b/assets/voxygen/element/icons/feet.vox deleted file mode 100644 index 20127bc7e0..0000000000 --- a/assets/voxygen/element/icons/feet.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8a20ba6cc66e585069fddeacdafd89746504ee6ac81e57fcfa2a34293b81cc24 -size 61212 diff --git a/assets/voxygen/element/icons/gem.vox b/assets/voxygen/element/icons/gem.vox deleted file mode 100644 index 4a346ed2bf..0000000000 --- a/assets/voxygen/element/icons/gem.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0eeda19e2850ef3b521cb6a4d7d2ea9c85bc7c141ef01abf589880cc3738b234 -size 62236 diff --git a/assets/voxygen/element/icons/hands.vox b/assets/voxygen/element/icons/hands.vox deleted file mode 100644 index 3f47c0c3a3..0000000000 --- a/assets/voxygen/element/icons/hands.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0cc139fac19e456c4ed91df21fd41f5c8ef868bfd968055ff66d4ff8acb7c3b5 -size 61644 diff --git a/assets/voxygen/element/icons/head.vox b/assets/voxygen/element/icons/head.vox deleted file mode 100644 index de41bf0327..0000000000 --- a/assets/voxygen/element/icons/head.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5beedc43d289152ecbe622f36bb203fa0b39ff51cf1c77e7ef59fddfa075b4ee -size 63728 diff --git a/assets/voxygen/element/icons/item_flower.png b/assets/voxygen/element/icons/item_flower.png deleted file mode 100644 index 80ecd5f523..0000000000 --- a/assets/voxygen/element/icons/item_flower.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3630ed8f161514e1fb5960c0faa59c88f1be17aae9bacc26f935b7ffc18332f9 -size 13979 diff --git a/assets/voxygen/element/icons/item_mushroom.vox b/assets/voxygen/element/icons/item_mushroom.vox deleted file mode 100644 index afb453857f..0000000000 --- a/assets/voxygen/element/icons/item_mushroom.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3d777456ff641f2e4a0b3e87caa01b264cc93ec9554ed123c42ee91729ba6589 -size 57847 diff --git a/assets/voxygen/element/icons/legs.vox b/assets/voxygen/element/icons/legs.vox deleted file mode 100644 index 85375ee204..0000000000 --- a/assets/voxygen/element/icons/legs.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:62817a15ea83e0af343bce8eac4260cd0a1c5386cea227ad1ca1b7ae488b1439 -size 60140 diff --git a/assets/voxygen/element/icons/mainhand.vox b/assets/voxygen/element/icons/mainhand.vox deleted file mode 100644 index 68d68bf9d7..0000000000 --- a/assets/voxygen/element/icons/mainhand.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b29577ae26134a468e767001ac69929e1ad656af694bda38b75e4bee83da673d -size 15844 diff --git a/assets/voxygen/element/icons/necklace.vox b/assets/voxygen/element/icons/necklace.vox deleted file mode 100644 index 7712027800..0000000000 --- a/assets/voxygen/element/icons/necklace.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9f6c06b002a1d836fe8921dbe2888232c47040a120efb8617f26846cd9a1af21 -size 59564 diff --git a/assets/voxygen/element/icons/offhand.vox b/assets/voxygen/element/icons/offhand.vox deleted file mode 100644 index 4e65802558..0000000000 --- a/assets/voxygen/element/icons/offhand.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3fc29c53975102582cf938181311f0ada6a2c7c9e044f9a4d0883ab9c899fc4e -size 19088 diff --git a/assets/voxygen/element/icons/ring.vox b/assets/voxygen/element/icons/ring.vox deleted file mode 100644 index cddf5b7483..0000000000 --- a/assets/voxygen/element/icons/ring.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1c73f9198c986bce203d62afaeeb5690a4009cb9b0b731eb99775a36b3932466 -size 19496 diff --git a/assets/voxygen/element/icons/shoulders.vox b/assets/voxygen/element/icons/shoulders.vox deleted file mode 100644 index bc260ac9f8..0000000000 --- a/assets/voxygen/element/icons/shoulders.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b277676fd12242532f0002c074df50066da54accf6e2b54d94c65ca3ac0b2107 -size 60428 diff --git a/assets/voxygen/element/icons/skill_charge.vox b/assets/voxygen/element/icons/skill_charge.vox deleted file mode 100644 index a9bffe8990..0000000000 --- a/assets/voxygen/element/icons/skill_charge.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bec1cad802a5751cfa9cd4d4d0159adb51e4af3e67ced65db25fcaff059e0b6f -size 57497 diff --git a/assets/voxygen/element/icons/skill_charge_2.png b/assets/voxygen/element/icons/skill_charge_2.png new file mode 100644 index 0000000000..a6cca701f6 --- /dev/null +++ b/assets/voxygen/element/icons/skill_charge_2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8db97a822c66a4f2a7045518ddef3af9015388b5184a856f44f81c6be8884cb4 +size 1408 diff --git a/assets/voxygen/element/icons/skill_charge_2.vox b/assets/voxygen/element/icons/skill_charge_2.vox deleted file mode 100644 index d81971f6c4..0000000000 --- a/assets/voxygen/element/icons/skill_charge_2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:02751d68177ade46c3692a7abdc64f6ad222f41bab01dcb0be8beb49f91b3ae4 -size 63221 diff --git a/assets/voxygen/element/icons/skill_charge_3.png b/assets/voxygen/element/icons/skill_charge_3.png new file mode 100644 index 0000000000..e4b0404ee7 --- /dev/null +++ b/assets/voxygen/element/icons/skill_charge_3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7beb4d4f02c645e24956391ea1b1900724f62cee8a03dc7e0732e288ab5485fd +size 1448 diff --git a/assets/voxygen/element/icons/skill_charge_3.vox b/assets/voxygen/element/icons/skill_charge_3.vox deleted file mode 100644 index dc30739204..0000000000 --- a/assets/voxygen/element/icons/skill_charge_3.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:af880f99099b027bad51aa2e16ea622012d9f99a3ce3691909a041f5afa1c927 -size 63217 diff --git a/assets/voxygen/element/icons/skill_slice_2.png b/assets/voxygen/element/icons/skill_slice_2.png new file mode 100644 index 0000000000..6d1c8b295f --- /dev/null +++ b/assets/voxygen/element/icons/skill_slice_2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1f2f61e5942a5b2f079c2dafebe0860cbd66e4bf2b9b87e2be104ca47220c474 +size 758 diff --git a/assets/voxygen/element/icons/skill_slice_2.vox b/assets/voxygen/element/icons/skill_slice_2.vox deleted file mode 100644 index 565f4a2280..0000000000 --- a/assets/voxygen/element/icons/skill_slice_2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b86b496d708546a05dca97b53805061b4c6d430fa5ff34b22400e08dccc2ae64 -size 62249 diff --git a/assets/voxygen/element/icons/skull.png b/assets/voxygen/element/icons/skull.png new file mode 100644 index 0000000000..5b86367acf --- /dev/null +++ b/assets/voxygen/element/icons/skull.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:912330f19920dbe6a90c9e22cba4624c3900ceb98850b3f623ff136f421f3435 +size 340 diff --git a/assets/voxygen/element/icons/skull.vox b/assets/voxygen/element/icons/skull.vox deleted file mode 100644 index 024f888038..0000000000 --- a/assets/voxygen/element/icons/skull.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1708cf57ec4d132e3478f86aef7083d37cf85b890a2ddcf4278d8b5d4394f53d -size 57720 diff --git a/assets/voxygen/element/icons/skull_2.png b/assets/voxygen/element/icons/skull_2.png new file mode 100644 index 0000000000..9c7b1696d9 --- /dev/null +++ b/assets/voxygen/element/icons/skull_2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a2b2d4093520f1513b0909e808f50390a80a093170bf2d0583fbf65a2f21c51 +size 310 diff --git a/assets/voxygen/element/icons/skull_2.vox b/assets/voxygen/element/icons/skull_2.vox deleted file mode 100644 index 140ab7bf2c..0000000000 --- a/assets/voxygen/element/icons/skull_2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d9ddbabd913b6b5afaf2d9344b457cdd9068ee5a1f019141c3f13e364b463dda -size 57784 diff --git a/assets/voxygen/element/icons/staff_m1.png b/assets/voxygen/element/icons/staff_m1.png new file mode 100644 index 0000000000..3955caf46a --- /dev/null +++ b/assets/voxygen/element/icons/staff_m1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b743bbccb12309114e55a35d21b196f6a97b458d4ea208b48654019c2d24e90 +size 795 diff --git a/assets/voxygen/element/icons/staff_m1.vox b/assets/voxygen/element/icons/staff_m1.vox deleted file mode 100644 index ae5682d692..0000000000 --- a/assets/voxygen/element/icons/staff_m1.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0d80d1b075793a3e120cddd98b1f85742e0462e0c403cfaf9d8260a7c8fda045 -size 58444 diff --git a/assets/voxygen/element/icons/staff_m2.png b/assets/voxygen/element/icons/staff_m2.png new file mode 100644 index 0000000000..f22841c798 --- /dev/null +++ b/assets/voxygen/element/icons/staff_m2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:813f0d30ac437525faa2adb022ce4f57d1beac2ec60d0e9b671c16111eef379c +size 1091 diff --git a/assets/voxygen/element/icons/staff_m2.vox b/assets/voxygen/element/icons/staff_m2.vox deleted file mode 100644 index 74fb309158..0000000000 --- a/assets/voxygen/element/icons/staff_m2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b1dd296878391652f6c5151cee6eba5bf003e07360ecbe08f342f7ac631d103d -size 60360 diff --git a/assets/voxygen/element/icons/tabard.vox b/assets/voxygen/element/icons/tabard.vox deleted file mode 100644 index 69999e3228..0000000000 --- a/assets/voxygen/element/icons/tabard.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7fae087fbbddc39faf126b7a7ae80301f331c048677fbd047d790918043c29e9 -size 62188 diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index ee846de0da..f9c40cf4ec 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -55,10 +55,10 @@ (0.0, 0.0, 0.0), (-90.0, 90.0, 0.0), 2.4, ), // Other - Utility(Collar): VoxTrans( + Utility(Collar): Png( "element.icons.collar", - (0.0, 0.0, 0.0), (-90.0, 180.0, 10.0), 1.3, ), + // Armor // Assassin Set Armor(Chest(Assassin)): VoxTrans( diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 9c051b8b6c..78e99a9a54 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -375,6 +375,7 @@ impl Item { "common.items.collar", "common.items.weapons.starter_sword", "common.items.weapons.starter_axe", + "common.items.weapons.staff_nature", "common.items.weapons.starter_hammer", "common.items.weapons.starter_bow", "common.items.weapons.starter_staff", diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 9a1ffd7d18..1bf0638ecc 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -103,27 +103,11 @@ image_ids! { fireplace: "voxygen.element.misc_bg.fireplace", // Skill Icons - twohsword_m1: "voxygen.element.icons.2hsword_m1", - twohsword_m2: "voxygen.element.icons.2hsword_m2", - twohhammer_m1: "voxygen.element.icons.2hhammer_m1", - twohhammer_m2: "voxygen.element.icons.2hhammer_m2", - twohaxe_m1: "voxygen.element.icons.2haxe_m1", - twohaxe_m2: "voxygen.element.icons.2haxe_m2", - bow_m1: "voxygen.element.icons.bow_m1", bow_m2: "voxygen.element.icons.bow_m2", - staff_m1: "voxygen.element.icons.staff_m1", - staff_m2: "voxygen.element.icons.staff_m2", - flyingrod_m1: "voxygen.element.icons.debug_wand_m1", - flyingrod_m2: "voxygen.element.icons.debug_wand_m2", - charge: "voxygen.element.icons.skill_charge_3", // Icons flower: "voxygen.element.icons.item_flower", grass: "voxygen.element.icons.item_grass", - apple: "voxygen.element.icons.item_apple", - mushroom: "voxygen.element.icons.item_mushroom", - skull: "voxygen.element.icons.skull", - skull_2: "voxygen.element.icons.skull_2", // Map indicator_mmap: "voxygen.element.buttons.indicator_mmap", @@ -202,6 +186,25 @@ image_ids! { ////////////////////////////////////////////////////////////////////////////////////////////////////// + // Skill Icons + twohsword_m1: "voxygen.element.icons.2hsword_m1", + twohsword_m2: "voxygen.element.icons.2hsword_m2", + twohhammer_m1: "voxygen.element.icons.2hhammer_m1", + twohhammer_m2: "voxygen.element.icons.2hhammer_m2", + twohaxe_m1: "voxygen.element.icons.2haxe_m1", + twohaxe_m2: "voxygen.element.icons.2haxe_m2", + bow_m1: "voxygen.element.icons.bow_m1", + //bow_m2: "voxygen.element.icons.bow_m2", + staff_m1: "voxygen.element.icons.staff_m1", + staff_m2: "voxygen.element.icons.staff_m2", + flyingrod_m1: "voxygen.element.icons.debug_wand_m1", + flyingrod_m2: "voxygen.element.icons.debug_wand_m2", + charge: "voxygen.element.icons.skill_charge_3", + + // Other Icons + skull: "voxygen.element.icons.skull", + skull_2: "voxygen.element.icons.skull_2", + // Map map_bg: "voxygen.element.misc_bg.map_bg", map_frame: "voxygen.element.misc_bg.map_frame", diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index c8fa8ea2f4..68da07b996 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -19,11 +19,12 @@ use conrod_core::{ widget::{self, Button, Image, Rectangle, Text}, widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, }; -//use const_tweaker::tweak; -use std::time::{Duration, Instant}; // <- REMOVE THIS BEFORE MERGE! -/*#[tweak(min = 0.5, max = 1.0, step = 0.01)] -const ALPHA: f32 = 0.90;*/ +use std::time::{Duration, Instant}; +/* +use const_tweaker::tweak; +#[tweak(min = 0.0, max = 1.0, step = 0.01)] +const RGB: f32 = 0.1;*/ widget_ids! { struct Ids { @@ -608,9 +609,9 @@ impl<'a> Widget for Skillbar<'a> { ToolKind::Bow(_) => self.imgs.bow_m1, ToolKind::Staff(_) => self.imgs.staff_m1, ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m1, - _ => self.imgs.twohaxe_m1, + _ => self.imgs.nothing, }, - _ => self.imgs.twohaxe_m1, + _ => self.imgs.nothing, }, ) // Insert Icon here .w( @@ -704,21 +705,20 @@ impl<'a> Widget for Skillbar<'a> { match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { ToolKind::Sword(_) => self.imgs.charge, - ToolKind::Hammer(_) => self.imgs.twohhammer_m2, - ToolKind::Axe(_) => self.imgs.twohaxe_m2, - ToolKind::Bow(_) => self.imgs.bow_m2, + ToolKind::Hammer(_) => self.imgs.nothing, + ToolKind::Axe(_) => self.imgs.nothing, + ToolKind::Bow(_) => self.imgs.nothing, ToolKind::Staff(StaffKind::Sceptre) => self.imgs.heal_0, ToolKind::Staff(_) => self.imgs.staff_m2, ToolKind::Debug(DebugKind::Boost) => self.imgs.flyingrod_m2, - _ => self.imgs.twohaxe_m2, + _ => self.imgs.nothing, }, - _ => self.imgs.twohaxe_m2, + _ => self.imgs.nothing, }, ) // Insert Icon here .w( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow(_) => 30.0 * scale, ToolKind::Staff(_) => 30.0 * scale, _ => 38.0 * scale, }, @@ -728,7 +728,6 @@ impl<'a> Widget for Skillbar<'a> { .h( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { - ToolKind::Bow(_) => 30.0 * scale, ToolKind::Staff(_) => 30.0 * scale, _ => 38.0 * scale, }, @@ -736,14 +735,21 @@ impl<'a> Widget for Skillbar<'a> { }, ) .middle_of(state.ids.m2_slot_bg) - .color( + .image_color( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { ToolKind::Sword(_) => { if self.energy.current() as f64 >= 200.0 { Color::Rgba(1.0, 1.0, 1.0, 1.0) } else { - Color::Rgba(0.4, 0.4, 0.4, 1.0) + Color::Rgba(0.3, 0.3, 0.3, 0.8) + } + }, + ToolKind::Staff(StaffKind::Sceptre) => { + if self.energy.current() as f64 >= 400.0 { + Color::Rgba(1.0, 1.0, 1.0, 1.0) + } else { + Color::Rgba(0.3, 0.3, 0.3, 0.8) } }, _ => Color::Rgba(1.0, 1.0, 1.0, 1.0), @@ -844,7 +850,7 @@ impl<'a> Widget for Skillbar<'a> { .color(if self.energy.current() as f64 >= 500.0 { Some(Color::Rgba(1.0, 1.0, 1.0, 1.0)) } else { - Some(Color::Rgba(0.4, 0.4, 0.4, 1.0)) + Some(Color::Rgba(0.3, 0.3, 0.3, 0.8)) }) .middle_of(state.ids.slot1_bg) .set(state.ids.slot1_icon, ui); From 5f10cdf0c655bd2494515e93e5ffb09669dd80ac Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Wed, 25 Mar 2020 21:06:01 +0100 Subject: [PATCH 243/326] adjusted foot step sounds, inventory space above bag --- assets/voxygen/audio/sfx.ron | 4 ++-- voxygen/src/hud/buttons.rs | 40 +++++++++++++++++++++++++++++++++--- voxygen/src/hud/mod.rs | 1 + 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/assets/voxygen/audio/sfx.ron b/assets/voxygen/audio/sfx.ron index e29cd9d1e4..cc28f980d3 100644 --- a/assets/voxygen/audio/sfx.ron +++ b/assets/voxygen/audio/sfx.ron @@ -9,7 +9,7 @@ "voxygen.audio.sfx.footsteps.stepgrass_5", "voxygen.audio.sfx.footsteps.stepgrass_6", ], - threshold: 0.4, + threshold: 0.25, ), GliderOpen: ( files: [ @@ -96,4 +96,4 @@ threshold: 0.3, ) } -) \ No newline at end of file +) diff --git a/voxygen/src/hud/buttons.rs b/voxygen/src/hud/buttons.rs index 7cc9b7b0c2..926436bc68 100644 --- a/voxygen/src/hud/buttons.rs +++ b/voxygen/src/hud/buttons.rs @@ -1,15 +1,17 @@ +use super::{img_ids::Imgs, Windows, BLACK, CRITICAL_HP_COLOR, LOW_HP_COLOR, TEXT_COLOR}; +use crate::ui::{fonts::ConrodVoxygenFonts, ToggleButton}; +use client::Client; use conrod_core::{ widget::{self, Button, Image, Text}, widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon, }; -use super::{img_ids::Imgs, Windows, TEXT_COLOR}; -use crate::ui::{fonts::ConrodVoxygenFonts, ToggleButton}; - widget_ids! { struct Ids { bag, bag_text, + bag_space_bg, + bag_space, bag_show_map, map_button, settings_button, @@ -22,6 +24,7 @@ widget_ids! { #[derive(WidgetCommon)] pub struct Buttons<'a> { + client: &'a Client, open_windows: &'a Windows, show_map: bool, show_bag: bool, @@ -34,6 +37,7 @@ pub struct Buttons<'a> { impl<'a> Buttons<'a> { pub fn new( + client: &'a Client, open_windows: &'a Windows, show_map: bool, show_bag: bool, @@ -41,6 +45,7 @@ impl<'a> Buttons<'a> { fonts: &'a ConrodVoxygenFonts, ) -> Self { Self { + client, open_windows, show_map, show_bag, @@ -78,6 +83,11 @@ impl<'a> Widget for Buttons<'a> { fn update(self, args: widget::UpdateArgs) -> Self::Event { let widget::UpdateArgs { state, ui, .. } = args; + let invs = self.client.inventories(); + let inventory = match invs.get(self.client.entity()) { + Some(inv) => inv, + None => return None, + }; // Bag if !self.show_map { @@ -110,6 +120,30 @@ impl<'a> Widget for Buttons<'a> { .color(TEXT_COLOR) .set(state.ids.bag_text, ui); } + if !self.show_bag { + let space_used = inventory.amount; + let space_max = inventory.slots.len(); + let bag_space = format!("{}/{}", space_used, space_max); + let bag_space_percentage = space_used as f32 / space_max as f32; + Text::new(&bag_space) + .mid_top_with_margin_on(state.ids.bag, -15.0) + .font_size(12) + .font_id(self.fonts.cyri.conrod_id) + .color(BLACK) + .set(state.ids.bag_space_bg, ui); + Text::new(&bag_space) + .top_left_with_margins_on(state.ids.bag_space_bg, -1.0, -1.0) + .font_size(12) + .font_id(self.fonts.cyri.conrod_id) + .color(if bag_space_percentage < 0.8 { + TEXT_COLOR + } else if bag_space_percentage < 1.0 { + LOW_HP_COLOR + } else { + CRITICAL_HP_COLOR + }) + .set(state.ids.bag_space, ui); + } // 0 Settings if Button::image(self.imgs.settings) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 13e7ff3476..75a10241c1 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1573,6 +1573,7 @@ impl Hud { // Bag button and nearby icons match Buttons::new( + client, &self.show.open_windows, self.show.map, self.show.bag, From 74eacbe27cb19843461ccb396c7bb1f43202f3a3 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Wed, 25 Mar 2020 22:23:03 +0100 Subject: [PATCH 244/326] fix "Npcs can't be healed anymore" --- common/src/sys/combat.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index c7413f311f..33ae5d8073 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -72,12 +72,23 @@ impl<'a> System<'a> for Sys { attack.applied = true; // Go through all other entities - for (b, uid_b, pos_b, ori_b, scale_b_maybe, character_b, stats_b, body_b) in ( + for ( + b, + uid_b, + pos_b, + ori_b, + scale_b_maybe, + agent_b_maybe, + character_b, + stats_b, + body_b, + ) in ( &entities, &uids, &positions, &orientations, scales.maybe(), + agents.maybe(), &character_states, &stats, &bodies, @@ -106,11 +117,12 @@ impl<'a> System<'a> for Sys { // NPCs do less damage: if agent_maybe.is_some() { - if healthchange > 0 { - healthchange = 0; - } else if healthchange < 0 { - healthchange = (healthchange / 2).min(-1); - } + healthchange = (healthchange / 2).min(-1); + } + + // Don't heal npc's hp + if agent_b_maybe.is_some() && healthchange > 0 { + healthchange = 0; } if rand::random() { From ae0a3076e3f0de69a3d44cae2624ebc22ca3a3d8 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Wed, 25 Mar 2020 23:10:50 +0100 Subject: [PATCH 245/326] Allow holding ability keys again --- common/src/states/utils.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 4397e5ab22..3e9113fc46 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -161,7 +161,7 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) { /// Will attempt to go into `loadout.active_item.ability1` pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.primary.is_just_pressed() { + if data.inputs.primary.is_pressed() { if let Some(ability) = data .loadout .active_item @@ -176,7 +176,7 @@ pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) { /// Will attempt to go into `loadout.active_item.ability2` pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.secondary.is_just_pressed() { + if data.inputs.secondary.is_pressed() { if let Some(ability) = data .loadout .active_item @@ -191,7 +191,7 @@ pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) { /// Will attempt to go into `loadout.active_item.ability3` pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.ability3.is_just_pressed() { + if data.inputs.ability3.is_pressed() { if let Some(ability) = data .loadout .active_item @@ -207,7 +207,7 @@ pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) { /// Checks that player can perform a dodge, then /// attempts to go into `loadout.active_item.dodge_ability` pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { - if data.inputs.roll.is_just_pressed() { + if data.inputs.roll.is_pressed() { if let Some(ability) = data .loadout .active_item From e6f50b40326c08d5b04d18889fb76d0695864129 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 25 Mar 2020 18:40:07 -0400 Subject: [PATCH 246/326] Replace uses of normalized() to avoid setting ori to NaN values, tweak triple strike code --- common/src/states/dash_melee.rs | 4 ++- common/src/states/triple_strike.rs | 43 ++++++++++++++---------------- common/src/sys/projectile.rs | 7 +++-- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index c027b9f113..b3d67a8256 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -28,7 +28,9 @@ impl CharacterBehavior for Data { if self.initialize { update.vel.0 = data.inputs.look_dir * 20.0; - update.ori.0 = Vec3::from(data.vel.0.xy()).normalized(); + if let Some(dir) = Vec3::from(data.vel.0.xy()).try_normalized() { + update.ori.0 = dir; + } } if self.buildup_duration != Duration::default() && data.physics.touch_entity.is_none() { diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 01b12be422..72e80ef453 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -54,13 +54,14 @@ impl CharacterBehavior for Data { let should_transition = data.inputs.primary.is_pressed() && self.should_transition; if !self.initialized { - update.ori.0 = data.inputs.look_dir.normalized(); update.vel.0 = Vec3::zero(); + if let Some(dir) = data.inputs.look_dir.try_normalized() { + update.ori.0 = dir; + } } let initialized = true; // Handling movement - if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { let adjusted_accel = match (self.stage, data.physics.touch_entity.is_none()) { (Stage::First, true) => INITIAL_ACCEL, @@ -69,7 +70,7 @@ impl CharacterBehavior for Data { (_, _) => 0.0, }; - // Move player forward while in first third of first stage + // Move player forward while in first third of each stage if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) { update.vel.0 = update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * adjusted_accel; @@ -111,26 +112,22 @@ impl CharacterBehavior for Data { initialized, }) } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { - if should_transition { - if let Stage::Third = self.stage { - // Make sure attack component is removed - data.updater.remove::(data.entity); - // Done - CharacterState::Wielding - } else { - CharacterState::TripleStrike(Data { - base_damage: self.base_damage, - stage: match self.stage { - Stage::First => Stage::Second, - Stage::Second => Stage::Third, - Stage::Third => Stage::First, - }, - stage_time_active: Duration::default(), - stage_exhausted: false, - should_transition, - initialized, - }) - } + let next_stage = match self.stage { + _ if !should_transition => None, + Stage::First => Some(Stage::Second), + Stage::Second => Some(Stage::Third), + Stage::Third => None, + }; + + if let Some(stage) = next_stage { + CharacterState::TripleStrike(Data { + base_damage: self.base_damage, + stage, + stage_time_active: Duration::default(), + stage_exhausted: false, + should_transition, + initialized, + }) } else { // Make sure attack component is removed data.updater.remove::(data.entity); diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index 4a8b15dd7b..e09050cc0f 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -110,8 +110,11 @@ impl<'a> System<'a> for Sys { } } } else { - if let Some(vel) = velocities.get(entity) { - ori.0 = vel.0.normalized(); + if let Some(dir) = velocities + .get(entity) + .and_then(|vel| vel.0.try_normalized()) + { + ori.0 = dir; } } From 175fea98ef78b22c423fa70f341dc0e2ae0dd0fd Mon Sep 17 00:00:00 2001 From: jshipsey Date: Thu, 26 Mar 2020 01:35:25 -0400 Subject: [PATCH 247/326] more cleanup, WIP fake swimming --- voxygen/src/anim/character/equip.rs | 10 +- voxygen/src/anim/character/idlewield.rs | 247 ------------------------ voxygen/src/anim/character/mod.rs | 8 +- voxygen/src/anim/character/swim.rs | 56 ++---- voxygen/src/anim/character/wield.rs | 176 +++++++++++------ voxygen/src/scene/figure/mod.rs | 30 +-- 6 files changed, 150 insertions(+), 377 deletions(-) delete mode 100644 voxygen/src/anim/character/idlewield.rs diff --git a/voxygen/src/anim/character/equip.rs b/voxygen/src/anim/character/equip.rs index 5792e05043..277a46e890 100644 --- a/voxygen/src/anim/character/equip.rs +++ b/voxygen/src/anim/character/equip.rs @@ -22,13 +22,13 @@ impl Animation for EquipAnimation { let lab = 1.0; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.6).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 10.6).sin()); + * ((anim_time as f32 * lab as f32 * 16.0).sin()); let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 10.6).sin()).powf(2.0 as f32))) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 10.6).sin()); + * ((anim_time as f32 * lab as f32 * 16.0).sin()); let equip_slow = 1.0 + (anim_time as f32 * 12.0 + PI).cos(); let equip_slowa = 1.0 + (anim_time as f32 * 12.0 + PI / 4.0).cos(); @@ -36,7 +36,7 @@ impl Animation for EquipAnimation { let wave_ultra_slow = (anim_time as f32 * 10.0 + PI).sin(); let wave_ultra_slow_cos = (anim_time as f32 * 30.0 + PI).cos(); - let wave = (anim_time as f32 * 10.0).sin(); + let wave = (anim_time as f32 * 16.0).sin(); match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { diff --git a/voxygen/src/anim/character/idlewield.rs b/voxygen/src/anim/character/idlewield.rs deleted file mode 100644 index 2b7a9df755..0000000000 --- a/voxygen/src/anim/character/idlewield.rs +++ /dev/null @@ -1,247 +0,0 @@ -use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; -use common::comp::item::ToolKind; -use std::{f32::consts::PI, ops::Mul}; - -use vek::*; - -pub struct IdleWieldAnimation; - -impl Animation for IdleWieldAnimation { - type Dependency = (Option, f32, f64); - type Skeleton = CharacterSkeleton; - - fn update_skeleton( - skeleton: &Self::Skeleton, - (active_tool_kind, _velocity, global_time): Self::Dependency, - anim_time: f64, - _rate: &mut f32, - skeleton_attr: &SkeletonAttr, - ) -> Self::Skeleton { - let mut next = (*skeleton).clone(); - let _lab = 1.0; - let wave_slow_cos = (anim_time as f32 * 6.0 + PI).cos(); - let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); - let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); - - let wave = (anim_time as f32 * 1.0).sin(); - match active_tool_kind { - //TODO: Inventory - Some(ToolKind::Sword(_)) => { - next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0); - next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2); - next.l_hand.scale = Vec3::one() * 1.04; - next.r_hand.offset = Vec3::new(1.25, -5.5, -8.0); - next.r_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 0.0, -6.0); - next.main.ori = Quaternion::rotation_x(-0.1) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.15) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow_cos * 0.08); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Axe(_)) => { - next.l_hand.offset = Vec3::new(-4.0, 3.0, 6.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_z(3.14 - 0.3) - * Quaternion::rotation_y(-0.8); - next.l_hand.scale = Vec3::one() * 1.08; - next.r_hand.offset = Vec3::new(-2.5, 9.0, 4.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_z(3.14 - 0.3) - * Quaternion::rotation_y(-0.8); - next.r_hand.scale = Vec3::one() * 1.06; - next.main.offset = Vec3::new(-6.0, 10.0, -1.0); - next.main.ori = Quaternion::rotation_x(1.27) - * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(-0.8); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(0.0, 0.0, 0.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.1 + 0.2) - * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(wave_ultra_slow * 0.1 + 0.0); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Hammer(_)) => { - next.l_hand.offset = Vec3::new(-7.0, 4.6, 7.5); - next.l_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.32); - next.l_hand.scale = Vec3::one() * 1.08; - next.r_hand.offset = Vec3::new(8.0, 5.75, 4.0); - next.r_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.22); - next.r_hand.scale = Vec3::one() * 1.06; - next.main.offset = Vec3::new(6.0, 7.0, 0.0); - next.main.ori = Quaternion::rotation_x(0.3) - * Quaternion::rotation_y(-1.35) - * Quaternion::rotation_z(1.57); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(0.0, 0.0, 0.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.15) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow_cos * 0.08); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Staff(_)) => { - next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); - next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0); - next.r_hand.ori = Quaternion::rotation_x(1.8) - * Quaternion::rotation_y(0.5) - * Quaternion::rotation_z(-0.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(11.0, 9.0, 10.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(3.14 + 0.3) - * Quaternion::rotation_z(0.9); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Shield(_)) => { - next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x, - 4.5 + skeleton_attr.weapon_y, - 0.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Bow(_)) => { - next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); - next.l_hand.ori = Quaternion::rotation_x(1.20) - * Quaternion::rotation_y(-0.6) - * Quaternion::rotation_z(-0.3); - next.l_hand.scale = Vec3::one() * 1.05; - next.r_hand.offset = Vec3::new(3.0, -1.0, -5.0); - next.r_hand.ori = Quaternion::rotation_x(1.20) - * Quaternion::rotation_y(-0.6) - * Quaternion::rotation_z(-0.3); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(3.0, 2.0, -13.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.3) - * Quaternion::rotation_z(-0.6); - next.main.scale = Vec3::one(); - - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); - next.control.scale = Vec3::one(); - }, - Some(ToolKind::Dagger(_)) => { - next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0); - next.l_hand.ori = Quaternion::rotation_x(-0.3); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0); - next.r_hand.ori = Quaternion::rotation_x(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - -6.0 + skeleton_attr.weapon_x, - 4.5 + skeleton_attr.weapon_y, - 0.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); - }, - Some(ToolKind::Debug(_)) => { - next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); - next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.l_hand.scale = Vec3::one() * 1.01; - next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); - next.r_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(-0.3); - next.r_hand.scale = Vec3::one() * 1.01; - next.main.offset = Vec3::new( - 5.0 + skeleton_attr.weapon_x, - 8.75 + skeleton_attr.weapon_y, - -2.0, - ); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(-1.27) - * Quaternion::rotation_z(wave * -0.25); - next.main.scale = Vec3::one(); - }, - _ => {}, - } - let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 10.0) - .floor() - .mul(7331.0) - .sin() - * 0.2, - ((global_time + anim_time) as f32 / 10.0) - .floor() - .mul(1337.0) - .sin() - * 0.1, - ); - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 14.0 + wave_ultra_slow * 0.1, - ); - next.head.ori = - Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 7.0 + wave_ultra_slow * 0.5); - next.chest.ori = - Quaternion::rotation_y(wave_ultra_slow_cos * 0.04) * Quaternion::rotation_z(0.15); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = - Quaternion::rotation_y(wave_ultra_slow_cos * 0.03) * Quaternion::rotation_z(0.22); - next.belt.scale = Vec3::one() * 1.02; - - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(0.3); - next.shorts.scale = Vec3::one(); - - next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0); - next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2); - next.l_foot.scale = Vec3::one(); - - next.r_foot.offset = Vec3::new(3.4, 3.5, 8.0); - next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035); - next.r_foot.scale = Vec3::one(); - - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - - next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); - next.l_control.ori = Quaternion::rotation_x(0.0); - next.l_control.scale = Vec3::one(); - - next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); - next.r_control.ori = Quaternion::rotation_x(0.0); - next.r_control.scale = Vec3::one(); - next - } -} diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 89e2f823ad..b441d4a937 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -6,7 +6,6 @@ pub mod climb; pub mod equip; pub mod gliding; pub mod idle; -pub mod idlewield; pub mod jump; pub mod roll; pub mod run; @@ -21,10 +20,9 @@ pub mod wield; pub use self::{ attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, charge::ChargeAnimation, climb::ClimbAnimation, equip::EquipAnimation, - gliding::GlidingAnimation, idle::IdleAnimation, idlewield::IdleWieldAnimation, - jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, - sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation, swim::SwimAnimation, - wield::WieldAnimation, + gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, roll::RollAnimation, + run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, + stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation, }; use super::{Bone, Skeleton}; diff --git a/voxygen/src/anim/character/swim.rs b/voxygen/src/anim/character/swim.rs index f67d609572..d5fdec6df5 100644 --- a/voxygen/src/anim/character/swim.rs +++ b/voxygen/src/anim/character/swim.rs @@ -19,32 +19,17 @@ impl Animation for SwimAnimation { let mut next = (*skeleton).clone(); let speed = Vec2::::from(velocity).magnitude(); - *rate = speed; + *rate = 1.0; let lab = 1.0; - let long = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.8).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 0.8).sin()); - let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.6).sin()); + let short = (anim_time as f32 * lab as f32 * 2.0).sin(); - let shortalt = (((5.0) - / (1.5 - + 3.5 - * ((anim_time as f32 * lab as f32 * 1.6 + PI / 2.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.6 + PI / 2.0).sin()); + let shortalt = (anim_time as f32 * lab as f32 * 2.0 + PI / 2.0).sin(); - let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.6).sin()); + let foot = (anim_time as f32 * lab as f32 * 2.0).sin(); - let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0 / 2.0).sin(); + let wave_stop = (anim_time as f32 * 3.0).min(PI / 2.0 / 2.0).sin(); let head_look = Vec2::new( ((global_time + anim_time) as f32 / 18.0) @@ -64,7 +49,7 @@ impl Animation for SwimAnimation { -3.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 13.0 + short * 0.3, ); - next.head.ori = Quaternion::rotation_z(head_look.x + long * -0.1 - short * 0.3) + next.head.ori = Quaternion::rotation_z(head_look.x - short * 0.3) * Quaternion::rotation_x(head_look.y + 0.35); next.head.scale = Vec3::one() * skeleton_attr.head_scale; @@ -80,30 +65,20 @@ impl Animation for SwimAnimation { next.shorts.ori = Quaternion::rotation_z(short * 0.4); next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new( - -6.0 + wave_stop * -1.0, - -0.25 + short * 3.0, - 4.0 + short * -1.5, - ); - next.l_hand.ori = - Quaternion::rotation_x(0.8 + short * 1.2) * Quaternion::rotation_y(wave_stop * 0.1); + next.l_hand.offset = Vec3::new(-6.0, -0.25 - foot * 1.0, 5.0 + foot * -2.5); + next.l_hand.ori = Quaternion::rotation_x(0.8 + foot * -0.5) * Quaternion::rotation_y(0.2); next.l_hand.scale = Vec3::one(); - next.r_hand.offset = Vec3::new( - 6.0 + wave_stop * 1.0, - -0.25 + short * -3.0, - 4.0 + short * 1.5, - ); - next.r_hand.ori = - Quaternion::rotation_x(0.8 + short * -1.2) * Quaternion::rotation_y(wave_stop * -0.1); + next.r_hand.offset = Vec3::new(6.0, -0.25 + foot * 1.0, 5.0 + foot * 2.5); + next.r_hand.ori = Quaternion::rotation_x(0.8 + foot * 0.5) * Quaternion::rotation_y(-0.2); next.r_hand.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 6.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); + next.l_foot.offset = Vec3::new(-3.4, 6.0 + foot * 1.0, 0.0 + foot * 5.5); + next.l_foot.ori = Quaternion::rotation_x(-1.40 + foot * 0.5); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 6.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); + next.r_foot.offset = Vec3::new(3.4, 6.0 - foot * 1.0, 0.0 + foot * -5.5); + next.r_foot.ori = Quaternion::rotation_x(-1.40 + foot * -0.5); next.r_foot.scale = Vec3::one(); next.l_shoulder.offset = Vec3::new(-5.0, -1.0, 4.7); @@ -140,8 +115,7 @@ impl Animation for SwimAnimation { next.torso.offset = Vec3::new(0.0, -0.3 + shortalt * -0.065, 0.4) * skeleton_attr.scaler; next.torso.ori = - Quaternion::rotation_x(wave_stop * speed * -0.05 + wave_stop * speed * -0.005) - * Quaternion::rotation_y(0.0); + Quaternion::rotation_x(speed * -0.157 * wave_stop * 1.6) * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.control.offset = Vec3::new(0.0, 0.0, 0.0); diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index b6955c0eb9..8d646b8f9b 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -12,29 +12,27 @@ impl Animation for WieldAnimation { fn update_skeleton( skeleton: &Self::Skeleton, - (active_tool_kind, _velocity, global_time): Self::Dependency, + (active_tool_kind, velocity, global_time): Self::Dependency, anim_time: f64, - _rate: &mut f32, + rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { + *rate = 1.0; let mut next = (*skeleton).clone(); let lab = 1.0; - - let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.6).sin()); - let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.6).sin()); + let wave_slow_cos = (anim_time as f32 * 6.0 + PI).cos(); let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); - let long = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.8).sin()).powf(2.0 as f32))) + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 0.8).sin()); - let wave = (anim_time as f32 * 1.0).sin(); + * ((anim_time as f32 * lab as f32 * 16.0).sin()); + let short = (((5.0) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 16.0).sin()); + + let wave = (anim_time as f32 * 16.0).sin(); match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { @@ -199,58 +197,118 @@ impl Animation for WieldAnimation { }, _ => {}, } - let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 6.0) - .floor() - .mul(7331.0) - .sin() - * 0.2, - ((global_time + anim_time) as f32 / 6.0) - .floor() - .mul(1337.0) - .sin() - * 0.1, - ); - next.head.offset = Vec3::new( - 0.0, - -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 13.0 + short * 0.2, - ); - next.head.ori = Quaternion::rotation_z(head_look.x + long * 0.1 - short * 0.2) - * Quaternion::rotation_x(head_look.y + 0.35); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1); - next.chest.ori = Quaternion::rotation_z(short * 0.2); - next.chest.scale = Vec3::one(); + if velocity > 0.5 { + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 6.0) + .floor() + .mul(7331.0) + .sin() + * 0.2, + ((global_time + anim_time) as f32 / 6.0) + .floor() + .mul(1337.0) + .sin() + * 0.1, + ); + next.head.offset = Vec3::new( + 0.0, + -3.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 13.0 + short * 0.2, + ); + next.head.ori = Quaternion::rotation_z(head_look.x - short * 0.2) + * Quaternion::rotation_x(head_look.y + 0.35); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = Quaternion::rotation_z(short * 0.15); - next.belt.scale = Vec3::one(); + next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1); + next.chest.ori = Quaternion::rotation_z(short * 0.2); + next.chest.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(short * 0.4); - next.shorts.scale = Vec3::one(); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_z(short * 0.15); + next.belt.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); - next.l_foot.scale = Vec3::one(); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(short * 0.4); + next.shorts.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); - next.r_foot.scale = Vec3::one(); + next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); + next.l_foot.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(-0.2); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); + next.r_foot.scale = Vec3::one(); - next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); - next.l_control.ori = Quaternion::rotation_x(0.0); - next.l_control.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(-0.2); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); + } else { + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 10.0) + .floor() + .mul(7331.0) + .sin() + * 0.2, + ((global_time + anim_time) as f32 / 10.0) + .floor() + .mul(1337.0) + .sin() + * 0.1, + ); + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 14.0 + wave_ultra_slow * 0.1, + ); + next.head.ori = + Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = + Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 7.0 + wave_ultra_slow * 0.5); + next.chest.ori = + Quaternion::rotation_y(wave_ultra_slow_cos * 0.04) * Quaternion::rotation_z(0.15); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = + Quaternion::rotation_y(wave_ultra_slow_cos * 0.03) * Quaternion::rotation_z(0.22); + next.belt.scale = Vec3::one() * 1.02; + + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(0.3); + next.shorts.scale = Vec3::one(); + + next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0); + next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, 3.5, 8.0); + next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035); + next.r_foot.scale = Vec3::one(); + + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); + } - next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); - next.r_control.ori = Quaternion::rotation_x(0.0); - next.r_control.scale = Vec3::one(); next } } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index d64eeb148f..c0ae0e3530 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -429,7 +429,7 @@ impl FigureMgr { physics.in_fluid, // In water ) { // Standing - (true, false, false) => anim::character::StandAnimation::update_skeleton( + (true, false, _) => anim::character::StandAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, time), state.state_time, @@ -437,7 +437,7 @@ impl FigureMgr { skeleton_attr, ), // Running - (true, true, false) => anim::character::RunAnimation::update_skeleton( + (true, true, _) => anim::character::RunAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0, ori.0, state.last_ori, time), state.state_time, @@ -453,7 +453,7 @@ impl FigureMgr { skeleton_attr, ), // Swim - (_, _, true) => anim::character::SwimAnimation::update_skeleton( + (false, _, true) => anim::character::SwimAnimation::update_skeleton( &CharacterSkeleton::new(), (active_tool_kind, vel.0, ori.0.magnitude(), time), state.state_time, @@ -581,23 +581,13 @@ impl FigureMgr { ) }, CharacterState::Wielding { .. } => { - if vel.0.magnitude_squared() > 0.5 { - anim::character::WieldAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) - } else { - anim::character::IdleWieldAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) - } + anim::character::WieldAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) }, CharacterState::Glide { .. } => { anim::character::GlidingAnimation::update_skeleton( From 0446a56f00e92281e5842b8a10625cf9b8739e3d Mon Sep 17 00:00:00 2001 From: Shane Handley Date: Thu, 26 Mar 2020 18:23:57 +1100 Subject: [PATCH 248/326] Regen energy when sitting. --- common/src/sys/stats.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/sys/stats.rs b/common/src/sys/stats.rs index 25b92017dd..61396bc8fb 100644 --- a/common/src/sys/stats.rs +++ b/common/src/sys/stats.rs @@ -75,7 +75,7 @@ impl<'a> System<'a> for Sys { // Accelerate recharging energy if not wielding. match character_state { - CharacterState::Idle { .. } => { + CharacterState::Idle { .. } | CharacterState::Sit { .. } => { if { let energy = energy.get_unchecked(); energy.current() < energy.maximum() From 604a6cf16901969760e8c1b9ba2cb5244daad42e Mon Sep 17 00:00:00 2001 From: Songtronix Date: Thu, 26 Mar 2020 12:41:30 +0100 Subject: [PATCH 249/326] feat: log server version --- server-cli/src/main.rs | 7 +++++-- server/src/lib.rs | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index 466d5d9b79..0702f341e1 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -9,9 +9,12 @@ const TPS: u64 = 30; fn main() { // Init logging + if let Err(_) = std::env::var("RUST_LOG") { + std::env::set_var("RUST_LOG", "info"); + } pretty_env_logger::init(); - info!("Starting server-cli..."); + info!("Starting server..."); // Set up an fps clock let mut clock = Clock::start(); @@ -23,7 +26,7 @@ fn main() { // Create server let mut server = Server::new(settings).expect("Failed to create server instance!"); - info!("Server is ready to accept connections"); + info!("Server is ready to accept connections."); info!("Metrics port: {}", metrics_port); loop { diff --git a/server/src/lib.rs b/server/src/lib.rs index 5d06f7498f..8ec76db015 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -204,6 +204,11 @@ impl Server { server_settings: settings.clone(), }; debug!("created veloren server with: {:?}", &settings); + log::info!( + "Server version: {}[{}]", + *common::util::GIT_HASH, + *common::util::GIT_DATE + ); Ok(this) } From 03396eb77ea5ea1f8d8366eaab79e9c436488286 Mon Sep 17 00:00:00 2001 From: Capucho Date: Thu, 26 Mar 2020 21:22:21 +0000 Subject: [PATCH 250/326] Implement #505 --- CHANGELOG.md | 1 + assets/voxygen/i18n/en.ron | 2 ++ voxygen/src/hud/mod.rs | 25 +++++++++++++++++++++++++ voxygen/src/session.rs | 14 +++++++++++--- voxygen/src/settings.rs | 2 ++ voxygen/src/window.rs | 4 ++++ 6 files changed, 45 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0f8bc8c16..a579276f06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added authentication system (to play on the official server register on https://account.veloren.net) - Added gamepad/controller support - Added player feedback when attempting to pickup an item with a full inventory +- Added free look ### Changed diff --git a/assets/voxygen/i18n/en.ron b/assets/voxygen/i18n/en.ron index a9ab34bd68..57ef0300db 100644 --- a/assets/voxygen/i18n/en.ron +++ b/assets/voxygen/i18n/en.ron @@ -327,6 +327,8 @@ Chat commands: "hud.social.play_online_fmt": "{nb_player} player(s) online", "hud.spell": "Spell", + + "hud.free_look_indicator": "Free look active", /// End HUD section diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index f5a0a89ad8..9a45e82156 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -56,6 +56,7 @@ use vek::*; const XP_COLOR: Color = Color::Rgba(0.59, 0.41, 0.67, 1.0); const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0); +const TEXT_BG: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0); //const TEXT_COLOR_GREY: Color = Color::Rgba(1.0, 1.0, 1.0, 0.5); const MENU_BG: Color = Color::Rgba(0.0, 0.0, 0.0, 0.4); //const TEXT_COLOR_2: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0); @@ -175,6 +176,10 @@ widget_ids! { small_window, social_window, settings_window, + + // Free look indicator + free_look_txt, + free_look_bg, } } @@ -285,6 +290,7 @@ pub struct Show { settings_tab: SettingsTab, social_tab: SocialTab, want_grab: bool, + free_look: bool, } impl Show { fn bag(&mut self, open: bool) { @@ -507,6 +513,7 @@ impl Hud { social_tab: SocialTab::Online, want_grab: true, ingame: true, + free_look: false, }, to_focus: None, never_show: false, @@ -1961,6 +1968,22 @@ impl Hud { } } + // Free look indicator + if self.show.free_look { + Text::new(&self.voxygen_i18n.get("hud.free_look_indicator")) + .color(TEXT_BG) + .mid_top_with_margin_on(ui_widgets.window, 100.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(20)) + .set(self.ids.free_look_bg, ui_widgets); + Text::new(&self.voxygen_i18n.get("hud.free_look_indicator")) + .color(KILL_COLOR) + .top_left_with_margins_on(self.ids.free_look_bg, -1.0, -1.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(20)) + .set(self.ids.free_look_txt, ui_widgets); + } + events } @@ -2132,4 +2155,6 @@ impl Hud { self.ui.render(renderer, Some(globals)); } } + + pub fn free_look(&mut self, free_look: bool) { self.show.free_look = free_look; } } diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 7f8ecd2370..5e9d46b6fb 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -154,6 +154,9 @@ impl PlayState for SessionState { ) .unwrap(); + let mut ori = self.scene.camera().get_orientation(); + let mut free_look = false; + // Game loop let mut current_client_state = self.client.borrow().get_client_state(); while let ClientState::Pending | ClientState::Character = current_client_state { @@ -399,6 +402,10 @@ impl PlayState for SessionState { Event::InputUpdate(GameInput::Charge, state) => { self.inputs.charge.set_state(state); }, + Event::InputUpdate(GameInput::FreeLook, true) => { + free_look = !free_look; + self.hud.free_look(free_look); + }, Event::AnalogGameInput(input) => match input { AnalogGameInput::MovementX(v) => { self.key_state.analog_matrix.x = v; @@ -418,9 +425,12 @@ impl PlayState for SessionState { } } + if !free_look { + ori = self.scene.camera().get_orientation(); + self.inputs.look_dir = cam_dir; + } // Calculate the movement input vector of the player from the current key // presses and the camera direction. - let ori = self.scene.camera().get_orientation(); let unit_vecs = ( Vec2::new(ori[0].cos(), -ori[0].sin()), Vec2::new(ori[0].sin(), ori[0].cos()), @@ -428,8 +438,6 @@ impl PlayState for SessionState { let dir_vec = self.key_state.dir_vec(); self.inputs.move_dir = unit_vecs.0 * dir_vec[0] + unit_vecs.1 * dir_vec[1]; - self.inputs.look_dir = cam_dir; - // Runs if either in a multiplayer server or the singleplayer server is unpaused if global_state.singleplayer.is_none() || !global_state.singleplayer.as_ref().unwrap().is_paused() diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 78431b2dd1..5f47300544 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -51,6 +51,7 @@ pub struct ControlSettings { pub interact: KeyMouse, pub toggle_wield: KeyMouse, pub charge: KeyMouse, + pub free_look: KeyMouse, } /// Since Macbook trackpads lack middle click, on OS X we default to LShift @@ -101,6 +102,7 @@ impl Default for ControlSettings { interact: KeyMouse::Mouse(MouseButton::Right), toggle_wield: KeyMouse::Key(VirtualKeyCode::T), charge: KeyMouse::Key(VirtualKeyCode::Key1), + free_look: KeyMouse::Key(VirtualKeyCode::LAlt), } } } diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index f052ec73a2..9d24999eb6 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -49,6 +49,7 @@ pub enum GameInput { Interact, ToggleWield, Charge, + FreeLook, } /// Represents a key that the game menus recognise after input mapping @@ -458,6 +459,9 @@ impl Window { map.entry(settings.controls.charge) .or_default() .push(GameInput::Charge); + map.entry(settings.controls.free_look) + .or_default() + .push(GameInput::FreeLook); let keypress_map = HashMap::new(); From 7f1a90ae273fe150c26b09a85d2786859b74ed89 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Thu, 26 Mar 2020 14:44:39 -0700 Subject: [PATCH 251/326] Prevent transition if failed hit --- common/src/states/triple_strike.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 72e80ef453..b99b0e5876 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -51,7 +51,7 @@ impl CharacterBehavior for Data { .unwrap_or(Duration::default()); // If player stops holding input, don't go to the next stage - let should_transition = data.inputs.primary.is_pressed() && self.should_transition; + let mut should_transition = data.inputs.primary.is_pressed() && self.should_transition; if !self.initialized { update.vel.0 = Vec3::zero(); @@ -61,6 +61,21 @@ impl CharacterBehavior for Data { } let initialized = true; + // Handle hit applied + if let Some(attack) = data.attacking { + if attack.applied { + if attack.hit_count > 0 { + // Take energy on successful hit + update.energy.change_by(100, EnergySource::HitEnemy); + } else { + // Prevent transition on failure + should_transition = false; + } + // Always remove component + data.updater.remove::(data.entity); + } + } + // Handling movement if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { let adjusted_accel = match (self.stage, data.physics.touch_entity.is_none()) { From 8d1f93a2d142f927436588e8a0ef98bb3a1943b8 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Thu, 26 Mar 2020 14:48:51 -0700 Subject: [PATCH 252/326] ore responsive oreintating --- common/src/states/triple_strike.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index b99b0e5876..7f6104c257 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -95,7 +95,7 @@ impl CharacterBehavior for Data { } }; } else { - handle_orientation(data, &mut update, 10.0); + handle_orientation(data, &mut update, 20.0); } // Handling attacking From b9c85b9beb9258f17ff5bd9697f93b8b5561389f Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 26 Mar 2020 14:46:08 +0100 Subject: [PATCH 253/326] Balancing --- assets/common/items/apple.ron | 4 +- assets/common/items/cheese.ron | 4 +- assets/common/items/weapons/hammer_1.ron | 2 +- assets/common/items/weapons/starter_axe.ron | 2 +- .../common/items/weapons/starter_hammer.ron | 2 +- common/src/comp/ability.rs | 39 +++++++------------ common/src/comp/inventory/item.rs | 2 +- common/src/comp/stats.rs | 2 +- common/src/states/basic_melee.rs | 1 + common/src/states/roll.rs | 11 +++++- common/src/states/triple_strike.rs | 15 ++++--- common/src/states/utils.rs | 11 +++++- common/src/sys/agent.rs | 2 +- common/src/sys/combat.rs | 24 ++++++------ server/src/sys/terrain.rs | 4 +- 15 files changed, 68 insertions(+), 57 deletions(-) diff --git a/assets/common/items/apple.ron b/assets/common/items/apple.ron index 7179502e22..0c44a094ce 100644 --- a/assets/common/items/apple.ron +++ b/assets/common/items/apple.ron @@ -2,11 +2,11 @@ Item( name: "Apple", description: "Red and juicy. -Restores 20 Health.", +Restores 2 Health.", kind: Consumable( kind: Apple, effect: Health(( - amount: 20, + amount: 2, cause: Item, )), ), diff --git a/assets/common/items/cheese.ron b/assets/common/items/cheese.ron index 6e0bbe751e..9cb95fcbf8 100644 --- a/assets/common/items/cheese.ron +++ b/assets/common/items/cheese.ron @@ -2,11 +2,11 @@ Item( name: "Dwarven Cheese", description: "Aromatic and nutritious. -Restores 40 Health.", +Restores 15 Health.", kind: Consumable( kind: Cheese, effect: Health(( - amount: 40, + amount: 15, cause: Item, )), ), diff --git a/assets/common/items/weapons/hammer_1.ron b/assets/common/items/weapons/hammer_1.ron index 9f31453a57..d38e03d6ea 100644 --- a/assets/common/items/weapons/hammer_1.ron +++ b/assets/common/items/weapons/hammer_1.ron @@ -6,7 +6,7 @@ Item( kind: Tool( ToolData ( kind: Hammer(BasicHammer), - equip_time_millis: 1000, + equip_time_millis: 600, ) ) ) diff --git a/assets/common/items/weapons/starter_axe.ron b/assets/common/items/weapons/starter_axe.ron index a534e2eaa4..b77ef73c7d 100644 --- a/assets/common/items/weapons/starter_axe.ron +++ b/assets/common/items/weapons/starter_axe.ron @@ -6,7 +6,7 @@ Item( kind: Tool( ToolData ( kind: Axe(BasicAxe), - equip_time_millis: 1000, + equip_time_millis: 700, ) ), ) diff --git a/assets/common/items/weapons/starter_hammer.ron b/assets/common/items/weapons/starter_hammer.ron index 3e3a55f6e3..77d9ef6812 100644 --- a/assets/common/items/weapons/starter_hammer.ron +++ b/assets/common/items/weapons/starter_hammer.ron @@ -6,7 +6,7 @@ Item( kind: Tool( ToolData ( kind: Hammer(BasicHammer), - equip_time_millis: 1000, + equip_time_millis: 600, ) ), ) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 0d2538aea5..0c6d3b7f63 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -56,34 +56,24 @@ impl CharacterAbility { match self { CharacterAbility::Roll => { data.physics.on_ground - && !data.physics.in_fluid && data.body.is_humanoid() && update .energy - .try_change_by(-200, EnergySource::Ability) - .is_ok() - }, - CharacterAbility::DashMelee { .. } => { - !data.physics.in_fluid - && update - .energy - .try_change_by(-300, EnergySource::Ability) - .is_ok() - }, - CharacterAbility::BasicMelee { energy_cost, .. } => { - !data.physics.in_fluid - && update - .energy - .try_change_by(-(*energy_cost as i32), EnergySource::Ability) - .is_ok() - }, - CharacterAbility::BasicRanged { energy_cost, .. } => { - !data.physics.in_fluid - && update - .energy - .try_change_by(-(*energy_cost as i32), EnergySource::Ability) + .try_change_by(-150, EnergySource::Ability) .is_ok() }, + CharacterAbility::DashMelee { .. } => update + .energy + .try_change_by(-700, EnergySource::Ability) + .is_ok(), + CharacterAbility::BasicMelee { energy_cost, .. } => update + .energy + .try_change_by(-(*energy_cost as i32), EnergySource::Ability) + .is_ok(), + CharacterAbility::BasicRanged { energy_cost, .. } => update + .energy + .try_change_by(-(*energy_cost as i32), EnergySource::Ability) + .is_ok(), _ => true, } } @@ -165,7 +155,8 @@ impl From<&CharacterAbility> for CharacterState { }), CharacterAbility::BasicBlock => CharacterState::BasicBlock, CharacterAbility::Roll => CharacterState::Roll(roll::Data { - remaining_duration: Duration::from_millis(300), + remaining_duration: Duration::from_millis(500), + was_wielded: false, // false by default. utils might set it to true }), CharacterAbility::TimedCombo { buildup_duration, diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 78e99a9a54..90ce466ef8 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -70,7 +70,7 @@ impl ToolData { use ToolKind::*; match self.kind { - Sword(_) => vec![TripleStrike { base_damage: 7 }, DashMelee { + Sword(_) => vec![TripleStrike { base_damage: 5 }, DashMelee { buildup_duration: Duration::from_millis(500), recover_duration: Duration::from_millis(500), base_damage: 20, diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index 3e6d957fef..1c31af1187 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -135,7 +135,7 @@ impl Stats { } // TODO: Delete this once stat points will be a thing - pub fn update_max_hp(&mut self) { self.health.set_maximum(33 + 7 * self.level.amount); } + pub fn update_max_hp(&mut self) { self.health.set_maximum(52 + 3 * self.level.amount); } } impl Stats { diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 03e7851b0d..c6e5af5a62 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -26,6 +26,7 @@ impl CharacterBehavior for Data { let mut update = StateUpdate::from(data); handle_move(data, &mut update); + handle_jump(data, &mut update); if self.buildup_duration != Duration::default() { // Build up diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 6eed23d488..f2ca53ecf1 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -6,11 +6,13 @@ use crate::{ use std::time::Duration; use vek::Vec3; -const ROLL_SPEED: f32 = 17.0; +const ROLL_SPEED: f32 = 15.0; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Data { /// How long the state has until exiting pub remaining_duration: Duration, + /// Had weapon + pub was_wielded: bool, } impl CharacterBehavior for Data { @@ -31,7 +33,11 @@ impl CharacterBehavior for Data { if self.remaining_duration == Duration::default() { // Roll duration has expired update.vel.0 *= 0.3; - update.character = CharacterState::Idle {}; + if self.was_wielded { + update.character = CharacterState::Wielding; + } else { + update.character = CharacterState::Idle; + } } else { // Otherwise, tick down remaining_duration update.character = CharacterState::Roll(Data { @@ -39,6 +45,7 @@ impl CharacterBehavior for Data { .remaining_duration .checked_sub(Duration::from_secs_f32(data.dt.0)) .unwrap_or_default(), + was_wielded: self.was_wielded, }); } diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 7f6104c257..d39f55416b 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -7,9 +7,9 @@ use std::time::Duration; use vek::vec::{Vec2, Vec3}; // In millis -const STAGE_DURATION: u64 = 600; +const STAGE_DURATION: u64 = 500; -const INITIAL_ACCEL: f32 = 200.0; +const INITIAL_ACCEL: f32 = 90.0; const BASE_SPEED: f32 = 25.0; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] @@ -87,8 +87,13 @@ impl CharacterBehavior for Data { // Move player forward while in first third of each stage if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) { - update.vel.0 = - update.vel.0 + Vec2::broadcast(data.dt.0) * data.ori.0 * adjusted_accel; + update.vel.0 = update.vel.0 + + data.dt.0 + * (if data.physics.on_ground { + Vec3::new(0.0, 0.0, 500.0) // Jump upwards if on ground + } else { + Vec3::one() + } + adjusted_accel * Vec3::from(data.ori.0.xy())); let mag2 = update.vel.0.magnitude_squared(); if mag2 > BASE_SPEED.powf(2.0) { update.vel.0 = update.vel.0.normalized() * BASE_SPEED; @@ -115,7 +120,7 @@ impl CharacterBehavior for Data { max_angle: 180_f32.to_radians(), applied: false, hit_count: 0, - knockback: 7.0, + knockback: 20.0, }); CharacterState::TripleStrike(Data { diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 3e9113fc46..6af1a90168 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -53,7 +53,7 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate) { } } - handle_orientation(data, update, 9.0); + handle_orientation(data, update, 20.0); } pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, strength: f32) { @@ -215,7 +215,14 @@ pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { .and_then(|i| i.dodge_ability.as_ref()) .filter(|ability| ability.requirements_paid(data, update)) { - update.character = ability.into(); + if data.character.is_wield() { + update.character = ability.into(); + if let CharacterState::Roll(roll) = &mut update.character { + roll.was_wielded = true; + } + } else { + update.character = ability.into(); + } } } } diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index 2c9186b26d..750465c674 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -180,7 +180,7 @@ impl<'a> System<'a> for Sys { inputs.move_dir = Vec2::from(tgt_pos.0 - pos.0) .try_normalized() .unwrap_or(Vec2::unit_y()) - * 0.01; + * 0.7; inputs.primary.set_state(true); } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 33ae5d8073..c9c33ac8c9 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -113,40 +113,40 @@ impl<'a> System<'a> for Sys { && ori2.angle_between(pos_b2 - pos2) < attack.max_angle + (rad_b / pos2.distance(pos_b2)).atan() { // Weapon gives base damage - let mut healthchange = attack.base_healthchange; + let mut healthchange = attack.base_healthchange as f32; - // NPCs do less damage: - if agent_maybe.is_some() { - healthchange = (healthchange / 2).min(-1); - } + //// NPCs do less damage: + //if agent_maybe.is_some() { + // healthchange = (healthchange / 1.5).min(-1.0); + //} // Don't heal npc's hp - if agent_b_maybe.is_some() && healthchange > 0 { - healthchange = 0; + if agent_b_maybe.is_some() && healthchange > 0.0 { + healthchange = 0.0; } if rand::random() { - healthchange = (healthchange as f32 * 1.2) as i32; + healthchange = healthchange * 1.2; } // Block if character_b.is_block() && ori_b.0.angle_between(pos.0 - pos_b.0) < BLOCK_ANGLE.to_radians() / 2.0 { - healthchange = (healthchange as f32 * (1.0 - BLOCK_EFFICIENCY)) as i32 + healthchange = healthchange * (1.0 - BLOCK_EFFICIENCY) } server_emitter.emit(ServerEvent::Damage { uid: *uid_b, change: HealthChange { - amount: healthchange, + amount: healthchange as i32, cause: HealthSource::Attack { by: *uid }, }, }); if attack.knockback != 0.0 { - local_emitter.emit(LocalEvent::KnockUp { + local_emitter.emit(LocalEvent::ApplyForce { entity: b, - dir: ori.0, + dir: Vec3::slerp(ori.0, Vec3::new(0.0, 0.0, 1.0), 0.5), force: attack.knockback, }); } diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index bb5a58661f..16f863f776 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -209,8 +209,8 @@ impl<'a> System<'a> for Sys { ability1: Some(CharacterAbility::BasicMelee { energy_cost: 0, buildup_duration: Duration::from_millis(0), - recover_duration: Duration::from_millis(300), - base_healthchange: -2, + recover_duration: Duration::from_millis(400), + base_healthchange: -4, range: 3.5, max_angle: 60.0, }), From e573fbbce5e66970934249d9c5a43ab8dd3022b3 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 26 Mar 2020 17:19:12 +0100 Subject: [PATCH 254/326] Better glider physics --- common/src/states/glide.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 01d3771dfa..497334ac8c 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -6,8 +6,8 @@ use crate::{ use vek::Vec2; // Gravity is 9.81 * 4, so this makes gravity equal to .15 -const GLIDE_ANTIGRAV: f32 = crate::sys::phys::GRAVITY * 0.96; -const GLIDE_ACCEL: f32 = 15.0; +const GLIDE_ANTIGRAV: f32 = crate::sys::phys::GRAVITY * 0.90; +const GLIDE_ACCEL: f32 = 12.0; const GLIDE_SPEED: f32 = 45.0; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] From 8010e5afb43ebc051e2ae70f53f9a44affedfbf3 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 26 Mar 2020 20:02:01 +0100 Subject: [PATCH 255/326] Better equip durations, fix roll bug, slow down while attacking, smoother gliding, stronger npcs, giants --- assets/common/items/weapons/hammer_1.ron | 2 +- assets/common/items/weapons/short_sword_0.ron | 2 +- assets/common/items/weapons/staff_1.ron | 2 +- assets/common/items/weapons/staff_nature.ron | 2 +- assets/common/items/weapons/starter_axe.ron | 2 +- assets/common/items/weapons/starter_bow.ron | 2 +- assets/common/items/weapons/starter_hammer.ron | 2 +- assets/common/items/weapons/starter_staff.ron | 2 +- assets/common/items/weapons/starter_sword.ron | 2 +- assets/common/items/weapons/wood_sword.ron | 2 +- .../common/items/weapons/zweihander_sword_0.ron | 2 +- common/src/comp/ability.rs | 1 + common/src/states/basic_block.rs | 2 +- common/src/states/basic_melee.rs | 2 +- common/src/states/basic_ranged.rs | 2 +- common/src/states/boost.rs | 2 +- common/src/states/dash_melee.rs | 2 +- common/src/states/equipping.rs | 2 +- common/src/states/glide.rs | 9 ++++++--- common/src/states/idle.rs | 2 +- common/src/states/utils.rs | 16 +++++++++------- common/src/states/wielding.rs | 2 +- common/src/util/mod.rs | 2 +- server/src/sys/terrain.rs | 4 ++-- 24 files changed, 38 insertions(+), 32 deletions(-) diff --git a/assets/common/items/weapons/hammer_1.ron b/assets/common/items/weapons/hammer_1.ron index d38e03d6ea..3907ed9aff 100644 --- a/assets/common/items/weapons/hammer_1.ron +++ b/assets/common/items/weapons/hammer_1.ron @@ -6,7 +6,7 @@ Item( kind: Tool( ToolData ( kind: Hammer(BasicHammer), - equip_time_millis: 600, + equip_time_millis: 500, ) ) ) diff --git a/assets/common/items/weapons/short_sword_0.ron b/assets/common/items/weapons/short_sword_0.ron index 4ee3ca4da2..1c8c91d308 100644 --- a/assets/common/items/weapons/short_sword_0.ron +++ b/assets/common/items/weapons/short_sword_0.ron @@ -5,7 +5,7 @@ Item( kind: Tool( ToolData ( kind: Sword(Short0), - equip_time_millis: 800, + equip_time_millis: 400, ) ), ) diff --git a/assets/common/items/weapons/staff_1.ron b/assets/common/items/weapons/staff_1.ron index 6ad09d6635..0287853a69 100644 --- a/assets/common/items/weapons/staff_1.ron +++ b/assets/common/items/weapons/staff_1.ron @@ -6,7 +6,7 @@ Item( kind: Tool( ToolData ( kind: Staff(BasicStaff), - equip_time_millis: 800, + equip_time_millis: 200, ) ), ) diff --git a/assets/common/items/weapons/staff_nature.ron b/assets/common/items/weapons/staff_nature.ron index d9961ef873..b9065cad11 100644 --- a/assets/common/items/weapons/staff_nature.ron +++ b/assets/common/items/weapons/staff_nature.ron @@ -5,7 +5,7 @@ Item( kind: Tool( ToolData ( kind: Staff(Sceptre), - equip_time_millis: 800, + equip_time_millis: 400, ) ), ) diff --git a/assets/common/items/weapons/starter_axe.ron b/assets/common/items/weapons/starter_axe.ron index b77ef73c7d..61d546fe80 100644 --- a/assets/common/items/weapons/starter_axe.ron +++ b/assets/common/items/weapons/starter_axe.ron @@ -6,7 +6,7 @@ Item( kind: Tool( ToolData ( kind: Axe(BasicAxe), - equip_time_millis: 700, + equip_time_millis: 400, ) ), ) diff --git a/assets/common/items/weapons/starter_bow.ron b/assets/common/items/weapons/starter_bow.ron index 33064b766b..735de375fb 100644 --- a/assets/common/items/weapons/starter_bow.ron +++ b/assets/common/items/weapons/starter_bow.ron @@ -6,7 +6,7 @@ Item( kind: Tool( ToolData ( kind: Bow(BasicBow), - equip_time_millis: 800, + equip_time_millis: 400, ) ), ) diff --git a/assets/common/items/weapons/starter_hammer.ron b/assets/common/items/weapons/starter_hammer.ron index 77d9ef6812..9d7e38f115 100644 --- a/assets/common/items/weapons/starter_hammer.ron +++ b/assets/common/items/weapons/starter_hammer.ron @@ -6,7 +6,7 @@ Item( kind: Tool( ToolData ( kind: Hammer(BasicHammer), - equip_time_millis: 600, + equip_time_millis: 500, ) ), ) diff --git a/assets/common/items/weapons/starter_staff.ron b/assets/common/items/weapons/starter_staff.ron index 16a1971dfa..ae6de21968 100644 --- a/assets/common/items/weapons/starter_staff.ron +++ b/assets/common/items/weapons/starter_staff.ron @@ -6,7 +6,7 @@ Item( kind: Tool( ToolData ( kind: Staff(BasicStaff), - equip_time_millis: 800, + equip_time_millis: 300, ) ), ) diff --git a/assets/common/items/weapons/starter_sword.ron b/assets/common/items/weapons/starter_sword.ron index c7094813ec..9b0eaae181 100644 --- a/assets/common/items/weapons/starter_sword.ron +++ b/assets/common/items/weapons/starter_sword.ron @@ -6,7 +6,7 @@ Item( kind: Tool( ToolData ( kind: Sword(BasicSword), - equip_time_millis: 800, + equip_time_millis: 300, ) ), ) diff --git a/assets/common/items/weapons/wood_sword.ron b/assets/common/items/weapons/wood_sword.ron index 26f0e33c93..ce1189d866 100644 --- a/assets/common/items/weapons/wood_sword.ron +++ b/assets/common/items/weapons/wood_sword.ron @@ -5,7 +5,7 @@ Item( kind: Tool( ToolData ( kind: Sword(WoodTraining), - equip_time_millis: 800, + equip_time_millis: 400, ) ), ) diff --git a/assets/common/items/weapons/zweihander_sword_0.ron b/assets/common/items/weapons/zweihander_sword_0.ron index 3703a16da1..be64c6f17b 100644 --- a/assets/common/items/weapons/zweihander_sword_0.ron +++ b/assets/common/items/weapons/zweihander_sword_0.ron @@ -5,7 +5,7 @@ Item( kind: Tool( ToolData ( kind: Sword(Zweihander0), - equip_time_millis: 800, + equip_time_millis: 500, ) ), ) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 0c6d3b7f63..e561bdbcbe 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -57,6 +57,7 @@ impl CharacterAbility { CharacterAbility::Roll => { data.physics.on_ground && data.body.is_humanoid() + && data.vel.0.xy().magnitude_squared() > 0.5 && update .energy .try_change_by(-150, EnergySource::Ability) diff --git a/common/src/states/basic_block.rs b/common/src/states/basic_block.rs index 06df786b6d..b60b7e548f 100644 --- a/common/src/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -14,7 +14,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_move(&data, &mut update); + handle_move(&data, &mut update, 0.4); if !data.physics.on_ground || !(data.inputs.secondary.is_pressed() || data.inputs.primary.is_pressed()) diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index c6e5af5a62..d67681cc0c 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -25,7 +25,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_move(data, &mut update); + handle_move(data, &mut update, 0.7); handle_jump(data, &mut update); if self.buildup_duration != Duration::default() { diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index 25c965785d..9a73bd45ab 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -26,7 +26,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_move(data, &mut update); + handle_move(data, &mut update, 0.5); handle_jump(data, &mut update); if self.prepare_timer < self.prepare_duration diff --git a/common/src/states/boost.rs b/common/src/states/boost.rs index c4b547eb17..20e5b53909 100644 --- a/common/src/states/boost.rs +++ b/common/src/states/boost.rs @@ -16,7 +16,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_move(data, &mut update); + handle_move(data, &mut update, 1.0); // Still going if self.duration != Duration::default() { diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index b3d67a8256..06c513b5a8 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -72,7 +72,7 @@ impl CharacterBehavior for Data { }); } else if self.recover_duration != Duration::default() { // Recovery - handle_move(data, &mut update); + handle_move(data, &mut update, 0.7); update.character = CharacterState::DashMelee(Data { buildup_duration: self.buildup_duration, recover_duration: self diff --git a/common/src/states/equipping.rs b/common/src/states/equipping.rs index 6f8e16b54b..29cf1d8453 100644 --- a/common/src/states/equipping.rs +++ b/common/src/states/equipping.rs @@ -15,7 +15,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_move(&data, &mut update); + handle_move(&data, &mut update, 1.0); handle_jump(&data, &mut update); if self.time_left == Duration::default() { diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 497334ac8c..1c21ae9df9 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -19,12 +19,14 @@ impl CharacterBehavior for Data { // If glide button isn't held or player is on ground, end glide if !data.inputs.glide.is_pressed() || data.physics.on_ground { - update.character = CharacterState::Idle {}; + update.character = CharacterState::Idle; + return update; } // If there is a wall in front of character go to climb if let Some(_) = data.physics.on_wall { - update.character = CharacterState::Climb {}; + update.character = CharacterState::Climb; + return update; } // Move player according to movement direction vector @@ -38,7 +40,7 @@ impl CharacterBehavior for Data { // Determine orientation vector from movement direction vector let ori_dir = Vec2::from(update.vel.0); - update.ori.0 = safe_slerp(update.ori.0, ori_dir.into(), 2.0 * data.dt.0); + update.ori.0 = safe_slerp(update.ori.0, ori_dir.into(), 0.1); // Apply Glide antigrav lift if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) @@ -53,6 +55,7 @@ impl CharacterBehavior for Data { } // Otherwise keep gliding + update.character = CharacterState::Glide; update } } diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index 0355ddbe5a..eb58dccf55 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -10,7 +10,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_move(data, &mut update); + handle_move(data, &mut update, 1.0); handle_jump(data, &mut update); handle_primary_wield(data, &mut update); handle_climb(data, &mut update); diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 6af1a90168..f44b413b13 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -28,16 +28,16 @@ const BASE_HUMANOID_WATER_SPEED: f32 = 120.0; // const CLIMB_COST: i32 = 5; /// Handles updating `Components` to move player based on state of `JoinData` -pub fn handle_move(data: &JoinData, update: &mut StateUpdate) { +pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { if data.physics.in_fluid { - swim_move(data, update); + swim_move(data, update, efficiency); } else { - basic_move(data, update); + basic_move(data, update, efficiency); } } /// Updates components to move player as if theyre on ground or in air -fn basic_move(data: &JoinData, update: &mut StateUpdate) { +fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { let (accel, speed): (f32, f32) = if data.physics.on_ground { (BASE_HUMANOID_ACCEL, BASE_HUMANOID_SPEED) } else { @@ -46,7 +46,8 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate) { // Move player according to move_dir if update.vel.0.magnitude_squared() < speed.powf(2.0) { - update.vel.0 = update.vel.0 + Vec2::broadcast(data.dt.0) * data.inputs.move_dir * accel; + update.vel.0 = + update.vel.0 + Vec2::broadcast(data.dt.0) * data.inputs.move_dir * accel * efficiency; let mag2 = update.vel.0.magnitude_squared(); if mag2 > speed.powf(2.0) { update.vel.0 = update.vel.0.normalized() * speed; @@ -69,7 +70,7 @@ pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, strength: f } /// Updates components to move player as if theyre swimming -fn swim_move(data: &JoinData, update: &mut StateUpdate) { +fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { // Update velocity update.vel.0 += Vec2::broadcast(data.dt.0) * data.inputs.move_dir @@ -77,7 +78,8 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) { BASE_HUMANOID_WATER_ACCEL } else { 0.0 - }; + } + * efficiency; handle_orientation(data, update, if data.physics.on_ground { 9.0 } else { 2.0 }); diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 74ca337cda..9381c185e5 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -10,7 +10,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_move(&data, &mut update); + handle_move(&data, &mut update, 1.0); handle_jump(&data, &mut update); handle_climb(&data, &mut update); handle_glide(&data, &mut update); diff --git a/common/src/util/mod.rs b/common/src/util/mod.rs index 36ef3841e0..bb4d1be981 100644 --- a/common/src/util/mod.rs +++ b/common/src/util/mod.rs @@ -41,7 +41,7 @@ pub fn safe_slerp(from: vek::Vec3, to: vek::Vec3, factor: f32) -> vek: }; let dot = from.dot(to); - if dot > 0.999 { + if dot >= 1.0 - 1E-6 { // Close together, just use to return to; } diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 16f863f776..83500188a5 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -282,7 +282,7 @@ impl<'a> System<'a> for Sys { // TODO: Remove this and implement scaling or level depending on stuff like // species instead - stats.level.set_level(rand::thread_rng().gen_range(1, 4)); + stats.level.set_level(rand::thread_rng().gen_range(1, 9)); // Replace stuff if it's a boss if let EntityKind::Boss = entity.kind { @@ -337,7 +337,7 @@ impl<'a> System<'a> for Sys { )), }; - stats.level.set_level(rand::thread_rng().gen_range(8, 15)); + stats.level.set_level(rand::thread_rng().gen_range(30, 35)); scale = 2.0 + rand::random::(); } From 2b68adff515d797e5ea5b694a0639b371f8a75eb Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 26 Mar 2020 22:52:44 +0100 Subject: [PATCH 256/326] Balancing, make fireball not holdable, arrow knockback --- common/src/comp/ability.rs | 5 ++++- common/src/comp/inventory/item.rs | 19 ++++++++++++------- common/src/comp/projectile.rs | 1 + common/src/states/basic_ranged.rs | 9 +++++++-- common/src/states/triple_strike.rs | 4 ++-- common/src/states/utils.rs | 10 +++++++++- common/src/sys/character_behavior.rs | 10 ++++++++-- common/src/sys/combat.rs | 10 ++-------- common/src/sys/projectile.rs | 22 ++++++++++++++++++++-- 9 files changed, 65 insertions(+), 25 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index e561bdbcbe..a8c2f604c2 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -21,6 +21,7 @@ pub enum CharacterAbility { }, BasicRanged { energy_cost: u32, + holdable: bool, prepare_duration: Duration, recover_duration: Duration, projectile: Projectile, @@ -60,7 +61,7 @@ impl CharacterAbility { && data.vel.0.xy().magnitude_squared() > 0.5 && update .energy - .try_change_by(-150, EnergySource::Ability) + .try_change_by(-220, EnergySource::Ability) .is_ok() }, CharacterAbility::DashMelee { .. } => update @@ -122,6 +123,7 @@ impl From<&CharacterAbility> for CharacterState { max_angle: *max_angle, }), CharacterAbility::BasicRanged { + holdable, prepare_duration, recover_duration, projectile, @@ -132,6 +134,7 @@ impl From<&CharacterAbility> for CharacterState { } => CharacterState::BasicRanged(basic_ranged::Data { exhausted: false, prepare_timer: Duration::default(), + holdable: *holdable, prepare_duration: *prepare_duration, recover_duration: *recover_duration, projectile: projectile.clone(), diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 90ce466ef8..27ced5f27b 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -73,7 +73,7 @@ impl ToolData { Sword(_) => vec![TripleStrike { base_damage: 5 }, DashMelee { buildup_duration: Duration::from_millis(500), recover_duration: Duration::from_millis(500), - base_damage: 20, + base_damage: 10, }], Axe(_) => vec![BasicMelee { energy_cost: 0, @@ -93,17 +93,19 @@ impl ToolData { }], Bow(_) => vec![BasicRanged { energy_cost: 0, + holdable: true, prepare_duration: Duration::from_millis(100), - recover_duration: Duration::from_millis(300), + recover_duration: Duration::from_millis(500), projectile: Projectile { hit_ground: vec![projectile::Effect::Stick], hit_wall: vec![projectile::Effect::Stick], hit_entity: vec![ projectile::Effect::Damage(HealthChange { // TODO: This should not be fixed (?) - amount: -3, + amount: -5, cause: HealthSource::Projectile { owner: None }, }), + projectile::Effect::Knockback(10.0), projectile::Effect::Vanish, ], time_left: Duration::from_secs(15), @@ -132,15 +134,16 @@ impl ToolData { }, BasicRanged { energy_cost: 0, - prepare_duration: Duration::from_millis(300), - recover_duration: Duration::from_millis(100), + holdable: false, + prepare_duration: Duration::from_millis(0), + recover_duration: Duration::from_millis(200), projectile: Projectile { hit_ground: vec![projectile::Effect::Vanish], hit_wall: vec![projectile::Effect::Vanish], hit_entity: vec![ projectile::Effect::Damage(HealthChange { // TODO: This should not be fixed (?) - amount: -2, + amount: -1, cause: HealthSource::Projectile { owner: None }, }), projectile::Effect::Vanish, @@ -158,6 +161,7 @@ impl ToolData { }, BasicRanged { energy_cost: 400, + holdable: false, prepare_duration: Duration::from_millis(800), recover_duration: Duration::from_millis(300), projectile: Projectile { @@ -217,7 +221,8 @@ impl ToolData { ], Possess => vec![BasicRanged { energy_cost: 0, - prepare_duration: Duration::from_millis(300), + holdable: false, + prepare_duration: Duration::from_millis(0), recover_duration: Duration::from_millis(300), projectile: Projectile { hit_ground: vec![projectile::Effect::Stick], diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 6f1982be33..a4dda1ac7c 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -6,6 +6,7 @@ use std::time::Duration; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum Effect { Damage(comp::HealthChange), + Knockback(f32), Explode { power: f32 }, Vanish, Stick, diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index 9a73bd45ab..81f1485baf 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -8,6 +8,8 @@ use std::time::Duration; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Data { + /// Can you hold the abilty beyond the prepare duration + pub holdable: bool, /// How long we have to prepare the weapon pub prepare_duration: Duration, /// How long we prepared the weapon already @@ -26,15 +28,16 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_move(data, &mut update, 0.5); + handle_move(data, &mut update, 0.2); handle_jump(data, &mut update); if self.prepare_timer < self.prepare_duration - || !self.exhausted && data.inputs.holding_ability_key() + || self.holdable && !self.exhausted && data.inputs.holding_ability_key() { // Prepare (draw the bow) update.character = CharacterState::BasicRanged(Data { prepare_timer: self.prepare_timer + Duration::from_secs_f32(data.dt.0), + holdable: self.holdable, prepare_duration: self.prepare_duration, recover_duration: self.recover_duration, projectile: self.projectile.clone(), @@ -58,6 +61,7 @@ impl CharacterBehavior for Data { update.character = CharacterState::BasicRanged(Data { prepare_timer: self.prepare_timer, + holdable: self.holdable, prepare_duration: self.prepare_duration, recover_duration: self.recover_duration, projectile: self.projectile.clone(), @@ -70,6 +74,7 @@ impl CharacterBehavior for Data { // Recovery update.character = CharacterState::BasicRanged(Data { prepare_timer: self.prepare_timer, + holdable: self.holdable, prepare_duration: self.prepare_duration, recover_duration: self .recover_duration diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index d39f55416b..43bbcfb0ba 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -4,10 +4,10 @@ use crate::{ sys::character_behavior::{CharacterBehavior, JoinData}, }; use std::time::Duration; -use vek::vec::{Vec2, Vec3}; +use vek::vec::Vec3; // In millis -const STAGE_DURATION: u64 = 500; +const STAGE_DURATION: u64 = 700; const INITIAL_ACCEL: f32 = 90.0; const BASE_SPEED: f32 = 25.0; diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index f44b413b13..4c635cd68e 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -10,6 +10,7 @@ use vek::vec::Vec2; pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; const BASE_HUMANOID_ACCEL: f32 = 100.0; const BASE_HUMANOID_SPEED: f32 = 150.0; +const NPC_HUMANOID_SPEED: f32 = 150.0; const BASE_HUMANOID_AIR_ACCEL: f32 = 15.0; const BASE_HUMANOID_AIR_SPEED: f32 = 8.0; const BASE_HUMANOID_WATER_ACCEL: f32 = 70.0; @@ -39,7 +40,14 @@ pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { /// Updates components to move player as if theyre on ground or in air fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { let (accel, speed): (f32, f32) = if data.physics.on_ground { - (BASE_HUMANOID_ACCEL, BASE_HUMANOID_SPEED) + ( + BASE_HUMANOID_ACCEL, + if data.agent.is_some() { + NPC_HUMANOID_SPEED + } else { + BASE_HUMANOID_SPEED + }, + ) } else { (BASE_HUMANOID_AIR_ACCEL, BASE_HUMANOID_AIR_SPEED) }; diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 729e4be506..e46fd63242 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - Attacking, Body, CharacterState, ControlAction, Controller, ControllerInputs, Energy, - Loadout, Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, + Agent, Attacking, Body, CharacterState, ControlAction, Controller, ControllerInputs, + Energy, Loadout, Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -46,6 +46,7 @@ pub struct JoinData<'a> { pub body: &'a Body, pub physics: &'a PhysicsState, pub attacking: Option<&'a Attacking>, + pub agent: Option<&'a Agent>, pub updater: &'a LazyUpdate, } @@ -63,6 +64,7 @@ pub type JoinTuple<'a> = ( &'a Body, &'a PhysicsState, Option<&'a Attacking>, + Option<&'a Agent>, ); fn incorporate_update(tuple: &mut JoinTuple, state_update: StateUpdate) { @@ -91,6 +93,7 @@ impl<'a> JoinData<'a> { body: j.10, physics: j.11, attacking: j.12, + agent: j.13, updater, dt, } @@ -121,6 +124,7 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Body>, ReadStorage<'a, PhysicsState>, ReadStorage<'a, Attacking>, + ReadStorage<'a, Agent>, ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, ); @@ -145,6 +149,7 @@ impl<'a> System<'a> for Sys { bodies, physics_states, attacking_storage, + agent_storage, uids, mountings, ): Self::SystemData, @@ -166,6 +171,7 @@ impl<'a> System<'a> for Sys { &bodies, &physics_states, attacking_storage.maybe(), + agent_storage.maybe(), ) .join(); diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index c9c33ac8c9..bf8abe1639 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -1,7 +1,6 @@ use crate::{ comp::{ - Agent, Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos, - Scale, Stats, + Agent, Attacking, Body, CharacterState, HealthChange, HealthSource, Ori, Pos, Scale, Stats, }, event::{EventBus, LocalEvent, ServerEvent}, sync::Uid, @@ -25,7 +24,6 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Ori>, ReadStorage<'a, Scale>, ReadStorage<'a, Agent>, - ReadStorage<'a, Controller>, ReadStorage<'a, Body>, ReadStorage<'a, Stats>, WriteStorage<'a, Attacking>, @@ -43,7 +41,6 @@ impl<'a> System<'a> for Sys { orientations, scales, agents, - controllers, bodies, stats, mut attacking_storage, @@ -53,15 +50,12 @@ impl<'a> System<'a> for Sys { let mut server_emitter = server_bus.emitter(); let mut local_emitter = local_bus.emitter(); // Attacks - for (entity, uid, pos, ori, scale_maybe, agent_maybe, _, _attacker_stats, attack) in ( + for (entity, uid, pos, ori, scale_maybe, attack) in ( &entities, &uids, &positions, &orientations, scales.maybe(), - agents.maybe(), - &controllers, - &stats, &mut attacking_storage, ) .join() diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index e09050cc0f..3f0ee14a04 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -1,10 +1,12 @@ use crate::{ comp::{projectile, HealthSource, Ori, PhysicsState, Pos, Projectile, Vel}, - event::{EventBus, ServerEvent}, + event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, + sync::UidAllocator, }; -use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; +use specs::{saveload::MarkerAllocator, Entities, Join, Read, ReadStorage, System, WriteStorage}; use std::time::Duration; +use vek::*; /// This system is responsible for handling projectile effect triggers pub struct Sys; @@ -12,6 +14,8 @@ impl<'a> System<'a> for Sys { type SystemData = ( Entities<'a>, Read<'a, DeltaTime>, + Read<'a, UidAllocator>, + Read<'a, EventBus>, Read<'a, EventBus>, ReadStorage<'a, Pos>, ReadStorage<'a, PhysicsState>, @@ -25,6 +29,8 @@ impl<'a> System<'a> for Sys { ( entities, dt, + uid_allocator, + local_bus, server_bus, positions, physics_states, @@ -33,6 +39,7 @@ impl<'a> System<'a> for Sys { mut projectiles, ): Self::SystemData, ) { + let mut local_emitter = local_bus.emitter(); let mut server_emitter = server_bus.emitter(); // Attacks @@ -90,6 +97,17 @@ impl<'a> System<'a> for Sys { projectile::Effect::Damage(change) => { server_emitter.emit(ServerEvent::Damage { uid: other, change }) }, + projectile::Effect::Knockback(knockback) => { + if let Some(entity) = + uid_allocator.retrieve_entity_internal(other.into()) + { + local_emitter.emit(LocalEvent::ApplyForce { + entity, + dir: Vec3::slerp(ori.0, Vec3::new(0.0, 0.0, 1.0), 0.5), + force: knockback, + }); + } + }, projectile::Effect::Explode { power } => { server_emitter.emit(ServerEvent::Explosion { pos: pos.0, From 7692f1d354906f3b62292076f017f67a22d65459 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Thu, 26 Mar 2020 18:26:23 -0400 Subject: [PATCH 257/326] fixed wield feet while jumping, tweaked charge anim --- voxygen/src/anim/character/charge.rs | 6 +- voxygen/src/anim/character/equip.rs | 32 +--------- voxygen/src/anim/character/jump.rs | 6 +- voxygen/src/anim/character/run.rs | 20 +++---- voxygen/src/anim/character/wield.rs | 89 ++++++---------------------- 5 files changed, 36 insertions(+), 117 deletions(-) diff --git a/voxygen/src/anim/character/charge.rs b/voxygen/src/anim/character/charge.rs index 945cb41cd5..01672ecfeb 100644 --- a/voxygen/src/anim/character/charge.rs +++ b/voxygen/src/anim/character/charge.rs @@ -52,7 +52,7 @@ impl Animation for ChargeAnimation { next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 2.0); - next.chest.ori = Quaternion::rotation_x(-0.7) * Quaternion::rotation_z(-0.9); + next.chest.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.7); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, 1.0, -1.0); @@ -76,9 +76,9 @@ impl Animation for ChargeAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0); - next.control.ori = Quaternion::rotation_x(0.0) + next.control.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(1.4 + slow * 0.2); + * Quaternion::rotation_z(1.1 + slow * 0.2); next.control.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-1.4, foot * 3.0, 8.0); next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8); diff --git a/voxygen/src/anim/character/equip.rs b/voxygen/src/anim/character/equip.rs index 277a46e890..d7c1f2d764 100644 --- a/voxygen/src/anim/character/equip.rs +++ b/voxygen/src/anim/character/equip.rs @@ -21,10 +21,7 @@ impl Animation for EquipAnimation { let mut next = (*skeleton).clone(); let lab = 1.0; - let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 16.0).sin()); + let short = (((5.0) / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) .sqrt()) @@ -217,33 +214,6 @@ impl Animation for EquipAnimation { ); if velocity > 0.5 { - next.head.offset = Vec3::new( - 0.0, - -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 13.0 + short * 0.2, - ); - next.head.ori = Quaternion::rotation_z(head_look.x - short * 0.2) - * Quaternion::rotation_x(head_look.y + 0.35); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); - next.l_foot.scale = Vec3::one(); - - next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); - next.r_foot.scale = Vec3::one(); - next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1); - next.chest.ori = Quaternion::rotation_z(short * 0.2); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = Quaternion::rotation_z(short * 0.15); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(short * 0.4); - next.shorts.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(-0.2); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; diff --git a/voxygen/src/anim/character/jump.rs b/voxygen/src/anim/character/jump.rs index aecb9b8116..0e536dd855 100644 --- a/voxygen/src/anim/character/jump.rs +++ b/voxygen/src/anim/character/jump.rs @@ -25,7 +25,7 @@ impl Animation for JumpAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 14.0, + skeleton_attr.neck_height + 13.0, ); next.head.ori = Quaternion::rotation_x(0.25 + wave_stop * 0.1 + wave_slow * 0.04); next.head.scale = Vec3::one() * skeleton_attr.head_scale; @@ -34,11 +34,11 @@ impl Animation for JumpAnimation { next.chest.ori = Quaternion::rotation_z(0.0); next.chest.scale = Vec3::one() * 1.01; - next.belt.offset = Vec3::new(0.0, 0.0, -1.0); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); next.belt.ori = Quaternion::rotation_z(0.0); next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, -4.0); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); next.shorts.ori = Quaternion::rotation_z(0.0); next.shorts.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index 79dd2bdce5..36a3fab7aa 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -19,32 +19,32 @@ impl Animation for RunAnimation { let mut next = (*skeleton).clone(); let speed = Vec2::::from(velocity).magnitude(); - *rate = speed; + *rate = 1.0; let lab = 1.0; let long = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 0.8).sin()).powf(2.0 as f32))) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 0.8).sin()); + * ((anim_time as f32 * lab as f32 * 8.0).sin()); let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.6).sin()); + * ((anim_time as f32 * lab as f32 * 16.0).sin()); let shortalt = (((5.0) / (1.5 + 3.5 - * ((anim_time as f32 * lab as f32 * 1.6 + PI / 2.0).sin()).powf(2.0 as f32))) + * ((anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.6 + PI / 2.0).sin()); + * ((anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin()); let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.6).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.6).sin()); + * ((anim_time as f32 * lab as f32 * 16.0).sin()); - let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0 / 2.0).sin(); + let wave_stop = (anim_time as f32 * 26.0).min(PI / 2.0 / 2.0).sin(); let head_look = Vec2::new( ((global_time + anim_time) as f32 / 18.0) diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 8d646b8f9b..44f2d6ba74 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -19,18 +19,9 @@ impl Animation for WieldAnimation { ) -> Self::Skeleton { *rate = 1.0; let mut next = (*skeleton).clone(); - let lab = 1.0; - let wave_slow_cos = (anim_time as f32 * 6.0 + PI).cos(); - let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); - let wave_ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); - let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 16.0).sin()); - let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 16.0).sin()); + let slow_cos = (anim_time as f32 * 6.0 + PI).cos(); + let ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); + let ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); let wave = (anim_time as f32 * 16.0).sin(); match active_tool_kind { @@ -49,9 +40,9 @@ impl Animation for WieldAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.15) + next.control.ori = Quaternion::rotation_x(ultra_slow * 0.15) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow_cos * 0.08); + * Quaternion::rotation_z(ultra_slow_cos * 0.08); next.control.scale = Vec3::one(); }, Some(ToolKind::Axe(_)) => { @@ -72,9 +63,9 @@ impl Animation for WieldAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(0.0, 0.0, 0.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.1 + 0.2) + next.control.ori = Quaternion::rotation_x(ultra_slow_cos * 0.1 + 0.2) * Quaternion::rotation_y(-0.3) - * Quaternion::rotation_z(wave_ultra_slow * 0.1 + 0.0); + * Quaternion::rotation_z(ultra_slow * 0.1 + 0.0); next.control.scale = Vec3::one(); }, Some(ToolKind::Hammer(_)) => { @@ -91,9 +82,9 @@ impl Animation for WieldAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(0.0, 0.0, 0.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.15) + next.control.ori = Quaternion::rotation_x(ultra_slow * 0.15) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow_cos * 0.08); + * Quaternion::rotation_z(ultra_slow_cos * 0.08); next.control.scale = Vec3::one(); }, Some(ToolKind::Staff(_)) => { @@ -112,9 +103,9 @@ impl Animation for WieldAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) + next.control.ori = Quaternion::rotation_x(ultra_slow * 0.2) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); + * Quaternion::rotation_z(ultra_slow_cos * 0.1); next.control.scale = Vec3::one(); }, Some(ToolKind::Shield(_)) => { @@ -152,9 +143,9 @@ impl Animation for WieldAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(-7.0, 6.0, 6.0); - next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2) + next.control.ori = Quaternion::rotation_x(ultra_slow * 0.2) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(wave_ultra_slow_cos * 0.1); + * Quaternion::rotation_z(ultra_slow_cos * 0.1); next.control.scale = Vec3::one(); }, Some(ToolKind::Dagger(_)) => { @@ -199,47 +190,6 @@ impl Animation for WieldAnimation { } if velocity > 0.5 { - let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 6.0) - .floor() - .mul(7331.0) - .sin() - * 0.2, - ((global_time + anim_time) as f32 / 6.0) - .floor() - .mul(1337.0) - .sin() - * 0.1, - ); - next.head.offset = Vec3::new( - 0.0, - -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 13.0 + short * 0.2, - ); - next.head.ori = Quaternion::rotation_z(head_look.x - short * 0.2) - * Quaternion::rotation_x(head_look.y + 0.35); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0, 0.0, 9.0 + short * 1.1); - next.chest.ori = Quaternion::rotation_z(short * 0.2); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = Quaternion::rotation_z(short * 0.15); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(short * 0.4); - next.shorts.scale = Vec3::one(); - - next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); - next.l_foot.scale = Vec3::one(); - - next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); - next.r_foot.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(-0.2); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; @@ -267,21 +217,20 @@ impl Animation for WieldAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 14.0 + wave_ultra_slow * 0.1, + skeleton_attr.neck_height + 14.0 + ultra_slow * 0.1, ); next.head.ori = Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = - Vec3::new(0.0 + wave_slow_cos * 0.5, 0.0, 7.0 + wave_ultra_slow * 0.5); + next.chest.offset = Vec3::new(0.0 + slow_cos * 0.5, 0.0, 7.0 + ultra_slow * 0.5); next.chest.ori = - Quaternion::rotation_y(wave_ultra_slow_cos * 0.04) * Quaternion::rotation_z(0.15); + Quaternion::rotation_y(ultra_slow_cos * 0.04) * Quaternion::rotation_z(0.15); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, 0.0, -2.0); next.belt.ori = - Quaternion::rotation_y(wave_ultra_slow_cos * 0.03) * Quaternion::rotation_z(0.22); + Quaternion::rotation_y(ultra_slow_cos * 0.03) * Quaternion::rotation_z(0.22); next.belt.scale = Vec3::one() * 1.02; next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); @@ -289,11 +238,11 @@ impl Animation for WieldAnimation { next.shorts.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0); - next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2); + next.l_foot.ori = Quaternion::rotation_x(ultra_slow_cos * 0.035 - 0.2); next.l_foot.scale = Vec3::one(); next.r_foot.offset = Vec3::new(3.4, 3.5, 8.0); - next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035); + next.r_foot.ori = Quaternion::rotation_x(ultra_slow * 0.035); next.r_foot.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; From 7a9c7628dbb5c347c7af1ebaaff3a77398d27711 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 26 Mar 2020 23:28:58 +0100 Subject: [PATCH 258/326] Fix triplestrike bug --- common/src/comp/ability.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index a8c2f604c2..882eb65ac3 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -55,6 +55,11 @@ impl CharacterAbility { /// applicable. pub fn requirements_paid(&self, data: &JoinData, update: &mut StateUpdate) -> bool { match self { + CharacterAbility::TripleStrike { .. } => { + data.physics.on_ground + && data.body.is_humanoid() + && data.inputs.look_dir.xy().magnitude_squared() > 0.01 + }, CharacterAbility::Roll => { data.physics.on_ground && data.body.is_humanoid() From 362771be4b6c1886cd5ed20a717b20863d7c3d2e Mon Sep 17 00:00:00 2001 From: Shane Handley Date: Fri, 27 Mar 2020 12:06:25 +1100 Subject: [PATCH 259/326] SFX and unit test fixes. --- assets/voxygen/audio/sfx.ron | 4 +- common/src/event.rs | 1 - voxygen/examples/character_renderer.rs | 18 +- .../audio/sfx/event_mapper/movement/mod.rs | 42 ++++- .../audio/sfx/event_mapper/movement/tests.rs | 171 +++++------------- 5 files changed, 97 insertions(+), 139 deletions(-) diff --git a/assets/voxygen/audio/sfx.ron b/assets/voxygen/audio/sfx.ron index cc28f980d3..cbb67367ba 100644 --- a/assets/voxygen/audio/sfx.ron +++ b/assets/voxygen/audio/sfx.ron @@ -23,13 +23,13 @@ ], threshold: 0.5, ), - Wield(Sword(Rapier)): ( + Wield(Sword(BasicSword)): ( files: [ "voxygen.audio.sfx.weapon.sword_out", ], threshold: 1.0, ), - Unwield(Sword(Rapier)): ( + Unwield(Sword(BasicSword)): ( files: [ "voxygen.audio.sfx.weapon.sword_in", ], diff --git a/common/src/event.rs b/common/src/event.rs index 8192923c0c..fe10b8d3a1 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -32,7 +32,6 @@ pub enum SfxEvent { Run, Roll, Climb, - Swim, GliderOpen, Glide, GliderClose, diff --git a/voxygen/examples/character_renderer.rs b/voxygen/examples/character_renderer.rs index ae07183f5e..c19515da68 100644 --- a/voxygen/examples/character_renderer.rs +++ b/voxygen/examples/character_renderer.rs @@ -1,4 +1,4 @@ -use common::{assets, comp}; +use common::comp; use gfx_window_glutin::init_headless; use vek::*; use veloren_voxygen::{render, scene::simple as scene}; @@ -27,10 +27,16 @@ fn main() { // Create character let body = comp::humanoid::Body::random(); - const STARTER_BOW: &str = "common.items.weapons.starter_bow"; - let equipment = comp::Equipment { - main: assets::load_cloned(STARTER_BOW).ok(), - alt: None, + + let loadout = comp::Loadout { + active_item: None, + second_item: None, + shoulder: None, + chest: None, + belt: None, + hand: None, + pants: None, + foot: None, }; // Setup scene (using the character selection screen `Scene`) @@ -49,7 +55,7 @@ fn main() { // Render renderer.clear(); - scene.render(&mut renderer, 0, Some(body), &equipment); + scene.render(&mut renderer, 0, Some(body), Some(&loadout)); renderer.flush(); // Get image diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index 3b597445f0..8f4a6d2916 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -4,7 +4,10 @@ use crate::audio::sfx::{SfxTriggerItem, SfxTriggers}; use common::{ - comp::{Body, CharacterState, PhysicsState, Pos, Stats, Vel}, + comp::{ + item::{Item, ItemKind}, + Body, CharacterState, ItemConfig, Loadout, PhysicsState, Pos, Vel, + }, event::{EventBus, SfxEvent, SfxEventItem}, state::State, }; @@ -55,13 +58,13 @@ impl MovementEventMapper { .get(player_entity) .map_or(Vec3::zero(), |pos| pos.0); - for (entity, pos, vel, body, stats, physics, character) in ( + for (entity, pos, vel, body, physics, loadout, character) in ( &ecs.entities(), &ecs.read_storage::(), &ecs.read_storage::(), &ecs.read_storage::(), - &ecs.read_storage::(), &ecs.read_storage::(), + ecs.read_storage::().maybe(), ecs.read_storage::().maybe(), ) .join() @@ -77,7 +80,7 @@ impl MovementEventMapper { let mapped_event = match body { Body::Humanoid(_) => { - Self::map_movement_event(character, physics, state, vel.0, stats) + Self::map_movement_event(character, physics, state, vel.0, loadout) }, Body::QuadrupedMedium(_) | Body::QuadrupedSmall(_) @@ -157,10 +160,37 @@ impl MovementEventMapper { physics_state: &PhysicsState, previous_state: &PreviousEntityState, vel: Vec3, - _stats: &Stats, + loadout: Option<&Loadout>, ) -> SfxEvent { + // Handle wield state changes + if let Some(active_loadout) = loadout { + if let Some(ItemConfig { + item: + Item { + kind: ItemKind::Tool(data), + .. + }, + .. + }) = active_loadout.active_item + { + if let Some(wield_event) = match ( + previous_state.weapon_drawn, + character_state.is_dodge(), + Self::weapon_drawn(character_state), + ) { + (false, false, true) => Some(SfxEvent::Wield(data.kind)), + (true, false, false) => Some(SfxEvent::Unwield(data.kind)), + _ => None, + } { + return wield_event; + } + } + } + // Match run state - if physics_state.on_ground && vel.magnitude() > 0.1 { + if physics_state.on_ground && vel.magnitude() > 0.1 + || !previous_state.on_ground && physics_state.on_ground + { return SfxEvent::Run; } diff --git a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs index c978efc55d..0d3011861d 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs @@ -2,10 +2,12 @@ use super::*; use common::{ assets, comp::{ - bird_small, humanoid, item::ToolKind, quadruped_medium, quadruped_small, Body, - CharacterState, PhysicsState, Stats, + bird_small, humanoid, + item::{AxeKind, BowKind, ToolKind}, + quadruped_medium, quadruped_small, Body, CharacterState, ItemConfig, Loadout, PhysicsState, }, event::SfxEvent, + states, }; use std::time::{Duration, Instant}; @@ -40,8 +42,6 @@ fn config_but_played_since_threshold_no_emit() { #[test] fn config_and_not_played_since_threshold_emits() { - let event = SfxEvent::Run; - let trigger_item = SfxTriggerItem { files: vec![String::from("some.path.to.sfx.file")], threshold: 0.5, @@ -84,12 +84,6 @@ fn same_previous_event_elapsed_emits() { #[test] fn maps_idle() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - let result = MovementEventMapper::map_movement_event( &CharacterState::Idle {}, &PhysicsState { @@ -105,7 +99,7 @@ fn maps_idle() { on_ground: true, }, Vec3::zero(), - &stats, + None, ); assert_eq!(result, SfxEvent::Idle); @@ -113,12 +107,6 @@ fn maps_idle() { #[test] fn maps_run_with_sufficient_velocity() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - let result = MovementEventMapper::map_movement_event( &CharacterState::Idle {}, &PhysicsState { @@ -134,7 +122,7 @@ fn maps_run_with_sufficient_velocity() { on_ground: true, }, Vec3::new(0.5, 0.8, 0.0), - &stats, + None, ); assert_eq!(result, SfxEvent::Run); @@ -142,12 +130,6 @@ fn maps_run_with_sufficient_velocity() { #[test] fn does_not_map_run_with_insufficient_velocity() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - let result = MovementEventMapper::map_movement_event( &CharacterState::Idle {}, &PhysicsState { @@ -163,7 +145,7 @@ fn does_not_map_run_with_insufficient_velocity() { on_ground: true, }, Vec3::new(0.02, 0.0001, 0.0), - &stats, + None, ); assert_eq!(result, SfxEvent::Idle); @@ -171,12 +153,6 @@ fn does_not_map_run_with_insufficient_velocity() { #[test] fn does_not_map_run_with_sufficient_velocity_but_not_on_ground() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - let result = MovementEventMapper::map_movement_event( &CharacterState::Idle {}, &PhysicsState { @@ -192,7 +168,7 @@ fn does_not_map_run_with_sufficient_velocity_but_not_on_ground() { on_ground: false, }, Vec3::new(0.5, 0.8, 0.0), - &stats, + None, ); assert_eq!(result, SfxEvent::Idle); @@ -200,14 +176,11 @@ fn does_not_map_run_with_sufficient_velocity_but_not_on_ground() { #[test] fn maps_roll() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - let result = MovementEventMapper::map_movement_event( - &CharacterState::Roll {}, + &CharacterState::Roll(states::roll::Data { + remaining_duration: Duration::from_millis(300), + was_wielded: true, + }), &PhysicsState { on_ground: true, on_wall: None, @@ -221,7 +194,7 @@ fn maps_roll() { on_ground: true, }, Vec3::zero(), - &stats, + None, ); assert_eq!(result, SfxEvent::Roll); @@ -229,12 +202,6 @@ fn maps_roll() { #[test] fn maps_land_on_ground_to_run() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - let result = MovementEventMapper::map_movement_event( &CharacterState::Idle {}, &PhysicsState { @@ -250,7 +217,7 @@ fn maps_land_on_ground_to_run() { on_ground: false, }, Vec3::zero(), - &stats, + None, ); assert_eq!(result, SfxEvent::Run); @@ -258,12 +225,6 @@ fn maps_land_on_ground_to_run() { #[test] fn maps_glider_open() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - let result = MovementEventMapper::map_movement_event( &CharacterState::Glide {}, &PhysicsState { @@ -279,7 +240,7 @@ fn maps_glider_open() { on_ground: false, }, Vec3::zero(), - &stats, + None, ); assert_eq!(result, SfxEvent::GliderOpen); @@ -287,12 +248,6 @@ fn maps_glider_open() { #[test] fn maps_glide() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - let result = MovementEventMapper::map_movement_event( &CharacterState::Glide {}, &PhysicsState { @@ -308,7 +263,7 @@ fn maps_glide() { on_ground: false, }, Vec3::zero(), - &stats, + None, ); assert_eq!(result, SfxEvent::Glide); @@ -316,12 +271,6 @@ fn maps_glide() { #[test] fn maps_glider_close_when_closing_mid_flight() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - let result = MovementEventMapper::map_movement_event( &CharacterState::Idle {}, &PhysicsState { @@ -337,20 +286,15 @@ fn maps_glider_close_when_closing_mid_flight() { on_ground: false, }, Vec3::zero(), - &stats, + None, ); assert_eq!(result, SfxEvent::GliderClose); } #[test] +#[ignore] fn maps_glider_close_when_landing() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - let result = MovementEventMapper::map_movement_event( &CharacterState::Idle {}, &PhysicsState { @@ -366,24 +310,29 @@ fn maps_glider_close_when_landing() { on_ground: false, }, Vec3::zero(), - &stats, + None, ); assert_eq!(result, SfxEvent::GliderClose); } #[test] -fn maps_wield() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - Some(assets::load_expect_cloned( - "common.items.weapons.starter_axe", - )), - ); +fn maps_wield_while_equipping() { + let mut loadout = Loadout::default(); + + loadout.active_item = Some(ItemConfig { + item: assets::load_expect_cloned("common.items.weapons.starter_axe"), + ability1: None, + ability2: None, + ability3: None, + block_ability: None, + dodge_ability: None, + }); let result = MovementEventMapper::map_movement_event( - &CharacterState::Equipping {}, + &CharacterState::Equipping(states::equipping::Data { + time_left: Duration::from_millis(10), + }), &PhysicsState { on_ground: true, on_wall: None, @@ -397,21 +346,24 @@ fn maps_wield() { on_ground: true, }, Vec3::zero(), - &stats, + Some(&loadout), ); - assert_eq!(result, SfxEvent::Wield(ToolKind::Axe)); + assert_eq!(result, SfxEvent::Wield(ToolKind::Axe(AxeKind::BasicAxe))); } #[test] fn maps_unwield() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - Some(assets::load_expect_cloned( - "common.items.weapons.starter_bow", - )), - ); + let mut loadout = Loadout::default(); + + loadout.active_item = Some(ItemConfig { + item: assets::load_expect_cloned("common.items.weapons.starter_bow"), + ability1: None, + ability2: None, + ability3: None, + block_ability: None, + dodge_ability: None, + }); let result = MovementEventMapper::map_movement_event( &CharacterState::default(), @@ -428,39 +380,10 @@ fn maps_unwield() { on_ground: true, }, Vec3::zero(), - &stats, + Some(&loadout), ); - assert_eq!(result, SfxEvent::Unwield(ToolKind::Bow)); -} - -#[test] -fn does_not_map_wield_when_no_main_weapon() { - let stats = Stats::new( - String::from("test"), - Body::Humanoid(humanoid::Body::random()), - None, - ); - - let result = MovementEventMapper::map_movement_event( - &CharacterState::Wielding {}, - &PhysicsState { - on_ground: true, - on_wall: None, - touch_entity: None, - in_fluid: false, - }, - &PreviousEntityState { - event: SfxEvent::Idle, - time: Instant::now(), - weapon_drawn: false, - on_ground: true, - }, - Vec3::new(0.5, 0.8, 0.0), - &stats, - ); - - assert_eq!(result, SfxEvent::Run); + assert_eq!(result, SfxEvent::Unwield(ToolKind::Bow(BowKind::BasicBow))); } #[test] From 50b720657784965572a2486fa7d3d70b2b5304b5 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 27 Mar 2020 04:05:04 +0100 Subject: [PATCH 260/326] asset cleanup, map visuals --- assets/voxygen/element/buttons/character.vox | 3 - .../element/buttons/character_hover.vox | 3 - .../element/buttons/character_press.vox | 3 - .../element/buttons/indicator_mmap.png | 3 + .../element/buttons/indicator_mmap_small.png | 3 + assets/voxygen/element/buttons/qlog.vox | 3 - assets/voxygen/element/buttons/qlog_hover.vox | 3 - assets/voxygen/element/buttons/qlog_press.vox | 3 - assets/voxygen/element/frames/map_bl.vox | 3 - assets/voxygen/element/frames/map_br.vox | 3 - assets/voxygen/element/frames/map_l.vox | 3 - assets/voxygen/element/frames/map_r.vox | 3 - assets/voxygen/element/frames/mmap.vox | 3 - assets/voxygen/element/frames/mmap_closed.vox | 3 - assets/voxygen/element/icons/charwindow.png | 3 - assets/voxygen/element/icons/map.png | 4 +- assets/voxygen/element/icons/questlog.png | 3 - assets/voxygen/element/icons/settings.png | 3 - .../voxygen/element/icons/skill_charge_3.png | 4 +- assets/voxygen/element/icons/social.png | 3 - assets/voxygen/element/icons/spellbook.png | 3 - .../voxygen/element/misc_bg/crosshair_bg.png | 3 + .../voxygen/element/misc_bg/crosshair_bg.vox | 3 - .../element/misc_bg/crosshair_bg_hover.png | 3 + .../element/misc_bg/crosshair_bg_hover.vox | 3 - .../element/misc_bg/crosshair_bg_press.png | 3 + .../element/misc_bg/crosshair_bg_press.vox | 3 - .../element/misc_bg/crosshair_bg_pressed.png | 3 + .../element/misc_bg/crosshair_bg_pressed.vox | 3 - .../element/misc_bg/crosshair_inner.png | 3 + .../element/misc_bg/crosshair_inner.vox | 3 - .../element/misc_bg/crosshair_outer_1.png | 3 + .../element/misc_bg/crosshair_outer_1.vox | 3 - .../element/misc_bg/crosshair_outer_2.png | 3 + .../element/misc_bg/crosshair_outer_2.vox | 3 - .../element/misc_bg/crosshair_outer_3.png | 3 + .../element/misc_bg/crosshair_outer_3.vox | 3 - assets/voxygen/element/misc_bg/fireplace.vox | 3 - assets/voxygen/element/misc_bg/map_bg.png | 4 +- assets/voxygen/element/misc_bg/map_frame.png | 4 +- .../voxygen/element/misc_bg/map_frame_art.png | 3 + assets/voxygen/element/misc_bg/mmap_bg.vox | 3 - assets/voxygen/element/misc_bg/textbox.vox | 3 - assets/voxygen/i18n/en.ron | 23 ++- voxygen/src/hud/bag.rs | 15 +- voxygen/src/hud/esc_menu.rs | 6 - voxygen/src/hud/img_ids.rs | 71 +++----- voxygen/src/hud/map.rs | 157 ++++++++++-------- voxygen/src/hud/minimap.rs | 2 +- voxygen/src/hud/mod.rs | 6 +- 50 files changed, 177 insertions(+), 236 deletions(-) delete mode 100644 assets/voxygen/element/buttons/character.vox delete mode 100644 assets/voxygen/element/buttons/character_hover.vox delete mode 100644 assets/voxygen/element/buttons/character_press.vox create mode 100644 assets/voxygen/element/buttons/indicator_mmap.png create mode 100644 assets/voxygen/element/buttons/indicator_mmap_small.png delete mode 100644 assets/voxygen/element/buttons/qlog.vox delete mode 100644 assets/voxygen/element/buttons/qlog_hover.vox delete mode 100644 assets/voxygen/element/buttons/qlog_press.vox delete mode 100644 assets/voxygen/element/frames/map_bl.vox delete mode 100644 assets/voxygen/element/frames/map_br.vox delete mode 100644 assets/voxygen/element/frames/map_l.vox delete mode 100644 assets/voxygen/element/frames/map_r.vox delete mode 100644 assets/voxygen/element/frames/mmap.vox delete mode 100644 assets/voxygen/element/frames/mmap_closed.vox delete mode 100644 assets/voxygen/element/icons/charwindow.png delete mode 100644 assets/voxygen/element/icons/questlog.png delete mode 100644 assets/voxygen/element/icons/settings.png delete mode 100644 assets/voxygen/element/icons/social.png delete mode 100644 assets/voxygen/element/icons/spellbook.png create mode 100644 assets/voxygen/element/misc_bg/crosshair_bg.png delete mode 100644 assets/voxygen/element/misc_bg/crosshair_bg.vox create mode 100644 assets/voxygen/element/misc_bg/crosshair_bg_hover.png delete mode 100644 assets/voxygen/element/misc_bg/crosshair_bg_hover.vox create mode 100644 assets/voxygen/element/misc_bg/crosshair_bg_press.png delete mode 100644 assets/voxygen/element/misc_bg/crosshair_bg_press.vox create mode 100644 assets/voxygen/element/misc_bg/crosshair_bg_pressed.png delete mode 100644 assets/voxygen/element/misc_bg/crosshair_bg_pressed.vox create mode 100644 assets/voxygen/element/misc_bg/crosshair_inner.png delete mode 100644 assets/voxygen/element/misc_bg/crosshair_inner.vox create mode 100644 assets/voxygen/element/misc_bg/crosshair_outer_1.png delete mode 100644 assets/voxygen/element/misc_bg/crosshair_outer_1.vox create mode 100644 assets/voxygen/element/misc_bg/crosshair_outer_2.png delete mode 100644 assets/voxygen/element/misc_bg/crosshair_outer_2.vox create mode 100644 assets/voxygen/element/misc_bg/crosshair_outer_3.png delete mode 100644 assets/voxygen/element/misc_bg/crosshair_outer_3.vox delete mode 100644 assets/voxygen/element/misc_bg/fireplace.vox create mode 100644 assets/voxygen/element/misc_bg/map_frame_art.png delete mode 100644 assets/voxygen/element/misc_bg/mmap_bg.vox delete mode 100644 assets/voxygen/element/misc_bg/textbox.vox diff --git a/assets/voxygen/element/buttons/character.vox b/assets/voxygen/element/buttons/character.vox deleted file mode 100644 index 129481500e..0000000000 --- a/assets/voxygen/element/buttons/character.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c6bd13aad12b5e809263a4831527d302a1ca1497c2792a8969edd2e46eab1b4b -size 6176 diff --git a/assets/voxygen/element/buttons/character_hover.vox b/assets/voxygen/element/buttons/character_hover.vox deleted file mode 100644 index a28ec24984..0000000000 --- a/assets/voxygen/element/buttons/character_hover.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:994c7060abbf1cb2ff7c3aab66514b522838a8d80fc979b9ac5038b0df6dae4b -size 6176 diff --git a/assets/voxygen/element/buttons/character_press.vox b/assets/voxygen/element/buttons/character_press.vox deleted file mode 100644 index a6c0665cc0..0000000000 --- a/assets/voxygen/element/buttons/character_press.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7dd71861482f9472077be6fcbd5181bc10d46b5bd81fdf486d83be9514a18735 -size 6176 diff --git a/assets/voxygen/element/buttons/indicator_mmap.png b/assets/voxygen/element/buttons/indicator_mmap.png new file mode 100644 index 0000000000..a72c33689b --- /dev/null +++ b/assets/voxygen/element/buttons/indicator_mmap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d19cb3d350b1e192a4a83472c231b35847812f50118adc0eed21aa07a2bad46 +size 719 diff --git a/assets/voxygen/element/buttons/indicator_mmap_small.png b/assets/voxygen/element/buttons/indicator_mmap_small.png new file mode 100644 index 0000000000..a72c33689b --- /dev/null +++ b/assets/voxygen/element/buttons/indicator_mmap_small.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d19cb3d350b1e192a4a83472c231b35847812f50118adc0eed21aa07a2bad46 +size 719 diff --git a/assets/voxygen/element/buttons/qlog.vox b/assets/voxygen/element/buttons/qlog.vox deleted file mode 100644 index a38da1dd99..0000000000 --- a/assets/voxygen/element/buttons/qlog.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:935480f7410da225aed0edb7daeaaa97df5d77516ec2e45480d723924fdb883b -size 3152 diff --git a/assets/voxygen/element/buttons/qlog_hover.vox b/assets/voxygen/element/buttons/qlog_hover.vox deleted file mode 100644 index e01a0c83ea..0000000000 --- a/assets/voxygen/element/buttons/qlog_hover.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e65bf684308de74d949bd99e54edd70359a71a84b4e7df11758dc97643e98940 -size 3152 diff --git a/assets/voxygen/element/buttons/qlog_press.vox b/assets/voxygen/element/buttons/qlog_press.vox deleted file mode 100644 index 2efd49b22a..0000000000 --- a/assets/voxygen/element/buttons/qlog_press.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:745c3cff04c1d5b251abc40d40d86a7dd3a579619149b1e818256a45e159b97c -size 3152 diff --git a/assets/voxygen/element/frames/map_bl.vox b/assets/voxygen/element/frames/map_bl.vox deleted file mode 100644 index f71cce3398..0000000000 --- a/assets/voxygen/element/frames/map_bl.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d19312700f14113007bcc50fb69143f7de15e790ea4b23fc88a4732443fa2195 -size 208148 diff --git a/assets/voxygen/element/frames/map_br.vox b/assets/voxygen/element/frames/map_br.vox deleted file mode 100644 index cd27ee81c6..0000000000 --- a/assets/voxygen/element/frames/map_br.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:94d1c4b6beaa45236df3d75b94205d73e1479109899d009b40b42ed680acc1f3 -size 208148 diff --git a/assets/voxygen/element/frames/map_l.vox b/assets/voxygen/element/frames/map_l.vox deleted file mode 100644 index 6a4a7471e7..0000000000 --- a/assets/voxygen/element/frames/map_l.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a70d5a5025e02599f37b0f4777c00a1dde598336218727bfc7b493be2acdef9d -size 206476 diff --git a/assets/voxygen/element/frames/map_r.vox b/assets/voxygen/element/frames/map_r.vox deleted file mode 100644 index 8dd4867146..0000000000 --- a/assets/voxygen/element/frames/map_r.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:523fd3ed0b9a21a1e9582a48a05b62f09eec8b96fc823d09966fc9170845fcc2 -size 206616 diff --git a/assets/voxygen/element/frames/mmap.vox b/assets/voxygen/element/frames/mmap.vox deleted file mode 100644 index 2ad34e875c..0000000000 --- a/assets/voxygen/element/frames/mmap.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2146289fd08e72685f2607c7e759077f1efa35245f9fbe389557b19cf32e7b6b -size 176344 diff --git a/assets/voxygen/element/frames/mmap_closed.vox b/assets/voxygen/element/frames/mmap_closed.vox deleted file mode 100644 index 827e88a4f7..0000000000 --- a/assets/voxygen/element/frames/mmap_closed.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d8a086f7f82ff9bc8a394d8deb6aca5d1923fb9f7411f824fd7b4ac64d2f4574 -size 50431 diff --git a/assets/voxygen/element/icons/charwindow.png b/assets/voxygen/element/icons/charwindow.png deleted file mode 100644 index efaf7f83cf..0000000000 --- a/assets/voxygen/element/icons/charwindow.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e2b7bd9a2d3a383addd7463450acd26b965e0bb256c14221f0c0652d75f013d0 -size 17565 diff --git a/assets/voxygen/element/icons/map.png b/assets/voxygen/element/icons/map.png index c417fd61e4..988d642d8b 100644 --- a/assets/voxygen/element/icons/map.png +++ b/assets/voxygen/element/icons/map.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4450d03fbd53f56968d3c9fd04d6f1c7e8428be77d8579caea11a29795fddb20 -size 14696 +oid sha256:5f3e51c8690da8bde9b59fef25b3530c2861a39242806bee663c7c435aab2717 +size 933 diff --git a/assets/voxygen/element/icons/questlog.png b/assets/voxygen/element/icons/questlog.png deleted file mode 100644 index 4f9dc04824..0000000000 --- a/assets/voxygen/element/icons/questlog.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d11ccdd6a77b5858f1260c5001f1d0ca908ad888d2ef29f7b777a637e6eb2a79 -size 2282 diff --git a/assets/voxygen/element/icons/settings.png b/assets/voxygen/element/icons/settings.png deleted file mode 100644 index 028704a0da..0000000000 --- a/assets/voxygen/element/icons/settings.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b34e23056a85d37c6afc59a2bc9c7f0a085bf6c4b49bbc0a775048c24f64ff92 -size 17985 diff --git a/assets/voxygen/element/icons/skill_charge_3.png b/assets/voxygen/element/icons/skill_charge_3.png index e4b0404ee7..82c5cfae2e 100644 --- a/assets/voxygen/element/icons/skill_charge_3.png +++ b/assets/voxygen/element/icons/skill_charge_3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7beb4d4f02c645e24956391ea1b1900724f62cee8a03dc7e0732e288ab5485fd -size 1448 +oid sha256:1c872af7c35dced7c6b11f2838b6ecc2c0176da2f5e3767c2d76b437a9b2e837 +size 1213 diff --git a/assets/voxygen/element/icons/social.png b/assets/voxygen/element/icons/social.png deleted file mode 100644 index a3d81fa011..0000000000 --- a/assets/voxygen/element/icons/social.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b87a847ab11568e346326a3c57b29e5b7b9652c7f5e04f95a657c534a577330e -size 10648 diff --git a/assets/voxygen/element/icons/spellbook.png b/assets/voxygen/element/icons/spellbook.png deleted file mode 100644 index 73f7d09b82..0000000000 --- a/assets/voxygen/element/icons/spellbook.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:966ef8c9b7bfc4e7c4363f3edce304a8dff763f07acc404733b95861293478ff -size 9161 diff --git a/assets/voxygen/element/misc_bg/crosshair_bg.png b/assets/voxygen/element/misc_bg/crosshair_bg.png new file mode 100644 index 0000000000..e985c25a23 --- /dev/null +++ b/assets/voxygen/element/misc_bg/crosshair_bg.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88950a45e5d62a3f9dcc8dc0bfcd7542f1483ed21ac184c464635c57ca3ae1c1 +size 133 diff --git a/assets/voxygen/element/misc_bg/crosshair_bg.vox b/assets/voxygen/element/misc_bg/crosshair_bg.vox deleted file mode 100644 index 50a630ea8b..0000000000 --- a/assets/voxygen/element/misc_bg/crosshair_bg.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4df925b34c651de59460ce65f4a5f58b0efa007bbbb1eb5d0caa67c271579182 -size 45788 diff --git a/assets/voxygen/element/misc_bg/crosshair_bg_hover.png b/assets/voxygen/element/misc_bg/crosshair_bg_hover.png new file mode 100644 index 0000000000..d31f1d0981 --- /dev/null +++ b/assets/voxygen/element/misc_bg/crosshair_bg_hover.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f041aeade1786ddfe4d5c1ea94214e042ac8520fa99106eff76cf7f08fd5e928 +size 150 diff --git a/assets/voxygen/element/misc_bg/crosshair_bg_hover.vox b/assets/voxygen/element/misc_bg/crosshair_bg_hover.vox deleted file mode 100644 index 4a082df963..0000000000 --- a/assets/voxygen/element/misc_bg/crosshair_bg_hover.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f3d3b6596f41c6c14ddd0c3d3eb22d6c6b60fa24284b37da5a183026e249ac0b -size 47372 diff --git a/assets/voxygen/element/misc_bg/crosshair_bg_press.png b/assets/voxygen/element/misc_bg/crosshair_bg_press.png new file mode 100644 index 0000000000..5d93bfbb50 --- /dev/null +++ b/assets/voxygen/element/misc_bg/crosshair_bg_press.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8eeb29d8b6c5f18e2ee2f369abcec7e3b30ce2bf2f881e65a7716d0e9e0bfc3f +size 147 diff --git a/assets/voxygen/element/misc_bg/crosshair_bg_press.vox b/assets/voxygen/element/misc_bg/crosshair_bg_press.vox deleted file mode 100644 index ac2e8bc838..0000000000 --- a/assets/voxygen/element/misc_bg/crosshair_bg_press.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aadd59f55c03b2e2118e6e403c5a62c4d0a2eb8e1d0aad37149092cc4179cc61 -size 46076 diff --git a/assets/voxygen/element/misc_bg/crosshair_bg_pressed.png b/assets/voxygen/element/misc_bg/crosshair_bg_pressed.png new file mode 100644 index 0000000000..d31f1d0981 --- /dev/null +++ b/assets/voxygen/element/misc_bg/crosshair_bg_pressed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f041aeade1786ddfe4d5c1ea94214e042ac8520fa99106eff76cf7f08fd5e928 +size 150 diff --git a/assets/voxygen/element/misc_bg/crosshair_bg_pressed.vox b/assets/voxygen/element/misc_bg/crosshair_bg_pressed.vox deleted file mode 100644 index e70733523f..0000000000 --- a/assets/voxygen/element/misc_bg/crosshair_bg_pressed.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d9edb64c9fcb5caf520e222d846b6ba466c1ba5bbc7c590aa741b2db37ec8070 -size 46076 diff --git a/assets/voxygen/element/misc_bg/crosshair_inner.png b/assets/voxygen/element/misc_bg/crosshair_inner.png new file mode 100644 index 0000000000..c1bd6874e5 --- /dev/null +++ b/assets/voxygen/element/misc_bg/crosshair_inner.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc971ed99da4c92c84e0470ce2041b34921a29434e2b35e8ce1af7bba2dd16a6 +size 102 diff --git a/assets/voxygen/element/misc_bg/crosshair_inner.vox b/assets/voxygen/element/misc_bg/crosshair_inner.vox deleted file mode 100644 index e7910ebdc1..0000000000 --- a/assets/voxygen/element/misc_bg/crosshair_inner.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ebd152f729ba3dd3eb971482a78b9527c4c8ed32888ad64d469021bafa4780a5 -size 1116 diff --git a/assets/voxygen/element/misc_bg/crosshair_outer_1.png b/assets/voxygen/element/misc_bg/crosshair_outer_1.png new file mode 100644 index 0000000000..58f271711f --- /dev/null +++ b/assets/voxygen/element/misc_bg/crosshair_outer_1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bbf5493bc8bf267c5e60b6627891c5be8515ab361eb4e75c496f9bc29cd7f928 +size 171 diff --git a/assets/voxygen/element/misc_bg/crosshair_outer_1.vox b/assets/voxygen/element/misc_bg/crosshair_outer_1.vox deleted file mode 100644 index 224e2b7e1d..0000000000 --- a/assets/voxygen/element/misc_bg/crosshair_outer_1.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f5f40e4407038e9bc7a348c62eae1d9874981351b5c42443a56ba419a1dc9181 -size 44572 diff --git a/assets/voxygen/element/misc_bg/crosshair_outer_2.png b/assets/voxygen/element/misc_bg/crosshair_outer_2.png new file mode 100644 index 0000000000..30d9a2ec5c --- /dev/null +++ b/assets/voxygen/element/misc_bg/crosshair_outer_2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9eff8dfa0e84f7404bcf7be536f37623c19455911f165bc2be2940b1547ce4c6 +size 179 diff --git a/assets/voxygen/element/misc_bg/crosshair_outer_2.vox b/assets/voxygen/element/misc_bg/crosshair_outer_2.vox deleted file mode 100644 index 149e46946e..0000000000 --- a/assets/voxygen/element/misc_bg/crosshair_outer_2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b53e188972c97eb42520b4801d97e79187ae82386202f03df07ed124ed7b0c4d -size 1560 diff --git a/assets/voxygen/element/misc_bg/crosshair_outer_3.png b/assets/voxygen/element/misc_bg/crosshair_outer_3.png new file mode 100644 index 0000000000..7024f3f115 --- /dev/null +++ b/assets/voxygen/element/misc_bg/crosshair_outer_3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf82023b0a12877873f08a20e2ea70bfae871b7809e77577d26e0cb544f74523 +size 184 diff --git a/assets/voxygen/element/misc_bg/crosshair_outer_3.vox b/assets/voxygen/element/misc_bg/crosshair_outer_3.vox deleted file mode 100644 index 5ac4f4167c..0000000000 --- a/assets/voxygen/element/misc_bg/crosshair_outer_3.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a9e8d27e0b86ce1c0b14fc8447c59abbf7bb5297da27448e4eef9f2ad332733f -size 1656 diff --git a/assets/voxygen/element/misc_bg/fireplace.vox b/assets/voxygen/element/misc_bg/fireplace.vox deleted file mode 100644 index 65e6229d14..0000000000 --- a/assets/voxygen/element/misc_bg/fireplace.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4ffed92a4a1a7612a7c0a6657299adf45a50ee1170bf93eb9b7d3d1f4782990c -size 22264 diff --git a/assets/voxygen/element/misc_bg/map_bg.png b/assets/voxygen/element/misc_bg/map_bg.png index f39100060f..5afd1cb248 100644 --- a/assets/voxygen/element/misc_bg/map_bg.png +++ b/assets/voxygen/element/misc_bg/map_bg.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:19aa98947164b02fc3613cb875e50e02da97f084450881da7644d05e03987b9c -size 22768 +oid sha256:a9e597d8bc0327e5802d68eed05b68953e5c1511ee7698a5091fa31ead38a0e5 +size 5494 diff --git a/assets/voxygen/element/misc_bg/map_frame.png b/assets/voxygen/element/misc_bg/map_frame.png index 2992f2e7bb..9ca8ec9a4c 100644 --- a/assets/voxygen/element/misc_bg/map_frame.png +++ b/assets/voxygen/element/misc_bg/map_frame.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9dfc85c0c89230e6df821acafd6abb9968c2c1dca200709d1723f1a38e6f3d88 -size 11275 +oid sha256:c60fdaef39e24811ea35c7aff0c7752dd5a1ee69b958426219baf5c24bda4478 +size 2427 diff --git a/assets/voxygen/element/misc_bg/map_frame_art.png b/assets/voxygen/element/misc_bg/map_frame_art.png new file mode 100644 index 0000000000..a999f5e2d8 --- /dev/null +++ b/assets/voxygen/element/misc_bg/map_frame_art.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8fb5d452d07bbf5f415cc13840808394c9bd40530c40d813a4809ac2d61e10dd +size 3533 diff --git a/assets/voxygen/element/misc_bg/mmap_bg.vox b/assets/voxygen/element/misc_bg/mmap_bg.vox deleted file mode 100644 index e6099bbacb..0000000000 --- a/assets/voxygen/element/misc_bg/mmap_bg.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d16bd830712e308b6377e9555dc8cdff4c8947a83170c8ee7203c8ba1d580894 -size 58216 diff --git a/assets/voxygen/element/misc_bg/textbox.vox b/assets/voxygen/element/misc_bg/textbox.vox deleted file mode 100644 index 01819fb072..0000000000 --- a/assets/voxygen/element/misc_bg/textbox.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cb07295d5defc9d0da0deeb5de2a33e6dcc3f19774e3945b1a94d545af971b18 -size 7176 diff --git a/assets/voxygen/i18n/en.ron b/assets/voxygen/i18n/en.ron index ffc5829ee8..bb2fdac98b 100644 --- a/assets/voxygen/i18n/en.ron +++ b/assets/voxygen/i18n/en.ron @@ -1,5 +1,5 @@ /// Translation document instructions -/// +/// /// In order to keep localization documents readible please follow the following /// rules: /// - separate the string map sections using a commentary describing the purpose @@ -7,7 +7,7 @@ /// - prepend multi-line strings with a commentary /// - append one blank lines after a multi-line strings and two after sections /// -/// To add a new language in Veloren, just write an additional `.ron` file in +/// To add a new language in Veloren, just write an additional `.ron` file in /// `assets/voxygen/i18n` and that's it! /// Localization for "global" English @@ -98,7 +98,7 @@ Is the client up to date?"#, Before you dive into the fun, please keep a few things in mind: -- This is a very early alpha. Expect bugs, extremely unfinished gameplay, unpolished mechanics, and missing features. +- This is a very early alpha. Expect bugs, extremely unfinished gameplay, unpolished mechanics, and missing features. - If you have constructive feedback or bug reports, you can contact us via Reddit, GitLab, or our community Discord server. - Veloren is licensed under the GPL 3 open-source licence. That means you're free to play, modify, and redistribute the game however you wish (provided derived work is also under GPL 3). @@ -143,7 +143,7 @@ https://account.veloren.net."#, "hud.show_tips": "Show Tips", "hud.quests": "Quests", "hud.you_died": "You Died", - + "hud.press_key_to_show_keybindings_fmt": "Press {key} to show keybindings", "hud.press_key_to_show_debug_info_fmt": "Press {key} to show debug info", "hud.press_key_to_toggle_keybindings_fmt": "Press {key} to toogle keybindings", @@ -193,8 +193,15 @@ Enjoy your stay in the World of Veloren."#, // Inventory "hud.bag.inventory": "'s Inventory", - "hud.bag.stats": "'s Stats", - "hud.bag.exp": "Exp", + "hud.bag.stats_title": "'s Stats", + "hud.bag.exp": "Exp", + "hud.bag.armor": "Armor", + "hud.bag.stats": "Stats", + + // Map and Questlog + "hud.map.map_title": "Map", + "hud.map.qlog_title": "Quests", + // Settings "hud.settings.general": "General", "hud.settings.none": "None", @@ -318,7 +325,7 @@ Chat commands: /alias [Name] - Change your Chat Name /tp [Name] - Teleports you to another player -/jump - Offset your position +/jump - Offset your position /goto - Teleport to a position /kill - Kill yourself /pig - Spawn pig NPC @@ -374,7 +381,7 @@ Willpower /// Start character window section - + /// Start Escape Menu Section "esc_menu.logout": "Logout", diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 0e8219f1ba..204d0f0873 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -15,7 +15,7 @@ use conrod_core::{ widget::{self, Button, Image, Rectangle, Text}, widget_ids, Color, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon, }; -//use const_tweaker::tweak; +// widget_ids! { pub struct Ids { @@ -150,8 +150,7 @@ pub enum Event { Close, } /* -#[tweak(min = -100.0, max = 20.0, step = 1.0)] -const END_X: f64 = 10.0; + */ impl<'a> Widget for Bag<'a> { type Event = Option; @@ -498,7 +497,7 @@ impl<'a> Widget for Bag<'a> { Text::new(&format!( "{}{}", &self.stats.name, - &self.localized_strings.get("hud.bag.stats") + &self.localized_strings.get("hud.bag.stats_title") )) .mid_top_with_margin_on(state.ids.bg_frame, 9.0) .font_id(self.fonts.cyri.conrod_id) @@ -508,7 +507,7 @@ impl<'a> Widget for Bag<'a> { Text::new(&format!( "{}{}", &self.stats.name, - &self.localized_strings.get("hud.bag.stats") + &self.localized_strings.get("hud.bag.stats_title") )) .top_left_with_margins_on(state.ids.inventory_title_bg, 2.0, 2.0) .font_id(self.fonts.cyri.conrod_id) @@ -749,7 +748,11 @@ impl<'a> Widget for Bag<'a> { .mid_top_with_margin_on(state.ids.bg, 435.0) .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) - .label(if self.show.stats { "Armor" } else { "Stats" }) + .label(if self.show.stats { + &self.localized_strings.get("hud.bag.armor") + } else { + &self.localized_strings.get("hud.bag.stats") + }) .label_y(conrod_core::position::Relative::Scalar(1.0)) .label_color(TEXT_COLOR) .label_font_size(self.fonts.cyri.scale(12)) diff --git a/voxygen/src/hud/esc_menu.rs b/voxygen/src/hud/esc_menu.rs index a1d547107f..230d23b2df 100644 --- a/voxygen/src/hud/esc_menu.rs +++ b/voxygen/src/hud/esc_menu.rs @@ -83,12 +83,6 @@ impl<'a> Widget for EscMenu<'a> { .mid_top_with_margin_on(state.ids.esc_bg, -34.0) .set(state.ids.banner_top, ui); - /*Image::new(self.imgs.fireplace) - .w_h(210.0, 60.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.8))) - .mid_top_with_margin_on(state.ids.esc_bg, 5.0) - .set(state.ids.fireplace, ui);*/ - // Resume if Button::image(self.imgs.button) .mid_bottom_with_margin_on(state.ids.banner_top, -60.0) diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 1bf0638ecc..b62913d453 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -9,12 +9,11 @@ rotation_image_ids! { tt_side: "voxygen/element/frames/tt_test_edge", tt_corner: "voxygen/element/frames/tt_test_corner_tr", + + indicator_mmap_small: "voxygen.element.buttons.indicator_mmap_small", ////////////////////////////////////////////////////////////////////////////////////////////////////// - - // Minimap - indicator_mmap_small: "voxygen.element.buttons.indicator_mmap_small", } } @@ -79,29 +78,16 @@ image_ids! { slider_indicator: "voxygen.element.slider.indicator", esc_frame: "voxygen.element.frames.esc_menu", - // Map Window - map_frame_l: "voxygen.element.frames.map_l", - map_frame_r: "voxygen.element.frames.map_r", - map_frame_bl: "voxygen.element.frames.map_bl", - map_frame_br: "voxygen.element.frames.map_br", - pos_indicator: "voxygen.element.buttons.qlog", - // Chat-Arrows chat_arrow: "voxygen.element.buttons.arrow_down", chat_arrow_mo: "voxygen.element.buttons.arrow_down_hover", chat_arrow_press: "voxygen.element.buttons.arrow_down_press", - // Crosshair - crosshair_inner: "voxygen.element.misc_bg.crosshair_inner", - //////////////////////////////////////////////////////////////////////// - // Esc-Menu - fireplace: "voxygen.element.misc_bg.fireplace", - // Skill Icons bow_m2: "voxygen.element.icons.bow_m2", @@ -109,21 +95,12 @@ image_ids! { flower: "voxygen.element.icons.item_flower", grass: "voxygen.element.icons.item_grass", + // Minimap + // Map - indicator_mmap: "voxygen.element.buttons.indicator_mmap", indicator_mmap_2: "voxygen.element.buttons.indicator_mmap_2", indicator_mmap_3: "voxygen.element.buttons.indicator_mmap_3", - // Crosshair - crosshair_outer_round: "voxygen.element.misc_bg.crosshair_outer_1", - crosshair_outer_round_edges: "voxygen.element.misc_bg.crosshair_outer_2", - crosshair_outer_edges: "voxygen.element.misc_bg.crosshair_outer_3", - - crosshair_bg: "voxygen.element.misc_bg.crosshair_bg", - crosshair_bg_hover: "voxygen.element.misc_bg.crosshair_bg_hover", - crosshair_bg_press: "voxygen.element.misc_bg.crosshair_bg_press", - crosshair_bg_pressed: "voxygen.element.misc_bg.crosshair_bg_pressed", - // Checkboxes and Radio buttons check: "voxygen.element.buttons.radio.inactive", check_mo: "voxygen.element.buttons.radio.inactive_hover", @@ -157,20 +134,10 @@ image_ids! { spellbook_hover: "voxygen.element.buttons.spellbook_hover", spellbook_press: "voxygen.element.buttons.spellbook_press", - character_button: "voxygen.element.buttons.character", - character_hover: "voxygen.element.buttons.character_hover", - character_press: "voxygen.element.buttons.character_press", - - qlog_button: "voxygen.element.buttons.qlog", - qlog_hover: "voxygen.element.buttons.qlog_hover", - qlog_press: "voxygen.element.buttons.qlog_press", - // Charwindow xp_charwindow: "voxygen.element.frames.xp_charwindow", divider: "voxygen.element.frames.divider_charwindow", - // Close button - // Items potion_red: "voxygen.voxel.object.potion_red", @@ -180,12 +147,10 @@ image_ids! { key_gold: "voxygen.voxel.object.key_gold", - - - ////////////////////////////////////////////////////////////////////////////////////////////////////// + // Skill Icons twohsword_m1: "voxygen.element.icons.2hsword_m1", twohsword_m2: "voxygen.element.icons.2hsword_m2", @@ -201,13 +166,28 @@ image_ids! { flyingrod_m2: "voxygen.element.icons.debug_wand_m2", charge: "voxygen.element.icons.skill_charge_3", - // Other Icons + // Other Icons/Art skull: "voxygen.element.icons.skull", skull_2: "voxygen.element.icons.skull_2", + fireplace: "voxygen.element.misc_bg.fireplace", + + // Crosshair + crosshair_inner: "voxygen.element.misc_bg.crosshair_inner", + + crosshair_outer_round: "voxygen.element.misc_bg.crosshair_outer_1", + crosshair_outer_round_edges: "voxygen.element.misc_bg.crosshair_outer_2", + crosshair_outer_edges: "voxygen.element.misc_bg.crosshair_outer_3", + + crosshair_bg: "voxygen.element.misc_bg.crosshair_bg", + crosshair_bg_hover: "voxygen.element.misc_bg.crosshair_bg_hover", + crosshair_bg_press: "voxygen.element.misc_bg.crosshair_bg_press", + crosshair_bg_pressed: "voxygen.element.misc_bg.crosshair_bg_pressed", // Map map_bg: "voxygen.element.misc_bg.map_bg", map_frame: "voxygen.element.misc_bg.map_frame", + map_frame_art: "voxygen.element.misc_bg.map_frame_art", + indicator_mmap: "voxygen.element.buttons.indicator_mmap", // MiniMap mmap_frame: "voxygen.element.frames.mmap", @@ -291,8 +271,6 @@ image_ids! { enemy_health_bg: "voxygen.element.frames.enemybar_bg", // Enemy Bar Content: enemy_bar: "voxygen.element.skillbar.enemy_bar_content", - // Spell Book Window - spellbook_icon: "voxygen.element.icons.spellbook", // Bag bag: "voxygen.element.buttons.bag.closed", bag_hover: "voxygen.element.buttons.bag.closed_hover", @@ -312,13 +290,6 @@ image_ids! { progress_frame: "voxygen.element.frames.progress_bar", progress: "voxygen.element.misc_bg.progress", - // Quest-Log Window - questlog_icon: "voxygen.element.icons.questlog", - - - // Social Window - social_icon: "voxygen.element.icons.social", - nothing: (), } diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index 0b237c72ec..fcb29999d7 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -1,32 +1,40 @@ use super::{ img_ids::{Imgs, ImgsRot}, - Show, TEXT_COLOR, + Show, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, +}; +use crate::{ + i18n::VoxygenLocalization, + ui::{fonts::ConrodVoxygenFonts, img_ids}, }; -use crate::ui::{fonts::ConrodVoxygenFonts, img_ids}; use client::{self, Client}; use common::{comp, terrain::TerrainChunkSize, vol::RectVolSize}; use conrod_core::{ color, widget::{self, Button, Image, Rectangle, Text}, - widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, + widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon, }; +//use const_tweaker::tweak; use specs::WorldExt; use vek::*; +/*#[tweak(min = 0.0, max = 40.0, step = 1.0)] +const X: f64 = 10.0; +#[tweak(min = 0.0, max = 40.0, step = 1.0)] +const Y: f64 = 10.0;*/ widget_ids! { struct Ids { - map_frame, - map_bg, - map_icon, - map_close, - map_title, - map_frame_l, - map_frame_r, - map_frame_bl, - map_frame_br, + frame, + bg, + icon, + close, + title, + map_align, + qlog_align, location_name, indicator, grid, + map_title, + qlog_title, } } @@ -41,7 +49,7 @@ pub struct Map<'a> { #[conrod(common_builder)] common: widget::CommonBuilder, _pulse: f32, - velocity: f32, + localized_strings: &'a std::sync::Arc, } impl<'a> Map<'a> { pub fn new( @@ -52,7 +60,7 @@ impl<'a> Map<'a> { world_map: &'a (img_ids::Rotations, Vec2), fonts: &'a ConrodVoxygenFonts, pulse: f32, - velocity: f32, + localized_strings: &'a std::sync::Arc, ) -> Self { Self { _show: show, @@ -63,7 +71,7 @@ impl<'a> Map<'a> { fonts, common: widget::CommonBuilder::default(), _pulse: pulse, - velocity, + localized_strings, } } } @@ -91,87 +99,96 @@ impl<'a> Widget for Map<'a> { fn update(self, args: widget::UpdateArgs) -> Self::Event { let widget::UpdateArgs { state, ui, .. } = args; - // Set map transparency to 0.5 when player is moving - let mut fade = 1.0; - if self.velocity > 2.5 { - fade = 0.7 - }; - - // BG - Rectangle::fill_with([824.0, 976.0], color::TRANSPARENT) - .mid_top_with_margin_on(ui.window, 15.0) - .scroll_kids() - .scroll_kids_vertically() - .set(state.ids.map_bg, ui); // Frame - Image::new(self.imgs.map_frame_l) - .top_left_with_margins_on(state.ids.map_bg, 0.0, 0.0) - .w_h(412.0, 488.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade))) - .set(state.ids.map_frame_l, ui); - Image::new(self.imgs.map_frame_r) - .right_from(state.ids.map_frame_l, 0.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade))) - .w_h(412.0, 488.0) - .set(state.ids.map_frame_r, ui); - Image::new(self.imgs.map_frame_br) - .down_from(state.ids.map_frame_r, 0.0) - .w_h(412.0, 488.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade))) - .set(state.ids.map_frame_br, ui); - Image::new(self.imgs.map_frame_bl) - .down_from(state.ids.map_frame_l, 0.0) - .w_h(412.0, 488.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade))) - .set(state.ids.map_frame_bl, ui); + Image::new(self.imgs.map_bg) + .w_h(1052.0, 886.0) + .mid_top_with_margin_on(ui.window, 5.0) + .color(Some(UI_MAIN)) + .set(state.ids.bg, ui); + + Image::new(self.imgs.map_frame) + .w_h(1052.0, 886.0) + .middle_of(state.ids.bg) + .color(Some(UI_HIGHLIGHT_0)) + .set(state.ids.frame, ui); + + // Map Content Alignment + Rectangle::fill_with([814.0, 834.0], color::TRANSPARENT) + .top_right_with_margins_on(state.ids.frame, 46.0, 2.0) + .set(state.ids.map_align, ui); + + // Questlog Content Alignment + Rectangle::fill_with([232.0, 814.0], color::TRANSPARENT) + .top_left_with_margins_on(state.ids.frame, 44.0, 2.0) + .set(state.ids.qlog_align, ui); // Icon Image::new(self.imgs.map_icon) - .w_h(224.0 / 3.0, 224.0 / 3.0) - .top_left_with_margins_on(state.ids.map_frame, -10.0, -10.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade))) - .set(state.ids.map_icon, ui); + .w_h(30.0, 30.0) + .top_left_with_margins_on(state.ids.frame, 6.0, 8.0) + .set(state.ids.icon, ui); + + // Map Title + Text::new(&self.localized_strings.get("hud.map.map_title")) + .mid_top_with_margin_on(state.ids.frame, 3.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(29)) + .color(TEXT_COLOR) + .set(state.ids.map_title, ui); + + // Questlog Title + Text::new(&format!( + "{}", + &self.localized_strings.get("hud.map.qlog_title") + )) + .mid_top_with_margin_on(state.ids.qlog_align, 6.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(21)) + .color(TEXT_COLOR) + .set(state.ids.qlog_title, ui); // X-Button if Button::image(self.imgs.close_button) - .w_h(28.0, 28.0) - .hover_image(self.imgs.close_button_hover) - .press_image(self.imgs.close_button_press) - .color(Color::Rgba(1.0, 1.0, 1.0, fade - 0.5)) - .top_right_with_margins_on(state.ids.map_frame_r, 0.0, 0.0) - .set(state.ids.map_close, ui) + .w_h(24.0, 25.0) + .hover_image(self.imgs.close_btn_hover) + .press_image(self.imgs.close_btn_press) + .top_right_with_margins_on(state.ids.frame, 0.0, 0.0) + .set(state.ids.close, ui) .was_clicked() { return Some(Event::Close); } // Location Name - match self.client.current_chunk() { + /*match self.client.current_chunk() { Some(chunk) => Text::new(chunk.meta().name()) - .mid_top_with_margin_on(state.ids.map_bg, 55.0) + .mid_top_with_margin_on(state.ids.bg, 55.0) .font_size(self.fonts.alkhemi.scale(60)) .color(TEXT_COLOR) .font_id(self.fonts.alkhemi.conrod_id) - .parent(state.ids.map_frame_r) + .parent(state.ids.frame) .set(state.ids.location_name, ui), None => Text::new(" ") - .mid_top_with_margin_on(state.ids.map_bg, 3.0) + .mid_top_with_margin_on(state.ids.bg, 3.0) .font_size(self.fonts.alkhemi.scale(40)) .font_id(self.fonts.alkhemi.conrod_id) .color(TEXT_COLOR) .set(state.ids.location_name, ui), - } - + }*/ + Image::new(self.imgs.map_frame_art) + .mid_top_with_margin_on(state.ids.map_align, 5.0) + .w_h(765.0, 765.0) + .parent(state.ids.bg) + .set(state.ids.grid, ui); // Map Image let (world_map, worldsize) = self.world_map; let worldsize = worldsize.map2(TerrainChunkSize::RECT_SIZE, |e, f| e as f64 * f as f64); Image::new(world_map.none) - .middle_of(state.ids.map_bg) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade + 0.5))) - .w_h(700.0, 700.0) - .parent(state.ids.map_bg) + .mid_top_with_margin_on(state.ids.map_align, 10.0) + .w_h(760.0, 760.0) + .parent(state.ids.bg) .set(state.ids.grid, ui); // Coordinates let player_pos = self @@ -182,8 +199,8 @@ impl<'a> Widget for Map<'a> { .get(self.client.entity()) .map_or(Vec3::zero(), |pos| pos.0); - let x = player_pos.x as f64 / worldsize.x * 700.0; - let y = player_pos.y as f64 / worldsize.y * 700.0; + let x = player_pos.x as f64 / worldsize.x * 760.0; + let y = player_pos.y as f64 / worldsize.y * 760.0; let indic_scale = 0.6; Image::new(self.rot_imgs.indicator_mmap_small.target_north) .bottom_left_with_margins_on( @@ -192,7 +209,7 @@ impl<'a> Widget for Map<'a> { x - 32.0 * indic_scale / 2.0, ) .w_h(32.0 * indic_scale, 37.0 * indic_scale) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 1.0))) + .color(Some(UI_HIGHLIGHT_0)) .floating(true) .parent(ui.window) .set(state.ids.indicator, ui); diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index e9fe2b46fd..484fd6a1a1 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -214,7 +214,7 @@ impl<'a> Widget for MiniMap<'a> { Image::new(self.rot_imgs.indicator_mmap_small.none) .middle_of(state.ids.grid) .w_h(32.0 * ind_scale, 37.0 * ind_scale) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, 1.0))) + .color(Some(UI_HIGHLIGHT_0)) .floating(true) .parent(ui.window) .set(state.ids.indicator, ui); diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 11054f16a3..ea98754167 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -847,7 +847,7 @@ impl Hud { .color(if floater.hp_change < 0 { Color::Rgba(0.0, 0.0, 0.0, fade) } else { - Color::Rgba(0.1, 1.0, 0.1, 0.0) + Color::Rgba(0.0, 0.0, 0.0, 1.0) }) .x_y(0.0, y - 3.0) .position_ingame(ingame_pos) @@ -859,7 +859,7 @@ impl Hud { .color(if floater.hp_change < 0 { Color::Rgba(font_col.r, font_col.g, font_col.b, fade) } else { - Color::Rgba(0.1, 1.0, 0.1, 0.0) + Color::Rgba(0.1, 1.0, 0.1, 1.0) }) .position_ingame(ingame_pos) .set(sct_id, ui_widgets); @@ -1858,7 +1858,7 @@ impl Hud { &self.world_map, &self.fonts, self.pulse, - self.velocity, + &self.voxygen_i18n, ) .set(self.ids.map, ui_widgets) { From 1c3d1d260c5a55247a8a7b3f89eec1f67b2fa2fe Mon Sep 17 00:00:00 2001 From: jshipsey Date: Thu, 26 Mar 2020 23:51:55 -0400 Subject: [PATCH 261/326] small animation tweaks --- .../anim/character/{attack.rs => alpha.rs} | 18 +-- voxygen/src/anim/character/beta.rs | 132 ++++++++++++++++++ voxygen/src/anim/character/mod.rs | 4 +- voxygen/src/anim/character/shoot.rs | 2 +- voxygen/src/anim/character/sit.rs | 2 +- voxygen/src/anim/character/swim.rs | 12 +- voxygen/src/scene/figure/mod.rs | 10 +- 7 files changed, 157 insertions(+), 23 deletions(-) rename voxygen/src/anim/character/{attack.rs => alpha.rs} (98%) create mode 100644 voxygen/src/anim/character/beta.rs diff --git a/voxygen/src/anim/character/attack.rs b/voxygen/src/anim/character/alpha.rs similarity index 98% rename from voxygen/src/anim/character/attack.rs rename to voxygen/src/anim/character/alpha.rs index ca41ed49b0..e2a0ac9a0d 100644 --- a/voxygen/src/anim/character/attack.rs +++ b/voxygen/src/anim/character/alpha.rs @@ -3,12 +3,9 @@ use common::comp::item::ToolKind; use std::f32::consts::PI; use vek::*; -pub struct Input { - pub attack: bool, -} -pub struct AttackAnimation; +pub struct AlphaAnimation; -impl Animation for AttackAnimation { +impl Animation for AlphaAnimation { type Dependency = (Option, f32, f64); type Skeleton = CharacterSkeleton; @@ -25,9 +22,12 @@ impl Animation for AttackAnimation { let lab = 1.0; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 13.0).sin()).powf(2.0 as f32))) + / (1.1 + + 3.9 + * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 13.0).sin()); + * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()); + let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); @@ -86,8 +86,8 @@ impl Animation for AttackAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); - next.control.ori = Quaternion::rotation_x(-1.2) - * Quaternion::rotation_y(slow * 1.5) + next.control.ori = Quaternion::rotation_x(-1.4) + * Quaternion::rotation_y(slow * 1.5 + 0.7) * Quaternion::rotation_z(1.4 + slow * 0.5); next.control.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, foot * 3.0 + slow * -5.0, 8.0); diff --git a/voxygen/src/anim/character/beta.rs b/voxygen/src/anim/character/beta.rs new file mode 100644 index 0000000000..ffeba742a5 --- /dev/null +++ b/voxygen/src/anim/character/beta.rs @@ -0,0 +1,132 @@ +use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; +use common::comp::item::ToolKind; +use std::f32::consts::PI; +use vek::*; + +pub struct BetaAnimation; + +impl Animation for BetaAnimation { + type Dependency = (Option, f32, f64); + type Skeleton = CharacterSkeleton; + + fn update_skeleton( + skeleton: &Self::Skeleton, + (active_tool_kind, velocity, _global_time): Self::Dependency, + anim_time: f64, + rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + *rate = 1.0; + let mut next = (*skeleton).clone(); + + let lab = 1.0; + + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()); + + let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); + let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); + let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); + let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin(); + + let slow = (((5.0) + / (0.6 + 4.4 * ((anim_time as f32 * lab as f32 * 11.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 11.0).sin()); + let slower = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0).sin()); + let slowax = (((5.0) + / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()); + + match active_tool_kind { + //TODO: Inventory + Some(ToolKind::Sword(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 14.0, + ); + next.head.ori = Quaternion::rotation_z(slow * 0.08) + * Quaternion::rotation_x(0.0 + slow * 0.08) + * Quaternion::rotation_y(slow * -0.08); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(slow * -0.2) + * Quaternion::rotation_x(0.0 + slow * -0.2) + * Quaternion::rotation_y(slow * 0.2); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = next.chest.ori * -0.2; + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = next.chest.ori * -0.15; + next.shorts.scale = Vec3::one(); + + next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); + next.control.ori = Quaternion::rotation_x(-1.4) + * Quaternion::rotation_y(slow * 1.5 + 0.7) + * Quaternion::rotation_z(1.4 + slow * 0.5); + next.control.scale = Vec3::one(); + next.l_foot.offset = Vec3::new(-3.4, foot * 3.0 + slow * -5.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -0.6); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, foot * -3.0 + slow * 5.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 0.6); + next.r_foot.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + }, + _ => {}, + } + + next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.1; + + next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.1; + + next.glider.offset = Vec3::new(0.0, 5.0, 0.0); + next.glider.ori = Quaternion::rotation_y(0.0); + next.glider.scale = Vec3::one() * 0.0; + + next.lantern.offset = Vec3::new(0.0, 0.0, 0.0); + next.lantern.ori = Quaternion::rotation_x(0.0); + next.lantern.scale = Vec3::one() * 0.0; + + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); + next + } +} diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index b441d4a937..122f427312 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -1,4 +1,4 @@ -pub mod attack; +pub mod alpha; pub mod block; pub mod blockidle; pub mod charge; @@ -18,7 +18,7 @@ pub mod wield; // Reexports pub use self::{ - attack::AttackAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, + alpha::AlphaAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, charge::ChargeAnimation, climb::ClimbAnimation, equip::EquipAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, diff --git a/voxygen/src/anim/character/shoot.rs b/voxygen/src/anim/character/shoot.rs index 2e4bfdd978..8cd71eb4be 100644 --- a/voxygen/src/anim/character/shoot.rs +++ b/voxygen/src/anim/character/shoot.rs @@ -103,7 +103,7 @@ impl Animation for ShootAnimation { * Quaternion::rotation_z(-0.6); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.offset = Vec3::new(-9.0, 6.0, 8.0); next.control.ori = Quaternion::rotation_x((sloweralt * 0.4).max(0.4)) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); diff --git a/voxygen/src/anim/character/sit.rs b/voxygen/src/anim/character/sit.rs index 0a4cad45ae..5027adf884 100644 --- a/voxygen/src/anim/character/sit.rs +++ b/voxygen/src/anim/character/sit.rs @@ -39,7 +39,7 @@ impl Animation for SitAnimation { ); next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - wave_stop * -3.6 + skeleton_attr.neck_forward, + -3.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 14.0 + wave_slow * 0.1 + wave_stop * -0.8, ); next.head.ori = diff --git a/voxygen/src/anim/character/swim.rs b/voxygen/src/anim/character/swim.rs index d5fdec6df5..9b5e1193f8 100644 --- a/voxygen/src/anim/character/swim.rs +++ b/voxygen/src/anim/character/swim.rs @@ -23,13 +23,15 @@ impl Animation for SwimAnimation { let lab = 1.0; - let short = (anim_time as f32 * lab as f32 * 2.0).sin(); + let short = (anim_time as f32 * lab as f32 * 2.0 * speed / 5.0).sin(); - let shortalt = (anim_time as f32 * lab as f32 * 2.0 + PI / 2.0).sin(); + let shortalt = (anim_time as f32 * lab as f32 * 2.0 * speed / 5.0 + PI / 2.0).sin(); - let foot = (anim_time as f32 * lab as f32 * 2.0).sin(); + let foot = (anim_time as f32 * lab as f32 * 2.0 * speed / 5.0).sin(); - let wave_stop = (anim_time as f32 * 3.0).min(PI / 2.0 / 2.0).sin(); + let wave_stop = (anim_time as f32 * 3.0 * speed / 5.0) + .min(PI / 2.0 / 2.0) + .sin(); let head_look = Vec2::new( ((global_time + anim_time) as f32 / 18.0) @@ -115,7 +117,7 @@ impl Animation for SwimAnimation { next.torso.offset = Vec3::new(0.0, -0.3 + shortalt * -0.065, 0.4) * skeleton_attr.scaler; next.torso.ori = - Quaternion::rotation_x(speed * -0.157 * wave_stop * 1.6) * Quaternion::rotation_y(0.0); + Quaternion::rotation_x(speed * -0.190 * wave_stop * 1.6) * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.control.offset = Vec3::new(0.0, 0.0, 0.0); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index c0ae0e3530..322620727a 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -472,7 +472,7 @@ impl FigureMgr { ) }, CharacterState::BasicMelee(_) => { - anim::character::AttackAnimation::update_skeleton( + anim::character::AlphaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, @@ -490,7 +490,7 @@ impl FigureMgr { ) }, CharacterState::Boost(_) => { - anim::character::AttackAnimation::update_skeleton( + anim::character::AlphaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, @@ -509,7 +509,7 @@ impl FigureMgr { }, CharacterState::TripleStrike(s) => match s.stage { triple_strike::Stage::First => { - anim::character::AttackAnimation::update_skeleton( + anim::character::AlphaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, @@ -527,7 +527,7 @@ impl FigureMgr { ) }, triple_strike::Stage::Third => { - anim::character::AttackAnimation::update_skeleton( + anim::character::AlphaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, @@ -537,7 +537,7 @@ impl FigureMgr { }, }, CharacterState::TimedCombo(s) => match s.stage { - 0 | 2 => anim::character::AttackAnimation::update_skeleton( + 0 | 2 => anim::character::AlphaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, From 0ffff86e259c8132cc8671b895757b35e30bbc8b Mon Sep 17 00:00:00 2001 From: jshipsey Date: Fri, 27 Mar 2020 01:57:30 -0400 Subject: [PATCH 262/326] third attack for triple strike --- voxygen/src/anim/character/alpha.rs | 14 +++--- voxygen/src/anim/character/beta.rs | 71 ++++++++++++++-------------- voxygen/src/anim/character/charge.rs | 4 +- voxygen/src/anim/character/mod.rs | 11 +++-- voxygen/src/anim/character/run.rs | 12 ++--- voxygen/src/anim/character/spin.rs | 12 ++--- voxygen/src/anim/character/wield.rs | 6 +-- voxygen/src/scene/figure/mod.rs | 2 +- 8 files changed, 67 insertions(+), 65 deletions(-) diff --git a/voxygen/src/anim/character/alpha.rs b/voxygen/src/anim/character/alpha.rs index e2a0ac9a0d..bc1a7ca73d 100644 --- a/voxygen/src/anim/character/alpha.rs +++ b/voxygen/src/anim/character/alpha.rs @@ -22,8 +22,8 @@ impl Animation for AlphaAnimation { let lab = 1.0; let foot = (((5.0) - / (1.1 - + 3.9 + / (0.2 + + 4.8 * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()); @@ -91,11 +91,13 @@ impl Animation for AlphaAnimation { * Quaternion::rotation_z(1.4 + slow * 0.5); next.control.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, foot * 3.0 + slow * -5.0, 8.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -0.6); + next.l_foot.ori = + Quaternion::rotation_x(foot * -0.6) * Quaternion::rotation_y(foot * 0.2); next.l_foot.scale = Vec3::one(); next.r_foot.offset = Vec3::new(3.4, foot * -3.0 + slow * 5.0, 8.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 0.6); + next.r_foot.ori = + Quaternion::rotation_x(foot * 0.6) * Quaternion::rotation_y(foot * -0.2); next.r_foot.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_z(0.0) @@ -226,8 +228,8 @@ impl Animation for AlphaAnimation { next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; } - next.control.offset = Vec3::new(-6.0, 3.0, 8.0 + slower * 5.0); - next.control.ori = Quaternion::rotation_x(-0.2 + slower * 2.0) + next.control.offset = Vec3::new(-6.0, 3.0 + slower * 2.0, 8.0 + slower * 5.0); + next.control.ori = Quaternion::rotation_x(-0.2 + slower * 1.8) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(1.4 + 1.57); next.control.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/beta.rs b/voxygen/src/anim/character/beta.rs index ffeba742a5..0ae34b22a7 100644 --- a/voxygen/src/anim/character/beta.rs +++ b/voxygen/src/anim/character/beta.rs @@ -1,6 +1,5 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use common::comp::item::ToolKind; -use std::f32::consts::PI; use vek::*; pub struct BetaAnimation; @@ -11,7 +10,7 @@ impl Animation for BetaAnimation { fn update_skeleton( skeleton: &Self::Skeleton, - (active_tool_kind, velocity, _global_time): Self::Dependency, + (active_tool_kind, _velocity, _global_time): Self::Dependency, anim_time: f64, rate: &mut f32, skeleton_attr: &SkeletonAttr, @@ -21,28 +20,22 @@ impl Animation for BetaAnimation { let lab = 1.0; + let fast = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 28.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 28.0).sin()); + let footquick = (((5.0) + / (0.4 + 4.6 * ((anim_time as f32 * lab as f32 * 14.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 14.0).sin()); let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 14.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 1.3 * velocity).sin()); - - let accel_med = 1.0 - (anim_time as f32 * 16.0 * lab as f32).cos(); - let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); - let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); - let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin(); - + * ((anim_time as f32 * lab as f32 * 14.0).sin()); let slow = (((5.0) - / (0.6 + 4.4 * ((anim_time as f32 * lab as f32 * 11.0).sin()).powf(2.0 as f32))) + / (0.6 + 4.4 * ((anim_time as f32 * lab as f32 * 14.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 11.0).sin()); - let slower = (((5.0) - / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 4.0).sin()); - let slowax = (((5.0) - / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 4.0 + 1.9).cos()); + * ((anim_time as f32 * lab as f32 * 14.0).sin()); match active_tool_kind { //TODO: Inventory @@ -52,23 +45,27 @@ impl Animation for BetaAnimation { -2.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 14.0, ); - next.head.ori = Quaternion::rotation_z(slow * 0.08) - * Quaternion::rotation_x(0.0 + slow * 0.08) - * Quaternion::rotation_y(slow * -0.08); + next.head.ori = Quaternion::rotation_z(slow * -0.18) + * Quaternion::rotation_x(-0.1 + slow * -0.28) + * Quaternion::rotation_y(0.2 + slow * 0.18); next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(slow * -0.2) - * Quaternion::rotation_x(0.0 + slow * -0.2) - * Quaternion::rotation_y(slow * 0.2); + next.chest.offset = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(slow * 0.2) + * Quaternion::rotation_x(0.0 + slow * 0.2) + * Quaternion::rotation_y(slow * -0.1); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = next.chest.ori * -0.2; + next.belt.ori = Quaternion::rotation_z(slow * 0.1) + * Quaternion::rotation_x(0.0 + slow * 0.1) + * Quaternion::rotation_y(slow * -0.04); next.belt.scale = Vec3::one(); next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = next.chest.ori * -0.15; + next.shorts.ori = Quaternion::rotation_z(slow * 0.1) + * Quaternion::rotation_x(0.0 + slow * 0.1) + * Quaternion::rotation_y(slow * -0.05); next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); @@ -83,17 +80,19 @@ impl Animation for BetaAnimation { * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); + next.control.offset = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0); next.control.ori = Quaternion::rotation_x(-1.4) - * Quaternion::rotation_y(slow * 1.5 + 0.7) - * Quaternion::rotation_z(1.4 + slow * 0.5); + * Quaternion::rotation_y(slow * 2.0 + 0.7) + * Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6); next.control.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, foot * 3.0 + slow * -5.0, 8.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -0.6); + next.l_foot.offset = Vec3::new(-3.4, footquick * -9.5, 8.0); + next.l_foot.ori = Quaternion::rotation_x(footquick * 0.3) + * Quaternion::rotation_y(footquick * -0.6); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, foot * -3.0 + slow * 5.0, 8.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 0.6); + next.r_foot.offset = Vec3::new(3.4, footquick * 9.5, 8.0); + next.r_foot.ori = Quaternion::rotation_x(footquick * -0.3) + * Quaternion::rotation_y(footquick * 0.2); next.r_foot.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_z(0.0) diff --git a/voxygen/src/anim/character/charge.rs b/voxygen/src/anim/character/charge.rs index 01672ecfeb..c5d489bdf9 100644 --- a/voxygen/src/anim/character/charge.rs +++ b/voxygen/src/anim/character/charge.rs @@ -80,11 +80,11 @@ impl Animation for ChargeAnimation { * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(1.1 + slow * 0.2); next.control.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-1.4, foot * 3.0, 8.0); + next.l_foot.offset = Vec3::new(-1.4, foot * 3.0 + 2.0, 8.0); next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 3.0, 8.0); + next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 1.0, 8.0); next.r_foot.ori = Quaternion::rotation_x(foot * 0.4 - 0.8); next.r_foot.scale = Vec3::one(); }, diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index 122f427312..c506aafc88 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -1,4 +1,5 @@ pub mod alpha; +pub mod beta; pub mod block; pub mod blockidle; pub mod charge; @@ -18,11 +19,11 @@ pub mod wield; // Reexports pub use self::{ - alpha::AlphaAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, - charge::ChargeAnimation, climb::ClimbAnimation, equip::EquipAnimation, - gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, roll::RollAnimation, - run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, - stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation, + alpha::AlphaAnimation, beta::BetaAnimation, block::BlockAnimation, + blockidle::BlockIdleAnimation, charge::ChargeAnimation, climb::ClimbAnimation, + equip::EquipAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, + roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, + spin::SpinAnimation, stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation, }; use super::{Bone, Skeleton}; diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index 36a3fab7aa..27643664a1 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -82,7 +82,7 @@ impl Animation for RunAnimation { * Quaternion::rotation_x(head_look.y + 0.35); next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + short * 1.1); + next.chest.offset = Vec3::new(0.0, 0.0, 10.5 + short * 1.1); next.chest.ori = Quaternion::rotation_z(short * 0.3); next.chest.scale = Vec3::one(); @@ -97,7 +97,7 @@ impl Animation for RunAnimation { next.l_hand.offset = Vec3::new( -6.0 + wave_stop * -1.0, -0.25 + short * 3.0, - 4.0 + short * -1.5, + 5.0 + short * -1.5, ); next.l_hand.ori = Quaternion::rotation_x(0.8 + short * 1.2) * Quaternion::rotation_y(wave_stop * 0.1); @@ -106,17 +106,17 @@ impl Animation for RunAnimation { next.r_hand.offset = Vec3::new( 6.0 + wave_stop * 1.0, -0.25 + short * -3.0, - 4.0 + short * 1.5, + 5.0 + short * 1.5, ); next.r_hand.ori = Quaternion::rotation_x(0.8 + short * -1.2) * Quaternion::rotation_y(wave_stop * -0.1); next.r_hand.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 6.0); + next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 9.5); next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 6.0); + next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 9.5); next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); next.r_foot.scale = Vec3::one(); @@ -152,7 +152,7 @@ impl Animation for RunAnimation { next.lantern.ori = Quaternion::rotation_y(0.0); next.lantern.scale = Vec3::one() * 0.0; - next.torso.offset = Vec3::new(0.0, -0.3 + shortalt * -0.065, 0.4) * skeleton_attr.scaler; + next.torso.offset = Vec3::new(0.0, -0.3 + shortalt * -0.065, 0.0) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(wave_stop * speed * -0.05 + wave_stop * speed * -0.005) * Quaternion::rotation_y(tilt); diff --git a/voxygen/src/anim/character/spin.rs b/voxygen/src/anim/character/spin.rs index b9b19f7dcb..98f37e1c5e 100644 --- a/voxygen/src/anim/character/spin.rs +++ b/voxygen/src/anim/character/spin.rs @@ -56,16 +56,16 @@ impl Animation for SpinAnimation { next.control.scale = Vec3::one(); next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward + decel * -0.8, + -2.0 + skeleton_attr.neck_forward + spin * -0.8, skeleton_attr.neck_height + 14.0, ); - next.head.ori = Quaternion::rotation_z(decel * -0.25) - * Quaternion::rotation_x(0.0 + decel * -0.1) - * Quaternion::rotation_y(decel * 0.1); + next.head.ori = Quaternion::rotation_z(spin * -0.25) + * Quaternion::rotation_x(0.0 + spin * -0.1) + * Quaternion::rotation_y(spin * -0.2); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(decel * 0.1) - * Quaternion::rotation_x(0.0 + decel * 0.1) + next.chest.ori = Quaternion::rotation_z(spin * 0.1) + * Quaternion::rotation_x(0.0 + spin * 0.1) * Quaternion::rotation_y(decel * -0.2); next.chest.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 44f2d6ba74..05e61b67a2 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -237,15 +237,15 @@ impl Animation for WieldAnimation { next.shorts.ori = Quaternion::rotation_z(0.3); next.shorts.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0); + next.l_foot.offset = Vec3::new(-3.4, -2.5, 9.0); next.l_foot.ori = Quaternion::rotation_x(ultra_slow_cos * 0.035 - 0.2); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, 3.5, 8.0); + next.r_foot.offset = Vec3::new(3.4, 3.5, 9.0); next.r_foot.ori = Quaternion::rotation_x(ultra_slow * 0.035); next.r_foot.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 322620727a..4120c2da22 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -527,7 +527,7 @@ impl FigureMgr { ) }, triple_strike::Stage::Third => { - anim::character::AlphaAnimation::update_skeleton( + anim::character::BetaAnimation::update_skeleton( &target_base, (active_tool_kind, vel.0.magnitude(), time), state.state_time, From 3c36862f4213c977181cc80100381a63a205130b Mon Sep 17 00:00:00 2001 From: Marli Frost Date: Fri, 27 Mar 2020 10:09:21 +0000 Subject: [PATCH 263/326] fix: connect to LOCALHOST address in tests Windows doesn't allow us to connect to the Any (0.0.0.0) address, instead returning the WSAEADDRNOTAVAIL error code. https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2 --- common/src/net/post2.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/common/src/net/post2.rs b/common/src/net/post2.rs index ee9e7303e5..95307ac4bd 100644 --- a/common/src/net/post2.rs +++ b/common/src/net/post2.rs @@ -332,7 +332,8 @@ mod tests { #[test] fn connect() { - let (mut postoffice, sock) = create_postoffice::<(), ()>(0).unwrap(); + let (mut postoffice, bound) = create_postoffice::<(), ()>(0).unwrap(); + let sock = (std::net::Ipv4Addr::LOCALHOST, bound.port()); let _client0 = PostBox::<(), ()>::to(sock).unwrap(); let _client1 = PostBox::<(), ()>::to(sock).unwrap(); @@ -364,7 +365,8 @@ mod tests { #[test] fn send_recv() { - let (mut postoffice, sock) = create_postoffice::<(), i32>(2).unwrap(); + let (mut postoffice, bound) = create_postoffice::<(), i32>(2).unwrap(); + let sock = (std::net::Ipv4Addr::LOCALHOST, bound.port()); let test_msgs = vec![1, 1337, 42, -48]; let mut client = PostBox::::to(sock).unwrap(); @@ -386,7 +388,8 @@ mod tests { #[test] #[ignore] fn send_recv_huge() { - let (mut postoffice, sock) = create_postoffice::<(), Vec>(3).unwrap(); + let (mut postoffice, bound) = create_postoffice::<(), Vec>(3).unwrap(); + let sock = (std::net::Ipv4Addr::LOCALHOST, bound.port()); let test_msgs: Vec> = (0..5) .map(|i| (0..100000).map(|j| i * 2 + j).collect()) .collect(); @@ -410,7 +413,8 @@ mod tests { #[test] fn send_recv_both() { - let (mut postoffice, sock) = create_postoffice::(4).unwrap(); + let (mut postoffice, bound) = create_postoffice::(4).unwrap(); + let sock = (std::net::Ipv4Addr::LOCALHOST, bound.port()); let mut client = PostBox::::to(sock).unwrap(); loop_for(Duration::from_millis(250), || ()); let mut server = postoffice.new_postboxes().next().unwrap(); From c1647e93f1d5c762a733f8f4714d32ef7538ea4b Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 27 Mar 2020 07:03:26 -0700 Subject: [PATCH 264/326] make triple strike continue without hits again --- common/src/states/triple_strike.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 43bbcfb0ba..cbf5c7c817 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -51,7 +51,7 @@ impl CharacterBehavior for Data { .unwrap_or(Duration::default()); // If player stops holding input, don't go to the next stage - let mut should_transition = data.inputs.primary.is_pressed() && self.should_transition; + let should_transition = data.inputs.primary.is_pressed() && self.should_transition; if !self.initialized { update.vel.0 = Vec3::zero(); @@ -63,14 +63,9 @@ impl CharacterBehavior for Data { // Handle hit applied if let Some(attack) = data.attacking { - if attack.applied { - if attack.hit_count > 0 { - // Take energy on successful hit - update.energy.change_by(100, EnergySource::HitEnemy); - } else { - // Prevent transition on failure - should_transition = false; - } + if attack.applied && attack.hit_count > 0 { + // Take energy on successful hit + update.energy.change_by(100, EnergySource::HitEnemy); // Always remove component data.updater.remove::(data.entity); } From 7a3ad54628c4ff7f230521e16bb52c240a6bfa18 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 27 Mar 2020 15:27:42 +0100 Subject: [PATCH 265/326] asset cleanup --- assets/voxygen/voxel/figure/accessory/dwarf/warpaint-0.vox | 4 ++-- assets/voxygen/voxel/figure/accessory/elf/headband-0.vox | 4 ++-- .../voxygen/voxel/figure/accessory/orc/earring-female-0.vox | 4 ++-- assets/voxygen/voxel/figure/accessory/orc/earring-male-0.vox | 4 ++-- assets/voxygen/voxel/figure/accessory/orc/teeth-0.vox | 4 ++-- assets/voxygen/voxel/figure/accessory/orc/teeth-1.vox | 4 ++-- assets/voxygen/voxel/figure/accessory/orc/teeth-2.vox | 4 ++-- .../voxygen/voxel/figure/accessory/orc/warpaint-female-0.vox | 4 ++-- .../voxygen/voxel/figure/accessory/orc/warpaint-female-1.vox | 4 ++-- assets/voxygen/voxel/figure/accessory/orc/warpaint-male-0.vox | 4 ++-- assets/voxygen/voxel/figure/beard/danari/danari-0.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-0.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-1.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-10.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-11.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-12.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-13.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-14.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-15.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-16.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-17.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-18.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-19.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-2.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-20.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-3.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-4.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-5.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-6.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-7.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-8.vox | 4 ++-- assets/voxygen/voxel/figure/beard/dwarf/dwarf-9.vox | 4 ++-- assets/voxygen/voxel/figure/beard/human/human-0.vox | 4 ++-- assets/voxygen/voxel/figure/beard/human/human-1.vox | 4 ++-- assets/voxygen/voxel/figure/beard/human/human-2.vox | 4 ++-- assets/voxygen/voxel/figure/beard/orc/2.vox | 4 ++-- assets/voxygen/voxel/figure/body/chest.vox | 4 ++-- assets/voxygen/voxel/figure/body/chest_female.vox | 4 ++-- assets/voxygen/voxel/figure/body/chest_male.vox | 4 ++-- assets/voxygen/voxel/figure/body/foot.vox | 4 ++-- assets/voxygen/voxel/figure/body/hand.vox | 4 ++-- assets/voxygen/voxel/figure/body/pants_male.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/danari/female-0.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/danari/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/danari/male-1.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/dwarf/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/dwarf/male-1.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/elf/female-0.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/elf/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/human/female-0.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/human/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/human/male-1.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/orc/female-0.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/orc/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/undead/female-0.vox | 4 ++-- assets/voxygen/voxel/figure/eyes/undead/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/danari/female-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/danari/female-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/danari/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/danari/male-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/dwarf/bald.vox | 4 ++-- assets/voxygen/voxel/figure/hair/dwarf/female-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/dwarf/female-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/dwarf/female-2.vox | 4 ++-- assets/voxygen/voxel/figure/hair/dwarf/female-3.vox | 4 ++-- assets/voxygen/voxel/figure/hair/dwarf/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/dwarf/male-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-10.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-11.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-12.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-13.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-14.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-15.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-16.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-17.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-18.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-19.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-2.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-20.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-21.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-3.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-4.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-5.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-6.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-7.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-8.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/female-9.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/male-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/male-2.vox | 4 ++-- assets/voxygen/voxel/figure/hair/elf/male-3.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-10.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-11.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-12.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-13.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-14.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-15.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-16.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-17.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-18.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-19.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-2.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-3.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-4.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-5.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-6.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-7.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-8.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/female-9.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-10.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-11.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-12.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-13.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-14.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-15.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-16.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-17.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-18.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-19.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-2.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-20.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-3.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-4.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-5.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-6.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-7.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-8.vox | 4 ++-- assets/voxygen/voxel/figure/hair/human/male-9.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/female-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/female-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/female-2.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/female-3.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/female-4.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/female-5.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/female-6.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/male-0.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/male-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/male-2.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/male-3.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/male-4.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/male-5.vox | 4 ++-- assets/voxygen/voxel/figure/hair/orc/male-6.vox | 4 ++-- assets/voxygen/voxel/figure/hair/undead/female-1.vox | 4 ++-- assets/voxygen/voxel/figure/hair/undead/female-2.vox | 4 ++-- assets/voxygen/voxel/figure/hair/undead/female-3.vox | 4 ++-- assets/voxygen/voxel/figure/hair/undead/male-1.vox | 4 ++-- assets/voxygen/voxel/figure/head/danari/female.vox | 4 ++-- assets/voxygen/voxel/figure/head/danari/male.vox | 4 ++-- assets/voxygen/voxel/figure/head/dwarf/female.vox | 4 ++-- assets/voxygen/voxel/figure/head/dwarf/male.vox | 4 ++-- assets/voxygen/voxel/figure/head/elf/female.vox | 4 ++-- assets/voxygen/voxel/figure/head/elf/male.vox | 4 ++-- assets/voxygen/voxel/figure/head/human/female.vox | 4 ++-- assets/voxygen/voxel/figure/head/human/male.vox | 4 ++-- assets/voxygen/voxel/figure/head/orc/female.vox | 4 ++-- assets/voxygen/voxel/figure/head/orc/male.vox | 4 ++-- assets/voxygen/voxel/figure/head/undead/female.vox | 4 ++-- assets/voxygen/voxel/figure/head/undead/male.vox | 4 ++-- assets/voxygen/voxel/fixture/selection_bg.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/female/leg_l.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/female/leg_r.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/female/tail.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/female/torso.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/female/wing_l.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/female/wing_r.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/male/leg_l.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/male/leg_r.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/male/tail.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/male/torso.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/male/wing_l.vox | 4 ++-- assets/voxygen/voxel/npc/eagle/male/wing_r.vox | 4 ++-- assets/voxygen/voxel/npc/oger/hand-l.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/female/ears.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/female/foot_lf.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/female/foot_rf.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/female/head_lower.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/female/head_upper.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/female/jaw.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/female/tail.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/female/torso_back.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/female/torso_front.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/male/ears.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/male/foot_lf.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/male/foot_rf.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/male/head_lower.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/male/head_upper.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/male/jaw.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/male/tail.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/male/torso_back.vox | 4 ++-- assets/voxygen/voxel/npc/wolf/male/torso_front.vox | 4 ++-- assets/voxygen/voxel/object/anvil.vox | 4 ++-- assets/voxygen/voxel/object/bedroll.vox | 4 ++-- assets/voxygen/voxel/object/bench.vox | 4 ++-- assets/voxygen/voxel/object/bomb.vox | 4 ++-- assets/voxygen/voxel/object/campfire_lit.vox | 4 ++-- assets/voxygen/voxel/object/carpet.vox | 4 ++-- assets/voxygen/voxel/object/crate.vox | 4 ++-- assets/voxygen/voxel/object/door_spooky.vox | 4 ++-- assets/voxygen/voxel/object/gravestone.vox | 4 ++-- assets/voxygen/voxel/object/gravestone_2.vox | 4 ++-- assets/voxygen/voxel/object/key.vox | 4 ++-- assets/voxygen/voxel/object/key_gold.vox | 4 ++-- assets/voxygen/voxel/object/lantern_ground.vox | 4 ++-- assets/voxygen/voxel/object/lantern_ground_open.vox | 4 ++-- assets/voxygen/voxel/object/lantern_standing.vox | 4 ++-- assets/voxygen/voxel/object/lantern_standing_2.vox | 4 ++-- assets/voxygen/voxel/object/potion_blue.vox | 4 ++-- assets/voxygen/voxel/object/potion_green.vox | 4 ++-- assets/voxygen/voxel/object/potion_red.vox | 4 ++-- assets/voxygen/voxel/object/potion_turq.vox | 4 ++-- assets/voxygen/voxel/object/pouch.vox | 4 ++-- assets/voxygen/voxel/object/pumpkin.vox | 4 ++-- assets/voxygen/voxel/object/pumpkin_2.vox | 4 ++-- assets/voxygen/voxel/object/pumpkin_3.vox | 4 ++-- assets/voxygen/voxel/object/pumpkin_4.vox | 4 ++-- assets/voxygen/voxel/object/pumpkin_5.vox | 4 ++-- assets/voxygen/voxel/object/scarecrow.vox | 4 ++-- assets/voxygen/voxel/object/window_spooky.vox | 4 ++-- assets/voxygen/voxel/sprite/blueberry/1.vox | 4 ++-- assets/voxygen/voxel/sprite/blueberry/2.vox | 4 ++-- assets/voxygen/voxel/sprite/blueberry/3.vox | 4 ++-- assets/voxygen/voxel/sprite/blueberry/4.vox | 4 ++-- assets/voxygen/voxel/sprite/blueberry/5.vox | 4 ++-- assets/voxygen/voxel/sprite/blueberry/6.vox | 4 ++-- assets/voxygen/voxel/sprite/blueberry/7.vox | 4 ++-- assets/voxygen/voxel/sprite/blueberry/8.vox | 4 ++-- assets/voxygen/voxel/sprite/blueberry/9.vox | 4 ++-- assets/voxygen/voxel/sprite/cacti/cactus_round.vox | 4 ++-- assets/voxygen/voxel/sprite/dead_bush/1.vox | 4 ++-- assets/voxygen/voxel/sprite/dead_bush/2.vox | 4 ++-- assets/voxygen/voxel/sprite/dead_bush/3.vox | 4 ++-- assets/voxygen/voxel/sprite/dead_bush/4.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/1.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/10.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/11.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/12.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/2.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/3.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/4.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/5.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/6.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/7.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/8.vox | 4 ++-- assets/voxygen/voxel/sprite/ferns/9.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_blue_1.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_blue_2.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_blue_3.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_blue_4.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_blue_5.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_blue_6.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_blue_7.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_pink_1.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_pink_2.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_pink_3.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_pink_4.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_purple_1.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_red_1.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_red_2.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_red_3.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_white_1.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_white_2.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/flower_yellow_1.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/sunflower_1.vox | 4 ++-- assets/voxygen/voxel/sprite/flowers/sunflower_2.vox | 4 ++-- assets/voxygen/voxel/sprite/fruit/apple.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_long_1.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_long_2.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_long_3.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_long_4.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_long_5.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_long_6.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_long_7.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_med_1.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_med_2.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_med_3.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_med_4.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_med_5.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_short_1.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_short_2.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_short_3.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_short_4.vox | 4 ++-- assets/voxygen/voxel/sprite/grass/grass_short_5.vox | 4 ++-- assets/voxygen/voxel/sprite/leafy_plant/1.vox | 4 ++-- assets/voxygen/voxel/sprite/leafy_plant/10.vox | 4 ++-- assets/voxygen/voxel/sprite/leafy_plant/2.vox | 4 ++-- assets/voxygen/voxel/sprite/leafy_plant/3.vox | 4 ++-- assets/voxygen/voxel/sprite/leafy_plant/4.vox | 4 ++-- assets/voxygen/voxel/sprite/leafy_plant/5.vox | 4 ++-- assets/voxygen/voxel/sprite/leafy_plant/6.vox | 4 ++-- assets/voxygen/voxel/sprite/leafy_plant/7.vox | 4 ++-- assets/voxygen/voxel/sprite/leafy_plant/8.vox | 4 ++-- assets/voxygen/voxel/sprite/leafy_plant/9.vox | 4 ++-- assets/voxygen/voxel/sprite/lianas/liana-0.vox | 4 ++-- assets/voxygen/voxel/sprite/lianas/liana-1.vox | 4 ++-- assets/voxygen/voxel/sprite/lingonberry/1.vox | 4 ++-- assets/voxygen/voxel/sprite/lingonberry/2.vox | 4 ++-- assets/voxygen/voxel/sprite/lingonberry/3.vox | 4 ++-- assets/voxygen/voxel/sprite/mushrooms/mushroom-0.vox | 4 ++-- assets/voxygen/voxel/sprite/mushrooms/mushroom-10.vox | 4 ++-- assets/voxygen/voxel/sprite/mushrooms/mushroom-3.vox | 4 ++-- assets/voxygen/voxel/sprite/mushrooms/mushroom-4.vox | 4 ++-- assets/voxygen/voxel/sprite/mushrooms/mushroom-5.vox | 4 ++-- assets/voxygen/voxel/sprite/mushrooms/mushroom-6.vox | 4 ++-- assets/voxygen/voxel/sprite/mushrooms/mushroom-7.vox | 4 ++-- assets/voxygen/voxel/sprite/mushrooms/mushroom-8.vox | 4 ++-- assets/voxygen/voxel/sprite/mushrooms/mushroom-9.vox | 4 ++-- assets/voxygen/voxel/sprite/pumpkin/1.vox | 4 ++-- assets/voxygen/voxel/sprite/pumpkin/2.vox | 4 ++-- assets/voxygen/voxel/sprite/pumpkin/3.vox | 4 ++-- assets/voxygen/voxel/sprite/pumpkin/4.vox | 4 ++-- assets/voxygen/voxel/sprite/pumpkin/5.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_1.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_10.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_2.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_3.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_4.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_5.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_6.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_7.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_8.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_9.vox | 4 ++-- assets/voxygen/voxel/sprite/velorite/velorite_ore.vox | 4 ++-- assets/voxygen/voxel/sprite/welwitch/1.vox | 4 ++-- assets/world/module/human/door_big.vox | 4 ++-- assets/world/structure/dungeon/meso_sewer_temple.vox | 4 ++-- assets/world/structure/dungeon/ruins.vox | 4 ++-- assets/world/structure/dungeon/ruins_2.vox | 4 ++-- assets/world/structure/human/blacksmith.vox | 4 ++-- assets/world/structure/human/house_1.vox | 4 ++-- assets/world/structure/human/mage_tower.vox | 4 ++-- assets/world/structure/human/stables_1.vox | 4 ++-- assets/world/structure/human/town_hall.vox | 4 ++-- assets/world/structure/human/town_hall_spire.vox | 4 ++-- assets/world/structure/natural/tower-ruin.vox | 4 ++-- assets/world/structure/natural/witch-hut.vox | 4 ++-- assets/world/tree/acacia/1.vox | 4 ++-- assets/world/tree/acacia/2.vox | 4 ++-- assets/world/tree/acacia/3.vox | 4 ++-- assets/world/tree/acacia/4.vox | 4 ++-- assets/world/tree/acacia/5.vox | 4 ++-- assets/world/tree/acacia_2/1.vox | 4 ++-- assets/world/tree/acacia_2/2.vox | 4 ++-- assets/world/tree/acacia_2/3.vox | 4 ++-- assets/world/tree/acacia_2/4.vox | 4 ++-- assets/world/tree/acacia_2/5.vox | 4 ++-- assets/world/tree/acacia_savannah/1.vox | 4 ++-- assets/world/tree/acacia_savannah/2.vox | 4 ++-- assets/world/tree/acacia_savannah/3.vox | 4 ++-- assets/world/tree/acacia_savannah/4.vox | 4 ++-- assets/world/tree/acacia_savannah/5.vox | 4 ++-- assets/world/tree/birch/1.vox | 4 ++-- assets/world/tree/birch/10.vox | 4 ++-- assets/world/tree/birch/11.vox | 4 ++-- assets/world/tree/birch/12.vox | 4 ++-- assets/world/tree/birch/2.vox | 4 ++-- assets/world/tree/birch/3.vox | 4 ++-- assets/world/tree/birch/4.vox | 4 ++-- assets/world/tree/birch/5.vox | 4 ++-- assets/world/tree/birch/6.vox | 4 ++-- assets/world/tree/birch/7.vox | 4 ++-- assets/world/tree/birch/8.vox | 4 ++-- assets/world/tree/birch/9.vox | 4 ++-- assets/world/tree/desert_palm/1.vox | 4 ++-- assets/world/tree/desert_palm/10.vox | 4 ++-- assets/world/tree/desert_palm/2.vox | 4 ++-- assets/world/tree/desert_palm/3.vox | 4 ++-- assets/world/tree/desert_palm/4.vox | 4 ++-- assets/world/tree/desert_palm/5.vox | 4 ++-- assets/world/tree/desert_palm/6.vox | 4 ++-- assets/world/tree/desert_palm/7.vox | 4 ++-- assets/world/tree/desert_palm/8.vox | 4 ++-- assets/world/tree/desert_palm/9.vox | 4 ++-- assets/world/tree/desert_palm_old/1.vox | 4 ++-- assets/world/tree/desert_palm_old/10.vox | 4 ++-- assets/world/tree/desert_palm_old/2.vox | 4 ++-- assets/world/tree/desert_palm_old/3.vox | 4 ++-- assets/world/tree/desert_palm_old/4.vox | 4 ++-- assets/world/tree/desert_palm_old/5.vox | 4 ++-- assets/world/tree/desert_palm_old/6.vox | 4 ++-- assets/world/tree/desert_palm_old/7.vox | 4 ++-- assets/world/tree/desert_palm_old/8.vox | 4 ++-- assets/world/tree/desert_palm_old/9.vox | 4 ++-- assets/world/tree/fruit/1.vox | 4 ++-- assets/world/tree/fruit/2.vox | 4 ++-- assets/world/tree/fruit/3.vox | 4 ++-- assets/world/tree/fruit/4.vox | 4 ++-- assets/world/tree/fruit/5.vox | 4 ++-- assets/world/tree/fruit/6.vox | 4 ++-- assets/world/tree/mangroves/1.vox | 4 ++-- assets/world/tree/mangroves/2.vox | 4 ++-- assets/world/tree/mangroves/3.vox | 4 ++-- assets/world/tree/mangroves/4.vox | 4 ++-- assets/world/tree/mangroves/5.vox | 4 ++-- assets/world/tree/mangroves/6.vox | 4 ++-- assets/world/tree/mangroves/7.vox | 4 ++-- assets/world/tree/mangroves/8.vox | 4 ++-- assets/world/tree/oak_green/1.vox | 4 ++-- assets/world/tree/oak_green/2.vox | 4 ++-- assets/world/tree/oak_green/3.vox | 4 ++-- assets/world/tree/oak_green/4.vox | 4 ++-- assets/world/tree/oak_green/5.vox | 4 ++-- assets/world/tree/oak_green/6.vox | 4 ++-- assets/world/tree/oak_green/7.vox | 4 ++-- assets/world/tree/oak_green/8.vox | 4 ++-- assets/world/tree/oak_green/9.vox | 4 ++-- assets/world/tree/oak_stump/1.vox | 4 ++-- assets/world/tree/oak_stump/2.vox | 4 ++-- assets/world/tree/oak_stump/3.vox | 4 ++-- assets/world/tree/oak_stump/4.vox | 4 ++-- assets/world/tree/oak_stump/5.vox | 4 ++-- assets/world/tree/oak_stump/6.vox | 4 ++-- assets/world/tree/oak_stump/7.vox | 4 ++-- assets/world/tree/oak_stump/8.vox | 4 ++-- assets/world/tree/oak_stump/9.vox | 4 ++-- assets/world/tree/pine_green/1.vox | 4 ++-- assets/world/tree/pine_green/2.vox | 4 ++-- assets/world/tree/pine_green/3.vox | 4 ++-- assets/world/tree/pine_green/4.vox | 4 ++-- assets/world/tree/pine_green/5.vox | 4 ++-- assets/world/tree/pine_green/6.vox | 4 ++-- assets/world/tree/pine_green/7.vox | 4 ++-- assets/world/tree/pine_green/8.vox | 4 ++-- assets/world/tree/poplar/1.vox | 4 ++-- assets/world/tree/poplar/10.vox | 4 ++-- assets/world/tree/poplar/2.vox | 4 ++-- assets/world/tree/poplar/3.vox | 4 ++-- assets/world/tree/poplar/4.vox | 4 ++-- assets/world/tree/poplar/5.vox | 4 ++-- assets/world/tree/poplar/6.vox | 4 ++-- assets/world/tree/poplar/7.vox | 4 ++-- assets/world/tree/poplar/8.vox | 4 ++-- assets/world/tree/poplar/9.vox | 4 ++-- assets/world/tree/snow_pine/1.vox | 4 ++-- assets/world/tree/snow_pine/2.vox | 4 ++-- assets/world/tree/snow_pine/3.vox | 4 ++-- assets/world/tree/snow_pine/4.vox | 4 ++-- assets/world/tree/snow_pine/5.vox | 4 ++-- assets/world/tree/snow_pine/6.vox | 4 ++-- assets/world/tree/snow_pine/7.vox | 4 ++-- assets/world/tree/snow_pine/8.vox | 4 ++-- assets/world/tree/temperate_small/1.vox | 4 ++-- assets/world/tree/temperate_small/2.vox | 4 ++-- assets/world/tree/temperate_small/3.vox | 4 ++-- assets/world/tree/temperate_small/4.vox | 4 ++-- assets/world/tree/temperate_small/5.vox | 4 ++-- assets/world/tree/temperate_small/6.vox | 4 ++-- assets/world/tree/willow/1.vox | 4 ++-- assets/world/tree/willow/2.vox | 4 ++-- 454 files changed, 908 insertions(+), 908 deletions(-) diff --git a/assets/voxygen/voxel/figure/accessory/dwarf/warpaint-0.vox b/assets/voxygen/voxel/figure/accessory/dwarf/warpaint-0.vox index d7df1f190e..6384b30de5 100644 --- a/assets/voxygen/voxel/figure/accessory/dwarf/warpaint-0.vox +++ b/assets/voxygen/voxel/figure/accessory/dwarf/warpaint-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d8702f89eb3203f4e7a844ea15cf8a8002058693413391e05477efd549eff24 -size 44411 +oid sha256:ee5ef8c75028aac457778b2f5fb20be0c8f2bc71eb71787f506ece2aa27d6583 +size 1304 diff --git a/assets/voxygen/voxel/figure/accessory/elf/headband-0.vox b/assets/voxygen/voxel/figure/accessory/elf/headband-0.vox index 923a803745..6384b30de5 100644 --- a/assets/voxygen/voxel/figure/accessory/elf/headband-0.vox +++ b/assets/voxygen/voxel/figure/accessory/elf/headband-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a6f1d5adf62ce3acce2907ccaa6814ee9609ab6c3f511898d8ca03a4ce43ba35 -size 55596 +oid sha256:ee5ef8c75028aac457778b2f5fb20be0c8f2bc71eb71787f506ece2aa27d6583 +size 1304 diff --git a/assets/voxygen/voxel/figure/accessory/orc/earring-female-0.vox b/assets/voxygen/voxel/figure/accessory/orc/earring-female-0.vox index 28fbc02c9e..23615fc3f8 100644 --- a/assets/voxygen/voxel/figure/accessory/orc/earring-female-0.vox +++ b/assets/voxygen/voxel/figure/accessory/orc/earring-female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc7e36908ae2a7d4118bfdaa291ae3866d4d987537f29418f2e4bc6917caf2c1 -size 44265 +oid sha256:6355cd59e15dab5e9f634faa080562cdd7397239f04c2a9b575bd6b856843ac8 +size 1100 diff --git a/assets/voxygen/voxel/figure/accessory/orc/earring-male-0.vox b/assets/voxygen/voxel/figure/accessory/orc/earring-male-0.vox index a0474a5be4..d4b9c24734 100644 --- a/assets/voxygen/voxel/figure/accessory/orc/earring-male-0.vox +++ b/assets/voxygen/voxel/figure/accessory/orc/earring-male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c6f0c2545760e788b7cd323f21d6dbd4314d4dc33ea750e06ef2d4f164eb8a6 -size 55649 +oid sha256:8f8793d0ef73b5e87a5bb3970bf28091b3acb8ce2d8e159583eafb4ec739c71d +size 1108 diff --git a/assets/voxygen/voxel/figure/accessory/orc/teeth-0.vox b/assets/voxygen/voxel/figure/accessory/orc/teeth-0.vox index 5de62aa839..d265eb3924 100644 --- a/assets/voxygen/voxel/figure/accessory/orc/teeth-0.vox +++ b/assets/voxygen/voxel/figure/accessory/orc/teeth-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:56afe629d354ba46de0a9620f8efe8621c724bee198da0d4e688261494fb62cb -size 55572 +oid sha256:e015a61cec39a4fed42e1994597c5de625118caa353ddda898229e4bf971194c +size 1104 diff --git a/assets/voxygen/voxel/figure/accessory/orc/teeth-1.vox b/assets/voxygen/voxel/figure/accessory/orc/teeth-1.vox index cf2adc92bd..e85bdfcbdf 100644 --- a/assets/voxygen/voxel/figure/accessory/orc/teeth-1.vox +++ b/assets/voxygen/voxel/figure/accessory/orc/teeth-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:166de7e8a7ea76dba2092115c66b828ccbbf81940bbef3c908f57e14fbe95a00 -size 55572 +oid sha256:6b5800d8a12c7c27ba5454ccb11e09831ca2c468fee7072f78689f544b7bfa0e +size 1104 diff --git a/assets/voxygen/voxel/figure/accessory/orc/teeth-2.vox b/assets/voxygen/voxel/figure/accessory/orc/teeth-2.vox index 269776b72c..1ccd6cf112 100644 --- a/assets/voxygen/voxel/figure/accessory/orc/teeth-2.vox +++ b/assets/voxygen/voxel/figure/accessory/orc/teeth-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:41dc5164763ff2af08af28b25962f7a61c80403ca2bea7e0bcef132f0b054a1f -size 55572 +oid sha256:4dc2020629ca9d664d34cfe1d47aabb16947200c6f73818ab3415a789b5dfeb5 +size 1104 diff --git a/assets/voxygen/voxel/figure/accessory/orc/warpaint-female-0.vox b/assets/voxygen/voxel/figure/accessory/orc/warpaint-female-0.vox index bec886a3da..5199d3841b 100644 --- a/assets/voxygen/voxel/figure/accessory/orc/warpaint-female-0.vox +++ b/assets/voxygen/voxel/figure/accessory/orc/warpaint-female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:17cfb5e4f716fdb7c9c7617247a38f24c7ee72348c5ed2016e51dbec594a674b -size 57958 +oid sha256:635b1dfa3868c780910d235aa467ce821a78fd0c04e116089cd33ba86ad80e65 +size 1164 diff --git a/assets/voxygen/voxel/figure/accessory/orc/warpaint-female-1.vox b/assets/voxygen/voxel/figure/accessory/orc/warpaint-female-1.vox index b6594f60c9..2cfe197670 100644 --- a/assets/voxygen/voxel/figure/accessory/orc/warpaint-female-1.vox +++ b/assets/voxygen/voxel/figure/accessory/orc/warpaint-female-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b589c82819788d4613403fcde382adb3789e6d55e19ca3fb497f39d438a02acd -size 57914 +oid sha256:eed5f71dde24d04a5584c3d8103515a897c2bbf6fdfcfd00646d99337a2524f2 +size 1120 diff --git a/assets/voxygen/voxel/figure/accessory/orc/warpaint-male-0.vox b/assets/voxygen/voxel/figure/accessory/orc/warpaint-male-0.vox index 4b1f2ff17d..e21855128a 100644 --- a/assets/voxygen/voxel/figure/accessory/orc/warpaint-male-0.vox +++ b/assets/voxygen/voxel/figure/accessory/orc/warpaint-male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cea7b3d71c51f4c59695cedca70f1bfcfa549a76ef04586bcac3ffa06312cdeb -size 55805 +oid sha256:aaac3c35679745cb25a918857779379df8d800041f2803f72fbef08b65a584b5 +size 1264 diff --git a/assets/voxygen/voxel/figure/beard/danari/danari-0.vox b/assets/voxygen/voxel/figure/beard/danari/danari-0.vox index 70e0bcb070..349356722f 100644 --- a/assets/voxygen/voxel/figure/beard/danari/danari-0.vox +++ b/assets/voxygen/voxel/figure/beard/danari/danari-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a197d1325db805082defdf64711753767bb612360197461c8dad00f7de359d8 -size 55808 +oid sha256:89121d3f2158974a75bc8f8264272bfa7756f7f0b1cc3805cd62c349a4a0110f +size 1304 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-0.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-0.vox index b9b6d6352b..06e48e1dd7 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-0.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:70054f395189378830ef2420a3746a0041fc0e0a95e3cf487e4bb4563648f048 -size 55635 +oid sha256:5a78f9c73a5de56e1eab202b448737cd9ac1b6450a23285d83b59d0065395340 +size 1152 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-1.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-1.vox index 3999c7750c..1077c4311f 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-1.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:587913a3dfbf311019f1503765483726fa0707be2f81997c197a89fd00516453 -size 55880 +oid sha256:1b9f2e9facd32e4270d604b6fbd060dde7f94c53ef481a28a6817400d1888fc4 +size 1384 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-10.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-10.vox index db9fbd9fd2..fee7e6aeb7 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-10.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:79c91c5fc166c761381466b532700ba554dcbbf98c0e0920cd1e89a079832068 -size 55700 +oid sha256:58e8369fcf98d22b1008eaf53ca9151041bfbd5d1a9ed9782cb3db769d1464cd +size 1216 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-11.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-11.vox index 8397734269..d7e7cba495 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-11.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-11.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:abf492023b2d38100700db8c503ca56cd2e59425976983a137c3eb3a2984ad1b -size 55608 +oid sha256:c9e5060691cd8aa7cf6fcb7f15ea4e349eb63b9f2c8969ecf3a1e84fc1988e8b +size 1112 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-12.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-12.vox index bd34efb2fb..b1acab0aae 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-12.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-12.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2d4e1c97b446e0254f8a2ebdf540e41ea78c3f8c879ab741f41cf5c4c2d53c4e -size 55743 +oid sha256:ea2e1e778a36f554b8cad25919baaee70685641079b479b28fe122dd86419f7e +size 1248 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-13.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-13.vox index 2d9ec7a83c..81974f0b84 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-13.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-13.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b8319d01bcd0205ff5f8d2c46568dbfa254b4ff7235a33db6fcc2536165a8ac6 -size 55767 +oid sha256:5ed9973b3f2d2b7e659aaa49d474df061571a5f7986c83de0a671d8946ba0c95 +size 1272 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-14.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-14.vox index 6c19a9756d..5658855d85 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-14.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-14.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:85a8b17cb040cbc8a4f2fcf4d62708fe58eb9bc44a6601330ed3fe651d4fde30 -size 56031 +oid sha256:6bb5ced957dd009b77338c6c9a377c54e74bc80829f987778ea358d1ad298148 +size 1536 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-15.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-15.vox index 08632e12fc..f0e147b81b 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-15.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-15.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c5690077afe2310d5d5a2d3213d67591873d8ba2aa568bcd4297d197bebb5f69 -size 56255 +oid sha256:d7c213d67cd905119d6a24d58be1f629ddd5a784a7bd741c5de9b5c01bdd26e2 +size 1760 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-16.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-16.vox index bed8c99481..88a55ebdd2 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-16.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-16.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e55728feb14ef92691f78eb22e1acb28d962701d9b4a107c1f2755374c86bd74 -size 56319 +oid sha256:9094a2b9035efa5b8253f64df9b30b79cb1a485bfc247dc9119915750d488c8e +size 1824 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-17.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-17.vox index d42a737df4..4d35630ce4 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-17.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-17.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5dd1ff13263637a199099ebd073a7b288830451799aeac3f6f36c057a8308472 -size 56015 +oid sha256:d2d41a2736dda2f7fbcfc11ff2937b8f908bb6e33b45d18a8360f47296386684 +size 1520 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-18.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-18.vox index 3722310430..5ece4b7bdb 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-18.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-18.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bed743c48f4b5364218606b1542fddfa4611c021678e24942cca7adb9c85c248 -size 44461 +oid sha256:fae60c3dbcda4404ef89e6fbc09e12c80c85c968ccba1f29e91f14cf4e0665e6 +size 1288 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-19.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-19.vox index cc441a1f3c..f51fa6ee5b 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-19.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-19.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ffbb87ed5aa901712594644e2a1d01c6957a9377860ac1f7686b143850240bed -size 56135 +oid sha256:ab857cffd5f157ca5e443af2877c2fabd3ee2f95b1df870f061a8e788bb04ee9 +size 1640 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-2.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-2.vox index 8388512d32..d2c6af0edc 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-2.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6c458fd3cd37a950ed2a0aba20f2574057f0b214b80a3f29787e4f885c50ac6b -size 55592 +oid sha256:f03e0d1762b49e99d350c25420822b5c5916888bc3d0783e7f38b610002acbd4 +size 1108 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-20.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-20.vox index 35143ca15e..6ab4ce661f 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-20.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-20.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ca166da00ac7b9f22facfee633b72d5e329079ed88f1892bbd235f25993b842 -size 55823 +oid sha256:ef7b0909e5d665b64d2e8ee28c10b93ad8a0e3bb066df5a1772bfc5dd9919336 +size 1328 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-3.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-3.vox index b4557243fa..dbc5f5d671 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-3.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:22f78432ec6de234a6ea97bf23e2d8b8b92844dcf9c729b61fa6d6974d49f11b -size 55744 +oid sha256:a31013e7a8f584cfff875e730a66d525e81b777ef0a1d32e8e1d461b8913d785 +size 1248 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-4.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-4.vox index 2fa73c86d4..3d6f017615 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-4.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c5f7134d5a959664bc3c4a668f51f29415f8f90d4a4a8406fa1055087dc2fda9 -size 55660 +oid sha256:1a997e3ce8d0e4f0b98ad12c036fcc8af05a362aef46e618bf6fd5942b406b86 +size 1164 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-5.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-5.vox index 9cbdc737d2..05532071cb 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-5.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:97e5fe9cc441d008884432a939a28c51343a0896267444f6b81f3cb91f95c7f0 -size 56092 +oid sha256:79fe47c2e1a0827d3fa5ee43c2f20f56d483d2440a350ff6bac397953af54b95 +size 1608 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-6.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-6.vox index 45a3d7c420..d63c068df7 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-6.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5d7dbb993505870c5760a1fe076f0f8c5fdd1b782380d91afd2216f133ac16ef -size 56172 +oid sha256:de5c2b852f9310f62f94aafab0bfd711e129352ae5c9617ed3cb539dcc453c6e +size 1688 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-7.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-7.vox index 5a3206bdd1..d925d23530 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-7.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4656f1e1ac68a1ff25779f9c5ddf6dabfb6796b0f80fa7f506389e0f3213aaa3 -size 55636 +oid sha256:9b97cb3ddb387ee38614b1b42c90b7dca0c0c36bd4351bc39fa7907abf915578 +size 1152 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-8.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-8.vox index 84898f202c..d419959b79 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-8.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:168445edd3a04b4c31af94c50c3bafc8f4b18bb800609a01a1d787957798ba67 -size 55656 +oid sha256:28b6ebde1c0dabe2d40ee75b5fb9d5a601331efbfa135dd3f33d139cdb8b522c +size 1172 diff --git a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-9.vox b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-9.vox index 8789c39e08..37e30b75a6 100644 --- a/assets/voxygen/voxel/figure/beard/dwarf/dwarf-9.vox +++ b/assets/voxygen/voxel/figure/beard/dwarf/dwarf-9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:329413b38efdd883ca78100336d06cfef8fe247934262ab7a8c10d2bb6831f7a -size 55644 +oid sha256:1224a5567a1350e8f9c7320e7d6764ce6e7a895dc3cb1b2364c85e66e6d035ec +size 1160 diff --git a/assets/voxygen/voxel/figure/beard/human/human-0.vox b/assets/voxygen/voxel/figure/beard/human/human-0.vox index 85e6a409fc..31db774e58 100644 --- a/assets/voxygen/voxel/figure/beard/human/human-0.vox +++ b/assets/voxygen/voxel/figure/beard/human/human-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d0c5efe8f1645d8104ab07e6412440614febc9b8ca95fdfdc0f0e8ffaee4f331 -size 55723 +oid sha256:9e0a3b287e0248ac91080ebf5de54918571c8cfb1b81fc9db2bd861c15c10e8d +size 1240 diff --git a/assets/voxygen/voxel/figure/beard/human/human-1.vox b/assets/voxygen/voxel/figure/beard/human/human-1.vox index 8c77eb6027..53e8761f90 100644 --- a/assets/voxygen/voxel/figure/beard/human/human-1.vox +++ b/assets/voxygen/voxel/figure/beard/human/human-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3f2b9fa02e94502dab0d1969cb80c8d1b8487ad4e2f2856c3157f4dd916e14ad -size 46644 +oid sha256:a0068f185e10373f7ea1d5a859c225f76df6b0286d2b26227f030004f6838818 +size 1136 diff --git a/assets/voxygen/voxel/figure/beard/human/human-2.vox b/assets/voxygen/voxel/figure/beard/human/human-2.vox index 9afb46e0c6..5ece4b7bdb 100644 --- a/assets/voxygen/voxel/figure/beard/human/human-2.vox +++ b/assets/voxygen/voxel/figure/beard/human/human-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c4be53d43ff9edae15b8ee553224d8829ba07423ae59a54d0ef62ddff8b87838 -size 58183 +oid sha256:fae60c3dbcda4404ef89e6fbc09e12c80c85c968ccba1f29e91f14cf4e0665e6 +size 1288 diff --git a/assets/voxygen/voxel/figure/beard/orc/2.vox b/assets/voxygen/voxel/figure/beard/orc/2.vox index 1159d73666..4c9b6affcc 100644 --- a/assets/voxygen/voxel/figure/beard/orc/2.vox +++ b/assets/voxygen/voxel/figure/beard/orc/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:93ac4052c7f43806434a839ff560d8d3adbfc2415c69689a810848172a56665a -size 58452 +oid sha256:bf134a351e647345d55255633c2837e8ea6628496416ded1ada46cfb62d29138 +size 1540 diff --git a/assets/voxygen/voxel/figure/body/chest.vox b/assets/voxygen/voxel/figure/body/chest.vox index 5b603c33d2..304dce6dbd 100644 --- a/assets/voxygen/voxel/figure/body/chest.vox +++ b/assets/voxygen/voxel/figure/body/chest.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:88d68e0ece1a8029b4c437083ed31f404fb94ea39483acef9877dfdc6ed40b57 -size 55635 +oid sha256:0028bcc1fc7a78208467639c767cb999e7b1248c4c5619595af6453a06aa30ab +size 1152 diff --git a/assets/voxygen/voxel/figure/body/chest_female.vox b/assets/voxygen/voxel/figure/body/chest_female.vox index bbfbe470cb..b6219ec1cf 100644 --- a/assets/voxygen/voxel/figure/body/chest_female.vox +++ b/assets/voxygen/voxel/figure/body/chest_female.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:07d909f26e5e0eee95ccc6b2ddef03442fbcf70866daeeb91dedab6a69dd77f7 -size 45315 +oid sha256:c3dffb171111c349ce1873006e58935873357fcdc9cf30d69a87e195468457e1 +size 2208 diff --git a/assets/voxygen/voxel/figure/body/chest_male.vox b/assets/voxygen/voxel/figure/body/chest_male.vox index 2826a626a9..70d534e6ce 100644 --- a/assets/voxygen/voxel/figure/body/chest_male.vox +++ b/assets/voxygen/voxel/figure/body/chest_male.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a6ac0a625ef1f542e3614920e931697fe6f41503c80fcb2e6531d478161d8b61 -size 45323 +oid sha256:ee2210f0a3cbc05e3a8dc08d0bd2c3f957aa35c4835807ad787b9db0897540db +size 2216 diff --git a/assets/voxygen/voxel/figure/body/foot.vox b/assets/voxygen/voxel/figure/body/foot.vox index adb06abda1..0cbf680f10 100644 --- a/assets/voxygen/voxel/figure/body/foot.vox +++ b/assets/voxygen/voxel/figure/body/foot.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0de181956a0c6bf50cfb4eb4844a3509eb01f4adf1ad108a853a52e6e048a699 -size 55899 +oid sha256:21287486eb30ba437fb9f1cffa16a93e22d98ff35c6dab5e6f665fe34536020a +size 1416 diff --git a/assets/voxygen/voxel/figure/body/hand.vox b/assets/voxygen/voxel/figure/body/hand.vox index 053ab85c09..2fc57ec15f 100644 --- a/assets/voxygen/voxel/figure/body/hand.vox +++ b/assets/voxygen/voxel/figure/body/hand.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f828168f8ac886ca1b1947f20ead4b582dcf0b3f1f885629ac71819f6c50ac71 -size 55755 +oid sha256:5dcbebd44d164284b79ab97a3d4f0bc4a3a7088094f4c85b10955a23fda5d344 +size 1272 diff --git a/assets/voxygen/voxel/figure/body/pants_male.vox b/assets/voxygen/voxel/figure/body/pants_male.vox index a76a298be2..900c9e0569 100644 --- a/assets/voxygen/voxel/figure/body/pants_male.vox +++ b/assets/voxygen/voxel/figure/body/pants_male.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2486a04a6facfb002c0a504a1b6c138190df93e0b3a3a62da267c8c3f43dade7 -size 44831 +oid sha256:f46270fc3f1d46c32ddce368434debaca94ec2f94dc325ecc4df675fd7b82d5f +size 1724 diff --git a/assets/voxygen/voxel/figure/eyes/danari/female-0.vox b/assets/voxygen/voxel/figure/eyes/danari/female-0.vox index 1e07d63b51..36f9d053f4 100644 --- a/assets/voxygen/voxel/figure/eyes/danari/female-0.vox +++ b/assets/voxygen/voxel/figure/eyes/danari/female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:af6830d432bf365bd571736a88495a5e714f2bb238307ad30d5b7ff1da3f3110 -size 44259 +oid sha256:320e5b32b7d383ad05a51b2a026c1235aedd54fcb87f3e2e8b2fa662102d6fa5 +size 1152 diff --git a/assets/voxygen/voxel/figure/eyes/danari/male-0.vox b/assets/voxygen/voxel/figure/eyes/danari/male-0.vox index 4cb9737f76..5f32d0a872 100644 --- a/assets/voxygen/voxel/figure/eyes/danari/male-0.vox +++ b/assets/voxygen/voxel/figure/eyes/danari/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3243ba5a786197eaf4fcbab2c511decf3c7d5a7c95a1c4f204e199cea1cd08c0 -size 55661 +oid sha256:ff1ac798ca93a041195e3efee2c1166670a3f13c2fc907a432f1c7b44c381c4c +size 1176 diff --git a/assets/voxygen/voxel/figure/eyes/danari/male-1.vox b/assets/voxygen/voxel/figure/eyes/danari/male-1.vox index c56fb21d85..e89a0d081c 100644 --- a/assets/voxygen/voxel/figure/eyes/danari/male-1.vox +++ b/assets/voxygen/voxel/figure/eyes/danari/male-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:59d0f3818322a62cdfb61b8eb9528ff71c3eed832419b769492109c419fb02c0 -size 55629 +oid sha256:7cd5475e11718417f1b877d143b2cc75b43fb1f368581dd6f37b167fbdbb0aa5 +size 1144 diff --git a/assets/voxygen/voxel/figure/eyes/dwarf/male-0.vox b/assets/voxygen/voxel/figure/eyes/dwarf/male-0.vox index 4cb9737f76..5f32d0a872 100644 --- a/assets/voxygen/voxel/figure/eyes/dwarf/male-0.vox +++ b/assets/voxygen/voxel/figure/eyes/dwarf/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3243ba5a786197eaf4fcbab2c511decf3c7d5a7c95a1c4f204e199cea1cd08c0 -size 55661 +oid sha256:ff1ac798ca93a041195e3efee2c1166670a3f13c2fc907a432f1c7b44c381c4c +size 1176 diff --git a/assets/voxygen/voxel/figure/eyes/dwarf/male-1.vox b/assets/voxygen/voxel/figure/eyes/dwarf/male-1.vox index 133c89b750..8508f20ec7 100644 --- a/assets/voxygen/voxel/figure/eyes/dwarf/male-1.vox +++ b/assets/voxygen/voxel/figure/eyes/dwarf/male-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:61048b0758d68f323a74b099b2a5e9b616f51deae2bbcb4eea3bbd22ff2ed205 -size 44243 +oid sha256:6f43066f4edb931616cc537cc555591ae01da86fd4bcc43977d68733be717713 +size 1136 diff --git a/assets/voxygen/voxel/figure/eyes/elf/female-0.vox b/assets/voxygen/voxel/figure/eyes/elf/female-0.vox index d0a33723b9..3117f03062 100644 --- a/assets/voxygen/voxel/figure/eyes/elf/female-0.vox +++ b/assets/voxygen/voxel/figure/eyes/elf/female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1f93c0590c603f9b580dc970159908fac342b81752164d642ad62e8eaf360a7c -size 55635 +oid sha256:8cf208a53b7aa72af935be0155dbbea10225e543434a23dffd0f7afbe649ae99 +size 1152 diff --git a/assets/voxygen/voxel/figure/eyes/elf/male-0.vox b/assets/voxygen/voxel/figure/eyes/elf/male-0.vox index c56fb21d85..e89a0d081c 100644 --- a/assets/voxygen/voxel/figure/eyes/elf/male-0.vox +++ b/assets/voxygen/voxel/figure/eyes/elf/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:59d0f3818322a62cdfb61b8eb9528ff71c3eed832419b769492109c419fb02c0 -size 55629 +oid sha256:7cd5475e11718417f1b877d143b2cc75b43fb1f368581dd6f37b167fbdbb0aa5 +size 1144 diff --git a/assets/voxygen/voxel/figure/eyes/human/female-0.vox b/assets/voxygen/voxel/figure/eyes/human/female-0.vox index 92d9c14246..1cbb6c6220 100644 --- a/assets/voxygen/voxel/figure/eyes/human/female-0.vox +++ b/assets/voxygen/voxel/figure/eyes/human/female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:21c5a4f82b33258a8d3af1c4b518e0a37cc088bfb1bbe2e4652b4a07aa323c74 -size 44259 +oid sha256:870cb62cf318d20b1ebab5afe572df817f07966be45bf78e42d43f231d8dc188 +size 1152 diff --git a/assets/voxygen/voxel/figure/eyes/human/male-0.vox b/assets/voxygen/voxel/figure/eyes/human/male-0.vox index c56fb21d85..e89a0d081c 100644 --- a/assets/voxygen/voxel/figure/eyes/human/male-0.vox +++ b/assets/voxygen/voxel/figure/eyes/human/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:59d0f3818322a62cdfb61b8eb9528ff71c3eed832419b769492109c419fb02c0 -size 55629 +oid sha256:7cd5475e11718417f1b877d143b2cc75b43fb1f368581dd6f37b167fbdbb0aa5 +size 1144 diff --git a/assets/voxygen/voxel/figure/eyes/human/male-1.vox b/assets/voxygen/voxel/figure/eyes/human/male-1.vox index 4cb9737f76..5f32d0a872 100644 --- a/assets/voxygen/voxel/figure/eyes/human/male-1.vox +++ b/assets/voxygen/voxel/figure/eyes/human/male-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3243ba5a786197eaf4fcbab2c511decf3c7d5a7c95a1c4f204e199cea1cd08c0 -size 55661 +oid sha256:ff1ac798ca93a041195e3efee2c1166670a3f13c2fc907a432f1c7b44c381c4c +size 1176 diff --git a/assets/voxygen/voxel/figure/eyes/orc/female-0.vox b/assets/voxygen/voxel/figure/eyes/orc/female-0.vox index bc4322cab0..bfb89a681c 100644 --- a/assets/voxygen/voxel/figure/eyes/orc/female-0.vox +++ b/assets/voxygen/voxel/figure/eyes/orc/female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ac10923451391aa0066d9bcaed74a8ebb75d567a6b9647c8f7b72c780647a2e -size 55635 +oid sha256:e31d98bff4e3d183a605d312a444048a51021f0bec6bde94b44bf355e96a0d16 +size 1152 diff --git a/assets/voxygen/voxel/figure/eyes/orc/male-0.vox b/assets/voxygen/voxel/figure/eyes/orc/male-0.vox index 29b2ca100e..39b4cec076 100644 --- a/assets/voxygen/voxel/figure/eyes/orc/male-0.vox +++ b/assets/voxygen/voxel/figure/eyes/orc/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f12084720d46555fc7da25b97ccb965c6fdd2c9b714f8fc054b15c5b21580713 -size 55595 +oid sha256:ce9a5dcc298171c81c292331a85e4e46e859c9763915583343aad711e12f8fb1 +size 1112 diff --git a/assets/voxygen/voxel/figure/eyes/undead/female-0.vox b/assets/voxygen/voxel/figure/eyes/undead/female-0.vox index e7c919a0a3..ed58911c67 100644 --- a/assets/voxygen/voxel/figure/eyes/undead/female-0.vox +++ b/assets/voxygen/voxel/figure/eyes/undead/female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:88a1168befcbfdc2873511d8cd9bbd565151670f59310cf112da3a897ff3014d -size 55595 +oid sha256:10289af4d395cd4a55183b3398295c1b468c996a7aad05474ed3aaf39161f1ef +size 1112 diff --git a/assets/voxygen/voxel/figure/eyes/undead/male-0.vox b/assets/voxygen/voxel/figure/eyes/undead/male-0.vox index a9bbe373ef..a42ef18611 100644 --- a/assets/voxygen/voxel/figure/eyes/undead/male-0.vox +++ b/assets/voxygen/voxel/figure/eyes/undead/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ae79b438cafe7a78bfef431f286901ddbbdf6c4aed999b86b7543e73bf0ad75 -size 55595 +oid sha256:c1a84d7a62081ecf7bc5e3eb35f5537263889f3974b2261e4b7c11a682238c95 +size 1112 diff --git a/assets/voxygen/voxel/figure/hair/danari/female-0.vox b/assets/voxygen/voxel/figure/hair/danari/female-0.vox index 9e0363f1b0..c1758ba726 100644 --- a/assets/voxygen/voxel/figure/hair/danari/female-0.vox +++ b/assets/voxygen/voxel/figure/hair/danari/female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7de1f0cf0f94dc577b22f41a284f37c31d8674221e82a67698a8c3f46a6ab417 -size 45525 +oid sha256:d70d8bbc0ed7ebcaffc14154d6542e77be28897366da42374eed19f67fe8e194 +size 2364 diff --git a/assets/voxygen/voxel/figure/hair/danari/female-1.vox b/assets/voxygen/voxel/figure/hair/danari/female-1.vox index 3019932143..9ce7a1d23d 100644 --- a/assets/voxygen/voxel/figure/hair/danari/female-1.vox +++ b/assets/voxygen/voxel/figure/hair/danari/female-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:73a7623f6950249cffc3f029ccebb3f209fa15f6d57080b920ecb16f87fe9985 -size 59115 +oid sha256:3acd240b2dc5f68b4ace9a14b42bc7bb7d91e9f3f67ae409785ef0639aa0360e +size 2328 diff --git a/assets/voxygen/voxel/figure/hair/danari/male-0.vox b/assets/voxygen/voxel/figure/hair/danari/male-0.vox index 1013659af3..ca50e3c597 100644 --- a/assets/voxygen/voxel/figure/hair/danari/male-0.vox +++ b/assets/voxygen/voxel/figure/hair/danari/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a4f67ae300e73a5fea42a9fc2432e80ce4130fa4b23fe6053b04f7e5ca6952b9 -size 56299 +oid sha256:39b3c62cff1db93bc3f07ce166d9a9ccd0e7370de9a2ed75be5bcc3fd536d218 +size 1816 diff --git a/assets/voxygen/voxel/figure/hair/danari/male-1.vox b/assets/voxygen/voxel/figure/hair/danari/male-1.vox index b4f1f63106..36cef568f0 100644 --- a/assets/voxygen/voxel/figure/hair/danari/male-1.vox +++ b/assets/voxygen/voxel/figure/hair/danari/male-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a34a8aec3b192c2a7228805fb4825b5e72b67689951bbc0ca23f5a351e522bea -size 58663 +oid sha256:c329e3ca026ff35f2574fac8d48af4f3b7f65951a491399de1001a527f471a1c +size 1792 diff --git a/assets/voxygen/voxel/figure/hair/dwarf/bald.vox b/assets/voxygen/voxel/figure/hair/dwarf/bald.vox index 5217c5760d..52519e0411 100644 --- a/assets/voxygen/voxel/figure/hair/dwarf/bald.vox +++ b/assets/voxygen/voxel/figure/hair/dwarf/bald.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f8675bcccc30b5c452a080507f3cccd59cd0279db43e3388cf21bc6fa2c15519 -size 55579 +oid sha256:85e829c141db6ee7c7d7a521c8ef26c45b7d97cc732e1230bb124e74204e459c +size 1096 diff --git a/assets/voxygen/voxel/figure/hair/dwarf/female-0.vox b/assets/voxygen/voxel/figure/hair/dwarf/female-0.vox index 6189315569..8e9df08c4f 100644 --- a/assets/voxygen/voxel/figure/hair/dwarf/female-0.vox +++ b/assets/voxygen/voxel/figure/hair/dwarf/female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e97833f7e1e5420dd3193b15738eaae01cc42ee5ea0a10c25f70d0d631cfe234 -size 59195 +oid sha256:ddab65fcb39e2334262844464777012623ecf9dfc310b82a84e3c680460fa671 +size 2560 diff --git a/assets/voxygen/voxel/figure/hair/dwarf/female-1.vox b/assets/voxygen/voxel/figure/hair/dwarf/female-1.vox index d042496f30..854ddbe942 100644 --- a/assets/voxygen/voxel/figure/hair/dwarf/female-1.vox +++ b/assets/voxygen/voxel/figure/hair/dwarf/female-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a23aa08a25fcd292a16eb896f9b8826fe6caefbc4642a2cde3aa89db581d2d04 -size 59323 +oid sha256:a70fb875fbc7f6beddbedf9b3d208c53d495ee6a9e6f78c32ecc2e62e54f4c09 +size 2688 diff --git a/assets/voxygen/voxel/figure/hair/dwarf/female-2.vox b/assets/voxygen/voxel/figure/hair/dwarf/female-2.vox index 78b4830f99..76afb1902f 100644 --- a/assets/voxygen/voxel/figure/hair/dwarf/female-2.vox +++ b/assets/voxygen/voxel/figure/hair/dwarf/female-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8491baad5fdb761e2fe6bbe9f87de4d1c18c5d38be8a3518621cca928efa0265 -size 59131 +oid sha256:abaeca010745185c37dc46892814e2656ec4bc5a8901db3d505b94e7fdb3e8a6 +size 2496 diff --git a/assets/voxygen/voxel/figure/hair/dwarf/female-3.vox b/assets/voxygen/voxel/figure/hair/dwarf/female-3.vox index 37e802802e..3ea2051bd5 100644 --- a/assets/voxygen/voxel/figure/hair/dwarf/female-3.vox +++ b/assets/voxygen/voxel/figure/hair/dwarf/female-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:126fcd7f2a62d7629e33f63eb309ae27f92e712146b09e5ac3e1345a170958e6 -size 59559 +oid sha256:57511c54c2450856f0f2eea91b4cf4933ebfc50aa4ea91d7a4f9153571ea814d +size 2924 diff --git a/assets/voxygen/voxel/figure/hair/dwarf/male-0.vox b/assets/voxygen/voxel/figure/hair/dwarf/male-0.vox index e273c10037..3c4fb074bf 100644 --- a/assets/voxygen/voxel/figure/hair/dwarf/male-0.vox +++ b/assets/voxygen/voxel/figure/hair/dwarf/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3e59a672ee68537160653a4bc36815e508c56e88bc183d5ddae82dd8cf1a5857 -size 57005 +oid sha256:2eddaa5ffb8b5f0abfd9769147b7168fc35157666ad98bd874d64333969b161d +size 2520 diff --git a/assets/voxygen/voxel/figure/hair/dwarf/male-1.vox b/assets/voxygen/voxel/figure/hair/dwarf/male-1.vox index f321c9e0b7..ed4196bb8b 100644 --- a/assets/voxygen/voxel/figure/hair/dwarf/male-1.vox +++ b/assets/voxygen/voxel/figure/hair/dwarf/male-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bf11b892a7fe1a2d315c02c75f7eaec4e46b46b592b1769943e4f37066e4ccae -size 56283 +oid sha256:c60ed073ac070de5faf8e83b8ec41160cada993e8747f9192a03d8f345b4b5d3 +size 1800 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-0.vox b/assets/voxygen/voxel/figure/hair/elf/female-0.vox index 75989991d2..cd30bb6c38 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-0.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c43639107b475f7918687b478e339ed3308ec44d07ed02ce4932a01ef0fd240f -size 57436 +oid sha256:affe57e1e04764bf002ff027719799dad1b8f3df1629f3f3bfec13b9e430fa33 +size 2952 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-1.vox b/assets/voxygen/voxel/figure/hair/elf/female-1.vox index 16f68386b5..4259d071cd 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-1.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d010560a49eadab4f0e8a76a6e07fbb6d385d7e771b4665fde40161f28425163 -size 56860 +oid sha256:2f6fcbe925ecd7a8249cbe81c7b394a32e14f2aeb031e69bae522f0bc7dc2954 +size 2376 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-10.vox b/assets/voxygen/voxel/figure/hair/elf/female-10.vox index 6f562c6893..8c2670d908 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-10.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ffa6ebdea30df3b996af356834a48aacd6e1ad9dfcfb3cae0fb6a4d4c8183b3 -size 58036 +oid sha256:d83728287cc2caa9cfa02cc0d6295879a08c2b6a90e1a8c922d636aa289fcd10 +size 3552 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-11.vox b/assets/voxygen/voxel/figure/hair/elf/female-11.vox index 401ca43eb1..db849748bb 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-11.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-11.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:986449085be85193f06ccbb42584d92bc6143169f5c63aacc96b4340d85fafd5 -size 56504 +oid sha256:f1bdd7fc7cf521b96758442e1772a651726a4285537326e146b454bea602bdc7 +size 2020 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-12.vox b/assets/voxygen/voxel/figure/hair/elf/female-12.vox index 15d2f5a4aa..d64aac0dc6 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-12.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-12.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ce7fb066bcc8374fa73ef6535df87ea8ee1853621406c4016511bb70d9eaf10 -size 57484 +oid sha256:8be51f26eea7f5d9742d669bf0c0799f3619c21456e177bb1af45b55b76f16fc +size 3000 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-13.vox b/assets/voxygen/voxel/figure/hair/elf/female-13.vox index e9d02a1b8a..d744df025f 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-13.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-13.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a00ca5d4566a7595dd2212d5f1ac1219aae16078e8fcb05527a5d8098c76d24b -size 57128 +oid sha256:1c266fa848e7f1690c6fc8e0e8004ea8f8db18c43cc4351aec526b4544c56273 +size 2644 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-14.vox b/assets/voxygen/voxel/figure/hair/elf/female-14.vox index 5c8cfbf5d0..f3d513f8e1 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-14.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-14.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ebafbf4ee56f80da3969fa636d6c5535fc3a25c0cfcb2507f21892de9a8d022 -size 56431 +oid sha256:35d5cf15aa12c8f107ce2ce66f7fba062ce38ed095d34940b4044c2a99b11c5a +size 1948 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-15.vox b/assets/voxygen/voxel/figure/hair/elf/female-15.vox index 8756c72a47..2ac6422691 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-15.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-15.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b0dab20f6850994566a49f7713c782970898c8ebdb90653338f981e6e0e4df61 -size 45491 +oid sha256:8ce506e01c04f50a67199f914dff5b2cbd9340c24eb81553e8672747809f6331 +size 2384 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-16.vox b/assets/voxygen/voxel/figure/hair/elf/female-16.vox index 1bf35a53f9..76de90d5d8 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-16.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-16.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:12054d5bb41092833e3060b17b5f781ff71530607ea1f05a3da5dcffa203bca6 -size 56839 +oid sha256:da6c1d63dd85c570c104b8573b23aedbe7d4d44d7e14b7ab05e1a5c1ff8ad7d8 +size 2356 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-17.vox b/assets/voxygen/voxel/figure/hair/elf/female-17.vox index 5a95f00c2e..dd1360f8e6 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-17.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-17.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0b4e122316f0c424b45d488c4f282557a644e94da41b2556306f670a0d03f17 -size 57423 +oid sha256:3b557e1912c92e2163fd060c005f0fd6167a3ca41c616f13af14e36680b58336 +size 2940 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-18.vox b/assets/voxygen/voxel/figure/hair/elf/female-18.vox index 6aff62eaaa..844d2454fa 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-18.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-18.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f33c01e85f4d6ce8dfe10436c7b3772f97f4a51b392fc53bd19868b4e122b881 -size 57235 +oid sha256:7e85e4cfd2cd14dde11bd9d13acb38366036b585a4ba85efaebb3d61a00dedde +size 2752 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-19.vox b/assets/voxygen/voxel/figure/hair/elf/female-19.vox index b6696b32e9..c055b9f51b 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-19.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-19.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0bf37d298cd79c6490428b827ba275b06e87024e6a2b863b8a1f96ebda3f3c82 -size 57183 +oid sha256:b55cd9e8ac02fdf51b2b92d45545fad23af631ab735655e3572cc4f2b6835dab +size 2700 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-2.vox b/assets/voxygen/voxel/figure/hair/elf/female-2.vox index f0860a9c68..0f8d61b1be 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-2.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d6139dca50f10f22ae5b8b77b67986857913e21cca6d3ba720bde51189bc95c6 -size 59558 +oid sha256:e511587486c499d79b532961d1bfd13f313b0e28620f152a0b82dd5443fda4b1 +size 2632 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-20.vox b/assets/voxygen/voxel/figure/hair/elf/female-20.vox index 4be61e58e3..5a022cde25 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-20.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-20.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7f1f2860e3d049050c6f5a2c216b6e515677399ce617bced0aa1419db9b4fb1d -size 59333 +oid sha256:29e78db470fb10298b53b5cb85a25ae42fe2421dec68c675d823b957ab09b9dd +size 2460 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-21.vox b/assets/voxygen/voxel/figure/hair/elf/female-21.vox index 9925607619..48cd890ad4 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-21.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-21.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d1cdf8e3eace26b733572f39f42ce4440c2352992f3bc1400a43afd821462da -size 58226 +oid sha256:bdb7bbafc77b1549167c0b9198357b3ed787b8e8aa59d6b8cf25ef31ff50f371 +size 3716 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-3.vox b/assets/voxygen/voxel/figure/hair/elf/female-3.vox index 1d1a2de731..67c6de95fb 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-3.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b92cbba8ae9455e12d556b88edda753a6b4e2e66b98b19ada6adbb2840a72b4 -size 56888 +oid sha256:1ae29cf0c8b365d0358bc9ab175a90c85fc5f616a5d8fd66382503c1257f3b9b +size 2404 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-4.vox b/assets/voxygen/voxel/figure/hair/elf/female-4.vox index 22f90757b6..2d6b695a7c 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-4.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a858d60f0211d470e71c7c0f57d906f74983c57b4e9ca4b4ec631f399d319eef -size 57192 +oid sha256:95d2a6279a3adf51cf35cb5fde792d8a38538ef0edb5c137138392370ce01f1d +size 2708 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-5.vox b/assets/voxygen/voxel/figure/hair/elf/female-5.vox index b5af8b622b..20d231ded1 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-5.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c394d60cb4c560685695f46ccd64ea99644fb0b32f2694f5b3fda7b19b752f00 -size 56796 +oid sha256:7f705e19f9e0d6b2535f22b97424ef29cba6ec319202647fbc05a241ac217bea +size 2312 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-6.vox b/assets/voxygen/voxel/figure/hair/elf/female-6.vox index fd91992ce1..b1097c2c66 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-6.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:15bfdd21290dcdbcaa84cf0283b7dbe30e9ea87f04686bcae797390a90b3e2ec -size 59683 +oid sha256:7c558008dc134f8c056270186e3bcf5c14a55f02f2eecf8bedb3218b01a4e180 +size 2752 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-7.vox b/assets/voxygen/voxel/figure/hair/elf/female-7.vox index 084e3e2a7a..67aefec497 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-7.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f5fc742fc4bbd044db463048d498441b050e91d2caa2215d752b11776a1ec44c -size 57108 +oid sha256:f0b1c1e57101215c679058304ee7047114dcfed6e5a8618c73a8b4f26377e9ac +size 2624 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-8.vox b/assets/voxygen/voxel/figure/hair/elf/female-8.vox index 800d130ac8..fb06e14504 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-8.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7246ae4b8923b7eae180652d54a3e39f4bdbfa60585e84188874329c14e1d80c -size 57467 +oid sha256:3613c4c7bfd6018592f19376dd1f676928b6e603e7ee4c03483bc2466a5ec0a7 +size 2984 diff --git a/assets/voxygen/voxel/figure/hair/elf/female-9.vox b/assets/voxygen/voxel/figure/hair/elf/female-9.vox index 19e62e0c88..c83dfeea5a 100644 --- a/assets/voxygen/voxel/figure/hair/elf/female-9.vox +++ b/assets/voxygen/voxel/figure/hair/elf/female-9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:886ebb20b0e5e68a3ce09406f1b291fec9cec34913ee21fbad6b3d6c618654e4 -size 46276 +oid sha256:fca6cc008ca885f98a78194ca58210d1f6697faa686d158ca1f0bd8029e1a987 +size 3168 diff --git a/assets/voxygen/voxel/figure/hair/elf/male-0.vox b/assets/voxygen/voxel/figure/hair/elf/male-0.vox index 301732b9c1..a3de59ccc9 100644 --- a/assets/voxygen/voxel/figure/hair/elf/male-0.vox +++ b/assets/voxygen/voxel/figure/hair/elf/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bbd2e2b0038a0150e4aaec2477724903a44437ff90609c92122897dd19e60942 -size 56379 +oid sha256:d6d6b9f6e4bdfa5ce5e1cae102803d59e42b1c1ac9778a72181459547355adf9 +size 1896 diff --git a/assets/voxygen/voxel/figure/hair/elf/male-1.vox b/assets/voxygen/voxel/figure/hair/elf/male-1.vox index 800d130ac8..fb06e14504 100644 --- a/assets/voxygen/voxel/figure/hair/elf/male-1.vox +++ b/assets/voxygen/voxel/figure/hair/elf/male-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7246ae4b8923b7eae180652d54a3e39f4bdbfa60585e84188874329c14e1d80c -size 57467 +oid sha256:3613c4c7bfd6018592f19376dd1f676928b6e603e7ee4c03483bc2466a5ec0a7 +size 2984 diff --git a/assets/voxygen/voxel/figure/hair/elf/male-2.vox b/assets/voxygen/voxel/figure/hair/elf/male-2.vox index dac3a25e4e..1da5dee387 100644 --- a/assets/voxygen/voxel/figure/hair/elf/male-2.vox +++ b/assets/voxygen/voxel/figure/hair/elf/male-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c42e7da38ad6ef36e53c1fcfae73531f1dbf8adbf83b96a0f0f2981a248a5b7 -size 57026 +oid sha256:ef37ee588aa533263b94c0ccf0f81d303769530c4f606af4008928cf5b7331aa +size 2548 diff --git a/assets/voxygen/voxel/figure/hair/elf/male-3.vox b/assets/voxygen/voxel/figure/hair/elf/male-3.vox index c2f735d7a0..8afc3c4e99 100644 --- a/assets/voxygen/voxel/figure/hair/elf/male-3.vox +++ b/assets/voxygen/voxel/figure/hair/elf/male-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:003df0ac0d6115d676fe153431b111fd69a327893004785040bf92fb32c11492 -size 59276 +oid sha256:b2cd7e4a007367a45c73ade5c4f2b549e8b15abcb0b5b0befafa4a4b39a9f0d2 +size 2296 diff --git a/assets/voxygen/voxel/figure/hair/human/female-0.vox b/assets/voxygen/voxel/figure/hair/human/female-0.vox index 75989991d2..cd30bb6c38 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-0.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c43639107b475f7918687b478e339ed3308ec44d07ed02ce4932a01ef0fd240f -size 57436 +oid sha256:affe57e1e04764bf002ff027719799dad1b8f3df1629f3f3bfec13b9e430fa33 +size 2952 diff --git a/assets/voxygen/voxel/figure/hair/human/female-1.vox b/assets/voxygen/voxel/figure/hair/human/female-1.vox index 8fe3c18232..480d525b91 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-1.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:148b96d1a5c868aceffaf6d8ff8d27cf9827cc7183d538a9a3bfb57505ec0c89 -size 56860 +oid sha256:951038ce277d6194b8a11061312e0199c2df9f36a5d59d6193181307a99e56c6 +size 2376 diff --git a/assets/voxygen/voxel/figure/hair/human/female-10.vox b/assets/voxygen/voxel/figure/hair/human/female-10.vox index 6f562c6893..8c2670d908 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-10.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ffa6ebdea30df3b996af356834a48aacd6e1ad9dfcfb3cae0fb6a4d4c8183b3 -size 58036 +oid sha256:d83728287cc2caa9cfa02cc0d6295879a08c2b6a90e1a8c922d636aa289fcd10 +size 3552 diff --git a/assets/voxygen/voxel/figure/hair/human/female-11.vox b/assets/voxygen/voxel/figure/hair/human/female-11.vox index 401ca43eb1..db849748bb 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-11.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-11.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:986449085be85193f06ccbb42584d92bc6143169f5c63aacc96b4340d85fafd5 -size 56504 +oid sha256:f1bdd7fc7cf521b96758442e1772a651726a4285537326e146b454bea602bdc7 +size 2020 diff --git a/assets/voxygen/voxel/figure/hair/human/female-12.vox b/assets/voxygen/voxel/figure/hair/human/female-12.vox index 15d2f5a4aa..d64aac0dc6 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-12.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-12.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ce7fb066bcc8374fa73ef6535df87ea8ee1853621406c4016511bb70d9eaf10 -size 57484 +oid sha256:8be51f26eea7f5d9742d669bf0c0799f3619c21456e177bb1af45b55b76f16fc +size 3000 diff --git a/assets/voxygen/voxel/figure/hair/human/female-13.vox b/assets/voxygen/voxel/figure/hair/human/female-13.vox index e9d02a1b8a..d744df025f 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-13.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-13.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a00ca5d4566a7595dd2212d5f1ac1219aae16078e8fcb05527a5d8098c76d24b -size 57128 +oid sha256:1c266fa848e7f1690c6fc8e0e8004ea8f8db18c43cc4351aec526b4544c56273 +size 2644 diff --git a/assets/voxygen/voxel/figure/hair/human/female-14.vox b/assets/voxygen/voxel/figure/hair/human/female-14.vox index 5c8cfbf5d0..f3d513f8e1 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-14.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-14.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ebafbf4ee56f80da3969fa636d6c5535fc3a25c0cfcb2507f21892de9a8d022 -size 56431 +oid sha256:35d5cf15aa12c8f107ce2ce66f7fba062ce38ed095d34940b4044c2a99b11c5a +size 1948 diff --git a/assets/voxygen/voxel/figure/hair/human/female-15.vox b/assets/voxygen/voxel/figure/hair/human/female-15.vox index fa7703c1f1..23848ed252 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-15.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-15.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e08de7a6a3a69c6d1dade59e52c2c57b67e65c61237318444ddd3940764d36cc -size 45495 +oid sha256:02fa7137248fc3e27300214ab845dd1fcdeb2707f123cf9d2f3fbc23ad3a954c +size 2388 diff --git a/assets/voxygen/voxel/figure/hair/human/female-16.vox b/assets/voxygen/voxel/figure/hair/human/female-16.vox index 1bf35a53f9..76de90d5d8 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-16.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-16.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:12054d5bb41092833e3060b17b5f781ff71530607ea1f05a3da5dcffa203bca6 -size 56839 +oid sha256:da6c1d63dd85c570c104b8573b23aedbe7d4d44d7e14b7ab05e1a5c1ff8ad7d8 +size 2356 diff --git a/assets/voxygen/voxel/figure/hair/human/female-17.vox b/assets/voxygen/voxel/figure/hair/human/female-17.vox index 5a95f00c2e..dd1360f8e6 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-17.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-17.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0b4e122316f0c424b45d488c4f282557a644e94da41b2556306f670a0d03f17 -size 57423 +oid sha256:3b557e1912c92e2163fd060c005f0fd6167a3ca41c616f13af14e36680b58336 +size 2940 diff --git a/assets/voxygen/voxel/figure/hair/human/female-18.vox b/assets/voxygen/voxel/figure/hair/human/female-18.vox index 6aff62eaaa..844d2454fa 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-18.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-18.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f33c01e85f4d6ce8dfe10436c7b3772f97f4a51b392fc53bd19868b4e122b881 -size 57235 +oid sha256:7e85e4cfd2cd14dde11bd9d13acb38366036b585a4ba85efaebb3d61a00dedde +size 2752 diff --git a/assets/voxygen/voxel/figure/hair/human/female-19.vox b/assets/voxygen/voxel/figure/hair/human/female-19.vox index 9925607619..48cd890ad4 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-19.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-19.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d1cdf8e3eace26b733572f39f42ce4440c2352992f3bc1400a43afd821462da -size 58226 +oid sha256:bdb7bbafc77b1549167c0b9198357b3ed787b8e8aa59d6b8cf25ef31ff50f371 +size 3716 diff --git a/assets/voxygen/voxel/figure/hair/human/female-2.vox b/assets/voxygen/voxel/figure/hair/human/female-2.vox index d49a22402b..2d8a57854a 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-2.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a442b9712bf1cfeba5f2d8db2b6b86b10c8cad44b52810631615b16a1562a7bb -size 59578 +oid sha256:fad884bcd7ebd56c18df9717af7a40c00a7e3fd8c2a3d8a0f8da2b302d3d982e +size 2632 diff --git a/assets/voxygen/voxel/figure/hair/human/female-3.vox b/assets/voxygen/voxel/figure/hair/human/female-3.vox index a0856e47d2..2f8f0d2d2a 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-3.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:03d215ee1300bde1de09f3e2fb1552ac4e8db406510d61da7c3a935165fc17b6 -size 56888 +oid sha256:cf159dfe30389760438ce06ed05c66e911f93f86cb0fd9bc7a00ce6a35f7ed54 +size 2404 diff --git a/assets/voxygen/voxel/figure/hair/human/female-4.vox b/assets/voxygen/voxel/figure/hair/human/female-4.vox index 22f90757b6..2d6b695a7c 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-4.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a858d60f0211d470e71c7c0f57d906f74983c57b4e9ca4b4ec631f399d319eef -size 57192 +oid sha256:95d2a6279a3adf51cf35cb5fde792d8a38538ef0edb5c137138392370ce01f1d +size 2708 diff --git a/assets/voxygen/voxel/figure/hair/human/female-5.vox b/assets/voxygen/voxel/figure/hair/human/female-5.vox index b5af8b622b..20d231ded1 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-5.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c394d60cb4c560685695f46ccd64ea99644fb0b32f2694f5b3fda7b19b752f00 -size 56796 +oid sha256:7f705e19f9e0d6b2535f22b97424ef29cba6ec319202647fbc05a241ac217bea +size 2312 diff --git a/assets/voxygen/voxel/figure/hair/human/female-6.vox b/assets/voxygen/voxel/figure/hair/human/female-6.vox index 01c8f897c2..22a75844b4 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-6.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06fff76a6708d311ae6863ab884f371b2eb4a45ad941133a99e7415e3764b2a7 -size 59683 +oid sha256:be1836233f2b17b03e11f0c4644e03d21e5a76648cfef69e0a3546c62156141f +size 2752 diff --git a/assets/voxygen/voxel/figure/hair/human/female-7.vox b/assets/voxygen/voxel/figure/hair/human/female-7.vox index 084e3e2a7a..67aefec497 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-7.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f5fc742fc4bbd044db463048d498441b050e91d2caa2215d752b11776a1ec44c -size 57108 +oid sha256:f0b1c1e57101215c679058304ee7047114dcfed6e5a8618c73a8b4f26377e9ac +size 2624 diff --git a/assets/voxygen/voxel/figure/hair/human/female-8.vox b/assets/voxygen/voxel/figure/hair/human/female-8.vox index 800d130ac8..fb06e14504 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-8.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7246ae4b8923b7eae180652d54a3e39f4bdbfa60585e84188874329c14e1d80c -size 57467 +oid sha256:3613c4c7bfd6018592f19376dd1f676928b6e603e7ee4c03483bc2466a5ec0a7 +size 2984 diff --git a/assets/voxygen/voxel/figure/hair/human/female-9.vox b/assets/voxygen/voxel/figure/hair/human/female-9.vox index 19e62e0c88..c83dfeea5a 100644 --- a/assets/voxygen/voxel/figure/hair/human/female-9.vox +++ b/assets/voxygen/voxel/figure/hair/human/female-9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:886ebb20b0e5e68a3ce09406f1b291fec9cec34913ee21fbad6b3d6c618654e4 -size 46276 +oid sha256:fca6cc008ca885f98a78194ca58210d1f6697faa686d158ca1f0bd8029e1a987 +size 3168 diff --git a/assets/voxygen/voxel/figure/hair/human/male-0.vox b/assets/voxygen/voxel/figure/hair/human/male-0.vox index ee8e0a5a30..456fda8663 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-0.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9c097140e71170f0d4608d2436749492d36b316bbe67e4e18afbf904bbcb8117 -size 56351 +oid sha256:2024f688a627847d713274522b18d6b8a8159fe89bdad49f53082086e3b79998 +size 1868 diff --git a/assets/voxygen/voxel/figure/hair/human/male-1.vox b/assets/voxygen/voxel/figure/hair/human/male-1.vox index ee8e0a5a30..456fda8663 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-1.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9c097140e71170f0d4608d2436749492d36b316bbe67e4e18afbf904bbcb8117 -size 56351 +oid sha256:2024f688a627847d713274522b18d6b8a8159fe89bdad49f53082086e3b79998 +size 1868 diff --git a/assets/voxygen/voxel/figure/hair/human/male-10.vox b/assets/voxygen/voxel/figure/hair/human/male-10.vox index 86a4bf519f..526f3e9f41 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-10.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:53a158d070e5c1191f011efda7c0dfe07276973e5ce992c2e0cd9a6f7449d95d -size 58552 +oid sha256:cd6bb8be7c2972ac967afd8029a69b38ef62251c24d23c9444b6bc612334432d +size 1688 diff --git a/assets/voxygen/voxel/figure/hair/human/male-11.vox b/assets/voxygen/voxel/figure/hair/human/male-11.vox index 2b9dd79ce9..a421eefd11 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-11.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-11.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c1e881c9cbd41cc97d0b9cd1bc2f79cabfcc43d7d79debc9e901ec0827684a62 -size 56664 +oid sha256:22533597f6d8f7a81a1281084fe3a9b4c337a9d14ef71031cabab45474985cf8 +size 2184 diff --git a/assets/voxygen/voxel/figure/hair/human/male-12.vox b/assets/voxygen/voxel/figure/hair/human/male-12.vox index 704f80aded..ab45703d72 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-12.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-12.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3ed3799bade5ea5e9b4015a4214e092b651901f65b5503bfcb2565d9ed520aca -size 55640 +oid sha256:17a177635a44cce26bbd3200fcfc2a9b01a49b3fc7b5e3b781bb95f719ae63c8 +size 1160 diff --git a/assets/voxygen/voxel/figure/hair/human/male-13.vox b/assets/voxygen/voxel/figure/hair/human/male-13.vox index 7531279d73..c7f08044da 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-13.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-13.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ead8c89e70fc63335fa4bd3325462d087fe92f95f999019e70ed9551ccb3c51d -size 56728 +oid sha256:5df340fbade4cee1999fb1dbf3f60328eaa4315479e087776addf965a1b575a0 +size 2248 diff --git a/assets/voxygen/voxel/figure/hair/human/male-14.vox b/assets/voxygen/voxel/figure/hair/human/male-14.vox index 614217969f..4f3dab2ae6 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-14.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-14.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7667f9544ed63724899ea16708c3b22ff4410ea059b63cc59b7460ced0a3c962 -size 56416 +oid sha256:d17cedccc90f82b10157c26ca774b554057167224b91a94c548b87ee80fc0319 +size 1936 diff --git a/assets/voxygen/voxel/figure/hair/human/male-15.vox b/assets/voxygen/voxel/figure/hair/human/male-15.vox index 20f98be7b0..cbff54ebfc 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-15.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-15.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0a0b9927fcb7e6b1b0f6688b5959e443714a26a1896424db1adb948362430523 -size 56428 +oid sha256:95d6ba20b2c395413694f8604e91211245d560d95ef5bf818e73c134fe616a00 +size 1948 diff --git a/assets/voxygen/voxel/figure/hair/human/male-16.vox b/assets/voxygen/voxel/figure/hair/human/male-16.vox index 903aa62d3f..9661760017 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-16.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-16.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:03fa44f2e982b44ea9e4d20bd06f1e29646f38cdd2075ae4fba10c742be090dd -size 57680 +oid sha256:028a3a431f30b44c5b2dc95642952deb898b9c1ff0204de1c8ee450e567203df +size 3200 diff --git a/assets/voxygen/voxel/figure/hair/human/male-17.vox b/assets/voxygen/voxel/figure/hair/human/male-17.vox index 74e978fd4b..b449189faf 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-17.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-17.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d000ef9fd1a8dd2b92b7abb3b1ddaea069953afa6b4e1225bde6ebe48e941d57 -size 56584 +oid sha256:bd16b5c78c667715b5d1ee4fe0776af5b329c53cc9f4432cfc9261ae8e8e0c3c +size 2104 diff --git a/assets/voxygen/voxel/figure/hair/human/male-18.vox b/assets/voxygen/voxel/figure/hair/human/male-18.vox index 63940d939e..94e4e5a34b 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-18.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-18.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:14089f256144399d6397eedc0036794e2622d25b3a10765992706216247fec5b -size 56704 +oid sha256:8fc14c30703103be12546030c8e8c36e81ccbe794445b4f89bbff0dafb2ecbe6 +size 2224 diff --git a/assets/voxygen/voxel/figure/hair/human/male-19.vox b/assets/voxygen/voxel/figure/hair/human/male-19.vox index 1cc1df9dac..22725d666e 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-19.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-19.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a9d32f0bb9e34d7d93d1ecb219f3fc744b63916ea0f971338c2c95ce7bcf1349 -size 56416 +oid sha256:37febb8aa41738ff001853e76afd683d1346aa595986cdcf2b762fb7b5d39a9c +size 1936 diff --git a/assets/voxygen/voxel/figure/hair/human/male-2.vox b/assets/voxygen/voxel/figure/hair/human/male-2.vox index 32934f6105..017b950f0f 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-2.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a55636d8ea9abd185d161abb15bece85a65fb2706aa86c2486af4592f4561e6 -size 56747 +oid sha256:70ca7e4970b59b537f2e01ff0b8ca353edbf6eecfe09cae977687491fb3f618b +size 2264 diff --git a/assets/voxygen/voxel/figure/hair/human/male-20.vox b/assets/voxygen/voxel/figure/hair/human/male-20.vox index dac3a25e4e..1da5dee387 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-20.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-20.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c42e7da38ad6ef36e53c1fcfae73531f1dbf8adbf83b96a0f0f2981a248a5b7 -size 57026 +oid sha256:ef37ee588aa533263b94c0ccf0f81d303769530c4f606af4008928cf5b7331aa +size 2548 diff --git a/assets/voxygen/voxel/figure/hair/human/male-3.vox b/assets/voxygen/voxel/figure/hair/human/male-3.vox index 800d130ac8..fb06e14504 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-3.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7246ae4b8923b7eae180652d54a3e39f4bdbfa60585e84188874329c14e1d80c -size 57467 +oid sha256:3613c4c7bfd6018592f19376dd1f676928b6e603e7ee4c03483bc2466a5ec0a7 +size 2984 diff --git a/assets/voxygen/voxel/figure/hair/human/male-4.vox b/assets/voxygen/voxel/figure/hair/human/male-4.vox index 2b7a141222..2aca26fc08 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-4.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5f0ad3e0ac733f2c414f58975d9f3fe2c85d73fff709076826314151a1796c30 -size 56048 +oid sha256:f32db1626a76cad31ac5f6fd2434ba72dcae52951db6cb82bda903e849d82c06 +size 1568 diff --git a/assets/voxygen/voxel/figure/hair/human/male-5.vox b/assets/voxygen/voxel/figure/hair/human/male-5.vox index 07f1f501ba..648933841f 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-5.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:21bf17855229947784a3747d7385f646b72e7f9ab8cb289bef0d1e0719b98bad -size 56488 +oid sha256:65875c093e8b3a74b519f914d4e2f309f1e29dda003ae54c10eee21f5f1d1b7b +size 2008 diff --git a/assets/voxygen/voxel/figure/hair/human/male-6.vox b/assets/voxygen/voxel/figure/hair/human/male-6.vox index e010d18efd..72297429b2 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-6.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:658ac65e350c7a046d23e301a8d79153d198004fe4f0722accc443722e627e34 -size 58757 +oid sha256:12632fd6ca5195b45aa9c4239adbf467a4db0d558cfd9b5120ee5d70d90c8da8 +size 1884 diff --git a/assets/voxygen/voxel/figure/hair/human/male-7.vox b/assets/voxygen/voxel/figure/hair/human/male-7.vox index c5a8e712ef..f628b67325 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-7.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:09d1a2f620519b6c3c521bfb677f9b25362f893652b0b74929ec4f19fd4ee6cd -size 56420 +oid sha256:5bb469b98425dd33c26d9be23f13105b1fb14db595989df049e537d2ced6376c +size 1940 diff --git a/assets/voxygen/voxel/figure/hair/human/male-8.vox b/assets/voxygen/voxel/figure/hair/human/male-8.vox index 6e02c54ffb..ce47363876 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-8.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:12c07dd532873a363d3349d0cb8c1541c9d56f4de13adbf22316015e8b00a42e -size 56544 +oid sha256:4c71bbdda80e344851d8ac8fc6287ff59160b24eefcff63d4b04309ac868cc3d +size 2064 diff --git a/assets/voxygen/voxel/figure/hair/human/male-9.vox b/assets/voxygen/voxel/figure/hair/human/male-9.vox index cef5679567..7004e8d0c2 100644 --- a/assets/voxygen/voxel/figure/hair/human/male-9.vox +++ b/assets/voxygen/voxel/figure/hair/human/male-9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bbf19442d4a77053591d89623ea69d31088ab3427ac339037669fc1dc2c62851 -size 56216 +oid sha256:2ceb3f931065997603972c458252fc7790cc6bf9c6cb2cebff572c5aedc0c5c2 +size 1736 diff --git a/assets/voxygen/voxel/figure/hair/orc/female-0.vox b/assets/voxygen/voxel/figure/hair/orc/female-0.vox index 504d5a244e..8a0b886359 100644 --- a/assets/voxygen/voxel/figure/hair/orc/female-0.vox +++ b/assets/voxygen/voxel/figure/hair/orc/female-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:722ff5a49bd37bbc2da3cc1e6ea1f19b2ad38d88fede8dd5c96355a1269009fc -size 58642 +oid sha256:6e8513b0166f1b666b3f30387b698a36cdc4f0e8f1b40ffe08e66bb1f8a067ba +size 1840 diff --git a/assets/voxygen/voxel/figure/hair/orc/female-1.vox b/assets/voxygen/voxel/figure/hair/orc/female-1.vox index 1af8813a08..1d8151a08e 100644 --- a/assets/voxygen/voxel/figure/hair/orc/female-1.vox +++ b/assets/voxygen/voxel/figure/hair/orc/female-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:43b5e82e7fa965429288b1e6985e4449edc9e6a4b8d7386187d62153fd79d630 -size 58266 +oid sha256:77c1d8c6dfa1fa87c7cc55fa09770805d13bde44e20504eb0d0eb0fadd607964 +size 1464 diff --git a/assets/voxygen/voxel/figure/hair/orc/female-2.vox b/assets/voxygen/voxel/figure/hair/orc/female-2.vox index cf5f854aef..f345a4f5ec 100644 --- a/assets/voxygen/voxel/figure/hair/orc/female-2.vox +++ b/assets/voxygen/voxel/figure/hair/orc/female-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4bc1d189819717568b92fc327e98d6c4c096cbe28eeb7595688137a5055a497a -size 58810 +oid sha256:b827cbf9db4d3d32ff41ac5d8b59e167075f17f645637de3b18a19464927bbc9 +size 2008 diff --git a/assets/voxygen/voxel/figure/hair/orc/female-3.vox b/assets/voxygen/voxel/figure/hair/orc/female-3.vox index 496c9266d2..4c6003d01e 100644 --- a/assets/voxygen/voxel/figure/hair/orc/female-3.vox +++ b/assets/voxygen/voxel/figure/hair/orc/female-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:71ebeb3025d03aa0300a9ce1924932faa5616451e726aa72e573b2aaf2a283b4 -size 59946 +oid sha256:0a75131b529cffd94b2e8c805c12bbf1bd3192a869dae0aef2cdafa94375a79d +size 3136 diff --git a/assets/voxygen/voxel/figure/hair/orc/female-4.vox b/assets/voxygen/voxel/figure/hair/orc/female-4.vox index b38b1b738c..e4d645dbe3 100644 --- a/assets/voxygen/voxel/figure/hair/orc/female-4.vox +++ b/assets/voxygen/voxel/figure/hair/orc/female-4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0032b74cd99c530ff56872324407353fb84b524e03bca1617ed88ab1e61978ba -size 58378 +oid sha256:6a44e8d31745129f38735413e272e40add8962d1255abd0d0ca73b6f046b8401 +size 1576 diff --git a/assets/voxygen/voxel/figure/hair/orc/female-5.vox b/assets/voxygen/voxel/figure/hair/orc/female-5.vox index c2513264c0..c3f9b229d6 100644 --- a/assets/voxygen/voxel/figure/hair/orc/female-5.vox +++ b/assets/voxygen/voxel/figure/hair/orc/female-5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6f2c75b22f7587adb3960ac15db9841bd249f0fee37fabd3de0859a8e27a0eca -size 60158 +oid sha256:b22d1657dcbf09109168c8ac565aa049a2cc00b529c39840fa7f452e1e54ba91 +size 3348 diff --git a/assets/voxygen/voxel/figure/hair/orc/female-6.vox b/assets/voxygen/voxel/figure/hair/orc/female-6.vox index bbfcfc7b23..362af34643 100644 --- a/assets/voxygen/voxel/figure/hair/orc/female-6.vox +++ b/assets/voxygen/voxel/figure/hair/orc/female-6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:54950e3b327e36e547467518511baaf04cb99a282488e7da45db88eccba8d7e0 -size 59566 +oid sha256:e35d4a7a3f12e59cc16cbfa36c1f07ee34beaae66ed3a3ef22408a16b0aebc97 +size 2756 diff --git a/assets/voxygen/voxel/figure/hair/orc/male-0.vox b/assets/voxygen/voxel/figure/hair/orc/male-0.vox index 4b5acbada3..b2f875cbae 100644 --- a/assets/voxygen/voxel/figure/hair/orc/male-0.vox +++ b/assets/voxygen/voxel/figure/hair/orc/male-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:393785a5fe056830402ef38e3e3c20d6dee7373b0b48d2331b97d712cfe82dc0 -size 56067 +oid sha256:2e1d5544f54b8ca06619965bc3ef8142a8c140024a2c38bc6ccf6a61d2d1dc5c +size 1584 diff --git a/assets/voxygen/voxel/figure/hair/orc/male-1.vox b/assets/voxygen/voxel/figure/hair/orc/male-1.vox index 9820089eb4..3f56d06ddf 100644 --- a/assets/voxygen/voxel/figure/hair/orc/male-1.vox +++ b/assets/voxygen/voxel/figure/hair/orc/male-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3911e0ac35fc471bd3b13d00be925aef393c74ba6154119dc22b0622c769e484 -size 56554 +oid sha256:ecf277433dd8023f2e8d48a6d792597a37d0ec556122c55d2747a828fe42580d +size 2032 diff --git a/assets/voxygen/voxel/figure/hair/orc/male-2.vox b/assets/voxygen/voxel/figure/hair/orc/male-2.vox index a4302b8d6f..82a8db4dab 100644 --- a/assets/voxygen/voxel/figure/hair/orc/male-2.vox +++ b/assets/voxygen/voxel/figure/hair/orc/male-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f6d6d31fc96b07cc7ff4dd916d0d0c9cc4b29305a42c12f12225843e70df0126 -size 56399 +oid sha256:6f492d4568ebcffb8ddc6e9dc2ad4d60a2fb26da07dedc074ab5c5a8ad1b6d18 +size 1876 diff --git a/assets/voxygen/voxel/figure/hair/orc/male-3.vox b/assets/voxygen/voxel/figure/hair/orc/male-3.vox index d095f82fc4..b01b5a0035 100644 --- a/assets/voxygen/voxel/figure/hair/orc/male-3.vox +++ b/assets/voxygen/voxel/figure/hair/orc/male-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:47b7919e337153e35bc5b3075edffef23847a93cf956cdd1993c27871b559810 -size 56527 +oid sha256:598472d24ee293ec70eacf044b858ade57bc463ea0686bb3e624e655427f76b6 +size 2004 diff --git a/assets/voxygen/voxel/figure/hair/orc/male-4.vox b/assets/voxygen/voxel/figure/hair/orc/male-4.vox index 5c7b40de06..eeb3a067ea 100644 --- a/assets/voxygen/voxel/figure/hair/orc/male-4.vox +++ b/assets/voxygen/voxel/figure/hair/orc/male-4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ac19295ce12b7c9da1cf54b6ca0a44dac60a846131f234f09fa441495af16c00 -size 56083 +oid sha256:3aa93b8d72347f767e7ac426031588cb8dcb2ac1783a01fef229586e55b23810 +size 1560 diff --git a/assets/voxygen/voxel/figure/hair/orc/male-5.vox b/assets/voxygen/voxel/figure/hair/orc/male-5.vox index 75d77a361b..cbd2aa387d 100644 --- a/assets/voxygen/voxel/figure/hair/orc/male-5.vox +++ b/assets/voxygen/voxel/figure/hair/orc/male-5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:40d35793c6273fd3e0df04d78317b6973a326a0e884f19b937e1d916928359f5 -size 55875 +oid sha256:fc434af16b04768ae07a8052d1106b847dfca0a13eba0f0f61aaf8a3ae245108 +size 1352 diff --git a/assets/voxygen/voxel/figure/hair/orc/male-6.vox b/assets/voxygen/voxel/figure/hair/orc/male-6.vox index 2c97b71641..9005904b48 100644 --- a/assets/voxygen/voxel/figure/hair/orc/male-6.vox +++ b/assets/voxygen/voxel/figure/hair/orc/male-6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c047a63a9a8db66dd509ad357aa700344088c0d2bcc6e5df135a60f5604bdb99 -size 56515 +oid sha256:c9e3b4ae37c06dc30927dca14111b22ab8331c21cb36f4802a3ab1f180dfa990 +size 2004 diff --git a/assets/voxygen/voxel/figure/hair/undead/female-1.vox b/assets/voxygen/voxel/figure/hair/undead/female-1.vox index 1383440cac..144b5d96f6 100644 --- a/assets/voxygen/voxel/figure/hair/undead/female-1.vox +++ b/assets/voxygen/voxel/figure/hair/undead/female-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:98d421448617831a503fac225f7700b5df682cada8a6f71bfb8686cfca420594 -size 57499 +oid sha256:acd22b0a08cf9957c6ccd753bb42ea28416f03cb94a7992cd627021c1a701d03 +size 3016 diff --git a/assets/voxygen/voxel/figure/hair/undead/female-2.vox b/assets/voxygen/voxel/figure/hair/undead/female-2.vox index 1c11a21c1f..21e4a2ff84 100644 --- a/assets/voxygen/voxel/figure/hair/undead/female-2.vox +++ b/assets/voxygen/voxel/figure/hair/undead/female-2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:886e9c3d5e63bc4310fe21c6e6cd46edc0ff9e8f48c41fcf8ee123e304f8798e -size 56392 +oid sha256:9cbd8d99641825f711f10e79107f5b1a81a232e957243e470e65b334a37a9c2f +size 1880 diff --git a/assets/voxygen/voxel/figure/hair/undead/female-3.vox b/assets/voxygen/voxel/figure/hair/undead/female-3.vox index ad7e613302..f3ddccc5f1 100644 --- a/assets/voxygen/voxel/figure/hair/undead/female-3.vox +++ b/assets/voxygen/voxel/figure/hair/undead/female-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d629f9b892301c4c5f4ee9bf261f60769ee8ab9f06ddff3a65cbe920a4e5ad30 -size 56406 +oid sha256:0c5c991cc7fb399e2a33293aa3aefaf659aa45027701c1e05bd5bd7a6a1d70ff +size 1892 diff --git a/assets/voxygen/voxel/figure/hair/undead/male-1.vox b/assets/voxygen/voxel/figure/hair/undead/male-1.vox index b238461fde..5edc433b8c 100644 --- a/assets/voxygen/voxel/figure/hair/undead/male-1.vox +++ b/assets/voxygen/voxel/figure/hair/undead/male-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:254102f083bd647ffc735221a91be002e2237d505ff9840ef605c69f59285e6a -size 55895 +oid sha256:d13b6572d9a830d3fc02f4254ef368b340d9d85c5d307875a993a0eecd29572d +size 1412 diff --git a/assets/voxygen/voxel/figure/head/danari/female.vox b/assets/voxygen/voxel/figure/head/danari/female.vox index acb8a39990..8868d56f30 100644 --- a/assets/voxygen/voxel/figure/head/danari/female.vox +++ b/assets/voxygen/voxel/figure/head/danari/female.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6afe627cf97d5bf0fd3982f9a390a5aac74bb2f9048eafdc984edcef5147045b -size 57731 +oid sha256:5b10d54c8bef697cb5d34fe313d1e744a47c4588de1c281dde5b629ed88b045f +size 3248 diff --git a/assets/voxygen/voxel/figure/head/danari/male.vox b/assets/voxygen/voxel/figure/head/danari/male.vox index 2937aace25..22decee560 100644 --- a/assets/voxygen/voxel/figure/head/danari/male.vox +++ b/assets/voxygen/voxel/figure/head/danari/male.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dcddfd3a9045dc01518318c8abf21c896384cf4ac1b395fc198f66e48e51272e -size 57747 +oid sha256:903282a49a23745bed03fcc7271dd9cf8b704229deeb172fe223f6929871981d +size 3264 diff --git a/assets/voxygen/voxel/figure/head/dwarf/female.vox b/assets/voxygen/voxel/figure/head/dwarf/female.vox index e3242ef85e..2984389c8a 100644 --- a/assets/voxygen/voxel/figure/head/dwarf/female.vox +++ b/assets/voxygen/voxel/figure/head/dwarf/female.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9678639c8662bbd2ab8c5979dfaa383f5fa5983d2472eb566b3c147365d2ab90 -size 57531 +oid sha256:a7bd7d802ee07b5784c5d7c672a488efd3e70ed2fec974ba806e37f842732094 +size 3048 diff --git a/assets/voxygen/voxel/figure/head/dwarf/male.vox b/assets/voxygen/voxel/figure/head/dwarf/male.vox index 7c5ae68e07..8bab58bd76 100644 --- a/assets/voxygen/voxel/figure/head/dwarf/male.vox +++ b/assets/voxygen/voxel/figure/head/dwarf/male.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04e5bb53701ad6bcb95b383de6df28900d0c210560a40c70f47aabde98a3ac14 -size 57539 +oid sha256:4e8d32cbc846775bc86184df4865bf01057b91fe8b4a9dd0d891129e29d6771b +size 3056 diff --git a/assets/voxygen/voxel/figure/head/elf/female.vox b/assets/voxygen/voxel/figure/head/elf/female.vox index 1827c5676d..35b451df5a 100644 --- a/assets/voxygen/voxel/figure/head/elf/female.vox +++ b/assets/voxygen/voxel/figure/head/elf/female.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:249a73e5a3118dde82784e30daa14615c6b8340fadd2628b7e776ed586c149a2 -size 57851 +oid sha256:c8a9917cb6c018de09704a5b2c1244814a1f8b9c06702752a3d2c888cf7dea43 +size 3368 diff --git a/assets/voxygen/voxel/figure/head/elf/male.vox b/assets/voxygen/voxel/figure/head/elf/male.vox index e050f7ed04..bc33a011e0 100644 --- a/assets/voxygen/voxel/figure/head/elf/male.vox +++ b/assets/voxygen/voxel/figure/head/elf/male.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:75d03a797e76f9db75d3d98c991244042ea0295cf364abc28455f6a61be3d9a1 -size 57827 +oid sha256:1271ff8991fecd5ee1b12aad07877c54528e10f63d3dbfb2c7263f3efe705284 +size 3344 diff --git a/assets/voxygen/voxel/figure/head/human/female.vox b/assets/voxygen/voxel/figure/head/human/female.vox index 95943bfd01..f6e3d34884 100644 --- a/assets/voxygen/voxel/figure/head/human/female.vox +++ b/assets/voxygen/voxel/figure/head/human/female.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9c278d0c3aa53c002df0261830ff8637da77f68743841d7160d13f69275694ca -size 57827 +oid sha256:1297599c2467ce610c7a0d902be69e648e53dbf7034a3defe5ed06f1b1c77d34 +size 3344 diff --git a/assets/voxygen/voxel/figure/head/human/male.vox b/assets/voxygen/voxel/figure/head/human/male.vox index 4cf9b53885..6e9ffab9d0 100644 --- a/assets/voxygen/voxel/figure/head/human/male.vox +++ b/assets/voxygen/voxel/figure/head/human/male.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2323f14bcb9f26f96e4e8df8b164e2fbf6de7aaa59ee787f3130d2d0985c883d -size 57819 +oid sha256:1fdf5705ef1376f43a1ff147dd6539209c7cd759d0075693b493439fbc8a4cc2 +size 3336 diff --git a/assets/voxygen/voxel/figure/head/orc/female.vox b/assets/voxygen/voxel/figure/head/orc/female.vox index 2f95c47a23..309f3bfe66 100644 --- a/assets/voxygen/voxel/figure/head/orc/female.vox +++ b/assets/voxygen/voxel/figure/head/orc/female.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b788a472ced0a98d6bcab4f1b5c46068d3f30b966709921bd3d7db30f2d365a -size 57737 +oid sha256:a5ed0b6d1c545b7a24a92f0cb5a481736c50263f43f93276bb4813452d7223e2 +size 3216 diff --git a/assets/voxygen/voxel/figure/head/orc/male.vox b/assets/voxygen/voxel/figure/head/orc/male.vox index 6277f12885..b84af7b9b3 100644 --- a/assets/voxygen/voxel/figure/head/orc/male.vox +++ b/assets/voxygen/voxel/figure/head/orc/male.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c37c8abe7bac77d4a2b3f5c5771c53a8d117fb978b813f28374f3c4c391f446b -size 57846 +oid sha256:f5735aa6e4facad62b3e5fffed8c70f9c54acf95f1d326624cb6b7a1d9e8c535 +size 3308 diff --git a/assets/voxygen/voxel/figure/head/undead/female.vox b/assets/voxygen/voxel/figure/head/undead/female.vox index 87ff3b858e..9dc1d84f33 100644 --- a/assets/voxygen/voxel/figure/head/undead/female.vox +++ b/assets/voxygen/voxel/figure/head/undead/female.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0916b4f848e9c68fd67b25c86ec153b6c341e6e4169f54836c6146667087ed66 -size 57783 +oid sha256:0f7e459f4f4f5acc312d533650b6d207ab74a4a90ce6ab9c92f0c24845a81691 +size 3300 diff --git a/assets/voxygen/voxel/figure/head/undead/male.vox b/assets/voxygen/voxel/figure/head/undead/male.vox index b843358682..e28b12e47d 100644 --- a/assets/voxygen/voxel/figure/head/undead/male.vox +++ b/assets/voxygen/voxel/figure/head/undead/male.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7a881c157cd16c49e0bdcee82308a563f38d88d1d4061defed1c4580225e31e4 -size 57499 +oid sha256:d1cb58732a4086bf5f48f727d800de2bed3230b87c975f38dbc30044715fb3eb +size 3016 diff --git a/assets/voxygen/voxel/fixture/selection_bg.vox b/assets/voxygen/voxel/fixture/selection_bg.vox index 52af3cfac2..ad322ea087 100644 --- a/assets/voxygen/voxel/fixture/selection_bg.vox +++ b/assets/voxygen/voxel/fixture/selection_bg.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1ecf2cfd0b8dee28998263b4e823b9175906d724ff053d0f7c7c95f7cd427865 -size 650331 +oid sha256:cf4c380f75e788fe67c6f3673e0c638eb4ff467f512b73a6a57dd371e0c14ef8 +size 595564 diff --git a/assets/voxygen/voxel/npc/eagle/female/leg_l.vox b/assets/voxygen/voxel/npc/eagle/female/leg_l.vox index 38e5e2c5c6..31b8befb4f 100644 --- a/assets/voxygen/voxel/npc/eagle/female/leg_l.vox +++ b/assets/voxygen/voxel/npc/eagle/female/leg_l.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b6e82c2c806c245f8fdebb830b0763a1aa796593c041ad4ace556c8e413f5aa9 -size 55651 +oid sha256:30a26bcede8cd210e71cc743ce08cc29ff76df8b55be39ca81ba1ac93d20d909 +size 1168 diff --git a/assets/voxygen/voxel/npc/eagle/female/leg_r.vox b/assets/voxygen/voxel/npc/eagle/female/leg_r.vox index a2ec2f7233..fdf449ec92 100644 --- a/assets/voxygen/voxel/npc/eagle/female/leg_r.vox +++ b/assets/voxygen/voxel/npc/eagle/female/leg_r.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ecb3129efdb691a6b81d691bd34e01920bf0c9703d9e76bd6fafaeac978146f -size 55651 +oid sha256:e5bda2e9383f59ec4317f8e3c57175fe2acafa5a067fa8c9c1eef9e4650fef46 +size 1168 diff --git a/assets/voxygen/voxel/npc/eagle/female/tail.vox b/assets/voxygen/voxel/npc/eagle/female/tail.vox index f7bfb10410..1d805965b7 100644 --- a/assets/voxygen/voxel/npc/eagle/female/tail.vox +++ b/assets/voxygen/voxel/npc/eagle/female/tail.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:10fe121790e8434a04bcfc1288693d8ac30171aa991a15e7533fcb62290e2368 -size 55675 +oid sha256:615dc2933805af3f0be6241021305ef5da3490d28e3774bf83d8030e5ef966db +size 1192 diff --git a/assets/voxygen/voxel/npc/eagle/female/torso.vox b/assets/voxygen/voxel/npc/eagle/female/torso.vox index c299b03331..17a4a09ea4 100644 --- a/assets/voxygen/voxel/npc/eagle/female/torso.vox +++ b/assets/voxygen/voxel/npc/eagle/female/torso.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0f2df57bf231b5cdf34ce748f51394bc5fa67fff021244408babd2fbb40ce7f3 -size 56619 +oid sha256:8a7bf5e7a20fc8b2a924eee317123760f9ceba4f714e1a5ad6e34735111b634c +size 2136 diff --git a/assets/voxygen/voxel/npc/eagle/female/wing_l.vox b/assets/voxygen/voxel/npc/eagle/female/wing_l.vox index c989207c3c..71dbf9a9b8 100644 --- a/assets/voxygen/voxel/npc/eagle/female/wing_l.vox +++ b/assets/voxygen/voxel/npc/eagle/female/wing_l.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e9c4bc7aac5811e9189116501858b5a1cf12187e6e08d6798e6810c04154ffdf -size 56027 +oid sha256:5a8c4852cb663caf77805a111f8b4d8ae27b17bf5819e281d3f1b3d6f0866250 +size 1532 diff --git a/assets/voxygen/voxel/npc/eagle/female/wing_r.vox b/assets/voxygen/voxel/npc/eagle/female/wing_r.vox index b2aa360724..53ddbe5680 100644 --- a/assets/voxygen/voxel/npc/eagle/female/wing_r.vox +++ b/assets/voxygen/voxel/npc/eagle/female/wing_r.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65369f781827ace2267b450a5c40027748f1077a1245d5493c166571349af727 -size 56027 +oid sha256:4a9efd962517729b3aaedebf4d8bb08914885670edd5fbb134f49f28cf837c2f +size 1532 diff --git a/assets/voxygen/voxel/npc/eagle/male/leg_l.vox b/assets/voxygen/voxel/npc/eagle/male/leg_l.vox index 38e5e2c5c6..31b8befb4f 100644 --- a/assets/voxygen/voxel/npc/eagle/male/leg_l.vox +++ b/assets/voxygen/voxel/npc/eagle/male/leg_l.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b6e82c2c806c245f8fdebb830b0763a1aa796593c041ad4ace556c8e413f5aa9 -size 55651 +oid sha256:30a26bcede8cd210e71cc743ce08cc29ff76df8b55be39ca81ba1ac93d20d909 +size 1168 diff --git a/assets/voxygen/voxel/npc/eagle/male/leg_r.vox b/assets/voxygen/voxel/npc/eagle/male/leg_r.vox index a2ec2f7233..fdf449ec92 100644 --- a/assets/voxygen/voxel/npc/eagle/male/leg_r.vox +++ b/assets/voxygen/voxel/npc/eagle/male/leg_r.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ecb3129efdb691a6b81d691bd34e01920bf0c9703d9e76bd6fafaeac978146f -size 55651 +oid sha256:e5bda2e9383f59ec4317f8e3c57175fe2acafa5a067fa8c9c1eef9e4650fef46 +size 1168 diff --git a/assets/voxygen/voxel/npc/eagle/male/tail.vox b/assets/voxygen/voxel/npc/eagle/male/tail.vox index f7bfb10410..1d805965b7 100644 --- a/assets/voxygen/voxel/npc/eagle/male/tail.vox +++ b/assets/voxygen/voxel/npc/eagle/male/tail.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:10fe121790e8434a04bcfc1288693d8ac30171aa991a15e7533fcb62290e2368 -size 55675 +oid sha256:615dc2933805af3f0be6241021305ef5da3490d28e3774bf83d8030e5ef966db +size 1192 diff --git a/assets/voxygen/voxel/npc/eagle/male/torso.vox b/assets/voxygen/voxel/npc/eagle/male/torso.vox index c299b03331..17a4a09ea4 100644 --- a/assets/voxygen/voxel/npc/eagle/male/torso.vox +++ b/assets/voxygen/voxel/npc/eagle/male/torso.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0f2df57bf231b5cdf34ce748f51394bc5fa67fff021244408babd2fbb40ce7f3 -size 56619 +oid sha256:8a7bf5e7a20fc8b2a924eee317123760f9ceba4f714e1a5ad6e34735111b634c +size 2136 diff --git a/assets/voxygen/voxel/npc/eagle/male/wing_l.vox b/assets/voxygen/voxel/npc/eagle/male/wing_l.vox index c989207c3c..71dbf9a9b8 100644 --- a/assets/voxygen/voxel/npc/eagle/male/wing_l.vox +++ b/assets/voxygen/voxel/npc/eagle/male/wing_l.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e9c4bc7aac5811e9189116501858b5a1cf12187e6e08d6798e6810c04154ffdf -size 56027 +oid sha256:5a8c4852cb663caf77805a111f8b4d8ae27b17bf5819e281d3f1b3d6f0866250 +size 1532 diff --git a/assets/voxygen/voxel/npc/eagle/male/wing_r.vox b/assets/voxygen/voxel/npc/eagle/male/wing_r.vox index b2aa360724..53ddbe5680 100644 --- a/assets/voxygen/voxel/npc/eagle/male/wing_r.vox +++ b/assets/voxygen/voxel/npc/eagle/male/wing_r.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65369f781827ace2267b450a5c40027748f1077a1245d5493c166571349af727 -size 56027 +oid sha256:4a9efd962517729b3aaedebf4d8bb08914885670edd5fbb134f49f28cf837c2f +size 1532 diff --git a/assets/voxygen/voxel/npc/oger/hand-l.vox b/assets/voxygen/voxel/npc/oger/hand-l.vox index 605d6363f9..bdccb7e17c 100644 --- a/assets/voxygen/voxel/npc/oger/hand-l.vox +++ b/assets/voxygen/voxel/npc/oger/hand-l.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:64beb9f9cabf9cd887b8fe7d6323bdf0908063359809e2c18da58733fb9b82bc -size 44439 +oid sha256:08ccc11c9c68ab06d320a75f9e90edb9f969e31c3935c2effec650065642a6da +size 1332 diff --git a/assets/voxygen/voxel/npc/wolf/female/ears.vox b/assets/voxygen/voxel/npc/wolf/female/ears.vox index b7c6231844..4b24762f6f 100644 --- a/assets/voxygen/voxel/npc/wolf/female/ears.vox +++ b/assets/voxygen/voxel/npc/wolf/female/ears.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:85da6b879004886b43a159a04b65417ab5d2ce7025f40ddf840f6a6099bd7e0a -size 44307 +oid sha256:91cf8e0b2c7598c5aff97e7c5e298b72ca3d4c1bb856e3aa27f4da069851cde6 +size 1200 diff --git a/assets/voxygen/voxel/npc/wolf/female/foot_lf.vox b/assets/voxygen/voxel/npc/wolf/female/foot_lf.vox index 7c5c2e8b64..647177db46 100644 --- a/assets/voxygen/voxel/npc/wolf/female/foot_lf.vox +++ b/assets/voxygen/voxel/npc/wolf/female/foot_lf.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9f24f04d38cceb52344d33de69baeead27cb50fec15c6ef80d6115a4be6a419f -size 44451 +oid sha256:c95b0a86d6e29ba1235df27cf3f9f9807fe69b1725f005e197b3283075d858af +size 1344 diff --git a/assets/voxygen/voxel/npc/wolf/female/foot_rf.vox b/assets/voxygen/voxel/npc/wolf/female/foot_rf.vox index 5473932907..bed2196da8 100644 --- a/assets/voxygen/voxel/npc/wolf/female/foot_rf.vox +++ b/assets/voxygen/voxel/npc/wolf/female/foot_rf.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a0e5984c410c1cf6891ae966541e25eb19ffefb56a2bf82d0d762c9d4b5464b0 -size 44451 +oid sha256:5280204a15fcc66257d5240c2a31f93ef6a081b9bd2195d1cf89cd9199cd1bfb +size 1344 diff --git a/assets/voxygen/voxel/npc/wolf/female/head_lower.vox b/assets/voxygen/voxel/npc/wolf/female/head_lower.vox index 51bfcf9e2d..fccf4fecdf 100644 --- a/assets/voxygen/voxel/npc/wolf/female/head_lower.vox +++ b/assets/voxygen/voxel/npc/wolf/female/head_lower.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:77d567a024aabc463b938e662f0340d1d88a62686950e12cdd583039fd32b893 -size 46691 +oid sha256:c4b4b8ebb5db40ffbb8007c07cd832132ab18153f3aeeefb6c10638317e5d5bd +size 3584 diff --git a/assets/voxygen/voxel/npc/wolf/female/head_upper.vox b/assets/voxygen/voxel/npc/wolf/female/head_upper.vox index f750396fb1..61236f7f75 100644 --- a/assets/voxygen/voxel/npc/wolf/female/head_upper.vox +++ b/assets/voxygen/voxel/npc/wolf/female/head_upper.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:649ef3c87c3505e8599c75726236ff8e9d13caedd0bdec1155bd437cb486425f -size 47755 +oid sha256:8a7af96a369d3e9c94f331738360dab9bcc72feaa3bc5bb40771a908338ed6c9 +size 4648 diff --git a/assets/voxygen/voxel/npc/wolf/female/jaw.vox b/assets/voxygen/voxel/npc/wolf/female/jaw.vox index df6a3470b6..e7b1e1b2b6 100644 --- a/assets/voxygen/voxel/npc/wolf/female/jaw.vox +++ b/assets/voxygen/voxel/npc/wolf/female/jaw.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3190632201cc65f1a57b944cc07fd182ae3eceec2fc2852ffb3da3cd1a02d53e -size 44387 +oid sha256:9ad7e4b713398aa999a59718ed00363b1fd77e211dc5fef292a697f4eb873e69 +size 1280 diff --git a/assets/voxygen/voxel/npc/wolf/female/tail.vox b/assets/voxygen/voxel/npc/wolf/female/tail.vox index 3cbae3bb41..7fccdc8c1d 100644 --- a/assets/voxygen/voxel/npc/wolf/female/tail.vox +++ b/assets/voxygen/voxel/npc/wolf/female/tail.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:25d41aef2c2b86c287b46ba301c8009c010750fa6c892e778ba76605c7055544 -size 44779 +oid sha256:51f6077b009e3b66cb96b536780f3219bb4cdab8ba1584700c1e3febedc93161 +size 1672 diff --git a/assets/voxygen/voxel/npc/wolf/female/torso_back.vox b/assets/voxygen/voxel/npc/wolf/female/torso_back.vox index fbcf070931..f943384c01 100644 --- a/assets/voxygen/voxel/npc/wolf/female/torso_back.vox +++ b/assets/voxygen/voxel/npc/wolf/female/torso_back.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:393e513cb20d41b71e093a782938b33ed1dae801e19875342b2db72c5e964782 -size 48667 +oid sha256:13613d30abe1f4c3fadd57dc726a010e93c3e831a36ad5e374974d167f0bc161 +size 5560 diff --git a/assets/voxygen/voxel/npc/wolf/female/torso_front.vox b/assets/voxygen/voxel/npc/wolf/female/torso_front.vox index d2e23b9d34..0bfd40e870 100644 --- a/assets/voxygen/voxel/npc/wolf/female/torso_front.vox +++ b/assets/voxygen/voxel/npc/wolf/female/torso_front.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0c555e7dd857f908b787a53118d17d908a96762e3fe10f63a692d2969ac67eb5 -size 48863 +oid sha256:9146b97a1d8f3a9e1574c9aecfe7561b900dfa23bb3ceefe267c50a98c78d937 +size 5756 diff --git a/assets/voxygen/voxel/npc/wolf/male/ears.vox b/assets/voxygen/voxel/npc/wolf/male/ears.vox index b7c6231844..4b24762f6f 100644 --- a/assets/voxygen/voxel/npc/wolf/male/ears.vox +++ b/assets/voxygen/voxel/npc/wolf/male/ears.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:85da6b879004886b43a159a04b65417ab5d2ce7025f40ddf840f6a6099bd7e0a -size 44307 +oid sha256:91cf8e0b2c7598c5aff97e7c5e298b72ca3d4c1bb856e3aa27f4da069851cde6 +size 1200 diff --git a/assets/voxygen/voxel/npc/wolf/male/foot_lf.vox b/assets/voxygen/voxel/npc/wolf/male/foot_lf.vox index 7c5c2e8b64..647177db46 100644 --- a/assets/voxygen/voxel/npc/wolf/male/foot_lf.vox +++ b/assets/voxygen/voxel/npc/wolf/male/foot_lf.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9f24f04d38cceb52344d33de69baeead27cb50fec15c6ef80d6115a4be6a419f -size 44451 +oid sha256:c95b0a86d6e29ba1235df27cf3f9f9807fe69b1725f005e197b3283075d858af +size 1344 diff --git a/assets/voxygen/voxel/npc/wolf/male/foot_rf.vox b/assets/voxygen/voxel/npc/wolf/male/foot_rf.vox index 5473932907..bed2196da8 100644 --- a/assets/voxygen/voxel/npc/wolf/male/foot_rf.vox +++ b/assets/voxygen/voxel/npc/wolf/male/foot_rf.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a0e5984c410c1cf6891ae966541e25eb19ffefb56a2bf82d0d762c9d4b5464b0 -size 44451 +oid sha256:5280204a15fcc66257d5240c2a31f93ef6a081b9bd2195d1cf89cd9199cd1bfb +size 1344 diff --git a/assets/voxygen/voxel/npc/wolf/male/head_lower.vox b/assets/voxygen/voxel/npc/wolf/male/head_lower.vox index 51bfcf9e2d..fccf4fecdf 100644 --- a/assets/voxygen/voxel/npc/wolf/male/head_lower.vox +++ b/assets/voxygen/voxel/npc/wolf/male/head_lower.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:77d567a024aabc463b938e662f0340d1d88a62686950e12cdd583039fd32b893 -size 46691 +oid sha256:c4b4b8ebb5db40ffbb8007c07cd832132ab18153f3aeeefb6c10638317e5d5bd +size 3584 diff --git a/assets/voxygen/voxel/npc/wolf/male/head_upper.vox b/assets/voxygen/voxel/npc/wolf/male/head_upper.vox index f750396fb1..61236f7f75 100644 --- a/assets/voxygen/voxel/npc/wolf/male/head_upper.vox +++ b/assets/voxygen/voxel/npc/wolf/male/head_upper.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:649ef3c87c3505e8599c75726236ff8e9d13caedd0bdec1155bd437cb486425f -size 47755 +oid sha256:8a7af96a369d3e9c94f331738360dab9bcc72feaa3bc5bb40771a908338ed6c9 +size 4648 diff --git a/assets/voxygen/voxel/npc/wolf/male/jaw.vox b/assets/voxygen/voxel/npc/wolf/male/jaw.vox index df6a3470b6..e7b1e1b2b6 100644 --- a/assets/voxygen/voxel/npc/wolf/male/jaw.vox +++ b/assets/voxygen/voxel/npc/wolf/male/jaw.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3190632201cc65f1a57b944cc07fd182ae3eceec2fc2852ffb3da3cd1a02d53e -size 44387 +oid sha256:9ad7e4b713398aa999a59718ed00363b1fd77e211dc5fef292a697f4eb873e69 +size 1280 diff --git a/assets/voxygen/voxel/npc/wolf/male/tail.vox b/assets/voxygen/voxel/npc/wolf/male/tail.vox index 3cbae3bb41..7fccdc8c1d 100644 --- a/assets/voxygen/voxel/npc/wolf/male/tail.vox +++ b/assets/voxygen/voxel/npc/wolf/male/tail.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:25d41aef2c2b86c287b46ba301c8009c010750fa6c892e778ba76605c7055544 -size 44779 +oid sha256:51f6077b009e3b66cb96b536780f3219bb4cdab8ba1584700c1e3febedc93161 +size 1672 diff --git a/assets/voxygen/voxel/npc/wolf/male/torso_back.vox b/assets/voxygen/voxel/npc/wolf/male/torso_back.vox index fbcf070931..f943384c01 100644 --- a/assets/voxygen/voxel/npc/wolf/male/torso_back.vox +++ b/assets/voxygen/voxel/npc/wolf/male/torso_back.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:393e513cb20d41b71e093a782938b33ed1dae801e19875342b2db72c5e964782 -size 48667 +oid sha256:13613d30abe1f4c3fadd57dc726a010e93c3e831a36ad5e374974d167f0bc161 +size 5560 diff --git a/assets/voxygen/voxel/npc/wolf/male/torso_front.vox b/assets/voxygen/voxel/npc/wolf/male/torso_front.vox index d2e23b9d34..0bfd40e870 100644 --- a/assets/voxygen/voxel/npc/wolf/male/torso_front.vox +++ b/assets/voxygen/voxel/npc/wolf/male/torso_front.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0c555e7dd857f908b787a53118d17d908a96762e3fe10f63a692d2969ac67eb5 -size 48863 +oid sha256:9146b97a1d8f3a9e1574c9aecfe7561b900dfa23bb3ceefe267c50a98c78d937 +size 5756 diff --git a/assets/voxygen/voxel/object/anvil.vox b/assets/voxygen/voxel/object/anvil.vox index 5c801a2586..8d3c033b0f 100644 --- a/assets/voxygen/voxel/object/anvil.vox +++ b/assets/voxygen/voxel/object/anvil.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:efa901f8c256ca65e71fd240ab27877839c867276878a4403ca33e3947cc52d6 -size 56637 +oid sha256:6fd553f1bce1b7e69562dab4db0a00a4963e55d89afbbcaa105ce67d8509194b +size 2208 diff --git a/assets/voxygen/voxel/object/bedroll.vox b/assets/voxygen/voxel/object/bedroll.vox index 78562780d5..ac8724c200 100644 --- a/assets/voxygen/voxel/object/bedroll.vox +++ b/assets/voxygen/voxel/object/bedroll.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae74df38fcbc0ba5e9930db73f06740985bf2ce78258293d66451f64f193a3ad -size 51684 +oid sha256:bdb48ba161538e1da75df41a62eb2755baa716a583b3383421ae84201bb434ba +size 8576 diff --git a/assets/voxygen/voxel/object/bench.vox b/assets/voxygen/voxel/object/bench.vox index 22846826b5..fbf3641a50 100644 --- a/assets/voxygen/voxel/object/bench.vox +++ b/assets/voxygen/voxel/object/bench.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f956ba5f857163cbba699cc497f6d40db3a8ae7ba215b37806daddfc7d43cb5d -size 56305 +oid sha256:c1e904bb8d9382847b11deff551a3e3610f3660de5bec59b64f3c149803088d8 +size 1876 diff --git a/assets/voxygen/voxel/object/bomb.vox b/assets/voxygen/voxel/object/bomb.vox index c0f948ad32..8a7947e5e3 100644 --- a/assets/voxygen/voxel/object/bomb.vox +++ b/assets/voxygen/voxel/object/bomb.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b58a2013132620e61f62ac44708bd7a48edab2a53f7b9afbfc9052815e556ed9 -size 58586 +oid sha256:0b48eb8e678f0a878d65793ae9baacac7d554c7cc6eb7f736eb264bda6f7a1b7 +size 4140 diff --git a/assets/voxygen/voxel/object/campfire_lit.vox b/assets/voxygen/voxel/object/campfire_lit.vox index 12a87b01a5..12f28c3713 100644 --- a/assets/voxygen/voxel/object/campfire_lit.vox +++ b/assets/voxygen/voxel/object/campfire_lit.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:97cf1fa4d3e9545264d435ffe5bfa0f19259bd8114612e175beec900599b34db -size 58944 +oid sha256:dd530e5e53f79f66bbd2269ae2204aefc761c29d8244034216aa93dd9f36d099 +size 4460 diff --git a/assets/voxygen/voxel/object/carpet.vox b/assets/voxygen/voxel/object/carpet.vox index 952eb56040..85a3ebf80e 100644 --- a/assets/voxygen/voxel/object/carpet.vox +++ b/assets/voxygen/voxel/object/carpet.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9f6cec067f42eeced17be10965f24823e1f5e920e564c4d5172481fe5cab461c -size 47340 +oid sha256:145abedf68f9b4dba75f378045ff1e0076a1f011d1b29d1303e9347839c45f91 +size 4232 diff --git a/assets/voxygen/voxel/object/crate.vox b/assets/voxygen/voxel/object/crate.vox index 13c53699a1..77fd5a3e1f 100644 --- a/assets/voxygen/voxel/object/crate.vox +++ b/assets/voxygen/voxel/object/crate.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0ff9a7415ce335019e74384a1da24d0db2bf96d9e2a318b8c6c55c4e1539b2e7 -size 52827 +oid sha256:35c78b9f42ef171ddc9fc26bc64cb0f9f433cd1da44323180cbda40d22b49595 +size 9720 diff --git a/assets/voxygen/voxel/object/door_spooky.vox b/assets/voxygen/voxel/object/door_spooky.vox index 51f8eca2b8..3be4d63b22 100644 --- a/assets/voxygen/voxel/object/door_spooky.vox +++ b/assets/voxygen/voxel/object/door_spooky.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:df6b8d028f0334f37746418b8317de992e1645ad8076eb084e5a210c0753e7cc -size 69180 +oid sha256:71b959f2805d8a26cee6054b485599eda6a820bff804683d010ea59e165184ee +size 26072 diff --git a/assets/voxygen/voxel/object/gravestone.vox b/assets/voxygen/voxel/object/gravestone.vox index 56fc1d4707..c2030d1cc9 100644 --- a/assets/voxygen/voxel/object/gravestone.vox +++ b/assets/voxygen/voxel/object/gravestone.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4efe0580b5cccf7f9754703d032513984940bfdd044ac43dff2f79507624ae6e -size 56333 +oid sha256:3d12268a3171416e773d900ec95a68a9438486b1dc6fb6172df267438142ed9d +size 1904 diff --git a/assets/voxygen/voxel/object/gravestone_2.vox b/assets/voxygen/voxel/object/gravestone_2.vox index dd4cab6027..1889aa6259 100644 --- a/assets/voxygen/voxel/object/gravestone_2.vox +++ b/assets/voxygen/voxel/object/gravestone_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:46c126ef04c3f242337d492240fee7464f82ead1c5dd20c0f9a776133e5d4b1c -size 57269 +oid sha256:2877f464b675a09e69ff19796bb322e029f9fe631f403fb8cd3c02026db65cd5 +size 2840 diff --git a/assets/voxygen/voxel/object/key.vox b/assets/voxygen/voxel/object/key.vox index 3f34358f32..fe09eb10fb 100644 --- a/assets/voxygen/voxel/object/key.vox +++ b/assets/voxygen/voxel/object/key.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4592865022662696d7698c7c40d991eb18cb97660dcd36a291f57be1bb28828 -size 45239 +oid sha256:d3e50732b3ecebcca03f4c37ff40cb956a10d5425e28e55302c8c38d8af92cc9 +size 2128 diff --git a/assets/voxygen/voxel/object/key_gold.vox b/assets/voxygen/voxel/object/key_gold.vox index ec96f40a16..eaf0c3d39f 100644 --- a/assets/voxygen/voxel/object/key_gold.vox +++ b/assets/voxygen/voxel/object/key_gold.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1990da07d4666119dc68e7e9ef690a776fd06352db2803710416a928de2e048c -size 45239 +oid sha256:a120d2b72e1543f46279cc99166aa9e218d16a91b8c9c058f88c9708b007710b +size 2128 diff --git a/assets/voxygen/voxel/object/lantern_ground.vox b/assets/voxygen/voxel/object/lantern_ground.vox index 4f6f50f8d2..5fe8fddaf5 100644 --- a/assets/voxygen/voxel/object/lantern_ground.vox +++ b/assets/voxygen/voxel/object/lantern_ground.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a27b4da28d5096aa06ce4914482363e1d16641796823e70e2745607d3df5444 -size 45187 +oid sha256:6a4fe6620b8da74a9f096d3db0ed8695623e233c49ab57921f12c1c5b702980e +size 2076 diff --git a/assets/voxygen/voxel/object/lantern_ground_open.vox b/assets/voxygen/voxel/object/lantern_ground_open.vox index 1fa33490fb..1c38f45fec 100644 --- a/assets/voxygen/voxel/object/lantern_ground_open.vox +++ b/assets/voxygen/voxel/object/lantern_ground_open.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:731339f131b1a59900d827f2ed26ba553a1beb09136f0112abc2f5ec74949982 -size 44791 +oid sha256:c43633801341bc31a89118827332e975e2fbab2e3ace4148121b6196dce3b088 +size 1680 diff --git a/assets/voxygen/voxel/object/lantern_standing.vox b/assets/voxygen/voxel/object/lantern_standing.vox index bf7497401a..c8fc3f1db8 100644 --- a/assets/voxygen/voxel/object/lantern_standing.vox +++ b/assets/voxygen/voxel/object/lantern_standing.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b54d15b34e42a613fd1d90ff62f0cded7ee7cd1db0853c2e28a25572752df9d -size 49334 +oid sha256:c73516141b65bfe71d813624c5e89ffcc41e64edfee2f21dbdcfdd44610bcb47 +size 6224 diff --git a/assets/voxygen/voxel/object/lantern_standing_2.vox b/assets/voxygen/voxel/object/lantern_standing_2.vox index 58f2f0e1d0..47e3ea28d9 100644 --- a/assets/voxygen/voxel/object/lantern_standing_2.vox +++ b/assets/voxygen/voxel/object/lantern_standing_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c613adb439de0a8cfab026f89d97a0df1c6a465e1321becd91128a09e38453b0 -size 50431 +oid sha256:b600d263f843b4da8b8f7fbc6cdb50bbeaf7d94c4afcd29fc6ef81dcc14a9790 +size 7320 diff --git a/assets/voxygen/voxel/object/potion_blue.vox b/assets/voxygen/voxel/object/potion_blue.vox index 0d896db3f6..6feb366a85 100644 --- a/assets/voxygen/voxel/object/potion_blue.vox +++ b/assets/voxygen/voxel/object/potion_blue.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5153dcd60bf16898964759a7344728dc1e4a07f437a2b5b76c6ddcb366119fbd -size 44447 +oid sha256:ba35218bf76f9b3977ba6b92cfd1e56e66d443698ef5f3d2467a11cdd37d4ecc +size 1336 diff --git a/assets/voxygen/voxel/object/potion_green.vox b/assets/voxygen/voxel/object/potion_green.vox index 4fe10a451b..5fdb6abce5 100644 --- a/assets/voxygen/voxel/object/potion_green.vox +++ b/assets/voxygen/voxel/object/potion_green.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2925a582f0ce3d2bfdd26f5591cf4d652aac0b558ee16067d9272a6710e2bf78 -size 44447 +oid sha256:ac4c0003941030e1e2aa8678bfec3c3cc01d674a07b55d216686dbf2a9fdcb77 +size 1336 diff --git a/assets/voxygen/voxel/object/potion_red.vox b/assets/voxygen/voxel/object/potion_red.vox index fadd6c69fd..2243528656 100644 --- a/assets/voxygen/voxel/object/potion_red.vox +++ b/assets/voxygen/voxel/object/potion_red.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3734cb5df4d04a3373d72ebf361e7e95196906349aa32107af32b79836b884c1 -size 55889 +oid sha256:9a43b225d21834389f13cf6da5cf9de70fb094db570284c32dff394c728e4337 +size 1400 diff --git a/assets/voxygen/voxel/object/potion_turq.vox b/assets/voxygen/voxel/object/potion_turq.vox index 8bdbc01c74..c5c84fdbbd 100644 --- a/assets/voxygen/voxel/object/potion_turq.vox +++ b/assets/voxygen/voxel/object/potion_turq.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0c9c944dd7bc205288e0b28148d939252df5537f90ec8fa2b9cc18e8fe863921 -size 55889 +oid sha256:ba70c60b89f8a9c78604f6be439a11549d428e394e2eac23a7d54f96654e048e +size 1400 diff --git a/assets/voxygen/voxel/object/pouch.vox b/assets/voxygen/voxel/object/pouch.vox index 4f863db0a9..555b7f2d0c 100644 --- a/assets/voxygen/voxel/object/pouch.vox +++ b/assets/voxygen/voxel/object/pouch.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:41c5c4dacb7050121ce597d73957976e7476630e0078c2d9536fe179855b8edf -size 58277 +oid sha256:f7d7d595a9729254476993268e26f6657f3094a1a48370f4b5113ddb69198d53 +size 3848 diff --git a/assets/voxygen/voxel/object/pumpkin.vox b/assets/voxygen/voxel/object/pumpkin.vox index 6d406220d0..2fb3151468 100644 --- a/assets/voxygen/voxel/object/pumpkin.vox +++ b/assets/voxygen/voxel/object/pumpkin.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f6609b77d07e74b2dd5222a465f0698740fa39d1771bff64cb5365f26f376d72 -size 45676 +oid sha256:d5613fa852cc7434e6c79cef11f2aee2ddb1e2e4cb3c63625aad3537ea5ce230 +size 2568 diff --git a/assets/voxygen/voxel/object/pumpkin_2.vox b/assets/voxygen/voxel/object/pumpkin_2.vox index 34ec74a7d0..9d3956a32f 100644 --- a/assets/voxygen/voxel/object/pumpkin_2.vox +++ b/assets/voxygen/voxel/object/pumpkin_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:42e348d35023976eea5e3a6fd0f669a95e1b139a58ed5200c0ebb9820dbb54ef -size 45720 +oid sha256:1c84fd47e6bf52a4149cc34a465b847b3980731d9887449618a3c93fabe8bd25 +size 2612 diff --git a/assets/voxygen/voxel/object/pumpkin_3.vox b/assets/voxygen/voxel/object/pumpkin_3.vox index b36fcf376b..e3b4822909 100644 --- a/assets/voxygen/voxel/object/pumpkin_3.vox +++ b/assets/voxygen/voxel/object/pumpkin_3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:379de50a57739e51fc9d6782ddb5378cd42ed14748043d06e0a5c4ee2f3c4476 -size 45688 +oid sha256:b54413b3b8ba82f53f0e202ca44fa1d439c941ceaff458aa745a35fcb834c0ab +size 2580 diff --git a/assets/voxygen/voxel/object/pumpkin_4.vox b/assets/voxygen/voxel/object/pumpkin_4.vox index da2c128131..768eb28ac0 100644 --- a/assets/voxygen/voxel/object/pumpkin_4.vox +++ b/assets/voxygen/voxel/object/pumpkin_4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eab7e45966b3dfc58d597d862b2501de0fe4c35400f4d54eeff7382f534da82f -size 45700 +oid sha256:328f0ef26286adf0a5729934a3b6190b5d9d2b6b66ab416d0f161007daa252bd +size 2592 diff --git a/assets/voxygen/voxel/object/pumpkin_5.vox b/assets/voxygen/voxel/object/pumpkin_5.vox index 977bb144e3..86117ab44e 100644 --- a/assets/voxygen/voxel/object/pumpkin_5.vox +++ b/assets/voxygen/voxel/object/pumpkin_5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:525fed83b20342435c4e6e60ec52eaac25d83deb616958d8ddb2a6af8dad2ff2 -size 45724 +oid sha256:5587dd40fc9c95136601cbcb17e24965f167fd3202127c3f04c4855980d695cf +size 2616 diff --git a/assets/voxygen/voxel/object/scarecrow.vox b/assets/voxygen/voxel/object/scarecrow.vox index 0bd474a89f..2248fa9456 100644 --- a/assets/voxygen/voxel/object/scarecrow.vox +++ b/assets/voxygen/voxel/object/scarecrow.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:480a42912cc917d034da2a65f6841b67203accf8dc42f62fde446eb060516000 -size 57691 +oid sha256:b97144011503ac468c5b48fa8976a4c76fa8e045127235e51469d67b222f5e09 +size 3260 diff --git a/assets/voxygen/voxel/object/window_spooky.vox b/assets/voxygen/voxel/object/window_spooky.vox index 7360c573cc..a8105ded09 100644 --- a/assets/voxygen/voxel/object/window_spooky.vox +++ b/assets/voxygen/voxel/object/window_spooky.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:35944786a274f505a1733e95a3051c76e50e62425c3f44279d0e8027e6f531e6 -size 52396 +oid sha256:f6260bc765a4ae920b44b6437f71b4d8ae14dc924b4669a72cf9bcde7d1e199d +size 9288 diff --git a/assets/voxygen/voxel/sprite/blueberry/1.vox b/assets/voxygen/voxel/sprite/blueberry/1.vox index f512f25e44..c91c17bddf 100644 --- a/assets/voxygen/voxel/sprite/blueberry/1.vox +++ b/assets/voxygen/voxel/sprite/blueberry/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9c2fc29e68eb500b5dd4e6a02248002e3fe65ec45bef84b49467b141226332b2 -size 55931 +oid sha256:64d3a1a67ceb19fd1ec41ac941cdfc5622b1dba566069d41947d5dd617d26092 +size 1448 diff --git a/assets/voxygen/voxel/sprite/blueberry/2.vox b/assets/voxygen/voxel/sprite/blueberry/2.vox index 529bfaa59c..377b391b9c 100644 --- a/assets/voxygen/voxel/sprite/blueberry/2.vox +++ b/assets/voxygen/voxel/sprite/blueberry/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f1a4027cbb01457fc5d82c0b856a25d6aed491b22547e6ceb4e44b94335462fb -size 55955 +oid sha256:8f1c69b8e7d6de285f395b30430eb3b40fcac7b07ee81d2ce42c37503de1aaa9 +size 1472 diff --git a/assets/voxygen/voxel/sprite/blueberry/3.vox b/assets/voxygen/voxel/sprite/blueberry/3.vox index 2c5a8e17dc..9fb7f6c58a 100644 --- a/assets/voxygen/voxel/sprite/blueberry/3.vox +++ b/assets/voxygen/voxel/sprite/blueberry/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ddf19ef01220cd6022b14fe0358eb6ea6065b1a6eecc4cc931895adaf3837683 -size 55983 +oid sha256:3b36eab27a99a630d85762daad91421eaf90ea1f0412342cea1bcdc383e3736f +size 1500 diff --git a/assets/voxygen/voxel/sprite/blueberry/4.vox b/assets/voxygen/voxel/sprite/blueberry/4.vox index e44eb68faa..20d48ab751 100644 --- a/assets/voxygen/voxel/sprite/blueberry/4.vox +++ b/assets/voxygen/voxel/sprite/blueberry/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:92efb6fb4f8a5ec82f7e3cae272d288b4aeacd75188f4f54dc0786f113ce54d1 -size 55847 +oid sha256:b420454a5b6a3fd3450bd6e9c4d1f7e736c047c598ce3900ea8ede525c303b8e +size 1364 diff --git a/assets/voxygen/voxel/sprite/blueberry/5.vox b/assets/voxygen/voxel/sprite/blueberry/5.vox index d9b9f2b347..0fc528fba9 100644 --- a/assets/voxygen/voxel/sprite/blueberry/5.vox +++ b/assets/voxygen/voxel/sprite/blueberry/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d5e36ccccf42ced2b26125d9f0a97cd2ea8a0f2f236af930b58f70eb4c8d9449 -size 55863 +oid sha256:747f1b67b3a85ad3678499ca7b2aad1fe73e5320537d9e5e13c3bb0153fd9207 +size 1380 diff --git a/assets/voxygen/voxel/sprite/blueberry/6.vox b/assets/voxygen/voxel/sprite/blueberry/6.vox index 32872237d7..f6b12a4a1f 100644 --- a/assets/voxygen/voxel/sprite/blueberry/6.vox +++ b/assets/voxygen/voxel/sprite/blueberry/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:20764bf02c5d4bad24e94344d90b5b6fd8ea29b6bbbb00621c6a899c04565a6c -size 55891 +oid sha256:2112936f1444d89665cf3b359611485f6f864a8a2a85d2b3eeb66e76266448d6 +size 1408 diff --git a/assets/voxygen/voxel/sprite/blueberry/7.vox b/assets/voxygen/voxel/sprite/blueberry/7.vox index d46306f4ef..fb649aaaf2 100644 --- a/assets/voxygen/voxel/sprite/blueberry/7.vox +++ b/assets/voxygen/voxel/sprite/blueberry/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b45e70a17f702c78b9e32c94949c6420a6bcdbed46d45604f4b92a4f7566cd8 -size 55675 +oid sha256:ad3f7b6fef393959e230cd620a2bd722ac9b5d0b7e633d4b03103d53ad202241 +size 1192 diff --git a/assets/voxygen/voxel/sprite/blueberry/8.vox b/assets/voxygen/voxel/sprite/blueberry/8.vox index 47b456bad0..2fc1a8508d 100644 --- a/assets/voxygen/voxel/sprite/blueberry/8.vox +++ b/assets/voxygen/voxel/sprite/blueberry/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:47b930f188fcf2e8c936234deb8b503a1cc5d3b98afb39c3496b2af31a70412d -size 55687 +oid sha256:ccb9c87e5b65227469985adb049390435ae94ff43364e925234c00bde84e0dbd +size 1204 diff --git a/assets/voxygen/voxel/sprite/blueberry/9.vox b/assets/voxygen/voxel/sprite/blueberry/9.vox index cfbf76b948..dcfb6f8347 100644 --- a/assets/voxygen/voxel/sprite/blueberry/9.vox +++ b/assets/voxygen/voxel/sprite/blueberry/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bbf6407f2d05e4e8488873d66dd6ca867986f983d86acb9e1b18fd639ddda567 -size 55703 +oid sha256:04bf9753a1bd82903e4c3d0da1a8d1ba0ee834bc959f0ae4146e4a7d42d23302 +size 1220 diff --git a/assets/voxygen/voxel/sprite/cacti/cactus_round.vox b/assets/voxygen/voxel/sprite/cacti/cactus_round.vox index 0215a44371..a8552fc18d 100644 --- a/assets/voxygen/voxel/sprite/cacti/cactus_round.vox +++ b/assets/voxygen/voxel/sprite/cacti/cactus_round.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:429d3b5b1c4b331d5771d7b8af8e05abf8a2758847f967d62d83b81616fc44fd -size 44811 +oid sha256:0ee7ed801ba8a7cae2767eb46571d366f3961a1f24a8691e4313080941d2f911 +size 1700 diff --git a/assets/voxygen/voxel/sprite/dead_bush/1.vox b/assets/voxygen/voxel/sprite/dead_bush/1.vox index 9024bda738..331d6d2f63 100644 --- a/assets/voxygen/voxel/sprite/dead_bush/1.vox +++ b/assets/voxygen/voxel/sprite/dead_bush/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:37f8d6b7c359c2327b0a5909936c6d21c7083a0606e8c66774d730444eaef397 -size 56841 +oid sha256:409a3be1ffd47e65a5a9ded066270093ea4bf02ecbb4d36160909bf9a6a3c062 +size 2088 diff --git a/assets/voxygen/voxel/sprite/dead_bush/2.vox b/assets/voxygen/voxel/sprite/dead_bush/2.vox index 6576fb3caf..26c1c0a132 100644 --- a/assets/voxygen/voxel/sprite/dead_bush/2.vox +++ b/assets/voxygen/voxel/sprite/dead_bush/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:66f80d9e670a0d81b85a3b778ba43ee66574284ecf9b9f7065146a249b9ecb3c -size 56733 +oid sha256:d5c5614269b45198f1d357b2588b13ee89da9060c33a7b47fb7b909bf86e6b08 +size 1980 diff --git a/assets/voxygen/voxel/sprite/dead_bush/3.vox b/assets/voxygen/voxel/sprite/dead_bush/3.vox index 6a9610f8b0..1e02e7c7bb 100644 --- a/assets/voxygen/voxel/sprite/dead_bush/3.vox +++ b/assets/voxygen/voxel/sprite/dead_bush/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1507b8612b31cca4ee38248580ba16716708ef3c2d9aaa54adea27ee5a5714c -size 56365 +oid sha256:8fbd0c96e868b1fa4d2db548e126132074b9ec65e178ede62623c4060a4f9055 +size 1612 diff --git a/assets/voxygen/voxel/sprite/dead_bush/4.vox b/assets/voxygen/voxel/sprite/dead_bush/4.vox index 56ee404c7d..234b229812 100644 --- a/assets/voxygen/voxel/sprite/dead_bush/4.vox +++ b/assets/voxygen/voxel/sprite/dead_bush/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db68cd44a962ac77385a3495e9fa6cd5bd7a140ff56c661122d0b7af1be9617e -size 56161 +oid sha256:9a17d27c9bf07f64ad97cf208e050dcb253d122605bb2a7d382d36520a6965f5 +size 1408 diff --git a/assets/voxygen/voxel/sprite/ferns/1.vox b/assets/voxygen/voxel/sprite/ferns/1.vox index 2aa6031c82..75fd3a3bd7 100644 --- a/assets/voxygen/voxel/sprite/ferns/1.vox +++ b/assets/voxygen/voxel/sprite/ferns/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4fbf52bcea93e7b55ae1953de4e978f6af710e2bc6d8b757e8771ca7ec659c51 -size 56242 +oid sha256:4836e23cf5198c56b1038c10206d2cf8f347d6543bd8fff7d5454489aa2b4d39 +size 1492 diff --git a/assets/voxygen/voxel/sprite/ferns/10.vox b/assets/voxygen/voxel/sprite/ferns/10.vox index 9b52a08f97..54e4d15389 100644 --- a/assets/voxygen/voxel/sprite/ferns/10.vox +++ b/assets/voxygen/voxel/sprite/ferns/10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a231d28f92b612f084c37177d3a7558d80c76391ea758cea0fad467a3ac88efb -size 56086 +oid sha256:683039c5426944b423bb4a23b0a9ca6a2d4bd14a324e7f2c4726848d16949b3f +size 1336 diff --git a/assets/voxygen/voxel/sprite/ferns/11.vox b/assets/voxygen/voxel/sprite/ferns/11.vox index 5082549f7f..2f4af4358c 100644 --- a/assets/voxygen/voxel/sprite/ferns/11.vox +++ b/assets/voxygen/voxel/sprite/ferns/11.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ede46ea52aacc78f8b5cf4b1f9c3370b19bfa1d18a99d70046bf9d80c8be8ab0 -size 56002 +oid sha256:bf81d0e53f133b3c6b70c1ce0b0131dd50e72e24bb66ffeba68d7e5bdf1b465e +size 1252 diff --git a/assets/voxygen/voxel/sprite/ferns/12.vox b/assets/voxygen/voxel/sprite/ferns/12.vox index 36be1560b7..05e9acd4ce 100644 --- a/assets/voxygen/voxel/sprite/ferns/12.vox +++ b/assets/voxygen/voxel/sprite/ferns/12.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:912f4c77a170aef3ff325aca40758633aa4e2f1db6b19beb19552c43842af21b -size 55982 +oid sha256:3b1d92ec5430f277258c4c2e20478b1fc9a4d30263b3775af4bef13a85734acf +size 1232 diff --git a/assets/voxygen/voxel/sprite/ferns/2.vox b/assets/voxygen/voxel/sprite/ferns/2.vox index 28127128d5..1f07ba16c7 100644 --- a/assets/voxygen/voxel/sprite/ferns/2.vox +++ b/assets/voxygen/voxel/sprite/ferns/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a4623532da0096db30f552218bef29e2498174648a5be165bb86c9edc8d652f5 -size 56243 +oid sha256:e2add2e985cbce8013739551123934b9f2bee65cc9e7da55c8c267ae50c92261 +size 1492 diff --git a/assets/voxygen/voxel/sprite/ferns/3.vox b/assets/voxygen/voxel/sprite/ferns/3.vox index 512ffb48e4..874758e60d 100644 --- a/assets/voxygen/voxel/sprite/ferns/3.vox +++ b/assets/voxygen/voxel/sprite/ferns/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a13c4d18ce74ee4ab289e278651757ab5a8d85efe59bf08a879bcbc239ce3423 -size 56178 +oid sha256:22867c342215aa2dd177cf611d64f554a009483a5133da6d21344748ffbc2c6d +size 1428 diff --git a/assets/voxygen/voxel/sprite/ferns/4.vox b/assets/voxygen/voxel/sprite/ferns/4.vox index 611fa073d8..5188d75411 100644 --- a/assets/voxygen/voxel/sprite/ferns/4.vox +++ b/assets/voxygen/voxel/sprite/ferns/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:92ddf7001c4721c35b112d19f0cc90aea3f641885d6a9541a4eee36dea8d175b -size 56179 +oid sha256:ea5527cd5f1dea6155d43eb3052632684988160e9bef4283d7cee0cd562b56f4 +size 1428 diff --git a/assets/voxygen/voxel/sprite/ferns/5.vox b/assets/voxygen/voxel/sprite/ferns/5.vox index d9471eb9e9..af1c62ad8b 100644 --- a/assets/voxygen/voxel/sprite/ferns/5.vox +++ b/assets/voxygen/voxel/sprite/ferns/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d63edb0ed69a1a6a5cfcbda07a563ec7217687bfdcaa465809721844c9cce749 -size 56218 +oid sha256:b7fee466deac4265ffab7c9b84def8a4735b04b129bc6d9ad816c127630f0781 +size 1468 diff --git a/assets/voxygen/voxel/sprite/ferns/6.vox b/assets/voxygen/voxel/sprite/ferns/6.vox index 90a1ce4d9e..4d46b5f85f 100644 --- a/assets/voxygen/voxel/sprite/ferns/6.vox +++ b/assets/voxygen/voxel/sprite/ferns/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9bc276049c0ac255427a509ce3efa01cc82c7790c99415d74d8ade4a99ed06f5 -size 56219 +oid sha256:70cafdf06c4db42cbec34aa1862dbfe7d524423ce96e5ec689f150a425984f15 +size 1468 diff --git a/assets/voxygen/voxel/sprite/ferns/7.vox b/assets/voxygen/voxel/sprite/ferns/7.vox index c667bd4926..15091de26f 100644 --- a/assets/voxygen/voxel/sprite/ferns/7.vox +++ b/assets/voxygen/voxel/sprite/ferns/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bcd71e709f991c3e27e2b91a41428191807a6b5c6b6bffe01d0779f96afd7993 -size 56102 +oid sha256:866fd6cd69ef6682170c6250b01fed115c5501d87324f1010a457cdcb9d47e25 +size 1352 diff --git a/assets/voxygen/voxel/sprite/ferns/8.vox b/assets/voxygen/voxel/sprite/ferns/8.vox index 99578f0760..4ad53ad439 100644 --- a/assets/voxygen/voxel/sprite/ferns/8.vox +++ b/assets/voxygen/voxel/sprite/ferns/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:70465d5ff3c6754fa6fa409cf7547ce8dfbed8f377651ae1524011280aacbf4a -size 56122 +oid sha256:06ec44ea19df2a79b449d33e123044f51a2bf8c91dfee5b605f23cf265c90f3c +size 1372 diff --git a/assets/voxygen/voxel/sprite/ferns/9.vox b/assets/voxygen/voxel/sprite/ferns/9.vox index 64fdccc480..2643c1290d 100644 --- a/assets/voxygen/voxel/sprite/ferns/9.vox +++ b/assets/voxygen/voxel/sprite/ferns/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2972e1fb37bb29ed193fb9824b34724604bb5f07c95d70b44047f1ddb08f8b96 -size 56074 +oid sha256:6115029f7249fadfe7cde813165edd1984614e77fe141a64ceab67fcc5da0827 +size 1324 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_blue_1.vox b/assets/voxygen/voxel/sprite/flowers/flower_blue_1.vox index 752c381cc6..48002ce197 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_blue_1.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_blue_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:137b23eab91e066b9a6439ad12689bdbc7282c71f36c6c294b2f71de73334c28 -size 44323 +oid sha256:7eb7347e9c09878225b65e02b78662bd0aeca1b9f43eb8dac8d8dc04fe9fc1c5 +size 1216 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_blue_2.vox b/assets/voxygen/voxel/sprite/flowers/flower_blue_2.vox index c63e9bcbee..887979f3f6 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_blue_2.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_blue_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:09db5a4f07d37a7806e5557d599d4ac30e5528a06e12bee31740a17dc41f7c1f -size 44267 +oid sha256:b703d56f42792ed69e3c8dc31f657679f9edb52a9f96cf984ddfef94e95dab36 +size 1160 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_blue_3.vox b/assets/voxygen/voxel/sprite/flowers/flower_blue_3.vox index 7a660a83bd..517245ae49 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_blue_3.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_blue_3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8c8c6c7160c27780e81cc77429b8ff2c01cc6ddeb27d4240b3fe41a1b0901253 -size 44428 +oid sha256:f7a489e63e9fb08a85a7a5538fc34f1e8aeec0079bc0f53641fc7a52cb7d5398 +size 1320 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_blue_4.vox b/assets/voxygen/voxel/sprite/flowers/flower_blue_4.vox index 27913073cb..f152e801ca 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_blue_4.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_blue_4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b7d423ee6519166df1982cac0fd95d41611d371bbe265328cd1f09291b54c06 -size 44652 +oid sha256:efd82c0a3e493408605b28554e8f8cf06a4d5105bbe39a44a5015039b7af0ca8 +size 1544 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_blue_5.vox b/assets/voxygen/voxel/sprite/flowers/flower_blue_5.vox index 8f7bf1e67e..18d6b0c320 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_blue_5.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_blue_5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eefdbb220918b2d4c2399f6e33d8760456635c3603682417aa70800b498fd77c -size 44275 +oid sha256:ef17073547a52c82ae5ec6d159341bbd06b1207370104d149f5eb1a2cdef154b +size 1168 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_blue_6.vox b/assets/voxygen/voxel/sprite/flowers/flower_blue_6.vox index b2116625e8..b5f2325130 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_blue_6.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_blue_6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:294f4804ea76d2bf2f3e910521edbcbe331881467ed31c3332c227d674057b14 -size 55870 +oid sha256:ee772f4dc359b26295b581b0455fbfdac43b2a9492a5e5c86409c0c6199e069c +size 1384 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_blue_7.vox b/assets/voxygen/voxel/sprite/flowers/flower_blue_7.vox index c36b462514..ff254a3ca8 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_blue_7.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_blue_7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:25a792f45739c95c1f831874aef54a568c7aa3ed3f3217256a07b6974c4c36b0 -size 55800 +oid sha256:71fd10306b8300fc0c902fd623881912ce5bd0d1d27360c6190547ad8d834e82 +size 1316 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_pink_1.vox b/assets/voxygen/voxel/sprite/flowers/flower_pink_1.vox index ecd86bb9c0..9af8666c65 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_pink_1.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_pink_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d688b6111f1c5d15b527157489f61d3385beeb8e25088bca5fec282621305a4d -size 44271 +oid sha256:bc1ad943bd98f0ef598f86b0cee51967c743b133d378935cca3598740b37258b +size 1164 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_pink_2.vox b/assets/voxygen/voxel/sprite/flowers/flower_pink_2.vox index 523afec55c..5e05558b60 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_pink_2.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_pink_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04bd938016b6f17ea0f2cbdfd2cc1b5e91722f612f586ea8b467ecba0fafa01a -size 44228 +oid sha256:4f4ac49f2721e239bb6c252ec377a3cfc09b9124aad7a0118fdd13e46b7cc2fa +size 1136 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_pink_3.vox b/assets/voxygen/voxel/sprite/flowers/flower_pink_3.vox index a6c7428511..8d843e9d84 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_pink_3.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_pink_3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2bff7bde8c9b4ee9b1f9f9731a4d11e2f3ea7f08759fa57c617ae6062651e99b -size 44239 +oid sha256:73a6bed4042c40ab264997ede1cc031881c5ac16963eebe0fb8028538d3aac16 +size 1132 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_pink_4.vox b/assets/voxygen/voxel/sprite/flowers/flower_pink_4.vox index fd95d29ac0..ec5f42c7cc 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_pink_4.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_pink_4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e9ce9d1cd76d0d671c574f3f5be2bb6f94196146d1f2276bcd672d803f31bc3b -size 56162 +oid sha256:48c069ba7699e466130a037ac6ca928799882dd4332aef9f45c2872a8042144a +size 1676 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_purple_1.vox b/assets/voxygen/voxel/sprite/flowers/flower_purple_1.vox index da46bed104..f0810d733e 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_purple_1.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_purple_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5d41bfdd3cb5f31ba7f60ffdf1028bdf44bd3e2fb642df7744584bdf268d264b -size 44535 +oid sha256:4d93a37bcc70093efb1ed9170f7ae2f7bdc9807fb85c12efc9c062a89f9a1089 +size 1428 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_red_1.vox b/assets/voxygen/voxel/sprite/flowers/flower_red_1.vox index 415db9edae..0f0b7e6187 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_red_1.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_red_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:433252d0bd38f1d0087de74ad0fe0ecd14afc6bea71e2f40780b398776c35d22 -size 44607 +oid sha256:fd95cc9f1571bea2110f2d383f6ec14de52e094c54b162e805dbc5bc8a112690 +size 1500 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_red_2.vox b/assets/voxygen/voxel/sprite/flowers/flower_red_2.vox index 5f30e611de..f64fd1119c 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_red_2.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_red_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d94da7f4213a2e58dc77784c438bc16aa47ffc6f3db17c9f282f557ccdd2fe0e -size 55870 +oid sha256:1738e714df2a4159c12d2c22bbfbce803a264903d8e4918a8733ef62da2b66dc +size 1384 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_red_3.vox b/assets/voxygen/voxel/sprite/flowers/flower_red_3.vox index ee0cbf4fbc..16b7152784 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_red_3.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_red_3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d83823d8624c54d2c13010e64a7d886c7b933ab4d8639517760b60e190ec7e18 -size 55800 +oid sha256:26baf67a9a181ca644d5d1795e77bd268c50bf06fc944a19297996b7f23dd0ad +size 1316 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_white_1.vox b/assets/voxygen/voxel/sprite/flowers/flower_white_1.vox index c6d54d4e52..4cb0d56bcf 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_white_1.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_white_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ce257a89884fa3fa377ecb49b1c5225c97dc96703294b1af81661adc731edf6c -size 44275 +oid sha256:85ef3695d6a4e555818ee0082922964837fa3ab124738ed2335cdf0641a32aa9 +size 1168 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_white_2.vox b/assets/voxygen/voxel/sprite/flowers/flower_white_2.vox index ef88a12560..2a751c3a38 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_white_2.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_white_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc3886df0e32965e2dc4c1496f6d7f89ce64b0bf93f26346c7b019906bd3a4ef -size 55800 +oid sha256:fdd1c58bef68ad77c3754aa53e8581f1b0faf11d7e21fbb3121dff3d89d95576 +size 1316 diff --git a/assets/voxygen/voxel/sprite/flowers/flower_yellow_1.vox b/assets/voxygen/voxel/sprite/flowers/flower_yellow_1.vox index a09fc8d4b3..afa82dfb8e 100644 --- a/assets/voxygen/voxel/sprite/flowers/flower_yellow_1.vox +++ b/assets/voxygen/voxel/sprite/flowers/flower_yellow_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dd382675806c5cf98fd4b93cb406995cfd70f6abe6d3794e8ad626f336251d29 -size 44243 +oid sha256:03f488ef3c37b844210be98384d88d6842cbd0c15ffef4caec13d4ee3c1570e1 +size 1136 diff --git a/assets/voxygen/voxel/sprite/flowers/sunflower_1.vox b/assets/voxygen/voxel/sprite/flowers/sunflower_1.vox index 39985e6f4c..4af86c570b 100644 --- a/assets/voxygen/voxel/sprite/flowers/sunflower_1.vox +++ b/assets/voxygen/voxel/sprite/flowers/sunflower_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0de3698a419e3c68ee479e3c7fd8a24b0c1e4a5402b3ab007e77cad2d206a22 -size 44415 +oid sha256:bdc7e2fc8f7ae6e14f0a31a54207a96824a66611da196f062ae9e5445337abfd +size 1308 diff --git a/assets/voxygen/voxel/sprite/flowers/sunflower_2.vox b/assets/voxygen/voxel/sprite/flowers/sunflower_2.vox index 116259a969..eae0d79ac9 100644 --- a/assets/voxygen/voxel/sprite/flowers/sunflower_2.vox +++ b/assets/voxygen/voxel/sprite/flowers/sunflower_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:23a009406df7b1d14c79c6dc7fd140e75b9db1794fabcd461a68f8f79f910161 -size 44483 +oid sha256:41f2cb970b63ecb415748ba3de225f0dd31f7ccbae9fcc0111eb57c1eed71af5 +size 1376 diff --git a/assets/voxygen/voxel/sprite/fruit/apple.vox b/assets/voxygen/voxel/sprite/fruit/apple.vox index 5efb481e2f..4e16d1ab70 100644 --- a/assets/voxygen/voxel/sprite/fruit/apple.vox +++ b/assets/voxygen/voxel/sprite/fruit/apple.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e8ae144bb978a28d02025d5b5ba0b9de7bdee33fcfc64959e5f4751bc83a6f0 -size 57675 +oid sha256:7616be8382963a21f068f72e2c4c3034bd33f8c40bb6c544156eda6512405301 +size 3192 diff --git a/assets/voxygen/voxel/sprite/grass/grass_long_1.vox b/assets/voxygen/voxel/sprite/grass/grass_long_1.vox index 279d6f446f..e8dcdc3bec 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_long_1.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_long_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a9a8cea09c3994b43158b62be8b675edfae73229ea05167728d5cf0bd6656d14 -size 44551 +oid sha256:f4d348f0534f4b6952452d359fc7883125f9a2f0081ab7b172439f8cbba29f9a +size 1444 diff --git a/assets/voxygen/voxel/sprite/grass/grass_long_2.vox b/assets/voxygen/voxel/sprite/grass/grass_long_2.vox index a8e9c6302c..97a20a442d 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_long_2.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_long_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ad9a6155fc8244c02b61922ac360543bacf0fbca2c72891271f6635d0d361c75 -size 44503 +oid sha256:2a51e75e4168b50ecbddf93f73446a99eee7170f505fec14b26845b8352b36af +size 1396 diff --git a/assets/voxygen/voxel/sprite/grass/grass_long_3.vox b/assets/voxygen/voxel/sprite/grass/grass_long_3.vox index 4158bac628..da62315abe 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_long_3.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_long_3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:385da09d1fbca9875f06876c3aea58bf89a06f960d2426b9c5a79ae3064d46e4 -size 44535 +oid sha256:57ce1b9198565ab871b5ffa75eed3c33d98e460417d6b3bd9d0f16f0e6078f57 +size 1428 diff --git a/assets/voxygen/voxel/sprite/grass/grass_long_4.vox b/assets/voxygen/voxel/sprite/grass/grass_long_4.vox index 6231f60bd5..72cf6e18b0 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_long_4.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_long_4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b822e17f16fc7a3580b36ac3dfaab97bf8827bdfb87beaa2bfdf48cda0ccb5b5 -size 44487 +oid sha256:f669703367068650a538e54ef145e974a05781913bb161e6623cebe138f9819d +size 1380 diff --git a/assets/voxygen/voxel/sprite/grass/grass_long_5.vox b/assets/voxygen/voxel/sprite/grass/grass_long_5.vox index 87f15a2517..12d5a172a0 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_long_5.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_long_5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:846c44590d2cf2f76c13297cec5f4bf5588c24718560f2bf4ae0f88fa7a22862 -size 44535 +oid sha256:73512c97c009b922ba2dba87a76b22a88480ae1d176a29f1522c6093f588d605 +size 1428 diff --git a/assets/voxygen/voxel/sprite/grass/grass_long_6.vox b/assets/voxygen/voxel/sprite/grass/grass_long_6.vox index 6b5b8d671f..7619938d93 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_long_6.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_long_6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a0f790e13d900de42906770e982757db98ace1e8170d76c1e34b142c3a02a1b6 -size 44539 +oid sha256:fffddbb1896ceb76169b1d6b4336049b9420f6286a6499199081f9cf7b4f7b92 +size 1432 diff --git a/assets/voxygen/voxel/sprite/grass/grass_long_7.vox b/assets/voxygen/voxel/sprite/grass/grass_long_7.vox index 931f5c59d6..a0c962a166 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_long_7.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_long_7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c1a444e329a61d03fcf46b5e9d2d2ef5c15d9c18d40a08fe65e751b18a1577fa -size 44511 +oid sha256:fabcd5006ceb04101df626a5741e7e2f8db7879624dec8699746d2ba7262a62f +size 1404 diff --git a/assets/voxygen/voxel/sprite/grass/grass_med_1.vox b/assets/voxygen/voxel/sprite/grass/grass_med_1.vox index dd8ae959c0..a654b7d8c2 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_med_1.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_med_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9a951513b8b79f557a959838bc544ad4d19de65e3c9d6c4888dcdae40028fc3e -size 44339 +oid sha256:b39aea74e38cbc9734a0814f660ae31aac52668917d7c65b0563ca9935d6f69a +size 1232 diff --git a/assets/voxygen/voxel/sprite/grass/grass_med_2.vox b/assets/voxygen/voxel/sprite/grass/grass_med_2.vox index d285e54822..69f60e761f 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_med_2.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_med_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e1d099c794ac2c7c6443a602d6a75d476639076fd0cb5842ddab7134d5004221 -size 44395 +oid sha256:b1d5aa23a9e1fc7818712e2aede308f422ca24a11f1dc6203335352192b5180c +size 1288 diff --git a/assets/voxygen/voxel/sprite/grass/grass_med_3.vox b/assets/voxygen/voxel/sprite/grass/grass_med_3.vox index ba7ca2d0da..c643ed573f 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_med_3.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_med_3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fd2d98727aa16e0d53a4d5722852c1eaad14f5e1639c0554c53f0e78692c3d56 -size 44355 +oid sha256:5b6087272bb20c7ad3decae12c4d13d093781a8a94144ead8198e009956d59a3 +size 1248 diff --git a/assets/voxygen/voxel/sprite/grass/grass_med_4.vox b/assets/voxygen/voxel/sprite/grass/grass_med_4.vox index 5357415cd8..612ec9e2d6 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_med_4.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_med_4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5c47b69346bc2e067726f34ff1fea356814ae8a9562e739664e9d67c2198ef5c -size 44351 +oid sha256:510f33fc7b45c52d7675de08a56402a01b1f76716a6de82569697641213ef418 +size 1244 diff --git a/assets/voxygen/voxel/sprite/grass/grass_med_5.vox b/assets/voxygen/voxel/sprite/grass/grass_med_5.vox index 339d381391..67f1325f45 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_med_5.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_med_5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e4c14736a4fc99a063e3f095919c337ffa1c35aead85338cfcc3d8f53147f7a3 -size 44371 +oid sha256:46ff8cd7c1a9358d6fe120b58941b3ea4ac0dcd127924076cae0c9478cafecc5 +size 1264 diff --git a/assets/voxygen/voxel/sprite/grass/grass_short_1.vox b/assets/voxygen/voxel/sprite/grass/grass_short_1.vox index 3a5727ff7c..584fdfae8c 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_short_1.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_short_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dcfe61508867889fb9db63a3486c4ac837781fa8d88c6fa7d7f1860a960a86d3 -size 44247 +oid sha256:ec8ceb63b25e07aa37ba7e3b5ec6c18ee627ebfc94bbaf49024b9e985288ab57 +size 1140 diff --git a/assets/voxygen/voxel/sprite/grass/grass_short_2.vox b/assets/voxygen/voxel/sprite/grass/grass_short_2.vox index 281e109b45..04e0750466 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_short_2.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_short_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:de5bcee610a356e7967d2c1a6dbd8986fa5dd01da2452867fb33d594d23d5fe3 -size 44251 +oid sha256:26f222ad0fa2391131ecc0e801984439c07a9fe279968706f83d55241023ee60 +size 1144 diff --git a/assets/voxygen/voxel/sprite/grass/grass_short_3.vox b/assets/voxygen/voxel/sprite/grass/grass_short_3.vox index d28434ad0c..986532b8f5 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_short_3.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_short_3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0199be7c161f654639cd9b18b87e2c8ab8df463bd94b23084d6d2ae86ca12ad5 -size 44251 +oid sha256:5d332bd2f9e98b1c50b84867623e3a5a6be3e874310350cabbe5259bc0eab37e +size 1144 diff --git a/assets/voxygen/voxel/sprite/grass/grass_short_4.vox b/assets/voxygen/voxel/sprite/grass/grass_short_4.vox index 10f4dc7ff6..399a79bff3 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_short_4.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_short_4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cfede63847e63890c2ab85708a63f2f518ed54656c0292130c741d9dd72133f9 -size 44239 +oid sha256:fd8b7f18021cb3fc2e17159b0ab247de46c1f8785ab47b637cdf4a6b36c7e977 +size 1132 diff --git a/assets/voxygen/voxel/sprite/grass/grass_short_5.vox b/assets/voxygen/voxel/sprite/grass/grass_short_5.vox index 0b390bdf28..6153cf80d9 100644 --- a/assets/voxygen/voxel/sprite/grass/grass_short_5.vox +++ b/assets/voxygen/voxel/sprite/grass/grass_short_5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:acaa2231a3d6e58869d26322e5c3b426c290f606b8c724cd606242c099d5e94e -size 44263 +oid sha256:3d2e7b3390728d10d7075b88a9a7df75d80a2643a211e8a7523d428263c83866 +size 1156 diff --git a/assets/voxygen/voxel/sprite/leafy_plant/1.vox b/assets/voxygen/voxel/sprite/leafy_plant/1.vox index 509ba0afb5..13258089d6 100644 --- a/assets/voxygen/voxel/sprite/leafy_plant/1.vox +++ b/assets/voxygen/voxel/sprite/leafy_plant/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:febe526cc5e78ad0f8b5665eb32865e533790a43968d2ebbdc99219198040095 -size 56643 +oid sha256:2f7230dc9d14f13b7bad03fcc2cda7922e6898745c18791916d8fa59c5709bcb +size 1892 diff --git a/assets/voxygen/voxel/sprite/leafy_plant/10.vox b/assets/voxygen/voxel/sprite/leafy_plant/10.vox index f93ea337c5..73d3b3901d 100644 --- a/assets/voxygen/voxel/sprite/leafy_plant/10.vox +++ b/assets/voxygen/voxel/sprite/leafy_plant/10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed217eb3d68bbea14ce09fdb183b836d5891bed6f44cd0e021434b7b1b7f3391 -size 55911 +oid sha256:63accce104181146bbe0e02f7c1f22f3d849387c4da7975c23e6d9aa0174f8fa +size 1160 diff --git a/assets/voxygen/voxel/sprite/leafy_plant/2.vox b/assets/voxygen/voxel/sprite/leafy_plant/2.vox index c3906fdb15..daddc2cd70 100644 --- a/assets/voxygen/voxel/sprite/leafy_plant/2.vox +++ b/assets/voxygen/voxel/sprite/leafy_plant/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04aa9b7cfe0c1422b817fb4742c8a838a6bea0592884664c0161c2247b6359d2 -size 56091 +oid sha256:56fff236d95573b242fa086eb7c9d0ea88199d1b1c4509d072a84ff389c43618 +size 1340 diff --git a/assets/voxygen/voxel/sprite/leafy_plant/3.vox b/assets/voxygen/voxel/sprite/leafy_plant/3.vox index 754cf39ca2..a4cb1b017d 100644 --- a/assets/voxygen/voxel/sprite/leafy_plant/3.vox +++ b/assets/voxygen/voxel/sprite/leafy_plant/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:11b1f467c25f10c789550626abc5d55496ba1db2f2c93c1931baaaf1ebd9e76e -size 56182 +oid sha256:b376fd6ae77ee6b70b840ae836c3f45f9a534982793b6399b1e75e80f340ce40 +size 1432 diff --git a/assets/voxygen/voxel/sprite/leafy_plant/4.vox b/assets/voxygen/voxel/sprite/leafy_plant/4.vox index 6ac863df32..21506dc484 100644 --- a/assets/voxygen/voxel/sprite/leafy_plant/4.vox +++ b/assets/voxygen/voxel/sprite/leafy_plant/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:56500574106d5f9fb09a5b4a30d04bf39793cd9a2031c649e853634da1c8ca94 -size 56058 +oid sha256:b486ba258a8e9b780ce48a660814762593306520b901e058b5f803e50b4ed7f9 +size 1308 diff --git a/assets/voxygen/voxel/sprite/leafy_plant/5.vox b/assets/voxygen/voxel/sprite/leafy_plant/5.vox index 46688b58c9..6dca485f98 100644 --- a/assets/voxygen/voxel/sprite/leafy_plant/5.vox +++ b/assets/voxygen/voxel/sprite/leafy_plant/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:31090b38462baa9e057d9f70dc891dac169024a7a01b067217922b6816423451 -size 56035 +oid sha256:96113dd1de793a91c1b4eda784f89cc65396c41aa930274c748ee7afce666de0 +size 1284 diff --git a/assets/voxygen/voxel/sprite/leafy_plant/6.vox b/assets/voxygen/voxel/sprite/leafy_plant/6.vox index 1195bcfbf8..1ea45c7fe1 100644 --- a/assets/voxygen/voxel/sprite/leafy_plant/6.vox +++ b/assets/voxygen/voxel/sprite/leafy_plant/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bb29a2be29f4a9cbb4c8fe85c183f5e714b7755f0a8543ae14fd0bacb3f7955b -size 56043 +oid sha256:2546700413ad30593ca2f51c22f1b51dc9b94b43c9cbaa38ffecf18a7addbd07 +size 1292 diff --git a/assets/voxygen/voxel/sprite/leafy_plant/7.vox b/assets/voxygen/voxel/sprite/leafy_plant/7.vox index 75333653f0..57d2ee507f 100644 --- a/assets/voxygen/voxel/sprite/leafy_plant/7.vox +++ b/assets/voxygen/voxel/sprite/leafy_plant/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:133a4f32641a65843c38ecbb05863567813106b7ae3f652864af95f2b0d7ffdf -size 56003 +oid sha256:c50625eb6a07a0a3eb04975fa769b6301ad0f4f05f433adb1e3cb5b6b85b712d +size 1252 diff --git a/assets/voxygen/voxel/sprite/leafy_plant/8.vox b/assets/voxygen/voxel/sprite/leafy_plant/8.vox index c6d2d69999..f75a876043 100644 --- a/assets/voxygen/voxel/sprite/leafy_plant/8.vox +++ b/assets/voxygen/voxel/sprite/leafy_plant/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cfb5be221fdfeb5f16fbcf220cf487ed7e80c7078f042edfc6fbaabc2c0cc3b5 -size 56091 +oid sha256:5d37384289721949cfeb63c6429454d0356470c52a0d682a1147be46e801fa4d +size 1340 diff --git a/assets/voxygen/voxel/sprite/leafy_plant/9.vox b/assets/voxygen/voxel/sprite/leafy_plant/9.vox index 300ec11865..b4996a9d93 100644 --- a/assets/voxygen/voxel/sprite/leafy_plant/9.vox +++ b/assets/voxygen/voxel/sprite/leafy_plant/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e5b12020e170dffd9a6ef27e6b1c52df70a8500108e7a250949241e59725843a -size 55938 +oid sha256:74ffee6cdbda6bfed82453eb285a8d6f3d4bbc01abed21d73a96caf1ef075188 +size 1188 diff --git a/assets/voxygen/voxel/sprite/lianas/liana-0.vox b/assets/voxygen/voxel/sprite/lianas/liana-0.vox index 17d6c9ff16..7c41f0ff64 100644 --- a/assets/voxygen/voxel/sprite/lianas/liana-0.vox +++ b/assets/voxygen/voxel/sprite/lianas/liana-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cc7e966c151df969eba998d7db42b4f9c2692baac06007c578e5fd5f76257a8d -size 44614 +oid sha256:a814d732fb05062d88a69ca031a44ca0a7602d8176c4c2f7bd2fa297b5b6983f +size 1504 diff --git a/assets/voxygen/voxel/sprite/lianas/liana-1.vox b/assets/voxygen/voxel/sprite/lianas/liana-1.vox index 10c0f82c93..91a84ddfcf 100644 --- a/assets/voxygen/voxel/sprite/lianas/liana-1.vox +++ b/assets/voxygen/voxel/sprite/lianas/liana-1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:736508e09dadf421bda08cd7071bb343b5409d7228016fcd191934d9bdce16ee -size 44542 +oid sha256:aba2b0f74360c68d55869aa119bc8d12be11b31f8e4d7841938e1b7f98ddd2b6 +size 1432 diff --git a/assets/voxygen/voxel/sprite/lingonberry/1.vox b/assets/voxygen/voxel/sprite/lingonberry/1.vox index 810c35a96a..495ef481a7 100644 --- a/assets/voxygen/voxel/sprite/lingonberry/1.vox +++ b/assets/voxygen/voxel/sprite/lingonberry/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d7360f39a8586ca2ffb7ab9a83915dd2f7f71f918659b28c9dd2f74b7571fade -size 55962 +oid sha256:c06c3509d8bceffb5f7bd663e86a1c88d5ef72c4fc86e57511c13756bce3e998 +size 1208 diff --git a/assets/voxygen/voxel/sprite/lingonberry/2.vox b/assets/voxygen/voxel/sprite/lingonberry/2.vox index e1e91b4819..97b6479f80 100644 --- a/assets/voxygen/voxel/sprite/lingonberry/2.vox +++ b/assets/voxygen/voxel/sprite/lingonberry/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:573d189a28e73f31b0ef844d24d09b64f3ff9a1352d79b144e60cadcdb86ba3b -size 55894 +oid sha256:3d365f5e3d4295fde9e893f77cdc521d6c725e1d22ba833cbdfc01abe9dbe628 +size 1408 diff --git a/assets/voxygen/voxel/sprite/lingonberry/3.vox b/assets/voxygen/voxel/sprite/lingonberry/3.vox index 4afa3888c3..221289e105 100644 --- a/assets/voxygen/voxel/sprite/lingonberry/3.vox +++ b/assets/voxygen/voxel/sprite/lingonberry/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c2de4a70cbcc2fdc620943dbe540e74209ce0e31690f80a8503fedadeb3cf7ec -size 55819 +oid sha256:effa3d5c5776959346288693fc8c9eeab3f9510c099ffc523858419dd4867c22 +size 1332 diff --git a/assets/voxygen/voxel/sprite/mushrooms/mushroom-0.vox b/assets/voxygen/voxel/sprite/mushrooms/mushroom-0.vox index f4788d36a4..a2824a0262 100644 --- a/assets/voxygen/voxel/sprite/mushrooms/mushroom-0.vox +++ b/assets/voxygen/voxel/sprite/mushrooms/mushroom-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7b3b9a5b946e477c2fc83415453b375c7d20e2a745c5775dfaea4444d605ccd4 -size 44267 +oid sha256:65ed706fdb0b4ac5e66f22d2edcfc78dea308a51f3616e35cadac11ce8c22656 +size 1160 diff --git a/assets/voxygen/voxel/sprite/mushrooms/mushroom-10.vox b/assets/voxygen/voxel/sprite/mushrooms/mushroom-10.vox index 624733a756..f293502f1b 100644 --- a/assets/voxygen/voxel/sprite/mushrooms/mushroom-10.vox +++ b/assets/voxygen/voxel/sprite/mushrooms/mushroom-10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7a2508a2a557f5b3c6473ec7a00af1f46583d145a85f5bb8437c0097ee271066 -size 44555 +oid sha256:1bd2decf66c5b2c4712e7f2ae77ae4c530e79373a0ceed111f7254e98dbced6c +size 1448 diff --git a/assets/voxygen/voxel/sprite/mushrooms/mushroom-3.vox b/assets/voxygen/voxel/sprite/mushrooms/mushroom-3.vox index 6878d73760..fac5b3ca1f 100644 --- a/assets/voxygen/voxel/sprite/mushrooms/mushroom-3.vox +++ b/assets/voxygen/voxel/sprite/mushrooms/mushroom-3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9136b9445bc4ebd23744d9105ebdc570fc678f563d9cb493e7747dfa1efb96c0 -size 44351 +oid sha256:d262dc556c2c28fbba8d964aa7c2c42d78bec410e3aa1ee71eb353a7701a8b0e +size 1244 diff --git a/assets/voxygen/voxel/sprite/mushrooms/mushroom-4.vox b/assets/voxygen/voxel/sprite/mushrooms/mushroom-4.vox index 00ff0ad517..b7e0dba6dc 100644 --- a/assets/voxygen/voxel/sprite/mushrooms/mushroom-4.vox +++ b/assets/voxygen/voxel/sprite/mushrooms/mushroom-4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c0448145f03e200e4f09a78023d7f30b0899a6800c7ef1b293be259e69b70626 -size 55931 +oid sha256:192b8f2baddda973d5b9e55e2aaf0fe8dcb3ddc5be5d242cd6bab319b6f8a763 +size 1448 diff --git a/assets/voxygen/voxel/sprite/mushrooms/mushroom-5.vox b/assets/voxygen/voxel/sprite/mushrooms/mushroom-5.vox index 3132e61eb2..f32e812b5d 100644 --- a/assets/voxygen/voxel/sprite/mushrooms/mushroom-5.vox +++ b/assets/voxygen/voxel/sprite/mushrooms/mushroom-5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5585c33e889261346e527ab7915d00bfe2a4481259c102f33508c56a444f2e29 -size 44619 +oid sha256:5811aaf9f24505b2d089c9adc176ec906b746b506ae7e64434bc10638b3efd00 +size 1512 diff --git a/assets/voxygen/voxel/sprite/mushrooms/mushroom-6.vox b/assets/voxygen/voxel/sprite/mushrooms/mushroom-6.vox index 3731991771..a3af68eb4a 100644 --- a/assets/voxygen/voxel/sprite/mushrooms/mushroom-6.vox +++ b/assets/voxygen/voxel/sprite/mushrooms/mushroom-6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:02db7e016c7b20412e757547c7f86276974c467906a35b4c70883a3b8128acda -size 44447 +oid sha256:588d579a9c4dc18c5795459eb27b89082ace9ffabc2034815a0cff750464c9be +size 1340 diff --git a/assets/voxygen/voxel/sprite/mushrooms/mushroom-7.vox b/assets/voxygen/voxel/sprite/mushrooms/mushroom-7.vox index 86ad24fcd0..0a5fa93168 100644 --- a/assets/voxygen/voxel/sprite/mushrooms/mushroom-7.vox +++ b/assets/voxygen/voxel/sprite/mushrooms/mushroom-7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e2a25c0a08d80855400475b82bc2423af1f2af054efdefba4c42c0064652a8e4 -size 44331 +oid sha256:e0c01c8e11e19b510b7762389782721d55737857ed49230b557a59f10c5e932c +size 1224 diff --git a/assets/voxygen/voxel/sprite/mushrooms/mushroom-8.vox b/assets/voxygen/voxel/sprite/mushrooms/mushroom-8.vox index 656f084ddf..9ce82ae5a2 100644 --- a/assets/voxygen/voxel/sprite/mushrooms/mushroom-8.vox +++ b/assets/voxygen/voxel/sprite/mushrooms/mushroom-8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0e645c79d7fca501ce13f11c065f7a7316fc2859ad8b56db90644a9f821efbf6 -size 44359 +oid sha256:0ba9246881224580ae0b3df4a4ed7da8119744c48c62f2ab68eec3bb988a9513 +size 1252 diff --git a/assets/voxygen/voxel/sprite/mushrooms/mushroom-9.vox b/assets/voxygen/voxel/sprite/mushrooms/mushroom-9.vox index 99ba72460f..a081aa830e 100644 --- a/assets/voxygen/voxel/sprite/mushrooms/mushroom-9.vox +++ b/assets/voxygen/voxel/sprite/mushrooms/mushroom-9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9da8d612e2456f3a4a30de1ae800eb3e49e7c39625cb76f5b237f3ec4b241f5e -size 44539 +oid sha256:845460d4711a46dfd8666ed99591d50e846d3c35cc78e1a8fb2db62eba459d93 +size 1432 diff --git a/assets/voxygen/voxel/sprite/pumpkin/1.vox b/assets/voxygen/voxel/sprite/pumpkin/1.vox index acfb86a4c8..731d773e04 100644 --- a/assets/voxygen/voxel/sprite/pumpkin/1.vox +++ b/assets/voxygen/voxel/sprite/pumpkin/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:78d3c588742f2e5a27038f9941f31938ea1903543b436e036f5ca1909380e348 -size 30911 +oid sha256:09aedb0c998e662d2d9cb8a38d31094316804442b6aa68cb5533c043c07b87b8 +size 2568 diff --git a/assets/voxygen/voxel/sprite/pumpkin/2.vox b/assets/voxygen/voxel/sprite/pumpkin/2.vox index fe8002e648..a26eae8383 100644 --- a/assets/voxygen/voxel/sprite/pumpkin/2.vox +++ b/assets/voxygen/voxel/sprite/pumpkin/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3e592eb67bee97b702c557a80b81482fdb79235844b96afdc92a7f8268d40299 -size 30955 +oid sha256:cdf17c9e4feac356bf4941df983bfdb1c25bbe151d124dc24e177b793553bc99 +size 2612 diff --git a/assets/voxygen/voxel/sprite/pumpkin/3.vox b/assets/voxygen/voxel/sprite/pumpkin/3.vox index 66be67fa0e..bbbace60ec 100644 --- a/assets/voxygen/voxel/sprite/pumpkin/3.vox +++ b/assets/voxygen/voxel/sprite/pumpkin/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3cdaaa989326d92a54159aa9ae0b9dccb2f83f3fa0bf4235ad5bb46fa08bb461 -size 30923 +oid sha256:c42591c770fe910efb091b607e8f9c86f39ac687d70766251ee2a7f0e3da303e +size 2580 diff --git a/assets/voxygen/voxel/sprite/pumpkin/4.vox b/assets/voxygen/voxel/sprite/pumpkin/4.vox index 06160bec4f..8aea98cb56 100644 --- a/assets/voxygen/voxel/sprite/pumpkin/4.vox +++ b/assets/voxygen/voxel/sprite/pumpkin/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2caec7e41197dfaad625ca100de8f190772483ff8b7ebadc88cd5703a443e569 -size 30935 +oid sha256:735a9f6b32f207bf1ae0e1551c8789f08116991d97743e93620406b1d2850d2d +size 2592 diff --git a/assets/voxygen/voxel/sprite/pumpkin/5.vox b/assets/voxygen/voxel/sprite/pumpkin/5.vox index 3731b6d0c1..2bdf3cef8c 100644 --- a/assets/voxygen/voxel/sprite/pumpkin/5.vox +++ b/assets/voxygen/voxel/sprite/pumpkin/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b7cacac223c653c8b73e02b47fc55a3695fe06a798b5993b3387a6e3540fbd85 -size 30959 +oid sha256:260a5e45c90cbc153ecf1846a3461980710c648f682f62cf416d25c4c078db04 +size 2616 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_1.vox b/assets/voxygen/voxel/sprite/velorite/velorite_1.vox index ec1768dd96..ceea2e97cd 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_1.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7e96ae991ebf5cfa72ca348ec430668967fc04e75f458e843e4cae62ef4ef788 -size 44436 +oid sha256:8eececfffca6379c845a18ad21c226b6e76279574b09ab3db1303db65361f511 +size 1332 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_10.vox b/assets/voxygen/voxel/sprite/velorite/velorite_10.vox index fa686f0dbc..802b532def 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_10.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a07f51840fa53de0f62d21283eff60b6c88fa5a26c69b3c847c50120c274c88d -size 44480 +oid sha256:322d7832c4196899797335e7c4eb41887954a38b8b735ff0497b16d6043e3419 +size 1376 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_2.vox b/assets/voxygen/voxel/sprite/velorite/velorite_2.vox index ded60d71e4..c1d8e9ee63 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_2.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e010457fc3f41d6d704429ec71323994757fec4c5149a6334a8e9bcb63dd3c1 -size 44512 +oid sha256:3cdad254625676493f1e3b1546a6d8b37c781251dc0ae2ea25de559f542dedc6 +size 1408 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_3.vox b/assets/voxygen/voxel/sprite/velorite/velorite_3.vox index 8724a042cb..531f1f6e81 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_3.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:55b32b3a4eca12587bbb848de8e326cbd264b066144d5d2ca37feac0112a29bc -size 44452 +oid sha256:6d69c57dcaedf01985aae2e232c3db9b9da244baea9dddfbdb4bb509511acc43 +size 1348 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_4.vox b/assets/voxygen/voxel/sprite/velorite/velorite_4.vox index 83febbe7aa..35e5cebf53 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_4.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d95ebea771ed4438c4bad4b84a87edb32da65eb187b6ae4642daeb93fd73c8cb -size 44436 +oid sha256:cbdad9241fadbca80a21a0254b19d80c16d85ff32492482d899b28e9148aaf15 +size 1332 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_5.vox b/assets/voxygen/voxel/sprite/velorite/velorite_5.vox index 44f201fda0..7fdd8afea9 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_5.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f457b24de972880941f663cad3dd5687079df763f4bcdc69230bbaf6ba318606 -size 44468 +oid sha256:80887f9fb2ddbc44fa26b295bafd895263fe0191723bcbf14377c06627fe82fd +size 1364 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_6.vox b/assets/voxygen/voxel/sprite/velorite/velorite_6.vox index 64857bf36a..a737463af4 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_6.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0b9fca017e724914507a6604f9bc22ffd929e1282227726168e2d4d55c9ca974 -size 44408 +oid sha256:e2cd51a3ed11b54706e5e2e90d6e9bc1eea32f7db464b0e0d5a66414a251c734 +size 1304 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_7.vox b/assets/voxygen/voxel/sprite/velorite/velorite_7.vox index 73c5972a1a..2815dd9a59 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_7.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51142b773a0723eea1ecec2edce35fbfe0794a843bc655e92c1052d862b5cc78 -size 44508 +oid sha256:97e197a7e220f44a6c324f32512f744ec1206dab2e5aacf6d3a07a2881930a1a +size 1404 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_8.vox b/assets/voxygen/voxel/sprite/velorite/velorite_8.vox index 9faeb98634..39f3f6af7b 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_8.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2689f902b3d28c73f0d54afd09e6b564330610f02ee9de17ce98c3cf6623db6a -size 44340 +oid sha256:8e1eac4471f5a4b15c3fb1bb59bbdabd29024531b9fb92394bcc1f95844700ea +size 1236 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_9.vox b/assets/voxygen/voxel/sprite/velorite/velorite_9.vox index 5e72537ace..a39e99564b 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_9.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae35ed953bc5b0bd0196f095c9d5dbce1048b3fbbbf51aeeea9ac81a0196f49e -size 44416 +oid sha256:b31d490ccf8ba14e09b6e1605c292fc1cd37ad5831d8b59793575005ec3272be +size 1312 diff --git a/assets/voxygen/voxel/sprite/velorite/velorite_ore.vox b/assets/voxygen/voxel/sprite/velorite/velorite_ore.vox index d7caf61052..0e34869701 100644 --- a/assets/voxygen/voxel/sprite/velorite/velorite_ore.vox +++ b/assets/voxygen/voxel/sprite/velorite/velorite_ore.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1412107a5ce73b80dd8f91a9a61a232012680cd11e8c16c797ebf25388a1444b -size 57693 +oid sha256:c2670533afcfb70f2ecac6586ce863e02d067f68c208f7237c707461e06b6e7a +size 3212 diff --git a/assets/voxygen/voxel/sprite/welwitch/1.vox b/assets/voxygen/voxel/sprite/welwitch/1.vox index b47af24c3b..3a2c76cbeb 100644 --- a/assets/voxygen/voxel/sprite/welwitch/1.vox +++ b/assets/voxygen/voxel/sprite/welwitch/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a37b145fbd1e82dd6eff3512545be3e5dff7f9f07a15c095301994f7348afae3 -size 57636 +oid sha256:af1dbfe90347bd5c196b02fc19ab1f9c8cbc3db6a483b9d8d681bef448002e37 +size 3152 diff --git a/assets/world/module/human/door_big.vox b/assets/world/module/human/door_big.vox index a7b1fb2f37..03e2a5d720 100644 --- a/assets/world/module/human/door_big.vox +++ b/assets/world/module/human/door_big.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ea44b43263f79ca708b3b0fa196ed4eb2157521f4349b0c97524757950e4c59e -size 47099 +oid sha256:716c2f9e7c7fbdd2a0ce1b261967233d262223f905d4c2a23774527920211358 +size 3992 diff --git a/assets/world/structure/dungeon/meso_sewer_temple.vox b/assets/world/structure/dungeon/meso_sewer_temple.vox index 212170d4ed..4172cbf334 100644 --- a/assets/world/structure/dungeon/meso_sewer_temple.vox +++ b/assets/world/structure/dungeon/meso_sewer_temple.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c4c8d26d1273cff385a660bb3d8aaeda94263e77c9fdcda63ceaac7366d9de03 -size 1384956 +oid sha256:d186262d231775818d52c9d7613d2e832a03573981370f894e07c6bc25c5f81e +size 1330472 diff --git a/assets/world/structure/dungeon/ruins.vox b/assets/world/structure/dungeon/ruins.vox index af0aa47308..7141dda66b 100644 --- a/assets/world/structure/dungeon/ruins.vox +++ b/assets/world/structure/dungeon/ruins.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e5dd9935b439a64ecee8a58a5854189314a37714e76cc3388183afdff2ec2d10 -size 850124 +oid sha256:218bfbde154a099d7b2410337eab9e28682bab5a255eda5f20e96d035d142c27 +size 795640 diff --git a/assets/world/structure/dungeon/ruins_2.vox b/assets/world/structure/dungeon/ruins_2.vox index c8eb22eed8..8d919aa986 100644 --- a/assets/world/structure/dungeon/ruins_2.vox +++ b/assets/world/structure/dungeon/ruins_2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:439b57e8560b6b9167a992e83d94bc37da98e74552d304ed864cf1a3456f2c28 -size 750932 +oid sha256:0401ea93aeaa1b57248a309c49bc0f9b003dad971d2dbe5073b9c3a8d10f6226 +size 707824 diff --git a/assets/world/structure/human/blacksmith.vox b/assets/world/structure/human/blacksmith.vox index 78b85ca0fc..ff36b1c097 100644 --- a/assets/world/structure/human/blacksmith.vox +++ b/assets/world/structure/human/blacksmith.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0d5383bc6a28d2014ff5b2e170f86b20d36aad06224731f6c01a5cd3a7b44c2d -size 83276 +oid sha256:02de8d2db9d4046dbad44eef6b5e3f4ea827ca6a77a6076d121731ebd1b2fe65 +size 40168 diff --git a/assets/world/structure/human/house_1.vox b/assets/world/structure/human/house_1.vox index 4ea261776f..48cf82623a 100644 --- a/assets/world/structure/human/house_1.vox +++ b/assets/world/structure/human/house_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ff60c969d0b7d20b6de9e2fbcf5037675802e62b1580187983e3819a15761537 -size 8612 +oid sha256:ca799602961fa0d786081834352dd9c92e0149293d3f330517cef0fb0e90f88e +size 13400 diff --git a/assets/world/structure/human/mage_tower.vox b/assets/world/structure/human/mage_tower.vox index 0d2115c4c3..6969d0000b 100644 --- a/assets/world/structure/human/mage_tower.vox +++ b/assets/world/structure/human/mage_tower.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db4f7b604c35763c28aeafcfe7dc1d1722b2db77838677ffa5ef4fb08581be9d -size 41004 +oid sha256:f49b9458defb5de77c45e2f5266dadab448d1320f9593657df0e8f43ae260ff1 +size 76032 diff --git a/assets/world/structure/human/stables_1.vox b/assets/world/structure/human/stables_1.vox index ce5cf90ba3..4eb4a8e59d 100644 --- a/assets/world/structure/human/stables_1.vox +++ b/assets/world/structure/human/stables_1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4317ed2385e4a5da44a53a6c74c3b797c086a67290b2d4f722eb479557871479 -size 30660 +oid sha256:3a309d39bd5c3fafb402d249e76cf1ab6f22fcf1ba64491b466729b8fcf65aaa +size 49752 diff --git a/assets/world/structure/human/town_hall.vox b/assets/world/structure/human/town_hall.vox index 8befbaa750..1c2b0d9943 100644 --- a/assets/world/structure/human/town_hall.vox +++ b/assets/world/structure/human/town_hall.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:42595711180fbecf049f52b4e4c39a8d34d732d4aae841e7e32bd317a39c49e2 -size 80900 +oid sha256:5b7d7368adb164d98b2275cb228c0e75c4c57af0af6cfcc8080b420fbc404c8b +size 46848 diff --git a/assets/world/structure/human/town_hall_spire.vox b/assets/world/structure/human/town_hall_spire.vox index f23eb7e8dc..0e7218ab28 100644 --- a/assets/world/structure/human/town_hall_spire.vox +++ b/assets/world/structure/human/town_hall_spire.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:81bed37162a2179b1e3cc9cf2b1a78fe2498acc9bbbbbca521884c87f0babe85 -size 81773 +oid sha256:9bc99805b91d0db7767b3228ef8c69b13dfa344fe6fd607c309f87c847f1473d +size 48640 diff --git a/assets/world/structure/natural/tower-ruin.vox b/assets/world/structure/natural/tower-ruin.vox index 3a93401000..daf8e581ad 100644 --- a/assets/world/structure/natural/tower-ruin.vox +++ b/assets/world/structure/natural/tower-ruin.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b517ad8d5eec968b1fffb9a8b86d0a42841db2587e38fedd9c0be61c4f6668f3 -size 108341 +oid sha256:9ec122d3d5f63af2210361c215845b582c15e15f9c7f1a9a65afcaf9d77accca +size 53856 diff --git a/assets/world/structure/natural/witch-hut.vox b/assets/world/structure/natural/witch-hut.vox index 38680d217a..306f65b77f 100644 --- a/assets/world/structure/natural/witch-hut.vox +++ b/assets/world/structure/natural/witch-hut.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2901a54ea9a00e87575080069eaac436962e83394dbd207b5322ab6c6c725c0c -size 72628 +oid sha256:64d9e6236966f747004b3de4a5a8b00fb98223787a984b526790956e7d0f9d4b +size 18144 diff --git a/assets/world/tree/acacia/1.vox b/assets/world/tree/acacia/1.vox index 7f3bb1b173..310198c54f 100644 --- a/assets/world/tree/acacia/1.vox +++ b/assets/world/tree/acacia/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:96fbf34cd1b8bf56bf6bd369ddfbbba6ba181b0ffbd7367c15a1a32a0dd25379 -size 77084 +oid sha256:3e1fee1ea15e891aa424ea8054f5ea5bb02f1e6991c771d4191f0e655aba109b +size 22600 diff --git a/assets/world/tree/acacia/2.vox b/assets/world/tree/acacia/2.vox index c80037b118..08cb8d7e49 100644 --- a/assets/world/tree/acacia/2.vox +++ b/assets/world/tree/acacia/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b89cd2aa4c79d86637e82f325bdb5f3ebb89e0c216c97e891b1f05f7f14bf91 -size 56643 +oid sha256:976e990871ab219ca3023eaaad8d7e92a5ed4823555b819dabce6c60581a922f +size 2160 diff --git a/assets/world/tree/acacia/3.vox b/assets/world/tree/acacia/3.vox index 30d4e6bf6a..cb06009f12 100644 --- a/assets/world/tree/acacia/3.vox +++ b/assets/world/tree/acacia/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b086b9949e2025fc674b0df09ce8d490b646537ee89cfbd70717db0c253afbc2 -size 57551 +oid sha256:3d9bb5949defcad8260a0293a6e42429440dfff4833edfa9a04caf06ef5895e3 +size 3068 diff --git a/assets/world/tree/acacia/4.vox b/assets/world/tree/acacia/4.vox index cdee6ba1c6..30b2e0efde 100644 --- a/assets/world/tree/acacia/4.vox +++ b/assets/world/tree/acacia/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0ed2d8fe61bae4f075f95e5f1a14936cadab3bc69eac0784672557942314d878 -size 72196 +oid sha256:2071db98db659494ee497e7ed728c3cbf838fb7f02594b5255417e5e13e182ac +size 17712 diff --git a/assets/world/tree/acacia/5.vox b/assets/world/tree/acacia/5.vox index f744a7aaec..9cf8015236 100644 --- a/assets/world/tree/acacia/5.vox +++ b/assets/world/tree/acacia/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9dc5d76617a8aa6ae70e692b30e7f71ba6e32b558a1934446eca77ebdabb59f1 -size 88204 +oid sha256:9fc04f31dd7fb85219500d6145233663e6f1a040aed8b4acc84585e626c10b82 +size 33720 diff --git a/assets/world/tree/acacia_2/1.vox b/assets/world/tree/acacia_2/1.vox index cda1574acc..1e34877f5c 100644 --- a/assets/world/tree/acacia_2/1.vox +++ b/assets/world/tree/acacia_2/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c8f5224352c662e4400b16f0ebff2ee7accdf188b20748d5049f16f7011902bd -size 51468 +oid sha256:e1b58989ac01175fba006ec70815959a8cdc7fe3035c43f3464a06afd5f65f98 +size 8360 diff --git a/assets/world/tree/acacia_2/2.vox b/assets/world/tree/acacia_2/2.vox index 32ecce590e..b7719a4cec 100644 --- a/assets/world/tree/acacia_2/2.vox +++ b/assets/world/tree/acacia_2/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fcbe884c673e8e16911318fe228bfba6bc36e65bc1f8c26c9706d92719eac97c -size 44527 +oid sha256:5b17758334983bbd97eef5a66b64c1828bee6df480b745ed2e47e046c047f10e +size 1420 diff --git a/assets/world/tree/acacia_2/3.vox b/assets/world/tree/acacia_2/3.vox index 8bc06e54cc..d0c14bc134 100644 --- a/assets/world/tree/acacia_2/3.vox +++ b/assets/world/tree/acacia_2/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9734b6769fa66c77ddee14490b1c6a1241048fbdf7f7cfacfefb77c045e484b2 -size 44795 +oid sha256:adc156f886d8fddc6c456ec85c21c0561aee7fa5f51a1a9b074b704e3c0b92ad +size 1688 diff --git a/assets/world/tree/acacia_2/4.vox b/assets/world/tree/acacia_2/4.vox index 6bc02dac6e..ebeb422216 100644 --- a/assets/world/tree/acacia_2/4.vox +++ b/assets/world/tree/acacia_2/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c2a53a49c63b45712ee7ddcf9c6ec991193bc17041d12f63264e6372e112c056 -size 51196 +oid sha256:ece352f8ce6034fd20efca429b46426a66a7a2e637a6ec82b8e718af14ceb547 +size 8088 diff --git a/assets/world/tree/acacia_2/5.vox b/assets/world/tree/acacia_2/5.vox index 0c22065caa..77c24923f8 100644 --- a/assets/world/tree/acacia_2/5.vox +++ b/assets/world/tree/acacia_2/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cdea24bb04530868486a9b50a84c756a5a90981a70af1bb3c50c1ca72e3b666e -size 51672 +oid sha256:c030cffb4f8f5f908a70046bef904daa4e065d78f718ec22579a05139fba4103 +size 8564 diff --git a/assets/world/tree/acacia_savannah/1.vox b/assets/world/tree/acacia_savannah/1.vox index cda1574acc..1e34877f5c 100644 --- a/assets/world/tree/acacia_savannah/1.vox +++ b/assets/world/tree/acacia_savannah/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c8f5224352c662e4400b16f0ebff2ee7accdf188b20748d5049f16f7011902bd -size 51468 +oid sha256:e1b58989ac01175fba006ec70815959a8cdc7fe3035c43f3464a06afd5f65f98 +size 8360 diff --git a/assets/world/tree/acacia_savannah/2.vox b/assets/world/tree/acacia_savannah/2.vox index 32ecce590e..b7719a4cec 100644 --- a/assets/world/tree/acacia_savannah/2.vox +++ b/assets/world/tree/acacia_savannah/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fcbe884c673e8e16911318fe228bfba6bc36e65bc1f8c26c9706d92719eac97c -size 44527 +oid sha256:5b17758334983bbd97eef5a66b64c1828bee6df480b745ed2e47e046c047f10e +size 1420 diff --git a/assets/world/tree/acacia_savannah/3.vox b/assets/world/tree/acacia_savannah/3.vox index 8bc06e54cc..d0c14bc134 100644 --- a/assets/world/tree/acacia_savannah/3.vox +++ b/assets/world/tree/acacia_savannah/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9734b6769fa66c77ddee14490b1c6a1241048fbdf7f7cfacfefb77c045e484b2 -size 44795 +oid sha256:adc156f886d8fddc6c456ec85c21c0561aee7fa5f51a1a9b074b704e3c0b92ad +size 1688 diff --git a/assets/world/tree/acacia_savannah/4.vox b/assets/world/tree/acacia_savannah/4.vox index 6bc02dac6e..ebeb422216 100644 --- a/assets/world/tree/acacia_savannah/4.vox +++ b/assets/world/tree/acacia_savannah/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c2a53a49c63b45712ee7ddcf9c6ec991193bc17041d12f63264e6372e112c056 -size 51196 +oid sha256:ece352f8ce6034fd20efca429b46426a66a7a2e637a6ec82b8e718af14ceb547 +size 8088 diff --git a/assets/world/tree/acacia_savannah/5.vox b/assets/world/tree/acacia_savannah/5.vox index 0c22065caa..77c24923f8 100644 --- a/assets/world/tree/acacia_savannah/5.vox +++ b/assets/world/tree/acacia_savannah/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cdea24bb04530868486a9b50a84c756a5a90981a70af1bb3c50c1ca72e3b666e -size 51672 +oid sha256:c030cffb4f8f5f908a70046bef904daa4e065d78f718ec22579a05139fba4103 +size 8564 diff --git a/assets/world/tree/birch/1.vox b/assets/world/tree/birch/1.vox index a9ad3ad272..e7b73f2e3d 100644 --- a/assets/world/tree/birch/1.vox +++ b/assets/world/tree/birch/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4feb6fa04b9a6f690fcc7d38b95f7241f60755ce01f7f997085604e31b77c4e -size 81146 +oid sha256:12d70c9eb73e1dcdacb0d69bd9a15779c14330b9abf300fc72d8dbc5aeb94fc2 +size 26648 diff --git a/assets/world/tree/birch/10.vox b/assets/world/tree/birch/10.vox index a4d6dc6e5c..55b2cb4255 100644 --- a/assets/world/tree/birch/10.vox +++ b/assets/world/tree/birch/10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:44bf3260cc277fbc8d4dee3bf03ecee2731bba50be71c9cd0bfd8c09e6e15a47 -size 64047 +oid sha256:e41bc0f1f3dd4e132bc36f882c24f3b86250c45094a6148b54eebbc8ec390357 +size 9548 diff --git a/assets/world/tree/birch/11.vox b/assets/world/tree/birch/11.vox index 953562c42e..8308161019 100644 --- a/assets/world/tree/birch/11.vox +++ b/assets/world/tree/birch/11.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:116453e56fa397af73a745f9ea65c57c9a9e789fef9343b941e2dba3fdac2f48 -size 60803 +oid sha256:45a343718083ea858bfad37877c325f6f7072c8d8e6bfb733f52f99741a1e2a7 +size 6304 diff --git a/assets/world/tree/birch/12.vox b/assets/world/tree/birch/12.vox index 953562c42e..8308161019 100644 --- a/assets/world/tree/birch/12.vox +++ b/assets/world/tree/birch/12.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:116453e56fa397af73a745f9ea65c57c9a9e789fef9343b941e2dba3fdac2f48 -size 60803 +oid sha256:45a343718083ea858bfad37877c325f6f7072c8d8e6bfb733f52f99741a1e2a7 +size 6304 diff --git a/assets/world/tree/birch/2.vox b/assets/world/tree/birch/2.vox index 0b89405a7d..88b07be8e4 100644 --- a/assets/world/tree/birch/2.vox +++ b/assets/world/tree/birch/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8065a64cf3e79c94d1d4e12917a428efa145d1c8cb30279a67f71c781cbe7ff1 -size 78771 +oid sha256:4509282720a2888e579608a6e980653e0011e6d9efa0e8e3ab949e526275455a +size 24272 diff --git a/assets/world/tree/birch/3.vox b/assets/world/tree/birch/3.vox index b86528f3f1..0ba3461cfe 100644 --- a/assets/world/tree/birch/3.vox +++ b/assets/world/tree/birch/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4d2e54569129b94ba9e53d7a704862819fc696956cfb9766168230b8b4667e5 -size 65746 +oid sha256:4862bd818c18d3f182d6d4131a74154fd594ef97889efbfd42502f3bad8a1ad5 +size 11248 diff --git a/assets/world/tree/birch/4.vox b/assets/world/tree/birch/4.vox index 0c4c4326a5..13fc3a7710 100644 --- a/assets/world/tree/birch/4.vox +++ b/assets/world/tree/birch/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6c69b2bba7f3bc783388ca543f2949b43e26845633993f5ead407b8658739b42 -size 62803 +oid sha256:2e39d763277a9b3b6faba30e0437e5222b66acaa27e588151f215db5487a9a72 +size 8304 diff --git a/assets/world/tree/birch/5.vox b/assets/world/tree/birch/5.vox index 23a5ea04c5..f0b4fb9f2a 100644 --- a/assets/world/tree/birch/5.vox +++ b/assets/world/tree/birch/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5edb7f5238465dbef648ca870b5f757dfe6e0d169981e758f3732072889378dc -size 65646 +oid sha256:05fcb5e3434ff0a00f721f6ed4cbba409d09b5db696008d42a546d2d16d415cb +size 11148 diff --git a/assets/world/tree/birch/6.vox b/assets/world/tree/birch/6.vox index 3446c136ca..6ad324f14d 100644 --- a/assets/world/tree/birch/6.vox +++ b/assets/world/tree/birch/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:16f732bc64a135c159a4b79354baf98ee3635af364a07bcde87ea90db3be06fb -size 59982 +oid sha256:6243ed0c14c0da325de68696f69386f52ca3a878f7691599864aa9402e825cba +size 5484 diff --git a/assets/world/tree/birch/7.vox b/assets/world/tree/birch/7.vox index 457b7c0289..53a6e5af94 100644 --- a/assets/world/tree/birch/7.vox +++ b/assets/world/tree/birch/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b526678365634589a95cd450908e2c3bb18d90f9f8844209f57da1621ce9ec30 -size 61482 +oid sha256:341ff6145c2435b03258bd75da404fdd1ce186507dfd04b380224a1558867003 +size 6984 diff --git a/assets/world/tree/birch/8.vox b/assets/world/tree/birch/8.vox index 3b80814a10..c004751306 100644 --- a/assets/world/tree/birch/8.vox +++ b/assets/world/tree/birch/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:39146dbe33335e1bcdd2dc20d5a4fa6461ebc78661ab09334c73bbd70b803bad -size 63562 +oid sha256:f163166734a983cba401e68b8fccaf0b077a59150b1f2e829f5540dd15e3e6f0 +size 9064 diff --git a/assets/world/tree/birch/9.vox b/assets/world/tree/birch/9.vox index 0053d0af1f..3889a13a27 100644 --- a/assets/world/tree/birch/9.vox +++ b/assets/world/tree/birch/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7aef2d5997afbd3bc54b94ceb4e7a9cef2571f60419eff6232198dd66f97fc8b -size 61114 +oid sha256:431603f089ba004d648faf2dc75cbb332893af50c84330581f4ff5bc2d4ddd5d +size 6616 diff --git a/assets/world/tree/desert_palm/1.vox b/assets/world/tree/desert_palm/1.vox index 0c4eb78c72..bec36a7ddf 100644 --- a/assets/world/tree/desert_palm/1.vox +++ b/assets/world/tree/desert_palm/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3c513ebf3211c3d54b2c3c6958611ee9f731631358c526abc99d7cd5d319ebfb -size 57052 +oid sha256:abe347ac442a2afc287869f9d2256c5af2b6507f4d1fa370f39769a95119713c +size 2568 diff --git a/assets/world/tree/desert_palm/10.vox b/assets/world/tree/desert_palm/10.vox index fb4bdcff49..c0daf1cff2 100644 --- a/assets/world/tree/desert_palm/10.vox +++ b/assets/world/tree/desert_palm/10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b354e9dcb5d0248c2c5a6ff957a6672056857db2fff866dc95eeeaf42f73d602 -size 57840 +oid sha256:06a39754b0d316639d487275ea85534eb6a325a4d70b4e987450c1c702f12e01 +size 3356 diff --git a/assets/world/tree/desert_palm/2.vox b/assets/world/tree/desert_palm/2.vox index ee651885f5..7c582c5ae1 100644 --- a/assets/world/tree/desert_palm/2.vox +++ b/assets/world/tree/desert_palm/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:63d2ef68f5f9a3784d07b4c76b44ae142de65c5b6a7b07648216b316a5c72311 -size 57020 +oid sha256:807b9c55da8106d93d538d2e55b9cb3056cd01c35d98eb6cead69a9814e71225 +size 2536 diff --git a/assets/world/tree/desert_palm/3.vox b/assets/world/tree/desert_palm/3.vox index 5876b4ba4b..c8862eaee3 100644 --- a/assets/world/tree/desert_palm/3.vox +++ b/assets/world/tree/desert_palm/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:19074146b71d0cad6ebf4706ce0951be12d3af06b4afe17d594a12275c877b02 -size 57212 +oid sha256:a8869e83bc5fd1263d512153ea1e30296ffcce3d87f319edd488ee4d1c9fb4a7 +size 2728 diff --git a/assets/world/tree/desert_palm/4.vox b/assets/world/tree/desert_palm/4.vox index 7d13d8b3d8..83ee9bcdbb 100644 --- a/assets/world/tree/desert_palm/4.vox +++ b/assets/world/tree/desert_palm/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:22e6d4bcc29a4e0a8c35835e1c0fcc372053c80accbb0f0599bcaf7299ce4a7b -size 57148 +oid sha256:d9d7b5343efd602dfbb5f2fa61ad2882a67a1554a977f14d68b916229e284409 +size 2664 diff --git a/assets/world/tree/desert_palm/5.vox b/assets/world/tree/desert_palm/5.vox index e4ced51f77..3ca1dc1d68 100644 --- a/assets/world/tree/desert_palm/5.vox +++ b/assets/world/tree/desert_palm/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bd6107d228e05a15a9ff2c8acb219d4db818b408dfcd2ee558d8ed7203070c03 -size 57152 +oid sha256:d37842b815dcb28c0c2004d150ef2f0cbb466a1fc64934beb469e6f8312502c8 +size 2668 diff --git a/assets/world/tree/desert_palm/6.vox b/assets/world/tree/desert_palm/6.vox index 9057fb584b..93e02f1ba3 100644 --- a/assets/world/tree/desert_palm/6.vox +++ b/assets/world/tree/desert_palm/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8af2b8ed51ad5224cedc87d481fed965935bf75280a5a6f19120d43a544e5db8 -size 57252 +oid sha256:06876ab785668631c73147d4cea201e40579746055cab5f505f0d3017e21fe88 +size 2768 diff --git a/assets/world/tree/desert_palm/7.vox b/assets/world/tree/desert_palm/7.vox index eb7e973649..4445dbf3b3 100644 --- a/assets/world/tree/desert_palm/7.vox +++ b/assets/world/tree/desert_palm/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:156a9c3592e0d9a0fb90f1459b1c8310fe33f3dced04eb58c3cbcdd866cf139a -size 57524 +oid sha256:b7ae32444793fe113333e6969597eb8864b5212b0326eb0506c68cbde224d810 +size 3040 diff --git a/assets/world/tree/desert_palm/8.vox b/assets/world/tree/desert_palm/8.vox index b4beddc15d..579d53bf10 100644 --- a/assets/world/tree/desert_palm/8.vox +++ b/assets/world/tree/desert_palm/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7257c5316e7a8b8dd559bc0c511ed0b9b84eafdc758568fe53a71c0e0f7527ea -size 57188 +oid sha256:c33f5c43adf96b9a405f50b29bdb226b2775b3cca69692f3629afcc558f54cab +size 2704 diff --git a/assets/world/tree/desert_palm/9.vox b/assets/world/tree/desert_palm/9.vox index 7a6c2ec610..58315225c9 100644 --- a/assets/world/tree/desert_palm/9.vox +++ b/assets/world/tree/desert_palm/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a200ed2670bcdf2d7c1ef42aaf23dc253d1d6f87d0723c6a985465ca99259cb4 -size 57636 +oid sha256:3005d011c0a2cb0117adafffbb884c97ee8b6491e104cbcb97410be325acc096 +size 3152 diff --git a/assets/world/tree/desert_palm_old/1.vox b/assets/world/tree/desert_palm_old/1.vox index fff6ba1b91..bec36a7ddf 100644 --- a/assets/world/tree/desert_palm_old/1.vox +++ b/assets/world/tree/desert_palm_old/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db332ddd98b5175986dce254759eee3e6561cd559dcb9f58218ad7113577a1cd -size 46479 +oid sha256:abe347ac442a2afc287869f9d2256c5af2b6507f4d1fa370f39769a95119713c +size 2568 diff --git a/assets/world/tree/desert_palm_old/10.vox b/assets/world/tree/desert_palm_old/10.vox index f1d77777ec..e05ad08d54 100644 --- a/assets/world/tree/desert_palm_old/10.vox +++ b/assets/world/tree/desert_palm_old/10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3c3d3ef277cf6d52bebcd9478e51f7779dfe3c7b4f2e3fd1a611b993108249ac -size 46138 +oid sha256:10cebeb0facf61c5e5b01e0cb4a2c53d3871677f3c120ac14164afc89df32b87 +size 3004 diff --git a/assets/world/tree/desert_palm_old/2.vox b/assets/world/tree/desert_palm_old/2.vox index 50d106ffcf..a182725d0a 100644 --- a/assets/world/tree/desert_palm_old/2.vox +++ b/assets/world/tree/desert_palm_old/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e330bf9979b2c4f59c33e464dcdf4bb25fc4cf3348ab4e191f6f3c36bfca5f6a -size 46189 +oid sha256:caca1a9c7c717e3dcc2fe5787e69139d816ddd2cb0cb5ad54c51298f28764a9e +size 3056 diff --git a/assets/world/tree/desert_palm_old/3.vox b/assets/world/tree/desert_palm_old/3.vox index 7e2c279a1d..60a255cea8 100644 --- a/assets/world/tree/desert_palm_old/3.vox +++ b/assets/world/tree/desert_palm_old/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9dd9002762da1a11816e42066b937fc943d94f095ffe1cd28ad64df6f09cf7da -size 46585 +oid sha256:51016319e64f1df1a5121e14a488aacf35e29c5676fcba4ffcc595c439c22508 +size 3452 diff --git a/assets/world/tree/desert_palm_old/4.vox b/assets/world/tree/desert_palm_old/4.vox index 5080c63b60..c523f8be06 100644 --- a/assets/world/tree/desert_palm_old/4.vox +++ b/assets/world/tree/desert_palm_old/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65edf5be2cb4e192bc0f575c63c3824e20fd454bd7766b92624078404b27ba05 -size 46289 +oid sha256:5460e522e7026bf2f0f1b4f46f7d7fcff0e675c8cfcb216f39978f61f2bb4a96 +size 3156 diff --git a/assets/world/tree/desert_palm_old/5.vox b/assets/world/tree/desert_palm_old/5.vox index 63613e35f0..282c8bce65 100644 --- a/assets/world/tree/desert_palm_old/5.vox +++ b/assets/world/tree/desert_palm_old/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d1507a908ac2381b29045ef6d4b52d7868e3e712bd1d3e4c7635127f86ac088 -size 46145 +oid sha256:71ad147f6040ddca601f6eb35f06963bca0b5a0c9fdc9f848605487212bbd475 +size 3012 diff --git a/assets/world/tree/desert_palm_old/6.vox b/assets/world/tree/desert_palm_old/6.vox index a5e24de749..0b4b8b6d25 100644 --- a/assets/world/tree/desert_palm_old/6.vox +++ b/assets/world/tree/desert_palm_old/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b1c8184dd48feaf4665fa5e866a01080894494a1893c95b9465eb34f8bcb0c5a -size 46113 +oid sha256:e139c706a46394f4f84f0a3c948976a96c08d41b683a14bd47559d54f688a9e4 +size 2980 diff --git a/assets/world/tree/desert_palm_old/7.vox b/assets/world/tree/desert_palm_old/7.vox index 1fe792529b..9631bc5e3f 100644 --- a/assets/world/tree/desert_palm_old/7.vox +++ b/assets/world/tree/desert_palm_old/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:57ad80786e3e98e941693ace3c12d840de97bc13ac1c61b72f94db4ced3cd372 -size 46355 +oid sha256:ff5522828c67a45e8debcf1137fd871cab50e1dcd7d0d8d8fe1d82571284e6b1 +size 3236 diff --git a/assets/world/tree/desert_palm_old/8.vox b/assets/world/tree/desert_palm_old/8.vox index 673abcfb43..2e87ef74b0 100644 --- a/assets/world/tree/desert_palm_old/8.vox +++ b/assets/world/tree/desert_palm_old/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c2b901ce347828826e297c47a33000156f741ed43f33e2639317022a98f2a5dc -size 46257 +oid sha256:4d2711eabe9972f49449441e2ef0742b07b6e718cf4a81bbaba24c98ebc05b5a +size 3124 diff --git a/assets/world/tree/desert_palm_old/9.vox b/assets/world/tree/desert_palm_old/9.vox index 29756cff4b..f81f3e583f 100644 --- a/assets/world/tree/desert_palm_old/9.vox +++ b/assets/world/tree/desert_palm_old/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:557b27a10044a9e4228a77e8534e69382a22219c77a99e553feab6be4b03cc12 -size 46289 +oid sha256:db651fae2577f2d6d0e2c5e74484dba793edffe914313b90a1aaf0aafb22fffa +size 3156 diff --git a/assets/world/tree/fruit/1.vox b/assets/world/tree/fruit/1.vox index b4cf33a833..9d3539eeb5 100644 --- a/assets/world/tree/fruit/1.vox +++ b/assets/world/tree/fruit/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a0f89bd6bbe56c3759edee2155c4461d408e727b11261d78408a887557d73ec0 -size 45945 +oid sha256:525d55c479c0aebe717dc8eba0cde69c1177b1feaa85e4fb83991d68460cc682 +size 3360 diff --git a/assets/world/tree/fruit/2.vox b/assets/world/tree/fruit/2.vox index fa1e2f3a19..b4c19ba55a 100644 --- a/assets/world/tree/fruit/2.vox +++ b/assets/world/tree/fruit/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9462cb554dbf83893e634226ccb9db149d03e490d122e6d1876d225581538754 -size 47877 +oid sha256:9452cd1dfe06d4eb4a51b0536ae4836b77fbf02d4d80da1ed227a4d4ea93ff32 +size 4768 diff --git a/assets/world/tree/fruit/3.vox b/assets/world/tree/fruit/3.vox index 4843141be7..592f0f86c5 100644 --- a/assets/world/tree/fruit/3.vox +++ b/assets/world/tree/fruit/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1f3e8d2ec16b41db66190ba43bd8910d45fbab113dbe2d498db0d3e01f33ef1a -size 49165 +oid sha256:b0544810cad5496d0c7d6bb6973a6c7ded441f3184258efef27e6b8a1735605e +size 6056 diff --git a/assets/world/tree/fruit/4.vox b/assets/world/tree/fruit/4.vox index 58aa6273d7..a36a86f668 100644 --- a/assets/world/tree/fruit/4.vox +++ b/assets/world/tree/fruit/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:621466a1e25e08b1c80eb3d017a3fb0233e6f3182053277a9aef5a1bcfc2611f -size 45317 +oid sha256:cd38a56cb16eada7b1ece8dc1c3ef57fdac6c067ffbc0c21caaaa7845f5bdf53 +size 2208 diff --git a/assets/world/tree/fruit/5.vox b/assets/world/tree/fruit/5.vox index a68ed85026..b873c149a7 100644 --- a/assets/world/tree/fruit/5.vox +++ b/assets/world/tree/fruit/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:139b5e7ab4df1a969f0a090de0bdf87ecfae58b157d9c12091b79152f3f00659 -size 48853 +oid sha256:c71e99296fd036f1188fc249c9a6cde56bb28ca87a27c9552841ef1bf7f26e6e +size 5744 diff --git a/assets/world/tree/fruit/6.vox b/assets/world/tree/fruit/6.vox index 6fff562c22..8ad90de1b1 100644 --- a/assets/world/tree/fruit/6.vox +++ b/assets/world/tree/fruit/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3dad59c08180acc8f8ed3307e6ec7561098c4d8777bde48fd4007608deb3f415 -size 49153 +oid sha256:7c80c9cb3abf230ba078fe7d0762c86656763acfb1f7a3906d0af19e751c81fa +size 6044 diff --git a/assets/world/tree/mangroves/1.vox b/assets/world/tree/mangroves/1.vox index a2ddeafc07..01c27e08d2 100644 --- a/assets/world/tree/mangroves/1.vox +++ b/assets/world/tree/mangroves/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f7a77de284af943c8037ce526cf953bfeba5cecc0c7a618eb1235de2b1d8397b -size 92800 +oid sha256:8b2216711df71746938e13dd5d764d2d440b9b41342e870db311c31edd863b55 +size 38312 diff --git a/assets/world/tree/mangroves/2.vox b/assets/world/tree/mangroves/2.vox index e4dac3cd19..3ee653ec0b 100644 --- a/assets/world/tree/mangroves/2.vox +++ b/assets/world/tree/mangroves/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:130e42d52d64da1838b02c05452633c79405bc6c539d600d0ab5b4cca8e0d97b -size 82388 +oid sha256:3071e34a8192189c7f7c70bc4a75a06122c27a82e0bfc8d299c8843f8f42b6be +size 27900 diff --git a/assets/world/tree/mangroves/3.vox b/assets/world/tree/mangroves/3.vox index e100044a42..bf9fb014b2 100644 --- a/assets/world/tree/mangroves/3.vox +++ b/assets/world/tree/mangroves/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7735e2b70eb6e9c73e179f2bc9e93ea4fc115583ffd8b9a2d7e5f818372f1b42 -size 107016 +oid sha256:c35603fdbec8a0ed14cbf58133fefd999b457dda56bf8bb66ea519fa65a4bf04 +size 52528 diff --git a/assets/world/tree/mangroves/4.vox b/assets/world/tree/mangroves/4.vox index 72f4f68fee..4499836fcb 100644 --- a/assets/world/tree/mangroves/4.vox +++ b/assets/world/tree/mangroves/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a2e50b5dd0588d478cbc9eef360d3d0f35baa8984b0c12612e12b1ab271b19c6 -size 103344 +oid sha256:4dbca327b6129910e95f235c2c6d334b2ec0b77b192030ff0c5eb620fedaaff0 +size 48860 diff --git a/assets/world/tree/mangroves/5.vox b/assets/world/tree/mangroves/5.vox index 1ed5180763..ee34c5a1ce 100644 --- a/assets/world/tree/mangroves/5.vox +++ b/assets/world/tree/mangroves/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7b14f0750c28c624d3ba7d40a91c94b523cabeb093cecda28fc513ae27e965a3 -size 99336 +oid sha256:28c0db8409627938b41986bf976d8ff5a84f86e036fb385fb52228b743ad5c73 +size 44852 diff --git a/assets/world/tree/mangroves/6.vox b/assets/world/tree/mangroves/6.vox index 1d119e2641..6a479a72f5 100644 --- a/assets/world/tree/mangroves/6.vox +++ b/assets/world/tree/mangroves/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d63e1d72070ffd05d13514002c382e3ea5bcabb060cacc7e0d2fb8ae1bdcfa5 -size 117544 +oid sha256:05ae9ce6977e4b7ff6752023e53a6488e4ea8b2873f5aeb726dc83ffdbe85fbc +size 63060 diff --git a/assets/world/tree/mangroves/7.vox b/assets/world/tree/mangroves/7.vox index 10d1879771..dbfb89aae5 100644 --- a/assets/world/tree/mangroves/7.vox +++ b/assets/world/tree/mangroves/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:32aa2cea45cbeac63e1997e3887c8a5ba7f5d3bd3ec97007a2d8262791d19187 -size 104228 +oid sha256:963035ca5f4ab5b436620c1de7a0ef2e9ae8b57c54cd055db5c935f6147bd082 +size 49744 diff --git a/assets/world/tree/mangroves/8.vox b/assets/world/tree/mangroves/8.vox index 00d278c049..af66eaadfb 100644 --- a/assets/world/tree/mangroves/8.vox +++ b/assets/world/tree/mangroves/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:812ab3d5234040d75fa97b05aa5f50ac5f11bc79baf1c30f5280ca3badf6924b -size 123004 +oid sha256:3aaa46ee933a356a7b4f9f2fdb93ce4ec6b8383be6bc202022d461291de19bb9 +size 68520 diff --git a/assets/world/tree/oak_green/1.vox b/assets/world/tree/oak_green/1.vox index c2227fc623..2f3f218fc4 100644 --- a/assets/world/tree/oak_green/1.vox +++ b/assets/world/tree/oak_green/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:90cb2531d3a7bbf5a856b93abed2b4fa6c99038d2b1c119c01319e9bc6b092bd -size 80540 +oid sha256:0ae73d01cec664140951e5352897e23d1be22023e298e6f23640b7114f3afe2d +size 37436 diff --git a/assets/world/tree/oak_green/2.vox b/assets/world/tree/oak_green/2.vox index 1ab9fe3e60..efe83ff0c5 100644 --- a/assets/world/tree/oak_green/2.vox +++ b/assets/world/tree/oak_green/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8cbe46a82f64ec25e3dba71606d2215e601b2bc643b7422fb50a8f1d253fb531 -size 88800 +oid sha256:3a3a77fac13fddda713f3ab5ccce14db9e823f12f1a2a4635fa62e476180d73c +size 45696 diff --git a/assets/world/tree/oak_green/3.vox b/assets/world/tree/oak_green/3.vox index 988d4a93bd..eb25589e2c 100644 --- a/assets/world/tree/oak_green/3.vox +++ b/assets/world/tree/oak_green/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c7c63b94c8bdc6d41fdd22f1ce1426e8abbf2d7f1cc4d3e2feb24782a2015535 -size 126300 +oid sha256:4187d7ed8d8e68f8dec18e4ac1a58843c618820bf3c5eaa18147debc9d99e885 +size 71820 diff --git a/assets/world/tree/oak_green/4.vox b/assets/world/tree/oak_green/4.vox index 7bcd66bd37..94b332c90b 100644 --- a/assets/world/tree/oak_green/4.vox +++ b/assets/world/tree/oak_green/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5862b4a6bf51df3a0659e1f007cf408714a4db659fda78370b5fad732c08eaa9 -size 89452 +oid sha256:c548dd81c891b427eee64181abfcfab93e5f4a0b8e094c615abf6d6d7b05d536 +size 46348 diff --git a/assets/world/tree/oak_green/5.vox b/assets/world/tree/oak_green/5.vox index 09686c3c71..8e8a0024d8 100644 --- a/assets/world/tree/oak_green/5.vox +++ b/assets/world/tree/oak_green/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ebac9342727decad370699b7e77517518fcd82062eba6496d4cafa35360b403d -size 106552 +oid sha256:ab50dbd7b07351299187edafc3a57b27fe7a1547a570d808612ee0897858c4b7 +size 52072 diff --git a/assets/world/tree/oak_green/6.vox b/assets/world/tree/oak_green/6.vox index 44a55fa64e..251daa43ae 100644 --- a/assets/world/tree/oak_green/6.vox +++ b/assets/world/tree/oak_green/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:257fbc96e69cf00c6b0dd93df953dea53ee3cf628e296ba04259f887e83d7d1b -size 112496 +oid sha256:b59539ce4aa45d8c68ca2d44c7ded05870f5d56185b996eafd8606cdb4a1e1cf +size 69392 diff --git a/assets/world/tree/oak_green/7.vox b/assets/world/tree/oak_green/7.vox index 4809311ae6..94b332c90b 100644 --- a/assets/world/tree/oak_green/7.vox +++ b/assets/world/tree/oak_green/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6623f234e6a591a4f73934f192351eec1280a0c92208cd6e227e4c368a7e2e14 -size 123856 +oid sha256:c548dd81c891b427eee64181abfcfab93e5f4a0b8e094c615abf6d6d7b05d536 +size 46348 diff --git a/assets/world/tree/oak_green/8.vox b/assets/world/tree/oak_green/8.vox index 76bcb46efc..a9b43adb18 100644 --- a/assets/world/tree/oak_green/8.vox +++ b/assets/world/tree/oak_green/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c44033a6b7996f42022f79cb18323431f06dae59273713f3b943cad2a4cb6f2e -size 116232 +oid sha256:d377ea2188ec402c601ee1ab84f557eb0777154ac05e36f0f3448ed3800956c8 +size 73128 diff --git a/assets/world/tree/oak_green/9.vox b/assets/world/tree/oak_green/9.vox index 50dcb81feb..9169bc887b 100644 --- a/assets/world/tree/oak_green/9.vox +++ b/assets/world/tree/oak_green/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94bae0b39a4c902082c96deaee17371a3334ac6aa48fd268bf49c61258903344 -size 135498 +oid sha256:885b58ef71185d76fb4874b40f2c6bdb70864d3cd2c644a45a3bd7c5b024a999 +size 81020 diff --git a/assets/world/tree/oak_stump/1.vox b/assets/world/tree/oak_stump/1.vox index 80a25d58f6..3b3f2cf5a5 100644 --- a/assets/world/tree/oak_stump/1.vox +++ b/assets/world/tree/oak_stump/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:60135681a5a9565c77b3bb4b9227ac861d1c522ddbd94c03909aa0b3112848c4 -size 49680 +oid sha256:247892994e6005f1976cf20ade31fb1326152a62a4323734ca588ab9dddb4f9c +size 6576 diff --git a/assets/world/tree/oak_stump/2.vox b/assets/world/tree/oak_stump/2.vox index 5ce3b7e4eb..2a51198c40 100644 --- a/assets/world/tree/oak_stump/2.vox +++ b/assets/world/tree/oak_stump/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:120026d00835e35c953b642e855a02cfce3d9ad4298cf2f9cba7727c9b29d098 -size 49968 +oid sha256:2eaa74f4f81276aac5111fd91b360e4b898fe18ce297eca274f0ce2f3d2a1a04 +size 6864 diff --git a/assets/world/tree/oak_stump/3.vox b/assets/world/tree/oak_stump/3.vox index c8e6bdcf19..83b184d872 100644 --- a/assets/world/tree/oak_stump/3.vox +++ b/assets/world/tree/oak_stump/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2729b990855302cdca585049beddd7d1fd6277da8e24aaf82fc500f2390a53d5 -size 62136 +oid sha256:3ae1917ba5eed0708123ba960529e6c2c4087bb10aeafbc7b55b69a61eb73707 +size 7656 diff --git a/assets/world/tree/oak_stump/4.vox b/assets/world/tree/oak_stump/4.vox index 0083b4c41e..9a7e716831 100644 --- a/assets/world/tree/oak_stump/4.vox +++ b/assets/world/tree/oak_stump/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:efdd4d2545af5cdefdebe0b3903a00f6de067b53aebfbbacafa947f092cbe1f8 -size 50108 +oid sha256:6cd731b9357f59d0fb415e8e6179f85c3458ee7370f1f9b586721c60845b45ba +size 7004 diff --git a/assets/world/tree/oak_stump/5.vox b/assets/world/tree/oak_stump/5.vox index 139c635908..6d9a195b59 100644 --- a/assets/world/tree/oak_stump/5.vox +++ b/assets/world/tree/oak_stump/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d0b05790bfa582be6f11287e74c44bf82c9fb637718764b9e729f098263e2cc1 -size 50012 +oid sha256:bf110f9d82e0081f2344db1dfd7b88af43d02cb6e8ba7fc7ea08b2d970befa76 +size 6908 diff --git a/assets/world/tree/oak_stump/6.vox b/assets/world/tree/oak_stump/6.vox index eeb323998a..ce701351fc 100644 --- a/assets/world/tree/oak_stump/6.vox +++ b/assets/world/tree/oak_stump/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:055279ff59c34829980312ca87c754d73a102ed8af2b189dec0f2e4f754627c6 -size 52528 +oid sha256:534a823b86deacc40f887be78a928c73f67ea7307e27732f078bb9f84ddbe026 +size 9424 diff --git a/assets/world/tree/oak_stump/7.vox b/assets/world/tree/oak_stump/7.vox index 2d389a29d2..b481f6944e 100644 --- a/assets/world/tree/oak_stump/7.vox +++ b/assets/world/tree/oak_stump/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c5485e1bc4137a80608dbd2985ef0f7da829f2a989f14ff123cf7812f4a71487 -size 50052 +oid sha256:2c363912985f3b962b7a18c79f74fab8739386f9a78807c85dd5559b1f1dc3e1 +size 6948 diff --git a/assets/world/tree/oak_stump/8.vox b/assets/world/tree/oak_stump/8.vox index 161c58761b..985d99785f 100644 --- a/assets/world/tree/oak_stump/8.vox +++ b/assets/world/tree/oak_stump/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8204fd6e324d35461e2613e88f58417661365d120461428ee351b9a6a33cf2ba -size 51596 +oid sha256:78c157df55e0028c0538d8be481c09c9803c37b2cb6eb375411449b8ffc3954d +size 8492 diff --git a/assets/world/tree/oak_stump/9.vox b/assets/world/tree/oak_stump/9.vox index c3a84e0d36..2752b62850 100644 --- a/assets/world/tree/oak_stump/9.vox +++ b/assets/world/tree/oak_stump/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:626a92a02facc274f467c6c1f28291d1cc0b9a6fa2227945fa36e0d55c3a489e -size 51648 +oid sha256:fd7c515c14d7131f0f7f3c242c8fe20d1bfc9fe517d6e692c2ece492ea722490 +size 8544 diff --git a/assets/world/tree/pine_green/1.vox b/assets/world/tree/pine_green/1.vox index 5eb72f10a6..aff8542ab7 100644 --- a/assets/world/tree/pine_green/1.vox +++ b/assets/world/tree/pine_green/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8425e0432a170d171f90da4697be6574316934b5cb70e1aab47ce23149bafce8 -size 50448 +oid sha256:452a242cff15ae0d80bc233a36ff673026015c6ff4c56acc03e315f395969802 +size 7340 diff --git a/assets/world/tree/pine_green/2.vox b/assets/world/tree/pine_green/2.vox index 24afa41987..82e67039d2 100644 --- a/assets/world/tree/pine_green/2.vox +++ b/assets/world/tree/pine_green/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c95e7949bf4193e6387e80144e2d21e914b9326992223302f8f4a798cf70fd55 -size 54148 +oid sha256:63f7af9419dd79437bbff5268811efe8bc9d383c2a679c00f16d8436ec40b1b0 +size 11040 diff --git a/assets/world/tree/pine_green/3.vox b/assets/world/tree/pine_green/3.vox index d78aa31454..43143fa598 100644 --- a/assets/world/tree/pine_green/3.vox +++ b/assets/world/tree/pine_green/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c0fb6ae560bfd38100e37777f6da28447df0495535bb83e0dd7cceac4894a153 -size 56140 +oid sha256:03f1d60dcaf4808b98629d11871ae720007bcdded0f27b37fdc98372258561df +size 13032 diff --git a/assets/world/tree/pine_green/4.vox b/assets/world/tree/pine_green/4.vox index 060aa15fc3..c7da7adbce 100644 --- a/assets/world/tree/pine_green/4.vox +++ b/assets/world/tree/pine_green/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:776fd4e706994a8625f5df1c279b8b6783a056872c6d6e072e27ae908d159169 -size 48309 +oid sha256:1e6f1eafbc4b594ae5be130c43301720f8aada84007a7552a40a79fe9b988233 +size 5192 diff --git a/assets/world/tree/pine_green/5.vox b/assets/world/tree/pine_green/5.vox index 235e87c5e8..30e610e514 100644 --- a/assets/world/tree/pine_green/5.vox +++ b/assets/world/tree/pine_green/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4e497b28721e695dadf945e56cc0d7368bb62fcb8e903bb1f1a1ebc9776d9db1 -size 50952 +oid sha256:dcacca2633e35e45a6ee91ce4b7c2db788432c2631d52b2f263fa3c8519f786e +size 7844 diff --git a/assets/world/tree/pine_green/6.vox b/assets/world/tree/pine_green/6.vox index 3a58cb6df0..742db1aa45 100644 --- a/assets/world/tree/pine_green/6.vox +++ b/assets/world/tree/pine_green/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:971a3eb44ddb4defd5057a5320641b13b33ee634e3f837ed3d453b2912fa5d42 -size 49053 +oid sha256:0911b8fa5de4439e6b80c1b737e4dc3ccb838ae38ca6b3cccd484cd73bb21a4a +size 5936 diff --git a/assets/world/tree/pine_green/7.vox b/assets/world/tree/pine_green/7.vox index 9a5db1987f..9ff4d59072 100644 --- a/assets/world/tree/pine_green/7.vox +++ b/assets/world/tree/pine_green/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04e84e3982fda2f265169ac055f51b59dcfe4315c72a6befe16ad7308fc85b7b -size 54588 +oid sha256:044140ac4829f5268593e4f85fc8ee0cbc490f455bec51e15537a2d538955c9f +size 11480 diff --git a/assets/world/tree/pine_green/8.vox b/assets/world/tree/pine_green/8.vox index 60ad8714ec..95a159a4e2 100644 --- a/assets/world/tree/pine_green/8.vox +++ b/assets/world/tree/pine_green/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f9f09a2e98e67ad2a40951854b06fedc4121df40d36fc37483875803c8736190 -size 50265 +oid sha256:57b6361728e93961360f6960f7c2333f80c54728c21c5e89310cb8eefa0ffceb +size 7148 diff --git a/assets/world/tree/poplar/1.vox b/assets/world/tree/poplar/1.vox index def9050b24..ed3297d265 100644 --- a/assets/world/tree/poplar/1.vox +++ b/assets/world/tree/poplar/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:22ab052663f6331b628d55d1c997581758e7a39944594a95290e362751882bf3 -size 63195 +oid sha256:f34a32263631310be34730f1032c32ba9c9d92cf270421afa0e15cdc6f1130f1 +size 20080 diff --git a/assets/world/tree/poplar/10.vox b/assets/world/tree/poplar/10.vox index a69da34efd..36df0db41d 100644 --- a/assets/world/tree/poplar/10.vox +++ b/assets/world/tree/poplar/10.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:53259a9f379c965713dea6152b5ec85c48311d23a77aafc7a064702207fbf5b7 -size 67107 +oid sha256:c7c9b18022d58fe8d9c7c688fc82d1b8c4412fba15a709de10f4fbee5f8fb222 +size 23992 diff --git a/assets/world/tree/poplar/2.vox b/assets/world/tree/poplar/2.vox index 64c3241203..b9c26d8440 100644 --- a/assets/world/tree/poplar/2.vox +++ b/assets/world/tree/poplar/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db88af7a8c07b8146efbff78233f530f41022b9144fff07a46c90c72777699e9 -size 61183 +oid sha256:9b005d48d75414b736e7b221482b5c88ac3b34f71024d2219a3ecfa2c97cbe37 +size 18068 diff --git a/assets/world/tree/poplar/3.vox b/assets/world/tree/poplar/3.vox index fb927c3c22..ebbc29d519 100644 --- a/assets/world/tree/poplar/3.vox +++ b/assets/world/tree/poplar/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4c095d2f496aa2b0a531087cf64cf475217f583acc0492aa9496a20aafa9e8f -size 56455 +oid sha256:8d6795c479b8fa760868201ff5674b5a5daffdcbcf2b4bcdbc04bedeefd96740 +size 13340 diff --git a/assets/world/tree/poplar/4.vox b/assets/world/tree/poplar/4.vox index eab3776c31..53ac07d0ad 100644 --- a/assets/world/tree/poplar/4.vox +++ b/assets/world/tree/poplar/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8bca70d737f4d56202f81bd861f7891dc3c40574381cc46279c736a182cbf303 -size 54823 +oid sha256:7745c4a0b133a2ba6bf92c414de402f99e5244d39e5ecc628423697c434e815f +size 11708 diff --git a/assets/world/tree/poplar/5.vox b/assets/world/tree/poplar/5.vox index d38ec13c58..03a8586ac8 100644 --- a/assets/world/tree/poplar/5.vox +++ b/assets/world/tree/poplar/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9a7f16377fe5928bba4c1019941307e02bbe1edc8749874d560a797ce93cab39 -size 59219 +oid sha256:f5c2592f0334f8bc2bda48a84681773e767a3c56e0b0926a456420dcef65e5aa +size 16104 diff --git a/assets/world/tree/poplar/6.vox b/assets/world/tree/poplar/6.vox index f4ca924b8f..d5105806be 100644 --- a/assets/world/tree/poplar/6.vox +++ b/assets/world/tree/poplar/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f62a65ea5a10a2e30bc1a76cea02e78b1fa28d099832629f218ae29da6596672 -size 53167 +oid sha256:3cbd44e2ca546f754209d6d7e06c3227e29f9d2f83dc89d19db0fb563fa68097 +size 10052 diff --git a/assets/world/tree/poplar/7.vox b/assets/world/tree/poplar/7.vox index fd11e7e94d..be6aa613c7 100644 --- a/assets/world/tree/poplar/7.vox +++ b/assets/world/tree/poplar/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:12b2c6b44bc6fc52517559636c5ff7d42a2c127449652c47e094cd1253f11a19 -size 55883 +oid sha256:0e3c16156865a61a783bfb383ecce1f7f1605b930f759991616b4e0febdedb1b +size 12768 diff --git a/assets/world/tree/poplar/8.vox b/assets/world/tree/poplar/8.vox index bececb963a..6e8172d3a5 100644 --- a/assets/world/tree/poplar/8.vox +++ b/assets/world/tree/poplar/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:946470b5b7f4942e539b5da12c906513601d2145725ce7074d833d48526ee242 -size 59583 +oid sha256:f91dcf761ca66bbff6dc51ef1230d5036270e346fdc400491fb5e1994b4ba931 +size 16468 diff --git a/assets/world/tree/poplar/9.vox b/assets/world/tree/poplar/9.vox index 9c68248183..c20d4b714c 100644 --- a/assets/world/tree/poplar/9.vox +++ b/assets/world/tree/poplar/9.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bd00eb99e4be1b0274233ded21fde4e25bf7f213342ff981e90ed80d0389be90 -size 58867 +oid sha256:3f785e547995287fa907242c19b71f4d62b5b4e624e200a63b8a63ef0c31436c +size 15752 diff --git a/assets/world/tree/snow_pine/1.vox b/assets/world/tree/snow_pine/1.vox index 2a69754469..839c651e58 100644 --- a/assets/world/tree/snow_pine/1.vox +++ b/assets/world/tree/snow_pine/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e6e72f82b2a6a69a0a10f4a10aa33a96f9539306fee5afb1318073ac6cd17a40 -size 65748 +oid sha256:06f15f6e5080ebf960781647af3fe84b5cfb9441daf9b67fc994ebd657274feb +size 11264 diff --git a/assets/world/tree/snow_pine/2.vox b/assets/world/tree/snow_pine/2.vox index 5d862699d3..5b7ea048e2 100644 --- a/assets/world/tree/snow_pine/2.vox +++ b/assets/world/tree/snow_pine/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2fba53a6780a1bccbe7c793d0cd7c4e09e6fdbdd9d29e0e0292ed08fd1e30a42 -size 72092 +oid sha256:ae9bc1551d8f6b729391a73fef04b754e0428de0d38e2a3c0c3d3e6bd6e6af20 +size 17608 diff --git a/assets/world/tree/snow_pine/3.vox b/assets/world/tree/snow_pine/3.vox index 7d8f3bc357..b2d45eb909 100644 --- a/assets/world/tree/snow_pine/3.vox +++ b/assets/world/tree/snow_pine/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:593684e9d2cacba31a92e1d8510a3e7fd91c7fde7b4ad00956892e3a92b92a2a -size 75472 +oid sha256:4bb20e35a1467fd09e835262a38f595f96b76e9af7f9f6dcaa6d5c04ade08b6d +size 20988 diff --git a/assets/world/tree/snow_pine/4.vox b/assets/world/tree/snow_pine/4.vox index c4830fcbc7..8924349364 100644 --- a/assets/world/tree/snow_pine/4.vox +++ b/assets/world/tree/snow_pine/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:34727e053d0a4dab81d8c67145e8c2abe87ecb08be47b75f8d810d1341e8bad2 -size 61557 +oid sha256:4c0c15bb57f7dcf5833d769427a8654b85116965bc1a314c56a67866ed448d51 +size 7064 diff --git a/assets/world/tree/snow_pine/5.vox b/assets/world/tree/snow_pine/5.vox index a5b85ea83e..d7e69de1e4 100644 --- a/assets/world/tree/snow_pine/5.vox +++ b/assets/world/tree/snow_pine/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ffec069805e7e621116cf0a5f6e24d3787fe6c5a016e2978fa3eb450be33364 -size 65216 +oid sha256:ebaad973e1ed66869b0065ab13ba05b873a51f7775bfffb27f3522ded927e353 +size 10732 diff --git a/assets/world/tree/snow_pine/6.vox b/assets/world/tree/snow_pine/6.vox index 02e0f9a7a6..cc06334769 100644 --- a/assets/world/tree/snow_pine/6.vox +++ b/assets/world/tree/snow_pine/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ee3dbdb687aa41d920fa608821298b6724f0d70bc09daeab157ab63e707dbd31 -size 62269 +oid sha256:ed6c63f0927ce6ff927c4172a099dbbc8fdd60a9bf37da9564cc9f4ec0b82d0d +size 7776 diff --git a/assets/world/tree/snow_pine/7.vox b/assets/world/tree/snow_pine/7.vox index 29192ca0bb..dc1fcc3045 100644 --- a/assets/world/tree/snow_pine/7.vox +++ b/assets/world/tree/snow_pine/7.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04f6da6320c0e05c88a6d1fae1f1b26b414fcd5a1b67e9315c8cc8e975876409 -size 70028 +oid sha256:33a522078e71d2ba350f52bb30c346b837a64ff2a73fa933acf405243ab9c35e +size 15544 diff --git a/assets/world/tree/snow_pine/8.vox b/assets/world/tree/snow_pine/8.vox index 96c02d39df..89f7c65bbb 100644 --- a/assets/world/tree/snow_pine/8.vox +++ b/assets/world/tree/snow_pine/8.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9c2816b253ef0edb372f5d4d3b28cb8e4d376f3bac1242f637dc74130d346ff6 -size 64313 +oid sha256:cdc1bfe73e9a5d0a64e33b86227898243fa7243e81cc8cb302359accb6dc10f9 +size 9820 diff --git a/assets/world/tree/temperate_small/1.vox b/assets/world/tree/temperate_small/1.vox index 01304a1d6a..e90312ffef 100644 --- a/assets/world/tree/temperate_small/1.vox +++ b/assets/world/tree/temperate_small/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e7732d8f01169d6ec8aec60e8226ff6ae3a24a372d4cd30967839714fb50fbf -size 45145 +oid sha256:14e448a46ff8dac488730dc11d873c6d4cfd185f8ff10c8209ebf27dd2602f1b +size 2036 diff --git a/assets/world/tree/temperate_small/2.vox b/assets/world/tree/temperate_small/2.vox index 57736a5011..e2f2f5c293 100644 --- a/assets/world/tree/temperate_small/2.vox +++ b/assets/world/tree/temperate_small/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ed87cdd4f58d1d218d7b8c5789a6b2501bb5838e902634bc14ebcd5e803f455c -size 45361 +oid sha256:f248fa9cb5f8831740d71096ad10943edc6abc49b63cc726840b8cab3e0ba956 +size 2252 diff --git a/assets/world/tree/temperate_small/3.vox b/assets/world/tree/temperate_small/3.vox index 5d4a123a52..1ae64c5904 100644 --- a/assets/world/tree/temperate_small/3.vox +++ b/assets/world/tree/temperate_small/3.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:45568304006a9642619f9cc6e0a6d44240d9a6560980e9d9f20e318faba57a7b -size 45341 +oid sha256:b58e2f1b8c9d02e5f1a3c529a4b8adc1c4268e48f78c0068ef5a690de8e402cf +size 2232 diff --git a/assets/world/tree/temperate_small/4.vox b/assets/world/tree/temperate_small/4.vox index 99ef2aaa60..0b8f22c344 100644 --- a/assets/world/tree/temperate_small/4.vox +++ b/assets/world/tree/temperate_small/4.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a75707ba1a44887e8930029f2d837d0a7f6adce86614ac8fdb45fd467278a130 -size 45009 +oid sha256:e762fa4f9824e0baeaa287a24b5dc3f726c4be9146eaf067b445c6c1800401a3 +size 1900 diff --git a/assets/world/tree/temperate_small/5.vox b/assets/world/tree/temperate_small/5.vox index 3c0eca03ae..d24f7a73cd 100644 --- a/assets/world/tree/temperate_small/5.vox +++ b/assets/world/tree/temperate_small/5.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bd60587804d68157abf50641920baabc4463f71be7955b04bf7b39cd12078279 -size 45001 +oid sha256:85f7ec25448c758e1e62af70e77307096f1f6072e521a3b2b1672fbc2fee2d18 +size 1892 diff --git a/assets/world/tree/temperate_small/6.vox b/assets/world/tree/temperate_small/6.vox index 10bea0a7a7..23c3902c45 100644 --- a/assets/world/tree/temperate_small/6.vox +++ b/assets/world/tree/temperate_small/6.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:57590bd0944e1f810f4c09a0f425156ff58c7a2990c3ee7c28030a3ed7be0820 -size 45177 +oid sha256:053a32d35758d59b113bcc3a7c733b751a699f0bf521a274c83fe27c933dc81b +size 2068 diff --git a/assets/world/tree/willow/1.vox b/assets/world/tree/willow/1.vox index 9eee2810f4..1ca5ecc517 100644 --- a/assets/world/tree/willow/1.vox +++ b/assets/world/tree/willow/1.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5d8af7e482178ad773717a5c4d4a0c39b04363166f21e46492971f1c2b755969 -size 87604 +oid sha256:749ebea80dee38d0a287ec370c378fcb873e306d95a33c9c3858758896afde39 +size 44492 diff --git a/assets/world/tree/willow/2.vox b/assets/world/tree/willow/2.vox index 27daf7ecac..a5e8f56817 100644 --- a/assets/world/tree/willow/2.vox +++ b/assets/world/tree/willow/2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc5289388be68a9e1b69feb895346fc7e705e020df7a7685e70d0a15f669d6ce -size 66648 +oid sha256:3af5f90f9ac95c3cee1188b6d760e057dffa5d460486290f35e13026f61a4e6b +size 23536 From 11be9c10b2b7b7d474a596a2422c2f91a17e2954 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 27 Mar 2020 16:09:51 +0100 Subject: [PATCH 266/326] remapped default look key, removed unused keys --- voxygen/src/controller.rs | 6 ------ voxygen/src/hud/settings_window.rs | 8 ++------ voxygen/src/settings.rs | 6 +----- voxygen/src/window.rs | 6 ------ 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/voxygen/src/controller.rs b/voxygen/src/controller.rs index 2e6f8d8d3c..6fe0d76260 100644 --- a/voxygen/src/controller.rs +++ b/voxygen/src/controller.rs @@ -115,12 +115,6 @@ impl From<&crate::settings::GamepadSettings> for ControllerSettings { map.entry(settings.game_buttons.bag) .or_default() .push(GameInput::Bag); - map.entry(settings.game_buttons.quest_log) - .or_default() - .push(GameInput::QuestLog); - map.entry(settings.game_buttons.character_window) - .or_default() - .push(GameInput::CharacterWindow); map.entry(settings.game_buttons.social) .or_default() .push(GameInput::Social); diff --git a/voxygen/src/hud/settings_window.rs b/voxygen/src/hud/settings_window.rs index 1c63978804..5101819761 100644 --- a/voxygen/src/hud/settings_window.rs +++ b/voxygen/src/hud/settings_window.rs @@ -1358,8 +1358,6 @@ impl<'a> Widget for SettingsWindow<'a> { {}\n\ {}\n\ {}\n\ - {}\n\ - {}\n\ \n\ \n\ \n\ @@ -1369,8 +1367,6 @@ impl<'a> Widget for SettingsWindow<'a> { \n\ \n\ \n\ - \n\ - \n\ ", controls.toggle_cursor, controls.help, @@ -1412,8 +1408,8 @@ impl<'a> Widget for SettingsWindow<'a> { controls.social, controls.map, controls.spellbook, - controls.character_window, - controls.quest_log, + //controls.character_window, + //controls.quest_log, controls.bag, controls.enter, "Mouse Wheel", // Scroll chat diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index db290d764d..85c4f8fba0 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -36,8 +36,6 @@ pub struct ControlSettings { pub mount: KeyMouse, pub map: KeyMouse, pub bag: KeyMouse, - pub quest_log: KeyMouse, - pub character_window: KeyMouse, pub social: KeyMouse, pub spellbook: KeyMouse, pub settings: KeyMouse, @@ -89,8 +87,6 @@ impl Default for ControlSettings { mount: KeyMouse::Key(VirtualKeyCode::F), map: KeyMouse::Key(VirtualKeyCode::M), bag: KeyMouse::Key(VirtualKeyCode::B), - quest_log: KeyMouse::Key(VirtualKeyCode::L), - character_window: KeyMouse::Key(VirtualKeyCode::C), social: KeyMouse::Key(VirtualKeyCode::O), spellbook: KeyMouse::Key(VirtualKeyCode::P), settings: KeyMouse::Key(VirtualKeyCode::N), @@ -106,7 +102,7 @@ impl Default for ControlSettings { toggle_wield: KeyMouse::Key(VirtualKeyCode::T), swap_loadout: KeyMouse::Key(VirtualKeyCode::Q), charge: KeyMouse::Key(VirtualKeyCode::Key1), - free_look: KeyMouse::Key(VirtualKeyCode::LAlt), + free_look: KeyMouse::Key(VirtualKeyCode::L), } } } diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index 03db7074cc..f54e0eabf1 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -416,12 +416,6 @@ impl Window { map.entry(settings.controls.bag) .or_default() .push(GameInput::Bag); - map.entry(settings.controls.quest_log) - .or_default() - .push(GameInput::QuestLog); - map.entry(settings.controls.character_window) - .or_default() - .push(GameInput::CharacterWindow); map.entry(settings.controls.social) .or_default() .push(GameInput::Social); From 3a989f061f0d7b9fde5d5a656261646fd7158a4c Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Fri, 27 Mar 2020 15:13:36 +0000 Subject: [PATCH 267/326] Better water shaders --- assets/voxygen/shaders/fluid-frag/cheap.glsl | 12 +----------- assets/voxygen/shaders/fluid-frag/shiny.glsl | 14 ++------------ assets/voxygen/shaders/fluid-vert.glsl | 3 +++ assets/voxygen/shaders/include/sky.glsl | 4 +++- assets/voxygen/shaders/skybox-frag.glsl | 10 +++++++++- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/assets/voxygen/shaders/fluid-frag/cheap.glsl b/assets/voxygen/shaders/fluid-frag/cheap.glsl index b2e3d4b6ac..f3c92ab429 100644 --- a/assets/voxygen/shaders/fluid-frag/cheap.glsl +++ b/assets/voxygen/shaders/fluid-frag/cheap.glsl @@ -34,16 +34,6 @@ void main() { vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz); - /* - // Round the position to the nearest triangular grid cell - vec3 hex_pos = f_pos * 2.0; - hex_pos = hex_pos + vec3(hex_pos.y * 1.4 / 3.0, hex_pos.y * 0.1, 0); - if (fract(hex_pos.x) > fract(hex_pos.y)) { - hex_pos += vec3(1.0, 1.0, 0); - } - hex_pos = floor(hex_pos); - */ - vec3 light, diffuse_light, ambient_light; get_sun_diffuse(f_norm, time_of_day.x, light, diffuse_light, ambient_light, 0.0); float point_shadow = shadow_at(f_pos,f_norm); @@ -52,7 +42,7 @@ void main() { vec3 point_light = light_at(f_pos, f_norm); light += point_light; diffuse_light += point_light; - vec3 surf_color = illuminate(srgb_to_linear(vec3(0.2, 0.2, 1.0)), light, diffuse_light, ambient_light); + vec3 surf_color = srgb_to_linear(vec3(0.4, 0.7, 2.0)) * light * diffuse_light * ambient_light; float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x); vec4 clouds; diff --git a/assets/voxygen/shaders/fluid-frag/shiny.glsl b/assets/voxygen/shaders/fluid-frag/shiny.glsl index cb7a37544d..8d06ee468c 100644 --- a/assets/voxygen/shaders/fluid-frag/shiny.glsl +++ b/assets/voxygen/shaders/fluid-frag/shiny.glsl @@ -68,16 +68,6 @@ void main() { vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz); float frag_dist = length(f_pos - cam_pos.xyz); - /* - // Round the position to the nearest triangular grid cell - vec3 hex_pos = f_pos * 2.0; - hex_pos = hex_pos + vec3(hex_pos.y * 1.4 / 3.0, hex_pos.y * 0.1, 0); - if (fract(hex_pos.x) > fract(hex_pos.y)) { - hex_pos += vec3(1.0, 1.0, 0); - } - hex_pos = floor(hex_pos); - */ - vec3 b_norm; if (f_norm.z > 0.0) { b_norm = vec3(1, 0, 0); @@ -111,7 +101,7 @@ void main() { vec3 point_light = light_at(f_pos, norm); light += point_light; diffuse_light += point_light; - vec3 surf_color = illuminate(srgb_to_linear(f_col), light, diffuse_light, ambient_light); + vec3 surf_color = srgb_to_linear(vec3(0.2, 0.5, 1.0)) * light * diffuse_light * ambient_light; float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x); vec4 clouds; @@ -119,7 +109,7 @@ void main() { vec3 reflect_ray_dir = reflect(cam_to_frag, norm); // Hack to prevent the reflection ray dipping below the horizon and creating weird blue spots in the water - reflect_ray_dir.z = max(reflect_ray_dir.z, 0.05); + reflect_ray_dir.z = max(reflect_ray_dir.z, 0.01); vec4 _clouds; vec3 reflect_color = get_sky_color(reflect_ray_dir, time_of_day.x, f_pos, vec3(-100000), 0.25, false, _clouds) * f_light; diff --git a/assets/voxygen/shaders/fluid-vert.glsl b/assets/voxygen/shaders/fluid-vert.glsl index 2692e463a2..412b46bd80 100644 --- a/assets/voxygen/shaders/fluid-vert.glsl +++ b/assets/voxygen/shaders/fluid-vert.glsl @@ -27,6 +27,9 @@ void main() { f_pos.z *= min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0); f_pos.z -= 25.0 * pow(distance(focus_pos.xy, f_pos.xy) / view_distance.x, 20.0); + // Small waves + f_pos.z -= 0.05 + 0.05 * (sin(tick.x * 2.0 + f_pos.x * 2.0 + f_pos.y * 2.0) + 1.0) * 0.5; + f_col = vec3( float((v_col_light >> 8) & 0xFFu), float((v_col_light >> 16) & 0xFFu), diff --git a/assets/voxygen/shaders/include/sky.glsl b/assets/voxygen/shaders/include/sky.glsl index 5b3869c8ac..7ac0dbc6c9 100644 --- a/assets/voxygen/shaders/include/sky.glsl +++ b/assets/voxygen/shaders/include/sky.glsl @@ -21,6 +21,8 @@ const vec3 SKY_NIGHT_MID = vec3(0.001, 0.005, 0.02); const vec3 SKY_NIGHT_BOT = vec3(0.002, 0.004, 0.004); const vec3 NIGHT_LIGHT = vec3(0.002, 0.01, 0.03); +const float UNDERWATER_MIST_DIST = 100.0; + vec3 get_sun_dir(float time_of_day) { const float TIME_FACTOR = (PI * 2.0) / (3600.0 * 24.0); @@ -202,7 +204,7 @@ float fog(vec3 f_pos, vec3 focus_pos, uint medium) { float max_fog = 1.0; if (medium == 1u) { - mist_radius = 96.0; + mist_radius = UNDERWATER_MIST_DIST; min_fog = 0.0; } diff --git a/assets/voxygen/shaders/skybox-frag.glsl b/assets/voxygen/shaders/skybox-frag.glsl index ab39a37c3c..d537a1f9eb 100644 --- a/assets/voxygen/shaders/skybox-frag.glsl +++ b/assets/voxygen/shaders/skybox-frag.glsl @@ -14,5 +14,13 @@ out vec4 tgt_color; void main() { vec4 _clouds; - tgt_color = vec4(get_sky_color(normalize(f_pos), time_of_day.x, cam_pos.xyz, vec3(-100000), 1.0, true, _clouds), 1.0); + float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x); + + float dist = 100000.0; + if (medium.x == 1u) { + dist = UNDERWATER_MIST_DIST; + } + vec3 wpos = cam_pos.xyz + normalize(f_pos) * dist; + + tgt_color = vec4(get_sky_color(normalize(f_pos), time_of_day.x, cam_pos.xyz, wpos, 1.0, true, _clouds), 1.0); } From 31760d220acccc9c3ba78565cb8a635fa62b212f Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 27 Mar 2020 08:17:17 -0700 Subject: [PATCH 268/326] triple_strike knockback 20.0 -> 15.0 --- common/src/states/triple_strike.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index cbf5c7c817..e300111522 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -115,7 +115,7 @@ impl CharacterBehavior for Data { max_angle: 180_f32.to_radians(), applied: false, hit_count: 0, - knockback: 20.0, + knockback: 15.0, }); CharacterState::TripleStrike(Data { From 4bfc934772d275d5470c5a7471d7c72cde230cc5 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 27 Mar 2020 08:26:53 -0700 Subject: [PATCH 269/326] triples strike knockback 15.0 -> 16.0 --- common/src/states/triple_strike.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index e300111522..f557ce3163 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -115,7 +115,7 @@ impl CharacterBehavior for Data { max_angle: 180_f32.to_radians(), applied: false, hit_count: 0, - knockback: 15.0, + knockback: 16.0, }); CharacterState::TripleStrike(Data { From ad0314b4f5f6c69a99a950d965707bf23893f2e8 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 27 Mar 2020 17:07:19 +0100 Subject: [PATCH 270/326] Projectile hits regenerate energy --- common/src/comp/inventory/item.rs | 2 ++ common/src/comp/projectile.rs | 1 + common/src/sys/projectile.rs | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 27ced5f27b..ce7d6e936d 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -106,6 +106,7 @@ impl ToolData { cause: HealthSource::Projectile { owner: None }, }), projectile::Effect::Knockback(10.0), + projectile::Effect::RewardEnergy(100), projectile::Effect::Vanish, ], time_left: Duration::from_secs(15), @@ -146,6 +147,7 @@ impl ToolData { amount: -1, cause: HealthSource::Projectile { owner: None }, }), + projectile::Effect::RewardEnergy(100), projectile::Effect::Vanish, ], time_left: Duration::from_secs(20), diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index a4dda1ac7c..8ff384a87a 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -7,6 +7,7 @@ use std::time::Duration; pub enum Effect { Damage(comp::HealthChange), Knockback(f32), + RewardEnergy(u32), Explode { power: f32 }, Vanish, Stick, diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index 3f0ee14a04..bf0fc1064d 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -1,5 +1,7 @@ use crate::{ - comp::{projectile, HealthSource, Ori, PhysicsState, Pos, Projectile, Vel}, + comp::{ + projectile, Energy, EnergySource, HealthSource, Ori, PhysicsState, Pos, Projectile, Vel, + }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, sync::UidAllocator, @@ -22,6 +24,7 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Vel>, WriteStorage<'a, Ori>, WriteStorage<'a, Projectile>, + WriteStorage<'a, Energy>, ); fn run( @@ -37,6 +40,7 @@ impl<'a> System<'a> for Sys { velocities, mut orientations, mut projectiles, + mut energies, ): Self::SystemData, ) { let mut local_emitter = local_bus.emitter(); @@ -108,6 +112,15 @@ impl<'a> System<'a> for Sys { }); } }, + projectile::Effect::RewardEnergy(energy) => { + if let Some(energy_mut) = projectile + .owner + .and_then(|o| uid_allocator.retrieve_entity_internal(o.into())) + .and_then(|o| energies.get_mut(o)) + { + energy_mut.change_by(energy as i32, EnergySource::HitEnemy); + } + }, projectile::Effect::Explode { power } => { server_emitter.emit(ServerEvent::Explosion { pos: pos.0, From c3a4f897da02ea7d14c5f80de7e1e340ef01715d Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 27 Mar 2020 17:50:34 +0100 Subject: [PATCH 271/326] update help screen --- assets/voxygen/element/help.png | 4 ++-- voxygen/src/settings.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/voxygen/element/help.png b/assets/voxygen/element/help.png index c399bd2d1a..558430c026 100644 --- a/assets/voxygen/element/help.png +++ b/assets/voxygen/element/help.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c71ba3a6458d00f3c6fb2820f1a83c6138a4776fdfd7167c2766b40b7bbb377 -size 14939 +oid sha256:561db05ac9702129859c6b266dd63df7e0ab5c832c6ce587afc65bc203592cd6 +size 14794 diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 85c4f8fba0..c7d4dc8ae3 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -365,7 +365,7 @@ impl Default for GameplaySettings { chat_transp: 0.4, crosshair_type: CrosshairType::Round, intro_show: Intro::Show, - xp_bar: XpBar::OnGain, + xp_bar: XpBar::Always, shortcut_numbers: ShortcutNumbers::On, bar_numbers: BarNumbers::Off, ui_scale: ScaleMode::RelativeToWindow([1920.0, 1080.0].into()), From 6fd3339b75e834ffbbf37dc831da7db64ad64ee5 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 27 Mar 2020 17:50:45 +0100 Subject: [PATCH 272/326] Make apples great again --- assets/common/items/apple.ron | 4 ++-- world/src/block/mod.rs | 6 +++++- world/src/block/natural.rs | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/assets/common/items/apple.ron b/assets/common/items/apple.ron index 0c44a094ce..7179502e22 100644 --- a/assets/common/items/apple.ron +++ b/assets/common/items/apple.ron @@ -2,11 +2,11 @@ Item( name: "Apple", description: "Red and juicy. -Restores 2 Health.", +Restores 20 Health.", kind: Consumable( kind: Apple, effect: Health(( - amount: 2, + amount: 20, cause: Item, )), ), diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 3c61e20936..a994baf712 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -628,7 +628,11 @@ pub fn block_from_structure( ) .map(|e| e as u8), )), - StructureBlock::Fruit => Some(Block::new(BlockKind::Apple, Rgb::new(194, 30, 37))), + StructureBlock::Fruit => Some(if field.get(pos + structure_pos) % 3 > 0 { + Block::empty() + } else { + Block::new(BlockKind::Apple, Rgb::new(194, 30, 37)) + }), StructureBlock::Chest => Some(if structure_seed % 10 < 7 { Block::empty() } else { diff --git a/world/src/block/natural.rs b/world/src/block/natural.rs index 8e472e53e6..c60d593d34 100644 --- a/world/src/block/natural.rs +++ b/world/src/block/natural.rs @@ -56,7 +56,7 @@ pub fn structure_gen<'a>( ForestKind::Palm => &PALMS, ForestKind::Savannah => &ACACIAS, ForestKind::Oak if QUIRKY_RAND.get(st_seed) % 16 == 7 => &OAK_STUMPS, - ForestKind::Oak if QUIRKY_RAND.get(st_seed) % 8 == 7 => &FRUIT_TREES, + ForestKind::Oak if QUIRKY_RAND.get(st_seed) % 19 == 7 => &FRUIT_TREES, ForestKind::Oak if QUIRKY_RAND.get(st_seed) % 14 == 7 => &BIRCHES, ForestKind::Oak => &OAKS, ForestKind::Pine => &PINES, From 6fe5c5724c155ee0962ee15dac04640c705519dd Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 27 Mar 2020 18:17:41 +0100 Subject: [PATCH 273/326] Fix char selection not showing tools --- common/src/states/basic_ranged.rs | 2 +- voxygen/src/menu/char_selection/mod.rs | 2 +- voxygen/src/menu/char_selection/ui.rs | 28 +++++++++++++++++++++++--- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/common/src/states/basic_ranged.rs b/common/src/states/basic_ranged.rs index 81f1485baf..3652c40e1e 100644 --- a/common/src/states/basic_ranged.rs +++ b/common/src/states/basic_ranged.rs @@ -28,7 +28,7 @@ impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); - handle_move(data, &mut update, 0.2); + handle_move(data, &mut update, 0.3); handle_jump(data, &mut update); if self.prepare_timer < self.prepare_duration diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index a8c767c9fc..3ca05435d4 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -117,7 +117,7 @@ impl PlayState for CharSelectionState { global_state.window.renderer_mut(), self.client.borrow().get_tick(), humanoid_body.clone(), - loadout, + loadout.as_ref(), ); // Draw the UI to the screen. diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index a1ff30d842..2c8d7ac104 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -333,9 +333,31 @@ impl CharSelectionUi { } } - pub fn get_loadout(&mut self) -> Option<&comp::Loadout> { + pub fn get_loadout(&mut self) -> Option { match &mut self.mode { - Mode::Select(_) => None, + Mode::Select(characterdata) => { + let loadout = comp::Loadout { + active_item: characterdata + .as_ref() + .and_then(|d| d.tool.as_ref()) + .map(|tool| comp::ItemConfig { + item: (*load_expect::(&tool)).clone(), + ability1: None, + ability2: None, + ability3: None, + block_ability: None, + dodge_ability: None, + }), + second_item: None, + shoulder: None, + chest: None, + belt: None, + hand: None, + pants: None, + foot: None, + }; + Some(loadout) + }, Mode::Create { loadout, tool, .. } => { loadout.active_item = tool.map(|tool| comp::ItemConfig { item: (*load_expect::(tool)).clone(), @@ -345,7 +367,7 @@ impl CharSelectionUi { block_ability: None, dodge_ability: None, }); - Some(loadout) + Some(loadout.clone()) }, } } From 0b3fb2dd3cee121a4b5f85ff13186a5a68571468 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 27 Mar 2020 18:31:45 +0100 Subject: [PATCH 274/326] fire bolt visuals --- assets/voxygen/voxel/weapon/projectile/fire-bolt-0.vox | 3 +++ assets/voxygen/voxel/weapon/projectile/fire-bolt-1.vox | 3 +++ assets/voxygen/voxel/weapon/projectile/fire-bolt-2.vox | 3 --- assets/voxygen/voxel/weapon/projectile/fire-bolt.vox | 3 --- assets/voxygen/voxel/weapon/projectile/leaf.vox | 4 ++-- assets/voxygen/voxel/weapon/projectile/nature-bolt.vox | 4 ++-- assets/voxygen/voxel/weapon/projectile/simple-arrow.vox | 4 ++-- assets/voxygen/voxel/weapon/projectile/snake-arrow.vox | 4 ++-- common/src/comp/body/object.rs | 4 +++- common/src/comp/inventory/item.rs | 2 +- voxygen/src/scene/figure/load.rs | 3 ++- 11 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 assets/voxygen/voxel/weapon/projectile/fire-bolt-0.vox create mode 100644 assets/voxygen/voxel/weapon/projectile/fire-bolt-1.vox delete mode 100644 assets/voxygen/voxel/weapon/projectile/fire-bolt-2.vox delete mode 100644 assets/voxygen/voxel/weapon/projectile/fire-bolt.vox diff --git a/assets/voxygen/voxel/weapon/projectile/fire-bolt-0.vox b/assets/voxygen/voxel/weapon/projectile/fire-bolt-0.vox new file mode 100644 index 0000000000..fed4afe7ea --- /dev/null +++ b/assets/voxygen/voxel/weapon/projectile/fire-bolt-0.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec4e54b888ffd13401966692126b944c93a50bc2dffad859e5a66f6c91b4010b +size 1804 diff --git a/assets/voxygen/voxel/weapon/projectile/fire-bolt-1.vox b/assets/voxygen/voxel/weapon/projectile/fire-bolt-1.vox new file mode 100644 index 0000000000..0ff9320b16 --- /dev/null +++ b/assets/voxygen/voxel/weapon/projectile/fire-bolt-1.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e21be7a7667ffbf0ec9c1bdcc13476cd7c6a416afff352ecd188b6e51700d990 +size 5416 diff --git a/assets/voxygen/voxel/weapon/projectile/fire-bolt-2.vox b/assets/voxygen/voxel/weapon/projectile/fire-bolt-2.vox deleted file mode 100644 index 133b9c16c7..0000000000 --- a/assets/voxygen/voxel/weapon/projectile/fire-bolt-2.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8d15904841c98667bcb01da55d1d7ad2aa7fd5d3358b72d7070ee89e2a420800 -size 56123 diff --git a/assets/voxygen/voxel/weapon/projectile/fire-bolt.vox b/assets/voxygen/voxel/weapon/projectile/fire-bolt.vox deleted file mode 100644 index 385f737523..0000000000 --- a/assets/voxygen/voxel/weapon/projectile/fire-bolt.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2f57b1e7622e4af69e25010dace42b46a2b4628ecf31e438b5ed3d57c726bc72 -size 56287 diff --git a/assets/voxygen/voxel/weapon/projectile/leaf.vox b/assets/voxygen/voxel/weapon/projectile/leaf.vox index 5424426691..c8cac78836 100644 --- a/assets/voxygen/voxel/weapon/projectile/leaf.vox +++ b/assets/voxygen/voxel/weapon/projectile/leaf.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fce17a25351dd63d00de7850ca81d9a71ea93d713587bb23b3ef0cf0ba4f00a9 -size 55755 +oid sha256:7483ea5a59bf63b62cdb3d7a7c9ed7ce8d06fcc7afd8ca0c4b3fd482a0107bcb +size 1272 diff --git a/assets/voxygen/voxel/weapon/projectile/nature-bolt.vox b/assets/voxygen/voxel/weapon/projectile/nature-bolt.vox index d264912a00..621509ac91 100644 --- a/assets/voxygen/voxel/weapon/projectile/nature-bolt.vox +++ b/assets/voxygen/voxel/weapon/projectile/nature-bolt.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:477af654cf4a713e4c1128dfc64519482b8c12219c49cada4acc85e80713f5c0 -size 56123 +oid sha256:171a9e9eda4d240a86ec111c95c07d0373ab78885ba153759514a17ff08ec1b2 +size 1640 diff --git a/assets/voxygen/voxel/weapon/projectile/simple-arrow.vox b/assets/voxygen/voxel/weapon/projectile/simple-arrow.vox index 4cfe04e2da..36e4d33d25 100644 --- a/assets/voxygen/voxel/weapon/projectile/simple-arrow.vox +++ b/assets/voxygen/voxel/weapon/projectile/simple-arrow.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6cb25e13383c652a6b1cd27282db67ed86f1954e784e4d645d676df125742a9a -size 55647 +oid sha256:506e9c9675bfbd21278a9d01f44c025ae560f05ddec37412f7da394457f2fc0f +size 1164 diff --git a/assets/voxygen/voxel/weapon/projectile/snake-arrow.vox b/assets/voxygen/voxel/weapon/projectile/snake-arrow.vox index c0691fab73..ab253258cd 100644 --- a/assets/voxygen/voxel/weapon/projectile/snake-arrow.vox +++ b/assets/voxygen/voxel/weapon/projectile/snake-arrow.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:05be44bed311c4b7900e5fdcad6438bb3a0003ed4cb645c5d693f5f1a17006cd -size 55679 +oid sha256:964372054cad9962a6f0429bdb9b1ea5794e53e0e822d2a7f9cb6be268bcdf37 +size 1196 diff --git a/common/src/comp/body/object.rs b/common/src/comp/body/object.rs index 514a191bf1..d179884062 100644 --- a/common/src/comp/body/object.rs +++ b/common/src/comp/body/object.rs @@ -55,6 +55,7 @@ pub enum Body { BoltFire = 49, ArrowSnake = 50, CampfireLit = 51, + BoltFireBig = 52, } impl Body { @@ -64,7 +65,7 @@ impl Body { } } -const ALL_OBJECTS: [Body; 51] = [ +const ALL_OBJECTS: [Body; 52] = [ Body::Arrow, Body::Bomb, Body::Scarecrow, @@ -115,5 +116,6 @@ const ALL_OBJECTS: [Body; 51] = [ Body::CarpetHumanSquircle, Body::CraftingBench, Body::BoltFire, + Body::BoltFireBig, Body::ArrowSnake, ]; diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index ce7d6e936d..f29046354f 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -182,7 +182,7 @@ impl ToolData { time_left: Duration::from_secs(20), owner: None, }, - projectile_body: Body::Object(object::Body::BoltFire), + projectile_body: Body::Object(object::Body::BoltFireBig), projectile_light: Some(LightEmitter { col: (0.72, 0.11, 0.11).into(), ..Default::default() diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index a2e51c48ab..b9ea7bc49e 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -1869,7 +1869,8 @@ pub fn mesh_object(obj: object::Body) -> Mesh { Body::Pouch => ("object.pouch", Vec3::new(-5.5, -4.5, 0.0)), Body::CraftingBench => ("object.crafting_bench", Vec3::new(-9.5, -7.0, 0.0)), Body::ArrowSnake => ("weapon.projectile.snake-arrow", Vec3::new(-1.5, -6.5, 0.0)), - Body::BoltFire => ("weapon.projectile.fire-bolt", Vec3::new(-3.0, -5.5, -3.0)), + Body::BoltFire => ("weapon.projectile.fire-bolt-0", Vec3::new(-3.0, -5.5, -3.0)), + Body::BoltFireBig => ("weapon.projectile.fire-bolt-1", Vec3::new(-6.0, -6.0, -6.0)), }; load_mesh(name, offset) } From c6e635c51119ffd36dd5d181e39dc255db79d624 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 27 Mar 2020 18:38:01 +0100 Subject: [PATCH 275/326] Increase movement speed, make npcs slower than players --- common/src/comp/inventory/item.rs | 2 +- common/src/states/utils.rs | 4 ++-- server/src/events/entity_manipulation.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index f29046354f..f1b29b8a3f 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -165,7 +165,7 @@ impl ToolData { energy_cost: 400, holdable: false, prepare_duration: Duration::from_millis(800), - recover_duration: Duration::from_millis(300), + recover_duration: Duration::from_millis(50), projectile: Projectile { hit_ground: vec![ projectile::Effect::Explode { power: 1.4 }, diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 4c635cd68e..043468c0ae 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -9,8 +9,8 @@ use vek::vec::Vec2; pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; const BASE_HUMANOID_ACCEL: f32 = 100.0; -const BASE_HUMANOID_SPEED: f32 = 150.0; -const NPC_HUMANOID_SPEED: f32 = 150.0; +const BASE_HUMANOID_SPEED: f32 = 170.0; +const NPC_HUMANOID_SPEED: f32 = 170.0; const BASE_HUMANOID_AIR_ACCEL: f32 = 15.0; const BASE_HUMANOID_AIR_SPEED: f32 = 8.0; const BASE_HUMANOID_WATER_ACCEL: f32 = 70.0; diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 714d35933d..17231b07f1 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -194,7 +194,7 @@ pub fn handle_respawn(server: &Server, entity: EcsEntity) { pub fn handle_explosion(server: &Server, pos: Vec3, power: f32, owner: Option) { // Go through all other entities - let hit_range = 2.0 * power; + let hit_range = 3.0 * power; let ecs = &server.state.ecs(); for (pos_b, ori_b, character_b, stats_b) in ( &ecs.read_storage::(), From 2ffac59aa36bffabb5446b7fecc2ade343a6cfe6 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 27 Mar 2020 10:40:15 -0700 Subject: [PATCH 276/326] add triple strike timing --- common/src/comp/ability.rs | 27 ++++++++++++--------- common/src/comp/inventory/item.rs | 38 ++++++++++++++++++++---------- common/src/states/triple_strike.rs | 29 +++++++++++++++++++---- 3 files changed, 66 insertions(+), 28 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 882eb65ac3..5cfad8ccbc 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -47,6 +47,7 @@ pub enum CharacterAbility { }, TripleStrike { base_damage: u32, + needs_timing: bool, }, } @@ -55,7 +56,7 @@ impl CharacterAbility { /// applicable. pub fn requirements_paid(&self, data: &JoinData, update: &mut StateUpdate) -> bool { match self { - CharacterAbility::TripleStrike { .. } => { + CharacterAbility::TimedCombo { .. } | CharacterAbility::TripleStrike { .. } => { data.physics.on_ground && data.body.is_humanoid() && data.inputs.look_dir.xy().magnitude_squared() > 0.01 @@ -179,16 +180,20 @@ impl From<&CharacterAbility> for CharacterState { stage_time_active: Duration::default(), base_damage: *base_damage, }), - CharacterAbility::TripleStrike { base_damage } => { - CharacterState::TripleStrike(triple_strike::Data { - base_damage: *base_damage, - stage: triple_strike::Stage::First, - stage_exhausted: false, - stage_time_active: Duration::default(), - should_transition: true, - initialized: false, - }) - }, + CharacterAbility::TripleStrike { + base_damage, + needs_timing, + } => CharacterState::TripleStrike(triple_strike::Data { + base_damage: *base_damage, + stage: triple_strike::Stage::First, + stage_exhausted: false, + stage_time_active: Duration::default(), + needs_timing: *needs_timing, + // If `needs_timing`, prevent tansitioning by default, + // unless pressed at the right time. + should_transition: !*needs_timing, + initialized: false, + }), } } } diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 27ced5f27b..2750358d1e 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -70,11 +70,17 @@ impl ToolData { use ToolKind::*; match self.kind { - Sword(_) => vec![TripleStrike { base_damage: 5 }, DashMelee { - buildup_duration: Duration::from_millis(500), - recover_duration: Duration::from_millis(500), - base_damage: 10, - }], + Sword(_) => vec![ + TripleStrike { + base_damage: 5, + needs_timing: false, + }, + DashMelee { + buildup_duration: Duration::from_millis(500), + recover_duration: Duration::from_millis(500), + base_damage: 10, + }, + ], Axe(_) => vec![BasicMelee { energy_cost: 0, buildup_duration: Duration::from_millis(700), @@ -83,14 +89,20 @@ impl ToolData { range: 3.5, max_angle: 30.0, }], - Hammer(_) => vec![BasicMelee { - energy_cost: 0, - buildup_duration: Duration::from_millis(700), - recover_duration: Duration::from_millis(300), - base_healthchange: -10, - range: 3.5, - max_angle: 60.0, - }], + Hammer(_) => vec![ + BasicMelee { + energy_cost: 0, + buildup_duration: Duration::from_millis(700), + recover_duration: Duration::from_millis(300), + base_healthchange: -10, + range: 3.5, + max_angle: 60.0, + }, + TripleStrike { + base_damage: 7, + needs_timing: true, + }, + ], Bow(_) => vec![BasicRanged { energy_cost: 0, holdable: true, diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index f557ce3163..5dcc0de307 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -8,7 +8,6 @@ use vek::vec::Vec3; // In millis const STAGE_DURATION: u64 = 700; - const INITIAL_ACCEL: f32 = 90.0; const BASE_SPEED: f32 = 25.0; @@ -39,6 +38,10 @@ pub struct Data { pub should_transition: bool, /// Whether state has performed intialization logic pub initialized: bool, + /// Whether player must time button pressed properly to continue combo + pub needs_timing: bool, + /* /// Set to prevent transitioning, true by default when `needs_timing` + * pub prevent_transition: bool, */ } impl CharacterBehavior for Data { @@ -50,9 +53,6 @@ impl CharacterBehavior for Data { .checked_add(Duration::from_secs_f32(data.dt.0)) .unwrap_or(Duration::default()); - // If player stops holding input, don't go to the next stage - let should_transition = data.inputs.primary.is_pressed() && self.should_transition; - if !self.initialized { update.vel.0 = Vec3::zero(); if let Some(dir) = data.inputs.look_dir.try_normalized() { @@ -61,6 +61,24 @@ impl CharacterBehavior for Data { } let initialized = true; + // If player stops holding input, don't go to the next stage + let mut should_transition = self.should_transition; + + // Check inputs based on whether `needs_timing` + if self.needs_timing { + // Player must press at right time + if data.inputs.primary.is_pressed() + && stage_time_active > Duration::from_millis(STAGE_DURATION * 0.7) + { + should_transition = true; + } + } else { + // Prevent transitioning if player ever stops holding input + if !data.inputs.primary.is_pressed() { + should_transition = false; + } + } + // Handle hit applied if let Some(attack) = data.attacking { if attack.applied && attack.hit_count > 0 { @@ -125,6 +143,7 @@ impl CharacterBehavior for Data { stage_exhausted: true, should_transition, initialized, + needs_timing: self.needs_timing, }) } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { let next_stage = match self.stage { @@ -142,6 +161,7 @@ impl CharacterBehavior for Data { stage_exhausted: false, should_transition, initialized, + needs_timing: self.needs_timing, }) } else { // Make sure attack component is removed @@ -157,6 +177,7 @@ impl CharacterBehavior for Data { stage_exhausted: self.stage_exhausted, should_transition, initialized, + needs_timing: self.needs_timing, }) }; From 8eb233bdbc04c7f07ce22df24476ed17385a61c1 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 27 Mar 2020 10:43:18 -0700 Subject: [PATCH 277/326] Add timing window duration to triple strike --- common/src/states/triple_strike.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 5dcc0de307..0b9a566923 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -8,6 +8,7 @@ use vek::vec::Vec3; // In millis const STAGE_DURATION: u64 = 700; +const TIMING_WINDOW: u64 = 500; const INITIAL_ACCEL: f32 = 90.0; const BASE_SPEED: f32 = 25.0; @@ -68,7 +69,7 @@ impl CharacterBehavior for Data { if self.needs_timing { // Player must press at right time if data.inputs.primary.is_pressed() - && stage_time_active > Duration::from_millis(STAGE_DURATION * 0.7) + && stage_time_active > Duration::from_millis(TIMING_WINDOW) { should_transition = true; } From d774091fa4fba874ff5b67db189446b094da3fad Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 27 Mar 2020 11:00:58 -0700 Subject: [PATCH 278/326] Add triple_strike anims for axe and hammer --- common/src/comp/inventory/item.rs | 34 +++++++++++++++--------------- voxygen/src/anim/character/beta.rs | 2 +- voxygen/src/anim/character/spin.rs | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index ded78545c1..f8311d0fa3 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -81,28 +81,28 @@ impl ToolData { base_damage: 10, }, ], - Axe(_) => vec![BasicMelee { - energy_cost: 0, - buildup_duration: Duration::from_millis(700), - recover_duration: Duration::from_millis(100), - base_healthchange: -8, - range: 3.5, - max_angle: 30.0, - }], - Hammer(_) => vec![ - BasicMelee { - energy_cost: 0, - buildup_duration: Duration::from_millis(700), - recover_duration: Duration::from_millis(300), - base_healthchange: -10, - range: 3.5, - max_angle: 60.0, - }, + Axe(_) => vec![ TripleStrike { base_damage: 7, needs_timing: true, }, + BasicMelee { + energy_cost: 0, + buildup_duration: Duration::from_millis(700), + recover_duration: Duration::from_millis(100), + base_healthchange: -8, + range: 3.5, + max_angle: 30.0, + }, ], + Hammer(_) => vec![BasicMelee { + energy_cost: 0, + buildup_duration: Duration::from_millis(700), + recover_duration: Duration::from_millis(300), + base_healthchange: -10, + range: 3.5, + max_angle: 60.0, + }], Bow(_) => vec![BasicRanged { energy_cost: 0, holdable: true, diff --git a/voxygen/src/anim/character/beta.rs b/voxygen/src/anim/character/beta.rs index 0ae34b22a7..8161ba32a8 100644 --- a/voxygen/src/anim/character/beta.rs +++ b/voxygen/src/anim/character/beta.rs @@ -39,7 +39,7 @@ impl Animation for BetaAnimation { match active_tool_kind { //TODO: Inventory - Some(ToolKind::Sword(_)) => { + Some(ToolKind::Axe(_)) | Some(ToolKind::Hammer(_)) | Some(ToolKind::Sword(_)) => { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward, diff --git a/voxygen/src/anim/character/spin.rs b/voxygen/src/anim/character/spin.rs index 98f37e1c5e..44ad34c6e2 100644 --- a/voxygen/src/anim/character/spin.rs +++ b/voxygen/src/anim/character/spin.rs @@ -36,7 +36,7 @@ impl Animation for SpinAnimation { match active_tool_kind { //TODO: Inventory - Some(ToolKind::Sword(_)) => { + Some(ToolKind::Axe(_)) | Some(ToolKind::Hammer(_)) | Some(ToolKind::Sword(_)) => { next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.04; From 233595737e2220437d1065df66be59d5cd204b09 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 27 Mar 2020 11:03:07 -0700 Subject: [PATCH 279/326] Axe m2 dmg 10 -> 15 Axe m2 cost 0 -> 50 --- common/src/comp/inventory/item.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index f8311d0fa3..18181b2b11 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -96,10 +96,10 @@ impl ToolData { }, ], Hammer(_) => vec![BasicMelee { - energy_cost: 0, + energy_cost: 50, buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(300), - base_healthchange: -10, + base_healthchange: -15, range: 3.5, max_angle: 60.0, }], From 02b29efbfc51a343a552c66d3f665f68a1de4b9d Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 27 Mar 2020 11:07:21 -0700 Subject: [PATCH 280/326] Undo mistake, axe ability corrected. Axe m2 cost 0 -> 100 Axe m2 dmg 8 -> 12 --- common/src/comp/inventory/item.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item.rs index 18181b2b11..1a5f7b2fe1 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item.rs @@ -87,19 +87,19 @@ impl ToolData { needs_timing: true, }, BasicMelee { - energy_cost: 0, + energy_cost: 100, buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(100), - base_healthchange: -8, + base_healthchange: -12, range: 3.5, max_angle: 30.0, }, ], Hammer(_) => vec![BasicMelee { - energy_cost: 50, + energy_cost: 0, buildup_duration: Duration::from_millis(700), recover_duration: Duration::from_millis(300), - base_healthchange: -15, + base_healthchange: -10, range: 3.5, max_angle: 60.0, }], From e4f2bf7ebf2f9227e7bfb59212bcc7c507d6840a Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 27 Mar 2020 11:08:10 -0700 Subject: [PATCH 281/326] prevent holding to time combo --- common/src/states/triple_strike.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 0b9a566923..31eedcdc64 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -68,7 +68,7 @@ impl CharacterBehavior for Data { // Check inputs based on whether `needs_timing` if self.needs_timing { // Player must press at right time - if data.inputs.primary.is_pressed() + if data.inputs.primary.is_just_pressed() && stage_time_active > Duration::from_millis(TIMING_WINDOW) { should_transition = true; From 1d51f8fc0fc0b2a389fbf4b0b3299d2a3bf611fb Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Fri, 27 Mar 2020 11:17:34 -0700 Subject: [PATCH 282/326] prevent transition if pressing too early & timed --- common/src/comp/ability.rs | 1 + common/src/states/triple_strike.rs | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 5cfad8ccbc..4f3cdda038 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -193,6 +193,7 @@ impl From<&CharacterAbility> for CharacterState { // unless pressed at the right time. should_transition: !*needs_timing, initialized: false, + prevent_transition: false, }), } } diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 31eedcdc64..a3b994b985 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -41,8 +41,8 @@ pub struct Data { pub initialized: bool, /// Whether player must time button pressed properly to continue combo pub needs_timing: bool, - /* /// Set to prevent transitioning, true by default when `needs_timing` - * pub prevent_transition: bool, */ + /// Set to prevent transitioning, true by default when `needs_timing` + pub prevent_transition: bool, } impl CharacterBehavior for Data { @@ -64,14 +64,20 @@ impl CharacterBehavior for Data { // If player stops holding input, don't go to the next stage let mut should_transition = self.should_transition; + let mut prevent_transition = self.prevent_transition; // Check inputs based on whether `needs_timing` if self.needs_timing { // Player must press at right time - if data.inputs.primary.is_just_pressed() - && stage_time_active > Duration::from_millis(TIMING_WINDOW) - { - should_transition = true; + if data.inputs.primary.is_just_pressed() { + if stage_time_active > Duration::from_millis(TIMING_WINDOW) { + // Player pressed at right time, transition + // unless prevent_transition has been set + should_transition = true; + } else { + // Player pressed too early + prevent_transition = true; + } } } else { // Prevent transitioning if player ever stops holding input @@ -145,10 +151,11 @@ impl CharacterBehavior for Data { should_transition, initialized, needs_timing: self.needs_timing, + prevent_transition, }) } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { let next_stage = match self.stage { - _ if !should_transition => None, + _ if !should_transition || prevent_transition => None, Stage::First => Some(Stage::Second), Stage::Second => Some(Stage::Third), Stage::Third => None, @@ -163,6 +170,7 @@ impl CharacterBehavior for Data { should_transition, initialized, needs_timing: self.needs_timing, + prevent_transition, }) } else { // Make sure attack component is removed @@ -179,6 +187,7 @@ impl CharacterBehavior for Data { should_transition, initialized, needs_timing: self.needs_timing, + prevent_transition, }) }; From 15ecdfb9b4579583a269c43a8fe7d2a233c5f99d Mon Sep 17 00:00:00 2001 From: Capucho Date: Fri, 27 Mar 2020 18:35:52 +0000 Subject: [PATCH 283/326] Added an option for hold and added everything to the settings --- assets/voxygen/i18n/en.ron | 6 ++++ voxygen/src/hud/mod.rs | 9 ++++++ voxygen/src/hud/settings_window.rs | 51 ++++++++++++++++++++++++++++-- voxygen/src/session.rs | 20 +++++++++--- voxygen/src/settings.rs | 6 ++-- 5 files changed, 83 insertions(+), 9 deletions(-) diff --git a/assets/voxygen/i18n/en.ron b/assets/voxygen/i18n/en.ron index 57ef0300db..cdcad13db1 100644 --- a/assets/voxygen/i18n/en.ron +++ b/assets/voxygen/i18n/en.ron @@ -192,6 +192,8 @@ Enjoy your stay in the World of Veloren."#, "hud.settings.general": "General", "hud.settings.none": "None", + "hud.settings.press_behavior.toggle": "Toggle", + "hud.settings.press_behavior.hold": "Hold", "hud.settings.help_window": "Help Window", "hud.settings.debug_info": "Debug Info", "hud.settings.tips_on_startup": "Tips-On-Startup", @@ -219,6 +221,7 @@ Enjoy your stay in the World of Veloren."#, "hud.settings.zoom_sensitivity": "Zoom Sensitivity", "hud.settings.invert_scroll_zoom": "Invert Scroll Zoom", "hud.settings.invert_mouse_y_axis": "Invert Mouse Y Axis", + "hud.settings.free_look_behavior": "Free look behavior", "hud.settings.view_distance": "View Distance", "hud.settings.maximum_fps": "Maximum FPS", @@ -308,6 +311,9 @@ Send Chat Message Scroll Chat +Free look + + Chat commands: /alias [Name] - Change your Chat Name diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 9a45e82156..af37606609 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -231,6 +231,7 @@ pub enum Event { Logout, Quit, ChangeLanguage(LanguageMetadata), + ChangeFreeLookBehavior(PressBehavior), } // TODO: Are these the possible layouts we want? @@ -271,6 +272,11 @@ pub enum ShortcutNumbers { On, Off, } +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +pub enum PressBehavior { + Toggle = 0, + Hold = 1, +} pub struct Show { ui: bool, @@ -1825,6 +1831,9 @@ impl Hud { settings_window::Event::AdjustWindowSize(new_size) => { events.push(Event::AdjustWindowSize(new_size)); }, + settings_window::Event::ChangeFreeLookBehavior(behavior) => { + events.push(Event::ChangeFreeLookBehavior(behavior)); + }, } } } diff --git a/voxygen/src/hud/settings_window.rs b/voxygen/src/hud/settings_window.rs index 1c63978804..d0aba49fff 100644 --- a/voxygen/src/hud/settings_window.rs +++ b/voxygen/src/hud/settings_window.rs @@ -1,6 +1,6 @@ use super::{ - img_ids::Imgs, BarNumbers, CrosshairType, Intro, ShortcutNumbers, Show, XpBar, MENU_BG, - TEXT_COLOR, + img_ids::Imgs, BarNumbers, CrosshairType, Intro, PressBehavior, ShortcutNumbers, Show, XpBar, + MENU_BG, TEXT_COLOR, }; use crate::{ i18n::{list_localizations, LanguageMetadata, VoxygenLocalization}, @@ -141,7 +141,8 @@ widget_ids! { sct_num_dur_text, sct_num_dur_slider, sct_num_dur_value, - + free_look_behavior_text, + free_look_behavior_list } } @@ -220,6 +221,7 @@ pub enum Event { SctPlayerBatch(bool), SctDamageBatch(bool), ChangeLanguage(LanguageMetadata), + ChangeFreeLookBehavior(PressBehavior), } pub enum ScaleChange { @@ -1254,6 +1256,45 @@ impl<'a> Widget for SettingsWindow<'a> { .graphics_for(state.ids.mouse_y_invert_button) .color(TEXT_COLOR) .set(state.ids.mouse_y_invert_label, ui); + + // Free look behaviour + Text::new( + &self + .localized_strings + .get("hud.settings.free_look_behavior"), + ) + .down_from(state.ids.mouse_zoom_invert_button, 10.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.free_look_behavior_text, ui); + + let mode_label_list = [ + &self + .localized_strings + .get("hud.settings.press_behavior.toggle"), + &self + .localized_strings + .get("hud.settings.press_behavior.hold"), + ]; + + // Get which free look behavior is currently active + let selected = self.global_state.settings.gameplay.free_look_behavior as usize; + + if let Some(clicked) = DropDownList::new(&mode_label_list, Some(selected)) + .w_h(200.0, 30.0) + .color(MENU_BG) + .label_color(TEXT_COLOR) + .label_font_id(self.fonts.cyri.conrod_id) + .down_from(state.ids.free_look_behavior_text, 8.0) + .set(state.ids.free_look_behavior_list, ui) + { + match clicked { + 0 => events.push(Event::ChangeFreeLookBehavior(PressBehavior::Toggle)), + 1 => events.push(Event::ChangeFreeLookBehavior(PressBehavior::Hold)), + _ => unreachable!(), + } + } } // 3) Controls Tab -------------------------------- @@ -1367,6 +1408,9 @@ impl<'a> Widget for SettingsWindow<'a> { {}\n\ \n\ \n\ + {}\n\ + \n\ + \n\ \n\ \n\ \n\ @@ -1417,6 +1461,7 @@ impl<'a> Widget for SettingsWindow<'a> { controls.bag, controls.enter, "Mouse Wheel", // Scroll chat + controls.free_look )) .color(TEXT_COLOR) .right_from(state.ids.controls_text, 0.0) diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 5e9d46b6fb..335b06b21d 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -1,6 +1,6 @@ use crate::{ ecs::MyEntity, - hud::{DebugInfo, Event as HudEvent, Hud}, + hud::{DebugInfo, Event as HudEvent, Hud, PressBehavior}, i18n::{i18n_asset_key, VoxygenLocalization}, key_state::KeyState, menu::char_selection::CharSelectionState, @@ -402,9 +402,18 @@ impl PlayState for SessionState { Event::InputUpdate(GameInput::Charge, state) => { self.inputs.charge.set_state(state); }, - Event::InputUpdate(GameInput::FreeLook, true) => { - free_look = !free_look; - self.hud.free_look(free_look); + Event::InputUpdate(GameInput::FreeLook, state) => { + match (global_state.settings.gameplay.free_look_behavior, state) { + (PressBehavior::Toggle, true) => { + free_look = !free_look; + self.hud.free_look(free_look); + }, + (PressBehavior::Hold, state) => { + free_look = state; + self.hud.free_look(free_look); + }, + _ => {}, + }; }, Event::AnalogGameInput(input) => match input { AnalogGameInput::MovementX(v) => { @@ -681,6 +690,9 @@ impl PlayState for SessionState { global_state.settings.graphics.window_size = new_size; global_state.settings.save_to_file_warn(); }, + HudEvent::ChangeFreeLookBehavior(behavior) => { + global_state.settings.gameplay.free_look_behavior = behavior; + }, } } diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 5f47300544..6a7590f093 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -1,5 +1,5 @@ use crate::{ - hud::{BarNumbers, CrosshairType, Intro, ShortcutNumbers, XpBar}, + hud::{BarNumbers, CrosshairType, Intro, PressBehavior, ShortcutNumbers, XpBar}, i18n, render::{AaMode, CloudMode, FluidMode}, ui::ScaleMode, @@ -69,7 +69,7 @@ impl Default for ControlSettings { Self { primary: KeyMouse::Mouse(MouseButton::Left), secondary: KeyMouse::Mouse(MouseButton::Right), - toggle_cursor: KeyMouse::Key(VirtualKeyCode::Tab), + toggle_cursor: KeyMouse::Key(VirtualKeyCode::L), escape: KeyMouse::Key(VirtualKeyCode::Escape), enter: KeyMouse::Key(VirtualKeyCode::Return), command: KeyMouse::Key(VirtualKeyCode::Slash), @@ -346,6 +346,7 @@ pub struct GameplaySettings { pub shortcut_numbers: ShortcutNumbers, pub bar_numbers: BarNumbers, pub ui_scale: ScaleMode, + pub free_look_behavior: PressBehavior, } impl Default for GameplaySettings { @@ -367,6 +368,7 @@ impl Default for GameplaySettings { shortcut_numbers: ShortcutNumbers::On, bar_numbers: BarNumbers::Off, ui_scale: ScaleMode::RelativeToWindow([1920.0, 1080.0].into()), + free_look_behavior: PressBehavior::Toggle, } } } From 7d1f779c28be9ad0d1f71f0af96b291c5a5bfb2e Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Fri, 27 Mar 2020 20:00:16 +0100 Subject: [PATCH 284/326] Update headband-0.vox --- assets/voxygen/voxel/figure/accessory/elf/headband-0.vox | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/voxygen/voxel/figure/accessory/elf/headband-0.vox b/assets/voxygen/voxel/figure/accessory/elf/headband-0.vox index 6384b30de5..33c38a4369 100644 --- a/assets/voxygen/voxel/figure/accessory/elf/headband-0.vox +++ b/assets/voxygen/voxel/figure/accessory/elf/headband-0.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ee5ef8c75028aac457778b2f5fb20be0c8f2bc71eb71787f506ece2aa27d6583 -size 1304 +oid sha256:4a992b96ae9b6d891a0c98f98742bdc1beeab441e93741ae48401fd3aa6321fa +size 1112 From 15d2a6d3dc3364c43fdd1398c39c09d4060f4b10 Mon Sep 17 00:00:00 2001 From: Capucho Date: Fri, 27 Mar 2020 19:36:20 +0000 Subject: [PATCH 285/326] Fix the wrong default keybind change --- voxygen/src/settings.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 6a7590f093..a8ce79e0b4 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -69,7 +69,7 @@ impl Default for ControlSettings { Self { primary: KeyMouse::Mouse(MouseButton::Left), secondary: KeyMouse::Mouse(MouseButton::Right), - toggle_cursor: KeyMouse::Key(VirtualKeyCode::L), + toggle_cursor: KeyMouse::Key(VirtualKeyCode::Tab), escape: KeyMouse::Key(VirtualKeyCode::Escape), enter: KeyMouse::Key(VirtualKeyCode::Return), command: KeyMouse::Key(VirtualKeyCode::Slash), @@ -102,7 +102,7 @@ impl Default for ControlSettings { interact: KeyMouse::Mouse(MouseButton::Right), toggle_wield: KeyMouse::Key(VirtualKeyCode::T), charge: KeyMouse::Key(VirtualKeyCode::Key1), - free_look: KeyMouse::Key(VirtualKeyCode::LAlt), + free_look: KeyMouse::Key(VirtualKeyCode::L), } } } From df5a7ef0e3ad55ed51909ea78fa28518756c765f Mon Sep 17 00:00:00 2001 From: Imbris Date: Thu, 26 Mar 2020 11:05:17 -0400 Subject: [PATCH 286/326] split toggle events --- client/src/lib.rs | 44 ++++++++++++++++++++++++++-- common/src/comp/controller.rs | 6 ++-- common/src/states/idle.rs | 4 +-- common/src/states/sit.rs | 4 +-- common/src/states/wielding.rs | 4 +-- common/src/sys/character_behavior.rs | 12 +++++--- 6 files changed, 59 insertions(+), 15 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 7b4bb8dd8b..4e906bb765 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -307,11 +307,49 @@ impl Client { } } - pub fn swap_loadout(&mut self) { self.control_action(ControlAction::SwapLoadout); } + pub fn swap_loadout(&mut self) { + let can_swap = self + .state + .ecs() + .read_storage::() + .get(self.entity) + .map(|cs| cs.can_swap()); + match can_swap { + Some(true) => self.control_action(ControlAction::SwapLoadout), + Some(false) => {}, + None => warn!("Can't swap, client entity doesn't have a `CharacterState`"), + } + } - pub fn toggle_wield(&mut self) { self.control_action(ControlAction::ToggleWield); } + pub fn toggle_wield(&mut self) { + let is_wielding = self + .state + .ecs() + .read_storage::() + .get(self.entity) + .map(|cs| cs.is_wield()); - pub fn toggle_sit(&mut self) { self.control_action(ControlAction::ToggleSit); } + match is_wielding { + Some(true) => self.control_action(ControlAction::Unwield), + Some(false) => self.control_action(ControlAction::Wield), + None => warn!("Can't toggle wield, client entity doesn't have a `CharacterState`"), + } + } + + pub fn toggle_sit(&mut self) { + let is_sitting = self + .state + .ecs() + .read_storage::() + .get(self.entity) + .map(|cs| matches!(cs, comp::CharacterState::Sit)); + + match is_sitting { + Some(true) => self.control_action(ControlAction::Stand), + Some(false) => self.control_action(ControlAction::Sit), + None => warn!("Can't toggle sit, client entity doesn't have a `CharacterState`"), + } + } fn control_action(&mut self, control_action: ControlAction) { if let Some(controller) = self diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 87d9e1577f..ef955fa0bd 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -18,8 +18,10 @@ pub enum ControlEvent { #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] pub enum ControlAction { SwapLoadout, - ToggleWield, - ToggleSit, + Wield, + Unwield, + Sit, + Stand, } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index eb58dccf55..c403d43115 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -20,13 +20,13 @@ impl CharacterBehavior for Data { update } - fn toggle_wield(&self, data: &JoinData) -> StateUpdate { + fn wield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_wield(data, &mut update); update } - fn toggle_sit(&self, data: &JoinData) -> StateUpdate { + fn sit(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_sit(data, &mut update); update diff --git a/common/src/states/sit.rs b/common/src/states/sit.rs index ad919a3993..8dd7f9471f 100644 --- a/common/src/states/sit.rs +++ b/common/src/states/sit.rs @@ -21,13 +21,13 @@ impl CharacterBehavior for Data { update } - fn toggle_wield(&self, data: &JoinData) -> StateUpdate { + fn wield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_wield(data, &mut update); update } - fn toggle_sit(&self, data: &JoinData) -> StateUpdate { + fn stand(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); // Try to Fall/Stand up/Move update.character = CharacterState::Idle; diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 9381c185e5..6babe4f85d 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -22,13 +22,13 @@ impl CharacterBehavior for Data { update } - fn toggle_sit(&self, data: &JoinData) -> StateUpdate { + fn sit(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_sit(data, &mut update); update } - fn toggle_wield(&self, data: &JoinData) -> StateUpdate { + fn unwield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); update.character = CharacterState::Idle; update diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index e46fd63242..2dff358eae 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -17,13 +17,17 @@ pub trait CharacterBehavior { fn behavior(&self, data: &JoinData) -> StateUpdate; // Impl these to provide behavior for these inputs fn swap_loadout(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } - fn toggle_wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } - fn toggle_sit(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } + fn wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } + fn unwield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } + fn sit(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } + fn stand(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } fn handle_event(&self, data: &JoinData, event: ControlAction) -> StateUpdate { match event { ControlAction::SwapLoadout => self.swap_loadout(data), - ControlAction::ToggleWield => self.toggle_wield(data), - ControlAction::ToggleSit => self.toggle_sit(data), + ControlAction::Wield => self.wield(data), + ControlAction::Unwield => self.unwield(data), + ControlAction::Sit => self.sit(data), + ControlAction::Stand => self.stand(data), } } // fn init(data: &JoinData) -> CharacterState; From ba3fa16c3371b0994b7bb2026a5dca0a704aace2 Mon Sep 17 00:00:00 2001 From: Imbris Date: Fri, 27 Mar 2020 21:31:22 -0400 Subject: [PATCH 287/326] Create Dir type for better enforcement of non NaN, normalized representations of directions --- Cargo.lock | 3 +- Cargo.toml | 3 + common/src/comp/controller.rs | 4 +- common/src/comp/phys.rs | 4 +- common/src/event.rs | 4 +- common/src/states/boost.rs | 2 +- common/src/states/climb.rs | 34 +++-- common/src/states/dash_melee.rs | 8 +- common/src/states/glide.rs | 4 +- common/src/states/roll.rs | 4 +- common/src/states/triple_strike.rs | 2 +- common/src/states/utils.rs | 6 +- common/src/sys/agent.rs | 16 ++- common/src/sys/combat.rs | 5 +- common/src/sys/controller.rs | 6 - common/src/sys/projectile.rs | 5 +- common/src/util/dir.rs | 186 +++++++++++++++++++++++++++ common/src/util/mod.rs | 83 +----------- server/src/cmd.rs | 18 +-- server/src/events/entity_creation.rs | 13 +- server/src/events/inventory_manip.rs | 4 +- server/src/state_ext.rs | 9 +- voxygen/src/audio/sfx/mod.rs | 6 +- voxygen/src/ecs/comp.rs | 3 +- voxygen/src/ecs/sys/interpolation.rs | 4 +- voxygen/src/scene/figure/mod.rs | 36 +++--- voxygen/src/session.rs | 3 +- 27 files changed, 296 insertions(+), 179 deletions(-) create mode 100644 common/src/util/dir.rs diff --git a/Cargo.lock b/Cargo.lock index a62f45c156..062ed9b6f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4847,8 +4847,7 @@ checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" [[package]] name = "vek" version = "0.9.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b833a133490ae98e9e3db1c77fc28e844f8e51b12eb35b4ab8a2082cb7cb441a" +source = "git+https://github.com/Imberflur/vek?branch=is_normalized#7442254deb67ad6930bedc671057d14ea8e885eb" dependencies = [ "approx 0.1.1", "num-integer", diff --git a/Cargo.toml b/Cargo.toml index f4a8194459..4c8b444279 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,3 +68,6 @@ debug = false [profile.releasedebuginfo] inherits = 'release' debug = 1 + +[patch.crates-io] +vek = {git = "https://github.com/Imberflur/vek", branch = "is_normalized"} diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index ef955fa0bd..5852ad56ec 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -1,4 +1,4 @@ -use crate::sync::Uid; +use crate::{sync::Uid, util::Dir}; use specs::{Component, FlaggedStorage}; use specs_idvs::IDVStorage; use std::time::Duration; @@ -146,7 +146,7 @@ pub struct ControllerInputs { pub charge: Input, pub climb: Option, pub move_dir: Vec2, - pub look_dir: Vec3, + pub look_dir: Dir, } #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] diff --git a/common/src/comp/phys.rs b/common/src/comp/phys.rs index c1c54d80ce..202eed9cf9 100644 --- a/common/src/comp/phys.rs +++ b/common/src/comp/phys.rs @@ -1,4 +1,4 @@ -use crate::sync::Uid; +use crate::{sync::Uid, util::Dir}; use specs::{Component, FlaggedStorage, NullStorage}; use specs_idvs::IDVStorage; use vek::*; @@ -21,7 +21,7 @@ impl Component for Vel { // Orientation #[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct Ori(pub Vec3); +pub struct Ori(pub Dir); impl Component for Ori { type Storage = IDVStorage; diff --git a/common/src/event.rs b/common/src/event.rs index fe10b8d3a1..809c607802 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -1,4 +1,4 @@ -use crate::{comp, sync::Uid}; +use crate::{comp, sync::Uid, util::Dir}; use comp::{item::ToolKind, InventoryUpdateEvent}; use parking_lot::Mutex; use serde::Deserialize; @@ -87,7 +87,7 @@ pub enum ServerEvent { Respawn(EcsEntity), Shoot { entity: EcsEntity, - dir: Vec3, + dir: Dir, body: comp::Body, light: Option, projectile: comp::Projectile, diff --git a/common/src/states/boost.rs b/common/src/states/boost.rs index 20e5b53909..71d1e948a2 100644 --- a/common/src/states/boost.rs +++ b/common/src/states/boost.rs @@ -23,7 +23,7 @@ impl CharacterBehavior for Data { if self.only_up { update.vel.0.z += 500.0 * data.dt.0; } else { - update.vel.0 += data.inputs.look_dir * 500.0 * data.dt.0; + update.vel.0 += *data.inputs.look_dir * 500.0 * data.dt.0; } update.character = CharacterState::Boost(Data { duration: self diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 4614fe6721..7ddf2a7d57 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -5,7 +5,7 @@ use crate::{ character_behavior::{CharacterBehavior, JoinData}, phys::GRAVITY, }, - util::safe_slerp, + util::Dir, }; use vek::{ vec::{Vec2, Vec3}, @@ -23,7 +23,13 @@ impl CharacterBehavior for Data { let mut update = StateUpdate::from(data); // If no wall is in front of character or we stopped climbing; - if data.physics.on_wall.is_none() || data.physics.on_ground || data.inputs.climb.is_none() { + let (wall_dir, climb) = if let (Some(wall_dir), Some(climb), false) = ( + data.physics.on_wall, + data.inputs.climb, + data.physics.on_ground, + ) { + (wall_dir, climb) + } else { if data.inputs.jump.is_pressed() { // They've climbed atop something, give them a boost update @@ -32,7 +38,7 @@ impl CharacterBehavior for Data { } update.character = CharacterState::Idle {}; return update; - } + }; // Move player update.vel.0 += Vec2::broadcast(data.dt.0) @@ -44,11 +50,9 @@ impl CharacterBehavior for Data { }; // Expend energy if climbing - let energy_use = match data.inputs.climb { - Some(Climb::Up) | Some(Climb::Down) => 8, - Some(Climb::Hold) => 1, - // Note: this is currently unreachable - None => 0, + let energy_use = match climb { + Climb::Up | Climb::Down => 8, + Climb::Hold => 1, }; if let Err(_) = update .energy @@ -58,25 +62,17 @@ impl CharacterBehavior for Data { } // Set orientation direction based on wall direction - let ori_dir = if let Some(wall_dir) = data.physics.on_wall { - Vec2::from(wall_dir) - } else { - Vec2::from(update.vel.0) - }; + let ori_dir = Vec2::from(wall_dir); // Smooth orientation - update.ori.0 = safe_slerp( + update.ori.0 = Dir::slerp_to_vec3( update.ori.0, ori_dir.into(), if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0, ); // Apply Vertical Climbing Movement - if let (Some(climb), true, Some(_wall_dir)) = ( - data.inputs.climb, - update.vel.0.z <= CLIMB_SPEED, - data.physics.on_wall, - ) { + if update.vel.0.z <= CLIMB_SPEED { match climb { Climb::Down => { update.vel.0 -= diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 06c513b5a8..2090c6d60a 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -2,7 +2,7 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, StateUpdate}, states::utils::*, sys::character_behavior::*, - util::safe_slerp, + util::Dir, }; use std::time::Duration; use vek::Vec3; @@ -27,9 +27,9 @@ impl CharacterBehavior for Data { let mut update = StateUpdate::from(data); if self.initialize { - update.vel.0 = data.inputs.look_dir * 20.0; + update.vel.0 = *data.inputs.look_dir * 20.0; if let Some(dir) = Vec3::from(data.vel.0.xy()).try_normalized() { - update.ori.0 = dir; + update.ori.0 = dir.into(); } } @@ -98,7 +98,7 @@ impl CharacterBehavior for Data { } } - update.ori.0 = safe_slerp(update.ori.0, update.vel.0, 9.0 * data.dt.0); + update.ori.0 = Dir::slerp_to_vec3(update.ori.0, update.vel.0, 9.0 * data.dt.0); update } diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 1c21ae9df9..d19ef9cd90 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,7 +1,7 @@ use crate::{ comp::{CharacterState, StateUpdate}, sys::character_behavior::{CharacterBehavior, JoinData}, - util::safe_slerp, + util::Dir, }; use vek::Vec2; @@ -40,7 +40,7 @@ impl CharacterBehavior for Data { // Determine orientation vector from movement direction vector let ori_dir = Vec2::from(update.vel.0); - update.ori.0 = safe_slerp(update.ori.0, ori_dir.into(), 0.1); + update.ori.0 = Dir::slerp_to_vec3(update.ori.0, ori_dir.into(), 2.0 * data.dt.0); // Apply Glide antigrav lift if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index f2ca53ecf1..259ebe5c49 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,7 +1,7 @@ use crate::{ comp::{CharacterState, StateUpdate}, sys::character_behavior::{CharacterBehavior, JoinData}, - util::safe_slerp, + util::Dir, }; use std::time::Duration; use vek::Vec3; @@ -28,7 +28,7 @@ impl CharacterBehavior for Data { * ROLL_SPEED; // Smooth orientation - update.ori.0 = safe_slerp(update.ori.0, update.vel.0.into(), 9.0 * data.dt.0); + update.ori.0 = Dir::slerp_to_vec3(update.ori.0, update.vel.0, 9.0 * data.dt.0); if self.remaining_duration == Duration::default() { // Roll duration has expired diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index a3b994b985..d59869c20d 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -57,7 +57,7 @@ impl CharacterBehavior for Data { if !self.initialized { update.vel.0 = Vec3::zero(); if let Some(dir) = data.inputs.look_dir.try_normalized() { - update.ori.0 = dir; + update.ori.0 = dir.into(); } } let initialized = true; diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 043468c0ae..56bedf9728 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -3,7 +3,7 @@ use crate::{ event::LocalEvent, states::*, sys::{character_behavior::JoinData, phys::GRAVITY}, - util::safe_slerp, + util::Dir, }; use vek::vec::Vec2; @@ -68,13 +68,13 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, strength: f32) { // Set direction based on move direction let ori_dir = if update.character.is_attack() || update.character.is_block() { - Vec2::from(data.inputs.look_dir) + Vec2::from(*data.inputs.look_dir) } else { Vec2::from(data.inputs.move_dir) }; // Smooth orientation - update.ori.0 = safe_slerp(update.ori.0, ori_dir.into(), strength * data.dt.0); + update.ori.0 = Dir::slerp_to_vec3(update.ori.0, ori_dir.into(), strength * data.dt.0); } /// Updates components to move player as if theyre swimming diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index 750465c674..b11dcf22bb 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -1,9 +1,10 @@ use crate::{ - comp::{self, agent::Activity, Agent, Alignment, Controller, MountState, Pos, Stats}, + comp::{self, agent::Activity, Agent, Alignment, Controller, MountState, Ori, Pos, Stats}, path::Chaser, state::Time, sync::UidAllocator, terrain::TerrainGrid, + util::Dir, vol::ReadVol, }; use rand::{thread_rng, Rng}; @@ -21,6 +22,7 @@ impl<'a> System<'a> for Sys { Read<'a, Time>, Entities<'a>, ReadStorage<'a, Pos>, + ReadStorage<'a, Ori>, ReadStorage<'a, Stats>, ReadExpect<'a, TerrainGrid>, ReadStorage<'a, Alignment>, @@ -36,6 +38,7 @@ impl<'a> System<'a> for Sys { time, entities, positions, + orientations, stats, terrain, alignments, @@ -44,9 +47,10 @@ impl<'a> System<'a> for Sys { mount_states, ): Self::SystemData, ) { - for (entity, pos, alignment, agent, controller, mount_state) in ( + for (entity, pos, ori, alignment, agent, controller, mount_state) in ( &entities, &positions, + &orientations, alignments.maybe(), &mut agents, &mut controllers, @@ -70,9 +74,11 @@ impl<'a> System<'a> for Sys { controller.reset(); - //TODO: Make npcs have valid `look_dir` during all activities let mut inputs = &mut controller.inputs; + // Default to looking in orientation direction + inputs.look_dir = ori.0; + const AVG_FOLLOW_DIST: f32 = 6.0; const MAX_FOLLOW_DIST: f32 = 12.0; const MAX_CHASE_DIST: f32 = 24.0; @@ -162,7 +168,9 @@ impl<'a> System<'a> for Sys { .copied() .unwrap_or(Alignment::Owned(*target)), ) { - inputs.look_dir = tgt_pos.0 - pos.0; + if let Some(dir) = Dir::from_unnormalized(tgt_pos.0 - pos.0) { + inputs.look_dir = dir; + } // Don't attack entities we are passive towards // TODO: This is here, it's a bit of a hack diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index bf8abe1639..e8a7f207d2 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -4,6 +4,7 @@ use crate::{ }, event::{EventBus, LocalEvent, ServerEvent}, sync::Uid, + util::Dir, }; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; use vek::*; @@ -92,7 +93,7 @@ impl<'a> System<'a> for Sys { // 2D versions let pos2 = Vec2::from(pos.0); let pos_b2 = Vec2::::from(pos_b.0); - let ori2 = Vec2::from(ori.0); + let ori2 = Vec2::from(*ori.0); // Scales let scale = scale_maybe.map_or(1.0, |s| s.0); @@ -140,7 +141,7 @@ impl<'a> System<'a> for Sys { if attack.knockback != 0.0 { local_emitter.emit(LocalEvent::ApplyForce { entity: b, - dir: Vec3::slerp(ori.0, Vec3::new(0.0, 0.0, 1.0), 0.5), + dir: *Dir::slerp(ori.0, Dir::new(Vec3::new(0.0, 0.0, 1.0)), 0.5), force: attack.knockback, }); } diff --git a/common/src/sys/controller.rs b/common/src/sys/controller.rs index c92522b1b5..ceb49f9e9c 100644 --- a/common/src/sys/controller.rs +++ b/common/src/sys/controller.rs @@ -63,12 +63,6 @@ impl<'a> System<'a> for Sys { inputs.move_dir }; - // Update `inputs.look_dir` - inputs - .look_dir - .try_normalized() - .unwrap_or(inputs.move_dir.into()); - // Process other controller events for event in controller.events.drain(..) { match event { diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index bf0fc1064d..9841f1aaf9 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -5,6 +5,7 @@ use crate::{ event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, sync::UidAllocator, + util::Dir, }; use specs::{saveload::MarkerAllocator, Entities, Join, Read, ReadStorage, System, WriteStorage}; use std::time::Duration; @@ -107,7 +108,7 @@ impl<'a> System<'a> for Sys { { local_emitter.emit(LocalEvent::ApplyForce { entity, - dir: Vec3::slerp(ori.0, Vec3::new(0.0, 0.0, 1.0), 0.5), + dir: *Dir::slerp(ori.0, Dir::new(Vec3::unit_z()), 0.5), force: knockback, }); } @@ -145,7 +146,7 @@ impl<'a> System<'a> for Sys { .get(entity) .and_then(|vel| vel.0.try_normalized()) { - ori.0 = dir; + ori.0 = dir.into(); } } diff --git a/common/src/util/dir.rs b/common/src/util/dir.rs new file mode 100644 index 0000000000..4ea54d2bc7 --- /dev/null +++ b/common/src/util/dir.rs @@ -0,0 +1,186 @@ +use vek::*; + +/// Type representing a direction using Vec3 that is normalized and NaN free +/// These properties are enforced actively via panics when `debug_assertions` is +/// enabled +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(into = "SerdeDir")] +#[serde(from = "SerdeDir")] +pub struct Dir(Vec3); +impl Default for Dir { + fn default() -> Self { Self(Vec3::unit_y()) } +} + +// Validate at Deserialization +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +struct SerdeDir(Vec3); +impl From for Dir { + fn from(dir: SerdeDir) -> Self { + let dir = dir.0; + if dir.map(f32::is_nan).reduce_or() { + warn!("Deserialized dir containing NaNs, replacing with default"); + Default::default() + } else if !dir.is_normalized() { + warn!("Deserialized unnormalized dir, replacing with default"); + Default::default() + } else { + Self(dir) + } + } +} +impl Into for Dir { + fn into(self) -> SerdeDir { SerdeDir(*self) } +} +/*pub enum TryFromVec3Error { + ContainsNans, + NotNormalized, +} + +impl TryFrom> for Dir { + type Error = TryFromVec3Error; + + fn try_from(v: Vec3) -> Result { + if v.map(f32::is_nan).reduce_or() { + Err(TryFromVec3Error::ContainsNans) + } else { + v.try_normalized() + .map(|n| Self(n)) + .ok_or(TryFromVec3Error::NotNormalized) + } + } +}*/ + +impl Dir { + pub fn new(dir: Vec3) -> Self { + debug_assert!(!dir.map(f32::is_nan).reduce_or()); + debug_assert!(dir.is_normalized()); + Self(dir) + } + + pub fn from_unnormalized(dirs: Vec3) -> Option { + dirs.try_normalized().map(|dir| { + #[cfg(debug_assertions)] + { + if dir.map(f32::is_nan).reduce_or() { + panic!("{} => {}", dirs, dir); + } + } + Self(dir) + }) + } + + pub fn slerp(from: Self, to: Self, factor: f32) -> Self { + Self(slerp_normalized(from.0, to.0, factor)) + } + + /// Note: this uses `from` if `to` is unormalizable + pub fn slerp_to_vec3(from: Self, to: Vec3, factor: f32) -> Self { + Self(slerp_to_unnormalized(from.0, to, factor).unwrap_or_else(|e| e)) + } + + pub fn is_valid(&self) -> bool { !self.0.map(f32::is_nan).reduce_or() && self.is_normalized() } +} + +impl std::ops::Deref for Dir { + type Target = Vec3; + + fn deref(&self) -> &Vec3 { &self.0 } +} + +impl From> for Dir { + fn from(dir: Vec3) -> Self { Dir::new(dir.into()) } +} +/// Begone ye NaN's +/// Slerp two `Vec3`s skipping the slerp if their directions are very close +/// This avoids a case where `vek`s slerp produces NaN's +/// Additionally, it avoids unnecessary calculations if they are near identical +/// Assumes `from` and `to` are normalized and returns a normalized vector +#[inline(always)] +fn slerp_normalized(from: vek::Vec3, to: vek::Vec3, factor: f32) -> vek::Vec3 { + debug_assert!(!to.map(f32::is_nan).reduce_or()); + debug_assert!(!from.map(f32::is_nan).reduce_or()); + // Ensure from is normalized + #[cfg(debug_assertions)] + { + if { + let len_sq = from.magnitude_squared(); + len_sq < 0.999 || len_sq > 1.001 + } { + panic!("Called slerp_normalized with unnormalized from: {:?}", from); + } + } + // Ensure to is normalized + #[cfg(debug_assertions)] + { + if { + let len_sq = from.magnitude_squared(); + len_sq < 0.999 || len_sq > 1.001 + } { + panic!("Called slerp_normalized with unnormalized to: {:?}", to); + } + } + + let dot = from.dot(to); + if dot >= 1.0 - 1E-6 { + // Close together, just use to + return to; + } + + let (from, to, factor) = if dot < -0.999 { + // Not linearly independent (slerp will fail since it doesn't check for this) + // Instead we will choose a midpoint and slerp from or to that depending on the + // factor + let mid_dir = if from.z.abs() > 0.999 { + // If vec's lie along the z-axis default to (1, 0, 0) as midpoint + Vec3::unit_x() + } else { + // Default to picking midpoint in the xy plane + Vec3::new(from.y, -from.x, 0.0).normalized() + }; + + if factor > 0.5 { + (mid_dir, to, factor * 2.0 - 1.0) + } else { + (from, mid_dir, factor * 2.0) + } + } else { + (from, to, factor) + }; + + let slerped = Vec3::slerp(from, to, factor); + let slerped_normalized = slerped.normalized(); + // Ensure normalization worked + // This should not be possible but I will leave it here for now just in case + // something was missed + #[cfg(debug_assertions)] + { + if !slerped_normalized.is_normalized() || slerped_normalized.map(f32::is_nan).reduce_or() { + panic!( + "Failed to normalize {:?} produced from:\nslerp(\n {:?},\n {:?},\n \ + {:?},\n)\nWith result: {:?})", + slerped, from, to, factor, slerped_normalized + ); + } + } + + slerped_normalized +} + +/// Begone ye NaN's +/// Slerp two `Vec3`s skipping the slerp if their directions are very close +/// This avoids a case where `vek`s slerp produces NaN's +/// Additionally, it avoids unnecessary calculations if they are near identical +/// Assumes `from` is normalized and returns a normalized vector, but `to` +/// doesn't need to be normalized +/// Returns `Err(from)`` if `to` is unormalizable +// TODO: in some cases we might want to base the slerp rate on the magnitude of +// `to` for example when `to` is velocity and `from` is orientation +fn slerp_to_unnormalized( + from: Vec3, + to: Vec3, + factor: f32, +) -> Result, Vec3> { + to.try_normalized() + .map(|to| slerp_normalized(from, to, factor)) + .ok_or(from) +} diff --git a/common/src/util/mod.rs b/common/src/util/mod.rs index bb4d1be981..ff0d99e80b 100644 --- a/common/src/util/mod.rs +++ b/common/src/util/mod.rs @@ -1,4 +1,5 @@ mod color; +mod dir; pub const GIT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/githash")); @@ -8,84 +9,4 @@ lazy_static::lazy_static! { } pub use color::*; - -/// Begone ye NaN's -/// Slerp two `Vec3`s skipping the slerp if their directions are very close -/// This avoids a case where `vek`s slerp produces NaN's -/// Additionally, it avoids unnecessary calculations if they are near identical -/// Assumes `from` is normalized and returns a normalized vector, but `to` -/// doesn't need to be normalized -// TODO: in some cases we might want to base the slerp rate on the magnitude of -// `to` for example when `to` is velocity and `from` is orientation -#[inline(always)] -pub fn safe_slerp(from: vek::Vec3, to: vek::Vec3, factor: f32) -> vek::Vec3 { - use vek::Vec3; - - debug_assert!(!to.map(f32::is_nan).reduce_or()); - debug_assert!(!from.map(f32::is_nan).reduce_or()); - // Ensure from is normalized - #[cfg(debug_assertions)] - { - if { - let len_sq = from.magnitude_squared(); - len_sq < 0.999 || len_sq > 1.001 - } { - panic!("Called safe_slerp with unnormalized from: {:?}", from); - } - } - - let to = if to.magnitude_squared() > 0.001 { - to.normalized() - } else { - return from; - }; - - let dot = from.dot(to); - if dot >= 1.0 - 1E-6 { - // Close together, just use to - return to; - } - - let (from, to, factor) = if dot < -0.999 { - // Not linearly independent (slerp will fail since it doesn't check for this) - // Instead we will choose a midpoint and slerp from or to that depending on the - // factor - let mid_dir = if from.z > 0.999 { - // If vec's lie along the z-axis default to (1, 0, 0) as midpoint - Vec3::unit_x() - } else { - // Default to picking midpoint in the xy plane - Vec3::new(from.y, -from.x, 0.0).normalized() - }; - - if factor > 0.5 { - (mid_dir, to, factor * 2.0 - 1.0) - } else { - (from, mid_dir, factor * 2.0) - } - } else { - (from, to, factor) - }; - - let slerped = Vec3::slerp(from, to, factor); - let slerped_normalized = slerped.normalized(); - // Ensure normalization worked - // This should not be possible but I will leave it here for now just in case - // something was missed - #[cfg(debug_assertions)] - { - if { - let len_sq = slerped_normalized.magnitude_squared(); - len_sq < 0.999 || len_sq > 1.001 - } || slerped_normalized.map(f32::is_nan).reduce_or() - { - panic!( - "Failed to normalize {:?} produced from:\nslerp(\n {:?},\n {:?},\n \ - {:?},\n)\nWith result: {:?})", - slerped, from, to, factor, slerped_normalized - ); - } - } - - slerped_normalized -} +pub use dir::*; diff --git a/server/src/cmd.rs b/server/src/cmd.rs index d8e0ac61fa..b9a107d4d8 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -12,6 +12,7 @@ use common::{ state::TimeOfDay, sync::{Uid, WorldSyncExt}, terrain::TerrainChunkSize, + util::Dir, vol::RectVolSize, }; use rand::Rng; @@ -711,15 +712,14 @@ fn handle_object(server: &mut Server, entity: EcsEntity, args: String, _action: .with(comp::Ori( // converts player orientation into a 90° rotation for the object by using the axis // with the highest value - ori.0 - .map(|e| { - if e.abs() == ori.0.map(|e| e.abs()).reduce_partial_max() { - e - } else { - 0.0 - } - }) - .normalized(), + Dir::from_unnormalized(ori.0.map(|e| { + if e.abs() == ori.0.map(|e| e.abs()).reduce_partial_max() { + e + } else { + 0.0 + } + })) + .unwrap_or_default(), )) .build(); server.notify_client( diff --git a/server/src/events/entity_creation.rs b/server/src/events/entity_creation.rs index 68ad0e345c..77987794ab 100644 --- a/server/src/events/entity_creation.rs +++ b/server/src/events/entity_creation.rs @@ -1,7 +1,10 @@ use crate::{sys, Server, StateExt}; -use common::comp::{ - self, Agent, Alignment, Body, Gravity, LightEmitter, Loadout, Pos, Projectile, Scale, Stats, - Vel, WaypointArea, +use common::{ + comp::{ + self, Agent, Alignment, Body, Gravity, LightEmitter, Loadout, Pos, Projectile, Scale, + Stats, Vel, WaypointArea, + }, + util::Dir, }; use specs::{Builder, Entity as EcsEntity, WorldExt}; use vek::{Rgb, Vec3}; @@ -42,7 +45,7 @@ pub fn handle_create_npc( pub fn handle_shoot( server: &mut Server, entity: EcsEntity, - dir: Vec3, + dir: Dir, body: Body, light: Option, projectile: Projectile, @@ -60,7 +63,7 @@ pub fn handle_shoot( // TODO: Player height pos.z += 1.2; - let mut builder = state.create_projectile(Pos(pos), Vel(dir * 100.0), body, projectile); + let mut builder = state.create_projectile(Pos(pos), Vel(*dir * 100.0), body, projectile); if let Some(light) = light { builder = builder.with(light) } diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index 82f7fa4ebd..3b6819af17 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -256,7 +256,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv .read_storage::() .get(entity) .copied() - .unwrap_or(comp::Ori(Vec3::unit_y())), + .unwrap_or_default(), item, )); } @@ -269,7 +269,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv // Drop items for (pos, ori, item) in dropped_items { - let vel = ori.0.normalized() * 5.0 + let vel = *ori.0 * 5.0 + Vec3::unit_z() * 10.0 + Vec3::::zero().map(|_| rand::thread_rng().gen::() - 0.5) * 4.0; diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index f2be33961b..43a47f1f75 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -5,6 +5,7 @@ use common::{ msg::{ClientState, ServerMsg}, state::State, sync::{Uid, WorldSyncExt}, + util::Dir, }; use log::warn; use specs::{Builder, Entity as EcsEntity, EntityBuilder as EcsEntityBuilder, Join, WorldExt}; @@ -89,7 +90,7 @@ impl StateExt for State { .create_entity_synced() .with(pos) .with(comp::Vel(Vec3::zero())) - .with(comp::Ori(Vec3::unit_y())) + .with(comp::Ori::default()) .with(comp::Controller::default()) .with(body) .with(stats) @@ -106,7 +107,7 @@ impl StateExt for State { .create_entity_synced() .with(pos) .with(comp::Vel(Vec3::zero())) - .with(comp::Ori(Vec3::unit_y())) + .with(comp::Ori::default()) .with(comp::Body::Object(object)) .with(comp::Mass(100.0)) .with(comp::Gravity(1.0)) @@ -125,7 +126,7 @@ impl StateExt for State { .create_entity_synced() .with(pos) .with(vel) - .with(comp::Ori(vel.0.normalized())) + .with(comp::Ori(Dir::from_unnormalized(vel.0).unwrap_or_default())) .with(comp::Mass(0.0)) .with(body) .with(projectile) @@ -151,7 +152,7 @@ impl StateExt for State { self.write_component(entity, comp::Controller::default()); self.write_component(entity, comp::Pos(spawn_point)); self.write_component(entity, comp::Vel(Vec3::zero())); - self.write_component(entity, comp::Ori(Vec3::unit_y())); + self.write_component(entity, comp::Ori::default()); self.write_component(entity, comp::Gravity(1.0)); self.write_component(entity, comp::CharacterState::default()); self.write_component(entity, comp::Alignment::Owned(entity)); diff --git a/voxygen/src/audio/sfx/mod.rs b/voxygen/src/audio/sfx/mod.rs index 86771e86c2..ef40c85663 100644 --- a/voxygen/src/audio/sfx/mod.rs +++ b/voxygen/src/audio/sfx/mod.rs @@ -70,10 +70,12 @@ impl SfxMgr { .get(player_entity) .map_or(Vec3::zero(), |pos| pos.0); - let player_ori = ecs + let player_ori = *ecs .read_storage::() .get(player_entity) - .map_or(Vec3::zero(), |pos| pos.0); + .copied() + .unwrap_or_default() + .0; audio.set_listener_pos(&player_position, &player_ori); diff --git a/voxygen/src/ecs/comp.rs b/voxygen/src/ecs/comp.rs index 492b8543a9..8d051f0588 100644 --- a/voxygen/src/ecs/comp.rs +++ b/voxygen/src/ecs/comp.rs @@ -1,3 +1,4 @@ +use common::util::Dir; use specs::Component; use specs_idvs::IDVStorage; use vek::*; @@ -32,7 +33,7 @@ impl Component for HpFloaterList { #[derive(Copy, Clone, Debug)] pub struct Interpolated { pub pos: Vec3, - pub ori: Vec3, + pub ori: Dir, } impl Component for Interpolated { type Storage = IDVStorage; diff --git a/voxygen/src/ecs/sys/interpolation.rs b/voxygen/src/ecs/sys/interpolation.rs index 3d71af2601..dccfdddb95 100644 --- a/voxygen/src/ecs/sys/interpolation.rs +++ b/voxygen/src/ecs/sys/interpolation.rs @@ -2,7 +2,7 @@ use crate::ecs::comp::Interpolated; use common::{ comp::{Ori, Pos, Vel}, state::DeltaTime, - util::safe_slerp, + util::Dir, }; use log::warn; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; @@ -30,7 +30,7 @@ impl<'a> System<'a> for Sys { // Update interpolation values if i.pos.distance_squared(pos.0) < 64.0 * 64.0 { i.pos = Lerp::lerp(i.pos, pos.0 + vel.0 * 0.03, 10.0 * dt.0); - i.ori = safe_slerp(i.ori, ori.0, 5.0 * dt.0); + i.ori = Dir::slerp(i.ori, ori.0, 5.0 * dt.0); } else { i.pos = pos.0; i.ori = ori.0; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 4120c2da22..5e1efdc87f 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -142,8 +142,8 @@ impl FigureMgr { .join() { let (pos, ori) = interpolated - .map(|i| (Pos(i.pos), Ori(i.ori))) - .unwrap_or((*pos, Ori(Vec3::unit_y()))); + .map(|i| (Pos(i.pos), *i.ori)) + .unwrap_or((*pos, Vec3::unit_y())); // Don't process figures outside the vd let vd_frac = Vec2::from(pos.0 - player_pos) @@ -439,7 +439,7 @@ impl FigureMgr { // Running (true, true, _) => anim::character::RunAnimation::update_skeleton( &CharacterSkeleton::new(), - (active_tool_kind, vel.0, ori.0, state.last_ori, time), + (active_tool_kind, vel.0, ori, state.last_ori, time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -455,7 +455,7 @@ impl FigureMgr { // Swim (false, _, true) => anim::character::SwimAnimation::update_skeleton( &CharacterSkeleton::new(), - (active_tool_kind, vel.0, ori.0.magnitude(), time), + (active_tool_kind, vel.0, ori.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -465,7 +465,7 @@ impl FigureMgr { CharacterState::Roll { .. } => { anim::character::RollAnimation::update_skeleton( &target_base, - (active_tool_kind, ori.0, state.last_ori, time), + (active_tool_kind, ori, state.last_ori, time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -592,7 +592,7 @@ impl FigureMgr { CharacterState::Glide { .. } => { anim::character::GlidingAnimation::update_skeleton( &target_base, - (active_tool_kind, vel.0, ori.0, state.last_ori, time), + (active_tool_kind, vel.0, ori, state.last_ori, time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -601,7 +601,7 @@ impl FigureMgr { CharacterState::Climb { .. } => { anim::character::ClimbAnimation::update_skeleton( &CharacterSkeleton::new(), - (active_tool_kind, vel.0, ori.0, time), + (active_tool_kind, vel.0, ori, time), state.state_time, &mut state_animation_rate, skeleton_attr, @@ -623,7 +623,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, @@ -703,7 +703,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, @@ -785,7 +785,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, @@ -859,7 +859,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, @@ -933,7 +933,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, @@ -1007,7 +1007,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, @@ -1081,7 +1081,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, @@ -1155,7 +1155,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, @@ -1229,7 +1229,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, @@ -1303,7 +1303,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, @@ -1322,7 +1322,7 @@ impl FigureMgr { state.update( renderer, pos.0, - ori.0, + ori, scale, col, dt, diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index e674ddd2b5..289f92ef34 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -17,6 +17,7 @@ use common::{ comp::{Pos, Vel, MAX_PICKUP_RANGE_SQR}, msg::ClientState, terrain::{Block, BlockKind}, + util::Dir, vol::ReadVol, ChatType, }; @@ -446,7 +447,7 @@ impl PlayState for SessionState { if !free_look { ori = self.scene.camera().get_orientation(); - self.inputs.look_dir = cam_dir; + self.inputs.look_dir = Dir::from_unnormalized(cam_dir).unwrap(); } // Calculate the movement input vector of the player from the current key // presses and the camera direction. From ce0f54e9d646e834155a0caed9082e10fb89c93d Mon Sep 17 00:00:00 2001 From: Imbris Date: Fri, 27 Mar 2020 22:19:23 -0400 Subject: [PATCH 288/326] Combine dir and force in KnockUp and ApplyForce events --- common/src/event.rs | 16 ++++------------ common/src/state.rs | 10 ++++++---- common/src/sys/combat.rs | 4 ++-- common/src/sys/projectile.rs | 4 ++-- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/common/src/event.rs b/common/src/event.rs index 809c607802..1575f31283 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -47,19 +47,11 @@ pub enum SfxEvent { pub enum LocalEvent { /// Applies upward force to entity's `Vel` Jump(EcsEntity), - /// Applies the `force` + implicit upward force, in `dir` direction to + /// Applies the `force` + implicit upward force to /// `entity`'s `Vel` - KnockUp { - entity: EcsEntity, - dir: Vec3, - force: f32, - }, - /// Applies the `force`, in `dir` direction to `entity`'s `Vel` - ApplyForce { - entity: EcsEntity, - dir: Vec3, - force: f32, - }, + KnockUp { entity: EcsEntity, force: Vec3 }, + /// Applies the `force` to `entity`'s `Vel` + ApplyForce { entity: EcsEntity, force: Vec3 }, /// Applies leaping force to `entity`'s `Vel` away from `wall_dir` direction WallLeap { entity: EcsEntity, diff --git a/common/src/state.rs b/common/src/state.rs index 4efc494917..91374f1a2f 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -355,15 +355,17 @@ impl State { vel.0.z = HUMANOID_JUMP_ACCEL; } }, - LocalEvent::KnockUp { entity, dir, force } => { + LocalEvent::KnockUp { entity, force } => { if let Some(vel) = velocities.get_mut(entity) { - vel.0 = dir * force; + vel.0 = force; vel.0.z = HUMANOID_JUMP_ACCEL; } }, - LocalEvent::ApplyForce { entity, dir, force } => { + LocalEvent::ApplyForce { entity, force } => { + // TODO: this sets the velocity directly to the value of `force`, consider + // renaming the event or changing the behavior if let Some(vel) = velocities.get_mut(entity) { - vel.0 = dir * force; + vel.0 = force; } }, LocalEvent::WallLeap { entity, wall_dir } => { diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index e8a7f207d2..5d7bbc69c0 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -141,8 +141,8 @@ impl<'a> System<'a> for Sys { if attack.knockback != 0.0 { local_emitter.emit(LocalEvent::ApplyForce { entity: b, - dir: *Dir::slerp(ori.0, Dir::new(Vec3::new(0.0, 0.0, 1.0)), 0.5), - force: attack.knockback, + force: attack.knockback + * *Dir::slerp(ori.0, Dir::new(Vec3::new(0.0, 0.0, 1.0)), 0.5), }); } attack.hit_count += 1; diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index 9841f1aaf9..0174f4299f 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -108,8 +108,8 @@ impl<'a> System<'a> for Sys { { local_emitter.emit(LocalEvent::ApplyForce { entity, - dir: *Dir::slerp(ori.0, Dir::new(Vec3::unit_z()), 0.5), - force: knockback, + force: knockback + * *Dir::slerp(ori.0, Dir::new(Vec3::unit_z()), 0.5), }); } }, From 49ba1966711b64c193b8b7c6e53c3a6db5bc2236 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Fri, 27 Mar 2020 23:59:05 -0400 Subject: [PATCH 289/326] proper bow animation --- voxygen/src/anim/character/beta.rs | 1 + voxygen/src/anim/character/charge.rs | 180 +++++++++++++++++---------- voxygen/src/anim/character/dash.rs | 130 +++++++++++++++++++ voxygen/src/anim/character/mod.rs | 8 +- voxygen/src/anim/character/shoot.rs | 84 ++++++------- voxygen/src/anim/character/spin.rs | 1 + voxygen/src/scene/figure/mod.rs | 30 +++-- 7 files changed, 311 insertions(+), 123 deletions(-) create mode 100644 voxygen/src/anim/character/dash.rs diff --git a/voxygen/src/anim/character/beta.rs b/voxygen/src/anim/character/beta.rs index 8161ba32a8..a06a876332 100644 --- a/voxygen/src/anim/character/beta.rs +++ b/voxygen/src/anim/character/beta.rs @@ -40,6 +40,7 @@ impl Animation for BetaAnimation { match active_tool_kind { //TODO: Inventory Some(ToolKind::Axe(_)) | Some(ToolKind::Hammer(_)) | Some(ToolKind::Sword(_)) => { + //INTENTION: SWORD next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward, diff --git a/voxygen/src/anim/character/charge.rs b/voxygen/src/anim/character/charge.rs index c5d489bdf9..522513860f 100644 --- a/voxygen/src/anim/character/charge.rs +++ b/voxygen/src/anim/character/charge.rs @@ -2,100 +2,151 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use common::comp::item::ToolKind; use vek::*; -pub struct Input { - pub attack: bool, -} pub struct ChargeAnimation; impl Animation for ChargeAnimation { - type Dependency = (Option, f64); + type Dependency = (Option, f32, f64); type Skeleton = CharacterSkeleton; fn update_skeleton( skeleton: &Self::Skeleton, - (active_tool_kind, _global_time): Self::Dependency, + (active_tool_kind, velocity, _global_time): Self::Dependency, anim_time: f64, rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { *rate = 1.0; + let mut next = (*skeleton).clone(); - let constant = 8.0; + let lab = 1.0; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 25.0).sin()).powf(2.0 as f32))) + / (0.2 + 4.8 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 25.0).sin()); + * ((anim_time as f32 * lab as f32 * 8.0).sin()); + let foote = (((5.0) + / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 8.0 + 1.57).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 8.0).sin()); + let stress = (((5.0) + / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 10.0).cos()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 20.0).cos()); + let quick = (((5.0) + / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 2.0).cos()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 2.0).cos()); - let slow = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 12.4).sin()); + let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2); - let wave_cos = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 2.4).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * constant as f32 * 1.5).sin()); + next.head.offset = Vec3::new( + 0.0 + stop * -2.0 + skeleton_attr.neck_right, + -2.0 + stop * 2.5 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 14.0, + ); + next.head.ori = Quaternion::rotation_z(stop * -1.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(stop * -0.3); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(stop * 1.2 + stress * stop * 0.02) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_z(stop * -0.5); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(stop * -0.7); + next.shorts.scale = Vec3::one(); match active_tool_kind { //TODO: Inventory - Some(ToolKind::Sword(_)) => { - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 12.0, - ); - next.head.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 2.0); - next.chest.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.7); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, 1.0, -1.0); - next.belt.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.2); - next.belt.scale = Vec3::one(); - - next.shorts.offset = Vec3::new(0.0, 3.0, -3.0); - next.shorts.ori = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3); - next.shorts.scale = Vec3::one(); - - next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.04; - next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); - next.r_hand.ori = Quaternion::rotation_x(1.27); + Some(ToolKind::Staff(_)) => { + next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); + next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(1.8) + * Quaternion::rotation_y(0.5) + * Quaternion::rotation_z(-0.27); next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.offset = Vec3::new(11.0, 9.0, 10.0); next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); + * Quaternion::rotation_y(3.14 + 0.3) + * Quaternion::rotation_z(0.9); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0); - next.control.ori = Quaternion::rotation_x(-0.3) + next.control.offset = Vec3::new(-7.0, 6.0, 6.0 - quick * 5.0); + next.control.ori = Quaternion::rotation_x(quick * 1.3) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(1.1 + slow * 0.2); + * Quaternion::rotation_z(quick * 1.5); next.control.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-1.4, foot * 3.0 + 2.0, 8.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8); - next.l_foot.scale = Vec3::one(); + }, + Some(ToolKind::Bow(_)) => { + next.l_hand.offset = Vec3::new(1.0, -4.0 + stop * -1.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(3.0, -1.0, -5.0); + next.r_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(3.0, 2.0, -13.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.3) + * Quaternion::rotation_z(-0.6); + next.main.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 1.0, 8.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 0.4 - 0.8); - next.r_foot.scale = Vec3::one(); + next.control.offset = Vec3::new(-9.0 + stop * 13.0, 6.0 + stop * 4.0, 8.0); + next.control.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(stop * -0.5) + * Quaternion::rotation_z(stop * -0.9); + next.control.scale = Vec3::one(); }, _ => {}, } - next.head.offset = Vec3::new( - 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 12.0, - ); - next.head.ori = Quaternion::rotation_x(0.5); + if velocity > 0.5 { + next.l_foot.offset = Vec3::new(-3.4 - foot * 1.5, foote * 2.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foote * -0.1) + * Quaternion::rotation_z(0.4) + * Quaternion::rotation_y(0.15); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4 + foot * 1.5, foote * -1.5, 8.0); + next.r_foot.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_z(0.4) + * Quaternion::rotation_y(0.0); + next.r_foot.scale = Vec3::one(); + next.torso.offset = + Vec3::new(0.0 + foot * 0.03, foote * 0.05, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + } else { + next.l_foot.offset = Vec3::new(-3.4, -2.5 + stop * -1.3, 8.0); + next.l_foot.ori = Quaternion::rotation_x(stop * -0.2 - 0.2 + stop * stress * 0.02) + * Quaternion::rotation_z(stop * 0.1) + * Quaternion::rotation_y(stop * 0.08); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(3.4, 3.5 + stop * 1.5, 8.0); + next.r_foot.ori = + Quaternion::rotation_x(stop * 0.1) * Quaternion::rotation_z(stop * 0.1); + next.r_foot.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + } next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); next.l_shoulder.ori = Quaternion::rotation_x(0.0); @@ -113,11 +164,6 @@ impl Animation for ChargeAnimation { next.lantern.ori = Quaternion::rotation_x(0.0); next.lantern.scale = Vec3::one() * 0.0; - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); next.l_control.ori = Quaternion::rotation_x(0.0); next.l_control.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/dash.rs b/voxygen/src/anim/character/dash.rs new file mode 100644 index 0000000000..4840b3e3e2 --- /dev/null +++ b/voxygen/src/anim/character/dash.rs @@ -0,0 +1,130 @@ +use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; +use common::comp::item::ToolKind; +use vek::*; + +pub struct Input { + pub attack: bool, +} +pub struct DashAnimation; + +impl Animation for DashAnimation { + type Dependency = (Option, f64); + type Skeleton = CharacterSkeleton; + + fn update_skeleton( + skeleton: &Self::Skeleton, + (active_tool_kind, _global_time): Self::Dependency, + anim_time: f64, + rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + *rate = 1.0; + let mut next = (*skeleton).clone(); + let constant = 8.0; + let lab = 1.0; + + let foot = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 25.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 25.0).sin()); + + let slow = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 12.4).sin()); + + let wave_cos = (((5.0) + / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 2.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * constant as f32 * 1.5).sin()); + + match active_tool_kind { + //TODO: Inventory + Some(ToolKind::Sword(_)) => { + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 12.0, + ); + next.head.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 2.0); + next.chest.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.7); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, 1.0, -1.0); + next.belt.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.2); + next.belt.scale = Vec3::one(); + + next.shorts.offset = Vec3::new(0.0, 3.0, -3.0); + next.shorts.ori = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3); + next.shorts.scale = Vec3::one(); + + next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + + next.control.offset = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0); + next.control.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(1.1 + slow * 0.2); + next.control.scale = Vec3::one(); + next.l_foot.offset = Vec3::new(-1.4, foot * 3.0 + 2.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 1.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(foot * 0.4 - 0.8); + next.r_foot.scale = Vec3::one(); + }, + _ => {}, + } + next.head.offset = Vec3::new( + 0.0 + skeleton_attr.neck_right, + -2.0 + skeleton_attr.neck_forward, + skeleton_attr.neck_height + 12.0, + ); + next.head.ori = Quaternion::rotation_x(0.5); + + next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.1; + + next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.1; + + next.glider.offset = Vec3::new(0.0, 5.0, 0.0); + next.glider.ori = Quaternion::rotation_y(0.0); + next.glider.scale = Vec3::one() * 0.0; + + next.lantern.offset = Vec3::new(0.0, 0.0, 0.0); + next.lantern.ori = Quaternion::rotation_x(0.0); + next.lantern.scale = Vec3::one() * 0.0; + + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = + Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.l_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_control.ori = Quaternion::rotation_x(0.0); + next.l_control.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_control.ori = Quaternion::rotation_x(0.0); + next.r_control.scale = Vec3::one(); + next + } +} diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index c506aafc88..26cf805191 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -4,6 +4,7 @@ pub mod block; pub mod blockidle; pub mod charge; pub mod climb; +pub mod dash; pub mod equip; pub mod gliding; pub mod idle; @@ -21,9 +22,10 @@ pub mod wield; pub use self::{ alpha::AlphaAnimation, beta::BetaAnimation, block::BlockAnimation, blockidle::BlockIdleAnimation, charge::ChargeAnimation, climb::ClimbAnimation, - equip::EquipAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, - roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, - spin::SpinAnimation, stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation, + dash::DashAnimation, equip::EquipAnimation, gliding::GlidingAnimation, idle::IdleAnimation, + jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, + sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation, swim::SwimAnimation, + wield::WieldAnimation, }; use super::{Bone, Skeleton}; diff --git a/voxygen/src/anim/character/shoot.rs b/voxygen/src/anim/character/shoot.rs index 8cd71eb4be..07ed08bcfe 100644 --- a/voxygen/src/anim/character/shoot.rs +++ b/voxygen/src/anim/character/shoot.rs @@ -22,41 +22,38 @@ impl Animation for ShootAnimation { let lab = 1.0; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 15.0).sin()).powf(2.0 as f32))) + / (0.2 + 4.8 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 15.0).sin()); + * ((anim_time as f32 * lab as f32 * 8.0).sin()); + let foote = (((5.0) + / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 8.0 + 1.57).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 8.0).sin()); - let quick = (((5.0) - / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 2.0).cos()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 2.0).cos()); - let sloweralt = (((5.0) - / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).cos()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 4.0).cos()); + let exp = ((anim_time as f32).powf(0.3 as f32)).min(1.2); next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, - -2.0 + skeleton_attr.neck_forward - quick * 1.5, + -2.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 14.0, ); - next.head.ori = Quaternion::rotation_z(quick * 0.15) - * Quaternion::rotation_x(quick * 0.09) - * Quaternion::rotation_y(0.0); + next.head.ori = Quaternion::rotation_z(exp * -0.4) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(exp * 0.1); next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new(0.0, 0.0 - quick * 1.5, 7.0); - next.chest.ori = Quaternion::rotation_z(quick * 0.35) - * Quaternion::rotation_x(quick * 0.09) - * Quaternion::rotation_y(0.0); + next.chest.offset = Vec3::new(0.0, 0.0 - exp * 1.5, 7.0); + next.chest.ori = Quaternion::rotation_z(0.4 + exp * 1.0) + * Quaternion::rotation_x(0.0 + exp * 0.2) + * Quaternion::rotation_y(exp * -0.08); next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0 + quick * 1.0, -2.0); - next.belt.ori = next.chest.ori; + next.belt.offset = Vec3::new(0.0, 0.0 + exp * 1.0, -2.0); + next.belt.ori = next.chest.ori * -0.1; next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, quick * 1.0, -5.0); - next.shorts.ori = next.chest.ori; + next.shorts.offset = Vec3::new(0.0, exp * 1.0, -5.0); + next.shorts.ori = next.chest.ori * -0.08; next.shorts.scale = Vec3::one(); match active_tool_kind { @@ -76,21 +73,17 @@ impl Animation for ShootAnimation { * Quaternion::rotation_z(0.9); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-7.0, 6.0, 6.0 - quick * 5.0); - next.control.ori = Quaternion::rotation_x(quick * 1.3) + next.control.offset = Vec3::new(-7.0, 6.0, 6.0 - exp * 5.0); + next.control.ori = Quaternion::rotation_x(exp * 1.3) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(quick * 1.5); + * Quaternion::rotation_z(exp * 1.5); next.control.scale = Vec3::one(); }, Some(ToolKind::Bow(_)) => { - next.l_hand.offset = Vec3::new( - 1.0 - sloweralt * 2.0, - -4.0 - sloweralt * 7.0, - -1.0 + sloweralt * 6.0, - ); + next.l_hand.offset = Vec3::new(1.0 - exp * 2.0, -4.0 - exp * 7.0, -1.0 + exp * 6.0); next.l_hand.ori = Quaternion::rotation_x(1.20) - * Quaternion::rotation_y(-0.6 + sloweralt * 0.8) - * Quaternion::rotation_z(-0.3 + sloweralt * 0.9); + * Quaternion::rotation_y(-0.6 + exp * 0.8) + * Quaternion::rotation_z(-0.3 + exp * 0.9); next.l_hand.scale = Vec3::one() * 1.05; next.r_hand.offset = Vec3::new(3.0, -1.0, -5.0); next.r_hand.ori = Quaternion::rotation_x(1.20) @@ -104,7 +97,7 @@ impl Animation for ShootAnimation { next.main.scale = Vec3::one(); next.control.offset = Vec3::new(-9.0, 6.0, 8.0); - next.control.ori = Quaternion::rotation_x((sloweralt * 0.4).max(0.4)) + next.control.ori = Quaternion::rotation_x(exp * 0.4) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.control.scale = Vec3::one(); @@ -112,12 +105,18 @@ impl Animation for ShootAnimation { _ => {}, } if velocity > 0.5 { - next.l_foot.offset = Vec3::new(-3.4, foot * -2.0, 8.0); - next.l_foot.ori = Quaternion::rotation_x(foot * -0.4); + next.l_foot.offset = + Vec3::new(-3.4 - foot * 1.0 + exp * -1.0, foote * 0.8 + exp * 1.5, 8.0); + next.l_foot.ori = Quaternion::rotation_x(exp * 0.5) + * Quaternion::rotation_z(exp * 0.4) + * Quaternion::rotation_y(0.15); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, foot * 2.0, 8.0); - next.r_foot.ori = Quaternion::rotation_x(foot * 0.4); + next.r_foot.offset = + Vec3::new(3.4 + foot * 1.0 + exp * 1.0, foote * -0.8 + exp * -1.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(exp * -0.5) + * Quaternion::rotation_z(exp * 0.4) + * Quaternion::rotation_y(0.0); next.r_foot.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_z(0.0) @@ -125,14 +124,13 @@ impl Animation for ShootAnimation { * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; } else { - next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0 + (quick * 2.5).max(0.0)); - next.l_foot.ori = Quaternion::rotation_x(quick * -0.2 - 0.2) - * Quaternion::rotation_z((quick * 1.0).max(0.0)); + next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0 + exp * 2.5); + next.l_foot.ori = + Quaternion::rotation_x(exp * -0.2 - 0.2) * Quaternion::rotation_z(exp * 1.0); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, 3.5 - quick * 2.0, 8.0); - next.r_foot.ori = Quaternion::rotation_x(quick * 0.1) - * Quaternion::rotation_z((quick * 0.5).max(0.0)); + next.r_foot.offset = Vec3::new(3.4, 3.5 - exp * 2.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(exp * 0.1) * Quaternion::rotation_z(exp * 0.5); next.r_foot.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_z(0.0) diff --git a/voxygen/src/anim/character/spin.rs b/voxygen/src/anim/character/spin.rs index 44ad34c6e2..27d3391da9 100644 --- a/voxygen/src/anim/character/spin.rs +++ b/voxygen/src/anim/character/spin.rs @@ -37,6 +37,7 @@ impl Animation for SpinAnimation { match active_tool_kind { //TODO: Inventory Some(ToolKind::Axe(_)) | Some(ToolKind::Hammer(_)) | Some(ToolKind::Sword(_)) => { + //INTENTION: SWORD next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.scale = Vec3::one() * 1.04; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 4120c2da22..8affc42ba1 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -480,14 +480,24 @@ impl FigureMgr { skeleton_attr, ) }, - CharacterState::BasicRanged(_) => { - anim::character::ShootAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) + CharacterState::BasicRanged(data) => { + if data.exhausted { + anim::character::ShootAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } else { + anim::character::ChargeAnimation::update_skeleton( + &target_base, + (active_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } }, CharacterState::Boost(_) => { anim::character::AlphaAnimation::update_skeleton( @@ -499,7 +509,7 @@ impl FigureMgr { ) }, CharacterState::DashMelee(_) => { - anim::character::ChargeAnimation::update_skeleton( + anim::character::DashAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.state_time, @@ -544,7 +554,7 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ), - _ => anim::character::ChargeAnimation::update_skeleton( + _ => anim::character::DashAnimation::update_skeleton( &target_base, (active_tool_kind, time), state.state_time, From f551c4a2c5cba9631e5cf7750908a8e61e71557f Mon Sep 17 00:00:00 2001 From: Imbris Date: Sat, 28 Mar 2020 01:51:52 -0400 Subject: [PATCH 290/326] Move armor types to a new location, use a const for the moving cutoff in voxygen anims --- common/src/comp/ability.rs | 3 +- common/src/comp/body/humanoid.rs | 174 ------------- common/src/comp/inventory/item/armor.rs | 186 ++++++++++++++ common/src/comp/inventory/item/mod.rs | 176 ++++++++++++++ .../comp/inventory/{item.rs => item/tool.rs} | 230 ++---------------- common/src/comp/inventory/mod.rs | 4 +- common/src/comp/mod.rs | 3 +- common/src/states/utils.rs | 11 +- server/src/events/interaction.rs | 5 +- server/src/events/inventory_manip.rs | 12 +- server/src/state_ext.rs | 5 +- server/src/sys/terrain.rs | 4 +- voxygen/src/anim/mod.rs | 2 +- voxygen/src/hud/bag.rs | 2 +- voxygen/src/hud/item_imgs.rs | 8 +- voxygen/src/hud/skillbar.rs | 29 ++- voxygen/src/scene/figure/cache.rs | 5 +- voxygen/src/scene/figure/load.rs | 13 +- voxygen/src/scene/figure/mod.rs | 45 ++-- 19 files changed, 472 insertions(+), 445 deletions(-) create mode 100644 common/src/comp/inventory/item/armor.rs create mode 100644 common/src/comp/inventory/item/mod.rs rename common/src/comp/inventory/{item.rs => item/tool.rs} (57%) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 4f3cdda038..eb98cf0227 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -1,6 +1,7 @@ use crate::{ comp::{ - Body, CharacterState, EnergySource, Gravity, Item, LightEmitter, Projectile, StateUpdate, + item::Item, Body, CharacterState, EnergySource, Gravity, LightEmitter, Projectile, + StateUpdate, }, states::*, sys::character_behavior::JoinData, diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index d271a19985..f68b323a5a 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -471,180 +471,6 @@ pub enum BodyType { } pub const ALL_BODY_TYPES: [BodyType; 2] = [BodyType::Female, BodyType::Male]; -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[repr(u32)] -pub enum Chest { - None = 0, - Blue = 1, - Brown = 2, - Dark = 3, - Green = 4, - Orange = 5, - Midnight = 6, - Kimono = 7, - Assassin = 8, - PlateGreen0 = 9, - Leather0 = 10, - ClothPurple0 = 11, - ClothBlue0 = 12, - ClothGreen0 = 13, -} -pub const ALL_CHESTS: [Chest; 14] = [ - Chest::None, - Chest::Blue, - Chest::Brown, - Chest::Dark, - Chest::Green, - Chest::Orange, - Chest::Midnight, - Chest::Kimono, - Chest::Assassin, - Chest::PlateGreen0, - Chest::Leather0, - Chest::ClothPurple0, - Chest::ClothBlue0, - Chest::ClothGreen0, -]; - -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[repr(u32)] -pub enum Belt { - None = 0, - Dark = 1, - TurqCloth = 2, - BloodCloth = 3, - BlackCloth = 4, - Assassin = 5, - Plate0 = 6, - Leather0 = 7, - ClothPurple0 = 8, - ClothBlue0 = 9, - ClothGreen0 = 10, -} -pub const ALL_BELTS: [Belt; 11] = [ - Belt::None, - Belt::Dark, - Belt::TurqCloth, - Belt::BloodCloth, - Belt::BlackCloth, - Belt::Assassin, - Belt::Plate0, - Belt::Leather0, - Belt::ClothPurple0, - Belt::ClothBlue0, - Belt::ClothGreen0, -]; - -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[repr(u32)] -pub enum Pants { - None = 0, - Blue = 1, - Brown = 2, - Dark = 3, - Green = 4, - Orange = 5, - Kimono = 6, - Assassin = 7, - PlateGreen0 = 8, - Leather0 = 9, - ClothPurple0 = 10, - ClothBlue0 = 11, - ClothGreen0 = 12, -} -pub const ALL_PANTS: [Pants; 13] = [ - Pants::None, - Pants::Blue, - Pants::Brown, - Pants::Dark, - Pants::Green, - Pants::Orange, - Pants::Kimono, - Pants::Assassin, - Pants::PlateGreen0, - Pants::Leather0, - Pants::ClothPurple0, - Pants::ClothBlue0, - Pants::ClothGreen0, -]; - -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[repr(u32)] -pub enum Hand { - Bare = 0, - Cloth = 1, - Assassin = 2, - Plate0 = 3, - Leather0 = 4, - ClothPurple0 = 5, - ClothBlue0 = 6, - ClothGreen0 = 7, -} -pub const ALL_HANDS: [Hand; 8] = [ - Hand::Bare, - Hand::Cloth, - Hand::Assassin, - Hand::Plate0, - Hand::Leather0, - Hand::ClothPurple0, - Hand::ClothBlue0, - Hand::ClothGreen0, -]; - -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[repr(u32)] -pub enum Foot { - Bare = 0, - Dark = 1, - Sandal = 2, - Jester = 3, - Assassin = 4, - Plate0 = 5, - Leather0 = 6, - ClothPurple0 = 7, - ClothBlue0 = 8, - ClothGreen0 = 9, -} -pub const ALL_FEET: [Foot; 10] = [ - Foot::Bare, - Foot::Dark, - Foot::Sandal, - Foot::Jester, - Foot::Assassin, - Foot::Plate0, - Foot::Leather0, - Foot::ClothPurple0, - Foot::ClothBlue0, - Foot::ClothGreen0, -]; - -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[repr(u32)] -pub enum Shoulder { - None = 0, - Brown1 = 1, - Chain = 2, - Assassin = 3, - Plate0 = 4, - Leather0 = 5, - Leather1 = 6, - ClothPurple0 = 7, - ClothBlue0 = 8, - ClothGreen0 = 9, -} -pub const ALL_SHOULDERS: [Shoulder; 10] = [ - Shoulder::None, - Shoulder::Brown1, - Shoulder::Chain, - Shoulder::Assassin, - Shoulder::Plate0, - Shoulder::Leather0, - Shoulder::Leather1, - Shoulder::ClothPurple0, - Shoulder::ClothBlue0, - Shoulder::ClothGreen0, -]; - #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Eyebrows { diff --git a/common/src/comp/inventory/item/armor.rs b/common/src/comp/inventory/item/armor.rs new file mode 100644 index 0000000000..aba5645d3c --- /dev/null +++ b/common/src/comp/inventory/item/armor.rs @@ -0,0 +1,186 @@ +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[repr(u32)] +pub enum Chest { + None = 0, + Blue = 1, + Brown = 2, + Dark = 3, + Green = 4, + Orange = 5, + Midnight = 6, + Kimono = 7, + Assassin = 8, + PlateGreen0 = 9, + Leather0 = 10, + ClothPurple0 = 11, + ClothBlue0 = 12, + ClothGreen0 = 13, +} +pub const ALL_CHESTS: [Chest; 14] = [ + Chest::None, + Chest::Blue, + Chest::Brown, + Chest::Dark, + Chest::Green, + Chest::Orange, + Chest::Midnight, + Chest::Kimono, + Chest::Assassin, + Chest::PlateGreen0, + Chest::Leather0, + Chest::ClothPurple0, + Chest::ClothBlue0, + Chest::ClothGreen0, +]; + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[repr(u32)] +pub enum Belt { + None = 0, + Dark = 1, + TurqCloth = 2, + BloodCloth = 3, + BlackCloth = 4, + Assassin = 5, + Plate0 = 6, + Leather0 = 7, + ClothPurple0 = 8, + ClothBlue0 = 9, + ClothGreen0 = 10, +} +pub const ALL_BELTS: [Belt; 11] = [ + Belt::None, + Belt::Dark, + Belt::TurqCloth, + Belt::BloodCloth, + Belt::BlackCloth, + Belt::Assassin, + Belt::Plate0, + Belt::Leather0, + Belt::ClothPurple0, + Belt::ClothBlue0, + Belt::ClothGreen0, +]; + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[repr(u32)] +pub enum Pants { + None = 0, + Blue = 1, + Brown = 2, + Dark = 3, + Green = 4, + Orange = 5, + Kimono = 6, + Assassin = 7, + PlateGreen0 = 8, + Leather0 = 9, + ClothPurple0 = 10, + ClothBlue0 = 11, + ClothGreen0 = 12, +} +pub const ALL_PANTS: [Pants; 13] = [ + Pants::None, + Pants::Blue, + Pants::Brown, + Pants::Dark, + Pants::Green, + Pants::Orange, + Pants::Kimono, + Pants::Assassin, + Pants::PlateGreen0, + Pants::Leather0, + Pants::ClothPurple0, + Pants::ClothBlue0, + Pants::ClothGreen0, +]; + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[repr(u32)] +pub enum Hand { + Bare = 0, + Cloth = 1, + Assassin = 2, + Plate0 = 3, + Leather0 = 4, + ClothPurple0 = 5, + ClothBlue0 = 6, + ClothGreen0 = 7, +} +pub const ALL_HANDS: [Hand; 8] = [ + Hand::Bare, + Hand::Cloth, + Hand::Assassin, + Hand::Plate0, + Hand::Leather0, + Hand::ClothPurple0, + Hand::ClothBlue0, + Hand::ClothGreen0, +]; + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[repr(u32)] +pub enum Foot { + Bare = 0, + Dark = 1, + Sandal = 2, + Jester = 3, + Assassin = 4, + Plate0 = 5, + Leather0 = 6, + ClothPurple0 = 7, + ClothBlue0 = 8, + ClothGreen0 = 9, +} +pub const ALL_FEET: [Foot; 10] = [ + Foot::Bare, + Foot::Dark, + Foot::Sandal, + Foot::Jester, + Foot::Assassin, + Foot::Plate0, + Foot::Leather0, + Foot::ClothPurple0, + Foot::ClothBlue0, + Foot::ClothGreen0, +]; + +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[repr(u32)] +pub enum Shoulder { + None = 0, + Brown1 = 1, + Chain = 2, + Assassin = 3, + Plate0 = 4, + Leather0 = 5, + Leather1 = 6, + ClothPurple0 = 7, + ClothBlue0 = 8, + ClothGreen0 = 9, +} +pub const ALL_SHOULDERS: [Shoulder; 10] = [ + Shoulder::None, + Shoulder::Brown1, + Shoulder::Chain, + Shoulder::Assassin, + Shoulder::Plate0, + Shoulder::Leather0, + Shoulder::Leather1, + Shoulder::ClothPurple0, + Shoulder::ClothBlue0, + Shoulder::ClothGreen0, +]; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum Armor { + Shoulder(Shoulder), + Chest(Chest), + Belt(Belt), + Hand(Hand), + Pants(Pants), + Foot(Foot), +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct Stats(pub u32); diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs new file mode 100644 index 0000000000..2fb685db2f --- /dev/null +++ b/common/src/comp/inventory/item/mod.rs @@ -0,0 +1,176 @@ +pub mod armor; +pub mod tool; + +// Reexports +pub use tool::{DebugKind, SwordKind, Tool, ToolKind}; + +use crate::{ + assets::{self, Asset}, + effect::Effect, + terrain::{Block, BlockKind}, +}; +use rand::seq::SliceRandom; +use specs::{Component, FlaggedStorage}; +use specs_idvs::IDVStorage; +use std::{fs::File, io::BufReader}; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum Consumable { + Apple, + Cheese, + Potion, + Mushroom, + Velorite, + VeloriteFrag, + PotionMinor, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum Utility { + Collar, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum Ingredient { + Flower, + Grass, +} + +fn default_amount() -> u32 { 1 } + +#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum ItemKind { + /// Something wieldable + Tool(tool::Tool), + Armor { + kind: armor::Armor, + stats: armor::Stats, + }, + Consumable { + kind: Consumable, + effect: Effect, + #[serde(default = "default_amount")] + amount: u32, + }, + Utility { + kind: Utility, + #[serde(default = "default_amount")] + amount: u32, + }, + Ingredient { + kind: Ingredient, + #[serde(default = "default_amount")] + amount: u32, + }, +} + +#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct Item { + name: String, + description: String, + pub kind: ItemKind, +} + +impl Asset for Item { + const ENDINGS: &'static [&'static str] = &["ron"]; + + fn parse(buf_reader: BufReader) -> Result { + Ok(ron::de::from_reader(buf_reader).unwrap()) + } +} + +impl Item { + pub fn empty() -> Self { + Self { + name: "Empty Item".to_owned(), + description: "This item may grant abilities, but is invisible".to_owned(), + kind: ItemKind::Tool(Tool::empty()), + } + } + + pub fn name(&self) -> &str { &self.name } + + pub fn description(&self) -> &str { &self.description } + + pub fn try_reclaim_from_block(block: Block) -> Option { + match block.kind() { + BlockKind::Apple => Some(assets::load_expect_cloned("common.items.apple")), + BlockKind::Mushroom => Some(assets::load_expect_cloned("common.items.mushroom")), + BlockKind::Velorite => Some(assets::load_expect_cloned("common.items.velorite")), + BlockKind::BlueFlower => Some(assets::load_expect_cloned("common.items.flowers.blue")), + BlockKind::PinkFlower => Some(assets::load_expect_cloned("common.items.flowers.pink")), + BlockKind::PurpleFlower => { + Some(assets::load_expect_cloned("common.items.flowers.purple")) + }, + BlockKind::RedFlower => Some(assets::load_expect_cloned("common.items.flowers.red")), + BlockKind::WhiteFlower => { + Some(assets::load_expect_cloned("common.items.flowers.white")) + }, + BlockKind::YellowFlower => { + Some(assets::load_expect_cloned("common.items.flowers.yellow")) + }, + BlockKind::Sunflower => Some(assets::load_expect_cloned("common.items.flowers.sun")), + BlockKind::LongGrass => Some(assets::load_expect_cloned("common.items.grasses.long")), + BlockKind::MediumGrass => { + Some(assets::load_expect_cloned("common.items.grasses.medium")) + }, + BlockKind::ShortGrass => Some(assets::load_expect_cloned("common.items.grasses.short")), + BlockKind::Chest => Some(assets::load_expect_cloned( + [ + "common.items.apple", + "common.items.velorite", + "common.items.veloritefrag", + "common.items.cheese", + "common.items.potion_minor", + "common.items.collar", + "common.items.weapons.starter_sword", + "common.items.weapons.starter_axe", + "common.items.weapons.staff_nature", + "common.items.weapons.starter_hammer", + "common.items.weapons.starter_bow", + "common.items.weapons.starter_staff", + "common.items.armor.belt.plate_0", + "common.items.armor.belt.leather_0", + "common.items.armor.chest.plate_green_0", + "common.items.armor.chest.leather_0", + "common.items.armor.foot.plate_0", + "common.items.armor.foot.leather_0", + "common.items.armor.pants.plate_green_0", + "common.items.armor.belt.leather_0", + "common.items.armor.shoulder.plate_0", + "common.items.armor.shoulder.leather_1", + "common.items.armor.shoulder.leather_0", + "common.items.armor.hand.leather_0", + "common.items.armor.hand.plate_0", + "common.items.weapons.wood_sword", + "common.items.weapons.short_sword_0", + "common.items.armor.belt.cloth_blue_0", + "common.items.armor.chest.cloth_blue_0", + "common.items.armor.foot.cloth_blue_0", + "common.items.armor.pants.cloth_blue_0", + "common.items.armor.shoulder.cloth_blue_0", + "common.items.armor.hand.cloth_blue_0", + "common.items.armor.belt.cloth_green_0", + "common.items.armor.chest.cloth_green_0", + "common.items.armor.foot.cloth_green_0", + "common.items.armor.pants.cloth_green_0", + "common.items.armor.shoulder.cloth_green_0", + "common.items.armor.hand.cloth_green_0", + "common.items.armor.belt.cloth_purple_0", + "common.items.armor.chest.cloth_purple_0", + "common.items.armor.foot.cloth_purple_0", + "common.items.armor.pants.cloth_purple_0", + "common.items.armor.shoulder.cloth_purple_0", + "common.items.armor.hand.cloth_purple_0", + ] + .choose(&mut rand::thread_rng()) + .unwrap(), // Can't fail + )), + _ => None, + } + } +} + +impl Component for Item { + type Storage = FlaggedStorage>; +} diff --git a/common/src/comp/inventory/item.rs b/common/src/comp/inventory/item/tool.rs similarity index 57% rename from common/src/comp/inventory/item.rs rename to common/src/comp/inventory/item/tool.rs index 1a5f7b2fe1..a440eb9ca7 100644 --- a/common/src/comp/inventory/item.rs +++ b/common/src/comp/inventory/item/tool.rs @@ -1,17 +1,8 @@ -use crate::{ - assets::{self, Asset}, - comp::{ - body::{humanoid, object}, - projectile, Body, CharacterAbility, Gravity, HealthChange, HealthSource, LightEmitter, - Projectile, - }, - effect::Effect, - terrain::{Block, BlockKind}, +use crate::comp::{ + body::object, projectile, Body, CharacterAbility, Gravity, HealthChange, HealthSource, + LightEmitter, Projectile, }; -use rand::seq::SliceRandom; -use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; -use std::{fs::File, io::BufReader, time::Duration}; +use std::time::Duration; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum SwordKind { @@ -47,6 +38,12 @@ pub enum ShieldKind { BasicShield, } +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum DebugKind { + Boost, + Possess, +} + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ToolKind { Sword(SwordKind), @@ -61,8 +58,22 @@ pub enum ToolKind { Empty, } -impl ToolData { - pub fn equip_time(&self) -> Duration { Duration::from_millis(self.equip_time_millis) } +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct Tool { + pub kind: ToolKind, + equip_time_millis: u32, + // TODO: item specific abilities +} + +impl Tool { + pub fn empty() -> Self { + Self { + kind: ToolKind::Empty, + equip_time_millis: 0, + } + } + + pub fn equip_time(&self) -> Duration { Duration::from_millis(self.equip_time_millis as u64) } pub fn get_abilities(&self) -> Vec { use CharacterAbility::*; @@ -254,192 +265,3 @@ impl ToolData { } } } - -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum DebugKind { - Boost, - Possess, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum Armor { - Shoulder(humanoid::Shoulder), - Chest(humanoid::Chest), - Belt(humanoid::Belt), - Hand(humanoid::Hand), - Pants(humanoid::Pants), - Foot(humanoid::Foot), -} - -pub type ArmorStats = u32; - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum Consumable { - Apple, - Cheese, - Potion, - Mushroom, - Velorite, - VeloriteFrag, - PotionMinor, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum Utility { - Collar, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum Ingredient { - Flower, - Grass, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub struct ToolData { - pub kind: ToolKind, - equip_time_millis: u64, - // TODO: item specific abilities -} - -fn default_amount() -> u32 { 1 } - -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum ItemKind { - /// Something wieldable - Tool(ToolData), - Armor { - kind: Armor, - stats: ArmorStats, - }, - Consumable { - kind: Consumable, - effect: Effect, - #[serde(default = "default_amount")] - amount: u32, - }, - Utility { - kind: Utility, - #[serde(default = "default_amount")] - amount: u32, - }, - Ingredient { - kind: Ingredient, - #[serde(default = "default_amount")] - amount: u32, - }, -} - -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub struct Item { - name: String, - description: String, - pub kind: ItemKind, -} - -impl Asset for Item { - const ENDINGS: &'static [&'static str] = &["ron"]; - - fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).unwrap()) - } -} - -impl Item { - pub fn empty() -> Self { - Self { - name: "Empty Item".to_owned(), - description: "This item may grant abilities, but is invisible".to_owned(), - kind: ItemKind::Tool(ToolData { - kind: ToolKind::Empty, - equip_time_millis: 0, - }), - } - } - - pub fn name(&self) -> &str { &self.name } - - pub fn description(&self) -> &str { &self.description } - - pub fn try_reclaim_from_block(block: Block) -> Option { - match block.kind() { - BlockKind::Apple => Some(assets::load_expect_cloned("common.items.apple")), - BlockKind::Mushroom => Some(assets::load_expect_cloned("common.items.mushroom")), - BlockKind::Velorite => Some(assets::load_expect_cloned("common.items.velorite")), - BlockKind::BlueFlower => Some(assets::load_expect_cloned("common.items.flowers.blue")), - BlockKind::PinkFlower => Some(assets::load_expect_cloned("common.items.flowers.pink")), - BlockKind::PurpleFlower => { - Some(assets::load_expect_cloned("common.items.flowers.purple")) - }, - BlockKind::RedFlower => Some(assets::load_expect_cloned("common.items.flowers.red")), - BlockKind::WhiteFlower => { - Some(assets::load_expect_cloned("common.items.flowers.white")) - }, - BlockKind::YellowFlower => { - Some(assets::load_expect_cloned("common.items.flowers.yellow")) - }, - BlockKind::Sunflower => Some(assets::load_expect_cloned("common.items.flowers.sun")), - BlockKind::LongGrass => Some(assets::load_expect_cloned("common.items.grasses.long")), - BlockKind::MediumGrass => { - Some(assets::load_expect_cloned("common.items.grasses.medium")) - }, - BlockKind::ShortGrass => Some(assets::load_expect_cloned("common.items.grasses.short")), - BlockKind::Chest => Some(assets::load_expect_cloned( - [ - "common.items.apple", - "common.items.velorite", - "common.items.veloritefrag", - "common.items.cheese", - "common.items.potion_minor", - "common.items.collar", - "common.items.weapons.starter_sword", - "common.items.weapons.starter_axe", - "common.items.weapons.staff_nature", - "common.items.weapons.starter_hammer", - "common.items.weapons.starter_bow", - "common.items.weapons.starter_staff", - "common.items.armor.belt.plate_0", - "common.items.armor.belt.leather_0", - "common.items.armor.chest.plate_green_0", - "common.items.armor.chest.leather_0", - "common.items.armor.foot.plate_0", - "common.items.armor.foot.leather_0", - "common.items.armor.pants.plate_green_0", - "common.items.armor.belt.leather_0", - "common.items.armor.shoulder.plate_0", - "common.items.armor.shoulder.leather_1", - "common.items.armor.shoulder.leather_0", - "common.items.armor.hand.leather_0", - "common.items.armor.hand.plate_0", - "common.items.weapons.wood_sword", - "common.items.weapons.short_sword_0", - "common.items.armor.belt.cloth_blue_0", - "common.items.armor.chest.cloth_blue_0", - "common.items.armor.foot.cloth_blue_0", - "common.items.armor.pants.cloth_blue_0", - "common.items.armor.shoulder.cloth_blue_0", - "common.items.armor.hand.cloth_blue_0", - "common.items.armor.belt.cloth_green_0", - "common.items.armor.chest.cloth_green_0", - "common.items.armor.foot.cloth_green_0", - "common.items.armor.pants.cloth_green_0", - "common.items.armor.shoulder.cloth_green_0", - "common.items.armor.hand.cloth_green_0", - "common.items.armor.belt.cloth_purple_0", - "common.items.armor.chest.cloth_purple_0", - "common.items.armor.foot.cloth_purple_0", - "common.items.armor.pants.cloth_purple_0", - "common.items.armor.shoulder.cloth_purple_0", - "common.items.armor.hand.cloth_purple_0", - ] - .choose(&mut rand::thread_rng()) - .unwrap(), // Can't fail - )), - _ => None, - } - } -} - -impl Component for Item { - type Storage = FlaggedStorage>; -} diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 8090ea39ac..c5ee442e96 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -1,9 +1,7 @@ pub mod item; -// Reexports -pub use item::{Consumable, DebugKind, Item, ItemKind, SwordKind, ToolData, ToolKind}; - use crate::assets; +use item::{Consumable, Item, ItemKind}; use specs::{Component, FlaggedStorage, HashMapStorage}; use specs_idvs::IDVStorage; use std::ops::Not; diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 63ee953011..00079da365 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -31,8 +31,7 @@ pub use controller::{ pub use energy::{Energy, EnergySource}; pub use inputs::CanBuild; pub use inventory::{ - item, Inventory, InventoryUpdate, InventoryUpdateEvent, Item, ItemKind, SwordKind, ToolData, - ToolKind, MAX_PICKUP_RANGE_SQR, + item, item::Item, Inventory, InventoryUpdate, InventoryUpdateEvent, MAX_PICKUP_RANGE_SQR, }; pub use last::Last; pub use location::{Waypoint, WaypointArea}; diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 56bedf9728..6f44ab4273 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1,5 +1,8 @@ use crate::{ - comp::{CharacterState, ItemKind::Tool, StateUpdate, ToolData}, + comp::{ + item::{ItemKind, Tool}, + CharacterState, StateUpdate, + }, event::LocalEvent, states::*, sys::{character_behavior::JoinData, phys::GRAVITY}, @@ -108,7 +111,7 @@ pub fn handle_primary_wield(data: &JoinData, update: &mut StateUpdate) { /// If a tool is equipped, goes into Equipping state, otherwise goes to Idle pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) { - if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) { + if let Some(ItemKind::Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) { update.character = CharacterState::Equipping(equipping::Data { time_left: tool.equip_time(), }); @@ -237,8 +240,8 @@ pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) { } } -pub fn unwrap_tool_data<'a>(data: &'a JoinData) -> Option<&'a ToolData> { - if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) { +pub fn unwrap_tool_data<'a>(data: &'a JoinData) -> Option<&'a Tool> { + if let Some(ItemKind::Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) { Some(tool) } else { None diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index 95bd86430c..b46e3ffbd6 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -3,7 +3,8 @@ use crate::{ Server, }; use common::{ - assets, comp, + assets, + comp::{self, item}, msg::ServerMsg, sync::{Uid, WorldSyncExt}, }; @@ -85,7 +86,7 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) { .or_insert(comp::Loadout::default()); let item = assets::load_expect_cloned::("common.items.debug.possess"); - if let comp::ItemKind::Tool(tool) = item.kind { + if let item::ItemKind::Tool(tool) = item.kind { let mut abilities = tool.get_abilities(); let mut ability_drain = abilities.drain(..); loadout.active_item = Some(comp::ItemConfig { diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index 3b6819af17..f5929ec4f5 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -1,6 +1,6 @@ use crate::{Server, StateExt}; use common::{ - comp::{self, Pos, MAX_PICKUP_RANGE_SQR}, + comp::{self, item, Pos, MAX_PICKUP_RANGE_SQR}, sync::WorldSyncExt, terrain::block::Block, vol::{ReadVol, Vox}, @@ -94,7 +94,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv if let Some(item) = item_opt { match &item.kind { - comp::ItemKind::Tool(tool) => { + item::ItemKind::Tool(tool) => { if let Some(loadout) = state.ecs().write_storage::().get_mut(entity) { @@ -121,16 +121,16 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv } }, - comp::ItemKind::Consumable { kind, effect, .. } => { + item::ItemKind::Consumable { kind, effect, .. } => { event = comp::InventoryUpdateEvent::Consumed(*kind); state.apply_effect(entity, *effect); }, - comp::ItemKind::Armor { kind, .. } => { + item::ItemKind::Armor { kind, .. } => { if let Some(loadout) = state.ecs().write_storage::().get_mut(entity) { - use comp::item::Armor::*; + use comp::item::armor::Armor::*; let slot = match kind.clone() { Shoulder(_) => &mut loadout.shoulder, Chest(_) => &mut loadout.chest, @@ -153,7 +153,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv } }, - comp::ItemKind::Utility { kind, .. } => match kind { + item::ItemKind::Utility { kind, .. } => match kind { comp::item::Utility::Collar => { let reinsert = if let Some(pos) = state.read_storage::().get(entity) diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index 43a47f1f75..458339b690 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -1,6 +1,7 @@ use crate::{client::Client, settings::ServerSettings, sys::sentinel::DeletedEntities, SpawnPoint}; use common::{ - assets, comp, + assets, + comp::{self, item}, effect::Effect, msg::{ClientState, ServerMsg}, state::State, @@ -164,7 +165,7 @@ impl StateExt for State { self.write_component( entity, - if let Some(comp::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) { + if let Some(item::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) { let mut abilities = tool.get_abilities(); let mut ability_drain = abilities.drain(..); comp::Loadout { diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 83500188a5..dbc6bcd513 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -2,7 +2,7 @@ use super::SysTimer; use crate::{chunk_generator::ChunkGenerator, client::Client, Tick}; use common::{ assets, - comp::{self, CharacterAbility, Item, ItemConfig, Player, Pos}, + comp::{self, item, CharacterAbility, Item, ItemConfig, Player, Pos}, event::{EventBus, ServerEvent}, generation::EntityKind, msg::ServerMsg, @@ -190,7 +190,7 @@ impl<'a> System<'a> for Sys { let mut stats = comp::Stats::new(name, body); let active_item = - if let Some(comp::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) { + if let Some(item::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) { let mut abilities = tool.get_abilities(); let mut ability_drain = abilities.drain(..); diff --git a/voxygen/src/anim/mod.rs b/voxygen/src/anim/mod.rs index bfe6b38b5d..13eaff91f1 100644 --- a/voxygen/src/anim/mod.rs +++ b/voxygen/src/anim/mod.rs @@ -12,7 +12,7 @@ pub mod quadruped_medium; pub mod quadruped_small; use crate::render::FigureBoneData; -use common::comp::{self, ToolKind}; +use common::comp::{self, item::tool::ToolKind}; use vek::*; #[derive(Copy, Clone, Debug)] diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 204d0f0873..8bb4a2a7d8 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -9,7 +9,7 @@ use crate::{ ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, }; use client::Client; -use common::comp::{ItemKind, Stats}; +use common::comp::{item::ItemKind, Stats}; use conrod_core::{ color, image, widget::{self, Button, Image, Rectangle, Text}, diff --git a/voxygen/src/hud/item_imgs.rs b/voxygen/src/hud/item_imgs.rs index 3344633615..816d5fd2aa 100644 --- a/voxygen/src/hud/item_imgs.rs +++ b/voxygen/src/hud/item_imgs.rs @@ -1,7 +1,11 @@ use crate::ui::{Graphic, SampleStrat, Transform, Ui}; use common::{ assets::{self, watch::ReloadIndicator, Asset}, - comp::item::{Armor, Consumable, Ingredient, Item, ItemKind, ToolData, ToolKind, Utility}, + comp::item::{ + armor::Armor, + tool::{Tool, ToolKind}, + Consumable, Ingredient, Item, ItemKind, Utility, + }, }; use conrod_core::image::Id; use dot_vox::DotVoxData; @@ -24,7 +28,7 @@ pub enum ItemKey { impl From<&Item> for ItemKey { fn from(item: &Item) -> Self { match &item.kind { - ItemKind::Tool(ToolData { kind, .. }) => ItemKey::Tool(kind.clone()), + ItemKind::Tool(Tool { kind, .. }) => ItemKey::Tool(kind.clone()), ItemKind::Armor { kind, .. } => ItemKey::Armor(kind.clone()), ItemKind::Utility { kind, .. } => ItemKey::Utility(kind.clone()), ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()), diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 68da07b996..2c1f3136dd 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -10,8 +10,11 @@ use crate::{ use common::{ assets::load_expect, comp::{ - item::{DebugKind, StaffKind, ToolData, ToolKind}, - CharacterState, ControllerInputs, Energy, ItemKind, Loadout, Stats, + item::{ + tool::{DebugKind, StaffKind, Tool, ToolKind}, + ItemKind, + }, + CharacterState, ControllerInputs, Energy, Loadout, Stats, }, }; use conrod_core::{ @@ -590,7 +593,7 @@ impl<'a> Widget for Skillbar<'a> { .w_h(38.0 * scale, 38.0 * scale) .color( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Bow(_) => Some(BG_COLOR_2), ToolKind::Staff(_) => Some(BG_COLOR_2), _ => Some(BG_COLOR_2), @@ -602,7 +605,7 @@ impl<'a> Widget for Skillbar<'a> { .set(state.ids.m1_slot_bg, ui); Button::image( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Sword(_) => self.imgs.twohsword_m1, ToolKind::Hammer(_) => self.imgs.twohhammer_m1, ToolKind::Axe(_) => self.imgs.twohaxe_m1, @@ -616,7 +619,7 @@ impl<'a> Widget for Skillbar<'a> { ) // Insert Icon here .w( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Bow(_) => 30.0 * scale, ToolKind::Staff(_) => 32.0 * scale, _ => 38.0 * scale, @@ -626,7 +629,7 @@ impl<'a> Widget for Skillbar<'a> { ) .h( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Bow(_) => 30.0 * scale, ToolKind::Staff(_) => 32.0 * scale, _ => 38.0 * scale, @@ -691,7 +694,7 @@ impl<'a> Widget for Skillbar<'a> { .w_h(38.0 * scale, 38.0 * scale) .color( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Bow(_) => Some(BG_COLOR_2), ToolKind::Staff(_) => Some(BG_COLOR_2), _ => Some(BG_COLOR_2), @@ -703,7 +706,7 @@ impl<'a> Widget for Skillbar<'a> { .set(state.ids.m2_slot_bg, ui); Button::image( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Sword(_) => self.imgs.charge, ToolKind::Hammer(_) => self.imgs.nothing, ToolKind::Axe(_) => self.imgs.nothing, @@ -718,7 +721,7 @@ impl<'a> Widget for Skillbar<'a> { ) // Insert Icon here .w( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Staff(_) => 30.0 * scale, _ => 38.0 * scale, }, @@ -727,7 +730,7 @@ impl<'a> Widget for Skillbar<'a> { ) .h( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Staff(_) => 30.0 * scale, _ => 38.0 * scale, }, @@ -737,7 +740,7 @@ impl<'a> Widget for Skillbar<'a> { .middle_of(state.ids.m2_slot_bg) .image_color( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Sword(_) => { if self.energy.current() as f64 >= 200.0 { Color::Rgba(1.0, 1.0, 1.0, 1.0) @@ -832,7 +835,7 @@ impl<'a> Widget for Skillbar<'a> { .w_h(19.5 * scale, 19.5 * scale) .color( match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Staff(StaffKind::BasicStaff) => Some(BLACK), _ => Some(BG_COLOR), }, @@ -843,7 +846,7 @@ impl<'a> Widget for Skillbar<'a> { .set(state.ids.slot1_bg, ui); // TODO: Changeable slot image match self.loadout.active_item.as_ref().map(|i| &i.item.kind) { - Some(ItemKind::Tool(ToolData { kind, .. })) => match kind { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { ToolKind::Staff(StaffKind::BasicStaff) => { Image::new(self.imgs.fire_spell_1) .w_h(18.0 * scale, 18.0 * scale) diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 85becab458..26961df98c 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -6,7 +6,10 @@ use crate::{ }; use common::{ assets::watch::ReloadIndicator, - comp::{Body, CharacterState, Item, ItemKind, Loadout, ToolKind}, + comp::{ + item::{tool::ToolKind, ItemKind}, + Body, CharacterState, Item, Loadout, + }, }; use hashbrown::{hash_map::Entry, HashMap}; use std::{ diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index b9ea7bc49e..f2a948c4b1 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -10,15 +10,16 @@ use common::{ bird_small, critter::{BodyType as CBodyType, Species as CSpecies}, dragon, fish_medium, fish_small, - humanoid::{ - Belt, Body, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder, - Skin, + humanoid::{Body, BodyType, EyeColor, Eyebrows, Race, Skin}, + item::{ + armor::{Armor, Belt, Chest, Foot, Hand, Pants, Shoulder}, + tool::{Tool, ToolKind}, + ItemKind, }, - item::{Armor, ToolData, ToolKind}, object, quadruped_medium::{BodyType as QMBodyType, Species as QMSpecies}, quadruped_small::{BodyType as QSBodyType, Species as QSSpecies}, - ItemKind, Loadout, + Loadout, }, figure::{DynaUnionizer, MatSegment, Material, Segment}, }; @@ -609,7 +610,7 @@ impl HumMainWeaponSpec { } pub fn mesh_main_weapon(&self, item_kind: Option<&ItemKind>) -> Mesh { - let tool_kind = if let Some(ItemKind::Tool(ToolData { kind, .. })) = item_kind { + let tool_kind = if let Some(ItemKind::Tool(Tool { kind, .. })) = item_kind { kind } else { return Mesh::new(); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index e5fc6cbd6f..e77402be01 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -21,7 +21,8 @@ use crate::{ }; use common::{ comp::{ - Body, CharacterState, ItemKind, Last, Loadout, Ori, PhysicsState, Pos, Scale, Stats, Vel, + item::ItemKind, Body, CharacterState, Last, Loadout, Ori, PhysicsState, Pos, Scale, Stats, + Vel, }, state::State, states::triple_strike, @@ -35,6 +36,8 @@ use treeculler::{BVol, BoundingSphere}; use vek::*; const DAMAGE_FADE_COEFFICIENT: f64 = 5.0; +const MOVING_THRESHOLD: f32 = 0.7; +const MOVING_THRESHOLD_SQR: f32 = MOVING_THRESHOLD * MOVING_THRESHOLD; pub struct FigureMgr { model_cache: FigureModelCache, @@ -425,8 +428,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.5, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, _) => anim::character::StandAnimation::update_skeleton( @@ -673,8 +676,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.5, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => { @@ -753,8 +756,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.5, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => { @@ -833,8 +836,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.5, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::bird_medium::IdleAnimation::update_skeleton( @@ -907,8 +910,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.5, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::fish_medium::IdleAnimation::update_skeleton( @@ -981,8 +984,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.5, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::dragon::IdleAnimation::update_skeleton( @@ -1055,8 +1058,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.5, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::critter::IdleAnimation::update_skeleton( @@ -1129,8 +1132,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.5, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::bird_small::IdleAnimation::update_skeleton( @@ -1203,8 +1206,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.5, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::fish_small::IdleAnimation::update_skeleton( @@ -1277,8 +1280,8 @@ impl FigureMgr { let target_base = match ( physics.on_ground, - vel.0.magnitude_squared() > 0.5, // Moving - physics.in_fluid, // In water + vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving + physics.in_fluid, // In water ) { // Standing (true, false, false) => anim::biped_large::IdleAnimation::update_skeleton( From d3b5b1e637ae8c46b4b4677bfc41ac0002d1067f Mon Sep 17 00:00:00 2001 From: Imbris Date: Sat, 28 Mar 2020 03:51:24 -0400 Subject: [PATCH 291/326] Remove None variant fromm armor types --- assets/common/items/armor/belt/assassin.ron | 2 +- .../common/items/armor/belt/cloth_blue_0.ron | 2 +- .../common/items/armor/belt/cloth_green_0.ron | 2 +- .../items/armor/belt/cloth_purple_0.ron | 2 +- assets/common/items/armor/belt/leather_0.ron | 2 +- assets/common/items/armor/belt/plate_0.ron | 4 +- assets/common/items/armor/chest/assassin.ron | 2 +- .../common/items/armor/chest/cloth_blue_0.ron | 2 +- .../items/armor/chest/cloth_green_0.ron | 2 +- .../items/armor/chest/cloth_purple_0.ron | 2 +- assets/common/items/armor/chest/leather_0.ron | 2 +- .../items/armor/chest/plate_green_0.ron | 2 +- assets/common/items/armor/foot/assassin.ron | 2 +- .../common/items/armor/foot/cloth_blue_0.ron | 2 +- .../common/items/armor/foot/cloth_green_0.ron | 2 +- .../items/armor/foot/cloth_purple_0.ron | 2 +- assets/common/items/armor/foot/leather_0.ron | 2 +- assets/common/items/armor/foot/plate_0.ron | 2 +- assets/common/items/armor/hand/assassin.ron | 2 +- .../common/items/armor/hand/cloth_blue_0.ron | 4 +- .../common/items/armor/hand/cloth_green_0.ron | 2 +- .../items/armor/hand/cloth_purple_0.ron | 2 +- assets/common/items/armor/hand/leather_0.ron | 2 +- assets/common/items/armor/hand/plate_0.ron | 2 +- assets/common/items/armor/pants/assassin.ron | 2 +- .../common/items/armor/pants/cloth_blue_0.ron | 2 +- .../items/armor/pants/cloth_green_0.ron | 2 +- .../items/armor/pants/cloth_purple_0.ron | 2 +- assets/common/items/armor/pants/green_0.ron | 2 +- assets/common/items/armor/pants/leather_0.ron | 2 +- .../items/armor/pants/plate_green_0.ron | 2 +- .../common/items/armor/shoulder/assassin.ron | 2 +- .../items/armor/shoulder/cloth_blue_0.ron | 2 +- .../items/armor/shoulder/cloth_green_0.ron | 2 +- .../items/armor/shoulder/cloth_purple_0.ron | 2 +- .../common/items/armor/shoulder/leather_0.ron | 2 +- .../common/items/armor/shoulder/leather_1.ron | 2 +- .../common/items/armor/shoulder/plate_0.ron | 2 +- assets/common/items/weapons/hammer_1.ron | 2 +- assets/common/items/weapons/shield_1.ron | 2 +- assets/common/items/weapons/short_sword_0.ron | 2 +- assets/common/items/weapons/staff_1.ron | 2 +- assets/common/items/weapons/staff_nature.ron | 2 +- assets/common/items/weapons/starter_axe.ron | 2 +- assets/common/items/weapons/starter_bow.ron | 2 +- .../common/items/weapons/starter_dagger.ron | 2 +- .../common/items/weapons/starter_hammer.ron | 2 +- assets/common/items/weapons/starter_staff.ron | 2 +- assets/common/items/weapons/starter_sword.ron | 2 +- assets/common/items/weapons/wood_sword.ron | 2 +- .../items/weapons/zweihander_sword_0.ron | 2 +- .../voxel/humanoid_armor_belt_manifest.ron | 97 ++++----- .../voxel/humanoid_armor_chest_manifest.ron | 113 +++++------ .../voxel/humanoid_armor_foot_manifest.ron | 80 ++++---- .../voxel/humanoid_armor_hand_manifest.ron | 134 +++++++------ .../voxel/humanoid_armor_pants_manifest.ron | 104 +++++----- .../humanoid_armor_shoulder_manifest.ron | 188 +++++++++--------- common/src/comp/inventory/item/armor.rs | 16 +- voxygen/src/scene/figure/load.rs | 141 +++++++------ 59 files changed, 488 insertions(+), 491 deletions(-) diff --git a/assets/common/items/armor/belt/assassin.ron b/assets/common/items/armor/belt/assassin.ron index c365499f9b..e6bb45044e 100644 --- a/assets/common/items/armor/belt/assassin.ron +++ b/assets/common/items/armor/belt/assassin.ron @@ -3,6 +3,6 @@ Item( description: "Only the best for a member of the creed.", kind: Armor( kind: Belt(Assassin), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/belt/cloth_blue_0.ron b/assets/common/items/armor/belt/cloth_blue_0.ron index 8daff395d4..8b62419ff7 100644 --- a/assets/common/items/armor/belt/cloth_blue_0.ron +++ b/assets/common/items/armor/belt/cloth_blue_0.ron @@ -3,6 +3,6 @@ Item( description: "Soft and warm", kind: Armor( kind: Belt(ClothBlue0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/belt/cloth_green_0.ron b/assets/common/items/armor/belt/cloth_green_0.ron index a43723aaf6..c3424f7817 100644 --- a/assets/common/items/armor/belt/cloth_green_0.ron +++ b/assets/common/items/armor/belt/cloth_green_0.ron @@ -3,6 +3,6 @@ Item( description: "Soft and warm", kind: Armor( kind: Belt(ClothGreen0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/belt/cloth_purple_0.ron b/assets/common/items/armor/belt/cloth_purple_0.ron index 71c81db88f..5f55a20c09 100644 --- a/assets/common/items/armor/belt/cloth_purple_0.ron +++ b/assets/common/items/armor/belt/cloth_purple_0.ron @@ -3,6 +3,6 @@ Item( description: "Soft and warm", kind: Armor( kind: Belt(ClothPurple0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/belt/leather_0.ron b/assets/common/items/armor/belt/leather_0.ron index 8aa2663bee..b3cf347584 100644 --- a/assets/common/items/armor/belt/leather_0.ron +++ b/assets/common/items/armor/belt/leather_0.ron @@ -3,6 +3,6 @@ Item( description: "Swift like the wind.", kind: Armor( kind: Belt(Leather0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/belt/plate_0.ron b/assets/common/items/armor/belt/plate_0.ron index 7246beb7a4..2c18113d1a 100644 --- a/assets/common/items/armor/belt/plate_0.ron +++ b/assets/common/items/armor/belt/plate_0.ron @@ -1,8 +1,8 @@ Item( name: "Iron Belt", - description: "WIP", + description: "WIP", kind: Armor( kind: Belt(Plate0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/chest/assassin.ron b/assets/common/items/armor/chest/assassin.ron index 9df179fb06..66fc865695 100644 --- a/assets/common/items/armor/chest/assassin.ron +++ b/assets/common/items/armor/chest/assassin.ron @@ -3,6 +3,6 @@ Item( description: "Only the best for a member of the creed.", kind: Armor( kind: Chest(Assassin), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/chest/cloth_blue_0.ron b/assets/common/items/armor/chest/cloth_blue_0.ron index 4a15fdf2dd..289bf4bdc5 100644 --- a/assets/common/items/armor/chest/cloth_blue_0.ron +++ b/assets/common/items/armor/chest/cloth_blue_0.ron @@ -3,6 +3,6 @@ Item( description: "Soft and warm", kind: Armor( kind: Chest(ClothBlue0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/chest/cloth_green_0.ron b/assets/common/items/armor/chest/cloth_green_0.ron index ab0c087a54..a52fc12a19 100644 --- a/assets/common/items/armor/chest/cloth_green_0.ron +++ b/assets/common/items/armor/chest/cloth_green_0.ron @@ -3,6 +3,6 @@ Item( description: "Soft and warm", kind: Armor( kind: Chest(ClothGreen0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/chest/cloth_purple_0.ron b/assets/common/items/armor/chest/cloth_purple_0.ron index 65b2c2b338..728e5f5c85 100644 --- a/assets/common/items/armor/chest/cloth_purple_0.ron +++ b/assets/common/items/armor/chest/cloth_purple_0.ron @@ -3,6 +3,6 @@ Item( description: "Soft and warm", kind: Armor( kind: Chest(ClothPurple0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/chest/leather_0.ron b/assets/common/items/armor/chest/leather_0.ron index f96d7a01ac..48408e3674 100644 --- a/assets/common/items/armor/chest/leather_0.ron +++ b/assets/common/items/armor/chest/leather_0.ron @@ -3,6 +3,6 @@ Item( description: "Swift like the wind.", kind: Armor( kind: Chest(Leather0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/chest/plate_green_0.ron b/assets/common/items/armor/chest/plate_green_0.ron index a4d9916e63..92bb5fb664 100644 --- a/assets/common/items/armor/chest/plate_green_0.ron +++ b/assets/common/items/armor/chest/plate_green_0.ron @@ -3,6 +3,6 @@ Item( description: "Arrows to the stomach are soooo last update.", kind: Armor( kind: Chest(PlateGreen0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/foot/assassin.ron b/assets/common/items/armor/foot/assassin.ron index 58c2d0d824..13b587a306 100644 --- a/assets/common/items/armor/foot/assassin.ron +++ b/assets/common/items/armor/foot/assassin.ron @@ -3,6 +3,6 @@ Item( description: "Only the best for a member of the creed.", kind: Armor( kind: Foot(Assassin), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/foot/cloth_blue_0.ron b/assets/common/items/armor/foot/cloth_blue_0.ron index 5db06d6094..31b70750f9 100644 --- a/assets/common/items/armor/foot/cloth_blue_0.ron +++ b/assets/common/items/armor/foot/cloth_blue_0.ron @@ -3,6 +3,6 @@ Item( description: "Soft and warm", kind: Armor( kind: Foot(ClothBlue0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/foot/cloth_green_0.ron b/assets/common/items/armor/foot/cloth_green_0.ron index 55c4f16a99..117b19aad9 100644 --- a/assets/common/items/armor/foot/cloth_green_0.ron +++ b/assets/common/items/armor/foot/cloth_green_0.ron @@ -3,6 +3,6 @@ Item( description: "Soft and warm", kind: Armor( kind: Foot(ClothGreen0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/foot/cloth_purple_0.ron b/assets/common/items/armor/foot/cloth_purple_0.ron index a94dbd78ae..a80c44de89 100644 --- a/assets/common/items/armor/foot/cloth_purple_0.ron +++ b/assets/common/items/armor/foot/cloth_purple_0.ron @@ -3,6 +3,6 @@ Item( description: "Soft and warm", kind: Armor( kind: Foot(ClothPurple0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/foot/leather_0.ron b/assets/common/items/armor/foot/leather_0.ron index 051aa7f6fc..6ca6a07fc7 100644 --- a/assets/common/items/armor/foot/leather_0.ron +++ b/assets/common/items/armor/foot/leather_0.ron @@ -3,6 +3,6 @@ Item( description: "Swift like the wind.", kind: Armor( kind: Foot(Leather0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/foot/plate_0.ron b/assets/common/items/armor/foot/plate_0.ron index f4f221147f..12f95dcd4e 100644 --- a/assets/common/items/armor/foot/plate_0.ron +++ b/assets/common/items/armor/foot/plate_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Foot(Plate0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/hand/assassin.ron b/assets/common/items/armor/hand/assassin.ron index 1f80cc4ebc..19a09a3177 100644 --- a/assets/common/items/armor/hand/assassin.ron +++ b/assets/common/items/armor/hand/assassin.ron @@ -3,6 +3,6 @@ Item( description: "Only the best for a member of the creed.", kind: Armor( kind: Hand(Assassin), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/hand/cloth_blue_0.ron b/assets/common/items/armor/hand/cloth_blue_0.ron index eb759506c4..88496cbce3 100644 --- a/assets/common/items/armor/hand/cloth_blue_0.ron +++ b/assets/common/items/armor/hand/cloth_blue_0.ron @@ -1,8 +1,8 @@ Item( name: "Blue Linen Wrists", - description: "WIP", + description: "WIP", kind: Armor( kind: Hand(ClothBlue0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/hand/cloth_green_0.ron b/assets/common/items/armor/hand/cloth_green_0.ron index 486e106b56..a3452335c4 100644 --- a/assets/common/items/armor/hand/cloth_green_0.ron +++ b/assets/common/items/armor/hand/cloth_green_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Hand(ClothGreen0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/hand/cloth_purple_0.ron b/assets/common/items/armor/hand/cloth_purple_0.ron index 57dbe378d0..840694163c 100644 --- a/assets/common/items/armor/hand/cloth_purple_0.ron +++ b/assets/common/items/armor/hand/cloth_purple_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Hand(ClothPurple0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/hand/leather_0.ron b/assets/common/items/armor/hand/leather_0.ron index 8efe8a59f2..e4b62e3a72 100644 --- a/assets/common/items/armor/hand/leather_0.ron +++ b/assets/common/items/armor/hand/leather_0.ron @@ -3,6 +3,6 @@ Item( description: "Swift like the wind.", kind: Armor( kind: Hand(Leather0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/hand/plate_0.ron b/assets/common/items/armor/hand/plate_0.ron index 8e27eee491..1fdbb6d6da 100644 --- a/assets/common/items/armor/hand/plate_0.ron +++ b/assets/common/items/armor/hand/plate_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Hand(Plate0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/pants/assassin.ron b/assets/common/items/armor/pants/assassin.ron index 0d71d8548f..b5bb2c28ab 100644 --- a/assets/common/items/armor/pants/assassin.ron +++ b/assets/common/items/armor/pants/assassin.ron @@ -3,6 +3,6 @@ Item( description: "Only the best for a member of the creed.", kind: Armor( kind: Pants(Assassin), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/pants/cloth_blue_0.ron b/assets/common/items/armor/pants/cloth_blue_0.ron index b8642e11d9..9ef245a09a 100644 --- a/assets/common/items/armor/pants/cloth_blue_0.ron +++ b/assets/common/items/armor/pants/cloth_blue_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Pants(ClothBlue0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/pants/cloth_green_0.ron b/assets/common/items/armor/pants/cloth_green_0.ron index bbb60b2220..3782ac2617 100644 --- a/assets/common/items/armor/pants/cloth_green_0.ron +++ b/assets/common/items/armor/pants/cloth_green_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Pants(ClothGreen0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/pants/cloth_purple_0.ron b/assets/common/items/armor/pants/cloth_purple_0.ron index d1b73cb4b0..770961a1fe 100644 --- a/assets/common/items/armor/pants/cloth_purple_0.ron +++ b/assets/common/items/armor/pants/cloth_purple_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Pants(ClothPurple0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/pants/green_0.ron b/assets/common/items/armor/pants/green_0.ron index 0ef1d3339c..5fee632d92 100644 --- a/assets/common/items/armor/pants/green_0.ron +++ b/assets/common/items/armor/pants/green_0.ron @@ -3,6 +3,6 @@ Item( description: "", kind: Armor( kind: Pants(Green), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/pants/leather_0.ron b/assets/common/items/armor/pants/leather_0.ron index 301505818b..507ab116c0 100644 --- a/assets/common/items/armor/pants/leather_0.ron +++ b/assets/common/items/armor/pants/leather_0.ron @@ -3,6 +3,6 @@ Item( description: "", kind: Armor( kind: Pants(Leather0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/pants/plate_green_0.ron b/assets/common/items/armor/pants/plate_green_0.ron index 131d87be51..51c3620338 100644 --- a/assets/common/items/armor/pants/plate_green_0.ron +++ b/assets/common/items/armor/pants/plate_green_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Pants(PlateGreen0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/shoulder/assassin.ron b/assets/common/items/armor/shoulder/assassin.ron index 819538cc5e..ea92efbec5 100644 --- a/assets/common/items/armor/shoulder/assassin.ron +++ b/assets/common/items/armor/shoulder/assassin.ron @@ -3,6 +3,6 @@ Item( description: "Only the best for a member of the creed.", kind: Armor( kind: Shoulder(Assassin), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/shoulder/cloth_blue_0.ron b/assets/common/items/armor/shoulder/cloth_blue_0.ron index 70bfcf1bb3..2ec65be894 100644 --- a/assets/common/items/armor/shoulder/cloth_blue_0.ron +++ b/assets/common/items/armor/shoulder/cloth_blue_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Shoulder(ClothBlue0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/shoulder/cloth_green_0.ron b/assets/common/items/armor/shoulder/cloth_green_0.ron index 79ff879ecc..539b3a7063 100644 --- a/assets/common/items/armor/shoulder/cloth_green_0.ron +++ b/assets/common/items/armor/shoulder/cloth_green_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Shoulder(ClothGreen0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/shoulder/cloth_purple_0.ron b/assets/common/items/armor/shoulder/cloth_purple_0.ron index 130a52c5ab..308759e2b8 100644 --- a/assets/common/items/armor/shoulder/cloth_purple_0.ron +++ b/assets/common/items/armor/shoulder/cloth_purple_0.ron @@ -3,6 +3,6 @@ Item( description: "WIP", kind: Armor( kind: Shoulder(ClothPurple0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/shoulder/leather_0.ron b/assets/common/items/armor/shoulder/leather_0.ron index 351beaff2a..a145debbeb 100644 --- a/assets/common/items/armor/shoulder/leather_0.ron +++ b/assets/common/items/armor/shoulder/leather_0.ron @@ -3,6 +3,6 @@ Item( description: "", kind: Armor( kind: Shoulder(Leather0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/shoulder/leather_1.ron b/assets/common/items/armor/shoulder/leather_1.ron index 990c15e135..ce066e63a0 100644 --- a/assets/common/items/armor/shoulder/leather_1.ron +++ b/assets/common/items/armor/shoulder/leather_1.ron @@ -3,6 +3,6 @@ Item( description: "Swift like the wind.", kind: Armor( kind: Shoulder(Leather1), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/armor/shoulder/plate_0.ron b/assets/common/items/armor/shoulder/plate_0.ron index 37bde3183d..3323278ecb 100644 --- a/assets/common/items/armor/shoulder/plate_0.ron +++ b/assets/common/items/armor/shoulder/plate_0.ron @@ -3,6 +3,6 @@ Item( description: "A strong shoulder to lean on.", kind: Armor( kind: Shoulder(Plate0), - stats: 20, + stats: (20), ), ) diff --git a/assets/common/items/weapons/hammer_1.ron b/assets/common/items/weapons/hammer_1.ron index 3907ed9aff..12573ab023 100644 --- a/assets/common/items/weapons/hammer_1.ron +++ b/assets/common/items/weapons/hammer_1.ron @@ -4,7 +4,7 @@ Item( \n Power: 20", kind: Tool( - ToolData ( + ( kind: Hammer(BasicHammer), equip_time_millis: 500, ) diff --git a/assets/common/items/weapons/shield_1.ron b/assets/common/items/weapons/shield_1.ron index 8ad6d4f71b..83a4157942 100644 --- a/assets/common/items/weapons/shield_1.ron +++ b/assets/common/items/weapons/shield_1.ron @@ -2,7 +2,7 @@ Item( name: "A Shield", description: "Legends tell this item is useless.", kind: Tool ( - ToolData ( + ( kind: Shield(BasicShield), equip_time_millis: 400, ) diff --git a/assets/common/items/weapons/short_sword_0.ron b/assets/common/items/weapons/short_sword_0.ron index 1c8c91d308..f6ac3ffa0e 100644 --- a/assets/common/items/weapons/short_sword_0.ron +++ b/assets/common/items/weapons/short_sword_0.ron @@ -3,7 +3,7 @@ Item( description: " Power: 15", kind: Tool( - ToolData ( + ( kind: Sword(Short0), equip_time_millis: 400, ) diff --git a/assets/common/items/weapons/staff_1.ron b/assets/common/items/weapons/staff_1.ron index 0287853a69..220497d481 100644 --- a/assets/common/items/weapons/staff_1.ron +++ b/assets/common/items/weapons/staff_1.ron @@ -4,7 +4,7 @@ Item( Power: 6", kind: Tool( - ToolData ( + ( kind: Staff(BasicStaff), equip_time_millis: 200, ) diff --git a/assets/common/items/weapons/staff_nature.ron b/assets/common/items/weapons/staff_nature.ron index b9065cad11..d4c76c6b3a 100644 --- a/assets/common/items/weapons/staff_nature.ron +++ b/assets/common/items/weapons/staff_nature.ron @@ -3,7 +3,7 @@ Item( description: " Infused by the power of Nature. Power: 25", kind: Tool( - ToolData ( + ( kind: Staff(Sceptre), equip_time_millis: 400, ) diff --git a/assets/common/items/weapons/starter_axe.ron b/assets/common/items/weapons/starter_axe.ron index 61d546fe80..9c82e4901f 100644 --- a/assets/common/items/weapons/starter_axe.ron +++ b/assets/common/items/weapons/starter_axe.ron @@ -4,7 +4,7 @@ Item( Power: 15", kind: Tool( - ToolData ( + ( kind: Axe(BasicAxe), equip_time_millis: 400, ) diff --git a/assets/common/items/weapons/starter_bow.ron b/assets/common/items/weapons/starter_bow.ron index 735de375fb..fb88134255 100644 --- a/assets/common/items/weapons/starter_bow.ron +++ b/assets/common/items/weapons/starter_bow.ron @@ -4,7 +4,7 @@ Item( Power: 15", kind: Tool( - ToolData ( + ( kind: Bow(BasicBow), equip_time_millis: 400, ) diff --git a/assets/common/items/weapons/starter_dagger.ron b/assets/common/items/weapons/starter_dagger.ron index 0a74a79c67..6be38613bd 100644 --- a/assets/common/items/weapons/starter_dagger.ron +++ b/assets/common/items/weapons/starter_dagger.ron @@ -4,7 +4,7 @@ Item( Power: 15", kind: Tool( - ToolData ( + ( kind: Dagger(BasicDagger), equip_time_millis: 300, ) diff --git a/assets/common/items/weapons/starter_hammer.ron b/assets/common/items/weapons/starter_hammer.ron index 9d7e38f115..feb59a5da1 100644 --- a/assets/common/items/weapons/starter_hammer.ron +++ b/assets/common/items/weapons/starter_hammer.ron @@ -4,7 +4,7 @@ Item( Power: 15", kind: Tool( - ToolData ( + ( kind: Hammer(BasicHammer), equip_time_millis: 500, ) diff --git a/assets/common/items/weapons/starter_staff.ron b/assets/common/items/weapons/starter_staff.ron index ae6de21968..9f19fe2000 100644 --- a/assets/common/items/weapons/starter_staff.ron +++ b/assets/common/items/weapons/starter_staff.ron @@ -4,7 +4,7 @@ Item( Power: 20", kind: Tool( - ToolData ( + ( kind: Staff(BasicStaff), equip_time_millis: 300, ) diff --git a/assets/common/items/weapons/starter_sword.ron b/assets/common/items/weapons/starter_sword.ron index 9b0eaae181..4dab78f166 100644 --- a/assets/common/items/weapons/starter_sword.ron +++ b/assets/common/items/weapons/starter_sword.ron @@ -4,7 +4,7 @@ Item( Power: 15", kind: Tool( - ToolData ( + ( kind: Sword(BasicSword), equip_time_millis: 300, ) diff --git a/assets/common/items/weapons/wood_sword.ron b/assets/common/items/weapons/wood_sword.ron index ce1189d866..a766b88c19 100644 --- a/assets/common/items/weapons/wood_sword.ron +++ b/assets/common/items/weapons/wood_sword.ron @@ -3,7 +3,7 @@ Item( description: " Power: 15", kind: Tool( - ToolData ( + ( kind: Sword(WoodTraining), equip_time_millis: 400, ) diff --git a/assets/common/items/weapons/zweihander_sword_0.ron b/assets/common/items/weapons/zweihander_sword_0.ron index be64c6f17b..32f8e9ca1e 100644 --- a/assets/common/items/weapons/zweihander_sword_0.ron +++ b/assets/common/items/weapons/zweihander_sword_0.ron @@ -3,7 +3,7 @@ Item( description: " Power: 15", kind: Tool( - ToolData ( + ( kind: Sword(Zweihander0), equip_time_millis: 500, ) diff --git a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron index 24fbedd44c..10fd3396d4 100644 --- a/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_belt_manifest.ron @@ -1,51 +1,52 @@ -({ - None:( +(( + default:( vox_spec: ("armor.belt.belt_none", (-5.0, -3.5, 2.0)), color: None ), - Dark:( - vox_spec: ("armor.belt.dark", (-4.0, -3.5, 2.0)), - color: None - ), - TurqCloth:( - vox_spec: ("armor.belt.cloth_turq", (-4.0, -3.5, -6.0)), - color: None - ), - BloodCloth:( - vox_spec: ("armor.belt.cloth_blood", (-4.0, -3.5, -6.0)), - color: Some((29, 26, 33)) - ), - BlackCloth:( - vox_spec: ("armor.belt.cloth_black", (-4.0, -3.5, -6.0)), - color: Some((29, 26, 33)) - ), - Assassin:( - vox_spec: ("armor.belt.assa", (-5.0, -3.5, 2.0)), - color: None - ), - Dark:( - vox_spec: ("armor.belt.dark", (-4.0, -3.5, 2.0)), - color: None - ), - Plate0:( - vox_spec: ("armor.belt.plate-0", (-5.0, -3.5, 2.0)), - color: None - ), - Leather0:( - vox_spec: ("armor.belt.leather-0", (-5.0, -3.5, 2.0)), - color: None - ), - ClothPurple0:( - vox_spec: ("armor.belt.cloth_purple-0", (-5.0, -3.5, 2.0)), - color: None - ), - ClothBlue0:( - vox_spec: ("armor.belt.cloth_blue-0", (-5.0, -3.5, 2.0)), - color: None - ), - ClothGreen0:( - vox_spec: ("armor.belt.cloth_green-0", (-5.0, -3.5, 2.0)), - color: None - ), - -}) + map: { + Dark:( + vox_spec: ("armor.belt.dark", (-4.0, -3.5, 2.0)), + color: None + ), + TurqCloth:( + vox_spec: ("armor.belt.cloth_turq", (-4.0, -3.5, -6.0)), + color: None + ), + BloodCloth:( + vox_spec: ("armor.belt.cloth_blood", (-4.0, -3.5, -6.0)), + color: Some((29, 26, 33)) + ), + BlackCloth:( + vox_spec: ("armor.belt.cloth_black", (-4.0, -3.5, -6.0)), + color: Some((29, 26, 33)) + ), + Assassin:( + vox_spec: ("armor.belt.assa", (-5.0, -3.5, 2.0)), + color: None + ), + Dark:( + vox_spec: ("armor.belt.dark", (-4.0, -3.5, 2.0)), + color: None + ), + Plate0:( + vox_spec: ("armor.belt.plate-0", (-5.0, -3.5, 2.0)), + color: None + ), + Leather0:( + vox_spec: ("armor.belt.leather-0", (-5.0, -3.5, 2.0)), + color: None + ), + ClothPurple0:( + vox_spec: ("armor.belt.cloth_purple-0", (-5.0, -3.5, 2.0)), + color: None + ), + ClothBlue0:( + vox_spec: ("armor.belt.cloth_blue-0", (-5.0, -3.5, 2.0)), + color: None + ), + ClothGreen0:( + vox_spec: ("armor.belt.cloth_green-0", (-5.0, -3.5, 2.0)), + color: None + ), + }, +)) diff --git a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron index c053c04cbd..a311ef9ae7 100644 --- a/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_chest_manifest.ron @@ -1,59 +1,60 @@ -({ - None: ( +(( + default: ( vox_spec: ("armor.chest.chest_none", (-7.0, -3.5, 2.0)), color: None ), - Blue: ( - vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), - color: Some((44, 74, 109)) - ), - Brown: ( - vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), - color: Some((90, 49, 43)) - ), - Dark: ( - vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), - color: Some((73, 63, 59)) - ), - Green: ( - vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), - color: Some((59, 95, 67)) - ), - Orange: ( - vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), - color: Some((109, 58, 58)) - ), - Midnight: ( - vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), - color: Some((29, 26, 33)) - ), - Assassin: ( - vox_spec: ("armor.chest.assa", (-7.0, -3.5, 2.0)), - color: None - ), - Kimono: ( - vox_spec: ("armor.chest.cloth_red_kimono", (-7.0, -3.5, 2.0)), - color: None - ), - PlateGreen0: ( - vox_spec: ("armor.chest.plate_green-0", (-7.0, -3.5, 2.0)), - color: None - ), - Leather0: ( - vox_spec: ("armor.chest.leather-0", (-7.0, -3.5, 2.0)), - color: None - ), - ClothPurple0:( - vox_spec: ("armor.chest.cloth_purple-0", (-7.0, -3.5, 1.0)), - color: None - ), - ClothBlue0:( - vox_spec: ("armor.chest.cloth_blue-0", (-7.0, -3.5, 1.0)), - color: None - ), - ClothGreen0:( - vox_spec: ("armor.chest.cloth_green-0", (-7.0, -3.5, 1.0)), - color: None - ), - -}) + map: { + Blue: ( + vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), + color: Some((44, 74, 109)) + ), + Brown: ( + vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), + color: Some((90, 49, 43)) + ), + Dark: ( + vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), + color: Some((73, 63, 59)) + ), + Green: ( + vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), + color: Some((59, 95, 67)) + ), + Orange: ( + vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), + color: Some((109, 58, 58)) + ), + Midnight: ( + vox_spec: ("armor.chest.grayscale", (-7.0, -3.5, 2.0)), + color: Some((29, 26, 33)) + ), + Assassin: ( + vox_spec: ("armor.chest.assa", (-7.0, -3.5, 2.0)), + color: None + ), + Kimono: ( + vox_spec: ("armor.chest.cloth_red_kimono", (-7.0, -3.5, 2.0)), + color: None + ), + PlateGreen0: ( + vox_spec: ("armor.chest.plate_green-0", (-7.0, -3.5, 2.0)), + color: None + ), + Leather0: ( + vox_spec: ("armor.chest.leather-0", (-7.0, -3.5, 2.0)), + color: None + ), + ClothPurple0:( + vox_spec: ("armor.chest.cloth_purple-0", (-7.0, -3.5, 1.0)), + color: None + ), + ClothBlue0:( + vox_spec: ("armor.chest.cloth_blue-0", (-7.0, -3.5, 1.0)), + color: None + ), + ClothGreen0:( + vox_spec: ("armor.chest.cloth_green-0", (-7.0, -3.5, 1.0)), + color: None + ), + }, +)) diff --git a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron index 868541dc78..99f2e8580e 100644 --- a/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_foot_manifest.ron @@ -1,42 +1,44 @@ -({ - Bare: ( +(( + default: ( vox_spec: ("armor.foot.foot_none", (-2.5, -3.5, -9.0)), color: None ), - Dark: ( - vox_spec: ("armor.foot.dark-0", (-2.5, -3.5, -9.0)), - color: None - ), - Assassin: ( - vox_spec: ("armor.foot.assa", (-2.5, -3.5, -9.0)), - color: None - ), - Sandal: ( - vox_spec: ("armor.foot.cloth_sandals", (-2.5, -2.5, -9.0)), - color: None - ), - Jester: ( - vox_spec: ("armor.foot.dark_jester-elf_shoe", (-2.5, -3.0, -9.0)), - color: None - ), - Plate0: ( - vox_spec: ("armor.foot.plate-0", (-2.5, -3.5, -9.0)), - color: None - ), - Leather0: ( - vox_spec: ("armor.foot.leather-0", (-2.5, -3.5, -9.0)), - color: None - ), - ClothPurple0:( - vox_spec: ("armor.foot.cloth_purple-0", (-2.5, -3.5, -9.0)), - color: None - ), - ClothBlue0:( - vox_spec: ("armor.foot.cloth_blue-0", (-2.5, -3.5, -9.0)), - color: None - ), - ClothGreen0:( - vox_spec: ("armor.foot.cloth_green-0", (-2.5, -3.5, -9.0)), - color: None - ), -}) + map: { + Dark: ( + vox_spec: ("armor.foot.dark-0", (-2.5, -3.5, -9.0)), + color: None + ), + Assassin: ( + vox_spec: ("armor.foot.assa", (-2.5, -3.5, -9.0)), + color: None + ), + Sandal: ( + vox_spec: ("armor.foot.cloth_sandals", (-2.5, -2.5, -9.0)), + color: None + ), + Jester: ( + vox_spec: ("armor.foot.dark_jester-elf_shoe", (-2.5, -3.0, -9.0)), + color: None + ), + Plate0: ( + vox_spec: ("armor.foot.plate-0", (-2.5, -3.5, -9.0)), + color: None + ), + Leather0: ( + vox_spec: ("armor.foot.leather-0", (-2.5, -3.5, -9.0)), + color: None + ), + ClothPurple0:( + vox_spec: ("armor.foot.cloth_purple-0", (-2.5, -3.5, -9.0)), + color: None + ), + ClothBlue0:( + vox_spec: ("armor.foot.cloth_blue-0", (-2.5, -3.5, -9.0)), + color: None + ), + ClothGreen0:( + vox_spec: ("armor.foot.cloth_green-0", (-2.5, -3.5, -9.0)), + color: None + ), + }, +)) diff --git a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron index 151a85f9a9..bb6f5fcb47 100644 --- a/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_hand_manifest.ron @@ -1,5 +1,5 @@ -({ - Bare: ( +(( + default: ( left: ( vox_spec: ("armor.hand.hand_right_none", (-1.5, -1.5, -7.0)), color: None @@ -9,74 +9,76 @@ color: None ) ), - Assassin: ( - left: ( - vox_spec: ("armor.hand.assa_right", (-1.5, -1.5, -7.0)), - color: None + map: { + Assassin: ( + left: ( + vox_spec: ("armor.hand.assa_right", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.assa_right", (-1.5, -1.5, -7.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.hand.assa_right", (-1.5, -1.5, -7.0)), - color: None - ) - ), - Cloth: ( - left: ( - vox_spec: ("armor.hand.cloth_basic_right", (-1.5, -1.5, -7.0)), - color: None + Cloth: ( + left: ( + vox_spec: ("armor.hand.cloth_basic_right", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.cloth_basic_right", (-1.5, -1.5, -7.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.hand.cloth_basic_right", (-1.5, -1.5, -7.0)), - color: None - ) - ), - Plate0: ( - left: ( - vox_spec: ("armor.hand.plate_right-0", (-1.5, -1.5, -7.0)), - color: None + Plate0: ( + left: ( + vox_spec: ("armor.hand.plate_right-0", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.plate_right-0", (-1.5, -1.5, -7.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.hand.plate_right-0", (-1.5, -1.5, -7.0)), - color: None - ) - ), - Leather0: ( - left: ( - vox_spec: ("armor.hand.leather_right-0", (-1.5, -1.5, -7.0)), - color: None + Leather0: ( + left: ( + vox_spec: ("armor.hand.leather_right-0", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.leather_right-0", (-1.5, -1.5, -7.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.hand.leather_right-0", (-1.5, -1.5, -7.0)), - color: None - ) - ), - ClothPurple0: ( - left: ( - vox_spec: ("armor.hand.cloth_purple_right-0", (-1.5, -1.5, -7.0)), - color: None + ClothPurple0: ( + left: ( + vox_spec: ("armor.hand.cloth_purple_right-0", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.cloth_purple_right-0", (-1.5, -1.5, -7.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.hand.cloth_purple_right-0", (-1.5, -1.5, -7.0)), - color: None - ) - ), - ClothBlue0: ( - left: ( - vox_spec: ("armor.hand.cloth_blue_right-0", (-1.5, -1.5, -7.0)), - color: None + ClothBlue0: ( + left: ( + vox_spec: ("armor.hand.cloth_blue_right-0", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.cloth_blue_right-0", (-1.5, -1.5, -7.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.hand.cloth_blue_right-0", (-1.5, -1.5, -7.0)), - color: None - ) - ), - ClothGreen0: ( - left: ( - vox_spec: ("armor.hand.cloth_green_right-0", (-1.5, -1.5, -7.0)), - color: None + ClothGreen0: ( + left: ( + vox_spec: ("armor.hand.cloth_green_right-0", (-1.5, -1.5, -7.0)), + color: None + ), + right: ( + vox_spec: ("armor.hand.cloth_green_right-0", (-1.5, -1.5, -7.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.hand.cloth_green_right-0", (-1.5, -1.5, -7.0)), - color: None - ) - ), -}) + }, +)) diff --git a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron index 56ae5d0c2d..8d04e54fa2 100644 --- a/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_pants_manifest.ron @@ -1,54 +1,56 @@ -({ - None: ( +(( + default: ( vox_spec: ("armor.pants.pants_none", (-5.0, -3.5, 1.0)), color: Some((28, 66, 109)) ), - Blue: ( - vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), - color: Some((28, 66, 109)) - ), - Brown: ( - vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), - color: Some((54, 30, 26)) - ), - Dark: ( - vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), - color: Some((24, 19, 17)) - ), - Green: ( - vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), - color: Some((49, 95, 59)) - ), - Orange: ( - vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), - color: Some((148, 52, 33)) - ), - Assassin: ( - vox_spec: ("armor.pants.assa", (-5.0, -3.5, 1.0)), - color: None - ), - Kimono: ( - vox_spec: ("armor.pants.cloth_red_kimono", (-5.0, -3.5, 0.0)), - color: None - ), - PlateGreen0: ( - vox_spec: ("armor.pants.plate_green-0", (-5.0, -3.5, 1.0)), - color: None - ), - Leather0: ( - vox_spec: ("armor.pants.leather-0", (-5.0, -3.5, 1.0)), - color: None - ), - ClothPurple0:( - vox_spec: ("armor.pants.cloth_purple-0", (-5.0, -3.5, 0.0)), - color: None - ), - ClothBlue0:( - vox_spec: ("armor.pants.cloth_blue-0", (-5.0, -3.5, 0.0)), - color: None - ), - ClothGreen0:( - vox_spec: ("armor.pants.cloth_green-0", (-5.0, -3.5, 0.0)), - color: None - ), -}) + map: { + Blue: ( + vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), + color: Some((28, 66, 109)) + ), + Brown: ( + vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), + color: Some((54, 30, 26)) + ), + Dark: ( + vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), + color: Some((24, 19, 17)) + ), + Green: ( + vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), + color: Some((49, 95, 59)) + ), + Orange: ( + vox_spec: ("armor.pants.grayscale", (-5.0, -3.5, 1.0)), + color: Some((148, 52, 33)) + ), + Assassin: ( + vox_spec: ("armor.pants.assa", (-5.0, -3.5, 1.0)), + color: None + ), + Kimono: ( + vox_spec: ("armor.pants.cloth_red_kimono", (-5.0, -3.5, 0.0)), + color: None + ), + PlateGreen0: ( + vox_spec: ("armor.pants.plate_green-0", (-5.0, -3.5, 1.0)), + color: None + ), + Leather0: ( + vox_spec: ("armor.pants.leather-0", (-5.0, -3.5, 1.0)), + color: None + ), + ClothPurple0:( + vox_spec: ("armor.pants.cloth_purple-0", (-5.0, -3.5, 0.0)), + color: None + ), + ClothBlue0:( + vox_spec: ("armor.pants.cloth_blue-0", (-5.0, -3.5, 0.0)), + color: None + ), + ClothGreen0:( + vox_spec: ("armor.pants.cloth_green-0", (-5.0, -3.5, 0.0)), + color: None + ), + }, +)) diff --git a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron index 8b06beeeea..9789b7292b 100644 --- a/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron +++ b/assets/voxygen/voxel/humanoid_armor_shoulder_manifest.ron @@ -1,6 +1,6 @@ -({ +(( //This shouldn't be the none option, but what is? - None: ( + default: ( left: ( vox_spec: ("armor.empty", (-3.0, -3.5, 1.0)), color: None @@ -10,104 +10,106 @@ color: None ) ), - Brown1: ( - left: ( - vox_spec: ("armor.shoulder.brown_right", (-3.0, -3.5, 1.0)), - color: None + map: { + Brown1: ( + left: ( + vox_spec: ("armor.shoulder.brown_right", (-3.0, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.brown_right", (-2.0, -3.5, 1.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.shoulder.brown_right", (-2.0, -3.5, 1.0)), - color: None - ) - ), - Assassin: ( - left: ( - vox_spec: ("armor.shoulder.assa_right", (-4.0, -3.5, 1.0)), - color: None + Assassin: ( + left: ( + vox_spec: ("armor.shoulder.assa_right", (-4.0, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.assa_right", (-2.0, -3.5, 1.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.shoulder.assa_right", (-2.0, -3.5, 1.0)), - color: None - ) - ), - Assassin: ( - left: ( - vox_spec: ("armor.shoulder.assa_right", (-4.0, -3.5, 1.0)), - color: None + Assassin: ( + left: ( + vox_spec: ("armor.shoulder.assa_right", (-4.0, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.assa_right", (-2.0, -3.5, 1.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.shoulder.assa_right", (-2.0, -3.5, 1.0)), - color: None - ) - ), - Chain: ( - left: ( - vox_spec: ("armor.shoulder.chain_right-1", (-4.0, -3.5, 1.0)), - color: None + Chain: ( + left: ( + vox_spec: ("armor.shoulder.chain_right-1", (-4.0, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.chain_right-1", (-2.0, -3.5, 1.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.shoulder.chain_right-1", (-2.0, -3.5, 1.0)), - color: None - ) - ), - Plate0: ( - left: ( - vox_spec: ("armor.shoulder.plate_right-0", (-3.6, -3.5, 1.0)), - color: None + Plate0: ( + left: ( + vox_spec: ("armor.shoulder.plate_right-0", (-3.6, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.plate_right-0", (-2.6, -3.5, 1.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.shoulder.plate_right-0", (-2.6, -3.5, 1.0)), - color: None - ) - ), - Leather0: ( - left: ( - vox_spec: ("armor.shoulder.leather_right-0", (-3.2, -3.5, 1.0)), - color: None + Leather0: ( + left: ( + vox_spec: ("armor.shoulder.leather_right-0", (-3.2, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.leather_right-0", (-1.8, -3.5, 1.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.shoulder.leather_right-0", (-1.8, -3.5, 1.0)), - color: None - ) - ), - Leather1: ( - left: ( - vox_spec: ("armor.shoulder.leather_right-1", (-3.6, -4.5, 1.0)), - color: None + Leather1: ( + left: ( + vox_spec: ("armor.shoulder.leather_right-1", (-3.6, -4.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.leather_right-1", (-2.6, -4.5, 1.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.shoulder.leather_right-1", (-2.6, -4.5, 1.0)), - color: None - ) - ), - ClothPurple0: ( - left: ( - vox_spec: ("armor.shoulder.cloth_purple_right-0", (-3.2, -3.5, 1.0)), - color: None + ClothPurple0: ( + left: ( + vox_spec: ("armor.shoulder.cloth_purple_right-0", (-3.2, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.cloth_purple_right-0", (-1.8, -3.5, 1.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.shoulder.cloth_purple_right-0", (-1.8, -3.5, 1.0)), - color: None - ) - ), - ClothBlue0: ( - left: ( - vox_spec: ("armor.shoulder.cloth_blue_left-0", (-3.2, -3.5, 1.0)), - color: None + ClothBlue0: ( + left: ( + vox_spec: ("armor.shoulder.cloth_blue_left-0", (-3.2, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.cloth_blue_right-0", (-1.8, -3.5, 1.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.shoulder.cloth_blue_right-0", (-1.8, -3.5, 1.0)), - color: None - ) - ), - ClothGreen0: ( - left: ( - vox_spec: ("armor.shoulder.cloth_green_left-0", (-3.2, -3.5, 1.0)), - color: None + ClothGreen0: ( + left: ( + vox_spec: ("armor.shoulder.cloth_green_left-0", (-3.2, -3.5, 1.0)), + color: None + ), + right: ( + vox_spec: ("armor.shoulder.cloth_green_right-0", (-1.8, -3.5, 1.0)), + color: None + ) ), - right: ( - vox_spec: ("armor.shoulder.cloth_green_right-0", (-1.8, -3.5, 1.0)), - color: None - ) - ), -}) + }, +)) diff --git a/common/src/comp/inventory/item/armor.rs b/common/src/comp/inventory/item/armor.rs index aba5645d3c..88cd537203 100644 --- a/common/src/comp/inventory/item/armor.rs +++ b/common/src/comp/inventory/item/armor.rs @@ -1,7 +1,6 @@ #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Chest { - None = 0, Blue = 1, Brown = 2, Dark = 3, @@ -16,8 +15,7 @@ pub enum Chest { ClothBlue0 = 12, ClothGreen0 = 13, } -pub const ALL_CHESTS: [Chest; 14] = [ - Chest::None, +pub const ALL_CHESTS: [Chest; 13] = [ Chest::Blue, Chest::Brown, Chest::Dark, @@ -98,7 +96,6 @@ pub const ALL_PANTS: [Pants; 13] = [ #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Hand { - Bare = 0, Cloth = 1, Assassin = 2, Plate0 = 3, @@ -107,8 +104,7 @@ pub enum Hand { ClothBlue0 = 6, ClothGreen0 = 7, } -pub const ALL_HANDS: [Hand; 8] = [ - Hand::Bare, +pub const ALL_HANDS: [Hand; 7] = [ Hand::Cloth, Hand::Assassin, Hand::Plate0, @@ -121,7 +117,6 @@ pub const ALL_HANDS: [Hand; 8] = [ #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Foot { - Bare = 0, Dark = 1, Sandal = 2, Jester = 3, @@ -132,8 +127,7 @@ pub enum Foot { ClothBlue0 = 8, ClothGreen0 = 9, } -pub const ALL_FEET: [Foot; 10] = [ - Foot::Bare, +pub const ALL_FEET: [Foot; 9] = [ Foot::Dark, Foot::Sandal, Foot::Jester, @@ -148,7 +142,6 @@ pub const ALL_FEET: [Foot; 10] = [ #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] pub enum Shoulder { - None = 0, Brown1 = 1, Chain = 2, Assassin = 3, @@ -159,8 +152,7 @@ pub enum Shoulder { ClothBlue0 = 8, ClothGreen0 = 9, } -pub const ALL_SHOULDERS: [Shoulder; 10] = [ - Shoulder::None, +pub const ALL_SHOULDERS: [Shoulder; 9] = [ Shoulder::Brown1, Shoulder::Chain, Shoulder::Assassin, diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index f2a948c4b1..31457d3fcd 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -234,19 +234,26 @@ impl HumHeadSpec { // Armor spects should be in the same order, top to bottom. // These seem overly split up, but wanted to keep the armor seperated // unlike head which is done above. - #[derive(Serialize, Deserialize)] -pub struct HumArmorShoulderSpec(HashMap); +pub struct ArmorVoxSpecMap +where + K: std::hash::Hash + std::cmp::Eq, +{ + default: S, + map: HashMap, +} #[derive(Serialize, Deserialize)] -pub struct HumArmorChestSpec(HashMap); +pub struct HumArmorShoulderSpec(ArmorVoxSpecMap); #[derive(Serialize, Deserialize)] -pub struct HumArmorHandSpec(HashMap); +pub struct HumArmorChestSpec(ArmorVoxSpecMap); #[derive(Serialize, Deserialize)] -pub struct HumArmorBeltSpec(HashMap); +pub struct HumArmorHandSpec(ArmorVoxSpecMap); #[derive(Serialize, Deserialize)] -pub struct HumArmorPantsSpec(HashMap); +pub struct HumArmorBeltSpec(ArmorVoxSpecMap); #[derive(Serialize, Deserialize)] -pub struct HumArmorFootSpec(HashMap); +pub struct HumArmorPantsSpec(ArmorVoxSpecMap); +#[derive(Serialize, Deserialize)] +pub struct HumArmorFootSpec(ArmorVoxSpecMap); #[derive(Serialize, Deserialize)] pub struct HumMainWeaponSpec(HashMap); @@ -307,22 +314,20 @@ impl HumArmorShoulderSpec { } fn mesh_shoulder(&self, body: &Body, loadout: &Loadout, flipped: bool) -> Mesh { - let shoulder = if let Some(ItemKind::Armor { + let spec = if let Some(ItemKind::Armor { kind: Armor::Shoulder(shoulder), .. }) = loadout.shoulder.as_ref().map(|i| &i.kind) { - shoulder + match self.0.map.get(&shoulder) { + Some(spec) => spec, + None => { + error!("No shoulder specification exists for {:?}", shoulder); + return load_mesh("not_found", Vec3::new(-3.0, -3.5, 0.1)); + }, + } } else { - &Shoulder::None - }; - - let spec = match self.0.get(&shoulder) { - Some(spec) => spec, - None => { - error!("No shoulder specification exists for {:?}", shoulder); - return load_mesh("not_found", Vec3::new(-3.0, -3.5, 0.1)); - }, + &self.0.default }; let shoulder_segment = color_segment( @@ -366,22 +371,20 @@ impl HumArmorChestSpec { } pub fn mesh_chest(&self, body: &Body, loadout: &Loadout) -> Mesh { - let chest = if let Some(ItemKind::Armor { + let spec = if let Some(ItemKind::Armor { kind: Armor::Chest(chest), .. }) = loadout.chest.as_ref().map(|i| &i.kind) { - chest + match self.0.map.get(&chest) { + Some(spec) => spec, + None => { + error!("No chest specification exists for {:?}", loadout.chest); + return load_mesh("not_found", Vec3::new(-7.0, -3.5, 2.0)); + }, + } } else { - &Chest::None - }; - - let spec = match self.0.get(&chest) { - Some(spec) => spec, - None => { - error!("No chest specification exists for {:?}", loadout.chest); - return load_mesh("not_found", Vec3::new(-7.0, -3.5, 2.0)); - }, + &self.0.default }; let color = |mat_segment| { @@ -419,22 +422,20 @@ impl HumArmorHandSpec { } fn mesh_hand(&self, body: &Body, loadout: &Loadout, flipped: bool) -> Mesh { - let hand = if let Some(ItemKind::Armor { + let spec = if let Some(ItemKind::Armor { kind: Armor::Hand(hand), .. }) = loadout.hand.as_ref().map(|i| &i.kind) { - hand + match self.0.map.get(&hand) { + Some(spec) => spec, + None => { + error!("No hand specification exists for {:?}", hand); + return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0)); + }, + } } else { - &Hand::Bare - }; - - let spec = match self.0.get(&hand) { - Some(spec) => spec, - None => { - error!("No hand specification exists for {:?}", hand); - return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0)); - }, + &self.0.default }; let hand_segment = color_segment( @@ -473,22 +474,20 @@ impl HumArmorBeltSpec { } pub fn mesh_belt(&self, body: &Body, loadout: &Loadout) -> Mesh { - let belt = if let Some(ItemKind::Armor { + let spec = if let Some(ItemKind::Armor { kind: Armor::Belt(belt), .. }) = loadout.belt.as_ref().map(|i| &i.kind) { - belt + match self.0.map.get(&belt) { + Some(spec) => spec, + None => { + error!("No belt specification exists for {:?}", belt); + return load_mesh("not_found", Vec3::new(-4.0, -3.5, 2.0)); + }, + } } else { - &Belt::None - }; - - let spec = match self.0.get(&belt) { - Some(spec) => spec, - None => { - error!("No belt specification exists for {:?}", belt); - return load_mesh("not_found", Vec3::new(-4.0, -3.5, 2.0)); - }, + &self.0.default }; let belt_segment = color_segment( @@ -509,22 +508,20 @@ impl HumArmorPantsSpec { } pub fn mesh_pants(&self, body: &Body, loadout: &Loadout) -> Mesh { - let pants = if let Some(ItemKind::Armor { + let spec = if let Some(ItemKind::Armor { kind: Armor::Pants(pants), .. }) = loadout.pants.as_ref().map(|i| &i.kind) { - pants + match self.0.map.get(&pants) { + Some(spec) => spec, + None => { + error!("No pants specification exists for {:?}", pants); + return load_mesh("not_found", Vec3::new(-5.0, -3.5, 1.0)); + }, + } } else { - &Pants::None - }; - - let spec = match self.0.get(&pants) { - Some(spec) => spec, - None => { - error!("No pants specification exists for {:?}", pants); - return load_mesh("not_found", Vec3::new(-5.0, -3.5, 1.0)); - }, + &self.0.default }; let color = |mat_segment| { @@ -562,22 +559,20 @@ impl HumArmorFootSpec { } fn mesh_foot(&self, body: &Body, loadout: &Loadout, flipped: bool) -> Mesh { - let foot = if let Some(ItemKind::Armor { + let spec = if let Some(ItemKind::Armor { kind: Armor::Foot(foot), .. }) = loadout.foot.as_ref().map(|i| &i.kind) { - foot + match self.0.map.get(&foot) { + Some(spec) => spec, + None => { + error!("No foot specification exists for {:?}", foot); + return load_mesh("not_found", Vec3::new(-2.5, -3.5, -9.0)); + }, + } } else { - &Foot::Bare - }; - - let spec = match self.0.get(&foot) { - Some(spec) => spec, - None => { - error!("No foot specification exists for {:?}", foot); - return load_mesh("not_found", Vec3::new(-2.5, -3.5, -9.0)); - }, + &self.0.default }; let foot_segment = color_segment( From e3a5051b52ba241de2794d0e687d2eab18d75876 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Sat, 28 Mar 2020 18:06:00 +0100 Subject: [PATCH 292/326] small fix --- assets/voxygen/element/help.png | 4 ++-- voxygen/src/hud/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/voxygen/element/help.png b/assets/voxygen/element/help.png index 558430c026..b72966dcea 100644 --- a/assets/voxygen/element/help.png +++ b/assets/voxygen/element/help.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:561db05ac9702129859c6b266dd63df7e0ab5c832c6ce587afc65bc203592cd6 -size 14794 +oid sha256:1b9f41be9c1e49a2dfa1be3565a0c18d30ee4f7ab8ad2c879b8fa461c845699b +size 14795 diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index ea98754167..d5b2bd8fa7 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -57,7 +57,7 @@ const TEXT_BG: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0); const MENU_BG: Color = Color::Rgba(0.0, 0.0, 0.0, 0.4); //const TEXT_COLOR_2: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0); const TEXT_COLOR_3: Color = Color::Rgba(1.0, 1.0, 1.0, 0.1); -const BLACK: Color = Color::Rgba(0.0, 0.0, 0.0, 0.98); +const BLACK: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0); //const BG_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 0.8); const HP_COLOR: Color = Color::Rgba(0.33, 0.63, 0.0, 1.0); const LOW_HP_COLOR: Color = Color::Rgba(0.93, 0.59, 0.03, 1.0); From 6bd20c64f893dfa9a77e031796b9281a0a98c4dc Mon Sep 17 00:00:00 2001 From: Imbris Date: Sat, 28 Mar 2020 14:50:05 -0400 Subject: [PATCH 293/326] fix debug item rons --- assets/common/items/debug/boost.ron | 2 +- assets/common/items/debug/possess.ron | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/common/items/debug/boost.ron b/assets/common/items/debug/boost.ron index 141b093d09..0bfb72722c 100644 --- a/assets/common/items/debug/boost.ron +++ b/assets/common/items/debug/boost.ron @@ -2,7 +2,7 @@ Item( name: "Weightless Rod", description: "The sky is the limit.", kind: Tool( - ToolData ( + ( kind: Debug(Boost), equip_time_millis: 0, ) diff --git a/assets/common/items/debug/possess.ron b/assets/common/items/debug/possess.ron index 8e315cd5af..37c6df5d8a 100644 --- a/assets/common/items/debug/possess.ron +++ b/assets/common/items/debug/possess.ron @@ -2,7 +2,7 @@ Item( name: "Rod of Possession", description: "It's fixed on my branch.", kind: Tool( - ToolData ( + ( kind: Debug(Possess), equip_time_millis: 0, ) From ae975a67f43e0d697407b6336a29b26ca4c28630 Mon Sep 17 00:00:00 2001 From: comfymattress Date: Sat, 28 Mar 2020 14:13:55 -0500 Subject: [PATCH 294/326] Fixed Flowers and Grass items --- assets/common/items/flowers/blue.ron | 4 +++- assets/common/items/flowers/pink.ron | 4 +++- assets/common/items/flowers/red.ron | 4 +++- assets/common/items/flowers/sun.ron | 4 +++- assets/common/items/flowers/white.ron | 4 +++- assets/common/items/flowers/yellow.ron | 4 +++- assets/common/items/grasses/long.ron | 4 +++- assets/common/items/grasses/medium.ron | 4 +++- assets/common/items/grasses/short.ron | 4 +++- 9 files changed, 27 insertions(+), 9 deletions(-) diff --git a/assets/common/items/flowers/blue.ron b/assets/common/items/flowers/blue.ron index cc99b22a2b..7f137e1892 100644 --- a/assets/common/items/flowers/blue.ron +++ b/assets/common/items/flowers/blue.ron @@ -1,5 +1,7 @@ Item( name: "Blue Flower", description: "Matches the color of the sky.", - kind: Ingredient, + kind: Ingredient( + kind: Flower, + ) ) diff --git a/assets/common/items/flowers/pink.ron b/assets/common/items/flowers/pink.ron index f01edd7633..79c3bada08 100644 --- a/assets/common/items/flowers/pink.ron +++ b/assets/common/items/flowers/pink.ron @@ -1,5 +1,7 @@ Item( name: "Pink Flower", description: "Looks like a lollipop.", - kind: Ingredient, + kind: Ingredient( + kind: Flower, + ) ) diff --git a/assets/common/items/flowers/red.ron b/assets/common/items/flowers/red.ron index e92e19ed63..b9ea9425c1 100644 --- a/assets/common/items/flowers/red.ron +++ b/assets/common/items/flowers/red.ron @@ -1,5 +1,7 @@ Item( name: "Red Flower", description: "Roses are red...", - kind: Ingredient, + kind: Ingredient( + kind: Flower, + ) ) diff --git a/assets/common/items/flowers/sun.ron b/assets/common/items/flowers/sun.ron index d24ce0f52b..757db214a3 100644 --- a/assets/common/items/flowers/sun.ron +++ b/assets/common/items/flowers/sun.ron @@ -1,5 +1,7 @@ Item( name: "Sunflower", description: "Smells like summer.", - kind: Ingredient, + kind: Ingredient( + kind: Flower, + ) ) diff --git a/assets/common/items/flowers/white.ron b/assets/common/items/flowers/white.ron index 053f7d0ec7..0b98d0f799 100644 --- a/assets/common/items/flowers/white.ron +++ b/assets/common/items/flowers/white.ron @@ -1,5 +1,7 @@ Item( name: "White flower", description: "Pure and precious.", - kind: Ingredient, + kind: Ingredient( + kind: Flower, + ) ) diff --git a/assets/common/items/flowers/yellow.ron b/assets/common/items/flowers/yellow.ron index c58d067d9b..c9e799b32e 100644 --- a/assets/common/items/flowers/yellow.ron +++ b/assets/common/items/flowers/yellow.ron @@ -1,5 +1,7 @@ Item( name: "Yellow Flower", description: "Glows like the sun.", - kind: Ingredient, + kind: Ingredient( + kind: Flower, + ) ) diff --git a/assets/common/items/grasses/long.ron b/assets/common/items/grasses/long.ron index f94b5d10eb..e592ce9779 100644 --- a/assets/common/items/grasses/long.ron +++ b/assets/common/items/grasses/long.ron @@ -1,5 +1,7 @@ Item( name: "Long Grass", description: "Greener than an orc's snout.", - kind: Ingredient, + kind: Ingredient( + kind: Grass, + ) ) diff --git a/assets/common/items/grasses/medium.ron b/assets/common/items/grasses/medium.ron index 71b3b44ddf..ec67d4bb77 100644 --- a/assets/common/items/grasses/medium.ron +++ b/assets/common/items/grasses/medium.ron @@ -1,5 +1,7 @@ Item( name: "Medium Grass", description: "Greener than an orc's snout.", - kind: Ingredient, + kind: Ingredient( + kind: Grass, + ) ) diff --git a/assets/common/items/grasses/short.ron b/assets/common/items/grasses/short.ron index e3cdc0a5fc..a1808c85f6 100644 --- a/assets/common/items/grasses/short.ron +++ b/assets/common/items/grasses/short.ron @@ -1,5 +1,7 @@ Item( name: "Short Grass", description: "Greener than an orc's snout.", - kind: Ingredient, + kind: Ingredient( + kind: Grass, + ) ) From 86b0b8f644d80ecb79884cc2e3af9612d38c6887 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sat, 28 Mar 2020 13:50:42 -0700 Subject: [PATCH 295/326] triple_strike orientation --- common/src/states/triple_strike.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index d59869c20d..5a670c1cab 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -8,7 +8,7 @@ use vek::vec::Vec3; // In millis const STAGE_DURATION: u64 = 700; -const TIMING_WINDOW: u64 = 500; +const TIMING_WINDOW: u64 = 600; const INITIAL_ACCEL: f32 = 90.0; const BASE_SPEED: f32 = 25.0; @@ -120,7 +120,7 @@ impl CharacterBehavior for Data { } }; } else { - handle_orientation(data, &mut update, 20.0); + handle_orientation(data, &mut update, 50.0); } // Handling attacking From 1cb93b92ed89f60af0be6981b05ea1f212e00074 Mon Sep 17 00:00:00 2001 From: S Handley Date: Sun, 29 Mar 2020 01:47:18 +0000 Subject: [PATCH 296/326] Add Italian translation --- assets/voxygen/i18n/it.ron | 559 +++++++++++++++++++++++++++++++++++++ 1 file changed, 559 insertions(+) create mode 100644 assets/voxygen/i18n/it.ron diff --git a/assets/voxygen/i18n/it.ron b/assets/voxygen/i18n/it.ron new file mode 100644 index 0000000000..7099e32f5c --- /dev/null +++ b/assets/voxygen/i18n/it.ron @@ -0,0 +1,559 @@ +/// Translation document instructions +/// +/// In order to keep localization documents readible please follow the following +/// rules: +/// - separate the string map sections using a commentary describing the purpose +/// of the next section +/// - prepend multi-line strings with a commentary +/// - append one blank lines after a multi-line strings and two after sections +/// +/// To add a new language in Veloren, just write an additional `.ron` file in +/// `assets/voxygen/i18n` and that's it! + + + + +/// Localization for "global" Italian +VoxygenLocalization( + metadata: ( + language_name: "Italiano", + language_identifier: "it", + ), + convert_utf8_to_ascii: false, + fonts: { + "opensans": Font ( + asset_key: "voxygen.font.OpenSans-Regular", + scale_ratio: 1.0, + ), + "metamorph": Font ( + asset_key: "voxygen.font.Metamorphous-Regular", + scale_ratio: 1.0, + ), + "alkhemi": Font ( + asset_key: "voxygen.font.Alkhemikal", + scale_ratio: 1.0, + ), + "wizard": Font ( + asset_key: "voxygen.font.wizard", + scale_ratio: 1.0, + ), + "cyri": Font ( + asset_key: "voxygen.font.haxrcorp_4089_cyrillic_altgr_extended", + scale_ratio: 1.0, + ), + }, + string_map: { + /// Start Common section + // Texts used in multiple locations with the same formatting + "common.username": "Nome Utente", + "common.singleplayer": "Giocatore Singolo", + "common.multiplayer": "Multigiocatore", + "common.servers": "Server", + "common.quit": "Esci", + "common.settings": "Impostazioni", + "common.languages": "Lingue", + "common.interface": "Interfaccia", + "common.gameplay": "Gameplay", + "common.controls": "Controlli", + "common.video": "Video", + "common.sound": "Audio", + "common.resume": "Riprendi", + "common.characters": "Personaggi", + "common.close": "Chiudi", + "common.yes": "Si", + "common.no": "No", + "common.back": "Indietro", + "common.create": "Crea", + "common.okay": "Ok", + "common.disclaimer": "Disclaimer", + "common.cancel": "Cancella", + "common.none": "Nessuno", + "common.error": "Errore", + "common.fatal_error": "Errore Fatale", + + + + + + // Message when connection to the server is lost + "common.connection_lost": r#"Connessione persa! +Si è riavviato il server? +Il client è aggiornato?"#, + + + + + + + + + "common.races.orc": "Orco", + "common.races.human": "Umano", + "common.races.dwarf": "Nano", + "common.races.elf": "Elfo", + "common.races.undead": "Non-Morto", + "common.races.danari": "Danari", + + + + + "common.weapons.axe": "Ascia", + "common.weapons.sword": "Spada", + "common.weapons.staff": "Bastone", + "common.weapons.bow": "Arco", + "common.weapons.hammer": "Martello", + /// End Common section + + + + + + + + + /// Start Main screen section + "main.connecting": "Connessione in corso", + "main.creating_world": "Creazione del mondo", + + + + + // Welcome notice that appears the first time Veloren is started + "main.notice": r#"Benvenuto nella versione Alpha di Veloren! + + + + +Prima di tuffarti nel divertimento, ti preghiamo di tenere a mente che: + + + + +- Questa è un’Alpha molto prematura. Aspettati errori, gameplay non completo, meccaniche non rifinite, e funzioni mancanti. +- Se hai critiche costruttive o errori da segnalare, ci puoi contattare tramite Reddit, GitLab, o il server Discord della nostra community. +- Veloren è concesso in licenza con la licenza open-source GPL 3. Il che vuol dire che sei libero di giocare, modificare, e ridistribuire il gioco come tu desideri (purché il lavoro che ne derivi sia sempre sotto licenza GPL 3). +- Veloren è un progetto comunitario no-profit, e chiunque ci lavori sopra è un volontario. +Se ti piace ciò che vedi, sei il benvenuto ad unirti ai team di sviluppo e artistico! +- 'Voxel RPG' è un genere a sé stante. Gli sparatutto-in-prima-persona venivano considerati cloni di Doom. + + + + +Come loro, stiamo cercando di costruire una nicchia. Il gioco non è un clone, e il suo sviluppo divergerà dai giochi esistenti in futuro. + + + + +Grazie per aver dedicato del tempo a leggere questo avviso, speriamo che ti divertirai col gioco! + + + + +~ Il team di sviluppo di Veloren"#, + + + + + // Login process description + "main.login_process": r#"Informazioni sul processo del Login: + + +Se stai avendo problemi nell'accedere: + +Notare che hai bisogno di un account +per giocare su server con autenticazione abilitata. + +Puoi creare un account su + +https://account.veloren.net."#, + "main.login.server_not_found": "Server non trovato", + "main.login.authentication_error": "Errore di autenticazione server", + "main.login.server_full": "Il server è pieno", + "main.login.untrusted_auth_server": "Server di autenticazione non affidabile", + "main.login.outdated_client_or_server": "Il server è impazzito: Probabilmente le versioni sono incompatibili, controlla per degli aggiornamenti", + "main.login.timeout": "Tempo scaduto: Il server non ha risposto in tempo. (In sovraccarico o problemi di rete)", + "main.login.server_shut_down": "Il server è stato chiuso", + "main.login.already_logged_in": "Hai già effettuato l'accesso al server", + "main.login.network_error": "Errore di rete", + "main.login.failed_sending_request": "Richiesta ai server di autenticazione fallita", + "main.login.client_crashed": "Il client si è arrestato", + + + + + + + + + + /// End Main screen section + + + + + + + + + /// Start HUD Section + "hud.do_not_show_on_startup": "Non mostrare all’avvio", + "hud.show_tips": "Mostra consigli", + "hud.quests": "Missioni", + "hud.you_died": "Sei Morto", + + "hud.press_key_to_show_keybindings_fmt": "Premi {key} per mostrare le scorciatoie da tastiera", + "hud.press_key_to_show_debug_info_fmt": "Premi {key} per mostrare le informazioni di debug", + "hud.press_key_to_toggle_keybindings_fmt": "Premi {key} per attivare/disattivare le scorciatoie da tastiera", + "hud.press_key_to_toggle_debug_info_fmt": "Premi {key} per attivare/disattivare le informazioni di debug", + + + + + // Respawn message + "hud.press_key_to_respawn": r#"Premi {key} per rinascere al tuo Waypoint. + + + + +Premi Invio, scrivi /waypoint e conferma per impostarlo qui."#, + + + + + // Welcome message + "hud.welcome": r#"Benvenuto nell’Alpha di Veloren! + + + + +Alcuni consigli prima di cominciare: + + +MOLTO IMPORTANTE: Per impostare il tuo punto di rinascita scrivi /waypoint + + +nella chat. + + +Ciò può essere fatto anche se sei già morto! + + + + +Premi F1 per vedere i comandi chiave disponibili. + + +Scrivi /help nella chat per vedere i comandi della chat. + + + + +Ci sono forzieri e altri oggetti che appaiono casualmente nel Mondo! + + +Clicca col tasto destro del mouse per raccoglierli. + + +Per usare qualsiasi cosa tu ottenga da quei forzieri apri il tuo inventario con 'B'. + + +Fai doppio click sugli oggetti nella tua borsa per usarli o equipaggiarli. + + +Gettali via cliccandoci una volta sopra e una volta fuori dall’inventario. + + + + +Le notti possono essere molto buie in Veloren. + + +Accendi la tua lanterna scrivendo /lantern nella chat. + + + + +Vuoi sbloccare il cursore per chiudere questa finestra? Premi TAB! + + + + +Goditi il tuo soggiorno nel Mondo di Veloren."#, + + + + + "hud.settings.general": "Generale", + "hud.settings.none": "Nessuno", + "hud.settings.press_behavior.toggle": "Attiva/Disattiva" + "hud.settings.press_behavior.hold": "Tieni Premuto", + "hud.settings.help_window": "Finestra di Aiuto", + "hud.settings.debug_info": "Informazioni di Debug", + "hud.settings.tips_on_startup": "Consigli all’Avvio", + "hud.settings.ui_scale": "Proporzione Interfaccia", + "hud.settings.relative_scaling": "Proporzione Relativa", + "hud.settings.custom_scaling": "Proporzione Person.", + "hud.settings.crosshair": "Mirino", + "hud.settings.transparency": "Trasparenza", + "hud.settings.hotbar": "Barra Veloce", + "hud.settings.toggle_shortcuts": "Attivare/Disattivare Scorciatoie", + "hud.settings.toggle_bar_experience": "Attivare/Disattivare Barra dell’Esperienza", + "hud.settings.scrolling_combat_text": "Testo di Combattimento Scorrevole", + "hud.settings.single_damage_number": "Danno Nemico (Singolo)", + "hud.settings.cumulated_damage": "Danno Nemico (Cumulativo)", + "hud.settings.incoming_damage": "Danno Giocatore (Singolo)", + "hud.settings.cumulated_incoming_damage": "Danno Giocatore (Cumulativo)", + "hud.settings.energybar_numbers": "Numeri Barra dell’Energia", + "hud.settings.values": "Valori", + "hud.settings.percentages": "Percentuali", + "hud.settings.chat": "Chat", + "hud.settings.background_transparency": "Trasparenza dello Sfondo", + "hud.settings.none": "Nessuno", + + + + + "hud.settings.pan_sensitivity": "Sensibilità Camera", + "hud.settings.zoom_sensitivity": "Sensibilità Zoom", + "hud.settings.invert_scroll_zoom": "Zoom Invertito", + "hud.settings.invert_mouse_y_axis": "Asse Y del Mouse Invertito", + "hud.settings.free_look_behavior": "Comportamento Visuale Libera" + + + + + "hud.settings.view_distance": "Distanza Oggetto", + "hud.settings.maximum_fps": "FPS Massimi", + "hud.settings.fov": "Campo Visivo (gradi)", + "hud.settings.gamma": "Gamma", + "hud.settings.antialiasing_mode": "Modalità AntiAliasing", + "hud.settings.cloud_rendering_mode": "Modalità Renderizzazione Nuvole", + "hud.settings.fluid_rendering_mode": "Modalità Renderizzazione Fluido", + "hud.settings.fluid_rendering_mode.cheap": "Economico", + "hud.settings.fluid_rendering_mode.shiny": "Lucente", + "hud.settings.cloud_rendering_mode.regular": "Regolare", + "hud.settings.fullscreen": "Schermo Intero", + "hud.settings.save_window_size": "Salva dimensione finestra", + + + + + "hud.settings.music_volume": "Volume Musica", + "hud.settings.sound_effect_volume": "Volume Effetti Sonori", + "hud.settings.audio_device": "Dispositivo Audio", + + + + + // Control list + "hud.settings.control_names": r#"Cursore Libero +Attiva/Disattiva Finestra di Aiuto +Attiva/Disattiva Interfaccia +Attiva/Disattiva FPS e Informazioni di Debug +Scatta Screenshot +Attiva/Disattiva Nomi +Attiva/Disattiva Schermo Intero + + + + +Movimento in Avanti +Movimento a Sinistra +Movimento a Destra +Movimento all’Indietro + + +Salto + + +Aliante + + +Schivata + + +Rotolata + + +Scalata + + +Discesa + + +Camminata Automatica + + +Riporre/Sfoderare Armi + + +Mettere/Rimuovere Elmo + + +Sedersi + + +Cavalcatura + + +Interagire + + + + +Attacco Base +Attacco Secondario/Parata/Mira + + + + +Slot 1 Barra delle Abilità +Slot 2 Barra delle Abilità +Slot 3 Barra delle Abilità +Slot 4 Barra delle Abilità +Slot 5 Barra delle Abilità +Slot 6 Barra delle Abilità +Slot 7 Barra delle Abilità +Slot 8 Barra delle Abilità +Slot 9 Barra delle Abilità +Slot 10 Barra delle Abilità + + + + +Menù di Pausa +Impostazioni +Social +Mappa +Libro degli Incantesimi +Personaggio +Diario delle Missioni +Borsa + + + + + + +Invia Messaggio nella Chat +Scorrimento della Chat + + + +Camera Libera + + + +Comandi della Chat: + + + + +/alias [Name] - Cambia il tuo Nome nella Chat +/tp [Name] - Ti teleporta da un altro giocatore +/jump - Devia la tua posizione +/goto - Ti teleporta in una posizione +/kill - Suicidati +/pig - Fai apparire un maiale PNG +/wolf - Fai apparire un lupo PNG +/help - Mostra comandi della Chat + + +"#, + + + + + "hud.social": "Social", + "hud.social.online": "Online", + "hud.social.friends": "Amici", + "hud.social.not_yet_available": "Non ancora disponibile", + "hud.social.Faction": "Fazione", + "hud.social.play_online_fmt": "{nb_player} giocatore/i online", + + + + + "hud.spell": "Incantesimo", + + "hud.free_look_indicator": "Visuale Libera Attiva" + /// End HUD section + + + + + + + + + /// Start character selection section + "char_selection.delete_permanently": "Eliminare permanente questo Personaggio?", + "char_selection.change_server": "Cambia Server", + "char_selection.enter_world": "Unisciti al Mondo", + "char_selection.logout": "Disconnettiti", + "char_selection.create_new_charater": "Crea un nuovo Personaggio", + "char_selection.character_creation": "Creazione Personaggio", + + + + + "char_selection.human_default": "Umano Predefinito", + "char_selection.level_fmt": "Livello {level_nb}", + "char_selection.uncanny_valley": "Valle Perturbante", + "char_selection.plains_of_uncertainty": "Pianure dell'Incertezza", + "char_selection.beard": "Barba", + "char_selection.hair_style": "Stile Capelli", + "char_selection.hair_color": "Colore Capelli", + "char_selection.chest_color": "Colore Torace", + "char_selection.eye_color": "Colore Occhi", + "char_selection.skin": "Pelle", + "char_selection.eyebrows": "Sopracciglia", + "char_selection.accessories": "Accessori", + + + + + /// End chracter selection section + + + + + + + + + /// Start character window section + "character_window.character_name": "Nome Personaggio", + // Charater stats + "character_window.character_stats": r#"Stamina + + + + +Vitalità + + + + +Volontà +"#, + + + + + + + + + /// Start character window section + + + + + + /// Start Escape Menu Section + "esc_menu.logout": "Disconnettiti", + "esc_menu.quit_game": "Esci dal Gioco", + /// End Escape Menu Section + } +) \ No newline at end of file From fa54c90558b108ab688bdab4ad1261db7d3fc87b Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 29 Mar 2020 03:53:52 -0400 Subject: [PATCH 297/326] cleanup, tweak to triplestrike stage 1 --- voxygen/Cargo.toml | 2 +- voxygen/src/anim/character/alpha.rs | 51 ++++++++++-------- voxygen/src/anim/character/climb.rs | 59 +++++++++++---------- voxygen/src/anim/character/dash.rs | 8 +-- voxygen/src/anim/character/gliding.rs | 47 +++++++---------- voxygen/src/anim/character/idle.rs | 38 +++++--------- voxygen/src/anim/character/jump.rs | 38 +++++++------- voxygen/src/anim/character/sit.rs | 76 ++++++++++----------------- voxygen/src/anim/character/stand.rs | 10 ++-- 9 files changed, 142 insertions(+), 187 deletions(-) diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 71bbaadc35..b8224fa256 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -68,7 +68,7 @@ bincode = "1.2" deunicode = "1.0" uvth = "3.1.1" authc = { git = "https://gitlab.com/veloren/auth.git", rev = "65571ade0d954a0e0bd995fdb314854ff146ab97" } -const-tweaker = { version = "0.2.4", optional = true } +const-tweaker = { version = "0.2.5", optional = true } [target.'cfg(target_os = "macos")'.dependencies] dispatch = "0.1.4" diff --git a/voxygen/src/anim/character/alpha.rs b/voxygen/src/anim/character/alpha.rs index bc1a7ca73d..74573fc146 100644 --- a/voxygen/src/anim/character/alpha.rs +++ b/voxygen/src/anim/character/alpha.rs @@ -32,11 +32,15 @@ impl Animation for AlphaAnimation { let accel_slow = 1.0 - (anim_time as f32 * 12.0 * lab as f32).cos(); let accel_fast = 1.0 - (anim_time as f32 * 24.0 * lab as f32).cos(); let decel = (anim_time as f32 * 16.0 * lab as f32).min(PI / 2.0).sin(); - + let push = anim_time as f32 * lab as f32 * 4.0; let slow = (((5.0) - / (0.6 + 4.4 * ((anim_time as f32 * lab as f32 * 11.0).sin()).powf(2.0 as f32))) + / (0.4 + 4.6 * ((anim_time as f32 * lab as f32 * 9.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 11.0).sin()); + * ((anim_time as f32 * lab as f32 * 9.0).sin()); + let quick = (((5.0) + / (0.4 + 4.6 * ((anim_time as f32 * lab as f32 * 18.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 18.0).sin()); let slower = (((5.0) / (0.1 + 4.9 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) .sqrt()) @@ -54,50 +58,51 @@ impl Animation for AlphaAnimation { -2.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 14.0, ); - next.head.ori = Quaternion::rotation_z(slow * 0.08) - * Quaternion::rotation_x(0.0 + slow * 0.08) - * Quaternion::rotation_y(slow * -0.08); + next.head.ori = Quaternion::rotation_z(slow * -0.25) + * Quaternion::rotation_x(0.0 + slow * 0.15) + * Quaternion::rotation_y(slow * -0.15); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(slow * -0.2) + next.chest.ori = Quaternion::rotation_z(slow * 0.4) * Quaternion::rotation_x(0.0 + slow * -0.2) * Quaternion::rotation_y(slow * 0.2); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = next.chest.ori * -0.2; + next.belt.ori = next.chest.ori * -0.3; next.belt.scale = Vec3::one(); next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = next.chest.ori * -0.15; + next.shorts.ori = next.chest.ori * -0.45; next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); + next.l_hand.offset = Vec3::new(-0.25, -5.0, 1.0); next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.04; - next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(1.25, -5.5, -2.0); next.r_hand.ori = Quaternion::rotation_x(1.27); next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.offset = Vec3::new(0.0, 0.0, 0.0); next.main.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0); - next.control.ori = Quaternion::rotation_x(-1.4) - * Quaternion::rotation_y(slow * 1.5 + 0.7) - * Quaternion::rotation_z(1.4 + slow * 0.5); + next.control.offset = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0); + next.control.ori = Quaternion::rotation_x(-1.4 + slow * 0.4) + * Quaternion::rotation_y(slow * -1.3) + * Quaternion::rotation_z(1.4 + slow * -0.5); next.control.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, foot * 3.0 + slow * -5.0, 8.0); - next.l_foot.ori = - Quaternion::rotation_x(foot * -0.6) * Quaternion::rotation_y(foot * 0.2); + + next.l_foot.offset = Vec3::new(-3.4, slow * -3.0 + quick * 3.0 - 4.0, 8.0); + next.l_foot.ori = Quaternion::rotation_x(slow * 0.6) + * Quaternion::rotation_y((slow * -0.2).max(0.0)); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, foot * -3.0 + slow * 5.0, 8.0); - next.r_foot.ori = - Quaternion::rotation_x(foot * 0.6) * Quaternion::rotation_y(foot * -0.2); + next.r_foot.offset = Vec3::new(3.4, slow * 3.0 + quick * -3.0 + 5.0, 8.0); + next.r_foot.ori = Quaternion::rotation_x(slow * -0.6) + * Quaternion::rotation_y((slow * 0.2).min(0.0)); next.r_foot.scale = Vec3::one(); next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_z(0.0) diff --git a/voxygen/src/anim/character/climb.rs b/voxygen/src/anim/character/climb.rs index fc738e4ff5..463a4fdd0e 100644 --- a/voxygen/src/anim/character/climb.rs +++ b/voxygen/src/anim/character/climb.rs @@ -1,5 +1,6 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use common::comp::item::ToolKind; +use std::f32::consts::PI; use vek::*; pub struct ClimbAnimation; @@ -21,66 +22,69 @@ impl Animation for ClimbAnimation { *rate = speed; let constant = 1.0; - let wave = (anim_time as f32 * constant as f32 * 1.5).sin(); - let wave_cos = (anim_time as f32 * constant as f32 * 1.5).cos(); + let smooth = (anim_time as f32 * constant as f32 * 1.5).sin(); + let smootha = (anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin(); - let wave_test = (((5.0) + let quick = (((5.0) / (0.6 + 4.0 * ((anim_time as f32 * constant as f32 * 1.5).sin()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * constant as f32 * 1.5).sin()); - let wave_testc = (((5.0) - / (0.6 + 4.0 * ((anim_time as f32 * constant as f32 * 1.5).cos()).powf(2.0 as f32))) + let quicka = (((5.0) + / (0.6 + + 4.0 + * ((anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin()) + .powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * constant as f32 * 1.5).cos()); + * ((anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin()); next.head.offset = Vec3::new( 0.0, -4.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 13.50 + wave_cos * 0.2, + skeleton_attr.neck_height + 13.50 + smootha * 0.2, ); - next.head.ori = Quaternion::rotation_z(wave * 0.1) + next.head.ori = Quaternion::rotation_z(smooth * 0.1) * Quaternion::rotation_x(0.6) - * Quaternion::rotation_y(wave_test * 0.1); + * Quaternion::rotation_y(quick * 0.1); next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new(0.0, 1.0, 5.0 + wave_cos * 1.1); - next.chest.ori = Quaternion::rotation_z(wave_test * 0.25) + next.chest.offset = Vec3::new(0.0, 1.0, 5.0 + smootha * 1.1); + next.chest.ori = Quaternion::rotation_z(quick * 0.25) * Quaternion::rotation_x(-0.15) - * Quaternion::rotation_y(wave_test * -0.12); + * Quaternion::rotation_y(quick * -0.12); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, 1.0, -2.0); - next.belt.ori = Quaternion::rotation_z(wave_test * 0.0) * Quaternion::rotation_x(0.0); + next.belt.ori = Quaternion::rotation_z(quick * 0.0) * Quaternion::rotation_x(0.0); next.belt.scale = Vec3::one(); next.shorts.offset = Vec3::new(0.0, 1.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(wave_test * 0.0) + next.shorts.ori = Quaternion::rotation_z(quick * 0.0) * Quaternion::rotation_x(0.1) - * Quaternion::rotation_y(wave_test * 0.10); + * Quaternion::rotation_y(quick * 0.10); next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new(-6.0, -0.25 + wave_testc * 1.5, 6.0 - wave_test * 4.0); - next.l_hand.ori = Quaternion::rotation_x(2.2 + wave_testc * 0.5); + next.l_hand.offset = Vec3::new(-6.0, -0.25 + quicka * 1.5, 6.0 - quick * 4.0); + next.l_hand.ori = Quaternion::rotation_x(2.2 + quicka * 0.5); next.l_hand.scale = Vec3::one(); - next.r_hand.offset = Vec3::new(6.0, -0.25 - wave_testc * 1.5, 6.0 + wave_test * 4.0); - next.r_hand.ori = Quaternion::rotation_x(2.2 - wave_testc * 0.5); + next.r_hand.offset = Vec3::new(6.0, -0.25 - quicka * 1.5, 6.0 + quick * 4.0); + next.r_hand.ori = Quaternion::rotation_x(2.2 - quicka * 0.5); next.r_hand.scale = Vec3::one(); - next.l_foot.offset = Vec3::new(-3.4, 1.0, 6.0 + wave_test * 2.5); - next.l_foot.ori = Quaternion::rotation_x(0.2 - wave_testc * 0.5); + next.l_foot.offset = Vec3::new(-3.4, 1.0, 6.0 + quick * 2.5); + next.l_foot.ori = Quaternion::rotation_x(0.2 - quicka * 0.5); next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new(3.4, 1.0, 6.0 - wave_test * 2.5); - next.r_foot.ori = Quaternion::rotation_x(0.2 + wave_testc * 0.5); + next.r_foot.offset = Vec3::new(3.4, 1.0, 6.0 - quick * 2.5); + next.r_foot.ori = Quaternion::rotation_x(0.2 + quicka * 0.5); next.r_foot.scale = Vec3::one(); next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); - next.l_shoulder.ori = Quaternion::rotation_x(wave_cos * 0.15); + next.l_shoulder.ori = Quaternion::rotation_x(smootha * 0.15); next.l_shoulder.scale = Vec3::one() * 1.1; next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7); - next.r_shoulder.ori = Quaternion::rotation_x(wave * 0.15); + next.r_shoulder.ori = Quaternion::rotation_x(smooth * 0.15); next.r_shoulder.scale = Vec3::one() * 1.1; next.glider.offset = Vec3::new(0.0, 5.0, 0.0); @@ -92,8 +96,7 @@ impl Animation for ClimbAnimation { -5.0 + skeleton_attr.weapon_y, 18.0, ); - next.main.ori = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_cos * 0.25); + next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + smootha * 0.25); next.main.scale = Vec3::one(); next.second.offset = Vec3::new( @@ -108,7 +111,7 @@ impl Animation for ClimbAnimation { next.lantern.ori = Quaternion::rotation_x(0.0); next.lantern.scale = Vec3::one() * 0.0; - next.torso.offset = Vec3::new(0.0, -0.2 + wave * -0.08, 0.4) * skeleton_attr.scaler; + next.torso.offset = Vec3::new(0.0, -0.2 + smooth * -0.08, 0.4) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; diff --git a/voxygen/src/anim/character/dash.rs b/voxygen/src/anim/character/dash.rs index 4840b3e3e2..05f64819c7 100644 --- a/voxygen/src/anim/character/dash.rs +++ b/voxygen/src/anim/character/dash.rs @@ -20,7 +20,6 @@ impl Animation for DashAnimation { ) -> Self::Skeleton { *rate = 1.0; let mut next = (*skeleton).clone(); - let constant = 8.0; let lab = 1.0; let foot = (((5.0) @@ -33,11 +32,6 @@ impl Animation for DashAnimation { .sqrt()) * ((anim_time as f32 * lab as f32 * 12.4).sin()); - let wave_cos = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 2.4).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * constant as f32 * 1.5).sin()); - match active_tool_kind { //TODO: Inventory Some(ToolKind::Sword(_)) => { @@ -51,7 +45,7 @@ impl Animation for DashAnimation { * Quaternion::rotation_y(0.0); next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 2.0); + next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + slow * 2.0); next.chest.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.7); next.chest.scale = Vec3::one(); diff --git a/voxygen/src/anim/character/gliding.rs b/voxygen/src/anim/character/gliding.rs index d58f0a1b5a..50df85942c 100644 --- a/voxygen/src/anim/character/gliding.rs +++ b/voxygen/src/anim/character/gliding.rs @@ -20,12 +20,12 @@ impl Animation for GlidingAnimation { let speed = Vec2::::from(velocity).magnitude(); - let wave_slow = (anim_time as f32 * 7.0).sin(); - let wave_slow_cos = (anim_time as f32 * 7.0).cos(); + let quick = (anim_time as f32 * 7.0).sin(); + let quicka = (anim_time as f32 * 7.0 + PI / 2.0).sin(); let wave_stop = (anim_time as f32 * 1.5).min(PI / 2.0).sin(); - let wave_very_slow = (anim_time as f32 * 3.0).sin(); - let wave_very_slow_alt = (anim_time as f32 * 2.5).sin(); - let wave_very_slow_cos = (anim_time as f32 * 3.0).cos(); + let slow = (anim_time as f32 * 3.0).sin(); + let slowb = (anim_time as f32 * 3.0 + PI).sin(); + let slowa = (anim_time as f32 * 3.0 + PI / 2.0).sin(); let head_look = Vec2::new( ((global_time + anim_time) as f32 / 4.0) @@ -60,48 +60,40 @@ impl Animation for GlidingAnimation { -2.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 12.0, ); - next.head.ori = Quaternion::rotation_x(0.35 - wave_very_slow * 0.10 + head_look.y) - * Quaternion::rotation_z(head_look.x + wave_very_slow_cos * 0.15); + next.head.ori = Quaternion::rotation_x(0.35 - slow * 0.10 + head_look.y) + * Quaternion::rotation_z(head_look.x + slowa * 0.15); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, -2.0); - next.chest.ori = Quaternion::rotation_z(wave_very_slow_cos * 0.2); + next.chest.ori = Quaternion::rotation_z(slowa * 0.2); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = Quaternion::rotation_z(wave_very_slow_cos * 0.25); + next.belt.ori = Quaternion::rotation_z(slowa * 0.25); next.belt.scale = Vec3::one(); next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(wave_very_slow_cos * 0.35); + next.shorts.ori = Quaternion::rotation_z(slowa * 0.35); next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new( - -9.5 + wave_very_slow_cos * -1.5, - -3.0 + wave_very_slow_cos * 1.5, - 6.0, - ); - next.l_hand.ori = Quaternion::rotation_x(-2.7 + wave_very_slow_cos * -0.1); + next.l_hand.offset = Vec3::new(-9.5 + slowa * -1.5, -3.0 + slowa * 1.5, 6.0); + next.l_hand.ori = Quaternion::rotation_x(-2.7 + slowa * -0.1); next.l_hand.scale = Vec3::one(); - next.r_hand.offset = Vec3::new( - 9.5 + wave_very_slow_cos * -1.5, - -3.0 + wave_very_slow_cos * -1.5, - 6.0, - ); - next.r_hand.ori = Quaternion::rotation_x(-2.7 + wave_very_slow_cos * -0.10); + next.r_hand.offset = Vec3::new(9.5 + slowa * -1.5, -3.0 + slowa * -1.5, 6.0); + next.r_hand.ori = Quaternion::rotation_x(-2.7 + slowa * -0.10); next.r_hand.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, 1.0, -2.0); next.l_foot.ori = Quaternion::rotation_x( - (wave_stop * -0.7 - wave_slow_cos * -0.21 + wave_very_slow * 0.19) * speed * 0.04, + (wave_stop * -0.7 - quicka * -0.21 + slow * 0.19) * speed * 0.04, ); next.l_foot.scale = Vec3::one(); next.r_foot.offset = Vec3::new(3.4, 1.0, -2.0); next.r_foot.ori = Quaternion::rotation_x( - (wave_stop * -0.8 + wave_slow * -0.25 + wave_very_slow_alt * 0.13) * speed * 0.04, + (wave_stop * -0.8 + quick * -0.25 + slowb * 0.13) * speed * 0.04, ); next.r_foot.scale = Vec3::one(); @@ -113,9 +105,8 @@ impl Animation for GlidingAnimation { next.r_shoulder.ori = Quaternion::rotation_x(0.0); next.r_shoulder.scale = Vec3::one() * 1.1; - next.glider.offset = Vec3::new(0.0, -13.0 + wave_very_slow * 0.10, 6.0); - next.glider.ori = - Quaternion::rotation_x(1.0) * Quaternion::rotation_y(wave_very_slow_cos * 0.04); + next.glider.offset = Vec3::new(0.0, -13.0 + slow * 0.10, 6.0); + next.glider.ori = Quaternion::rotation_x(1.0) * Quaternion::rotation_y(slowa * 0.04); next.glider.scale = Vec3::one(); next.main.offset = Vec3::new( @@ -139,7 +130,7 @@ impl Animation for GlidingAnimation { next.lantern.scale = Vec3::one() * 0.0; next.torso.offset = Vec3::new(0.0, 6.0, 15.0) / 11.0 * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(-0.05 * speed.max(12.0) + wave_very_slow * 0.10) + next.torso.ori = Quaternion::rotation_x(-0.05 * speed.max(12.0) + slow * 0.10) * Quaternion::rotation_y(tilt * 16.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; diff --git a/voxygen/src/anim/character/idle.rs b/voxygen/src/anim/character/idle.rs index 810fe88151..4ef9a75a3e 100644 --- a/voxygen/src/anim/character/idle.rs +++ b/voxygen/src/anim/character/idle.rs @@ -17,39 +17,25 @@ impl Animation for IdleAnimation { ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); - let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI).cos(); - let wave_ultra_slow_abs = ((anim_time as f32 * 0.5 + PI).sin()) + 1.0; + let wave_ultra_slow = (anim_time as f32 * 1.0).sin(); + let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI / 2.0).sin(); + let head_abs = ((anim_time as f32 * 0.5 + PI).sin()) + 1.0; - /*let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 12.0) - .floor() - .mul(7331.0) - .sin() - * 0.5, - ((global_time + anim_time) as f32 / 12.0) - .floor() - .mul(1337.0) - .sin() - * 0.25, - );*/ next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -2.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 14.0 + wave_ultra_slow * 0.1, + skeleton_attr.neck_height + 14.0 + wave_ultra_slow * 0.1 + head_abs * -0.5, ); - /*next.head.ori = - Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs());*/ - next.head.scale = Vec3::one() * skeleton_attr.head_scale; + next.head.scale = Vec3::one() * skeleton_attr.head_scale - head_abs * 0.05; next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_ultra_slow * 0.1); next.chest.ori = Quaternion::rotation_x(0.0); - next.chest.scale = Vec3::one() + wave_ultra_slow_abs * 0.05; + next.chest.scale = Vec3::one() + head_abs * 0.05; next.belt.offset = Vec3::new(0.0, 0.0, -2.0 + wave_ultra_slow * 0.1); next.belt.ori = Quaternion::rotation_x(0.0); - next.belt.scale = Vec3::one() + wave_ultra_slow_abs * 0.05; + next.belt.scale = Vec3::one() - head_abs * 0.05; next.shorts.offset = Vec3::new(0.0, 0.0, -5.0 + wave_ultra_slow * 0.1); next.shorts.ori = Quaternion::rotation_x(0.0); @@ -67,10 +53,10 @@ impl Animation for IdleAnimation { next.r_hand.offset = Vec3::new( 7.0, -0.25 + wave_ultra_slow_cos * 0.15, - 5.0 + wave_ultra_slow * 0.5 + wave_ultra_slow_abs * -0.05, + 5.0 + wave_ultra_slow * 0.5 + head_abs * -0.05, ); next.r_hand.ori = Quaternion::rotation_x(0.0 + wave_ultra_slow * -0.06); - next.r_hand.scale = Vec3::one() + wave_ultra_slow_abs * -0.05; + next.r_hand.scale = Vec3::one() + head_abs * -0.05; next.l_foot.offset = Vec3::new(-3.4, -0.1, 8.0); next.l_foot.ori = Quaternion::identity(); @@ -82,11 +68,11 @@ impl Animation for IdleAnimation { next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 5.0); next.l_shoulder.ori = Quaternion::rotation_x(0.0); - next.l_shoulder.scale = (Vec3::one() + wave_ultra_slow_abs * -0.05) * 1.15; + next.l_shoulder.scale = (Vec3::one() + head_abs * -0.05) * 1.15; next.r_shoulder.offset = Vec3::new(5.0, 0.0, 5.0); next.r_shoulder.ori = Quaternion::rotation_x(0.0); - next.r_shoulder.scale = (Vec3::one() + wave_ultra_slow_abs * -0.05) * 1.15; + next.r_shoulder.scale = (Vec3::one() + head_abs * -0.05) * 1.15; next.glider.offset = Vec3::new(0.0, 5.0, 0.0); next.glider.ori = Quaternion::rotation_y(0.0); @@ -98,7 +84,7 @@ impl Animation for IdleAnimation { 18.0, ); next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); - next.main.scale = Vec3::one() + wave_ultra_slow_abs * -0.05; + next.main.scale = Vec3::one() + head_abs * -0.05; next.second.offset = Vec3::new( 0.0 + skeleton_attr.weapon_x, diff --git a/voxygen/src/anim/character/jump.rs b/voxygen/src/anim/character/jump.rs index 0e536dd855..ba90251487 100644 --- a/voxygen/src/anim/character/jump.rs +++ b/voxygen/src/anim/character/jump.rs @@ -4,7 +4,6 @@ use std::f32::consts::PI; use vek::*; pub struct JumpAnimation; - impl Animation for JumpAnimation { type Dependency = (Option, f64); type Skeleton = CharacterSkeleton; @@ -17,17 +16,16 @@ impl Animation for JumpAnimation { skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let wave = (anim_time as f32 * 14.0).sin(); - let wave_slow = (anim_time as f32 * 7.0).sin(); - let wave_stop = (anim_time as f32 * 4.5).min(PI / 2.0).sin(); - let wave_stop_alt = (anim_time as f32 * 5.0).min(PI / 2.0).sin(); + let quick = (anim_time as f32 * 14.0).sin(); + let slow = (anim_time as f32 * 7.0).sin(); + let stop = (anim_time as f32 * 1.5).min(PI / 2.0).sin(); next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -3.0 + skeleton_attr.neck_forward, skeleton_attr.neck_height + 13.0, ); - next.head.ori = Quaternion::rotation_x(0.25 + wave_stop * 0.1 + wave_slow * 0.04); + next.head.ori = Quaternion::rotation_x(0.25 + stop * 0.1 + slow * 0.04); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new(0.0, 0.0, 8.0); @@ -43,37 +41,37 @@ impl Animation for JumpAnimation { next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new( - -6.0 + wave_stop * -1.8, - -0.25 + wave_stop * 1.7, - 2.0 + wave_stop * 3.2 - wave * 0.4, + -6.0 + stop * -1.8, + -0.25 + stop * 2.0, + 2.0 + stop * 3.2 - quick * 0.4, ); - next.l_hand.ori = Quaternion::rotation_x(wave_stop_alt * 1.2 + wave_slow * 0.2) - * Quaternion::rotation_y(wave_stop_alt * 0.2); + next.l_hand.ori = + Quaternion::rotation_x(stop * 1.2 + slow * 0.3) * Quaternion::rotation_y(stop * 0.2); next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new( - 6.0 + wave_stop * 1.8, - -0.25 + wave_stop * -1.7, - 2.0 + wave_stop * 3.2 - wave * 0.4, + 6.0 + stop * 1.8, + -0.25 + stop * -2.0, + 2.0 + stop * 3.2 - quick * 0.4, ); - next.r_hand.ori = Quaternion::rotation_x(-wave_stop_alt * 1.2 + wave_slow * -0.2) - * Quaternion::rotation_y(wave_stop_alt * -0.2); + next.r_hand.ori = + Quaternion::rotation_x(-stop * 1.2 + slow * -0.3) * Quaternion::rotation_y(stop * -0.2); next.r_hand.scale = Vec3::one(); next.l_foot.offset = Vec3::new(-3.4, 1.0, 6.0); - next.l_foot.ori = Quaternion::rotation_x(wave_stop * -1.2 + wave_slow * -0.2); + next.l_foot.ori = Quaternion::rotation_x(stop * -1.2 + slow * -0.3); next.l_foot.scale = Vec3::one(); next.r_foot.offset = Vec3::new(3.4, -1.0, 6.0); - next.r_foot.ori = Quaternion::rotation_x(wave_stop * 1.2 + wave_slow * 0.2); + next.r_foot.ori = Quaternion::rotation_x(stop * 1.2 + slow * 0.3); next.r_foot.scale = Vec3::one(); next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); - next.l_shoulder.ori = Quaternion::rotation_x(wave_stop_alt * 0.3); + next.l_shoulder.ori = Quaternion::rotation_x(stop * 0.3); next.l_shoulder.scale = Vec3::one() * 1.1; next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7); - next.r_shoulder.ori = Quaternion::rotation_x(-wave_stop_alt * 0.3); + next.r_shoulder.ori = Quaternion::rotation_x(-stop * 0.3); next.r_shoulder.scale = Vec3::one() * 1.1; next.glider.offset = Vec3::new(0.0, 0.0, 10.0); diff --git a/voxygen/src/anim/character/sit.rs b/voxygen/src/anim/character/sit.rs index 5027adf884..4dadd1e095 100644 --- a/voxygen/src/anim/character/sit.rs +++ b/voxygen/src/anim/character/sit.rs @@ -18,12 +18,10 @@ impl Animation for SitAnimation { ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let wave_slow = (anim_time as f32 * 1.0 + PI).sin(); - let wave_slow_cos = (anim_time as f32 * 1.0 + PI).cos(); - let wave_stop = (anim_time as f32 * 3.0).min(PI / 2.0).sin(); - let wave_slow_abs = ((anim_time as f32 * 0.5 + PI).sin()) + 1.0; - let wave_ultra_slow = (anim_time as f32 * 0.3 + PI).sin(); - let wave_ultra_slow_cos = (anim_time as f32 * 0.3 + PI).cos(); + let slow = (anim_time as f32 * 1.0).sin(); + let slowa = (anim_time as f32 * 1.0 + PI / 2.0).sin(); + let stop = (anim_time as f32 * 3.0).min(PI / 2.0).sin(); + let slow_abs = ((anim_time as f32 * 0.3).sin()) + 1.0; let head_look = Vec2::new( ((global_time + anim_time) as f32 / 18.0) @@ -40,68 +38,48 @@ impl Animation for SitAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 14.0 + wave_slow * 0.1 + wave_stop * -0.8, + skeleton_attr.neck_height + 14.0 + slow * 0.1 + stop * -0.8, ); - next.head.ori = - Quaternion::rotation_z(head_look.x + wave_ultra_slow * 0.2 - wave_slow * 0.1) - * Quaternion::rotation_x( - (wave_ultra_slow_cos * -0.2 + wave_slow * 0.1 + head_look.y).abs(), - ); + next.head.ori = Quaternion::rotation_z(head_look.x + slow * 0.2 - slow * 0.1) + * Quaternion::rotation_x((slowa * -0.1 + slow * 0.1 + head_look.y).abs()); next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new( - 0.0, - wave_stop * -0.4, - 7.0 + wave_slow * 0.1 + wave_stop * -0.8, - ); - next.chest.ori = Quaternion::rotation_x(wave_stop * 0.15); - next.chest.scale = Vec3::one() + wave_slow_abs * 0.05; + next.chest.offset = Vec3::new(0.0, stop * -0.4, 7.0 + slow * 0.1 + stop * -0.8); + next.chest.ori = Quaternion::rotation_x(stop * 0.15); + next.chest.scale = Vec3::one() + slow_abs * 0.05; - next.belt.offset = Vec3::new(0.0, wave_stop * 1.2, -2.0); - next.belt.ori = Quaternion::rotation_x(wave_stop * 0.3); - next.belt.scale = (Vec3::one() + wave_slow_abs * 0.05) * 1.02; + next.belt.offset = Vec3::new(0.0, stop * 1.2, -2.0); + next.belt.ori = Quaternion::rotation_x(stop * 0.3); + next.belt.scale = (Vec3::one() + slow_abs * 0.05) * 1.02; - next.shorts.offset = Vec3::new(0.0, wave_stop * 2.5, -5.0 + wave_stop * 0.6); - next.shorts.ori = Quaternion::rotation_x(wave_stop * 0.6); + next.shorts.offset = Vec3::new(0.0, stop * 2.5, -5.0 + stop * 0.6); + next.shorts.ori = Quaternion::rotation_x(stop * 0.6); next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new( - -6.0, - -0.25 + wave_ultra_slow_cos * 0.15, - 7.0 + wave_ultra_slow * 0.7 + wave_stop * -2.0, - ); + next.l_hand.offset = Vec3::new(-6.0, -0.25 + slowa * 0.15, 6.0 + slow * 0.7 + stop * -2.0); - next.l_hand.ori = - Quaternion::rotation_x(0.0 + wave_slow_cos * -0.1 + wave_ultra_slow * 0.1); - next.l_hand.scale = Vec3::one() + wave_slow_abs * -0.05; + next.l_hand.ori = Quaternion::rotation_x(0.0 + slowa * -0.1 + slow * 0.1); + next.l_hand.scale = Vec3::one() + slow_abs * -0.05; - next.r_hand.offset = Vec3::new( - 6.0, - -0.25 + wave_ultra_slow_cos * 0.15, - 7.0 + wave_ultra_slow * 0.7 + wave_stop * -2.0, - ); - next.r_hand.ori = - Quaternion::rotation_x(0.0 + wave_slow * -0.1 + wave_ultra_slow_cos * 0.1); - next.r_hand.scale = Vec3::one() + wave_slow_abs * -0.05; + next.r_hand.offset = Vec3::new(6.0, -0.25 + slowa * 0.15, 6.0 + slow * 0.7 + stop * -2.0); + next.r_hand.ori = Quaternion::rotation_x(0.0 + slow * -0.1 + slowa * 0.1); + next.r_hand.scale = Vec3::one() + slow_abs * -0.05; next.l_foot.offset = Vec3::new(-3.4, -0.1, 8.0); - next.l_foot.ori = - Quaternion::rotation_x(wave_slow * 0.1 + wave_stop * 1.2 + wave_ultra_slow * 0.1); + next.l_foot.ori = Quaternion::rotation_x(slow * 0.1 + stop * 1.2 + slow * 0.1); next.l_foot.scale = Vec3::one(); next.r_foot.offset = Vec3::new(3.4, -0.1, 8.0); - next.r_foot.ori = Quaternion::rotation_x( - wave_slow_cos * 0.1 + wave_stop * 1.2 + wave_ultra_slow_cos * 0.1, - ); + next.r_foot.ori = Quaternion::rotation_x(slowa * 0.1 + stop * 1.2 + slowa * 0.1); next.r_foot.scale = Vec3::one(); next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7); next.l_shoulder.ori = Quaternion::rotation_x(0.0); - next.l_shoulder.scale = (Vec3::one() + wave_slow_abs * -0.05) * 1.15; + next.l_shoulder.scale = (Vec3::one() + slow_abs * -0.05) * 1.15; next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7); next.r_shoulder.ori = Quaternion::rotation_x(0.0); - next.r_shoulder.scale = (Vec3::one() + wave_slow_abs * -0.05) * 1.15; + next.r_shoulder.scale = (Vec3::one() + slow_abs * -0.05) * 1.15; next.glider.offset = Vec3::new(0.0, 5.0, 0.0); next.glider.ori = Quaternion::rotation_y(0.0); @@ -113,7 +91,7 @@ impl Animation for SitAnimation { 15.0, ); next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); - next.main.scale = Vec3::one() + wave_slow_abs * -0.05; + next.main.scale = Vec3::one() + slow_abs * -0.05; next.second.offset = Vec3::new( 0.0 + skeleton_attr.weapon_x, @@ -127,7 +105,7 @@ impl Animation for SitAnimation { next.lantern.ori = Quaternion::rotation_x(0.0); next.lantern.scale = Vec3::one() * 0.0; - next.torso.offset = Vec3::new(0.0, -0.2, wave_stop * -0.16) * skeleton_attr.scaler; + next.torso.offset = Vec3::new(0.0, -0.2, stop * -0.16) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; diff --git a/voxygen/src/anim/character/stand.rs b/voxygen/src/anim/character/stand.rs index b82658edb6..74b77ff306 100644 --- a/voxygen/src/anim/character/stand.rs +++ b/voxygen/src/anim/character/stand.rs @@ -36,23 +36,23 @@ impl Animation for StandAnimation { next.head.offset = Vec3::new( 0.0 + skeleton_attr.neck_right, -3.0 + skeleton_attr.neck_forward, - skeleton_attr.neck_height + 14.0 + slow * 0.3, //21 + skeleton_attr.neck_height + 14.0 + slow * 0.3 + breathe * -0.05, ); next.head.ori = Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; + next.head.scale = Vec3::one() * skeleton_attr.head_scale + breathe * -0.05; next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + slow * 0.3); next.chest.ori = Quaternion::rotation_z(head_look.x * 0.6); - next.chest.scale = Vec3::one() * 1.01; + next.chest.scale = Vec3::one() * 1.01 + breathe * 0.05; next.belt.offset = Vec3::new(0.0, 0.0, -2.0); //5 next.belt.ori = Quaternion::rotation_z(head_look.x * -0.1); - next.belt.scale = Vec3::one() + breathe * 0.05; + next.belt.scale = Vec3::one() + breathe * -0.05; next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); //2 next.shorts.ori = Quaternion::rotation_x(head_look.x * -0.2); - next.shorts.scale = Vec3::one(); + next.shorts.scale = Vec3::one() + breathe * -0.05; next.l_hand.offset = Vec3::new(-7.0, -0.25 + slow * 0.15, 5.0 + slow * 0.5); From bb293c44426c349805767ce134af15f34ab3bb55 Mon Sep 17 00:00:00 2001 From: Jack Rubino Date: Sun, 1 Mar 2020 16:07:35 +0000 Subject: [PATCH 298/326] Add Italian translation --- .../haxrcorp_4089_cyrillic_altgr_extended.ttf | 4 +- assets/voxygen/i18n/it.ron | 45 +++---------------- 2 files changed, 9 insertions(+), 40 deletions(-) diff --git a/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf b/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf index 28a2f56603..55115781c0 100644 --- a/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf +++ b/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e9fe6b6694620909217869f4f3fdce28d9ce9e5f0720c5a601903c95669dc428 -size 22120 +oid sha256:a926033dce94d9b8f86011fbdf2e32c07fc952363cbcd1d840939c47bf74f386 +size 23628 diff --git a/assets/voxygen/i18n/it.ron b/assets/voxygen/i18n/it.ron index 7099e32f5c..75d8b7a9de 100644 --- a/assets/voxygen/i18n/it.ron +++ b/assets/voxygen/i18n/it.ron @@ -20,7 +20,7 @@ VoxygenLocalization( language_identifier: "it", ), convert_utf8_to_ascii: false, - fonts: { + fonts: { "opensans": Font ( asset_key: "voxygen.font.OpenSans-Regular", scale_ratio: 1.0, @@ -285,7 +285,7 @@ Goditi il tuo soggiorno nel Mondo di Veloren."#, "hud.settings.general": "Generale", "hud.settings.none": "Nessuno", - "hud.settings.press_behavior.toggle": "Attiva/Disattiva" + "hud.settings.press_behavior.toggle": "Attiva/Disattiva", "hud.settings.press_behavior.hold": "Tieni Premuto", "hud.settings.help_window": "Finestra di Aiuto", "hud.settings.debug_info": "Informazioni di Debug", @@ -317,7 +317,7 @@ Goditi il tuo soggiorno nel Mondo di Veloren."#, "hud.settings.zoom_sensitivity": "Sensibilità Zoom", "hud.settings.invert_scroll_zoom": "Zoom Invertito", "hud.settings.invert_mouse_y_axis": "Asse Y del Mouse Invertito", - "hud.settings.free_look_behavior": "Comportamento Visuale Libera" + "hud.settings.free_look_behavior": "Comportamento Visuale Libera", @@ -355,58 +355,40 @@ Attiva/Disattiva Nomi Attiva/Disattiva Schermo Intero - - Movimento in Avanti Movimento a Sinistra Movimento a Destra Movimento all’Indietro - Salto - Aliante - Schivata - Rotolata - Scalata - Discesa - Camminata Automatica - Riporre/Sfoderare Armi - Mettere/Rimuovere Elmo - Sedersi - Cavalcatura - Interagire - - Attacco Base Attacco Secondario/Parata/Mira - - Slot 1 Barra delle Abilità Slot 2 Barra delle Abilità Slot 3 Barra delle Abilità @@ -419,8 +401,6 @@ Slot 9 Barra delle Abilità Slot 10 Barra delle Abilità - - Menù di Pausa Impostazioni Social @@ -432,23 +412,15 @@ Borsa - - - Invia Messaggio nella Chat Scorrimento della Chat - - Camera Libera Comandi della Chat: - - - /alias [Name] - Cambia il tuo Nome nella Chat /tp [Name] - Ti teleporta da un altro giocatore /jump - Devia la tua posizione @@ -456,10 +428,7 @@ Comandi della Chat: /kill - Suicidati /pig - Fai apparire un maiale PNG /wolf - Fai apparire un lupo PNG -/help - Mostra comandi della Chat - - -"#, +/help - Mostra comandi della Chat"#, @@ -468,7 +437,7 @@ Comandi della Chat: "hud.social.online": "Online", "hud.social.friends": "Amici", "hud.social.not_yet_available": "Non ancora disponibile", - "hud.social.Faction": "Fazione", + "hud.social.faction": "Fazione", "hud.social.play_online_fmt": "{nb_player} giocatore/i online", @@ -476,7 +445,7 @@ Comandi della Chat: "hud.spell": "Incantesimo", - "hud.free_look_indicator": "Visuale Libera Attiva" + "hud.free_look_indicator": "Visuale Libera Attiva", /// End HUD section @@ -556,4 +525,4 @@ Volontà "esc_menu.quit_game": "Esci dal Gioco", /// End Escape Menu Section } -) \ No newline at end of file +) From ff56e5f9f950f1480455ec550daa9b56c116cc14 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 29 Mar 2020 14:00:05 -0400 Subject: [PATCH 299/326] fireball damage tweaks/staff shooting anim --- voxygen/src/anim/character/charge.rs | 27 +++++++++++++++++++-------- voxygen/src/anim/character/shoot.rs | 2 +- voxygen/src/anim/character/wield.rs | 7 +++---- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/voxygen/src/anim/character/charge.rs b/voxygen/src/anim/character/charge.rs index 522513860f..bb6e3b168b 100644 --- a/voxygen/src/anim/character/charge.rs +++ b/voxygen/src/anim/character/charge.rs @@ -1,5 +1,6 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use common::comp::item::ToolKind; +use std::f32::consts::PI; use vek::*; pub struct ChargeAnimation; @@ -30,15 +31,21 @@ impl Animation for ChargeAnimation { .sqrt()) * ((anim_time as f32 * lab as f32 * 8.0).sin()); let stress = (((5.0) - / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 10.0).cos()).powf(2.0 as f32))) + / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 20.0).cos()).powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * lab as f32 * 20.0).cos()); let quick = (((5.0) - / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 2.0).cos()).powf(2.0 as f32))) + / (3.5 + 1.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32))) .sqrt()) - * ((anim_time as f32 * lab as f32 * 2.0).cos()); - + * ((anim_time as f32 * lab as f32 * 8.0).sin()); + let quicka = (((5.0) + / (3.5 + + 1.5 + * ((anim_time as f32 * lab as f32 * 8.0 + PI / 2.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 8.0 + PI / 2.0).sin()); let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2); + let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0); next.head.offset = Vec3::new( 0.0 + stop * -2.0 + skeleton_attr.neck_right, @@ -75,16 +82,20 @@ impl Animation for ChargeAnimation { * Quaternion::rotation_y(0.5) * Quaternion::rotation_z(-0.27); next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(11.0, 9.0, 10.0); + next.main.offset = Vec3::new(9.2, 8.4, 13.2); next.main.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(3.14 + 0.3) * Quaternion::rotation_z(0.9); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-7.0, 6.0, 6.0 - quick * 5.0); - next.control.ori = Quaternion::rotation_x(quick * 1.3) + next.control.offset = Vec3::new( + -7.0 + quick * 3.5 * (1.0 / (stopa + 0.1)), + 6.0 + quicka * 3.5 * (1.0 / (stopa + 0.1)), + 6.0 - stop * 3.0, + ); + next.control.ori = Quaternion::rotation_x(stop * -0.2) * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(quick * 1.5); + * Quaternion::rotation_z(stop * 0.2); next.control.scale = Vec3::one(); }, Some(ToolKind::Bow(_)) => { diff --git a/voxygen/src/anim/character/shoot.rs b/voxygen/src/anim/character/shoot.rs index 07ed08bcfe..26f0d6c443 100644 --- a/voxygen/src/anim/character/shoot.rs +++ b/voxygen/src/anim/character/shoot.rs @@ -67,7 +67,7 @@ impl Animation for ShootAnimation { * Quaternion::rotation_y(0.5) * Quaternion::rotation_z(-0.27); next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(11.0, 9.0, 10.0); + next.main.offset = Vec3::new(9.2, 8.4, 13.2); next.main.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(3.14 + 0.3) * Quaternion::rotation_z(0.9); diff --git a/voxygen/src/anim/character/wield.rs b/voxygen/src/anim/character/wield.rs index 05e61b67a2..a35edb4b6c 100644 --- a/voxygen/src/anim/character/wield.rs +++ b/voxygen/src/anim/character/wield.rs @@ -1,7 +1,6 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use common::comp::item::ToolKind; use std::{f32::consts::PI, ops::Mul}; - use vek::*; pub struct WieldAnimation; @@ -96,15 +95,15 @@ impl Animation for WieldAnimation { * Quaternion::rotation_y(0.5) * Quaternion::rotation_z(-0.27); next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(11.0, 9.0, 10.0); + next.main.offset = Vec3::new(9.2, 8.4, 13.2); next.main.ori = Quaternion::rotation_x(-0.3) * Quaternion::rotation_y(3.14 + 0.3) * Quaternion::rotation_z(0.9); next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.offset = Vec3::new(-14.0, 1.8, 3.0); next.control.ori = Quaternion::rotation_x(ultra_slow * 0.2) - * Quaternion::rotation_y(0.0) + * Quaternion::rotation_y(-0.2) * Quaternion::rotation_z(ultra_slow_cos * 0.1); next.control.scale = Vec3::one(); }, From dcc9d44b1cd6d5b24f2d0ba995899119c8981e26 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sun, 29 Mar 2020 13:40:03 -0700 Subject: [PATCH 300/326] remove unused timed_combo --- common/src/comp/ability.rs | 19 +--- common/src/comp/character_state.rs | 5 -- common/src/states/mod.rs | 1 - common/src/states/timed_combo.rs | 130 --------------------------- common/src/sys/character_behavior.rs | 2 - voxygen/src/scene/figure/mod.rs | 16 ---- 6 files changed, 1 insertion(+), 172 deletions(-) delete mode 100644 common/src/states/timed_combo.rs diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index eb98cf0227..0c98b9641b 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -41,11 +41,6 @@ pub enum CharacterAbility { }, BasicBlock, Roll, - TimedCombo { - buildup_duration: Duration, - recover_duration: Duration, - base_damage: u32, - }, TripleStrike { base_damage: u32, needs_timing: bool, @@ -57,7 +52,7 @@ impl CharacterAbility { /// applicable. pub fn requirements_paid(&self, data: &JoinData, update: &mut StateUpdate) -> bool { match self { - CharacterAbility::TimedCombo { .. } | CharacterAbility::TripleStrike { .. } => { + CharacterAbility::TripleStrike { .. } => { data.physics.on_ground && data.body.is_humanoid() && data.inputs.look_dir.xy().magnitude_squared() > 0.01 @@ -169,18 +164,6 @@ impl From<&CharacterAbility> for CharacterState { remaining_duration: Duration::from_millis(500), was_wielded: false, // false by default. utils might set it to true }), - CharacterAbility::TimedCombo { - buildup_duration, - recover_duration, - base_damage, - } => CharacterState::TimedCombo(timed_combo::Data { - buildup_duration: *buildup_duration, - recover_duration: *recover_duration, - stage: 0, - stage_exhausted: false, - stage_time_active: Duration::default(), - base_damage: *base_damage, - }), CharacterAbility::TripleStrike { base_damage, needs_timing, diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 36bc0fe8c0..6cc4f90e12 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -56,9 +56,6 @@ pub enum CharacterState { Boost(boost::Data), /// Dash forward and then attack DashMelee(dash_melee::Data), - /// A three-stage attack where play must click at appropriate times - /// to continue attack chain. - TimedCombo(timed_combo::Data), /// A three-stage attack where each attack pushes player forward /// and successive attacks increase in damage, while player holds button. TripleStrike(triple_strike::Data), @@ -72,7 +69,6 @@ impl CharacterState { | CharacterState::BasicRanged(_) | CharacterState::DashMelee(_) | CharacterState::TripleStrike(_) - | CharacterState::TimedCombo(_) | CharacterState::BasicBlock => true, _ => false, } @@ -89,7 +85,6 @@ impl CharacterState { match self { CharacterState::BasicMelee(_) | CharacterState::BasicRanged(_) - | CharacterState::TimedCombo(_) | CharacterState::DashMelee(_) | CharacterState::TripleStrike(_) => true, _ => false, diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 1dcf09c211..e6294bcb69 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -9,7 +9,6 @@ pub mod glide; pub mod idle; pub mod roll; pub mod sit; -pub mod timed_combo; pub mod triple_strike; pub mod utils; pub mod wielding; diff --git a/common/src/states/timed_combo.rs b/common/src/states/timed_combo.rs deleted file mode 100644 index 5d0a873dcb..0000000000 --- a/common/src/states/timed_combo.rs +++ /dev/null @@ -1,130 +0,0 @@ -use crate::{ - comp::{Attacking, CharacterState, EnergySource, StateUpdate}, - sys::character_behavior::{CharacterBehavior, JoinData}, -}; -use std::time::Duration; -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct Data { - /// Denotes what stage (of 3) the attack is in - pub stage: i8, - /// Whether current stage has exhausted its attack - pub stage_exhausted: bool, - /// How long state waits before it should deal damage - pub buildup_duration: Duration, - /// How long the state waits until exiting - pub recover_duration: Duration, - /// Tracks how long current stage has been active - pub stage_time_active: Duration, - /// Base damage - pub base_damage: u32, -} - -impl CharacterBehavior for Data { - fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - - let new_stage_time_active = self - .stage_time_active - .checked_add(Duration::from_secs_f32(data.dt.0)) - .unwrap_or(Duration::default()); - - if self.stage < 3 { - // Build up window - if new_stage_time_active < self.buildup_duration { - // If the player is pressing primary btn - if data.inputs.primary.is_just_pressed() { - // They failed, go back to `Wielding` - update.character = CharacterState::Wielding; - } - // Keep updating - else { - update.character = CharacterState::TimedCombo(Data { - stage: self.stage, - buildup_duration: self.buildup_duration, - recover_duration: self.recover_duration, - stage_exhausted: false, - stage_time_active: new_stage_time_active, - base_damage: self.base_damage, - }); - } - } - // Hit attempt window - else if !self.stage_exhausted { - // Swing hits - data.updater.insert(data.entity, Attacking { - base_healthchange: -((self.base_damage * (self.stage as u32 + 1)) as i32), - range: 3.5, - max_angle: 75_f32.to_radians(), - applied: false, - hit_count: 0, - knockback: 0.0, - }); - - update.character = CharacterState::TimedCombo(Data { - stage: self.stage, - buildup_duration: self.buildup_duration, - recover_duration: self.recover_duration, - stage_exhausted: true, - stage_time_active: new_stage_time_active, - base_damage: self.base_damage, - }); - } - // Swing recovery window - else if new_stage_time_active - < self - .buildup_duration - .checked_add(self.recover_duration) - .unwrap_or(Duration::default()) - { - // Try to transition to next stage - if data.inputs.primary.is_just_pressed() { - update.character = CharacterState::TimedCombo(Data { - stage: self.stage + 1, - buildup_duration: self.buildup_duration, - recover_duration: self.recover_duration, - stage_exhausted: true, - stage_time_active: Duration::default(), - base_damage: self.base_damage, - }); - } - // Player didn't click this frame - else { - // Update state - update.character = CharacterState::TimedCombo(Data { - stage: self.stage, - buildup_duration: self.buildup_duration, - recover_duration: self.recover_duration, - stage_exhausted: true, - stage_time_active: new_stage_time_active, - base_damage: self.base_damage, - }); - } - } - // Stage expired but missed transition to next stage - else { - // Back to `Wielding` - update.character = CharacterState::Wielding; - // Make sure attack component is removed - data.updater.remove::(data.entity); - } - } - // Made three successful hits! - else { - println!("Success!"); - // Back to `Wielding` - update.character = CharacterState::Wielding; - // Make sure attack component is removed - data.updater.remove::(data.entity); - } - - // Grant energy on successful hit - if let Some(attack) = data.attacking { - if attack.applied && attack.hit_count > 0 { - data.updater.remove::(data.entity); - update.energy.change_by(100, EnergySource::HitEnemy); - } - } - - update - } -} diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 2dff358eae..1882879954 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -213,7 +213,6 @@ impl<'a> System<'a> for Sys { CharacterState::BasicRanged(data) => data.handle_event(&j, action), CharacterState::Boost(data) => data.handle_event(&j, action), CharacterState::DashMelee(data) => data.handle_event(&j, action), - CharacterState::TimedCombo(data) => data.handle_event(&j, action), }; local_emitter.append(&mut state_update.local_events); server_emitter.append(&mut state_update.server_events); @@ -236,7 +235,6 @@ impl<'a> System<'a> for Sys { CharacterState::BasicRanged(data) => data.behavior(&j), CharacterState::Boost(data) => data.behavior(&j), CharacterState::DashMelee(data) => data.behavior(&j), - CharacterState::TimedCombo(data) => data.behavior(&j), }; local_emitter.append(&mut state_update.local_events); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index e77402be01..5fa3f1e485 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -549,22 +549,6 @@ impl FigureMgr { ) }, }, - CharacterState::TimedCombo(s) => match s.stage { - 0 | 2 => anim::character::AlphaAnimation::update_skeleton( - &target_base, - (active_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ), - _ => anim::character::DashAnimation::update_skeleton( - &target_base, - (active_tool_kind, time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ), - }, CharacterState::BasicBlock { .. } => { anim::character::BlockIdleAnimation::update_skeleton( &CharacterSkeleton::new(), From aa59e8715d6616fa6658c987246e5a9243de91c0 Mon Sep 17 00:00:00 2001 From: Mckol Date: Mon, 30 Mar 2020 15:45:22 +0200 Subject: [PATCH 301/326] Updated Cargo.lock to fix vek not compiling --- Cargo.lock | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 062ed9b6f7..71815ff909 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -682,9 +682,9 @@ dependencies = [ [[package]] name = "const-tweaker" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b51e91181af416a58123da1cebf00d2e600296f358d0d69aa14df63956d2753e" +checksum = "8a7081900ff8f4b89046f8898eb8af6ed26be5a47299c56147d5a7dac74298b0" dependencies = [ "anyhow", "async-std", @@ -698,9 +698,9 @@ dependencies = [ [[package]] name = "const-tweaker-attribute" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cef233d59741e1a93f0363145fe412bd13f64df1827c6c5d709c9403e081fc" +checksum = "1a43d28ffebd3bb949c8c274de94fb84826134a023c5e6dac528c38a0f1cf1ba" dependencies = [ "darling", "proc-macro2 1.0.9", @@ -4847,7 +4847,8 @@ checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" [[package]] name = "vek" version = "0.9.12" -source = "git+https://github.com/Imberflur/vek?branch=is_normalized#7442254deb67ad6930bedc671057d14ea8e885eb" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b833a133490ae98e9e3db1c77fc28e844f8e51b12eb35b4ab8a2082cb7cb441a" dependencies = [ "approx 0.1.1", "num-integer", @@ -5442,3 +5443,8 @@ name = "xml-rs" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" + +[[patch.unused]] +name = "vek" +version = "0.10.0" +source = "git+https://github.com/Imberflur/vek?branch=is_normalized#43bef0a9e953fbf6b00a073aef914c48b784c995" From abc1a041faaa4e0c08a846127f61938a04bbad55 Mon Sep 17 00:00:00 2001 From: Capucho Date: Fri, 27 Mar 2020 16:11:47 +0000 Subject: [PATCH 302/326] Added a portuguese translation --- CHANGELOG.md | 2 + .../haxrcorp_4089_cyrillic_altgr_extended.ttf | 4 +- assets/voxygen/i18n/en.ron | 1 + assets/voxygen/i18n/pt_PT.ron | 372 ++++++++++++++++++ voxygen/src/menu/main/ui.rs | 2 +- 5 files changed, 378 insertions(+), 3 deletions(-) create mode 100644 assets/voxygen/i18n/pt_PT.ron diff --git a/CHANGELOG.md b/CHANGELOG.md index a579276f06..341d89117a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added gamepad/controller support - Added player feedback when attempting to pickup an item with a full inventory - Added free look +- Added Italian translation +- Added Portuguese translation ### Changed diff --git a/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf b/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf index 55115781c0..8a611f6cfa 100644 --- a/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf +++ b/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a926033dce94d9b8f86011fbdf2e32c07fc952363cbcd1d840939c47bf74f386 -size 23628 +oid sha256:63aa82d178492b48fadb3ed79c2d508dcf3f4cb1297bdb8450eb6fe3278c6a42 +size 25284 diff --git a/assets/voxygen/i18n/en.ron b/assets/voxygen/i18n/en.ron index cdcad13db1..cafbce0178 100644 --- a/assets/voxygen/i18n/en.ron +++ b/assets/voxygen/i18n/en.ron @@ -62,6 +62,7 @@ VoxygenLocalization( "common.back": "Back", "common.create": "Create", "common.okay": "Okay", + "common.accept": "Accept", "common.disclaimer": "Disclaimer", "common.cancel": "Cancel", "common.none": "None", diff --git a/assets/voxygen/i18n/pt_PT.ron b/assets/voxygen/i18n/pt_PT.ron new file mode 100644 index 0000000000..a29d45f147 --- /dev/null +++ b/assets/voxygen/i18n/pt_PT.ron @@ -0,0 +1,372 @@ +/// Localization for portuguese (Portugal) +VoxygenLocalization( + metadata: ( + language_name: "Português", + language_identifier: "pt_PT", + ), + convert_utf8_to_ascii: false, + fonts: { + "opensans": Font ( + asset_key: "voxygen.font.OpenSans-Regular", + scale_ratio: 1.0, + ), + "metamorph": Font ( + asset_key: "voxygen.font.Metamorphous-Regular", + scale_ratio: 1.0, + ), + "alkhemi": Font ( + asset_key: "voxygen.font.Alkhemikal", + scale_ratio: 1.0, + ), + "wizard": Font ( + asset_key: "voxygen.font.wizard", + scale_ratio: 1.0, + ), + "cyri": Font ( + asset_key: "voxygen.font.haxrcorp_4089_cyrillic_altgr_extended", + scale_ratio: 1.0, + ), + }, + string_map: { + /// Start Common section + // Texts used in multiple locations with the same formatting + "common.username": "nome de utilizador", + "common.singleplayer": "Um jogador", + "common.multiplayer": "Multijogador", + "common.servers": "Servidores", + "common.quit": "Sair", + "common.settings": "Definições", + "common.languages": "Linguagens", + "common.interface": "Interface", + "common.gameplay": "Jogabilidade", + "common.controls": "Controlos", + "common.video": "Video", + "common.sound": "Som", + "common.resume": "Resumir", + "common.characters": "Personagens", + "common.close": "Fechar", + "common.yes": "Sim", + "common.no": "Não", + "common.back": "Voltar", + "common.create": "Criar", + "common.okay": "Okay", + "common.accept": "Aceitar", + "common.disclaimer": "Aviso", + "common.cancel": "Cancelar", + "common.none": "Nenhum", + "common.error": "Erro", + "common.fatal_error": "Erro fatal", + + // Message when connection to the server is lost + "common.connection_lost": r#"Conexâo perdida! +Será que o server reiniciou? +O cliente está atualizado?"#, + + + "common.races.orc": "Ogre", + "common.races.human": "Humano", + "common.races.dwarf": "Anão", + "common.races.elf": "Elfo", + "common.races.undead": "Morto-vivo", + "common.races.danari": "Danari", + + "common.weapons.axe": "Machado", + "common.weapons.sword": "Espada", + "common.weapons.staff": "Cajado", + "common.weapons.bow": "Arco", + "common.weapons.hammer": "Martelo", + /// End Common section + + + /// Start Main screen section + "main.connecting": "Conectando", + "main.creating_world": "Criando o mundo", + + // Welcome notice that appears the first time Veloren is started + "main.notice": r#"Bem vindo a versão alpha de Veloren! + +Antes de começar a jogar, por favor tenha em mente que: + +- Isto é uma versão muito experimental. Prepare-se para defeitos, jogabilidade muito inacabada, mecanismos por polir e funcionalidades por +adicionar. +- Se tiver comentários construtivos ou defeitos para reportar, pode contactar-nos através do Reddit, GitLab ou o nosso servidor comunitário de +Discord. +- Veloren está licenciado sob a licensa código aberto GPL 3. Isto significa que pode jogar, modificar e redistribuir como quiser + (Contanto que o trabalho derivado seja também GPL 3). +- Veloren é um projeto comunitário sem lucro, e toda a gente que trabalha nele é um voluntário. Se gostar do que ve, considere juntar-se a equipa +de desenvolvimento ou a de artes! +- 'Voxel RPG' é um género em si mesmo. First-person shooters costumavam ser chamados de clones do DOOM. + +Tal como eles, nós estamos a tentar construir um género. Este jogo não é um clone e o seu desenvolvimento vai divergir de jogos existentes no +futuro. + +Obrigado por ler este aviso, nós esperamos que goste do jogo! + +~ A equipa do Veloren"#, + + // Login process description + "main.login_process": r#"Informação sobre o processo de Login: + +Se tiver problemas a logar: + +Tenha em atenção que é necessário uma conta +para jogar em servidores com autenticação. + +Para criar uma conta navegue até + +https://account.veloren.net."#, + "main.login.server_not_found": "Servidor não encontrado", + "main.login.authentication_error": "Erro de autenticação", + "main.login.server_full": "Servidor está cheio", + "main.login.untrusted_auth_server": "Server de autenticação não confiado", + "main.login.outdated_client_or_server": "Servidor endoideceu: Provavelmente as versões são incompativéis, verifique se há versões mais recentes.", + "main.login.timeout": "Tempo esgotado: O servidor não respondeu a tempo. (Sobrecarregado ou problemas de rede).", + "main.login.server_shut_down": "O servidor encerrou", + "main.login.already_logged_in": "Vocé ja está logado neste servidor.", + "main.login.network_error": "Error de rede", + "main.login.failed_sending_request": "Pedido ao servidor de autenticação falhou", + "main.login.client_crashed": "O cliente crashou", + + /// End Main screen section + + + /// Start HUD Section + "hud.do_not_show_on_startup": "Não mostre no início", + "hud.show_tips": "Mostrar dicas", + "hud.quests": "Missões", + "hud.you_died": "Você Morreu", + + "hud.press_key_to_show_keybindings_fmt": "Clique em {key} para mostrar as teclas mapeadas", + "hud.press_key_to_show_debug_info_fmt": "Clique em {key} para mostrar a informação de depuração", + "hud.press_key_to_toggle_keybindings_fmt": "Clique em {key} para mostrar/ocultar as teclas mapeadas", + "hud.press_key_to_toggle_debug_info_fmt": "Clique em {key} para mostrar/ocultar a informação de depuração", + + // Respawn message + "hud.press_key_to_respawn": r#"Clique em {key} para renascer na última fogueira visitada."#, + + // Welcome message + "hud.welcome": r#"Bem vindo a Alpha do Veloren!, + + +Algumas dicas antes de começar: + + +MAIS IMPORTANTE: Para definir o seu local de renascimento escreva /waypoint no chat. + +Isto também pode ser realizado depois de morto! + + +Clique em F1 para ver as teclas mapeadas. + +Escreva /help no chat para ver os comandos de chat + + +A muitos baús e outros objetos a aperecer no mundo aleatoriamente! + +Pressione o botão direito do mouse pare coletá-los. + +Para usar o que coletou basta abrir o inventário pressionando a tecla 'B'. + +Faça duplo clique nos items para usá-los ou equipá-los. + +Deite-os fora cliquando uma vez neles e depois outra fora do inventário. + + +As noites podem ser bastante escuras. + +Acenda a lanterna escrevendo /lantern no chat. + + +Quer libertar o mouse para fechar esta janela? Clique em TAB! + + +Aprecie a sua estadia no mundo de Veloren."#, + + "hud.settings.general": "Geral", + "hud.settings.none": "Nenhum", + "hud.settings.press_behavior.toggle": "Alternar", + "hud.settings.press_behavior.hold": "Segurar", + "hud.settings.help_window": "Janela de ajuda", + "hud.settings.debug_info": "Informação de depuração", + "hud.settings.tips_on_startup": "Dicas no início", + "hud.settings.ui_scale": "Escala da interface", + "hud.settings.relative_scaling": "Escala relativa", + "hud.settings.custom_scaling": "Escala customizada", + "hud.settings.crosshair": "Crosshair", + "hud.settings.transparency": "Transparência", + "hud.settings.hotbar": "Hotbar", + "hud.settings.toggle_shortcuts": "Mostar/Ocultar atalhos", + "hud.settings.toggle_bar_experience": "Mostar/Ocultar barra de experiência", + "hud.settings.scrolling_combat_text": "Texto de combate deslizante", + "hud.settings.single_damage_number": "Números de dano únicos", + "hud.settings.cumulated_damage": "Dano acumulado", + "hud.settings.incoming_damage": "Dano recebido", + "hud.settings.cumulated_incoming_damage": "Dano recebido acumulado", + "hud.settings.energybar_numbers": "Números da barra de energia", + "hud.settings.values": "Valores", + "hud.settings.percentages": "Percentagens", + "hud.settings.chat": "Chat", + "hud.settings.background_transparency": "Transparência do fundo", + + "hud.settings.pan_sensitivity": "Sensibilidade de rotação", + "hud.settings.zoom_sensitivity": "Sensibilidade de zoom", + "hud.settings.invert_scroll_zoom": "Inverter scroll zoom", + "hud.settings.invert_mouse_y_axis": "Inverter o eixo Y do mouse", + "hud.settings.free_look_behavior": "Ativação de rotação livre", + + "hud.settings.view_distance": "Alcance de visão", + "hud.settings.maximum_fps": "FPS máximo", + "hud.settings.fov": "Campo de visão(graus)", + "hud.settings.gamma": "Luminosidade", + "hud.settings.antialiasing_mode": "Modo de antialiasing", + "hud.settings.cloud_rendering_mode": "Modo de representação de nuvens", + "hud.settings.fluid_rendering_mode": "Modo de representação de fluídos", + "hud.settings.fluid_rendering_mode.cheap": "Barato", + "hud.settings.fluid_rendering_mode.shiny": "Brilhante", + "hud.settings.cloud_rendering_mode.regular": "Normal", + "hud.settings.fullscreen": "Tela cheia", + "hud.settings.save_window_size": "Gravar dimensões", + + "hud.settings.music_volume": "Volume da música", + "hud.settings.sound_effect_volume": "Volume dos efeitos sonoros", + "hud.settings.audio_device": "Dispositivo de aúdio", + + // Control list + "hud.settings.control_names": r#"Libertar mouse +Mostar/Ocultar janela de ajuda +Mostar/Ocultar interface +Mostar/Ocultar FPS e informação de depuração +Gravar captura de ecrã +Mostar/Ocultar nomes +Mostar/Ocultar tela cheia + + +Mover para frente +Mover para a esquerda +Mover para a direita +Mover para trás + +Saltar + +Planador + +Desviar + +Rolar + +Trepar + +Descer + +Auto caminhar + +Embainhar/sacar armas + +Equipar/remover capacete + +Sentar + +Montar + +Interagir + + +Ataque básico +Ataque/bloquear/apontar secundário + + +Habilidade 1 +Habilidade 2 +Habilidade 3 +Habilidade 4 +Habilidade 5 +Habilidade 6 +Habilidade 7 +Habilidade 8 +Habilidade 9 +Habilidade 10 + + +Menu de pausa +Definições +Social +Mapa +Livro de feitiços +Personagem +Registo de missões +Inventário + + + +Enviar mensagem de chat +Scroll chat + + +Comandos de chat: + +/alias [nome] - Mudar o seu nome de chat +/tp [nome] - Teletransporta-te para outro player +/jump - Deslocar a posição +/goto - Teletransporta-te para a posição +/kill - Suicidar +/pig - Invocar NPC de porco +/wolf - Invocar NPC do lobo +/help - Mostrar comandos de chat"#, + + "hud.social": "Social", + "hud.social.online": "Online", + "hud.social.friends": "Amigos", + "hud.social.not_yet_available": "Indisponível de momento", + "hud.social.faction": "Facção", + "hud.social.play_online_fmt": "{nb_player} jogador(es) online", + + "hud.spell": "Feitiço", + + "hud.free_look_indicator": "Rotação livre ativada", + /// End HUD section + + + /// Start chracter selection section + "char_selection.delete_permanently": "Deletar esta personagem permanentemente?", + "char_selection.change_server": "Mudar de servidor", + "char_selection.enter_world": "Entrar no mundo", + "char_selection.logout": "Desconectar", + "char_selection.create_new_charater": "Criar nova personagem", + "char_selection.character_creation": "Criação de personagem", + + "char_selection.human_default": "Humano padrão", + "char_selection.level_fmt": "Nível {level_nb}", + "char_selection.uncanny_valley": "Vale da estranheza", + "char_selection.plains_of_uncertainty": "Planícies da incerteza", + "char_selection.beard": "Barba", + "char_selection.hair_style": "Estilo do cabelo", + "char_selection.hair_color": "Cor do cabelo", + "char_selection.chest_color": "Cor do peitoral", + "char_selection.eye_color": "Cor dos olhos", + "char_selection.skin": "Cor da pele", + "char_selection.eyebrows": "Pestanas", + "char_selection.accessories": "Acessórios", + + /// End chracter selection section + + + /// Start character window section + "character_window.character_name": "Nome da personagem", + // Charater stats + "character_window.character_stats": r#"Resistência + +Aptidão fisíca + +Força de vontade +"#, + + + /// Start character window section + + + /// Start Escape Menu Section + "esc_menu.logout": "Desconectar", + "esc_menu.quit_game": "Sair do jogo", + /// End Escape Menu Section + } +) diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index 8832cc7e59..25ed23f3df 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -428,7 +428,7 @@ impl MainMenuUi { .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) .label_y(Relative::Scalar(2.0)) - .label("Accept") + .label(&self.voxygen_i18n.get("common.accept")) .label_font_size(self.fonts.cyri.scale(22)) .label_color(TEXT_COLOR) .label_font_id(self.fonts.cyri.conrod_id) From 3f1f9b9ab0eb374e9479bb1b7b97e191adf1f824 Mon Sep 17 00:00:00 2001 From: Capucho Date: Mon, 30 Mar 2020 22:00:46 +0100 Subject: [PATCH 303/326] Make so that the resume button doesn't eject the mouse --- voxygen/src/hud/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index af37606609..8147eef49b 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1948,8 +1948,8 @@ impl Hud { }, Some(esc_menu::Event::Close) => { self.show.esc_menu = false; - self.show.want_grab = false; - self.force_ungrab = true; + self.show.want_grab = true; + self.force_ungrab = false; // Unpause the game if we are on singleplayer if let Some(singleplayer) = global_state.singleplayer.as_ref() { From b3791a2b4e21c46f28c1200ef77ba9707f21b070 Mon Sep 17 00:00:00 2001 From: Imbris Date: Mon, 30 Mar 2020 19:44:51 -0400 Subject: [PATCH 304/326] Upgrade vek version so that it actually uses the patch --- Cargo.lock | 37 ++++++++++++++++++++---------- client/Cargo.toml | 2 +- common/Cargo.toml | 2 +- server/Cargo.toml | 2 +- voxygen/Cargo.toml | 2 +- voxygen/src/ui/graphic/renderer.rs | 26 ++++++++++++++++++--- world/Cargo.toml | 2 +- 7 files changed, 53 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 71815ff909..4466efcfbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1227,7 +1227,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c20f6684a8420df7c300a36bed7cb0b2387b2bc385d4940282399b5df0c08ebd" dependencies = [ - "vek", + "vek 0.9.12", ] [[package]] @@ -4242,6 +4242,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "stb_truetype" version = "0.3.1" @@ -4854,8 +4860,20 @@ dependencies = [ "num-integer", "num-traits 0.1.43", "rustc_version", + "static_assertions 0.2.5", +] + +[[package]] +name = "vek" +version = "0.10.0" +source = "git+https://github.com/Imberflur/vek?branch=is_normalized#43bef0a9e953fbf6b00a073aef914c48b784c995" +dependencies = [ + "approx 0.3.2", + "num-integer", + "num-traits 0.2.11", + "rustc_version", "serde", - "static_assertions", + "static_assertions 1.1.0", ] [[package]] @@ -4880,7 +4898,7 @@ dependencies = [ "num_cpus", "specs", "uvth", - "vek", + "vek 0.10.0", "veloren-common", ] @@ -4913,7 +4931,7 @@ dependencies = [ "specs", "specs-idvs", "sum_type", - "vek", + "vek 0.10.0", ] [[package]] @@ -4938,7 +4956,7 @@ dependencies = [ "specs", "specs-idvs", "uvth", - "vek", + "vek 0.10.0", "veloren-common", "veloren-world", ] @@ -4996,7 +5014,7 @@ dependencies = [ "specs-idvs", "treeculler", "uvth", - "vek", + "vek 0.10.0", "veloren-client", "veloren-common", "veloren-server", @@ -5030,7 +5048,7 @@ dependencies = [ "roots", "serde", "serde_derive", - "vek", + "vek 0.10.0", "veloren-common", ] @@ -5443,8 +5461,3 @@ name = "xml-rs" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" - -[[patch.unused]] -name = "vek" -version = "0.10.0" -source = "git+https://github.com/Imberflur/vek?branch=is_normalized#43bef0a9e953fbf6b00a073aef914c48b784c995" diff --git a/client/Cargo.toml b/client/Cargo.toml index 9d649f0b01..ad417fb0e3 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -13,6 +13,6 @@ image = "0.22.3" num_cpus = "1.10.1" log = "0.4.8" specs = "0.15.1" -vek = { version = "0.9.9", features = ["serde"] } +vek = { version = "0.10.0", features = ["serde"] } hashbrown = { version = "0.6.2", features = ["rayon", "serde", "nightly"] } authc = { git = "https://gitlab.com/veloren/auth.git", rev = "65571ade0d954a0e0bd995fdb314854ff146ab97" } diff --git a/common/Cargo.toml b/common/Cargo.toml index f70c8c1b6c..69d7217c7a 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -11,7 +11,7 @@ no-assets = [] specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git" } specs = { version = "0.15.1", features = ["serde", "nightly", "storage-event-control"] } -vek = { version = "0.9.9", features = ["serde"] } +vek = { version = "0.10.0", features = ["serde"] } dot_vox = "4.0.0" image = "0.22.3" mio = "0.6.19" diff --git a/server/Cargo.toml b/server/Cargo.toml index c86adf42d8..e93df3f701 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -16,7 +16,7 @@ specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git" } log = "0.4.8" specs = { version = "0.15.1", features = ["shred-derive"] } -vek = "0.9.9" +vek = "0.10.0" uvth = "3.1.1" lazy_static = "1.4.0" scan_fmt = "0.2.4" diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index b8224fa256..4938dc55a3 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -34,7 +34,7 @@ specs = "0.15.1" specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git" } # Mathematics -vek = { version = "0.9.9", features = ["serde"] } +vek = { version = "0.10.0", features = ["serde"] } # Controller gilrs = { version = "0.7", features = ["serde"] } diff --git a/voxygen/src/ui/graphic/renderer.rs b/voxygen/src/ui/graphic/renderer.rs index 653b386ce5..946b464a54 100644 --- a/voxygen/src/ui/graphic/renderer.rs +++ b/voxygen/src/ui/graphic/renderer.rs @@ -57,10 +57,30 @@ impl Vert { } } +#[derive(Clone, Copy)] +struct VsOut(Rgba); +impl euc::Interpolate for VsOut { + #[inline(always)] + fn lerp2(a: Self, b: Self, x: f32, y: f32) -> Self { + //a * x + b * y + Self(a.0.map2(b.0, |a, b| a.mul_add(x, b * y))) + } + + #[inline(always)] + fn lerp3(a: Self, b: Self, c: Self, x: f32, y: f32, z: f32) -> Self { + //a * x + b * y + c * z + Self( + a.0.map2(b.0.map2(c.0, |b, c| b.mul_add(y, c * z)), |a, bc| { + a.mul_add(x, bc) + }), + ) + } +} + impl<'a> Pipeline for Voxel { type Pixel = [u8; 4]; type Vertex = Vert; - type VsOut = Rgba; + type VsOut = VsOut; #[inline(always)] fn vert( @@ -75,12 +95,12 @@ impl<'a> Pipeline for Voxel { let light = Rgba::from_opaque(Rgb::from(*ao_level as f32 / 4.0 + 0.25)); let color = light * srgba_to_linear(Rgba::from_opaque(*col)); let position = (self.mvp * Vec4::from_point(*pos)).xyz().into_array(); - (position, color) + (position, VsOut(color)) } #[inline(always)] fn frag(&self, color: &Self::VsOut) -> Self::Pixel { - linear_to_srgba(*color) + linear_to_srgba(color.0) .map(|e| (e * 255.0) as u8) .into_array() } diff --git a/world/Cargo.toml b/world/Cargo.toml index 4dd4c22b71..0784d933a9 100644 --- a/world/Cargo.toml +++ b/world/Cargo.toml @@ -10,7 +10,7 @@ common = { package = "veloren-common", path = "../common" } bitvec = "0.15.2" image = "0.22.3" itertools = "0.8.2" -vek = "0.9.9" +vek = "0.10.0" noise = { version = "0.6.0", default-features = false } num = "0.2.0" ordered-float = "1.0" From c5331cbabe35bbd3b409d2641e4608e66077b37d Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Fri, 27 Mar 2020 20:28:46 +0300 Subject: [PATCH 305/326] Add Turkish (Turkey) translation file --- CHANGELOG.md | 1 + .../haxrcorp_4089_cyrillic_altgr_extended.ttf | 4 +- assets/voxygen/i18n/tr_TR.ron | 388 ++++++++++++++++++ 3 files changed, 391 insertions(+), 2 deletions(-) create mode 100644 assets/voxygen/i18n/tr_TR.ron diff --git a/CHANGELOG.md b/CHANGELOG.md index 341d89117a..c397eafe55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added free look - Added Italian translation - Added Portuguese translation +- Added Turkish translation ### Changed diff --git a/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf b/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf index 8a611f6cfa..f1287a32c0 100644 --- a/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf +++ b/assets/voxygen/font/haxrcorp_4089_cyrillic_altgr_extended.ttf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:63aa82d178492b48fadb3ed79c2d508dcf3f4cb1297bdb8450eb6fe3278c6a42 -size 25284 +oid sha256:4d2fcb65f9c3956f91ddebc350729221704c75b3559d120772d4c9bd1898d720 +size 26232 diff --git a/assets/voxygen/i18n/tr_TR.ron b/assets/voxygen/i18n/tr_TR.ron new file mode 100644 index 0000000000..8aaff2eef4 --- /dev/null +++ b/assets/voxygen/i18n/tr_TR.ron @@ -0,0 +1,388 @@ +/// Translation document instructions +/// +/// In order to keep localization documents readible please follow the following +/// rules: +/// - separate the string map sections using a commentary describing the purpose +/// of the next section +/// - prepend multi-line strings with a commentary +/// - append one blank lines after a multi-line strings and two after sections +/// +/// To add a new language in Veloren, just write an additional `.ron` file in +/// `assets/voxygen/i18n` and that's it! + +/// Localization for Turkish (Turkey) +VoxygenLocalization( + metadata: ( + language_name: "Türkçe (Türkiye)", + language_identifier: "tr_TR", + ), + convert_utf8_to_ascii: false, + fonts: { + "opensans": Font ( + asset_key: "voxygen.font.OpenSans-Regular", + scale_ratio: 1.0, + ), + "metamorph": Font ( + asset_key: "voxygen.font.Metamorphous-Regular", + scale_ratio: 1.0, + ), + "alkhemi": Font ( + asset_key: "voxygen.font.Alkhemikal", + scale_ratio: 1.0, + ), + "wizard": Font ( + asset_key: "voxygen.font.wizard", + scale_ratio: 1.0, + ), + "cyri": Font ( + asset_key: "voxygen.font.haxrcorp_4089_cyrillic_altgr_extended", + scale_ratio: 1.0, + ), + }, + string_map: { + /// Start Common section + // Texts used in multiple locations with the same formatting + "common.username": "kullanıcı adı", + "common.singleplayer": "Tek oyuncu", + "common.multiplayer": "Çok oyunculu", + "common.servers": "Sunucular", + "common.quit": "Çık", + "common.settings": "Ayarlar", + "common.languages": "Diller", + "common.interface": "Arayüz", + "common.gameplay": "Oynanış", + "common.controls": "Kontroller", + "common.video": "Video", + "common.sound": "Ses", + "common.resume": "Devam Et", + "common.characters": "Karakterler", + "common.close": "Kapat", + "common.yes": "Evet", + "common.no": "Hayır", + "common.back": "Geri", + "common.create": "Oluştur", + "common.okay": "Tamam", + "common.disclaimer": "Uyarı", + "common.cancel": "İptal Et", + "common.none": "Yok", + "common.error": "Hata", + "common.fatal_error": "Ölümcül hata", + "common.accept": "Kabul Et", + + // Message when connection to the server is lost + "common.connection_lost": r#"Bağlantı koptu! +Sunucu yeniden mi başladı? +İstemci güncel mi?"#, + + + "common.races.orc": "Ork", + "common.races.human": "İnsan", + "common.races.dwarf": "Cüce", + "common.races.elf": "Elf", + "common.races.undead": "Hortlak", + "common.races.danari": "Danari", + + "common.weapons.axe": "Balta", + "common.weapons.sword": "Kılıç", + "common.weapons.staff": "Asa", + "common.weapons.bow": "Yay", + "common.weapons.hammer": "Çekiç", + /// End Common section + + + /// Start Main screen section + "main.connecting": "Bağlanılıyor", + "main.creating_world": "Dünya oluşturuluyor", + + // Welcome notice that appears the first time Veloren is started + "main.notice": r#"Veloren Alfa sürümüne hoşgeldin! + +Eğlenmeye başlamadan önce, lütfen bir kaç şeyi aklında tut: + +- Bu alfa sürümü daha çok yeni. Hatalar, bitmemiş oynanış, elden geçirilmemiş mekanikler ve eksik özellikler bulunuyor. +- Yapıcı geri bildirim veya hata raporların varsa, bize Reddit, GitLab veya Discord sunucumuzdan ulaşabilirsin. +- Veloren GPL 3 açık kaynak lisansı ile lisanslıdır. Bunun anlamı, oyunu istediğin gibi oynayabilir, değiştirebilir ve dağıtabilirsin +(türetilmiş çalışmalarda GPL 3 ile lisanslanmış olduğu sürece) +- Veloren kar gütmeyen bir topluluk projesidir ve üzerinde çalışan herkes birer gönüllüdür. +Gördüklerini beğendiysen, geliştirme veya sanat takımlarına katılabilirsin! +- 'Voxel RPG' kendi başına bir tür. Birinci şahıs nişancı oyunları önceden Doom kopyaları olarak adlandırılıyordu. + +Bizde onlar gibi bir niş inşa etmeye çalışıyoruz. Bu oyun bir kopya değil ve gelecekte gelişimi mevcut oyunlardan ayrılacak. + +Bu bildiriyi okumaya zaman ayırdığın için teşekkür ederiz, umarız ki oyundan memnun kalırsın! + +~ Veloren Geliştiricileri"#, + + // Login process description + "main.login_process": r#"Giriş işlemi hakkında bilgi: + +Eğer giriş yaparken sorunlarla karşılaşıyorsan: + +Lütfen kimlik doğrulaması gerektiren sunucularda +oynamak için bir hesaba ihtiyacın olduğunu hatırla. + +https://account.veloren.net adresinden + +bir hesap oluşturabilirsin."#, + "main.login.server_not_found": "Sunucu bulunamadı", + "main.login.authentication_error": "Sunucuda kimlik doğrulama hatası", + "main.login.server_full": "Sunucu dolu", + "main.login.untrusted_auth_server": "Kimlik doğrulama sunucusu güvenilir değil", + "main.login.outdated_client_or_server": "SunucuÇılgınaDöndü: Muhtemelen versiyonlar uyuşmuyor, güncellemeler için kontrol et.", + "main.login.timeout": "Zamanaşımı: Sunucu zamanında cevap vermedi. (Aşırı yüklenme veya ağ sorunları).", + "main.login.server_shut_down": "Sunucu kapandı", + "main.login.already_logged_in": "Zaten sunucuya giriş yapmışsın.", + "main.login.network_error": "Ağ hatası", + "main.login.failed_sending_request": "Kimlik doğrulama sunucusuna istek gönderilemedi", + "main.login.client_crashed": "İstemci çöktü", + + /// End Main screen section + + + /// Start HUD Section + "hud.do_not_show_on_startup": "Bunu açılışta gösterme", + "hud.show_tips": "Öneriler", + "hud.quests": "Görevler", + "hud.you_died": "Öldün", + + "hud.press_key_to_show_keybindings_fmt": "Kontrolleri göstermek için {key}'e bas", + "hud.press_key_to_show_debug_info_fmt": "Hata ayıklama bilgilerini göstermek için {key}'e bas", + "hud.press_key_to_toggle_keybindings_fmt": "Kontrolleri açmak veya kapamak için {key}'e bas", + "hud.press_key_to_toggle_debug_info_fmt": "Hata ayıklama bilgilerini açmak veya kapamak için {key}'e bas", + + // Respawn message + "hud.press_key_to_respawn": r#"Ziyaret ettiğin en son kamp ateşinde yeniden doğmak için {key}'e bas."#, + + // Welcome message + "hud.welcome": r#"Veloren Alfa sürümüne hoşgeldin!, + + +Başlamadan önce bazı ipuçları: + + +EN ÖNEMLİSİ: Yeniden doğma noktanı ayarlamak için sohbete /waypoint yaz. + +Bu ölmüşsen bile yapılabilir! + + +Kontrolleri görmek için F1'e bas. + +Sohbet komutlarını görmek için sohbete /help yaz. + + +Dünyada rastgele oluşan sandıklar ve başka objeler var! + +Onları toplamak için Sağ-Tık kullan. + +Topladıklarını kullanmak için 'B'ye basarak envanterini aç. + +Envanterindeki eşyaları kullanmak veya kuşanmak için iki kere üzerlerine tıkla. + +Üzerlerine bir kere tıklayıp ve sonra envaterin dışına tıklayarak onları at. + + +Veloren'de geceler oldukça karanlık olabiliyor. + +Sohbete /lantern yazarak fenerini yak. + + +Bu pencereyi kapatmak için imlecini serbest bırakmak mı istiyorsun? TAB'a bas! + + +Veloren'in Dünyasında sana iyi eğlenceler!"#, + + "hud.settings.general": "Genel", + "hud.settings.none": "Yok", + "hud.settings.press_behavior.toggle": "Aç/kapa", + "hud.settings.press_behavior.hold": "Basılı tut", + "hud.settings.help_window": "Yardım Penceresi", + "hud.settings.debug_info": "Hata Ayıklama Bilgileri", + "hud.settings.tips_on_startup": "Açılışta İpuçlarını Göster", + "hud.settings.ui_scale": "Arayüz Ölçeği", + "hud.settings.relative_scaling": "Otomatik Ölçek", + "hud.settings.custom_scaling": "Özel Ölçek", + "hud.settings.crosshair": "İmleç tipi", + "hud.settings.transparency": "Şeffaflık", + "hud.settings.hotbar": "Hotbar", + "hud.settings.toggle_shortcuts": "Kısayolları aç/kapa", + "hud.settings.toggle_bar_experience": "Tecrübe çubuğunu aç/kapa", + "hud.settings.scrolling_combat_text": "Verilen/Alınan Hasar Yazısı", + "hud.settings.single_damage_number": "Verilen Hasarı Tek Tek Göster", + "hud.settings.cumulated_damage": "Toplam Verilen Hasarı Göster", + "hud.settings.incoming_damage": "Alınan Hasarı Tek Tek Göster", + "hud.settings.cumulated_incoming_damage": "Toplam Alınan Hasarı Göster", + "hud.settings.energybar_numbers": "Enerji çubuğu değerleri", + "hud.settings.values": "Sayılar", + "hud.settings.percentages": "Yüzdeler", + "hud.settings.chat": "Sohbet", + "hud.settings.background_transparency": "Arkaplan Şeffaflığı", + "hud.settings.none": "Yok", + + "hud.settings.pan_sensitivity": "Kaydırma Hassaslığı", + "hud.settings.zoom_sensitivity": "Büyütme Hassaslığı", + "hud.settings.invert_scroll_zoom": "Kaydırma Büyütmesini ters çevir", + "hud.settings.invert_mouse_y_axis": "Fare Y eksenini ters çevir", + "hud.settings.free_look_behavior": "Serbest bakış davranışı", + + "hud.settings.view_distance": "Görüş Mesafesi", + "hud.settings.maximum_fps": "Maksimum FPS", + "hud.settings.fov": "Görüş alanı (derece)", + "hud.settings.gamma": "Gama", + "hud.settings.antialiasing_mode": "Kenar Yumuşatma Modu", + "hud.settings.cloud_rendering_mode": "Bulut Render Modu", + "hud.settings.fluid_rendering_mode": "Su Render Modu", + "hud.settings.fluid_rendering_mode.cheap": "Ucuz", + "hud.settings.fluid_rendering_mode.shiny": "Güzel", + "hud.settings.cloud_rendering_mode.regular": "Normal", + "hud.settings.fullscreen": "Tam ekran", + "hud.settings.save_window_size": "Pencere boyutunu kaydet", + + "hud.settings.music_volume": "Müzik Sesi", + "hud.settings.sound_effect_volume": "Efekt Sesi", + "hud.settings.audio_device": "Ses Aygıtı", + + // Control list + "hud.settings.control_names": r#"İmleci serbest bırak +Yardım Pencerisini aç/kapa +Arayüzü aç/kapa +FPS ve hata ayıklama bilgilerini aç/kapa +Ekran görüntüsü al +İsim etiketlerini aç/kapa +Tam ekranı aç/kapa + + +İleri Git +Sola Git +Sağa Git +Geriye Git + +Zıpla + +Planör + +Sıçra + +Yuvarlan + +Tırman + +İn + +Otomatik yürüme + +Silahları koy/çıkar + +Kaskı kuşan/çıkar + +Otur + +Bin + +Etkileşim + + +Basit Saldırı +İkincil Saldırı/Blok/Nişan Alma + + +Yetenek çubuğu Slot 1 +Yetenek çubuğu Slot 2 +Yetenek çubuğu Slot 3 +Yetenek çubuğu Slot 4 +Yetenek çubuğu Slot 5 +Yetenek çubuğu Slot 6 +Yetenek çubuğu Slot 7 +Yetenek çubuğu Slot 8 +Yetenek çubuğu Slot 9 +Yetenek çubuğu Slot 10 + + +Duraklatma Menüsü +Ayarlar +Sosyal +Harita +Büyü kitabı +Karakter +Görev kaydı +Çanta + + + +Sohbet Mesajı Gönder +Sohbeti Kaydır + + +Serbest bakış + + +Sohbet komutları: + +/alias [İsim] - Sohbet İsmini değiştir +/tp [İsim] - Seni başka bir oyuncuya ışınlar +/jump - Pozisyonunu kaydır +/goto - Bir pozisyona ışınlan +/kill - Kendini öldür +/pig - Domuz NPC'si oluştur +/wolf - Kurt NPC'si oluştur +/help - Sohbet komutlarını göster"#, + + "hud.social": "Sosyal", + "hud.social.online": "Çevrimiçi", + "hud.social.friends": "Arkadaşlar", + "hud.social.not_yet_available": "Şu anda kullanılabilir değil", + "hud.social.faction": "Klan", + "hud.social.play_online_fmt": "{nb_player} oyuncu çevrimiçi", + + "hud.spell": "Büyü", + + "hud.free_look_indicator": "Serbest bakış açık", + /// End HUD section + + + /// Start chracter selection section + // Character delete question + "char_selection.delete_permanently": r#"Bu karakteri kalıcı olarak +silmek istediğinden emin misin?"#, + + "char_selection.change_server": "Sunucu Değiştir", + "char_selection.enter_world": "Dünyaya Gir", + "char_selection.logout": "Çıkış yap", + "char_selection.create_new_charater": "Yeni Karakter Oluştur", + "char_selection.character_creation": "Karakter Oluşumu", + + "char_selection.human_default": "İnsan Varsayılanı", + "char_selection.level_fmt": "Seviye {level_nb}", + "char_selection.uncanny_valley": "Esrarengiz Vadi", + "char_selection.plains_of_uncertainty": "Belirsizlik Ovaları", + "char_selection.beard": "Sakal", + "char_selection.hair_style": "Saç Stili", + "char_selection.hair_color": "Saç Rengi", + "char_selection.chest_color": "Göğüs Rengi", + "char_selection.eye_color": "Göz Rengi", + "char_selection.skin": "Deri", + "char_selection.eyebrows": "Kaşlar", + "char_selection.accessories": "Aksesuarlar", + + /// End chracter selection section + + + /// Start character window section + "character_window.character_name": "Karakter Adı", + // Charater stats + "character_window.character_stats": r#"Dayanıklılık + +Fiziksel yetenek + +İrade gücü +"#, + + + /// Start character window section + + + /// Start Escape Menu Section + "esc_menu.logout": "Çıkış yap", + "esc_menu.quit_game": "Oyundan çık", + /// End Escape Menu Section + } +) From c82d1b9316900e955320b79b3a33c654003b37b5 Mon Sep 17 00:00:00 2001 From: Marli Frost Date: Sat, 28 Mar 2020 13:12:35 +0000 Subject: [PATCH 306/326] allow the game to start without an audio device --- voxygen/src/audio/mod.rs | 7 ++----- voxygen/src/main.rs | 17 +++++++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/voxygen/src/audio/mod.rs b/voxygen/src/audio/mod.rs index 1709649c89..299a8c53fe 100644 --- a/voxygen/src/audio/mod.rs +++ b/voxygen/src/audio/mod.rs @@ -238,11 +238,8 @@ impl AudioFrontend { /// Returns the default audio device. /// Does not return rodio Device struct in case our audio backend changes. -pub fn get_default_device() -> String { - rodio::default_output_device() - .expect("No audio output devices detected.") - .name() - .expect("Unable to get device name") +pub fn get_default_device() -> Option { + rodio::default_output_device().map(|dev| dev.name().expect("Unable to get device name")) } /// Returns a vec of the audio devices available. diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index 43b6726ab6..f27beab1ff 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -44,15 +44,16 @@ fn main() { panic!("Failed to save settings: {:?}", err); } - let audio_device = || match &settings.audio.audio_device { - Some(d) => d.to_string(), - None => audio::get_default_device(), - }; + let audio_device = settings + .audio + .audio_device + .as_ref() + .map(|s| s.clone()) + .or_else(audio::get_default_device); - let mut audio = if settings.audio.audio_on { - AudioFrontend::new(audio_device(), settings.audio.max_sfx_channels) - } else { - AudioFrontend::no_audio() + let mut audio = match (audio_device, settings.audio.audio_on) { + (Some(dev), true) => AudioFrontend::new(dev, settings.audio.max_sfx_channels), + _ => AudioFrontend::no_audio() }; audio.set_music_volume(settings.audio.music_volume); From a83f09bd606b8bc1154fc54d291a54336996cb93 Mon Sep 17 00:00:00 2001 From: Marli Frost Date: Tue, 31 Mar 2020 18:02:26 +0100 Subject: [PATCH 307/326] fix: avoid rodio API when audio is disabled --- voxygen/src/main.rs | 24 ++++++++++++++---------- voxygen/src/settings.rs | 5 +++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index f27beab1ff..f874529d10 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -1,4 +1,5 @@ #![deny(unsafe_code)] +#![feature(bool_to_option)] #![recursion_limit = "2048"] use veloren_voxygen::{ @@ -44,17 +45,20 @@ fn main() { panic!("Failed to save settings: {:?}", err); } - let audio_device = settings + let mut audio = settings .audio - .audio_device - .as_ref() - .map(|s| s.clone()) - .or_else(audio::get_default_device); - - let mut audio = match (audio_device, settings.audio.audio_on) { - (Some(dev), true) => AudioFrontend::new(dev, settings.audio.max_sfx_channels), - _ => AudioFrontend::no_audio() - }; + .audio_on + .then(|| { + settings + .audio + .audio_device + .as_ref() + .map(Clone::clone) + .or_else(audio::get_default_device) + }) + .flatten() + .map(|dev| AudioFrontend::new(dev, settings.audio.max_sfx_channels)) + .unwrap_or_else(AudioFrontend::no_audio); audio.set_music_volume(settings.audio.music_volume); audio.set_sfx_volume(settings.audio.sfx_volume); diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index a8ce79e0b4..59583661e4 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -474,6 +474,11 @@ pub struct AudioSettings { /// Audio Device that Voxygen will use to play audio. pub audio_device: Option, + /// Veloren's audio system wont work on some systems, + /// so you can use this to disable it, and allow the + /// game to function + // If this option is disabled, functions in the rodio + // library MUST NOT be called. pub audio_on: bool, } From 3806f08eb00b51d78cd1ce9ff1dc38cc189b2591 Mon Sep 17 00:00:00 2001 From: Marli Frost Date: Tue, 31 Mar 2020 19:12:49 +0100 Subject: [PATCH 308/326] feat: configure audio output using an enum --- voxygen/src/main.rs | 23 ++++++++--------------- voxygen/src/menu/main/mod.rs | 2 +- voxygen/src/session.rs | 3 ++- voxygen/src/settings.rs | 30 +++++++++++++++++++++--------- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index f874529d10..72382f5ecd 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -8,7 +8,7 @@ use veloren_voxygen::{ logging, menu::main::MainMenuState, meta::Meta, - settings::Settings, + settings::{AudioOutput, Settings}, window::Window, Direction, GlobalState, PlayState, PlayStateResult, }; @@ -45,20 +45,13 @@ fn main() { panic!("Failed to save settings: {:?}", err); } - let mut audio = settings - .audio - .audio_on - .then(|| { - settings - .audio - .audio_device - .as_ref() - .map(Clone::clone) - .or_else(audio::get_default_device) - }) - .flatten() - .map(|dev| AudioFrontend::new(dev, settings.audio.max_sfx_channels)) - .unwrap_or_else(AudioFrontend::no_audio); + let mut audio = match settings.audio.output { + AudioOutput::Off => None, + AudioOutput::Automatic => audio::get_default_device(), + AudioOutput::Device(ref dev) => Some(dev.clone()), + } + .map(|dev| AudioFrontend::new(dev, settings.audio.max_sfx_channels)) + .unwrap_or_else(AudioFrontend::no_audio); audio.set_music_volume(settings.audio.music_volume); audio.set_sfx_volume(settings.audio.sfx_volume); diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index 145d8e9b16..3e873f048d 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -36,7 +36,7 @@ impl PlayState for MainMenuState { let mut client_init: Option = None; // Kick off title music - if global_state.settings.audio.audio_on && global_state.audio.music_enabled() { + if global_state.settings.audio.output.is_enabled() && global_state.audio.music_enabled() { global_state.audio.play_title_music(); } diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 335b06b21d..2f1220c070 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -6,6 +6,7 @@ use crate::{ menu::char_selection::CharSelectionState, render::Renderer, scene::{camera, Scene, SceneData}, + settings::AudioOutput, window::{AnalogGameInput, Event, GameInput}, Direction, Error, GlobalState, PlayState, PlayStateResult, }; @@ -613,7 +614,7 @@ impl PlayState for SessionState { HudEvent::ChangeAudioDevice(name) => { global_state.audio.set_device(name.clone()); - global_state.settings.audio.audio_device = Some(name); + global_state.settings.audio.output = AudioOutput::Device(name); global_state.settings.save_to_file_warn(); }, HudEvent::ChangeMaxFPS(fps) => { diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 59583661e4..e28132f592 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -461,7 +461,26 @@ impl Default for GraphicsSettings { } } } +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum AudioOutput { + /// Veloren's audio system wont work on some systems, + /// so you can use this to disable it, and allow the + /// game to function + // If this option is disabled, functions in the rodio + // library MUST NOT be called. + Off, + Automatic, + Device(String), +} +impl AudioOutput { + pub fn is_enabled(&self) -> bool { + match self { + Self::Off => false, + _ => true, + } + } +} /// `AudioSettings` controls the volume of different audio subsystems and which /// device is used. #[derive(Clone, Debug, Serialize, Deserialize)] @@ -473,13 +492,7 @@ pub struct AudioSettings { pub max_sfx_channels: usize, /// Audio Device that Voxygen will use to play audio. - pub audio_device: Option, - /// Veloren's audio system wont work on some systems, - /// so you can use this to disable it, and allow the - /// game to function - // If this option is disabled, functions in the rodio - // library MUST NOT be called. - pub audio_on: bool, + pub output: AudioOutput, } impl Default for AudioSettings { @@ -489,8 +502,7 @@ impl Default for AudioSettings { music_volume: 0.4, sfx_volume: 0.6, max_sfx_channels: 10, - audio_device: None, - audio_on: true, + output: AudioOutput::Automatic, } } } From 89f441ae2c2b62809124226d334710256fb5ef39 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 1 Apr 2020 06:23:26 -0700 Subject: [PATCH 309/326] Roll speed 15.0 -> 25.0 --- common/src/states/roll.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 259ebe5c49..292f81c7b2 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -6,7 +6,7 @@ use crate::{ use std::time::Duration; use vek::Vec3; -const ROLL_SPEED: f32 = 15.0; +const ROLL_SPEED: f32 = 25.0; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct Data { /// How long the state has until exiting From 56fab6db09907756981e8007dc0e41a14eb7ccf2 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 1 Apr 2020 06:24:02 -0700 Subject: [PATCH 310/326] Roll duration 500 -> 700ms --- common/src/comp/ability.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 0c98b9641b..5431c0d2f4 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -161,7 +161,7 @@ impl From<&CharacterAbility> for CharacterState { }), CharacterAbility::BasicBlock => CharacterState::BasicBlock, CharacterAbility::Roll => CharacterState::Roll(roll::Data { - remaining_duration: Duration::from_millis(500), + remaining_duration: Duration::from_millis(700), was_wielded: false, // false by default. utils might set it to true }), CharacterAbility::TripleStrike { From 95bc486f7c217d1fa9c7e1809235081439273257 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 1 Apr 2020 06:42:56 -0700 Subject: [PATCH 311/326] Roll move_dir handling 1.5 -> 0.25 --- common/src/states/roll.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/states/roll.rs b/common/src/states/roll.rs index 292f81c7b2..420f06cf0b 100644 --- a/common/src/states/roll.rs +++ b/common/src/states/roll.rs @@ -22,7 +22,7 @@ impl CharacterBehavior for Data { // Update velocity update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z) + (update.vel.0 * Vec3::new(1.0, 1.0, 0.0) - + 1.5 * data.inputs.move_dir.try_normalized().unwrap_or_default()) + + 0.25 * data.inputs.move_dir.try_normalized().unwrap_or_default()) .try_normalized() .unwrap_or_default() * ROLL_SPEED; From 237393993fececcf4815cc6937a35d4972750bcb Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 1 Apr 2020 06:43:28 -0700 Subject: [PATCH 312/326] triple_strike combo timing window 600 -> 400 --- common/src/states/triple_strike.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 5a670c1cab..7fcee69217 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -8,7 +8,7 @@ use vek::vec::Vec3; // In millis const STAGE_DURATION: u64 = 700; -const TIMING_WINDOW: u64 = 600; +const TIMING_WINDOW: u64 = 400; const INITIAL_ACCEL: f32 = 90.0; const BASE_SPEED: f32 = 25.0; From e04fdd715e8cca405930060eb50dbf334e4ebe3d Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 1 Apr 2020 07:07:10 -0700 Subject: [PATCH 313/326] expose and use blocking consts --- common/src/sys/combat.rs | 4 ++-- common/src/sys/mod.rs | 2 +- server/src/events/entity_manipulation.rs | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 5d7bbc69c0..02cc2f5c0a 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -9,8 +9,8 @@ use crate::{ use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; use vek::*; -const BLOCK_EFFICIENCY: f32 = 0.9; -const BLOCK_ANGLE: f32 = 180.0; +pub const BLOCK_EFFICIENCY: f32 = 0.9; +pub const BLOCK_ANGLE: f32 = 180.0; /// This system is responsible for handling accepted inputs like moving or /// attacking diff --git a/common/src/sys/mod.rs b/common/src/sys/mod.rs index 1e478ea87c..832dc37d63 100644 --- a/common/src/sys/mod.rs +++ b/common/src/sys/mod.rs @@ -1,6 +1,6 @@ pub mod agent; pub mod character_behavior; -mod combat; +pub mod combat; pub mod controller; mod mount; pub mod phys; diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 17231b07f1..59eb020f02 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -5,6 +5,7 @@ use common::{ msg::ServerMsg, state::BlockChange, sync::{Uid, WorldSyncExt}, + sys::combat::{BLOCK_ANGLE, BLOCK_EFFICIENCY}, terrain::{Block, TerrainGrid}, vol::{ReadVol, Vox}, }; @@ -12,9 +13,6 @@ use log::error; use specs::{join::Join, Entity as EcsEntity, WorldExt}; use vek::Vec3; -const BLOCK_EFFICIENCY: f32 = 0.9; -const BLOCK_ANGLE: f32 = 180.0; - pub fn handle_damage(server: &Server, uid: Uid, change: HealthChange) { let state = &server.state; let ecs = state.ecs(); From 0c4d428298a0c9a36f3733baa4b7495670199f82 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 1 Apr 2020 07:10:35 -0700 Subject: [PATCH 314/326] remove unnecessary line --- common/src/states/glide.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index d19ef9cd90..3e6759780d 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -54,8 +54,6 @@ impl CharacterBehavior for Data { .max(0.2); } - // Otherwise keep gliding - update.character = CharacterState::Glide; update } } From 9ad9a24e22f734ab39522561466c586c3a1be990 Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 1 Apr 2020 07:30:06 -0700 Subject: [PATCH 315/326] Remove unused KnockUp LocalEvent (use ApplyForce) --- common/src/event.rs | 3 --- common/src/state.rs | 6 ------ 2 files changed, 9 deletions(-) diff --git a/common/src/event.rs b/common/src/event.rs index 1575f31283..6721107fd7 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -47,9 +47,6 @@ pub enum SfxEvent { pub enum LocalEvent { /// Applies upward force to entity's `Vel` Jump(EcsEntity), - /// Applies the `force` + implicit upward force to - /// `entity`'s `Vel` - KnockUp { entity: EcsEntity, force: Vec3 }, /// Applies the `force` to `entity`'s `Vel` ApplyForce { entity: EcsEntity, force: Vec3 }, /// Applies leaping force to `entity`'s `Vel` away from `wall_dir` direction diff --git a/common/src/state.rs b/common/src/state.rs index 91374f1a2f..62f492e513 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -355,12 +355,6 @@ impl State { vel.0.z = HUMANOID_JUMP_ACCEL; } }, - LocalEvent::KnockUp { entity, force } => { - if let Some(vel) = velocities.get_mut(entity) { - vel.0 = force; - vel.0.z = HUMANOID_JUMP_ACCEL; - } - }, LocalEvent::ApplyForce { entity, force } => { // TODO: this sets the velocity directly to the value of `force`, consider // renaming the event or changing the behavior From f515cc70bed7423032644dc5f5d267f65587876b Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 1 Apr 2020 07:30:18 -0700 Subject: [PATCH 316/326] Documentation for swap_loadout --- client/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/lib.rs b/client/src/lib.rs index 4e906bb765..7341cdd916 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -307,6 +307,8 @@ impl Client { } } + /// Checks whether a player can swap their weapon+ability `Loadout` settings + /// and sends the `ControlAction` event that signals to do the swap. pub fn swap_loadout(&mut self) { let can_swap = self .state From a73d010f7bfc41247c7f2be3fd6b97fd3baa1601 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 1 Apr 2020 11:04:04 -0400 Subject: [PATCH 317/326] Point to newly released vek, add todo to reconsider empty item, remove uneeded ori slerp, remove agent from character behavior, add todos to combat sys, check if entities still exist before possessing & if possessed entity has a loadout move the active item into the second item space --- Cargo.lock | 3 ++- Cargo.toml | 3 --- common/src/comp/inventory/item/mod.rs | 2 ++ common/src/states/dash_melee.rs | 3 --- common/src/states/utils.rs | 10 +--------- common/src/sys/character_behavior.rs | 10 ++-------- common/src/sys/combat.rs | 5 ++++- server/src/events/interaction.rs | 16 ++++++++++++++-- 8 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4466efcfbb..e981dbdde1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4866,7 +4866,8 @@ dependencies = [ [[package]] name = "vek" version = "0.10.0" -source = "git+https://github.com/Imberflur/vek?branch=is_normalized#43bef0a9e953fbf6b00a073aef914c48b784c995" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c98f7e1c1400d5b1704baee82cbc56a3fde406769555ead0f2306e43ebab967" dependencies = [ "approx 0.3.2", "num-integer", diff --git a/Cargo.toml b/Cargo.toml index 4c8b444279..f4a8194459 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,6 +68,3 @@ debug = false [profile.releasedebuginfo] inherits = 'release' debug = 1 - -[patch.crates-io] -vek = {git = "https://github.com/Imberflur/vek", branch = "is_normalized"} diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 2fb685db2f..34743a0bb4 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -80,6 +80,8 @@ impl Asset for Item { } impl Item { + // TODO: consider alternatives such as default abilities that can be added to a + // loadout when no weapon is present pub fn empty() -> Self { Self { name: "Empty Item".to_owned(), diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 2090c6d60a..580eef21b5 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -2,7 +2,6 @@ use crate::{ comp::{Attacking, CharacterState, EnergySource, StateUpdate}, states::utils::*, sys::character_behavior::*, - util::Dir, }; use std::time::Duration; use vek::Vec3; @@ -98,8 +97,6 @@ impl CharacterBehavior for Data { } } - update.ori.0 = Dir::slerp_to_vec3(update.ori.0, update.vel.0, 9.0 * data.dt.0); - update } } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 6f44ab4273..cf06820cf6 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -13,7 +13,6 @@ use vek::vec::Vec2; pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0; const BASE_HUMANOID_ACCEL: f32 = 100.0; const BASE_HUMANOID_SPEED: f32 = 170.0; -const NPC_HUMANOID_SPEED: f32 = 170.0; const BASE_HUMANOID_AIR_ACCEL: f32 = 15.0; const BASE_HUMANOID_AIR_SPEED: f32 = 8.0; const BASE_HUMANOID_WATER_ACCEL: f32 = 70.0; @@ -43,14 +42,7 @@ pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { /// Updates components to move player as if theyre on ground or in air fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { let (accel, speed): (f32, f32) = if data.physics.on_ground { - ( - BASE_HUMANOID_ACCEL, - if data.agent.is_some() { - NPC_HUMANOID_SPEED - } else { - BASE_HUMANOID_SPEED - }, - ) + (BASE_HUMANOID_ACCEL, BASE_HUMANOID_SPEED) } else { (BASE_HUMANOID_AIR_ACCEL, BASE_HUMANOID_AIR_SPEED) }; diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index 1882879954..fbd1414398 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -1,7 +1,7 @@ use crate::{ comp::{ - Agent, Attacking, Body, CharacterState, ControlAction, Controller, ControllerInputs, - Energy, Loadout, Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, + Attacking, Body, CharacterState, ControlAction, Controller, ControllerInputs, Energy, + Loadout, Mounting, Ori, PhysicsState, Pos, StateUpdate, Stats, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, state::DeltaTime, @@ -50,7 +50,6 @@ pub struct JoinData<'a> { pub body: &'a Body, pub physics: &'a PhysicsState, pub attacking: Option<&'a Attacking>, - pub agent: Option<&'a Agent>, pub updater: &'a LazyUpdate, } @@ -68,7 +67,6 @@ pub type JoinTuple<'a> = ( &'a Body, &'a PhysicsState, Option<&'a Attacking>, - Option<&'a Agent>, ); fn incorporate_update(tuple: &mut JoinTuple, state_update: StateUpdate) { @@ -97,7 +95,6 @@ impl<'a> JoinData<'a> { body: j.10, physics: j.11, attacking: j.12, - agent: j.13, updater, dt, } @@ -128,7 +125,6 @@ impl<'a> System<'a> for Sys { ReadStorage<'a, Body>, ReadStorage<'a, PhysicsState>, ReadStorage<'a, Attacking>, - ReadStorage<'a, Agent>, ReadStorage<'a, Uid>, ReadStorage<'a, Mounting>, ); @@ -153,7 +149,6 @@ impl<'a> System<'a> for Sys { bodies, physics_states, attacking_storage, - agent_storage, uids, mountings, ): Self::SystemData, @@ -175,7 +170,6 @@ impl<'a> System<'a> for Sys { &bodies, &physics_states, attacking_storage.maybe(), - agent_storage.maybe(), ) .join(); diff --git a/common/src/sys/combat.rs b/common/src/sys/combat.rs index 02cc2f5c0a..1d2675e679 100644 --- a/common/src/sys/combat.rs +++ b/common/src/sys/combat.rs @@ -110,11 +110,14 @@ impl<'a> System<'a> for Sys { // Weapon gives base damage let mut healthchange = attack.base_healthchange as f32; - //// NPCs do less damage: + // TODO: remove this, either it will remain unused or be used as a temporary + // gameplay balance + //// NPCs do less damage //if agent_maybe.is_some() { // healthchange = (healthchange / 1.5).min(-1.0); //} + // TODO: remove this when there is a better way to target healing // Don't heal npc's hp if agent_b_maybe.is_some() && healthchange > 0.0 { healthchange = 0.0; diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index b46e3ffbd6..9f34e6d8ed 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -67,6 +67,16 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) { ecs.entity_from_uid(possessor_uid.into()), ecs.entity_from_uid(possesse_uid.into()), ) { + // Check that entities still exist + if !(possessor.gen().is_alive() && ecs.is_alive(possessor)) + || !(possesse.gen().is_alive() && ecs.is_alive(possesse)) + { + error!( + "Error possessing! either the possessor entity or possesse entity no longer exists" + ); + return; + } + // You can't possess other players let mut clients = ecs.write_storage::(); if clients.get_mut(possesse).is_none() { @@ -89,14 +99,16 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) { if let item::ItemKind::Tool(tool) = item.kind { let mut abilities = tool.get_abilities(); let mut ability_drain = abilities.drain(..); - loadout.active_item = Some(comp::ItemConfig { + let debug_item = comp::ItemConfig { item, ability1: ability_drain.next(), ability2: ability_drain.next(), ability3: ability_drain.next(), block_ability: None, dodge_ability: None, - }); + }; + std::mem::swap(&mut loadout.active_item, &mut loadout.second_item); + loadout.active_item = Some(debug_item); } // Move player component From 2b10797db180ae105a5cfd2a72350c221a6719be Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 1 Apr 2020 08:39:18 -0700 Subject: [PATCH 318/326] refactor transition logic (thx imbris) --- common/src/comp/ability.rs | 11 ++- common/src/states/triple_strike.rs | 110 ++++++++++++++++++----------- 2 files changed, 72 insertions(+), 49 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 5431c0d2f4..0b009b270f 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -3,7 +3,7 @@ use crate::{ item::Item, Body, CharacterState, EnergySource, Gravity, LightEmitter, Projectile, StateUpdate, }, - states::*, + states::{triple_strike::*, *}, sys::character_behavior::JoinData, }; use specs::{Component, FlaggedStorage}; @@ -172,12 +172,11 @@ impl From<&CharacterAbility> for CharacterState { stage: triple_strike::Stage::First, stage_exhausted: false, stage_time_active: Duration::default(), - needs_timing: *needs_timing, - // If `needs_timing`, prevent tansitioning by default, - // unless pressed at the right time. - should_transition: !*needs_timing, initialized: false, - prevent_transition: false, + transition_style: match *needs_timing { + true => TransitionStyle::Timed(TimingState::NotPressed), + false => TransitionStyle::Hold(HoldingState::Holding), + }, }), } } diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 7fcee69217..0e014a129d 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -5,6 +5,9 @@ use crate::{ }; use std::time::Duration; use vek::vec::Vec3; +use HoldingState::*; +use TimingState::*; +use TransitionStyle::*; // In millis const STAGE_DURATION: u64 = 700; @@ -19,6 +22,27 @@ pub enum Stage { Third, } +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub enum TimingState { + NotPressed, + PressedEarly, + Success, +} + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub enum HoldingState { + Holding, + Released, +} + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] +pub enum TransitionStyle { + /// Player must time a button press properly to transition + Timed(TimingState), + /// Player must hold button for whole move + Hold(HoldingState), +} + /// ### A sequence of 3 incrementally increasing attacks. /// /// While holding down the `primary` button, perform a series of 3 attacks, @@ -29,20 +53,16 @@ pub enum Stage { pub struct Data { /// The tool this state will read to handle damage, etc. pub base_damage: u32, - /// What stage (of 3) the attack is in. + /// What stage (of 3) the attack is in pub stage: Stage, /// How long current stage has been active pub stage_time_active: Duration, /// Whether current stage has exhausted its attack pub stage_exhausted: bool, - /// Whether to go to next stage - pub should_transition: bool, /// Whether state has performed intialization logic pub initialized: bool, - /// Whether player must time button pressed properly to continue combo - pub needs_timing: bool, - /// Set to prevent transitioning, true by default when `needs_timing` - pub prevent_transition: bool, + /// What this instance's current transition stat is + pub transition_style: TransitionStyle, } impl CharacterBehavior for Data { @@ -62,29 +82,30 @@ impl CharacterBehavior for Data { } let initialized = true; - // If player stops holding input, don't go to the next stage - let mut should_transition = self.should_transition; - let mut prevent_transition = self.prevent_transition; - - // Check inputs based on whether `needs_timing` - if self.needs_timing { - // Player must press at right time - if data.inputs.primary.is_just_pressed() { - if stage_time_active > Duration::from_millis(TIMING_WINDOW) { - // Player pressed at right time, transition - // unless prevent_transition has been set - should_transition = true; + // Update transition + let transition_style = match self.transition_style { + Timed(state) => match state { + NotPressed => { + if data.inputs.primary.is_just_pressed() { + if stage_time_active > Duration::from_millis(TIMING_WINDOW) { + Timed(Success) + } else { + Timed(PressedEarly) + } + } else { + self.transition_style + } + }, + _ => self.transition_style, + }, + Hold(_) => { + if !data.inputs.primary.is_pressed() { + Hold(Released) } else { - // Player pressed too early - prevent_transition = true; + self.transition_style } - } - } else { - // Prevent transitioning if player ever stops holding input - if !data.inputs.primary.is_pressed() { - should_transition = false; - } - } + }, + }; // Handle hit applied if let Some(attack) = data.attacking { @@ -148,18 +169,22 @@ impl CharacterBehavior for Data { stage: self.stage, stage_time_active, stage_exhausted: true, - should_transition, initialized, - needs_timing: self.needs_timing, - prevent_transition, + transition_style, }) } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { - let next_stage = match self.stage { - _ if !should_transition || prevent_transition => None, - Stage::First => Some(Stage::Second), - Stage::Second => Some(Stage::Third), - Stage::Third => None, - }; + let next_stage = + // Determine whether stage can transition based on TransitionStyle + if let Hold(Holding) | Timed(Success) = transition_style { + // Determine what stage to transition to + match self.stage { + Stage::First => Some(Stage::Second), + Stage::Second => Some(Stage::Third), + Stage::Third => None, + } + } + // Player messed up inputs, don't transition + else { None }; if let Some(stage) = next_stage { CharacterState::TripleStrike(Data { @@ -167,10 +192,11 @@ impl CharacterBehavior for Data { stage, stage_time_active: Duration::default(), stage_exhausted: false, - should_transition, initialized, - needs_timing: self.needs_timing, - prevent_transition, + transition_style: match transition_style { + Hold(_) => Hold(Holding), + Timed(_) => Timed(NotPressed), + }, }) } else { // Make sure attack component is removed @@ -184,10 +210,8 @@ impl CharacterBehavior for Data { stage: self.stage, stage_time_active, stage_exhausted: self.stage_exhausted, - should_transition, initialized, - needs_timing: self.needs_timing, - prevent_transition, + transition_style, }) }; From 1ea2abd247cb8f22a57e60f39b681a699886433c Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Wed, 1 Apr 2020 08:40:25 -0700 Subject: [PATCH 319/326] better timing const name, timing_delay 400 -> 350 --- common/src/states/triple_strike.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 0e014a129d..02393c84e3 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -11,7 +11,7 @@ use TransitionStyle::*; // In millis const STAGE_DURATION: u64 = 700; -const TIMING_WINDOW: u64 = 400; +const TIMING_DELAY: u64 = 350; const INITIAL_ACCEL: f32 = 90.0; const BASE_SPEED: f32 = 25.0; @@ -87,7 +87,7 @@ impl CharacterBehavior for Data { Timed(state) => match state { NotPressed => { if data.inputs.primary.is_just_pressed() { - if stage_time_active > Duration::from_millis(TIMING_WINDOW) { + if stage_time_active > Duration::from_millis(TIMING_DELAY) { Timed(Success) } else { Timed(PressedEarly) From 87a82bb59a80c5f4a544933043ba973da79fa316 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 1 Apr 2020 11:39:56 -0400 Subject: [PATCH 320/326] Fix tests --- voxygen/src/audio/sfx/event_mapper/movement/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs index 0d3011861d..6d7d8325ba 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs @@ -3,7 +3,7 @@ use common::{ assets, comp::{ bird_small, humanoid, - item::{AxeKind, BowKind, ToolKind}, + item::tool::{AxeKind, BowKind, ToolKind}, quadruped_medium, quadruped_small, Body, CharacterState, ItemConfig, Loadout, PhysicsState, }, event::SfxEvent, From 83c7a944daab28cd75af3a55636bf0a289685528 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 1 Apr 2020 11:52:44 -0400 Subject: [PATCH 321/326] fmt --- common/src/states/triple_strike.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs index 02393c84e3..9421dbcbd7 100644 --- a/common/src/states/triple_strike.rs +++ b/common/src/states/triple_strike.rs @@ -173,7 +173,7 @@ impl CharacterBehavior for Data { transition_style, }) } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { - let next_stage = + let next_stage = // Determine whether stage can transition based on TransitionStyle if let Hold(Holding) | Timed(Success) = transition_style { // Determine what stage to transition to @@ -196,7 +196,7 @@ impl CharacterBehavior for Data { transition_style: match transition_style { Hold(_) => Hold(Holding), Timed(_) => Timed(NotPressed), - }, + }, }) } else { // Make sure attack component is removed From b256e374a4af5e0af74c348e85a70b7357082fa1 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Wed, 1 Apr 2020 19:22:05 +0200 Subject: [PATCH 322/326] Update CHANGELOG.md --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a579276f06..1a85200c5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added gamepad/controller support - Added player feedback when attempting to pickup an item with a full inventory - Added free look +- Complete rewrite of the combat system into a state machine +- Abilities like Dash and Triplestrike +- Armor can now be eqipped as items +- Fireball explosions +- Inventory supports stacking +- Many new armors and weapons to find in chests +- Fleshed out "attack" animation into alpha, beta and spin type attacks +- Fleshed out range attack into charging and shooting anims for staff/bow +- Customized attack animation for hammers and axes ### Changed @@ -36,6 +45,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed /give_exp ignoring player argument - Extend run sfx to small animals to prevent sneak attacks by geese. - Decreased clientside latency of ServerEvent mediated effects (e.g. projectiles, inventory operations, etc) +- Started changing the visual theme of the UI +- Merge of the Bag and Character-Screen +- Merge of the Map and Questlog +- Overhauled icon art +- Asset cleanup to lower client-size +- Rewrote the humanoid skeleton to be more ideal for attack animations + ### Removed From 5ed77b505447fa98cd58cfcbe10c44517ef0de3a Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 1 Apr 2020 20:03:15 -0400 Subject: [PATCH 323/326] Fix security --- Cargo.lock | 18 ++++++++++++++---- world/Cargo.toml | 2 +- world/src/sim/util.rs | 7 ++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 311406a162..98cf25c4af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -331,9 +331,13 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bitvec" -version = "0.15.2" +version = "0.17.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6" +checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c" +dependencies = [ + "either", + "radium", +] [[package]] name = "blake2b_simd" @@ -410,9 +414,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.2.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f359dc14ff8911330a51ef78022d376f25ed00248912803b58f00cb1c27f742" +checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" [[package]] name = "byteorder" @@ -3401,6 +3405,12 @@ dependencies = [ "proc-macro2 1.0.9", ] +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + [[package]] name = "rand" version = "0.4.6" diff --git a/world/Cargo.toml b/world/Cargo.toml index 0784d933a9..0ff1838510 100644 --- a/world/Cargo.toml +++ b/world/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] bincode = "1.2.0" common = { package = "veloren-common", path = "../common" } -bitvec = "0.15.2" +bitvec = "0.17.4" image = "0.22.3" itertools = "0.8.2" vek = "0.10.0" diff --git a/world/src/sim/util.rs b/world/src/sim/util.rs index fa138c40bf..e9f9cd816f 100644 --- a/world/src/sim/util.rs +++ b/world/src/sim/util.rs @@ -1,5 +1,5 @@ use super::WORLD_SIZE; -use bitvec::prelude::{bitbox, bitvec, BitBox}; +use bitvec::prelude::{bitbox, BitBox}; use common::{terrain::TerrainChunkSize, vol::RectVolSize}; use noise::{MultiFractal, NoiseFn, Perlin, Point2, Point3, Point4, Seedable}; use num::Float; @@ -322,10 +322,11 @@ pub fn get_oceans(oldh: impl Fn(usize) -> F + Sync) -> BitBox { while let Some(chunk_idx) = stack.pop() { // println!("Ocean chunk {:?}: {:?}", uniform_idx_as_vec2(chunk_idx), // oldh(chunk_idx)); - if *is_ocean.at(chunk_idx) { + let mut is_ocean = is_ocean.get_mut(chunk_idx).unwrap(); + if *is_ocean { continue; } - *is_ocean.at(chunk_idx) = true; + *is_ocean = true; stack.extend(neighbors(chunk_idx).filter(|&neighbor_idx| { // println!("Ocean neighbor: {:?}: {:?}", uniform_idx_as_vec2(neighbor_idx), // oldh(neighbor_idx)); From 831d7c77a60b2370b0dc69ac3f98fe0634b0f9a1 Mon Sep 17 00:00:00 2001 From: Imbris Date: Sat, 28 Mar 2020 21:09:19 -0400 Subject: [PATCH 324/326] Make Asset impls avoid panics when parsing fails --- common/src/assets/mod.rs | 18 +++++++++----- common/src/comp/body.rs | 4 ++-- common/src/comp/inventory/item/mod.rs | 2 +- voxygen/src/hud/item_imgs.rs | 2 +- voxygen/src/i18n.rs | 3 ++- voxygen/src/scene/figure/load.rs | 34 +++++++++++++-------------- world/src/block/natural.rs | 2 +- 7 files changed, 36 insertions(+), 29 deletions(-) diff --git a/common/src/assets/mod.rs b/common/src/assets/mod.rs index cadff415de..1da7243b52 100644 --- a/common/src/assets/mod.rs +++ b/common/src/assets/mod.rs @@ -19,8 +19,8 @@ use std::{ /// The error returned by asset loading functions #[derive(Debug, Clone)] pub enum Error { - /// An internal error occurred. - Internal(Arc), + /// Parsing error occurred. + ParseError(Arc), /// An asset of a different type has already been loaded with this /// specifier. InvalidType, @@ -28,10 +28,16 @@ pub enum Error { NotFound(String), } +impl Error { + pub fn parse_error(err: E) -> Self { + Self::ParseError(Arc::new(err)) + } +} + impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Error::Internal(err) => err.fmt(f), + Error::ParseError(err) => write!(f, "{:?}", err), Error::InvalidType => write!( f, "an asset of a different type has already been loaded with this specifier." @@ -226,7 +232,7 @@ impl Asset for DynamicImage { fn parse(mut buf_reader: BufReader) -> Result { let mut buf = Vec::new(); buf_reader.read_to_end(&mut buf)?; - Ok(image::load_from_memory(&buf).unwrap()) + image::load_from_memory(&buf).map_err(Error::parse_error) } } @@ -236,7 +242,7 @@ impl Asset for DotVoxData { fn parse(mut buf_reader: BufReader) -> Result { let mut buf = Vec::new(); buf_reader.read_to_end(&mut buf)?; - Ok(dot_vox::load_bytes(&buf).unwrap()) + dot_vox::load_bytes(&buf).map_err(Error::parse_error) } } @@ -245,7 +251,7 @@ impl Asset for Value { const ENDINGS: &'static [&'static str] = &["json"]; fn parse(buf_reader: BufReader) -> Result { - Ok(serde_json::from_reader(buf_reader).unwrap()) + serde_json::from_reader(buf_reader).map_err(Error::parse_error) } } diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index f75acce151..a777c4ace5 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -16,7 +16,7 @@ use crate::{ }; use specs::{Component, FlaggedStorage}; use specs_idvs::IDVStorage; -use std::{fs::File, io::BufReader, sync::Arc}; +use std::{fs::File, io::BufReader}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] @@ -84,7 +84,7 @@ impl< const ENDINGS: &'static [&'static str] = &["json"]; fn parse(buf_reader: BufReader) -> Result { - serde_json::de::from_reader(buf_reader).map_err(|e| assets::Error::Internal(Arc::new(e))) + serde_json::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 34743a0bb4..5cc42d5b8e 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -75,7 +75,7 @@ impl Asset for Item { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).unwrap()) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } diff --git a/voxygen/src/hud/item_imgs.rs b/voxygen/src/hud/item_imgs.rs index 816d5fd2aa..84566e45c0 100644 --- a/voxygen/src/hud/item_imgs.rs +++ b/voxygen/src/hud/item_imgs.rs @@ -78,7 +78,7 @@ impl Asset for ItemImagesSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing item images spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } diff --git a/voxygen/src/i18n.rs b/voxygen/src/i18n.rs index 3b8064a849..81b758a128 100644 --- a/voxygen/src/i18n.rs +++ b/voxygen/src/i18n.rs @@ -108,7 +108,8 @@ impl Asset for VoxygenLocalization { /// Load the translations located in the input buffer and convert them /// into a `VoxygenLocalization` object. fn parse(buf_reader: BufReader) -> Result { - let mut asked_localization: VoxygenLocalization = from_reader(buf_reader).unwrap(); + let mut asked_localization: VoxygenLocalization = + from_reader(buf_reader).map_err(assets::Error::parse_error)?; // Update the text if UTF-8 to ASCII conversion is enabled if asked_localization.convert_utf8_to_ascii { diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 31457d3fcd..fcb221726d 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -139,7 +139,7 @@ impl Asset for HumHeadSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid head spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } @@ -261,49 +261,49 @@ impl Asset for HumArmorShoulderSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor shoulder spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } impl Asset for HumArmorChestSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor chest spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } impl Asset for HumArmorHandSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor hand spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } impl Asset for HumArmorBeltSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor belt spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } impl Asset for HumArmorPantsSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor pants spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } impl Asset for HumArmorFootSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid armor foot spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } impl Asset for HumMainWeaponSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing humanoid main weapon spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } @@ -667,7 +667,7 @@ impl Asset for QuadrupedSmallCentralSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing quad_small central spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } @@ -675,7 +675,7 @@ impl Asset for QuadrupedSmallLateralSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing quadruped small lateral spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } @@ -828,7 +828,7 @@ impl Asset for QuadrupedMediumCentralSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing quadruped medium central spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } @@ -836,7 +836,7 @@ impl Asset for QuadrupedMediumLateralSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing quadruped medium lateral spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } @@ -1074,7 +1074,7 @@ impl Asset for BirdMediumCenterSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing bird medium center spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } @@ -1082,7 +1082,7 @@ impl Asset for BirdMediumLateralSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing bird medium lateral spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } @@ -1232,7 +1232,7 @@ impl Asset for CritterCenterSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing critter center spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } @@ -1587,7 +1587,7 @@ impl Asset for BipedLargeCenterSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing biped large center spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } @@ -1595,7 +1595,7 @@ impl Asset for BipedLargeLateralSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing biped large lateral spec")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } diff --git a/world/src/block/natural.rs b/world/src/block/natural.rs index c60d593d34..0c2814dada 100644 --- a/world/src/block/natural.rs +++ b/world/src/block/natural.rs @@ -87,7 +87,7 @@ impl Asset for StructuresSpec { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader) -> Result { - Ok(ron::de::from_reader(buf_reader).expect("Error parsing structure specs")) + ron::de::from_reader(buf_reader).map_err(assets::Error::parse_error) } } From 4652ae2f034e02c1adf3fd46302d68bd15bbe996 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 1 Apr 2020 20:37:23 -0400 Subject: [PATCH 325/326] Show errors loading individual files during glob asset loading --- common/src/assets/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common/src/assets/mod.rs b/common/src/assets/mod.rs index 1da7243b52..cdfa7fa1f2 100644 --- a/common/src/assets/mod.rs +++ b/common/src/assets/mod.rs @@ -116,7 +116,16 @@ pub fn load_glob(specifier: &str) -> Result>> let assets = Arc::new( glob_matches .into_iter() - .filter_map(|name| load(&specifier.replace("*", &name)).ok()) + .filter_map(|name| { + load(&specifier.replace("*", &name)) + .map_err(|e| { + error!( + "Failed to load \"{}\" as part of glob \"{}\" with error: {:?}", + name, specifier, e + ) + }) + .ok() + }) .collect::>(), ); let clone = Arc::clone(&assets); From 3e4b40380ffcf553e8db525e9a75000529a94912 Mon Sep 17 00:00:00 2001 From: Shane Handley Date: Thu, 2 Apr 2020 14:47:26 +1100 Subject: [PATCH 326/326] fix: Restore run SFX when the character is using a weapon other than the sword. --- .../src/audio/sfx/event_mapper/movement/mod.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index 8f4a6d2916..36dc653303 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -98,17 +98,14 @@ impl MovementEventMapper { Some(Self::get_volume_for_body_type(body)), )); - // Set the new previous entity state - state.event = mapped_event; state.time = Instant::now(); - state.weapon_drawn = Self::weapon_drawn(character); - state.on_ground = physics.on_ground; - } else { - // If we don't dispatch the event, store this data as we can use it to determine - // the next event - state.event = mapped_event; - state.on_ground = physics.on_ground; } + + // update state to determine the next event. We only record the time (above) if + // it was dispatched + state.event = mapped_event; + state.weapon_drawn = Self::weapon_drawn(character); + state.on_ground = physics.on_ground; } }