summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockNoteBlock.h
blob: f2980e0c2dcec5b0563e9d016f40286fafbfc0a2 (plain) (blame)
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

#pragma once

#include "BlockEntity.h"
#include "../BlockEntities/NoteEntity.h"





class cBlockNoteBlockHandler final : public cBlockEntityHandler
{
	using Super = cBlockEntityHandler;

  public:
	using Super::Super;

  private:
	virtual void OnDigging(
		cChunkInterface & a_ChunkInterface,
		cWorldInterface & a_WorldInterface,
		cPlayer & a_Player,
		const Vector3i a_BlockPos
	) const override
	{
		a_WorldInterface.DoWithBlockEntityAt(
			a_BlockPos,
			[](cBlockEntity & a_BlockEntity)
			{
				ASSERT(a_BlockEntity.GetBlockType() == E_BLOCK_NOTE_BLOCK);

				static_cast<cNoteEntity &>(a_BlockEntity).MakeSound();
				return false;
			}
		);
	}
};