2015-06-26 18:24:51 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "RedstoneHandler.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-13 12:38:06 -04:00
|
|
|
class cSolidBlockHandler:
|
|
|
|
public cRedstoneHandler
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cRedstoneHandler;
|
|
|
|
|
2015-06-26 18:24:51 -04:00
|
|
|
public:
|
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
virtual unsigned char GetPowerDeliveredToPosition(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2020-07-26 09:15:00 -04:00
|
|
|
const auto SolidBlock = DataForChunk(a_Chunk).GetCachedPowerData(a_Position);
|
2015-06-26 18:24:51 -04:00
|
|
|
return (
|
|
|
|
!cIncrementalRedstoneSimulator::IsRedstone(a_QueryBlockType) ||
|
|
|
|
(
|
|
|
|
(a_QueryBlockType == E_BLOCK_REDSTONE_WIRE) &&
|
2020-07-26 09:15:00 -04:00
|
|
|
(SolidBlock.PoweringBlock == E_BLOCK_REDSTONE_WIRE)
|
2015-06-26 18:24:51 -04:00
|
|
|
)
|
2020-07-26 09:15:00 -04:00
|
|
|
) ? 0 : SolidBlock.PowerLevel;
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
virtual void Update(cChunk & a_Chunk, cChunk & CurrentlyTicking, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
|
|
|
UNUSED(a_BlockType);
|
|
|
|
UNUSED(a_Meta);
|
2015-12-24 10:57:45 -05:00
|
|
|
// LOGD("Evaluating blocky the generic block (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
|
2015-06-26 18:24:51 -04:00
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
auto PreviousPower = DataForChunk(a_Chunk).ExchangeUpdateOncePowerData(a_Position, a_PoweringData);
|
2015-06-26 18:24:51 -04:00
|
|
|
if ((a_PoweringData != PreviousPower) || (a_PoweringData.PoweringBlock != PreviousPower.PoweringBlock))
|
|
|
|
{
|
2020-07-26 09:15:00 -04:00
|
|
|
UpdateAdjustedRelatives(a_Chunk, CurrentlyTicking, a_Position, RelativeAdjacents);
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-26 09:15:00 -04:00
|
|
|
virtual void ForValidSourcePositions(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_BlockType);
|
|
|
|
UNUSED(a_Meta);
|
|
|
|
|
|
|
|
/* TODO: is this more performant?
|
|
|
|
cVector3iArray Adjacents;
|
|
|
|
for (const auto Offset : GetRelativeAdjacents())
|
|
|
|
{
|
|
|
|
auto Position = Offset + a_Position;
|
|
|
|
auto Block = m_World.GetBlock(Position);
|
|
|
|
if ((Block == E_BLOCK_REDSTONE_REPEATER_ON) || (Block == E_BLOCK_REDSTONE_WIRE) || (Block == E_BLOCK_TRIPWIRE_HOOK))
|
|
|
|
{
|
|
|
|
Adjacents.emplace_back(Position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2020-07-26 09:15:00 -04:00
|
|
|
InvokeForAdjustedRelatives(Callback, a_Position, RelativeAdjacents);
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
};
|