the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 131 lines 3.2 kB view raw
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 "ControllerTask.h" 9 10ControllerTask::ControllerTask(Tutorial *tutorial, int descriptionId, bool enablePreCompletion, bool showMinimumTime, 11 int mappings[], unsigned int mappingsLength, int iCompletionMaskA[], int iCompletionMaskACount, int iSouthpawMappings[], unsigned int uiSouthpawMappingsCount) 12 : TutorialTask( tutorial, descriptionId, enablePreCompletion, NULL, showMinimumTime ) 13{ 14 for(unsigned int i = 0; i < mappingsLength; ++i) 15 { 16 constraints.push_back( new InputConstraint( mappings[i] ) ); 17 completedMappings[mappings[i]] = false; 18 } 19 if(uiSouthpawMappingsCount > 0 ) m_bHasSouthpaw = true; 20 for(unsigned int i = 0; i < uiSouthpawMappingsCount; ++i) 21 { 22 southpawCompletedMappings[iSouthpawMappings[i]] = false; 23 } 24 25 m_iCompletionMaskA= new int [iCompletionMaskACount]; 26 for(int i=0;i<iCompletionMaskACount;i++) 27 { 28 m_iCompletionMaskA[i]=iCompletionMaskA[i]; 29 } 30 m_iCompletionMaskACount=iCompletionMaskACount; 31 m_uiCompletionMask=0; 32 33 // If we don't want to be able to complete it early..then assume we want the constraints active 34 //if( !enablePreCompletion ) 35 // enableConstraints( true ); 36} 37 38ControllerTask::~ControllerTask() 39{ 40 delete[] m_iCompletionMaskA; 41} 42 43bool ControllerTask::isCompleted() 44{ 45 if( bIsCompleted ) 46 return true; 47 48 bool bAllComplete = true; 49 50 Minecraft *pMinecraft = Minecraft::GetInstance(); 51 52 int iCurrent=0; 53 54 if(m_bHasSouthpaw && app.GetGameSettings(pMinecraft->player->GetXboxPad(),eGameSetting_ControlSouthPaw)) 55 { 56 for(AUTO_VAR(it, southpawCompletedMappings.begin()); it != southpawCompletedMappings.end(); ++it) 57 { 58 bool current = (*it).second; 59 if(!current) 60 { 61 // TODO Use a different pad 62 if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0 ) 63 { 64 (*it).second = true; 65 m_uiCompletionMask|=1<<iCurrent; 66 } 67 else 68 { 69#ifdef _WINDOWS64 70 bAllComplete = true; 71#else 72 bAllComplete = false; 73#endif 74 } 75 } 76 iCurrent++; 77 } 78 } 79 else 80 { 81 for(AUTO_VAR(it, completedMappings.begin()); it != completedMappings.end(); ++it) 82 { 83 bool current = (*it).second; 84 if(!current) 85 { 86 // TODO Use a different pad 87 if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0 ) 88 { 89 (*it).second = true; 90 m_uiCompletionMask|=1<<iCurrent; 91 } 92 else 93 { 94#ifdef _WINDOWS64 95 bAllComplete = true; 96#else 97 bAllComplete = false; 98#endif 99 } 100 } 101 iCurrent++; 102 } 103 } 104 105 // If this has a list of completion masks then check if there is a matching one to mark the task as complete 106 if(m_iCompletionMaskA && CompletionMaskIsValid()) 107 { 108 bIsCompleted = true; 109 } 110 else 111 { 112 bIsCompleted = bAllComplete; 113 } 114 115 return bIsCompleted; 116} 117 118bool ControllerTask::CompletionMaskIsValid() 119{ 120 for(int i=0;i<m_iCompletionMaskACount;i++) 121 { 122 if(m_uiCompletionMask==m_iCompletionMaskA[i]) return true; 123 } 124 125 return false; 126} 127void ControllerTask::setAsCurrentTask(bool active /*= true*/) 128{ 129 TutorialTask::setAsCurrentTask(active); 130 enableConstraints(!active); 131}