improvement: make debug items of type ItemKind::Tool

This way all items that can be held in a hand are tools
This commit is contained in:
timokoesters 2019-10-22 22:58:27 +02:00
parent 20248a4818
commit 0a1e12c9ad
No known key found for this signature in database
GPG Key ID: CD80BE9AAEE78097
14 changed files with 160 additions and 62 deletions

View File

@ -1,5 +1,8 @@
Item(
name: "Boost rod",
description: "Your legs feel full of energy while holding this",
kind: Debug(Boost),
kind: Tool(
kind: Debug(Boost),
power: 0,
),
)

View File

@ -1,5 +1,8 @@
Item(
name: "Possession rod",
description: "Your body seems loose while holding this",
kind: Debug(Possess),
kind: Tool(
kind: Debug(Possess),
power: 0,
),
)

View File

@ -1,15 +1,7 @@
// Png(specifier),
// Vox(specier),
// VoxTrans(specifier, offset, (x_rot, y_rot, z_rot), zoom)
({ // Debug Items
Debug(Boost): VoxTrans(
"voxel.weapon.debug_wand-0",
(0.0, -7.0, 0.0), (90.0, 90.0, 0.0), 1.6,
),
Debug(Possess): VoxTrans(
"voxel.weapon.debug_wand-1",
(0.0, -7.0, 0.0), (90.0, 90.0, 0.0), 1.6,
),
({
// Weapons
Tool(Bow): VoxTrans(
"voxel.weapon.bow.simple-bow",
@ -69,4 +61,13 @@
"voxel.sprite.grass.grass_long_5",
(0.0, 0.0, 0.0), (-90.0, 50.0, 0.0), 1.0,
),
// Debug Items
Tool(Debug(Boost)): VoxTrans(
"voxel.weapon.debug_wand-0",
(0.0, -7.0, 0.0), (90.0, 90.0, 0.0), 1.6,
),
Tool(Debug(Possess)): VoxTrans(
"voxel.weapon.debug_wand-1",
(0.0, -7.0, 0.0), (90.0, 90.0, 0.0), 1.6,
),
})

View File

@ -17,6 +17,13 @@ pub enum Tool {
Hammer,
Bow,
Staff,
Debug(Debug),
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Debug {
Boost,
Possess,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
@ -50,19 +57,12 @@ pub enum Ingredient {
Grass,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Debug {
Boost,
Possess,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ItemKind {
Tool { kind: Tool, power: u32 },
Armor { kind: Armor, power: u32 },
Consumable { kind: Consumable, effect: Effect },
Ingredient(Ingredient),
Debug(Debug),
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]

View File

@ -233,38 +233,10 @@ impl<'a> System<'a> for Sys {
}
}
}
Some(ItemKind::Tool { .. }) => {
// Melee Attack
if inputs.primary
&& (character.movement == Stand
|| character.movement == Run
|| character.movement == Jump)
{
if let Wield { time_left } = character.action {
if time_left == Duration::default() {
character.action = Attack {
time_left: ATTACK_DURATION,
applied: false,
};
}
}
}
// Block
if inputs.secondary
&& (character.movement == Stand || character.movement == Run)
&& character.action.is_wield()
{
character.action = Block {
time_left: Duration::from_secs(5),
};
} else if !inputs.secondary && character.action.is_block() {
character.action = Wield {
time_left: Duration::default(),
};
}
}
Some(ItemKind::Debug(item::Debug::Boost)) => {
Some(ItemKind::Tool {
kind: item::Tool::Debug(item::Debug::Boost),
..
}) => {
if inputs.primary {
local_emitter.emit(LocalEvent::Boost {
entity,
@ -279,7 +251,10 @@ impl<'a> System<'a> for Sys {
});
}
}
Some(ItemKind::Debug(item::Debug::Possess)) => {
Some(ItemKind::Tool {
kind: item::Tool::Debug(item::Debug::Possess),
..
}) => {
if inputs.primary
&& (character.movement == Stand
|| character.movement == Run
@ -326,6 +301,38 @@ impl<'a> System<'a> for Sys {
};
}
}
// All other tools
Some(ItemKind::Tool { .. }) => {
// Attack
if inputs.primary
&& (character.movement == Stand
|| character.movement == Run
|| character.movement == Jump)
{
if let Wield { time_left } = character.action {
if time_left == Duration::default() {
character.action = Attack {
time_left: ATTACK_DURATION,
applied: false,
};
}
}
}
// Block
if inputs.secondary
&& (character.movement == Stand || character.movement == Run)
&& character.action.is_wield()
{
character.action = Block {
time_left: Duration::from_secs(5),
};
} else if !inputs.secondary && character.action.is_block() {
character.action = Wield {
time_left: Duration::default(),
};
}
}
None => {
// Attack
if inputs.primary

View File

@ -224,6 +224,27 @@ impl Animation for BlockAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::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)
* Quaternion::rotation_z(-0.2);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 2.5, 3.75);
next.r_hand.ori = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.2);
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,
5.5,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.35)
* Quaternion::rotation_z(-0.85);
next.weapon.scale = Vec3::one();
}
}
//next.l_foot.offset = Vec3::new(-3.4, 0.3, 8.0 + wave_ultra_slow_cos * 0.1);
//next.l_foot.ori = Quaternion::rotation_x(-0.3);

View File

@ -223,6 +223,27 @@ impl Animation for BlockIdleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::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)
* Quaternion::rotation_z(-0.2);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 2.5 + wave_ultra_slow * 2.0, 3.75);
next.r_hand.ori = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.2);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
5.0 + skeleton_attr.weapon_x,
8.75 + wave_ultra_slow * 2.0 + skeleton_attr.weapon_y,
5.5,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.35)
* Quaternion::rotation_z(-0.85);
next.weapon.scale = Vec3::one();
}
}
next.l_foot.offset = Vec3::new(-3.4, 0.3, 8.0 + wave_ultra_slow_cos * 0.1);
next.l_foot.ori = Quaternion::rotation_x(-0.3);

