mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-23 21:56:20 +00:00
restructure codebase according to vcproj filters
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../Tutorial.h"
|
||||
#include "AreaTask.h"
|
||||
|
||||
AreaTask::AreaTask(eTutorial_State state, Tutorial* tutorial,
|
||||
std::vector<TutorialConstraint*>* inConstraints,
|
||||
int descriptionId, EAreaTaskCompletionStates completionState)
|
||||
: TutorialTask(tutorial, descriptionId, false, inConstraints, false, false,
|
||||
false) {
|
||||
m_tutorialState = state;
|
||||
if (m_tutorialState == e_Tutorial_State_Gameplay) {
|
||||
enableConstraints(true);
|
||||
}
|
||||
m_completionState = completionState;
|
||||
}
|
||||
|
||||
bool AreaTask::isCompleted() {
|
||||
if (bIsCompleted) return true;
|
||||
|
||||
bool complete = false;
|
||||
switch (m_completionState) {
|
||||
case eAreaTaskCompletion_CompleteOnConstraintsSatisfied: {
|
||||
bool allSatisfied = true;
|
||||
for (auto it = constraints.begin(); it != constraints.end(); ++it) {
|
||||
TutorialConstraint* constraint = *it;
|
||||
if (!constraint->isConstraintSatisfied(tutorial->getPad())) {
|
||||
allSatisfied = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
complete = allSatisfied;
|
||||
} break;
|
||||
case eAreaTaskCompletion_CompleteOnActivation:
|
||||
complete = bHasBeenActivated;
|
||||
break;
|
||||
};
|
||||
bIsCompleted = complete;
|
||||
return complete;
|
||||
}
|
||||
|
||||
void AreaTask::setAsCurrentTask(bool active) {
|
||||
TutorialTask::setAsCurrentTask(active);
|
||||
|
||||
if (m_completionState ==
|
||||
eAreaTaskCompletion_CompleteOnConstraintsSatisfied) {
|
||||
enableConstraints(active);
|
||||
}
|
||||
}
|
||||
|
||||
void AreaTask::onStateChange(eTutorial_State newState) {
|
||||
if (m_completionState == eAreaTaskCompletion_CompleteOnActivation) {
|
||||
if (m_tutorialState == newState) {
|
||||
enableConstraints(true);
|
||||
} else if (m_tutorialState != e_Tutorial_State_Gameplay) {
|
||||
// enableConstraints(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
// A task that creates an maintains an area constraint until it is activated
|
||||
class AreaTask : public TutorialTask {
|
||||
public:
|
||||
enum EAreaTaskCompletionStates {
|
||||
eAreaTaskCompletion_CompleteOnActivation,
|
||||
eAreaTaskCompletion_CompleteOnConstraintsSatisfied,
|
||||
};
|
||||
|
||||
private:
|
||||
EAreaTaskCompletionStates m_completionState;
|
||||
eTutorial_State m_tutorialState;
|
||||
|
||||
public:
|
||||
AreaTask(eTutorial_State state, Tutorial* tutorial,
|
||||
std::vector<TutorialConstraint*>* inConstraints,
|
||||
int descriptionId = -1,
|
||||
EAreaTaskCompletionStates completionState =
|
||||
eAreaTaskCompletion_CompleteOnActivation);
|
||||
virtual bool isCompleted();
|
||||
virtual void setAsCurrentTask(bool active = true);
|
||||
virtual void onStateChange(eTutorial_State newState);
|
||||
};
|
||||
@@ -0,0 +1,129 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "../../../../net/minecraft/client/Minecraft.h"
|
||||
#include "../../../../net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
|
||||
#include "../Tutorial.h"
|
||||
#include "../Constraints/TutorialConstraints.h"
|
||||
#include "ChoiceTask.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/level/material/Material.h"
|
||||
|
||||
ChoiceTask::ChoiceTask(
|
||||
Tutorial* tutorial, int descriptionId, int promptId /*= -1*/,
|
||||
bool requiresUserInput /*= false*/, int iConfirmMapping /*= 0*/,
|
||||
int iCancelMapping /*= 0*/,
|
||||
eTutorial_CompletionAction cancelAction /*= e_Tutorial_Completion_None*/,
|
||||
ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/)
|
||||
: TutorialTask(tutorial, descriptionId, false, nullptr, true, false,
|
||||
false) {
|
||||
if (requiresUserInput == true) {
|
||||
constraints.push_back(new InputConstraint(iConfirmMapping));
|
||||
constraints.push_back(new InputConstraint(iCancelMapping));
|
||||
}
|
||||
m_iConfirmMapping = iConfirmMapping;
|
||||
m_iCancelMapping = iCancelMapping;
|
||||
m_bConfirmMappingComplete = false;
|
||||
m_bCancelMappingComplete = false;
|
||||
|
||||
m_cancelAction = cancelAction;
|
||||
|
||||
m_promptId = promptId;
|
||||
tutorial->addMessage(m_promptId);
|
||||
|
||||
m_eTelemetryEvent = telemetryEvent;
|
||||
}
|
||||
|
||||
bool ChoiceTask::isCompleted() {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (m_bConfirmMappingComplete || m_bCancelMappingComplete) {
|
||||
sendTelemetry();
|
||||
enableConstraints(false, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ui.GetMenuDisplayed(tutorial->getPad())) {
|
||||
// If a menu is displayed, then we use the handleUIInput to complete the
|
||||
// task
|
||||
} else {
|
||||
// If the player is under water then allow all keypresses so they can
|
||||
// jump out
|
||||
if (pMinecraft->localplayers[tutorial->getPad()]->isUnderLiquid(
|
||||
Material::water))
|
||||
return false;
|
||||
|
||||
if (!m_bConfirmMappingComplete &&
|
||||
InputManager.GetValue(pMinecraft->player->GetXboxPad(),
|
||||
m_iConfirmMapping) > 0) {
|
||||
m_bConfirmMappingComplete = true;
|
||||
}
|
||||
if (!m_bCancelMappingComplete &&
|
||||
InputManager.GetValue(pMinecraft->player->GetXboxPad(),
|
||||
m_iCancelMapping) > 0) {
|
||||
m_bCancelMappingComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bConfirmMappingComplete || m_bCancelMappingComplete) {
|
||||
sendTelemetry();
|
||||
enableConstraints(false, true);
|
||||
}
|
||||
return m_bConfirmMappingComplete || m_bCancelMappingComplete;
|
||||
}
|
||||
|
||||
eTutorial_CompletionAction ChoiceTask::getCompletionAction() {
|
||||
if (m_bCancelMappingComplete) {
|
||||
return m_cancelAction;
|
||||
} else {
|
||||
return e_Tutorial_Completion_None;
|
||||
}
|
||||
}
|
||||
|
||||
int ChoiceTask::getPromptId() {
|
||||
if (m_bShownForMinimumTime)
|
||||
return m_promptId;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ChoiceTask::setAsCurrentTask(bool active /*= true*/) {
|
||||
enableConstraints(active);
|
||||
TutorialTask::setAsCurrentTask(active);
|
||||
}
|
||||
|
||||
void ChoiceTask::handleUIInput(int iAction) {
|
||||
if (bHasBeenActivated && m_bShownForMinimumTime) {
|
||||
if (iAction == m_iConfirmMapping) {
|
||||
m_bConfirmMappingComplete = true;
|
||||
} else if (iAction == m_iCancelMapping) {
|
||||
m_bCancelMappingComplete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChoiceTask::sendTelemetry() {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (m_eTelemetryEvent != eTelemetryChallenges_Unknown) {
|
||||
bool firstPlay = true;
|
||||
// We only store first play for some of the events
|
||||
switch (m_eTelemetryEvent) {
|
||||
case eTelemetryTutorial_TrialStart:
|
||||
firstPlay =
|
||||
!tutorial->getCompleted(eTutorial_Telemetry_TrialStart);
|
||||
tutorial->setCompleted(eTutorial_Telemetry_TrialStart);
|
||||
break;
|
||||
case eTelemetryTutorial_Halfway:
|
||||
firstPlay =
|
||||
!tutorial->getCompleted(eTutorial_Telemetry_Halfway);
|
||||
tutorial->setCompleted(eTutorial_Telemetry_Halfway);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
TelemetryManager->RecordEnemyKilledOrOvercome(
|
||||
pMinecraft->player->GetXboxPad(), 0, 0, 0, 0, 0, 0,
|
||||
m_eTelemetryEvent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
// Information messages with a choice
|
||||
class ChoiceTask : public TutorialTask {
|
||||
private:
|
||||
int m_iConfirmMapping, m_iCancelMapping;
|
||||
bool m_bConfirmMappingComplete, m_bCancelMappingComplete;
|
||||
eTutorial_CompletionAction m_cancelAction;
|
||||
|
||||
ETelemetryChallenges m_eTelemetryEvent;
|
||||
|
||||
bool CompletionMaskIsValid();
|
||||
|
||||
public:
|
||||
ChoiceTask(
|
||||
Tutorial* tutorial, int descriptionId, int promptId = -1,
|
||||
bool requiresUserInput = false, int iConfirmMapping = 0,
|
||||
int iCancelMapping = 0,
|
||||
eTutorial_CompletionAction cancelAction = e_Tutorial_Completion_None,
|
||||
ETelemetryChallenges telemetryEvent = eTelemetryChallenges_Unknown);
|
||||
virtual bool isCompleted();
|
||||
virtual eTutorial_CompletionAction getCompletionAction();
|
||||
virtual int getPromptId();
|
||||
virtual void setAsCurrentTask(bool active = true);
|
||||
virtual void handleUIInput(int iAction);
|
||||
|
||||
private:
|
||||
void sendTelemetry();
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/item/ItemInstance.h"
|
||||
#include "CompleteUsingItemTask.h"
|
||||
|
||||
CompleteUsingItemTask::CompleteUsingItemTask(Tutorial* tutorial,
|
||||
int descriptionId, int itemIds[],
|
||||
unsigned int itemIdsLength,
|
||||
bool enablePreCompletion)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion, nullptr) {
|
||||
m_iValidItemsA = new int[itemIdsLength];
|
||||
for (int i = 0; i < itemIdsLength; i++) {
|
||||
m_iValidItemsA[i] = itemIds[i];
|
||||
}
|
||||
m_iValidItemsCount = itemIdsLength;
|
||||
}
|
||||
|
||||
CompleteUsingItemTask::~CompleteUsingItemTask() { delete[] m_iValidItemsA; }
|
||||
|
||||
bool CompleteUsingItemTask::isCompleted() { return bIsCompleted; }
|
||||
|
||||
void CompleteUsingItemTask::completeUsingItem(
|
||||
std::shared_ptr<ItemInstance> item) {
|
||||
if (!hasBeenActivated() && !isPreCompletionEnabled()) return;
|
||||
for (int i = 0; i < m_iValidItemsCount; i++) {
|
||||
if (item->id == m_iValidItemsA[i]) {
|
||||
bIsCompleted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
class Level;
|
||||
|
||||
class CompleteUsingItemTask : public TutorialTask {
|
||||
private:
|
||||
int* m_iValidItemsA;
|
||||
int m_iValidItemsCount;
|
||||
bool completed;
|
||||
|
||||
public:
|
||||
CompleteUsingItemTask(Tutorial* tutorial, int descriptionId, int itemIds[],
|
||||
unsigned int itemIdsLength,
|
||||
bool enablePreCompletion = false);
|
||||
virtual ~CompleteUsingItemTask();
|
||||
virtual bool isCompleted();
|
||||
virtual void completeUsingItem(std::shared_ptr<ItemInstance> item);
|
||||
};
|
||||
@@ -0,0 +1,120 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "../../../../net/minecraft/client/Minecraft.h"
|
||||
#include "../../../../net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
|
||||
#include "../Tutorial.h"
|
||||
#include "../Constraints/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, nullptr,
|
||||
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;
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
ControllerTask::~ControllerTask() { delete[] m_iCompletionMaskA; }
|
||||
|
||||
bool ControllerTask::isCompleted() {
|
||||
if (bIsCompleted) return true;
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
// mouse look check
|
||||
if (!m_initialized) {
|
||||
m_lastYaw = pMinecraft->player->yRot;
|
||||
m_lastPitch = pMinecraft->player->xRot;
|
||||
m_initialized = true;
|
||||
} else {
|
||||
float deltaYaw = fabs(pMinecraft->player->yRot - m_lastYaw);
|
||||
float deltaPitch = fabs(pMinecraft->player->xRot - m_lastPitch);
|
||||
m_lastYaw = pMinecraft->player->yRot;
|
||||
m_lastPitch = pMinecraft->player->xRot;
|
||||
|
||||
const float LOOK_THRESHOLD = 0.1f;
|
||||
if (deltaYaw > LOOK_THRESHOLD || deltaPitch > LOOK_THRESHOLD)
|
||||
return true;
|
||||
}
|
||||
|
||||
// check for controller button input
|
||||
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 (!it->second) {
|
||||
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(),
|
||||
it->first) > 0) {
|
||||
it->second = true;
|
||||
m_uiCompletionMask |= 1 << iCurrent;
|
||||
} else {
|
||||
bAllComplete = false;
|
||||
}
|
||||
}
|
||||
iCurrent++;
|
||||
}
|
||||
} else {
|
||||
for (auto it = completedMappings.begin(); it != completedMappings.end();
|
||||
++it) {
|
||||
if (!it->second) {
|
||||
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(),
|
||||
it->first) > 0) {
|
||||
it->second = true;
|
||||
m_uiCompletionMask |= 1 << iCurrent;
|
||||
} else {
|
||||
bAllComplete = false;
|
||||
}
|
||||
}
|
||||
iCurrent++;
|
||||
}
|
||||
}
|
||||
|
||||
// completion mask check
|
||||
if (m_iCompletionMaskA && CompletionMaskIsValid())
|
||||
bIsCompleted = true;
|
||||
else
|
||||
bIsCompleted = bAllComplete;
|
||||
|
||||
return bIsCompleted;
|
||||
}
|
||||
|
||||
bool ControllerTask::CompletionMaskIsValid() {
|
||||
for (int i = 0; i < m_iCompletionMaskACount; i++) {
|
||||
if (m_uiCompletionMask == m_iCompletionMaskA[i]) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
void ControllerTask::setAsCurrentTask(bool active /*= true*/) {
|
||||
TutorialTask::setAsCurrentTask(active);
|
||||
enableConstraints(!active);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
// 4J Stu - Tasks that involve using the controller
|
||||
class ControllerTask : public TutorialTask {
|
||||
private:
|
||||
std::unordered_map<int, bool> completedMappings;
|
||||
std::unordered_map<int, bool> southpawCompletedMappings;
|
||||
bool m_bHasSouthpaw;
|
||||
unsigned int m_uiCompletionMask;
|
||||
int* m_iCompletionMaskA;
|
||||
int m_iCompletionMaskACount;
|
||||
bool CompletionMaskIsValid();
|
||||
|
||||
// Mouse tracking for tutorial look-around task
|
||||
float m_lastYaw;
|
||||
float m_lastPitch;
|
||||
bool m_initialized = false;
|
||||
|
||||
public:
|
||||
ControllerTask(Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion, bool showMinimumTime,
|
||||
int mappings[], unsigned int mappingsLength,
|
||||
int iCompletionMaskA[] = nullptr,
|
||||
int iCompletionMaskACount = 0,
|
||||
int iSouthpawMappings[] = nullptr,
|
||||
unsigned int uiSouthpawMappingsCount = 0);
|
||||
~ControllerTask();
|
||||
virtual bool isCompleted();
|
||||
virtual void setAsCurrentTask(bool active = true);
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "CraftTask.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/item/net.minecraft.world.item.h"
|
||||
|
||||
CraftTask::CraftTask(
|
||||
int itemId, int auxValue, int quantity, Tutorial* tutorial,
|
||||
int descriptionId, bool enablePreCompletion /*= true*/,
|
||||
std::vector<TutorialConstraint*>* inConstraints /*= nullptr*/,
|
||||
bool bShowMinimumTime /*=false*/, bool bAllowFade /*=true*/,
|
||||
bool m_bTaskReminders /*=true*/)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints,
|
||||
bShowMinimumTime, bAllowFade, m_bTaskReminders),
|
||||
m_quantity(quantity),
|
||||
m_count(0) {
|
||||
m_numItems = 1;
|
||||
m_items = new int[1];
|
||||
m_items[0] = itemId;
|
||||
m_auxValues = new int[1];
|
||||
m_auxValues[0] = auxValue;
|
||||
}
|
||||
|
||||
CraftTask::CraftTask(
|
||||
int* items, int* auxValues, int numItems, int quantity, Tutorial* tutorial,
|
||||
int descriptionId, bool enablePreCompletion /*= true*/,
|
||||
std::vector<TutorialConstraint*>* inConstraints /*= nullptr*/,
|
||||
bool bShowMinimumTime /*=false*/, bool bAllowFade /*=true*/,
|
||||
bool m_bTaskReminders /*=true*/)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints,
|
||||
bShowMinimumTime, bAllowFade, m_bTaskReminders),
|
||||
m_quantity(quantity),
|
||||
m_count(0) {
|
||||
m_numItems = numItems;
|
||||
m_items = new int[m_numItems];
|
||||
m_auxValues = new int[m_numItems];
|
||||
|
||||
for (int i = 0; i < m_numItems; ++i) {
|
||||
m_items[i] = items[i];
|
||||
m_auxValues[i] = auxValues[i];
|
||||
}
|
||||
}
|
||||
|
||||
CraftTask::~CraftTask() {
|
||||
delete[] m_items;
|
||||
delete[] m_auxValues;
|
||||
}
|
||||
|
||||
void CraftTask::onCrafted(std::shared_ptr<ItemInstance> item) {
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
wprintf(L"CraftTask::onCrafted - %ls\n", item->toString().c_str());
|
||||
#endif
|
||||
bool itemFound = false;
|
||||
for (int i = 0; i < m_numItems; ++i) {
|
||||
if (m_items[i] == item->id &&
|
||||
(m_auxValues[i] == -1 || m_auxValues[i] == item->getAuxValue())) {
|
||||
itemFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemFound) {
|
||||
++m_count;
|
||||
}
|
||||
if (m_count >= m_quantity) {
|
||||
bIsCompleted = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include "TutorialTask.h"
|
||||
|
||||
class CraftTask : public TutorialTask {
|
||||
public:
|
||||
CraftTask(int itemId, int auxValue, int quantity, Tutorial* tutorial,
|
||||
int descriptionId, bool enablePreCompletion = true,
|
||||
std::vector<TutorialConstraint*>* inConstraints = nullptr,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool m_bTaskReminders = true);
|
||||
CraftTask(int* items, int* auxValues, int numItems, int quantity,
|
||||
Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion = true,
|
||||
std::vector<TutorialConstraint*>* inConstraints = nullptr,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool m_bTaskReminders = true);
|
||||
|
||||
~CraftTask();
|
||||
|
||||
virtual bool isCompleted() { return bIsCompleted; }
|
||||
virtual void onCrafted(std::shared_ptr<ItemInstance> item);
|
||||
|
||||
private:
|
||||
int* m_items;
|
||||
int* m_auxValues;
|
||||
int m_numItems;
|
||||
int m_quantity;
|
||||
int m_count;
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/effect/net.minecraft.world.effect.h"
|
||||
#include "EffectChangedTask.h"
|
||||
|
||||
EffectChangedTask::EffectChangedTask(Tutorial* tutorial, int descriptionId,
|
||||
MobEffect* effect, bool apply,
|
||||
bool enablePreCompletion,
|
||||
bool bShowMinimumTime, bool bAllowFade,
|
||||
bool bTaskReminders)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion, nullptr,
|
||||
bShowMinimumTime, bAllowFade, bTaskReminders) {
|
||||
m_effect = effect;
|
||||
m_apply = apply;
|
||||
}
|
||||
|
||||
bool EffectChangedTask::isCompleted() { return bIsCompleted; }
|
||||
|
||||
void EffectChangedTask::onEffectChanged(MobEffect* effect,
|
||||
bool bRemoved /*=false*/) {
|
||||
if (effect == m_effect) {
|
||||
if (m_apply == !bRemoved) {
|
||||
bIsCompleted = true;
|
||||
} else {
|
||||
bIsCompleted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
class MobEffect;
|
||||
|
||||
class EffectChangedTask : public TutorialTask {
|
||||
private:
|
||||
MobEffect* m_effect;
|
||||
bool m_apply;
|
||||
|
||||
public:
|
||||
EffectChangedTask(Tutorial* tutorial, int descriptionId, MobEffect* effect,
|
||||
bool apply = true, bool enablePreCompletion = true,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool bTaskReminders = true);
|
||||
virtual bool isCompleted();
|
||||
virtual void onEffectChanged(MobEffect* effect, bool bRemoved = false);
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../Tutorial.h"
|
||||
#include "FullTutorialActiveTask.h"
|
||||
|
||||
FullTutorialActiveTask::FullTutorialActiveTask(
|
||||
Tutorial* tutorial,
|
||||
eTutorial_CompletionAction completeAction /*= e_Tutorial_Completion_None*/)
|
||||
: TutorialTask(tutorial, -1, false, nullptr, false, false, false) {
|
||||
m_completeAction = completeAction;
|
||||
}
|
||||
|
||||
bool FullTutorialActiveTask::isCompleted() { return bHasBeenActivated; }
|
||||
|
||||
eTutorial_CompletionAction FullTutorialActiveTask::getCompletionAction() {
|
||||
if (tutorial->m_fullTutorialComplete) {
|
||||
return m_completeAction;
|
||||
} else {
|
||||
return e_Tutorial_Completion_None;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
// Information messages with a choice
|
||||
class FullTutorialActiveTask : public TutorialTask {
|
||||
private:
|
||||
eTutorial_CompletionAction m_completeAction;
|
||||
|
||||
bool CompletionMaskIsValid();
|
||||
|
||||
public:
|
||||
FullTutorialActiveTask(
|
||||
Tutorial* tutorial,
|
||||
eTutorial_CompletionAction completeAction = e_Tutorial_Completion_None);
|
||||
virtual bool isCompleted();
|
||||
virtual eTutorial_CompletionAction getCompletionAction();
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../../../../net/minecraft/client/Minecraft.h"
|
||||
#include "../Tutorial.h"
|
||||
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.h"
|
||||
|
||||
#include "HorseChoiceTask.h"
|
||||
|
||||
HorseChoiceTask::HorseChoiceTask(Tutorial* tutorial, int iDescHorse,
|
||||
int iDescDonkey, int iDescMule, int iPromptId,
|
||||
bool requiresUserInput, int iConfirmMapping,
|
||||
int iCancelMapping,
|
||||
eTutorial_CompletionAction cancelAction,
|
||||
ETelemetryChallenges telemetryEvent)
|
||||
|
||||
: ChoiceTask(tutorial, -1, iPromptId, requiresUserInput, iConfirmMapping,
|
||||
iCancelMapping, cancelAction, telemetryEvent) {
|
||||
m_eHorseType = -1;
|
||||
m_iDescMule = iDescMule;
|
||||
m_iDescDonkey = iDescDonkey;
|
||||
m_iDescHorse = iDescHorse;
|
||||
}
|
||||
|
||||
int HorseChoiceTask::getDescriptionId() {
|
||||
switch (m_eHorseType) {
|
||||
case EntityHorse::TYPE_HORSE:
|
||||
return m_iDescHorse;
|
||||
case EntityHorse::TYPE_DONKEY:
|
||||
return m_iDescDonkey;
|
||||
case EntityHorse::TYPE_MULE:
|
||||
return m_iDescMule;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void HorseChoiceTask::onLookAtEntity(std::shared_ptr<Entity> entity) {
|
||||
if ((m_eHorseType < 0) && entity->instanceof(eTYPE_HORSE)) {
|
||||
std::shared_ptr<EntityHorse> horse =
|
||||
std::dynamic_pointer_cast<EntityHorse>(entity);
|
||||
if (horse->isAdult()) m_eHorseType = horse->getType();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "ChoiceTask.h"
|
||||
|
||||
// Same as choice task, but switches description based on horse type.
|
||||
class HorseChoiceTask : public ChoiceTask {
|
||||
protected:
|
||||
int m_eHorseType;
|
||||
|
||||
int m_iDescHorse, m_iDescDonkey, m_iDescMule;
|
||||
|
||||
public:
|
||||
HorseChoiceTask(
|
||||
Tutorial* tutorial, int iDescHorse, int iDescDonkey, int iDescMule,
|
||||
int iPromptId = -1, bool requiresUserInput = false,
|
||||
int iConfirmMapping = 0, int iCancelMapping = 0,
|
||||
eTutorial_CompletionAction cancelAction = e_Tutorial_Completion_None,
|
||||
ETelemetryChallenges telemetryEvent = eTelemetryChallenges_Unknown);
|
||||
|
||||
virtual int getDescriptionId();
|
||||
|
||||
virtual void onLookAtEntity(std::shared_ptr<Entity> entity);
|
||||
};
|
||||
126
Minecraft.Client/Common/Source Files/Tutorial/Tasks/InfoTask.cpp
Normal file
126
Minecraft.Client/Common/Source Files/Tutorial/Tasks/InfoTask.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "../../../../net/minecraft/client/Minecraft.h"
|
||||
#include "../../../../net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
|
||||
#include "../Tutorial.h"
|
||||
#include "../Constraints/TutorialConstraints.h"
|
||||
#include "InfoTask.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/level/material/Material.h"
|
||||
|
||||
InfoTask::InfoTask(
|
||||
Tutorial* tutorial, int descriptionId, int promptId /*= -1*/,
|
||||
bool requiresUserInput /*= false*/, int iMapping /*= 0*/,
|
||||
ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/)
|
||||
: TutorialTask(tutorial, descriptionId, false, nullptr, true, false,
|
||||
false) {
|
||||
if (requiresUserInput == true) {
|
||||
constraints.push_back(new InputConstraint(iMapping));
|
||||
}
|
||||
completedMappings[iMapping] = false;
|
||||
|
||||
m_promptId = promptId;
|
||||
tutorial->addMessage(m_promptId);
|
||||
|
||||
m_eTelemetryEvent = telemetryEvent;
|
||||
}
|
||||
|
||||
bool InfoTask::isCompleted() {
|
||||
if (bIsCompleted) return true;
|
||||
|
||||
if (tutorial->m_hintDisplayed) return false;
|
||||
|
||||
if (!bHasBeenActivated || !m_bShownForMinimumTime) return false;
|
||||
|
||||
bool bAllComplete = true;
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
// If the player is under water then allow all keypresses so they can jump
|
||||
// out
|
||||
if (pMinecraft->localplayers[tutorial->getPad()]->isUnderLiquid(
|
||||
Material::water))
|
||||
return false;
|
||||
|
||||
if (ui.GetMenuDisplayed(tutorial->getPad())) {
|
||||
// If a menu is displayed, then we use the handleUIInput to complete the
|
||||
// task
|
||||
bAllComplete = true;
|
||||
for (auto it = completedMappings.begin(); it != completedMappings.end();
|
||||
++it) {
|
||||
bool current = (*it).second;
|
||||
if (!current) {
|
||||
bAllComplete = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int iCurrent = 0;
|
||||
|
||||
for (auto it = completedMappings.begin(); it != completedMappings.end();
|
||||
++it) {
|
||||
bool current = (*it).second;
|
||||
if (!current) {
|
||||
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(),
|
||||
(*it).first) > 0) {
|
||||
(*it).second = true;
|
||||
bAllComplete = true;
|
||||
} else {
|
||||
bAllComplete = false;
|
||||
}
|
||||
}
|
||||
iCurrent++;
|
||||
}
|
||||
}
|
||||
|
||||
if (bAllComplete == true) {
|
||||
sendTelemetry();
|
||||
enableConstraints(false, true);
|
||||
}
|
||||
bIsCompleted = bAllComplete;
|
||||
return bAllComplete;
|
||||
}
|
||||
|
||||
int InfoTask::getPromptId() {
|
||||
if (m_bShownForMinimumTime)
|
||||
return m_promptId;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
void InfoTask::setAsCurrentTask(bool active /*= true*/) {
|
||||
enableConstraints(active);
|
||||
TutorialTask::setAsCurrentTask(active);
|
||||
}
|
||||
|
||||
void InfoTask::handleUIInput(int iAction) {
|
||||
if (bHasBeenActivated) {
|
||||
for (auto it = completedMappings.begin(); it != completedMappings.end();
|
||||
++it) {
|
||||
if (iAction == (*it).first) {
|
||||
(*it).second = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InfoTask::sendTelemetry() {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (m_eTelemetryEvent != eTelemetryChallenges_Unknown) {
|
||||
bool firstPlay = true;
|
||||
// We only store first play for some of the events
|
||||
switch (m_eTelemetryEvent) {
|
||||
case eTelemetryTutorial_Complete:
|
||||
firstPlay =
|
||||
!tutorial->getCompleted(eTutorial_Telemetry_Complete);
|
||||
tutorial->setCompleted(eTutorial_Telemetry_Complete);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
TelemetryManager->RecordEnemyKilledOrOvercome(
|
||||
pMinecraft->player->GetXboxPad(), 0, 0, 0, 0, 0, 0,
|
||||
m_eTelemetryEvent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
// Information messages
|
||||
class InfoTask : public TutorialTask {
|
||||
private:
|
||||
std::unordered_map<int, bool> completedMappings;
|
||||
|
||||
ETelemetryChallenges m_eTelemetryEvent;
|
||||
|
||||
bool CompletionMaskIsValid();
|
||||
|
||||
public:
|
||||
InfoTask(
|
||||
Tutorial* tutorial, int descriptionId, int promptId = -1,
|
||||
bool requiresUserInput = false, int iMapping = 0,
|
||||
ETelemetryChallenges telemetryEvent = eTelemetryChallenges_Unknown);
|
||||
virtual bool isCompleted();
|
||||
virtual int getPromptId();
|
||||
virtual void setAsCurrentTask(bool active = true);
|
||||
virtual void handleUIInput(int iAction);
|
||||
|
||||
private:
|
||||
void sendTelemetry();
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "PickupTask.h"
|
||||
|
||||
void PickupTask::onTake(std::shared_ptr<ItemInstance> item,
|
||||
unsigned int invItemCountAnyAux,
|
||||
unsigned int invItemCountThisAux) {
|
||||
if (item->id == m_itemId) {
|
||||
if (m_auxValue == -1 && invItemCountAnyAux >= m_quantity) {
|
||||
bIsCompleted = true;
|
||||
} else if (m_auxValue == item->getAuxValue() &&
|
||||
invItemCountThisAux >= m_quantity) {
|
||||
bIsCompleted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
#include "TutorialTask.h"
|
||||
|
||||
class ItemInstance;
|
||||
|
||||
class PickupTask : public TutorialTask {
|
||||
public:
|
||||
PickupTask(int itemId, unsigned int quantity, int auxValue,
|
||||
Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion = true,
|
||||
std::vector<TutorialConstraint*>* inConstraints = nullptr,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool m_bTaskReminders = true)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion,
|
||||
inConstraints, bShowMinimumTime, bAllowFade,
|
||||
m_bTaskReminders),
|
||||
m_itemId(itemId),
|
||||
m_quantity(quantity),
|
||||
m_auxValue(auxValue) {}
|
||||
|
||||
virtual bool isCompleted() { return bIsCompleted; }
|
||||
virtual void onTake(std::shared_ptr<ItemInstance> item,
|
||||
unsigned int invItemCountAnyAux,
|
||||
unsigned int invItemCountThisAux);
|
||||
|
||||
private:
|
||||
int m_itemId;
|
||||
unsigned int m_quantity;
|
||||
int m_auxValue;
|
||||
};
|
||||
@@ -0,0 +1,212 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "ProcedureCompoundTask.h"
|
||||
|
||||
ProcedureCompoundTask::~ProcedureCompoundTask() {
|
||||
for (auto it = m_taskSequence.begin(); it < m_taskSequence.end(); ++it) {
|
||||
delete (*it);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcedureCompoundTask::AddTask(TutorialTask* task) {
|
||||
if (task != nullptr) {
|
||||
m_taskSequence.push_back(task);
|
||||
}
|
||||
}
|
||||
|
||||
int ProcedureCompoundTask::getDescriptionId() {
|
||||
if (bIsCompleted) return -1;
|
||||
|
||||
// Return the id of the first task not completed
|
||||
int descriptionId = -1;
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
if (!task->isCompleted()) {
|
||||
task->setAsCurrentTask(true);
|
||||
descriptionId = task->getDescriptionId();
|
||||
break;
|
||||
} else if (task->getCompletionAction() ==
|
||||
e_Tutorial_Completion_Complete_State) {
|
||||
bIsCompleted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return descriptionId;
|
||||
}
|
||||
|
||||
int ProcedureCompoundTask::getPromptId() {
|
||||
if (bIsCompleted) return -1;
|
||||
|
||||
// Return the id of the first task not completed
|
||||
int promptId = -1;
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
if (!task->isCompleted()) {
|
||||
promptId = task->getPromptId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return promptId;
|
||||
}
|
||||
|
||||
bool ProcedureCompoundTask::isCompleted() {
|
||||
// Return whether all tasks are completed
|
||||
|
||||
bool allCompleted = true;
|
||||
bool isCurrentTask = true;
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
|
||||
if (allCompleted && isCurrentTask) {
|
||||
if (task->isCompleted()) {
|
||||
if (task->getCompletionAction() ==
|
||||
e_Tutorial_Completion_Complete_State) {
|
||||
allCompleted = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
task->setAsCurrentTask(true);
|
||||
allCompleted = false;
|
||||
isCurrentTask = false;
|
||||
}
|
||||
} else if (!allCompleted) {
|
||||
task->setAsCurrentTask(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (allCompleted) {
|
||||
// Disable all constraints
|
||||
itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
task->enableConstraints(false);
|
||||
}
|
||||
}
|
||||
bIsCompleted = allCompleted;
|
||||
return allCompleted;
|
||||
}
|
||||
|
||||
void ProcedureCompoundTask::onCrafted(std::shared_ptr<ItemInstance> item) {
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
task->onCrafted(item);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcedureCompoundTask::handleUIInput(int iAction) {
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
task->handleUIInput(iAction);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcedureCompoundTask::setAsCurrentTask(bool active /*= true*/) {
|
||||
bool allCompleted = true;
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
if (allCompleted && !task->isCompleted()) {
|
||||
task->setAsCurrentTask(true);
|
||||
allCompleted = false;
|
||||
} else if (!allCompleted) {
|
||||
task->setAsCurrentTask(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ProcedureCompoundTask::ShowMinimumTime() {
|
||||
if (bIsCompleted) return false;
|
||||
|
||||
bool showMinimumTime = false;
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
if (!task->isCompleted()) {
|
||||
showMinimumTime = task->ShowMinimumTime();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return showMinimumTime;
|
||||
}
|
||||
|
||||
bool ProcedureCompoundTask::hasBeenActivated() {
|
||||
if (bIsCompleted) return true;
|
||||
|
||||
bool hasBeenActivated = false;
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
if (!task->isCompleted()) {
|
||||
hasBeenActivated = task->hasBeenActivated();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hasBeenActivated;
|
||||
}
|
||||
|
||||
void ProcedureCompoundTask::setShownForMinimumTime() {
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
if (!task->isCompleted()) {
|
||||
task->setShownForMinimumTime();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ProcedureCompoundTask::AllowFade() {
|
||||
if (bIsCompleted) return true;
|
||||
|
||||
bool allowFade = true;
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
if (!task->isCompleted()) {
|
||||
allowFade = task->AllowFade();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return allowFade;
|
||||
}
|
||||
|
||||
void ProcedureCompoundTask::useItemOn(Level* level,
|
||||
std::shared_ptr<ItemInstance> item, int x,
|
||||
int y, int z, bool bTestUseOnly) {
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
task->useItemOn(level, item, x, y, z, bTestUseOnly);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcedureCompoundTask::useItem(std::shared_ptr<ItemInstance> item,
|
||||
bool bTestUseOnly) {
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
task->useItem(item, bTestUseOnly);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcedureCompoundTask::onTake(std::shared_ptr<ItemInstance> item,
|
||||
unsigned int invItemCountAnyAux,
|
||||
unsigned int invItemCountThisAux) {
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
task->onTake(item, invItemCountAnyAux, invItemCountThisAux);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcedureCompoundTask::onStateChange(eTutorial_State newState) {
|
||||
auto itEnd = m_taskSequence.end();
|
||||
for (auto it = m_taskSequence.begin(); it < itEnd; ++it) {
|
||||
TutorialTask* task = *it;
|
||||
task->onStateChange(newState);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
// A tutorial task that requires each of the task to be completed in order until
|
||||
// the last one is complete. If an earlier task that was complete is now not
|
||||
// complete then it's hint should be shown.
|
||||
class ProcedureCompoundTask : public TutorialTask {
|
||||
public:
|
||||
ProcedureCompoundTask(Tutorial* tutorial)
|
||||
: TutorialTask(tutorial, -1, false, nullptr, false, true, false) {}
|
||||
|
||||
~ProcedureCompoundTask();
|
||||
|
||||
void AddTask(TutorialTask* task);
|
||||
|
||||
virtual int getDescriptionId();
|
||||
virtual int getPromptId();
|
||||
virtual bool isCompleted();
|
||||
virtual void onCrafted(std::shared_ptr<ItemInstance> item);
|
||||
virtual void handleUIInput(int iAction);
|
||||
virtual void setAsCurrentTask(bool active = true);
|
||||
virtual bool ShowMinimumTime();
|
||||
virtual bool hasBeenActivated();
|
||||
virtual void setShownForMinimumTime();
|
||||
virtual bool AllowFade();
|
||||
|
||||
virtual void useItemOn(Level* level, std::shared_ptr<ItemInstance> item,
|
||||
int x, int y, int z, bool bTestUseOnly = false);
|
||||
virtual void useItem(std::shared_ptr<ItemInstance> item,
|
||||
bool bTestUseOnly = false);
|
||||
virtual void onTake(std::shared_ptr<ItemInstance> item,
|
||||
unsigned int invItemCountAnyAux,
|
||||
unsigned int invItemCountThisAux);
|
||||
virtual void onStateChange(eTutorial_State newState);
|
||||
|
||||
private:
|
||||
std::vector<TutorialTask*> m_taskSequence;
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "ProgressFlagTask.h"
|
||||
|
||||
bool ProgressFlagTask::isCompleted() {
|
||||
switch (m_type) {
|
||||
case e_Progress_Set_Flag:
|
||||
(*flags) |= m_mask;
|
||||
bIsCompleted = true;
|
||||
break;
|
||||
case e_Progress_Flag_On:
|
||||
bIsCompleted = ((*flags) & m_mask) == m_mask;
|
||||
break;
|
||||
}
|
||||
return bIsCompleted;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
#include "../Tutorial.h"
|
||||
#include "TutorialTask.h"
|
||||
|
||||
class ProgressFlagTask : public TutorialTask {
|
||||
public:
|
||||
enum EProgressFlagType {
|
||||
e_Progress_Set_Flag,
|
||||
e_Progress_Flag_On,
|
||||
};
|
||||
|
||||
private:
|
||||
char* flags; // Not a member of this object
|
||||
char m_mask;
|
||||
EProgressFlagType m_type;
|
||||
|
||||
public:
|
||||
ProgressFlagTask(char* flags, char mask, EProgressFlagType type,
|
||||
Tutorial* tutorial)
|
||||
: TutorialTask(tutorial, -1, false, nullptr),
|
||||
flags(flags),
|
||||
m_mask(mask),
|
||||
m_type(type) {}
|
||||
|
||||
virtual bool isCompleted();
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../../../../net/minecraft/client/Minecraft.h"
|
||||
#include "../Tutorial.h"
|
||||
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.h"
|
||||
|
||||
#include "RideEntityTask.h"
|
||||
|
||||
RideEntityTask::RideEntityTask(const int eType, Tutorial* tutorial,
|
||||
int descriptionId, bool enablePreCompletion,
|
||||
std::vector<TutorialConstraint*>* inConstraints,
|
||||
bool bShowMinimumTime, bool bAllowFade,
|
||||
bool bTaskReminders)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints,
|
||||
bShowMinimumTime, bAllowFade, bTaskReminders),
|
||||
m_eType(eType) {}
|
||||
|
||||
bool RideEntityTask::isCompleted() { return bIsCompleted; }
|
||||
|
||||
void RideEntityTask::onRideEntity(std::shared_ptr<Entity> entity) {
|
||||
if (entity->instanceof((eINSTANCEOF)m_eType)) {
|
||||
bIsCompleted = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
class Level;
|
||||
|
||||
// 4J-JEV: Tasks that involve riding an entity.
|
||||
class RideEntityTask : public TutorialTask {
|
||||
protected:
|
||||
const int m_eType;
|
||||
|
||||
public:
|
||||
RideEntityTask(const int eTYPE, Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion = false,
|
||||
std::vector<TutorialConstraint*>* inConstraints = nullptr,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool bTaskReminders = true);
|
||||
|
||||
virtual bool isCompleted();
|
||||
|
||||
virtual void onRideEntity(std::shared_ptr<Entity> entity);
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../../../../net/minecraft/client/Minecraft.h"
|
||||
#include "../../../../net/minecraft/client/player/LocalPlayer.h"
|
||||
#include "../../../../net/minecraft/stats/StatsCounter.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/stats/net.minecraft.stats.h"
|
||||
#include "StatTask.h"
|
||||
|
||||
StatTask::StatTask(Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion, Stat* stat, int variance /*= 1*/)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion, nullptr) {
|
||||
this->stat = stat;
|
||||
|
||||
Minecraft* minecraft = Minecraft::GetInstance();
|
||||
targetValue =
|
||||
minecraft->stats[ProfileManager.GetPrimaryPad()]->getTotalValue(stat) +
|
||||
variance;
|
||||
}
|
||||
|
||||
bool StatTask::isCompleted() {
|
||||
if (bIsCompleted) return true;
|
||||
|
||||
Minecraft* minecraft = Minecraft::GetInstance();
|
||||
bIsCompleted =
|
||||
minecraft->stats[ProfileManager.GetPrimaryPad()]->getTotalValue(stat) >=
|
||||
(unsigned int)targetValue;
|
||||
return bIsCompleted;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
class Stat;
|
||||
|
||||
// 4J Stu - Tutorial tasks that can use the current stat trackin code. This is
|
||||
// things like blocks mined/items crafted.
|
||||
class StatTask : public TutorialTask {
|
||||
private:
|
||||
Stat* stat;
|
||||
int targetValue;
|
||||
|
||||
public:
|
||||
StatTask(Tutorial* tutorial, int descriptionId, bool enablePreCompletion,
|
||||
Stat* stat, int variance = 1);
|
||||
virtual bool isCompleted();
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
#include "../Tutorial.h"
|
||||
#include "TutorialTask.h"
|
||||
|
||||
class StateChangeTask : public TutorialTask {
|
||||
private:
|
||||
eTutorial_State m_state;
|
||||
|
||||
public:
|
||||
StateChangeTask(eTutorial_State state, Tutorial* tutorial,
|
||||
int descriptionId = -1, bool enablePreCompletion = false,
|
||||
std::vector<TutorialConstraint*>* inConstraints = nullptr,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool m_bTaskReminders = true)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion,
|
||||
inConstraints, bShowMinimumTime, bAllowFade,
|
||||
m_bTaskReminders),
|
||||
m_state(state) {}
|
||||
|
||||
virtual bool isCompleted() { return bIsCompleted; }
|
||||
|
||||
virtual void onStateChange(eTutorial_State newState) {
|
||||
if (newState == m_state) {
|
||||
bIsCompleted = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../Tutorial.h"
|
||||
#include "../Constraints/TutorialConstraints.h"
|
||||
#include "TutorialTask.h"
|
||||
|
||||
TutorialTask::TutorialTask(Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion,
|
||||
std::vector<TutorialConstraint*>* inConstraints,
|
||||
bool bShowMinimumTime, bool bAllowFade,
|
||||
bool bTaskReminders)
|
||||
: tutorial(tutorial),
|
||||
descriptionId(descriptionId),
|
||||
m_promptId(-1),
|
||||
enablePreCompletion(enablePreCompletion),
|
||||
areConstraintsEnabled(false),
|
||||
bIsCompleted(false),
|
||||
bHasBeenActivated(false),
|
||||
m_bAllowFade(bAllowFade),
|
||||
m_bTaskReminders(bTaskReminders),
|
||||
m_bShowMinimumTime(bShowMinimumTime),
|
||||
m_bShownForMinimumTime(false) {
|
||||
if (inConstraints != nullptr) {
|
||||
for (auto it = inConstraints->begin(); it < inConstraints->end();
|
||||
++it) {
|
||||
TutorialConstraint* constraint = *it;
|
||||
constraints.push_back(constraint);
|
||||
}
|
||||
delete inConstraints;
|
||||
}
|
||||
|
||||
tutorial->addMessage(descriptionId);
|
||||
}
|
||||
|
||||
TutorialTask::~TutorialTask() {
|
||||
enableConstraints(false);
|
||||
|
||||
for (auto it = constraints.begin(); it < constraints.end(); ++it) {
|
||||
TutorialConstraint* constraint = *it;
|
||||
|
||||
if (constraint->getQueuedForRemoval()) {
|
||||
constraint->setDeleteOnDeactivate(true);
|
||||
} else {
|
||||
delete constraint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TutorialTask::taskCompleted() {
|
||||
if (areConstraintsEnabled == true) enableConstraints(false);
|
||||
}
|
||||
|
||||
void TutorialTask::enableConstraints(bool enable,
|
||||
bool delayRemove /*= false*/) {
|
||||
if (!enable && (areConstraintsEnabled || !delayRemove)) {
|
||||
// Remove
|
||||
for (auto it = constraints.begin(); it != constraints.end(); ++it) {
|
||||
TutorialConstraint* constraint = *it;
|
||||
// app.DebugPrintf(">>>>>>>> %i\n", constraints.size());
|
||||
tutorial->RemoveConstraint(constraint, delayRemove);
|
||||
}
|
||||
areConstraintsEnabled = false;
|
||||
} else if (!areConstraintsEnabled && enable) {
|
||||
// Add
|
||||
for (auto it = constraints.begin(); it != constraints.end(); ++it) {
|
||||
TutorialConstraint* constraint = *it;
|
||||
tutorial->AddConstraint(constraint);
|
||||
}
|
||||
areConstraintsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void TutorialTask::setAsCurrentTask(bool active /*= true*/) {
|
||||
bHasBeenActivated = active;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
#include "../TutorialEnum.h"
|
||||
|
||||
class Level;
|
||||
class Tutorial;
|
||||
class TutorialConstraint;
|
||||
class MobEffect;
|
||||
|
||||
// A class that represents each individual task in the tutorial.
|
||||
//
|
||||
// Members:
|
||||
// enablePreCompletion - If this is true, then the player can complete this
|
||||
// task out of sequence.
|
||||
// This stops us asking them to do
|
||||
// things they have already done
|
||||
// constraints - A list of constraints which can be activated
|
||||
// (as a whole).
|
||||
// If they are active, then the
|
||||
// constraints are removed when the task is completed
|
||||
// areConstraintsEnabled- A flag which records whether or not we have added the
|
||||
// constraints to the tutorial
|
||||
class TutorialTask {
|
||||
protected:
|
||||
int descriptionId;
|
||||
int m_promptId;
|
||||
Tutorial* tutorial;
|
||||
bool enablePreCompletion;
|
||||
bool bHasBeenActivated;
|
||||
bool m_bAllowFade;
|
||||
bool m_bTaskReminders;
|
||||
bool m_bShowMinimumTime;
|
||||
|
||||
protected:
|
||||
bool bIsCompleted;
|
||||
bool m_bShownForMinimumTime;
|
||||
std::vector<TutorialConstraint*> constraints;
|
||||
bool areConstraintsEnabled;
|
||||
|
||||
public:
|
||||
TutorialTask(Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion,
|
||||
std::vector<TutorialConstraint*>* inConstraints,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool bTaskReminders = true);
|
||||
virtual ~TutorialTask();
|
||||
|
||||
virtual int getDescriptionId() { return descriptionId; }
|
||||
virtual int getPromptId() { return m_promptId; }
|
||||
|
||||
virtual bool isCompleted() = 0;
|
||||
virtual eTutorial_CompletionAction getCompletionAction() {
|
||||
return e_Tutorial_Completion_None;
|
||||
}
|
||||
virtual bool isPreCompletionEnabled() { return enablePreCompletion; }
|
||||
virtual void taskCompleted();
|
||||
virtual void enableConstraints(bool enable, bool delayRemove = false);
|
||||
virtual void setAsCurrentTask(bool active = true);
|
||||
|
||||
virtual void setShownForMinimumTime() { m_bShownForMinimumTime = true; }
|
||||
virtual bool hasBeenActivated() { return bHasBeenActivated; }
|
||||
virtual bool AllowFade() { return m_bAllowFade; }
|
||||
bool TaskReminders() { return m_bTaskReminders; }
|
||||
virtual bool ShowMinimumTime() { return m_bShowMinimumTime; }
|
||||
|
||||
virtual void useItemOn(Level* level, std::shared_ptr<ItemInstance> item,
|
||||
int x, int y, int z, bool bTestUseOnly = false) {}
|
||||
virtual void useItem(std::shared_ptr<ItemInstance> item,
|
||||
bool bTestUseOnly = false) {}
|
||||
virtual void completeUsingItem(std::shared_ptr<ItemInstance> item) {}
|
||||
virtual void handleUIInput(int iAction) {}
|
||||
virtual void onCrafted(std::shared_ptr<ItemInstance> item) {}
|
||||
virtual void onTake(std::shared_ptr<ItemInstance> item,
|
||||
unsigned int invItemCountAnyAux,
|
||||
unsigned int invItemCountThisAux) {}
|
||||
virtual void onStateChange(eTutorial_State newState) {}
|
||||
virtual void onEffectChanged(MobEffect* effect, bool bRemoved = false) {}
|
||||
|
||||
virtual void onLookAtEntity(std::shared_ptr<Entity> entity) {}
|
||||
virtual void onRideEntity(std::shared_ptr<Entity> entity) {}
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include "StatTask.h"
|
||||
#include "CraftTask.h"
|
||||
#include "PickupTask.h"
|
||||
#include "UseTileTask.h"
|
||||
#include "UseItemTask.h"
|
||||
#include "InfoTask.h"
|
||||
#include "ControllerTask.h"
|
||||
#include "ProcedureCompoundTask.h"
|
||||
#include "XuiCraftingTask.h"
|
||||
#include "StateChangeTask.h"
|
||||
#include "ChoiceTask.h"
|
||||
#include "HorseChoiceTask.h"
|
||||
#include "RideEntityTask.h"
|
||||
#include "FullTutorialActiveTask.h"
|
||||
#include "AreaTask.h"
|
||||
#include "ProgressFlagTask.h"
|
||||
#include "CompleteUsingItemTask.h"
|
||||
#include "EffectChangedTask.h"
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/entity/Entity.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/level/Level.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/item/ItemInstance.h"
|
||||
#include "UseItemTask.h"
|
||||
|
||||
UseItemTask::UseItemTask(const int itemId, Tutorial* tutorial,
|
||||
int descriptionId, bool enablePreCompletion,
|
||||
std::vector<TutorialConstraint*>* inConstraints,
|
||||
bool bShowMinimumTime, bool bAllowFade,
|
||||
bool bTaskReminders)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints,
|
||||
bShowMinimumTime, bAllowFade, bTaskReminders),
|
||||
itemId(itemId) {}
|
||||
|
||||
bool UseItemTask::isCompleted() { return bIsCompleted; }
|
||||
|
||||
void UseItemTask::useItem(std::shared_ptr<ItemInstance> item,
|
||||
bool bTestUseOnly) {
|
||||
if (bTestUseOnly) return;
|
||||
|
||||
if (item->id == itemId) bIsCompleted = true;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
class Level;
|
||||
|
||||
// 4J Stu - Tasks that involve placing a tile
|
||||
class UseItemTask : public TutorialTask {
|
||||
private:
|
||||
const int itemId;
|
||||
|
||||
public:
|
||||
UseItemTask(const int itemId, Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion = false,
|
||||
std::vector<TutorialConstraint*>* inConstraints = nullptr,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool bTaskReminders = true);
|
||||
virtual bool isCompleted();
|
||||
virtual void useItem(std::shared_ptr<ItemInstance> item,
|
||||
bool bTestUseOnly = false);
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/entity/Entity.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/level/Level.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/item/ItemInstance.h"
|
||||
#include "UseTileTask.h"
|
||||
|
||||
UseTileTask::UseTileTask(const int tileId, int x, int y, int z,
|
||||
Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion,
|
||||
std::vector<TutorialConstraint*>* inConstraints,
|
||||
bool bShowMinimumTime, bool bAllowFade,
|
||||
bool bTaskReminders)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints,
|
||||
bShowMinimumTime, bAllowFade, bTaskReminders),
|
||||
x(x),
|
||||
y(y),
|
||||
z(z),
|
||||
tileId(tileId) {
|
||||
useLocation = true;
|
||||
}
|
||||
|
||||
UseTileTask::UseTileTask(const int tileId, Tutorial* tutorial,
|
||||
int descriptionId, bool enablePreCompletion,
|
||||
std::vector<TutorialConstraint*>* inConstraints,
|
||||
bool bShowMinimumTime, bool bAllowFade,
|
||||
bool bTaskReminders)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints,
|
||||
bShowMinimumTime, bAllowFade, bTaskReminders),
|
||||
tileId(tileId) {
|
||||
useLocation = false;
|
||||
}
|
||||
|
||||
bool UseTileTask::isCompleted() { return bIsCompleted; }
|
||||
|
||||
void UseTileTask::useItemOn(Level* level, std::shared_ptr<ItemInstance> item,
|
||||
int x, int y, int z, bool bTestUseOnly) {
|
||||
if (bTestUseOnly) return;
|
||||
|
||||
if (!enablePreCompletion && !bHasBeenActivated) return;
|
||||
|
||||
if (!useLocation || (x == this->x && y == this->y && z == this->z)) {
|
||||
int t = level->getTile(x, y, z);
|
||||
if (t == tileId) bIsCompleted = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "TutorialTask.h"
|
||||
|
||||
class Level;
|
||||
|
||||
// 4J Stu - Tasks that involve using a tile, with or without an item. e.g.
|
||||
// Opening a chest
|
||||
class UseTileTask : public TutorialTask {
|
||||
private:
|
||||
int x, y, z;
|
||||
const int tileId;
|
||||
bool useLocation;
|
||||
bool completed;
|
||||
|
||||
public:
|
||||
UseTileTask(const int tileId, int x, int y, int z, Tutorial* tutorial,
|
||||
int descriptionId, bool enablePreCompletion = false,
|
||||
std::vector<TutorialConstraint*>* inConstraints = nullptr,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool bTaskReminders = true);
|
||||
UseTileTask(const int tileId, Tutorial* tutorial, int descriptionId,
|
||||
bool enablePreCompletion = false,
|
||||
std::vector<TutorialConstraint*>* inConstraints = nullptr,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool bTaskReminders = true);
|
||||
virtual bool isCompleted();
|
||||
virtual void useItemOn(Level* level, std::shared_ptr<ItemInstance> item,
|
||||
int x, int y, int z, bool bTestUseOnly = false);
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "../../../../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/item/ItemInstance.h"
|
||||
#include "../../UI/UI.h"
|
||||
#include "../Tutorial.h"
|
||||
#include "XuiCraftingTask.h"
|
||||
|
||||
bool XuiCraftingTask::isCompleted() {
|
||||
// This doesn't seem to work
|
||||
// IUIScene_CraftingMenu *craftScene =
|
||||
// reinterpret_cast<IUIScene_CraftingMenu *>(tutorial->getScene());
|
||||
UIScene_CraftingMenu* craftScene =
|
||||
reinterpret_cast<UIScene_CraftingMenu*>(tutorial->getScene());
|
||||
|
||||
bool completed = false;
|
||||
|
||||
switch (m_type) {
|
||||
case e_Crafting_SelectGroup:
|
||||
if (craftScene != nullptr &&
|
||||
craftScene->getCurrentGroup() == m_group) {
|
||||
completed = true;
|
||||
}
|
||||
break;
|
||||
case e_Crafting_SelectItem:
|
||||
if (craftScene != nullptr && craftScene->isItemSelected(m_item)) {
|
||||
completed = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return completed;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include "TutorialTask.h"
|
||||
#include "../../../../../Minecraft.World/net/minecraft/world/item/crafting/Recipy.h"
|
||||
|
||||
class XuiCraftingTask : public TutorialTask {
|
||||
public:
|
||||
enum eCraftingTaskType {
|
||||
e_Crafting_SelectGroup,
|
||||
e_Crafting_SelectItem,
|
||||
};
|
||||
|
||||
// Select group
|
||||
XuiCraftingTask(Tutorial* tutorial, int descriptionId,
|
||||
Recipy::_eGroupType groupToSelect,
|
||||
bool enablePreCompletion = false,
|
||||
std::vector<TutorialConstraint*>* inConstraints = nullptr,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool m_bTaskReminders = true)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion,
|
||||
inConstraints, bShowMinimumTime, bAllowFade,
|
||||
m_bTaskReminders),
|
||||
m_group(groupToSelect),
|
||||
m_type(e_Crafting_SelectGroup) {}
|
||||
|
||||
// Select Item
|
||||
XuiCraftingTask(Tutorial* tutorial, int descriptionId, int itemId,
|
||||
bool enablePreCompletion = false,
|
||||
std::vector<TutorialConstraint*>* inConstraints = nullptr,
|
||||
bool bShowMinimumTime = false, bool bAllowFade = true,
|
||||
bool m_bTaskReminders = true)
|
||||
: TutorialTask(tutorial, descriptionId, enablePreCompletion,
|
||||
inConstraints, bShowMinimumTime, bAllowFade,
|
||||
m_bTaskReminders),
|
||||
m_item(itemId),
|
||||
m_type(e_Crafting_SelectItem) {}
|
||||
|
||||
virtual bool isCompleted();
|
||||
|
||||
private:
|
||||
eCraftingTaskType m_type;
|
||||
Recipy::_eGroupType m_group;
|
||||
int m_item;
|
||||
};
|
||||
Reference in New Issue
Block a user