mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix: make climbing cost stamina
This commit is contained in:
parent
2fa902270e
commit
31f3aae75c
@ -2,10 +2,14 @@ Item(
|
|||||||
name: "Weightless Rod",
|
name: "Weightless Rod",
|
||||||
description: "The sky is the limit.",
|
description: "The sky is the limit.",
|
||||||
kind: Tool(
|
kind: Tool(
|
||||||
kind: Debug(Boost),
|
ToolData (
|
||||||
equip_time_millis: 0,
|
kind: Debug(Boost),
|
||||||
attack_buildup_millis: 0,
|
equip_time_millis: 0,
|
||||||
attack_recover_millis: 0,
|
attack_buildup_millis: 0,
|
||||||
|
attack_recover_millis: 0,
|
||||||
|
range: 0,
|
||||||
|
base_damage: 0,
|
||||||
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
// And the ground is pretty hard at maximum velocity...
|
// And the ground is pretty hard at maximum velocity...
|
||||||
|
@ -2,10 +2,14 @@ Item(
|
|||||||
name: "Rod of Possession",
|
name: "Rod of Possession",
|
||||||
description: "It's fixed on my branch.",
|
description: "It's fixed on my branch.",
|
||||||
kind: Tool(
|
kind: Tool(
|
||||||
kind: Debug(Possess),
|
ToolData (
|
||||||
equip_time_millis: 0,
|
kind: Debug(Possess),
|
||||||
attack_buildup_millis: 0,
|
equip_time_millis: 0,
|
||||||
attack_recover_millis: 0,
|
attack_buildup_millis: 0,
|
||||||
|
attack_recover_millis: 0,
|
||||||
|
range: 3,
|
||||||
|
base_damage: 10,
|
||||||
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
// ... as zesterer always uses to tell us.
|
// ... as zesterer always uses to tell us.
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{AbilityPool, Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, ToolData, Vel},
|
comp::{
|
||||||
|
AbilityPool, Body, ControllerInputs, Energy, Ori, PhysicsState, Pos, Stats, ToolData, Vel,
|
||||||
|
},
|
||||||
event::{LocalEvent, ServerEvent},
|
event::{LocalEvent, ServerEvent},
|
||||||
state::DeltaTime,
|
state::DeltaTime,
|
||||||
states::*,
|
states::*,
|
||||||
@ -7,7 +9,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use specs::{Component, Entity, FlaggedStorage, HashMapStorage, LazyUpdate, VecStorage};
|
use specs::{Component, Entity, FlaggedStorage, HashMapStorage, LazyUpdate, VecStorage};
|
||||||
use std::{collections::VecDeque, time::Duration};
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
pub struct EcsStateData<'a> {
|
pub struct EcsStateData<'a> {
|
||||||
pub entity: &'a Entity,
|
pub entity: &'a Entity,
|
||||||
@ -19,6 +21,7 @@ pub struct EcsStateData<'a> {
|
|||||||
pub dt: &'a DeltaTime,
|
pub dt: &'a DeltaTime,
|
||||||
pub inputs: &'a ControllerInputs,
|
pub inputs: &'a ControllerInputs,
|
||||||
pub stats: &'a Stats,
|
pub stats: &'a Stats,
|
||||||
|
pub energy: &'a Energy,
|
||||||
pub body: &'a Body,
|
pub body: &'a Body,
|
||||||
pub physics: &'a PhysicsState,
|
pub physics: &'a PhysicsState,
|
||||||
pub ability_pool: &'a AbilityPool,
|
pub ability_pool: &'a AbilityPool,
|
||||||
@ -30,6 +33,7 @@ pub struct StateUpdate {
|
|||||||
pub pos: Pos,
|
pub pos: Pos,
|
||||||
pub vel: Vel,
|
pub vel: Vel,
|
||||||
pub ori: Ori,
|
pub ori: Ori,
|
||||||
|
pub energy: Energy,
|
||||||
pub local_events: VecDeque<LocalEvent>,
|
pub local_events: VecDeque<LocalEvent>,
|
||||||
pub server_events: VecDeque<ServerEvent>,
|
pub server_events: VecDeque<ServerEvent>,
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ pub enum EnergySource {
|
|||||||
LevelUp,
|
LevelUp,
|
||||||
Regen,
|
Regen,
|
||||||
Revive,
|
Revive,
|
||||||
|
Climb,
|
||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ impl StateHandler for State {
|
|||||||
pos: *ecs_data.pos,
|
pos: *ecs_data.pos,
|
||||||
vel: *ecs_data.vel,
|
vel: *ecs_data.vel,
|
||||||
ori: *ecs_data.ori,
|
ori: *ecs_data.ori,
|
||||||
|
energy: *ecs_data.energy,
|
||||||
character: *ecs_data.character,
|
character: *ecs_data.character,
|
||||||
local_events: VecDeque::new(),
|
local_events: VecDeque::new(),
|
||||||
server_events: VecDeque::new(),
|
server_events: VecDeque::new(),
|
||||||
|
@ -20,6 +20,7 @@ impl StateHandler for State {
|
|||||||
pos: *ecs_data.pos,
|
pos: *ecs_data.pos,
|
||||||
vel: *ecs_data.vel,
|
vel: *ecs_data.vel,
|
||||||
ori: *ecs_data.ori,
|
ori: *ecs_data.ori,
|
||||||
|
energy: *ecs_data.energy,
|
||||||
character: *ecs_data.character,
|
character: *ecs_data.character,
|
||||||
local_events: VecDeque::new(),
|
local_events: VecDeque::new(),
|
||||||
server_events: VecDeque::new(),
|
server_events: VecDeque::new(),
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
use crate::comp::{CharacterState, EcsStateData, StateUpdate};
|
use crate::{
|
||||||
use crate::states::StateHandler;
|
comp::{CharacterState, EcsStateData, EnergySource, StateUpdate},
|
||||||
use crate::sys::phys::GRAVITY;
|
states::StateHandler,
|
||||||
|
sys::phys::GRAVITY,
|
||||||
|
};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use vek::vec::{Vec2, Vec3};
|
use vek::{
|
||||||
use vek::Lerp;
|
vec::{Vec2, Vec3},
|
||||||
|
Lerp,
|
||||||
|
};
|
||||||
|
|
||||||
const HUMANOID_CLIMB_ACCEL: f32 = 5.0;
|
const HUMANOID_CLIMB_ACCEL: f32 = 5.0;
|
||||||
const CLIMB_SPEED: f32 = 5.0;
|
const CLIMB_SPEED: f32 = 5.0;
|
||||||
@ -12,9 +16,7 @@ const CLIMB_SPEED: f32 = 5.0;
|
|||||||
pub struct State;
|
pub struct State;
|
||||||
|
|
||||||
impl StateHandler for State {
|
impl StateHandler for State {
|
||||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
fn new(_ecs_data: &EcsStateData) -> Self { Self {} }
|
||||||
Self {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
|
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
|
||||||
let mut update = StateUpdate {
|
let mut update = StateUpdate {
|
||||||
@ -22,10 +24,15 @@ impl StateHandler for State {
|
|||||||
vel: *ecs_data.vel,
|
vel: *ecs_data.vel,
|
||||||
ori: *ecs_data.ori,
|
ori: *ecs_data.ori,
|
||||||
character: *ecs_data.character,
|
character: *ecs_data.character,
|
||||||
|
energy: *ecs_data.energy,
|
||||||
local_events: VecDeque::new(),
|
local_events: VecDeque::new(),
|
||||||
server_events: VecDeque::new(),
|
server_events: VecDeque::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Err(_) = update.energy.try_change_by(-5, EnergySource::Climb) {
|
||||||
|
update.character = CharacterState::Idle(None);
|
||||||
|
}
|
||||||
|
|
||||||
// If no wall is in front of character ...
|
// If no wall is in front of character ...
|
||||||
if ecs_data.physics.on_wall.is_none() || ecs_data.physics.on_ground {
|
if ecs_data.physics.on_wall.is_none() || ecs_data.physics.on_ground {
|
||||||
if ecs_data.inputs.jump.is_pressed() {
|
if ecs_data.inputs.jump.is_pressed() {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
use crate::comp::{CharacterState, EcsStateData, StateUpdate};
|
use crate::{
|
||||||
use crate::states::StateHandler;
|
comp::{CharacterState, EcsStateData, StateUpdate},
|
||||||
|
states::StateHandler,
|
||||||
|
};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use vek::{Vec2, Vec3};
|
use vek::{Vec2, Vec3};
|
||||||
|
|
||||||
@ -12,15 +14,14 @@ const GLIDE_SPEED: f32 = 45.0;
|
|||||||
pub struct State;
|
pub struct State;
|
||||||
|
|
||||||
impl StateHandler for State {
|
impl StateHandler for State {
|
||||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
fn new(_ecs_data: &EcsStateData) -> Self { Self {} }
|
||||||
Self {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
|
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
|
||||||
let mut update = StateUpdate {
|
let mut update = StateUpdate {
|
||||||
pos: *ecs_data.pos,
|
pos: *ecs_data.pos,
|
||||||
vel: *ecs_data.vel,
|
vel: *ecs_data.vel,
|
||||||
ori: *ecs_data.ori,
|
ori: *ecs_data.ori,
|
||||||
|
energy: *ecs_data.energy,
|
||||||
character: *ecs_data.character,
|
character: *ecs_data.character,
|
||||||
local_events: VecDeque::new(),
|
local_events: VecDeque::new(),
|
||||||
server_events: VecDeque::new(),
|
server_events: VecDeque::new(),
|
||||||
|
@ -7,9 +7,7 @@ use crate::states::StateHandler;
|
|||||||
pub struct State;
|
pub struct State;
|
||||||
|
|
||||||
impl StateHandler for State {
|
impl StateHandler for State {
|
||||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
fn new(_ecs_data: &EcsStateData) -> Self { Self {} }
|
||||||
Self {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
|
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
|
||||||
let mut update = StateUpdate {
|
let mut update = StateUpdate {
|
||||||
@ -17,6 +15,7 @@ impl StateHandler for State {
|
|||||||
pos: *ecs_data.pos,
|
pos: *ecs_data.pos,
|
||||||
vel: *ecs_data.vel,
|
vel: *ecs_data.vel,
|
||||||
ori: *ecs_data.ori,
|
ori: *ecs_data.ori,
|
||||||
|
energy: *ecs_data.energy,
|
||||||
local_events: VecDeque::new(),
|
local_events: VecDeque::new(),
|
||||||
server_events: VecDeque::new(),
|
server_events: VecDeque::new(),
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData};
|
use crate::{
|
||||||
use crate::states::StateHandler;
|
comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData},
|
||||||
use std::collections::VecDeque;
|
states::StateHandler,
|
||||||
use std::time::Duration;
|
};
|
||||||
|
use std::{collections::VecDeque, time::Duration};
|
||||||
use vek::Vec3;
|
use vek::Vec3;
|
||||||
|
|
||||||
const ROLL_SPEED: f32 = 17.0;
|
const ROLL_SPEED: f32 = 17.0;
|
||||||
@ -31,6 +32,7 @@ impl StateHandler for State {
|
|||||||
pos: *ecs_data.pos,
|
pos: *ecs_data.pos,
|
||||||
vel: *ecs_data.vel,
|
vel: *ecs_data.vel,
|
||||||
ori: *ecs_data.ori,
|
ori: *ecs_data.ori,
|
||||||
|
energy: *ecs_data.energy,
|
||||||
local_events: VecDeque::new(),
|
local_events: VecDeque::new(),
|
||||||
server_events: VecDeque::new(),
|
server_events: VecDeque::new(),
|
||||||
};
|
};
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::comp::{CharacterState, EcsStateData, StateUpdate};
|
use crate::{
|
||||||
use crate::states::StateHandler;
|
comp::{CharacterState, EcsStateData, StateUpdate},
|
||||||
|
states::StateHandler,
|
||||||
|
};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||||
pub struct State;
|
pub struct State;
|
||||||
|
|
||||||
impl StateHandler for State {
|
impl StateHandler for State {
|
||||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
fn new(_ecs_data: &EcsStateData) -> Self { Self {} }
|
||||||
Self {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
|
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
|
||||||
let mut update = StateUpdate {
|
let mut update = StateUpdate {
|
||||||
@ -17,6 +17,7 @@ impl StateHandler for State {
|
|||||||
pos: *ecs_data.pos,
|
pos: *ecs_data.pos,
|
||||||
vel: *ecs_data.vel,
|
vel: *ecs_data.vel,
|
||||||
ori: *ecs_data.ori,
|
ori: *ecs_data.ori,
|
||||||
|
energy: *ecs_data.energy,
|
||||||
local_events: VecDeque::new(),
|
local_events: VecDeque::new(),
|
||||||
server_events: VecDeque::new(),
|
server_events: VecDeque::new(),
|
||||||
};
|
};
|
||||||
|
@ -31,6 +31,7 @@ impl StateHandler for State {
|
|||||||
pos: *ecs_data.pos,
|
pos: *ecs_data.pos,
|
||||||
vel: *ecs_data.vel,
|
vel: *ecs_data.vel,
|
||||||
ori: *ecs_data.ori,
|
ori: *ecs_data.ori,
|
||||||
|
energy: *ecs_data.energy,
|
||||||
local_events: VecDeque::new(),
|
local_events: VecDeque::new(),
|
||||||
server_events: VecDeque::new(),
|
server_events: VecDeque::new(),
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData};
|
use crate::{
|
||||||
use crate::states::StateHandler;
|
comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData},
|
||||||
use std::collections::VecDeque;
|
states::StateHandler,
|
||||||
use std::time::Duration;
|
};
|
||||||
|
use std::{collections::VecDeque, time::Duration};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
@ -31,6 +32,7 @@ impl StateHandler for State {
|
|||||||
pos: *ecs_data.pos,
|
pos: *ecs_data.pos,
|
||||||
vel: *ecs_data.vel,
|
vel: *ecs_data.vel,
|
||||||
ori: *ecs_data.ori,
|
ori: *ecs_data.ori,
|
||||||
|
energy: *ecs_data.energy,
|
||||||
local_events: VecDeque::new(),
|
local_events: VecDeque::new(),
|
||||||
server_events: VecDeque::new(),
|
server_events: VecDeque::new(),
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{
|
comp::{
|
||||||
AbilityPool, Body, CharacterState, Controller, EcsStateData, Mounting, Ori, PhysicsState,
|
AbilityPool, Body, CharacterState, Controller, EcsStateData, Energy, Mounting, Ori,
|
||||||
Pos, Stats, Vel,
|
PhysicsState, Pos, Stats, Vel,
|
||||||
},
|
},
|
||||||
event::{EventBus, LocalEvent, ServerEvent},
|
event::{EventBus, LocalEvent, ServerEvent},
|
||||||
state::DeltaTime,
|
state::DeltaTime,
|
||||||
@ -11,10 +11,11 @@ use crate::{
|
|||||||
use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage};
|
use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage};
|
||||||
|
|
||||||
/// ## Character State System
|
/// ## Character State System
|
||||||
/// #### Calls updates to `CharacterState`s. Acts on tuples of ( `CharacterState`, `Pos`, `Vel`, and `Ori` ).
|
/// #### Calls updates to `CharacterState`s. Acts on tuples of (
|
||||||
|
/// `CharacterState`, `Pos`, `Vel`, and `Ori` ).
|
||||||
///
|
///
|
||||||
/// _System forms `EcsStateData` tuples and passes those to `ActionState` `update()` fn,
|
/// _System forms `EcsStateData` tuples and passes those to `ActionState`
|
||||||
/// then does the same for `MoveState` `update`_
|
/// `update()` fn, then does the same for `MoveState` `update`_
|
||||||
pub struct Sys;
|
pub struct Sys;
|
||||||
|
|
||||||
impl<'a> System<'a> for Sys {
|
impl<'a> System<'a> for Sys {
|
||||||
@ -29,6 +30,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
WriteStorage<'a, Pos>,
|
WriteStorage<'a, Pos>,
|
||||||
WriteStorage<'a, Vel>,
|
WriteStorage<'a, Vel>,
|
||||||
WriteStorage<'a, Ori>,
|
WriteStorage<'a, Ori>,
|
||||||
|
WriteStorage<'a, Energy>,
|
||||||
ReadStorage<'a, Controller>,
|
ReadStorage<'a, Controller>,
|
||||||
ReadStorage<'a, Stats>,
|
ReadStorage<'a, Stats>,
|
||||||
ReadStorage<'a, Body>,
|
ReadStorage<'a, Body>,
|
||||||
@ -37,6 +39,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
ReadStorage<'a, Uid>,
|
ReadStorage<'a, Uid>,
|
||||||
ReadStorage<'a, Mounting>,
|
ReadStorage<'a, Mounting>,
|
||||||
);
|
);
|
||||||
|
|
||||||
fn run(
|
fn run(
|
||||||
&mut self,
|
&mut self,
|
||||||
(
|
(
|
||||||
@ -50,6 +53,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
mut positions,
|
mut positions,
|
||||||
mut velocities,
|
mut velocities,
|
||||||
mut orientations,
|
mut orientations,
|
||||||
|
mut energies,
|
||||||
controllers,
|
controllers,
|
||||||
stats,
|
stats,
|
||||||
bodies,
|
bodies,
|
||||||
@ -66,6 +70,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
pos,
|
pos,
|
||||||
vel,
|
vel,
|
||||||
ori,
|
ori,
|
||||||
|
energy,
|
||||||
controller,
|
controller,
|
||||||
stats,
|
stats,
|
||||||
body,
|
body,
|
||||||
@ -78,6 +83,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
&mut positions,
|
&mut positions,
|
||||||
&mut velocities,
|
&mut velocities,
|
||||||
&mut orientations,
|
&mut orientations,
|
||||||
|
&mut energies,
|
||||||
&controllers,
|
&controllers,
|
||||||
&stats,
|
&stats,
|
||||||
&bodies,
|
&bodies,
|
||||||
@ -113,6 +119,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
pos,
|
pos,
|
||||||
vel,
|
vel,
|
||||||
ori,
|
ori,
|
||||||
|
energy,
|
||||||
dt: &dt,
|
dt: &dt,
|
||||||
inputs,
|
inputs,
|
||||||
stats,
|
stats,
|
||||||
@ -126,6 +133,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
*pos = state_update.pos;
|
*pos = state_update.pos;
|
||||||
*vel = state_update.vel;
|
*vel = state_update.vel;
|
||||||
*ori = state_update.ori;
|
*ori = state_update.ori;
|
||||||
|
*energy = state_update.energy;
|
||||||
local_bus.emitter().append(&mut state_update.local_events);
|
local_bus.emitter().append(&mut state_update.local_events);
|
||||||
server_bus.emitter().append(&mut state_update.server_events);
|
server_bus.emitter().append(&mut state_update.server_events);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage};
|
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
pub const GRAVITY: f32 = 9.81 * 7.0;
|
pub const GRAVITY: f32 = 9.81 * 10.0;
|
||||||
const BOUYANCY: f32 = 0.0;
|
const BOUYANCY: f32 = 0.0;
|
||||||
// Friction values used for linear damping. They are unitless quantities. The
|
// Friction values used for linear damping. They are unitless quantities. The
|
||||||
// value of these quantities must be between zero and one. They represent the
|
// value of these quantities must be between zero and one. They represent the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user