View File

@ -235,6 +235,27 @@ impl Animation for CidleAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::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.weapon.offset = Vec3::new(
5.0 + skeleton_attr.weapon_x,
8.75 + skeleton_attr.weapon_y,
-2.5,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.27)
* Quaternion::rotation_z(wave_ultra_slow * 0.2);
next.weapon.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);

View File

@ -151,6 +151,27 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
Tool::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.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.27)
* Quaternion::rotation_z(wave * -0.25);
next.weapon.scale = Vec3::one();
}
}
next

View File

@ -154,6 +154,7 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr {
Tool::Staff => 3.0,
Tool::Bow => 0.0,
Tool::Dagger => 0.0,
Tool::Debug(_) => 0.0,
},
weapon_y: match Tool::Hammer {
// TODO: Inventory
@ -164,6 +165,7 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr {
Tool::Staff => 0.0,
Tool::Bow => -2.0,
Tool::Dagger => -2.0,
Tool::Debug(_) => 0.0,
},
}
}

View File

@ -1,7 +1,7 @@
use crate::ui::{Graphic, Transform, Ui};
use common::{
assets::{self, watch::ReloadIndicator, Asset},
comp::item::{Armor, Consumable, Debug, Ingredient, Item, ItemKind, Tool},
comp::item::{Armor, Consumable, Ingredient, Item, ItemKind, Tool},
};
use conrod_core::image::Id;
use dot_vox::DotVoxData;
@ -18,7 +18,6 @@ pub enum ItemKey {
Armor(Armor),
Consumable(Consumable),
Ingredient(Ingredient),
Debug(Debug),
}
impl From<&Item> for ItemKey {
fn from(item: &Item) -> Self {
@ -27,7 +26,6 @@ impl From<&Item> for ItemKey {
ItemKind::Armor { kind, .. } => ItemKey::Armor(kind.clone()),
ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()),
ItemKind::Ingredient(kind) => ItemKey::Ingredient(kind.clone()),
ItemKind::Debug(kind) => ItemKey::Debug(kind.clone()),
}
}
}

View File

@ -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, Item, ItemKind, Stats};
use common::comp::{item::Debug, item::Tool, ItemKind, Stats};
use conrod_core::{
color,
widget::{self, Button, Image, Rectangle, Text},
@ -535,7 +535,7 @@ impl<'a> Widget for Skillbar<'a> {
},
_ => 38.0 * scale,
})
.h(match self.stats.equipment.main {
.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,
@ -552,8 +552,8 @@ impl<'a> Widget for Skillbar<'a> {
.set(state.ids.m2_slot, ui);
Image::new(self.imgs.skillbar_slot_big_bg)
.w_h(36.0 * scale, 36.0 * scale)
.color(match self.stats.equipment.main {
Some(Item::Tool { kind, .. }) => match kind {
.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(BG_COLOR_2),
@ -574,7 +574,7 @@ impl<'a> Widget for Skillbar<'a> {
},
_ => self.imgs.twohaxe_m2,
}) // Insert Icon here
.w(match self.stats.equipment.main {
.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,
@ -582,7 +582,7 @@ impl<'a> Widget for Skillbar<'a> {
},
_ => 38.0 * scale,
})
.h(match self.stats.equipment.main {
.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,

View File

@ -8,7 +8,7 @@ use crate::{
GlobalState,
};
use client::Client;
use common::comp::{humanoid, item::Tool};
use common::comp::humanoid;
use conrod_core::{
color,
color::TRANSPARENT,

View File

@ -520,8 +520,8 @@ pub fn mesh_main(item: Option<&Item>) -> Mesh<FigurePipeline> {
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::Debug(_) => ("weapon.debug_wand", Vec3::new(-1.5, -9.5, -4.0)),
_ => return Mesh::new(),
};
load_mesh(name, offset)