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
14 changed files with 160 additions and 62 deletions

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