mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-23 11:26:16 +00:00
exclude unused GameMode implementations, format Platform/Common/Tutorial
This commit is contained in:
@@ -7,58 +7,55 @@
|
||||
#include "TutorialConstraints.h"
|
||||
#include "ControllerTask.h"
|
||||
|
||||
ControllerTask::ControllerTask(Tutorial *tutorial, int descriptionId, bool enablePreCompletion, bool showMinimumTime,
|
||||
int mappings[], unsigned int mappingsLength, int iCompletionMaskA[], int iCompletionMaskACount, int iSouthpawMappings[], unsigned int uiSouthpawMappingsCount)
|
||||
: TutorialTask( tutorial, descriptionId, enablePreCompletion, NULL, showMinimumTime )
|
||||
{
|
||||
for(unsigned int i = 0; i < mappingsLength; ++i)
|
||||
{
|
||||
constraints.push_back( new InputConstraint( mappings[i] ) );
|
||||
completedMappings[mappings[i]] = false;
|
||||
}
|
||||
if(uiSouthpawMappingsCount > 0 ) m_bHasSouthpaw = true;
|
||||
for(unsigned int i = 0; i < uiSouthpawMappingsCount; ++i)
|
||||
{
|
||||
southpawCompletedMappings[iSouthpawMappings[i]] = false;
|
||||
}
|
||||
ControllerTask::ControllerTask(Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion, bool showMinimumTime,
|
||||
int mappings[], unsigned int mappingsLength,
|
||||
int iCompletionMaskA[],
|
||||
int iCompletionMaskACount,
|
||||
int iSouthpawMappings[],
|
||||
unsigned int uiSouthpawMappingsCount)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion, NULL,
|
||||
showMinimumTime) {
|
||||
for (unsigned int i = 0; i < mappingsLength; ++i) {
|
||||
constraints.push_back(new InputConstraint(mappings[i]));
|
||||
completedMappings[mappings[i]] = false;
|
||||
}
|
||||
if (uiSouthpawMappingsCount > 0) m_bHasSouthpaw = true;
|
||||
for (unsigned int i = 0; i < uiSouthpawMappingsCount; ++i) {
|
||||
southpawCompletedMappings[iSouthpawMappings[i]] = false;
|
||||
}
|
||||
|
||||
m_iCompletionMaskA= new int [iCompletionMaskACount];
|
||||
for(int i=0;i<iCompletionMaskACount;i++)
|
||||
{
|
||||
m_iCompletionMaskA[i]=iCompletionMaskA[i];
|
||||
}
|
||||
m_iCompletionMaskACount=iCompletionMaskACount;
|
||||
m_uiCompletionMask=0;
|
||||
m_iCompletionMaskA = new int[iCompletionMaskACount];
|
||||
for (int i = 0; i < iCompletionMaskACount; i++) {
|
||||
m_iCompletionMaskA[i] = iCompletionMaskA[i];
|
||||
}
|
||||
m_iCompletionMaskACount = iCompletionMaskACount;
|
||||
m_uiCompletionMask = 0;
|
||||
|
||||
// If we don't want to be able to complete it early..then assume we want the constraints active
|
||||
//if( !enablePreCompletion )
|
||||
// enableConstraints( true );
|
||||
// If we don't want to be able to complete it early..then assume we want the
|
||||
// constraints active
|
||||
// if( !enablePreCompletion )
|
||||
// enableConstraints( true );
|
||||
|
||||
|
||||
m_initialized = false; // we can set yaw + pitch on the first tick
|
||||
m_initialized = false; // we can set yaw + pitch on the first tick
|
||||
}
|
||||
|
||||
ControllerTask::~ControllerTask()
|
||||
{
|
||||
delete[] m_iCompletionMaskA;
|
||||
}
|
||||
ControllerTask::~ControllerTask() { delete[] m_iCompletionMaskA; }
|
||||
|
||||
bool ControllerTask::isCompleted()
|
||||
{
|
||||
if (bIsCompleted)
|
||||
return true;
|
||||
bool ControllerTask::isCompleted() {
|
||||
if (bIsCompleted) return true;
|
||||
|
||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
// mouse look check
|
||||
if (!m_initialized) {
|
||||
m_lastYaw = pMinecraft->player->yRot;
|
||||
m_lastYaw = pMinecraft->player->yRot;
|
||||
m_lastPitch = pMinecraft->player->xRot;
|
||||
m_initialized = true;
|
||||
} else {
|
||||
float deltaYaw = fabs(pMinecraft->player->yRot - m_lastYaw);
|
||||
float deltaYaw = fabs(pMinecraft->player->yRot - m_lastYaw);
|
||||
float deltaPitch = fabs(pMinecraft->player->xRot - m_lastPitch);
|
||||
m_lastYaw = pMinecraft->player->yRot;
|
||||
m_lastYaw = pMinecraft->player->yRot;
|
||||
m_lastPitch = pMinecraft->player->xRot;
|
||||
|
||||
const float LOOK_THRESHOLD = 0.1f;
|
||||
@@ -70,10 +67,13 @@ bool ControllerTask::isCompleted()
|
||||
bool bAllComplete = true;
|
||||
int iCurrent = 0;
|
||||
|
||||
if (m_bHasSouthpaw && app.GetGameSettings(pMinecraft->player->GetXboxPad(), eGameSetting_ControlSouthPaw)) {
|
||||
for (auto it = southpawCompletedMappings.begin(); it != southpawCompletedMappings.end(); ++it) {
|
||||
if (m_bHasSouthpaw && app.GetGameSettings(pMinecraft->player->GetXboxPad(),
|
||||
eGameSetting_ControlSouthPaw)) {
|
||||
for (auto it = southpawCompletedMappings.begin();
|
||||
it != southpawCompletedMappings.end(); ++it) {
|
||||
if (!it->second) {
|
||||
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(), it->first) > 0) {
|
||||
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(),
|
||||
it->first) > 0) {
|
||||
it->second = true;
|
||||
m_uiCompletionMask |= 1 << iCurrent;
|
||||
} else {
|
||||
@@ -83,9 +83,11 @@ bool ControllerTask::isCompleted()
|
||||
iCurrent++;
|
||||
}
|
||||
} else {
|
||||
for (auto it = completedMappings.begin(); it != completedMappings.end(); ++it) {
|
||||
for (auto it = completedMappings.begin(); it != completedMappings.end();
|
||||
++it) {
|
||||
if (!it->second) {
|
||||
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(), it->first) > 0) {
|
||||
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(),
|
||||
it->first) > 0) {
|
||||
it->second = true;
|
||||
m_uiCompletionMask |= 1 << iCurrent;
|
||||
} else {
|
||||
@@ -105,17 +107,14 @@ bool ControllerTask::isCompleted()
|
||||
return bIsCompleted;
|
||||
}
|
||||
|
||||
bool ControllerTask::CompletionMaskIsValid()
|
||||
{
|
||||
for(int i=0;i<m_iCompletionMaskACount;i++)
|
||||
{
|
||||
if(m_uiCompletionMask==m_iCompletionMaskA[i]) return true;
|
||||
}
|
||||
bool ControllerTask::CompletionMaskIsValid() {
|
||||
for (int i = 0; i < m_iCompletionMaskACount; i++) {
|
||||
if (m_uiCompletionMask == m_iCompletionMaskA[i]) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
void ControllerTask::setAsCurrentTask(bool active /*= true*/)
|
||||
{
|
||||
TutorialTask::setAsCurrentTask(active);
|
||||
enableConstraints(!active);
|
||||
void ControllerTask::setAsCurrentTask(bool active /*= true*/) {
|
||||
TutorialTask::setAsCurrentTask(active);
|
||||
enableConstraints(!active);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user