2015-06-26 18:24:51 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-08-28 20:51:25 -04:00
|
|
|
#include "../../BlockEntities/NoteEntity.h"
|
2015-06-26 18:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-19 16:14:40 -04:00
|
|
|
namespace NoteBlockHandler
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2021-01-21 17:51:55 -05:00
|
|
|
static PowerLevel GetPowerDeliveredToPosition(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked)
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2020-07-26 09:15:00 -04:00
|
|
|
UNUSED(a_Chunk);
|
2015-06-26 18:24:51 -04:00
|
|
|
UNUSED(a_Position);
|
|
|
|
UNUSED(a_BlockType);
|
|
|
|
UNUSED(a_QueryPosition);
|
|
|
|
UNUSED(a_QueryBlockType);
|
2020-08-08 13:22:16 -04:00
|
|
|
UNUSED(IsLinked);
|
2015-06-26 18:24:51 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-01-21 17:51:55 -05:00
|
|
|
static void Update(cChunk & a_Chunk, cChunk &, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const PowerLevel Power)
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2020-08-20 15:04:28 -04:00
|
|
|
// LOGD("Evaluating sparky the magical note block (%d %d %d) %i", a_Position.x, a_Position.y, a_Position.z, Power);
|
2015-06-26 18:24:51 -04:00
|
|
|
|
2020-08-20 15:04:28 -04:00
|
|
|
const auto Previous = DataForChunk(a_Chunk).ExchangeUpdateOncePowerData(a_Position, Power);
|
|
|
|
if ((Previous != 0) || (Power == 0))
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
|
|
|
// If we're already powered or received an update of no power, don't make a sound
|
2020-07-26 09:15:00 -04:00
|
|
|
return;
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
|
2021-03-28 09:40:57 -04:00
|
|
|
a_Chunk.DoWithBlockEntityAt(a_Position, [](cBlockEntity & a_BlockEntity)
|
2020-07-26 09:15:00 -04:00
|
|
|
{
|
2021-04-30 09:23:46 -04:00
|
|
|
ASSERT(a_BlockEntity.GetBlockType() == E_BLOCK_NOTE_BLOCK);
|
2021-03-28 09:40:57 -04:00
|
|
|
|
|
|
|
static_cast<cNoteEntity &>(a_BlockEntity).MakeSound();
|
2020-07-26 09:15:00 -04:00
|
|
|
return false;
|
|
|
|
});
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
|
2021-01-21 17:51:55 -05:00
|
|
|
static void ForValidSourcePositions(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, ForEachSourceCallback & Callback)
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2020-07-26 09:15:00 -04:00
|
|
|
UNUSED(a_Chunk);
|
2015-06-26 18:24:51 -04:00
|
|
|
UNUSED(a_BlockType);
|
|
|
|
UNUSED(a_Meta);
|
2020-07-26 09:15:00 -04:00
|
|
|
InvokeForAdjustedRelatives(Callback, a_Position, RelativeAdjacents);
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
};
|