Clean up
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
enum HoldState
|
||||
{
|
||||
HOLD_NONE,
|
||||
HOLD_SANKAKU = 64,
|
||||
HOLD_MARU = 128,
|
||||
HOLD_BATSU = 256,
|
||||
HOLD_SHIKAKU = 512,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
enum TargetHitStates
|
||||
{
|
||||
COOL,
|
||||
FINE,
|
||||
SAFE,
|
||||
SAD,
|
||||
COOL_WRONG, // unsure
|
||||
FINE_WRONG, // unsure
|
||||
SAFE_WRONG, // unsure
|
||||
SAD_WRONG, // unsure
|
||||
WORST,
|
||||
NONE = 21,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#include "TargetInspector.h"
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
bool TargetInspector::repressTbl[maxTargetSlots];
|
||||
|
||||
TargetInspector::TargetInspector()
|
||||
{
|
||||
}
|
||||
|
||||
TargetInspector::~TargetInspector()
|
||||
{
|
||||
}
|
||||
|
||||
void TargetInspector::Initialize(ComponentsManager*)
|
||||
{
|
||||
tgtTypePtr = (int*)TGT_TYPE_BASE_ADDRESS;
|
||||
tgtHitStatePtr = (int*)TGT_HIT_STATE_BASE_ADDRESS;
|
||||
tgtRemainingTimePtr = (float*)TGT_REMAINING_DURATION_BASE_ADDRESS;
|
||||
}
|
||||
|
||||
void TargetInspector::Update()
|
||||
{
|
||||
GetTargetStates();
|
||||
UpdateRepressTbl();
|
||||
}
|
||||
|
||||
const char* TargetInspector::GetDisplayName()
|
||||
{
|
||||
return "target_inspector";
|
||||
}
|
||||
|
||||
void TargetInspector::GetTargetStates()
|
||||
{
|
||||
for (int i = 0; i < maxTargetSlots; ++i)
|
||||
{
|
||||
tgtStates[i].tgtType = *((int*)((char*)tgtTypePtr + (i * offset)));
|
||||
tgtStates[i].tgtHitState = *((int*)((char*)tgtHitStatePtr + (i * offset)));
|
||||
tgtStates[i].tgtRemainingTime = *((float*)((char*)tgtRemainingTimePtr + (i * offset)));
|
||||
}
|
||||
}
|
||||
|
||||
void TargetInspector::UpdateRepressTbl()
|
||||
{
|
||||
for (int i = 0; i < maxTargetSlots; ++i)
|
||||
{
|
||||
repressTbl[i] = IsWithinRange(tgtStates[i].tgtRemainingTime)
|
||||
&& HasNotBeenHit(tgtStates[i].tgtHitState)
|
||||
&& !IsSlide(tgtStates[i].tgtType);
|
||||
}
|
||||
}
|
||||
|
||||
bool TargetInspector::IsWithinRange(float time)
|
||||
{
|
||||
return time < timingThreshold && time > -timingThreshold && time != 0;
|
||||
}
|
||||
|
||||
bool TargetInspector::HasNotBeenHit(int hitState)
|
||||
{
|
||||
return hitState == NONE;
|
||||
}
|
||||
|
||||
bool TargetInspector::IsSlide(int type)
|
||||
{
|
||||
return (type >= SLIDE_L && type <= SLIDE_LONG_R) || type >= SLIDE_L_CH;
|
||||
}
|
||||
|
||||
bool TargetInspector::IsAnyRepress()
|
||||
{
|
||||
for (int i = 0; i < maxTargetSlots; ++i)
|
||||
{
|
||||
if (repressTbl[i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include "../EmulatorComponent.h"
|
||||
#include "../Input/InputEmulator.h"
|
||||
#include "../../Constants.h"
|
||||
#include "TargetHitStates.h"
|
||||
#include "TargetState.h"
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
const int maxTargetSlots = 32;
|
||||
|
||||
class TargetInspector : public EmulatorComponent
|
||||
{
|
||||
public:
|
||||
TargetInspector();
|
||||
~TargetInspector();
|
||||
|
||||
static bool repressTbl[maxTargetSlots];
|
||||
|
||||
virtual void Initialize(ComponentsManager*) override;
|
||||
virtual void Update() override;
|
||||
virtual const char* GetDisplayName() override;
|
||||
|
||||
void GetTargetStates();
|
||||
static bool IsAnyRepress();
|
||||
|
||||
private:
|
||||
const uint64_t offset = 0x4A8;
|
||||
const float timingThreshold = 0.13f; // PS4 estimate
|
||||
|
||||
TargetState tgtStates[maxTargetSlots];
|
||||
|
||||
int* tgtTypePtr;
|
||||
int* tgtHitStatePtr;
|
||||
float* tgtRemainingTimePtr;
|
||||
|
||||
bool IsSlide(int);
|
||||
bool IsWithinRange(float);
|
||||
bool HasNotBeenHit(int);
|
||||
void UpdateRepressTbl();
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
struct TargetState
|
||||
{
|
||||
int tgtType;
|
||||
int tgtHitState;
|
||||
float tgtRemainingTime;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
enum TargetTypes
|
||||
{
|
||||
SANKAKU,
|
||||
MARU,
|
||||
BATSU,
|
||||
SHIKAKU,
|
||||
SANKAKU_H,
|
||||
MARU_H,
|
||||
BATSU_H,
|
||||
SHIKAKU_H,
|
||||
SLIDE_L = 12,
|
||||
SLIDE_R,
|
||||
SLIDE_LONG_L = 15,
|
||||
SLIDE_LONG_R,
|
||||
SANKAKU_CH = 18,
|
||||
MARU_CH,
|
||||
BATSU_CH,
|
||||
SHIKAKU_CH,
|
||||
SLIDE_L_CH = 23,
|
||||
SLIDE_R_CH,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user