mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Interactable campfires
This commit is contained in:
parent
38ecfe7c8b
commit
0e2808a8fd
@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Put date at the begining of the log file instead of the end to allow MIME type recognition
|
||||
- Tweaked CR and exp calculation formula
|
||||
- Sprite spawn rates
|
||||
- The Interact button can be used on campfires to sit
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -150,6 +150,8 @@ impl<
|
||||
impl Body {
|
||||
pub fn is_humanoid(&self) -> bool { matches!(self, Body::Humanoid(_)) }
|
||||
|
||||
pub fn is_campfire(&self) -> bool { matches!(self, Body::Object(object::Body::CampfireLit)) }
|
||||
|
||||
/// Average density of the body
|
||||
// Units are based on kg/m³
|
||||
pub fn density(&self) -> Density {
|
||||
|
@ -27,7 +27,7 @@ pub enum BuffKind {
|
||||
/// Strength should be the healing per second
|
||||
Potion,
|
||||
/// Applied when sitting at a campfire
|
||||
/// Strength is fraction of health resotred per second
|
||||
/// Strength is fraction of health restored per second
|
||||
CampfireHeal,
|
||||
/// Raises maximum energy
|
||||
/// Strength should be 10x the effect to max energy
|
||||
|
@ -1,6 +1,9 @@
|
||||
use crate::{
|
||||
combat::Attack,
|
||||
comp::{tool::ToolKind, ControlAction, Density, Energy, InputAttr, InputKind, Ori, Pos, Vel},
|
||||
comp::{
|
||||
item::ConsumableKind, tool::ToolKind, ControlAction, Density, Energy, InputAttr, InputKind,
|
||||
Ori, Pos, Vel,
|
||||
},
|
||||
event::{LocalEvent, ServerEvent},
|
||||
states::{
|
||||
self,
|
||||
@ -219,6 +222,23 @@ impl CharacterState {
|
||||
|| matches!(self, CharacterState::Roll(s) if s.stage_section == StageSection::Movement)
|
||||
}
|
||||
|
||||
pub fn is_sitting(&self) -> bool {
|
||||
use use_item::{Data, ItemUseKind, StaticData};
|
||||
matches!(
|
||||
self,
|
||||
CharacterState::Sit
|
||||
| CharacterState::UseItem(Data {
|
||||
static_data: StaticData {
|
||||
item_kind: ItemUseKind::Consumable(
|
||||
ConsumableKind::ComplexFood | ConsumableKind::Food
|
||||
),
|
||||
..
|
||||
},
|
||||
..
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/// Compares for shallow equality (does not check internal struct equality)
|
||||
pub fn same_variant(&self, other: &Self) -> bool {
|
||||
// Check if state is the same without looking at the inner data
|
||||
|
@ -163,11 +163,12 @@ fn activate_aura(
|
||||
let should_activate = match aura.aura_kind {
|
||||
AuraKind::Buff { kind, source, .. } => {
|
||||
let conditions_held = match kind {
|
||||
BuffKind::CampfireHeal => {
|
||||
let target_state = read_data.char_states.get(target);
|
||||
matches!(target_state, Some(CharacterState::Sit))
|
||||
&& health.current() < health.maximum()
|
||||
},
|
||||
BuffKind::CampfireHeal => read_data
|
||||
.char_states
|
||||
.get(target)
|
||||
.map_or(false, |target_state| {
|
||||
target_state.is_sitting() && health.current() < health.maximum()
|
||||
}),
|
||||
// Add other specific buff conditions here
|
||||
_ => true,
|
||||
};
|
||||
@ -175,7 +176,7 @@ fn activate_aura(
|
||||
// TODO: this check will disable friendly fire with PvE switch.
|
||||
//
|
||||
// Which means that you can't apply debuffs on you and your group
|
||||
// even if it's intented mechanic.
|
||||
// even if it's intended mechanic.
|
||||
//
|
||||
// We don't have this for now, but think about this
|
||||
// when we will add this.
|
||||
|
@ -35,7 +35,7 @@ impl Interactable {
|
||||
}
|
||||
}
|
||||
|
||||
/// Select interactable to hightlight, display interaction text for, and to
|
||||
/// Select interactable to highlight, display interaction text for, and to
|
||||
/// interact with if the interact key is pressed
|
||||
/// Selected in the following order:
|
||||
/// 1) Targeted items, in order of nearest under cursor:
|
||||
|
@ -732,6 +732,15 @@ impl PlayState for SessionState {
|
||||
.is_some()
|
||||
{
|
||||
client.pick_up(entity);
|
||||
} else if client
|
||||
.state()
|
||||
.ecs()
|
||||
.read_storage::<comp::Body>()
|
||||
.get(entity)
|
||||
.map_or(false, |b| b.is_campfire())
|
||||
{
|
||||
// TODO: maybe start crafting instead?
|
||||
client.toggle_sit();
|
||||
} else {
|
||||
client.npc_interact(entity);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user