Use Food after Buildup

+ Remove Saturation effect by rolling
+ Remove Saturation effect if interrupted with poise
+ Rename Potion to Drink, add ComplexFood
This commit is contained in:
juliancoffee 2021-06-30 21:34:35 +03:00
parent 8b9316a2c6
commit c538a9696c
4 changed files with 26 additions and 10 deletions

View File

@ -271,8 +271,9 @@ pub enum ItemKind {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ConsumableKind {
Potion,
Drink,
Food,
ComplexFood,
}
impl ItemKind {

View File

@ -51,19 +51,21 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
match self.static_data.item_kind {
ItemUseKind::Consumable(ConsumableKind::Potion) => {
ItemUseKind::Consumable(ConsumableKind::Drink) => {
handle_orientation(data, &mut update, 1.0);
handle_move(data, &mut update, 1.0);
},
ItemUseKind::Consumable(ConsumableKind::Food) => {
ItemUseKind::Consumable(ConsumableKind::Food | ConsumableKind::ComplexFood) => {
handle_orientation(data, &mut update, 0.0);
handle_move(data, &mut update, 0.0);
},
}
let use_point = match self.static_data.item_kind {
ItemUseKind::Consumable(ConsumableKind::Potion) => UsePoint::BuildupUse,
ItemUseKind::Consumable(ConsumableKind::Food) => UsePoint::UseRecover,
ItemUseKind::Consumable(ConsumableKind::Drink | ConsumableKind::Food) => {
UsePoint::BuildupUse
},
ItemUseKind::Consumable(ConsumableKind::ComplexFood) => UsePoint::UseRecover,
};
match self.stage_section {
@ -138,11 +140,15 @@ impl CharacterBehavior for Data {
handle_state_interrupt(data, &mut update, false);
if matches!(update.character, CharacterState::Roll(_)) {
// Remove potion effect if left the use item state early by rolling
// Remove potion/saturation effect if left the use item state early by rolling
update.server_events.push_front(ServerEvent::Buff {
entity: data.entity,
buff_change: BuffChange::RemoveByKind(BuffKind::Potion),
});
update.server_events.push_front(ServerEvent::Buff {
entity: data.entity,
buff_change: BuffChange::RemoveByKind(BuffKind::Saturation),
});
}
update
@ -168,7 +174,7 @@ impl ItemUseKind {
/// Returns (buildup, use, recover)
pub fn durations(&self) -> (Duration, Duration, Duration) {
match self {
Self::Consumable(ConsumableKind::Potion) => (
Self::Consumable(ConsumableKind::Drink) => (
Duration::from_secs_f32(0.1),
Duration::from_secs_f32(1.1),
Duration::from_secs_f32(0.1),
@ -178,6 +184,11 @@ impl ItemUseKind {
Duration::from_secs_f32(5.0),
Duration::from_secs_f32(0.5),
),
Self::Consumable(ConsumableKind::ComplexFood) => (
Duration::from_secs_f32(1.0),
Duration::from_secs_f32(5.0),
Duration::from_secs_f32(0.5),
),
}
}
}

View File

@ -165,13 +165,17 @@ impl<'a> System<'a> for Sys {
let was_wielded = char_state.get_unchecked().is_wield();
let poise_state = poise.poise_state();
let pos = pos.0;
// Remove potion buff if knocked into poise state
// Remove potion/saturation buff if knocked into poise state
if !matches!(poise_state, PoiseState::Normal) {
use comp::buff::{BuffChange, BuffKind};
server_emitter.emit(ServerEvent::Buff {
entity,
buff_change: BuffChange::RemoveByKind(BuffKind::Potion),
});
server_emitter.emit(ServerEvent::Buff {
entity,
buff_change: BuffChange::RemoveByKind(BuffKind::Saturation),
});
}
match poise_state {
PoiseState::Normal => {},

View File

@ -27,7 +27,7 @@ impl Animation for ConsumeAnimation {
let mut next = (*skeleton).clone();
match item_kind {
Some(ItemUseKind::Consumable(ConsumableKind::Potion)) => {
Some(ItemUseKind::Consumable(ConsumableKind::Drink)) => {
let (move1, move2, move3) = match stage_section {
Some(StageSection::Buildup) => (anim_time, 0.0, 0.0),
Some(StageSection::Use) => (1.0, (anim_time * 8.0).sin(), 0.0),
@ -56,7 +56,7 @@ impl Animation for ConsumeAnimation {
next.hand_l.orientation =
Quaternion::rotation_x(move1 * 0.8) * Quaternion::rotation_y(move1 * -0.5);
},
Some(ItemUseKind::Consumable(ConsumableKind::Food)) => {
Some(ItemUseKind::Consumable(ConsumableKind::Food | ConsumableKind::ComplexFood)) => {
let (move1, move2, move3) = match stage_section {
Some(StageSection::Buildup) => (anim_time, 0.0, 0.0),
Some(StageSection::Use) => (1.0, (anim_time * 12.0).sin(), 0.0),