mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
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:
parent
8b9316a2c6
commit
c538a9696c
@ -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 {
|
||||
|
@ -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),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 => {},
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user