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"
|
2020-05-24 16:00:42 +00:00
|
|
|
#include "vrsession.hpp"
|
2020-03-15 14:31:38 +00:00
|
|
|
|
|
|
|
namespace MWVR { namespace RealisticCombat {
|
|
|
|
enum SwingState
|
|
|
|
{
|
2020-06-21 21:40:07 +00:00
|
|
|
SwingState_Ready,
|
|
|
|
SwingState_Launch,
|
|
|
|
SwingState_Swing,
|
|
|
|
SwingState_Impact,
|
|
|
|
SwingState_Cooldown,
|
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-06-21 21:40:07 +00:00
|
|
|
SwingState state = SwingState_Ready;
|
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-06-21 21:40:07 +00:00
|
|
|
|
2020-03-15 14:31:38 +00:00
|
|
|
float timeSinceEnteredState = { 0.f };
|
|
|
|
float movementSinceEnteredState = { 0.f };
|
|
|
|
|
|
|
|
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-06-21 21:40:07 +00:00
|
|
|
void update_cooldownState();
|
|
|
|
void transition_cooldownToReady();
|
2020-03-23 22:32:47 +00:00
|
|
|
|
2020-03-15 14:31:38 +00:00
|
|
|
void update_readyState();
|
2020-06-21 21:40:07 +00:00
|
|
|
void transition_readyToLaunch();
|
|
|
|
|
|
|
|
void update_launchState();
|
|
|
|
void transition_launchToReady();
|
|
|
|
void transition_launchToSwing();
|
2020-03-15 14:31:38 +00:00
|
|
|
|
2020-06-21 21:40:07 +00:00
|
|
|
void update_swingState();
|
2020-03-15 14:31:38 +00:00
|
|
|
void transition_swingingToImpact();
|
|
|
|
|
|
|
|
void update_impactState();
|
2020-06-21 21:40:07 +00:00
|
|
|
void transition_impactToCooldown();
|
2020-03-15 14:31:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
#endif
|