blob: a1746fbdc0eb813687fe60a19d41751b9eb0ff18 (
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
|
#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 "..\..\..\Minecraft.World\net.minecraft.world.entity.h"
#include "Tutorial.h"
#include "DiggerItemHint.h"
DiggerItemHint::DiggerItemHint(eTutorial_Hint id, Tutorial *tutorial, int descriptionId, int items[], unsigned int itemsLength)
: TutorialHint(id, tutorial, descriptionId, e_Hint_DiggerItem)
{
m_iItemsCount = itemsLength;
m_iItems= new int [m_iItemsCount];
for(unsigned int i=0;i<m_iItemsCount;i++)
{
m_iItems[i]=items[i];
}
tutorial->addMessage(IDS_TUTORIAL_HINT_ATTACK_WITH_TOOL, true);
}
int DiggerItemHint::startDestroyBlock(std::shared_ptr<ItemInstance> item, Tile *tile)
{
if(item != NULL)
{
bool itemFound = false;
for(unsigned int i=0;i<m_iItemsCount;i++)
{
if(item->id == m_iItems[i])
{
itemFound = true;
break;
}
}
if(itemFound)
{
float speed = item->getDestroySpeed(tile);
if(speed == 1)
{
// Display hint
return m_descriptionId;
}
}
}
return -1;
}
int DiggerItemHint::attack(std::shared_ptr<ItemInstance> item, std::shared_ptr<Entity> entity)
{
if(item != NULL)
{
bool itemFound = false;
for(unsigned int i=0;i<m_iItemsCount;i++)
{
if(item->id == m_iItems[i])
{
itemFound = true;
break;
}
}
if(itemFound)
{
// It's also possible that we could hit TileEntities (eg falling sand) so don't want to give this hint then
if( std::dynamic_pointer_cast<Mob>( entity ) != NULL )
{
return IDS_TUTORIAL_HINT_ATTACK_WITH_TOOL;
}
else
{
return -1;
}
}
}
return -1;
}
|