Merge branch 'combat' of https://gitlab.com/veloren/veloren into combat

This commit is contained in:
jshipsey 2020-03-22 00:14:11 -04:00
commit eafd761d5a
60 changed files with 423 additions and 183 deletions

View File

@ -0,0 +1,8 @@
Item(
name: "Blue Linen Belt",
description: "Soft and warm",
kind: Armor(
kind: Belt(ClothBlue0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Green Linen Belt",
description: "Soft and warm",
kind: Armor(
kind: Belt(ClothGreen0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Purple Linen Belt",
description: "Soft and warm",
kind: Armor(
kind: Belt(ClothPurple0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Blue Linen Chest",
description: "Soft and warm",
kind: Armor(
kind: Chest(ClothBlue0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Green Linen Chest",
description: "Soft and warm",
kind: Armor(
kind: Chest(ClothGreen0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Purple Linen Chest",
description: "Soft and warm",
kind: Armor(
kind: Chest(ClothPurple0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Blue Linen Boots",
description: "Soft and warm",
kind: Armor(
kind: Foot(ClothBlue0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Green Linen Boots",
description: "Soft and warm",
kind: Armor(
kind: Foot(ClothGreen0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Purple Linen Boots",
description: "Soft and warm",
kind: Armor(
kind: Foot(ClothPurple0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Blue Linen Wrists",
description: "WIP",
kind: Armor(
kind: Hand(ClothBlue0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Green Linen Wrists",
description: "WIP",
kind: Armor(
kind: Hand(ClothGreen0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Purple Silk Wrists",
description: "WIP",
kind: Armor(
kind: Hand(ClothPurple0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Blue Linen Skirt",
description: "WIP",
kind: Armor(
kind: Belt(ClothBlue0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Green Linen Skirt",
description: "WIP",
kind: Armor(
kind: Belt(ClothGreen0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Purple Linen Skirt",
description: "WIP",
kind: Armor(
kind: Belt(ClothPurple0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Blue Linen Coat",
description: "WIP",
kind: Armor(
kind: Belt(ClothBlue0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Green Linen Coat",
description: "WIP",
kind: Armor(
kind: Belt(ClothGreen0),
stats: 20,
),
)

View File

@ -0,0 +1,8 @@
Item(
name: "Purple Linen Coat",
description: "WIP",
kind: Armor(
kind: Belt(ClothPurple0),
stats: 20,
),
)

View File

@ -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
),
})

View File

@ -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
),
})

View File

@ -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
),
})

View File

@ -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: (
@ -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
)
),
})

View File

@ -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
),
})

View File

@ -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: (
@ -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
)
),
})

View File

@ -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<Self>;
type Storage = IDVStorage<Self>;
}
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
@ -159,5 +162,5 @@ impl From<&CharacterAbility> for CharacterState {
}
impl Component for Loadout {
type Storage = FlaggedStorage<Self, HashMapStorage<Self>>;
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
}

View File

@ -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)]

View File

@ -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 {

View File

@ -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<f32>,
force: f32,
},
/// Applies the `force`, in `dir` direction to `entity`'s `Vel`
ApplyForce {
entity: EcsEntity,
dir: Vec3<f32>,
force: f32,
},
/// Applies leaping force to `entity`'s `Vel` away from `wall_dir` direction
WallLeap {
entity: EcsEntity,
wall_dir: Vec3<f32>,
},
Boost {
entity: EcsEntity,
vel: Vec3<f32>,
},
/// Applies `vel` velocity to `entity`
Boost { entity: EcsEntity, vel: Vec3<f32> },
}
pub enum ServerEvent {

View File

@ -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) }
}

View File

@ -107,7 +107,6 @@ impl State {
ecs.register_sync_marker();
// Register server -> all clients synced components.
ecs.register::<comp::Loadout>();
ecs.register::<comp::CharacterAbility>();
ecs.register::<comp::Projectile>();
ecs.register::<comp::Body>();
ecs.register::<comp::Player>();
@ -351,7 +350,6 @@ impl State {
let events = self.ecs.read_resource::<EventBus<LocalEvent>>().recv_all();
for event in events {
let mut velocities = self.ecs.write_storage::<comp::Vel>();
let mut orientations = self.ecs.write_storage::<comp::Ori>();
let mut controllers = self.ecs.write_storage::<comp::Controller>();
match event {
LocalEvent::Jump(entity) => {
@ -359,12 +357,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 } => {

View File

@ -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::<Attacking>(data.entity);
// return update;
should_transition = false;
}

View File

@ -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();
}

View File

@ -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;

View File

@ -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;

View File

@ -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<ServerEvent>>,
Read<'a, EventBus<LocalEvent>>,
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,

View File

@ -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<f32>) -> Mesh<FigurePipeline> {
Meshable::<FigurePipeline, FigurePipeline>::generate_mesh(segment, offset).0
@ -302,7 +306,7 @@ impl HumArmorShoulderSpec {
.unwrap()
}
pub fn mesh_left_shoulder(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
fn mesh_shoulder(&self, body: &Body, loadout: &Loadout, flipped: bool) -> Mesh<FigurePipeline> {
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<FigurePipeline> {
self.mesh_shoulder(body, loadout, true)
}
pub fn mesh_right_shoulder(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
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<FigurePipeline> {
fn mesh_hand(&self, body: &Body, loadout: &Loadout, flipped: bool) -> Mesh<FigurePipeline> {
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<FigurePipeline> {
self.mesh_hand(body, loadout, true)
}
pub fn mesh_right_hand(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
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<FigurePipeline> {
fn mesh_foot(&self, body: &Body, loadout: &Loadout, flipped: bool) -> Mesh<FigurePipeline> {
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<FigurePipeline> {
self.mesh_foot(body, loadout, true)
}
pub fn mesh_right_foot(&self, body: &Body, loadout: &Loadout) -> Mesh<FigurePipeline> {
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)
}
}