mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Begin implementing combat actions
This commit is contained in:
parent
7a4cdfb7a4
commit
9c6ce9babd
@ -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,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
@ -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,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
@ -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,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
@ -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,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
@ -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,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
@ -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,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
@ -27,7 +27,7 @@
|
||||
threshold: 0.5,
|
||||
),
|
||||
(
|
||||
trigger: Attack(Sword),
|
||||
trigger: Attack(Sword(Rapier)),
|
||||
files: [
|
||||
"voxygen.audio.sfx.weapon.sword",
|
||||
],
|
||||
|
@ -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,
|
||||
),
|
||||
|
@ -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)]
|
||||
|
@ -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),
|
||||
|
@ -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};
|
||||
|
@ -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};
|
||||
|
@ -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,
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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<Tool>, f64);
|
||||
type Dependency = (Option<ToolKind>, f64);
|
||||
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
|
@ -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<Tool>, f64);
|
||||
type Dependency = (Option<ToolKind>, 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)
|
||||
|
@ -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<Tool>, f64);
|
||||
type Dependency = (Option<ToolKind>, 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)
|
||||
|
@ -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<Tool>, f64);
|
||||
type Dependency = (Option<ToolKind>, f64);
|
||||
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
|
@ -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<Tool>, f64);
|
||||
type Dependency = (Option<ToolKind>, 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)
|
||||
|
@ -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<Tool>, Vec3<f32>, Vec3<f32>, f64);
|
||||
type Dependency = (Option<ToolKind>, Vec3<f32>, Vec3<f32>, f64);
|
||||
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
|
@ -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;
|
||||
|
@ -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<Tool>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
|
||||
type Dependency = (Option<ToolKind>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
|
||||
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
|
@ -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<Tool>, f64);
|
||||
type Dependency = (Option<ToolKind>, f64);
|
||||
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
|
@ -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<Tool>, f64);
|
||||
type Dependency = (Option<ToolKind>, f64);
|
||||
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
|
@ -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<Tool>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
|
||||
type Dependency = (Option<ToolKind>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
|
||||
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
|
@ -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<Tool>, f64);
|
||||
type Dependency = (Option<ToolKind>, f64);
|
||||
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
|
@ -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<Tool>, f64);
|
||||
type Dependency = (Option<ToolKind>, f64);
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
(_active_tool_kind, global_time): Self::Dependency,
|
||||
|
@ -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<Tool>, f32, f32, f64);
|
||||
type Dependency = (Option<ToolKind>, f32, f32, f64);
|
||||
|
||||
fn update_skeleton(
|
||||
skeleton: &Self::Skeleton,
|
||||
|
@ -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<Tool>, f32, f64);
|
||||
type Dependency = (Option<ToolKind>, 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)
|
||||
|
Loading…
Reference in New Issue
Block a user