2017-09-19 04:34:08 -04:00
|
|
|
|
2015-06-26 18:24:51 -04:00
|
|
|
#pragma once
|
|
|
|
|
2018-08-28 20:51:25 -04:00
|
|
|
#include "../../BlockEntities/ChestEntity.h"
|
2015-06-26 18:24:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-19 16:14:40 -04:00
|
|
|
namespace TrappedChestHandler
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2020-08-20 15:04:28 -04:00
|
|
|
inline 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
|
|
|
{
|
|
|
|
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
|
|
|
|
2020-08-20 15:04:28 -04:00
|
|
|
return DataForChunk(a_Chunk).GetCachedPowerData(a_Position);
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
|
2020-08-19 16:14:40 -04:00
|
|
|
inline unsigned char GetPowerLevel(cChunk & a_Chunk, Vector3i a_Position)
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2017-09-11 17:20:49 -04:00
|
|
|
int NumberOfPlayers = 0;
|
2020-07-26 09:15:00 -04:00
|
|
|
VERIFY(
|
|
|
|
!a_Chunk.DoWithChestAt(a_Position, [&](cChestEntity & a_Chest)
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2017-09-11 17:20:49 -04:00
|
|
|
ASSERT(a_Chest.GetBlockType() == E_BLOCK_TRAPPED_CHEST);
|
|
|
|
NumberOfPlayers = a_Chest.GetNumberOfPlayers();
|
2015-06-26 18:24:51 -04:00
|
|
|
return true;
|
2020-07-26 09:15:00 -04:00
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2017-09-11 17:20:49 -04:00
|
|
|
return static_cast<unsigned char>(std::min(NumberOfPlayers, 15));
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
|
2020-08-20 15:04:28 -04:00
|
|
|
inline void Update(cChunk & a_Chunk, cChunk & CurrentlyTicking, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const PowerLevel Power)
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2015-12-24 10:57:45 -05:00
|
|
|
// LOGD("Evaluating tricky the trapped chest (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
|
2015-06-26 18:24:51 -04:00
|
|
|
|
2020-08-20 15:04:28 -04:00
|
|
|
const auto PowerLevel = GetPowerLevel(a_Chunk, a_Position);
|
|
|
|
const auto PreviousPower = DataForChunk(a_Chunk).ExchangeUpdateOncePowerData(a_Position, PowerLevel);
|
2015-06-26 18:24:51 -04:00
|
|
|
|
2020-08-20 15:04:28 -04:00
|
|
|
if (PowerLevel != PreviousPower)
|
2015-06-26 18:24:51 -04:00
|
|
|
{
|
2020-08-08 13:22:16 -04:00
|
|
|
UpdateAdjustedRelatives(a_Chunk, CurrentlyTicking, a_Position, RelativeAdjacents);
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-19 16:14:40 -04:00
|
|
|
inline 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_Position);
|
|
|
|
UNUSED(a_BlockType);
|
|
|
|
UNUSED(a_Meta);
|
2020-07-26 09:15:00 -04:00
|
|
|
UNUSED(Callback);
|
2015-06-26 18:24:51 -04:00
|
|
|
}
|
|
|
|
};
|