1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 12:49:56 +00:00
openmw-tes3mp/apps/openmw/mwvr/realisticcombat.hpp
2020-06-21 23:40:07 +02:00

80 lines
1.6 KiB
C++

#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 "vrsession.hpp"
namespace MWVR { namespace RealisticCombat {
enum SwingState
{
SwingState_Ready,
SwingState_Launch,
SwingState_Swing,
SwingState_Impact,
SwingState_Cooldown,
};
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;
SwingState state = SwingState_Ready;
MWWorld::Ptr ptr = MWWorld::Ptr();
int swingType = -1;
float strength = 0.f;
float thrustVelocity{ 0.f };
float slashChopVelocity{ 0.f };
float sideVelocity{ 0.f };
float minimumPeriod{ .25f };
float timeSinceEnteredState = { 0.f };
float movementSinceEnteredState = { 0.f };
bool mEnabled = false;
osg::Vec3 previousPosition{ 0.f,0.f,0.f };
StateMachine(MWWorld::Ptr ptr);
bool canSwing();
void playSwish();
void reset();
void transition(SwingState newState);
void update(float dt, bool enabled);
void update_cooldownState();
void transition_cooldownToReady();
void update_readyState();
void transition_readyToLaunch();
void update_launchState();
void transition_launchToReady();
void transition_launchToSwing();
void update_swingState();
void transition_swingingToImpact();
void update_impactState();
void transition_impactToCooldown();
};
}}
#endif