aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/Tutorial/TutorialHint.cpp
blob: 5f0808bf26a87204b1005c209f5d48e2fc7e8f97 (plain)
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
#include "stdafx.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
#include "Tutorial.h"
#include "TutorialHint.h"
#include "..\..\Minecraft.h"
#include "..\..\MultiplayerLocalPlayer.h"

TutorialHint::TutorialHint(eTutorial_Hint id, Tutorial *tutorial, int descriptionId, eHintType type, bool allowFade /*= true*/) 
	: m_id( id ), m_tutorial(tutorial), m_descriptionId( descriptionId ), m_type( type ), m_counter( 0 ),
	m_lastTile( NULL ), m_hintNeeded( true ), m_allowFade(allowFade)
{
	tutorial->addMessage(descriptionId, type != e_Hint_NoIngredients);
}

int TutorialHint::startDestroyBlock(shared_ptr<ItemInstance> item, Tile *tile)
{
	int returnVal = -1;
	switch(m_type)
	{
	case e_Hint_HoldToMine:
		if( tile == m_lastTile && m_hintNeeded )
		{
			++m_counter;
			if(m_counter > TUTORIAL_HINT_MAX_MINE_REPEATS)
			{
				returnVal = m_descriptionId;
			}
		}
		else
		{
			m_counter = 0;
		}
		m_lastTile = tile;
		break;
	default:
		break;
	}

	return returnVal;
}

int TutorialHint::destroyBlock(Tile *tile)
{
	int returnVal = -1;
	switch(m_type)
	{
	case e_Hint_HoldToMine:
		if(tile == m_lastTile && m_counter > 0)
		{
			m_hintNeeded = false;
		}
		break;
	default:
		break;
	}

	return returnVal;
}

int TutorialHint::attack(shared_ptr<ItemInstance> item, shared_ptr<Entity> entity)
{
	/*
	switch(m_type)
	{
	default:
		return -1;
	}
	*/
	return -1;
}

int TutorialHint::createItemSelected(shared_ptr<ItemInstance> item, bool canMake)
{
	int returnVal = -1;
	switch(m_type)
	{
	case e_Hint_NoIngredients:
		if(!canMake)
			returnVal = m_descriptionId;
		break;
	default:
		break;
	}
	return returnVal;
}

int TutorialHint::itemDamaged(shared_ptr<ItemInstance> item)
{
	int returnVal = -1;
	switch(m_type)
	{
	case e_Hint_ToolDamaged:
			returnVal = m_descriptionId;
		break;
	default:
		break;
	}
	return returnVal;
}

bool TutorialHint::onTake( shared_ptr<ItemInstance> item )
{
	return false;
}

bool TutorialHint::onLookAt(int id, int iData)
{
	return false;
}

bool TutorialHint::onLookAtEntity(eINSTANCEOF type)
{
	return false;
}

int TutorialHint::tick()
{
	int returnVal = -1;
	switch(m_type)
	{
	case e_Hint_SwimUp:
		if( Minecraft::GetInstance()->localplayers[m_tutorial->getPad()]->isUnderLiquid(Material::water) ) returnVal = m_descriptionId; 
		break;
	}
	return returnVal;
}