the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include <string>
3#include <unordered_map>
4#include "..\..\Minecraft.h"
5#include "..\..\MultiplayerLocalPlayer.h"
6#include "Tutorial.h"
7#include "TutorialConstraints.h"
8#include "InfoTask.h"
9#include "..\..\..\Minecraft.World\Material.h"
10#include "..\..\KeyboardMouseInput.h"
11
12InfoTask::InfoTask(Tutorial *tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/,
13 int iMapping /*= 0*/, ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/)
14 : TutorialTask( tutorial, descriptionId, false, NULL, true, false, false )
15{
16 if(requiresUserInput == true)
17 {
18 constraints.push_back( new InputConstraint( iMapping ) );
19 }
20 completedMappings[iMapping]=false;
21
22 m_promptId = promptId;
23 tutorial->addMessage( m_promptId );
24
25 m_eTelemetryEvent = telemetryEvent;
26}
27
28bool InfoTask::isCompleted()
29{
30 if( bIsCompleted )
31 return true;
32
33 if( tutorial->m_hintDisplayed )
34 return false;
35
36 if( !bHasBeenActivated || !m_bShownForMinimumTime )
37 return false;
38
39 bool bAllComplete = true;
40
41 Minecraft *pMinecraft = Minecraft::GetInstance();
42
43 // If the player is under water then allow all keypresses so they can jump out
44 if( pMinecraft->localplayers[tutorial->getPad()]->isUnderLiquid(Material::water) ) return false;
45
46 if(ui.GetMenuDisplayed(tutorial->getPad()))
47 {
48 // If a menu is displayed, then we use the handleUIInput to complete the task
49 bAllComplete = true;
50 for(AUTO_VAR(it, completedMappings.begin()); it != completedMappings.end(); ++it)
51 {
52 bool current = (*it).second;
53 if(!current)
54 {
55 bAllComplete = false;
56 break;
57 }
58 }
59 }
60 else
61 {
62 int iCurrent=0;
63
64 for(AUTO_VAR(it, completedMappings.begin()); it != completedMappings.end(); ++it)
65 {
66 bool current = (*it).second;
67 if(!current)
68 {
69#ifdef _WINDOWS64
70 if (InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0 || KMInput.IsKeyDown(VK_SPACE))
71#else
72 if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0)
73#endif
74 {
75 (*it).second = true;
76 bAllComplete=true;
77 }
78 else
79 {
80 bAllComplete = false;
81 }
82 }
83 iCurrent++;
84 }
85 }
86
87 if(bAllComplete==true)
88 {
89 sendTelemetry();
90 enableConstraints(false, true);
91 }
92 bIsCompleted = bAllComplete;
93 return bAllComplete;
94}
95
96int InfoTask::getPromptId()
97{
98 if( m_bShownForMinimumTime )
99 return m_promptId;
100 else
101 return -1;
102}
103
104void InfoTask::setAsCurrentTask(bool active /*= true*/)
105{
106 enableConstraints( active );
107 TutorialTask::setAsCurrentTask(active);
108}
109
110void InfoTask::handleUIInput(int iAction)
111{
112 if(bHasBeenActivated)
113 {
114 for(AUTO_VAR(it, completedMappings.begin()); it != completedMappings.end(); ++it)
115 {
116 if( iAction == (*it).first )
117 {
118 (*it).second = true;
119 }
120 }
121 }
122}
123
124
125void InfoTask::sendTelemetry()
126{
127 Minecraft *pMinecraft = Minecraft::GetInstance();
128
129 if( m_eTelemetryEvent != eTelemetryChallenges_Unknown )
130 {
131 bool firstPlay = true;
132 // We only store first play for some of the events
133 switch(m_eTelemetryEvent)
134 {
135 case eTelemetryTutorial_Complete:
136 firstPlay = !tutorial->getCompleted( eTutorial_Telemetry_Complete );
137 tutorial->setCompleted( eTutorial_Telemetry_Complete );
138 break;
139 };
140 TelemetryManager->RecordEnemyKilledOrOvercome(pMinecraft->player->GetXboxPad(), 0, 0, 0, 0, 0, 0, m_eTelemetryEvent);
141 }
142}