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
132
133
134
135
136
137
138
139
140
141
142
143
|
#include "stdafx.h"
#include <string>
#include <unordered_map>
#include "..\..\Minecraft.h"
#include "..\..\MultiplayerLocalPlayer.h"
#include "Tutorial.h"
#include "TutorialConstraints.h"
#include "InfoTask.h"
#include "..\..\..\Minecraft.World\Material.h"
#include "..\..\Windows64\KeyboardMouseInput.h"
#include "Common/UI/UI.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 )
{
bool current = it.second;
if(!current)
{
bAllComplete = false;
break;
}
}
}
else
{
int iCurrent=0;
for( auto& it : completedMappings )
{
bool current = it.second;
if(!current)
{
#ifdef _WINDOWS64
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(), it.first) > 0 || g_KBMInput.IsKeyDown(VK_SPACE))
#else
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), it.first) > 0)
#endif
{
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 )
{
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;
};
TelemetryManager->RecordEnemyKilledOrOvercome(pMinecraft->player->GetXboxPad(), 0, 0, 0, 0, 0, 0, m_eTelemetryEvent);
}
}
|