2020-03-15 14:31:38 +00:00
|
|
|
#ifndef MWVR_REALISTICCOMBAT_H
|
|
|
|
#define MWVR_REALISTICCOMBAT_H
|
|
|
|
|
|
|
|
#include <components/esm/loadweap.hpp>
|
|
|
|
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
|
|
|
|
#include "vrenvironment.hpp"
|
|
|
|
#include "openxrsession.hpp"
|
|
|
|
|
|
|
|
namespace MWVR { namespace RealisticCombat {
|
|
|
|
enum SwingState
|
|
|
|
{
|
2020-03-23 22:32:47 +00:00
|
|
|
SwingState_Idle = 0,
|
|
|
|
SwingState_Ready = 1,
|
|
|
|
SwingState_Swinging = 2,
|
|
|
|
SwingState_Impact = 3
|
2020-03-15 14:31:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct StateMachine
|
|
|
|
{
|
|
|
|
// TODO: These should be configurable
|
|
|
|
const float minVelocity = 1.f;
|
|
|
|
const float maxVelocity = 4.f;
|
|
|
|
|
|
|
|
float velocity = 0.f;
|
|
|
|
float maxSwingVelocity = 0.f;
|
|
|
|
|
2020-03-23 22:32:47 +00:00
|
|
|
SwingState state = SwingState_Idle;
|
2020-03-15 14:31:38 +00:00
|
|
|
MWWorld::Ptr ptr = MWWorld::Ptr();
|
|
|
|
int swingType = -1;
|
|
|
|
float strength = 0.f;
|
|
|
|
|
|
|
|
float thrustVelocity{ 0.f };
|
2020-03-28 15:35:49 +00:00
|
|
|
float slashChopVelocity{ 0.f };
|
|
|
|
float sideVelocity{ 0.f };
|
2020-03-15 14:31:38 +00:00
|
|
|
|
2020-03-23 22:32:47 +00:00
|
|
|
float minimumPeriod{ .25f };
|
2020-03-15 14:31:38 +00:00
|
|
|
float timeSinceEnteredState = { 0.f };
|
|
|
|
float movementSinceEnteredState = { 0.f };
|
|
|
|
|
|
|
|
bool shouldSwish = false;
|
|
|
|
bool mEnabled = false;
|
|
|
|
|
|
|
|
osg::Vec3 previousPosition{ 0.f,0.f,0.f };
|
|
|
|
|
|
|
|
StateMachine(MWWorld::Ptr ptr);
|
|
|
|
|
2020-03-23 22:32:47 +00:00
|
|
|
bool canSwing();
|
|
|
|
|
2020-03-15 14:31:38 +00:00
|
|
|
void playSwish();
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
void transition(SwingState newState);
|
|
|
|
|
|
|
|
void update(float dt, bool enabled);
|
|
|
|
|
2020-03-23 22:32:47 +00:00
|
|
|
void update_idleState();
|
|
|
|
void transition_idleToReady();
|
|
|
|
|
2020-03-15 14:31:38 +00:00
|
|
|
void update_readyState();
|
|
|
|
void transition_readyToSwinging();
|
|
|
|
|
|
|
|
void update_swingingState();
|
|
|
|
void transition_swingingToReady();
|
|
|
|
void transition_swingingToImpact();
|
|
|
|
|
|
|
|
void update_impactState();
|
2020-03-23 22:32:47 +00:00
|
|
|
void transition_impactToIdle();
|
2020-03-15 14:31:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
#endif
|