1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#include "stdafx.h"
#include <string>
#include <unordered_map>
#include "..\..\Minecraft.h"
#include "..\..\MultiplayerLocalPlayer.h"
#include "Tutorial.h"
#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;
}
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 );
}
ControllerTask::~ControllerTask()
{
delete[] m_iCompletionMaskA;
}
bool ControllerTask::isCompleted()
{
if( bIsCompleted )
return true;
bool bAllComplete = true;
Minecraft *pMinecraft = Minecraft::GetInstance();
int iCurrent=0;
if(m_bHasSouthpaw && app.GetGameSettings(pMinecraft->player->GetXboxPad(),eGameSetting_ControlSouthPaw))
{
for (auto& it : southpawCompletedMappings )
{
bool current = it.second;
if(!current)
{
// TODO Use a different pad
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), it.first) > 0 )
{
it.second = true;
m_uiCompletionMask|=1<<iCurrent;
}
else
{
#ifdef _WINDOWS64
bAllComplete = true;
#else
bAllComplete = false;
#endif
}
}
iCurrent++;
}
}
else
{
for (auto& it : completedMappings )
{
bool current = it.second;
if(!current)
{
// TODO Use a different pad
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), it.first) > 0 )
{
it.second = true;
m_uiCompletionMask|=1<<iCurrent;
}
else
{
#ifdef _WINDOWS64
bAllComplete = true;
#else
bAllComplete = false;
#endif
}
}
iCurrent++;
}
}
// If this has a list of completion masks then check if there is a matching one to mark the task as complete
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);
}
|