2015-06-26 18:24:51 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
class cRedstoneLampHandler final : public cRedstoneHandler
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
|
|
|
inline static bool IsOn(BLOCKTYPE a_BlockType)
|
|
|
|
{
|
|
|
|
return (a_BlockType == E_BLOCK_REDSTONE_LAMP_ON);
|
|
|
|
}
|
|
|
|
|
2020-08-08 13:22:16 -04:00
|
|
|
virtual unsigned char GetPowerDeliveredToPosition(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked) const override
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
virtual void Update(cChunk & a_Chunk, cChunk &, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2015-12-24 10:57:45 -05:00
|
|
|
// LOGD("Evaluating lamp (%i %i %i)", a_Position.x, a_Position.y, a_Position.z);
|
2015-06-26 18:24:51 -04:00
|
|
|
|
|
|
|
if (a_PoweringData.PowerLevel > 0)
|
|
|
|
{
|
|
|
|
if (!IsOn(a_BlockType))
|
|
|
|
{
|
2020-07-26 09:15:00 -04:00
|
|
|
a_Chunk.FastSetBlock(a_Position, E_BLOCK_REDSTONE_LAMP_ON, 0);
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (IsOn(a_BlockType))
|
|
|
|
{
|
2020-07-26 09:15:00 -04:00
|
|
|
a_Chunk.FastSetBlock(a_Position, E_BLOCK_REDSTONE_LAMP_OFF, 0);
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-08 13:22:16 -04:00
|
|
|
virtual void ForValidSourcePositions(const cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, SourceCallback Callback) const override
|
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_Meta);
|
|
|
|
UNUSED(a_BlockType);
|
2020-07-26 09:15:00 -04:00
|
|
|
InvokeForAdjustedRelatives(Callback, a_Position, RelativeAdjacents);
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
};
|