fix: jumping and attacking

This commit is contained in:
timokoesters 2020-02-03 11:54:50 +01:00
parent 76dfac7366
commit aa52c6fd4f
19 changed files with 154 additions and 242 deletions

View File

@ -21,7 +21,7 @@ impl Component for AbilityAction {
type Storage = FlaggedStorage<Self, VecStorage<Self>>;
}
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
pub struct AbilityPool {
pub primary: Option<comp::CharacterState>,
pub secondary: Option<comp::CharacterState>,
@ -29,6 +29,17 @@ pub struct AbilityPool {
pub dodge: Option<comp::CharacterState>,
}
impl Default for AbilityPool {
fn default() -> Self {
Self {
primary: Some(comp::CharacterState::BasicAttack(None)),
secondary: None,
block: None,
dodge: Some(comp::CharacterState::Roll(None)),
}
}
}
impl Component for AbilityPool {
type Storage = FlaggedStorage<Self, HashMapStorage<Self>>;
}

View File

@ -1,7 +1,7 @@
use crate::states::*;
use crate::{
comp::{Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel},
event::{EventBus, LocalEvent, ServerEvent},
comp::{AbilityPool, Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel},
event::{LocalEvent, ServerEvent},
state::DeltaTime,
sync::Uid,
};
@ -9,6 +9,7 @@ use serde::Deserialize;
use serde::Serialize;
use specs::LazyUpdate;
use specs::{Component, Entity, FlaggedStorage, HashMapStorage};
use std::collections::VecDeque;
pub struct EcsStateData<'a> {
pub entity: &'a Entity,
@ -22,9 +23,8 @@ pub struct EcsStateData<'a> {
pub stats: &'a Stats,
pub body: &'a Body,
pub physics: &'a PhysicsState,
pub ability_pool: &'a AbilityPool,
pub updater: &'a LazyUpdate,
pub server_bus: &'a EventBus<ServerEvent>,
pub local_bus: &'a EventBus<LocalEvent>,
}
pub struct StateUpdate {
@ -32,6 +32,8 @@ pub struct StateUpdate {
pub pos: Pos,
pub vel: Vel,
pub ori: Ori,
pub local_events: VecDeque<LocalEvent>,
pub server_events: VecDeque<ServerEvent>,
}
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
@ -41,17 +43,17 @@ pub enum CharacterState {
Sit(Option<sit::State>),
Wielding(Option<wielding::State>),
Wielded(Option<wielded::State>),
//BasicAttack(Option<basic_attack::State>),
Glide(Option<glide::State>),
BasicAttack(Option<basic_attack::State>),
//BasicBlock(Option<basic_block::State>),
//Charge(Option<charge_attack::State>),
Roll(Option<roll::State>),
Glide(Option<glide::State>),
}
impl CharacterState {
pub fn is_attack(&self) -> bool {
match self {
//CharacterState::BasicAttack(_) => true,
CharacterState::BasicAttack(_) => true,
_ => false,
}
}
@ -83,7 +85,9 @@ impl CharacterState {
pub fn update(&self, ecs_data: &EcsStateData) -> StateUpdate {
match self {
CharacterState::Idle(opt_state) => opt_state
// If data hasn't been initialized, initialize a new one
.unwrap_or_else(|| idle::State::new(ecs_data))
// Call handler
.handle(ecs_data),
CharacterState::Climb(opt_state) => opt_state
.unwrap_or_else(|| climb::State::new(ecs_data))
@ -97,12 +101,10 @@ impl CharacterState {
CharacterState::Wielded(opt_state) => opt_state
.unwrap_or_else(|| wielded::State::new(ecs_data))
.handle(ecs_data),
/*CharacterState::BasicAttack(opt_state) => opt_state
// If data hasn't been initialized, initialize a new one
CharacterState::BasicAttack(opt_state) => opt_state
.unwrap_or_else(|| basic_attack::State::new(ecs_data))
// Call handler
.handle(ecs_data),
CharacterState::Charge(opt_state) => opt_state
/*CharacterState::Charge(opt_state) => opt_state
.unwrap_or_else(|| charge_attack::State::new(ecs_data))
.handle(ecs_data),
CharacterState::BasicBlock(opt_state) => opt_state
@ -115,7 +117,7 @@ impl CharacterState {
.unwrap_or_else(|| glide::State::new(ecs_data))
.handle(ecs_data),
// All states should be explicitly handled
// Do not use default match: _ => {},
// DO NOT use default match: _ => {},
}
}
}

View File

@ -146,6 +146,9 @@ impl<'a, E> Emitter<'a, E> {
pub fn emit(&mut self, event: E) {
self.events.push_front(event);
}
pub fn append(&mut self, other: &mut VecDeque<E>) {
self.events.append(other)
}
}
impl<'a, E> Drop for Emitter<'a, E> {

View File

@ -1,9 +1,6 @@
use super::utils::*;
use crate::comp::{
ActionState::Attack, AttackKind::BasicAttack, EcsStateData, ItemKind::Tool, StateUpdate,
ToolData,
};
use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData};
use crate::states::StateHandler;
use std::collections::VecDeque;
use std::time::Duration;
@ -32,22 +29,22 @@ impl StateHandler for State {
vel: *ecs_data.vel,
ori: *ecs_data.ori,
character: *ecs_data.character,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
// Check if attack duration has expired
if self.remaining_duration == Duration::default() {
// If so, go back to wielding or idling
update.character.action_state = attempt_wield(ecs_data.stats);
return update;
}
// Otherwise, tick down remaining_duration, and keep rolling
update.character.action_state = Attack(BasicAttack(Some(State {
// Tick down remaining_duration
update.character = CharacterState::BasicAttack(Some(State {
remaining_duration: self
.remaining_duration
.checked_sub(Duration::from_secs_f32(ecs_data.dt.0))
.unwrap_or_default(),
})));
}));
// Check if attack duration has expired
if self.remaining_duration == Duration::default() {
update.character = CharacterState::Wielded(None);
}
update
}

View File

@ -1,6 +1,7 @@
use crate::comp::{CharacterState, EcsStateData, StateUpdate};
use crate::states::StateHandler;
use crate::sys::phys::GRAVITY;
use std::collections::VecDeque;
use vek::vec::{Vec2, Vec3};
use vek::Lerp;
@ -21,6 +22,8 @@ impl StateHandler for State {
vel: *ecs_data.vel,
ori: *ecs_data.ori,
character: *ecs_data.character,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
// If no wall is in front of character ...

View File

@ -1,5 +1,6 @@
use crate::comp::{CharacterState, EcsStateData, StateUpdate};
use crate::states::StateHandler;
use std::collections::VecDeque;
use vek::{Vec2, Vec3};
// Gravity is 9.81 * 4, so this makes gravity equal to .15
@ -21,6 +22,8 @@ impl StateHandler for State {
vel: *ecs_data.vel,
ori: *ecs_data.ori,
character: *ecs_data.character,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
// If glide button isn't held or player is on ground, end glide

View File

@ -1,5 +1,6 @@
use super::utils::*;
use crate::comp::{EcsStateData, StateUpdate};
use std::collections::VecDeque;
use crate::states::StateHandler;
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
@ -16,15 +17,17 @@ impl StateHandler for State {
pos: *ecs_data.pos,
vel: *ecs_data.vel,
ori: *ecs_data.ori,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
handle_move_dir(ecs_data, &mut update);
handle_jump(ecs_data, &mut update);
handle_wield(ecs_data, &mut update);
handle_sit(ecs_data, &mut update);
handle_climb(ecs_data, &mut update);
handle_roll(ecs_data, &mut update);
//handle_jump(ecs_data, &mut update);
handle_glide(ecs_data, &mut update);
handle_dodge(ecs_data, &mut update);
update
}

View File

@ -1,4 +1,5 @@
// Module declarations
pub mod basic_attack;
pub mod climb;
pub mod glide;
pub mod idle;

View File

@ -1,6 +1,6 @@
use super::utils::*;
use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData};
use crate::states::StateHandler;
use std::collections::VecDeque;
use std::time::Duration;
use vek::Vec3;
@ -31,6 +31,8 @@ impl StateHandler for State {
pos: *ecs_data.pos,
vel: *ecs_data.vel,
ori: *ecs_data.ori,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
// Update velocity

View File

@ -1,6 +1,7 @@
use super::utils::*;
use crate::comp::{CharacterState, EcsStateData, StateUpdate};
use crate::states::StateHandler;
use std::collections::VecDeque;
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
pub struct State;
@ -16,6 +17,8 @@ impl StateHandler for State {
pos: *ecs_data.pos,
vel: *ecs_data.vel,
ori: *ecs_data.ori,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
//handle_jump(ecs_data, &mut update);

View File

@ -1,111 +1,9 @@
use crate::comp::{
Body, CharacterState, ControllerInputs, EcsStateData, ItemKind::Tool, PhysicsState,
StateUpdate, Stats,
use crate::{
comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate},
event::LocalEvent,
};
use vek::vec::{Vec2, Vec3};
/*
/// _Determines what ability a player has selected for their primary ability,
/// and returns the corresponding `ActionState` or Idle if nothing_
pub fn determine_primary_ability(stats: &Stats) -> ActionState {
if let Some(Tool(_)) = stats.equipment.main.as_ref().map(|i| &i.kind) {
Attack(BasicAttack(None))
} else {
Idle(None)
}
}
/// _Determines what ability a player has selected for their primary ability,
/// and returns the corresponding `ActionState` or Idle if nothing_
pub fn determine_secondary_ability(stats: &Stats) -> ActionState {
if let Some(Tool(_)) = stats.equipment.main.as_ref().map(|i| &i.kind) {
Block(BasicBlock(None))
} else {
Idle(None)
}
}
/// _Returns a `MoveState` based on `in_fluid` condition_
pub fn determine_fall_or_swim(physics: &PhysicsState) -> MoveState {
// Check if in fluid to go to swimming or back to falling
if physics.in_fluid {
Swim(None)
} else {
Fall(None)
}
}
/// _Returns a `MoveState` based on `move_dir` magnitude_
pub fn determine_stand_or_run(inputs: &ControllerInputs) -> MoveState {
// Return to running or standing based on move inputs
if inputs.move_dir.magnitude_squared() > 0.0 {
Run(None)
} else {
Stand(None)
}
}
/// _Returns a `MoveState` based on `on_ground` state._
///
/// _`FallState`, or `SwimState` if not `on_ground`,
/// `StandState` or `RunState` if is `on_ground`_
pub fn determine_move_from_grounded_state(
physics: &PhysicsState,
inputs: &ControllerInputs,
) -> MoveState {
// Not on ground, go to swim or fall
if !physics.on_ground {
determine_fall_or_swim(physics)
}
// On ground
else {
determine_stand_or_run(inputs)
}
}
/// _Returns an ActionState based on whether character has a weapon equipped._
pub fn attempt_wield(stats: &Stats) -> ActionState {
if let Some(Tool(_)) = stats.equipment.main.as_ref().map(|i| &i.kind) {
Wield(None)
} else {
Idle(None)
}
}
pub fn can_climb(physics: &PhysicsState, inputs: &ControllerInputs, body: &Body) -> bool {
if let (true, Some(_wall_dir)) = (
(inputs.climb.is_pressed() | inputs.climb_down.is_pressed()) && body.is_humanoid(),
physics.on_wall,
) {
true
} else {
false
}
}
pub fn can_glide(physics: &PhysicsState, inputs: &ControllerInputs, body: &Body) -> bool {
if inputs.glide.is_pressed() && body.is_humanoid() && physics.on_wall == None {
true
} else {
false
}
}
pub fn can_sit(physics: &PhysicsState, inputs: &ControllerInputs, body: &Body) -> bool {
if inputs.sit.is_pressed() && physics.on_ground && body.is_humanoid() {
true
} else {
false
}
}
pub fn can_jump(physics: &PhysicsState, inputs: &ControllerInputs) -> bool {
if physics.on_ground && inputs.jump.is_pressed() {
true
} else {
false
}
}*/
pub fn handle_move_dir(ecs_data: &EcsStateData, update: &mut StateUpdate) {
let (accel, speed): (f32, f32) = if ecs_data.physics.on_ground {
let accel = 50.0;
@ -166,15 +64,6 @@ pub fn handle_climb(ecs_data: &EcsStateData, update: &mut StateUpdate) {
}
}
pub fn handle_roll(ecs_data: &EcsStateData, update: &mut StateUpdate) {
if ecs_data.inputs.roll.is_pressed()
&& ecs_data.physics.on_ground
&& ecs_data.body.is_humanoid()
{
update.character = CharacterState::Roll(None);
}
}
pub fn handle_unwield(ecs_data: &EcsStateData, update: &mut StateUpdate) {
if let CharacterState::Wielded(_) = update.character {
if ecs_data.inputs.toggle_wield.is_pressed() {
@ -184,10 +73,43 @@ pub fn handle_unwield(ecs_data: &EcsStateData, update: &mut StateUpdate) {
}
pub fn handle_glide(ecs_data: &EcsStateData, update: &mut StateUpdate) {
if ecs_data.inputs.glide.is_pressed()
&& !ecs_data.physics.on_ground
&& ecs_data.body.is_humanoid()
{
update.character = CharacterState::Glide(None);
if let CharacterState::Idle(_) | CharacterState::Wielded(_) = update.character {
if ecs_data.inputs.glide.is_pressed()
&& !ecs_data.physics.on_ground
&& ecs_data.body.is_humanoid()
{
update.character = CharacterState::Glide(None);
}
}
}
pub fn handle_jump(ecs_data: &EcsStateData, update: &mut StateUpdate) {
if ecs_data.inputs.jump.is_pressed() && ecs_data.physics.on_ground {
update
.local_events
.push_front(LocalEvent::Jump(*ecs_data.entity));
}
}
pub fn handle_primary(ecs_data: &EcsStateData, update: &mut StateUpdate) {
if let Some(state) = ecs_data.ability_pool.primary {
if let CharacterState::Wielded(_) = update.character {
if ecs_data.inputs.primary.is_pressed() {
update.character = state;
}
}
}
}
pub fn handle_dodge(ecs_data: &EcsStateData, update: &mut StateUpdate) {
if let Some(state) = ecs_data.ability_pool.dodge {
if let CharacterState::Idle(_) | CharacterState::Wielded(_) = update.character {
if ecs_data.inputs.roll.is_pressed()
&& ecs_data.physics.on_ground
&& ecs_data.body.is_humanoid()
{
update.character = state;
}
}
}
}

View File

@ -1,6 +1,7 @@
use super::utils::*;
use crate::comp::{EcsStateData, ItemKind::Tool, StateUpdate, ToolData};
use crate::states::StateHandler;
use std::collections::VecDeque;
use std::time::Duration;
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
@ -29,14 +30,18 @@ impl StateHandler for State {
pos: *ecs_data.pos,
vel: *ecs_data.vel,
ori: *ecs_data.ori,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
handle_move_dir(&ecs_data, &mut update);
handle_jump(&ecs_data, &mut update);
handle_sit(&ecs_data, &mut update);
handle_roll(&ecs_data, &mut update);
handle_climb(&ecs_data, &mut update);
handle_glide(&ecs_data, &mut update);
handle_unwield(&ecs_data, &mut update);
handle_primary(&ecs_data, &mut update);
handle_dodge(&ecs_data, &mut update);
update
}

View File

@ -1,6 +1,7 @@
use super::utils::*;
use crate::comp::{CharacterState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData};
use crate::states::StateHandler;
use std::collections::VecDeque;
use std::time::Duration;
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
@ -30,6 +31,8 @@ impl StateHandler for State {
pos: *ecs_data.pos,
vel: *ecs_data.vel,
ori: *ecs_data.ori,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
handle_move_dir(&ecs_data, &mut update);

View File

@ -1,65 +0,0 @@
#![allow(unused_imports)]
#![allow(dead_code)]
use crate::comp::{AbilityAction, AbilityActionKind, AbilityPool, CharacterState};
use crate::states::StateHandler;
use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage};
/// # Ability System
/// #### Updates tuples of ( `CharacterState`, `AbilityAction`, and `AbilityPool`s )
/// _Each update determines what type of ability is being started, and looks into the AbilityPool for which
/// Ability that should be used. System then updates `CharacterState` to that Ability._
pub struct Sys;
impl<'a> System<'a> for Sys {
type SystemData = (
Entities<'a>,
Read<'a, LazyUpdate>,
WriteStorage<'a, CharacterState>,
ReadStorage<'a, AbilityAction>,
ReadStorage<'a, AbilityPool>,
);
fn run(
&mut self,
(
entities,
_updater,
mut character_state_storage,
ability_action_storage,
ability_pool_storage,
): Self::SystemData,
) {
for (_entity, mut _character, _ability_action, _ability_pool) in (
&entities,
&mut character_state_storage,
&ability_action_storage,
&ability_pool_storage,
)
.join()
{
// match ability_action.0 {
// AbilityActionKind::Primary => {
// if let Some(AttackKind(Some(attack_kind))) = ability_pool.primary {
// character.action_state = Attack(attack_kind::default());
// }
// }
// AbilityActionKind::Secondary => {
// if let Some(attack_kind) = ability_pool.secondary {
// character.action_state = Attack(attack_kind::default());
// }
// }
// AbilityActionKind::Block => {
// if let Some(block_kind) = ability_pool.block {
// character.action_state = Block(block_kind::default());
// }
// }
// AbilityActionKind::Dodge => {
// if let Some(dodge_kind) = ability_pool.dodge {
// character.action_state = Dodge(dodge_kind::default());
// }
// }
// _ => {}
// }
}
}
}

View File

@ -1,7 +1,7 @@
use crate::{
comp::{
Body, CharacterState, Controller, EcsStateData, Mounting, Ori, PhysicsState, Pos, Stats,
Vel,
AbilityPool, Body, CharacterState, Controller, EcsStateData, Mounting, Ori, PhysicsState,
Pos, Stats, Vel,
},
event::{EventBus, LocalEvent, ServerEvent},
state::DeltaTime,
@ -33,6 +33,7 @@ impl<'a> System<'a> for Sys {
ReadStorage<'a, Stats>,
ReadStorage<'a, Body>,
ReadStorage<'a, PhysicsState>,
ReadStorage<'a, AbilityPool>,
ReadStorage<'a, Uid>,
ReadStorage<'a, Mounting>,
);
@ -53,11 +54,24 @@ impl<'a> System<'a> for Sys {
stats,
bodies,
physics_states,
ability_pools,
uids,
mountings,
): Self::SystemData,
) {
for (entity, uid, mut character, pos, vel, ori, controller, stats, body, physics) in (
for (
entity,
uid,
character,
pos,
vel,
ori,
controller,
stats,
body,
physics,
ability_pool,
) in (
&entities,
&uids,
&mut character_states,
@ -68,6 +82,7 @@ impl<'a> System<'a> for Sys {
&stats,
&bodies,
&physics_states,
&ability_pools,
)
.join()
{
@ -91,7 +106,7 @@ impl<'a> System<'a> for Sys {
return;
}
let state_update = character.update(&EcsStateData {
let mut state_update = character.update(&EcsStateData {
entity: &entity,
uid,
character,
@ -104,14 +119,15 @@ impl<'a> System<'a> for Sys {
body,
physics,
updater: &updater,
server_bus: &server_bus,
local_bus: &local_bus,
ability_pool,
});
*character = state_update.character;
*pos = state_update.pos;
*vel = state_update.vel;
*ori = state_update.ori;
local_bus.emitter().append(&mut state_update.local_events);
server_bus.emitter().append(&mut state_update.server_events);
}
}
}

View File

@ -1,4 +1,3 @@
mod ability;
pub mod agent;
pub mod character_state;
pub mod controller;
@ -11,7 +10,6 @@ mod stats;
use specs::DispatcherBuilder;
// System names
pub const ABILITY_SYS: &str = "ability_sys";
pub const CHARACTER_STATE_SYS: &str = "character_state_sys";
pub const AGENT_SYS: &str = "agent_sys";
pub const CONTROLLER_SYS: &str = "controller_sys";
@ -27,7 +25,6 @@ pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {
dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS, MOUNT_SYS]);
dispatch_builder.add(character_state::Sys, CHARACTER_STATE_SYS, &[CONTROLLER_SYS]);
dispatch_builder.add(stats::Sys, STATS_SYS, &[]);
dispatch_builder.add(ability::Sys, ABILITY_SYS, &[CHARACTER_STATE_SYS]);
dispatch_builder.add(phys::Sys, PHYS_SYS, &[CONTROLLER_SYS, MOUNT_SYS, STATS_SYS]);
dispatch_builder.add(projectile::Sys, PROJECTILE_SYS, &[PHYS_SYS]);
}

View File

@ -267,6 +267,7 @@ impl Server {
state.write_component(entity, comp::CharacterState::default());
state.write_component(entity, comp::Inventory::default());
state.write_component(entity, comp::InventoryUpdate);
state.write_component(entity, comp::AbilityPool::default());
// Make sure physics are accepted.
state.write_component(entity, comp::ForceUpdate);
@ -1188,6 +1189,7 @@ impl StateExt for State {
.with(comp::Energy::new(100))
.with(comp::Gravity(1.0))
.with(comp::CharacterState::default())
.with(comp::AbilityPool::default())
}
fn notify_registered_clients(&self, msg: ServerMsg) {

View File

@ -1,8 +1,8 @@
use super::SysTimer;
use common::{
comp::{
Body, CanBuild, Energy, Gravity, Item, LightEmitter, Mass, MountState, Mounting, Player,
Scale, Stats, Sticky,
AbilityPool, Body, CanBuild, Energy, Gravity, Item, LightEmitter, Mass, MountState,
Mounting, Player, Scale, Stats, Sticky,
},
msg::EcsCompPacket,
sync::{EntityPackage, SyncPackage, Uid, UpdateTracker, WorldSyncExt},
@ -50,6 +50,7 @@ pub struct TrackedComps<'a> {
pub mass: ReadStorage<'a, Mass>,
pub sticky: ReadStorage<'a, Sticky>,
pub gravity: ReadStorage<'a, Gravity>,
pub ability_pool: ReadStorage<'a, AbilityPool>,
}
impl<'a> TrackedComps<'a> {
pub fn create_entity_package(&self, entity: EcsEntity) -> EntityPackage<EcsCompPacket> {
@ -103,6 +104,10 @@ impl<'a> TrackedComps<'a> {
.get(entity)
.copied()
.map(|c| comps.push(c.into()));
self.ability_pool
.get(entity)
.copied()
.map(|c| comps.push(c.into()));
EntityPackage { uid, comps }
}
@ -123,6 +128,7 @@ pub struct ReadTrackers<'a> {
pub mass: ReadExpect<'a, UpdateTracker<Mass>>,
pub sticky: ReadExpect<'a, UpdateTracker<Sticky>>,
pub gravity: ReadExpect<'a, UpdateTracker<Gravity>>,
pub ability_pool: ReadExpect<'a, UpdateTracker<AbilityPool>>,
}
impl<'a> ReadTrackers<'a> {
pub fn create_sync_package(
@ -150,6 +156,7 @@ impl<'a> ReadTrackers<'a> {
.with_component(&comps.uid, &*self.mass, &comps.mass, filter)
.with_component(&comps.uid, &*self.sticky, &comps.sticky, filter)
.with_component(&comps.uid, &*self.gravity, &comps.gravity, filter)
.with_component(&comps.uid, &*self.ability_pool, &comps.ability_pool, filter)
}
}
@ -169,6 +176,7 @@ pub struct WriteTrackers<'a> {
mass: WriteExpect<'a, UpdateTracker<Mass>>,
sticky: WriteExpect<'a, UpdateTracker<Sticky>>,
gravity: WriteExpect<'a, UpdateTracker<Gravity>>,
ability_pool: WriteExpect<'a, UpdateTracker<AbilityPool>>,
}
fn record_changes(comps: &TrackedComps, trackers: &mut WriteTrackers) {
@ -187,6 +195,7 @@ fn record_changes(comps: &TrackedComps, trackers: &mut WriteTrackers) {
trackers.mass.record_changes(&comps.mass);
trackers.sticky.record_changes(&comps.sticky);
trackers.gravity.record_changes(&comps.gravity);
trackers.ability_pool.record_changes(&comps.ability_pool);
}
pub fn register_trackers(world: &mut World) {
@ -204,6 +213,7 @@ pub fn register_trackers(world: &mut World) {
world.register_tracker::<Mass>();
world.register_tracker::<Sticky>();
world.register_tracker::<Gravity>();
world.register_tracker::<AbilityPool>();
}
/// Deleted entities grouped by region

View File

@ -331,12 +331,6 @@ impl FigureMgr {
let mut state_animation_rate = 1.0;
let vel = ecs
.read_storage::<Vel>()
.get(entity)
.cloned()
.unwrap_or_default();
let active_tool_kind = if let Some(ItemKind::Tool(ToolData { kind, .. })) = stats
.and_then(|s| s.equipment.main.as_ref())
.map(|i| &i.kind)
@ -407,6 +401,15 @@ impl FigureMgr {
&mut state_animation_rate,
skeleton_attr,
),
CharacterState::BasicAttack(_) => {
anim::character::AttackAnimation::update_skeleton(
&target_base,
(active_tool_kind, time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
}
/*CharacterState::Block(_) => {
anim::character::BlockIdleAnimation::update_skeleton(
&target_base,
@ -424,15 +427,6 @@ impl FigureMgr {
&mut state_animation_rate,
skeleton_attr,
)
}
CharacterState::BasicAttack(_) => {
anim::character::AttackAnimation::update_skeleton(
&target_base,
(active_tool_kind, time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
}*/
CharacterState::Wielding(_) => {
anim::character::WieldAnimation::update_skeleton(