4 #include "../../BoundingBox.h"
5 #include "../../Entities/Pickup.h"
15 size_t NumberOfEntities = 0;
16 bool FoundPlayer =
false;
27 const auto & Player = static_cast<cPlayer &>(Entity);
29 if (Player.IsGameModeSpectator())
38 const auto & Pickup = static_cast<cPickup &>(Entity);
39 NumberOfEntities += static_cast<size_t>(Pickup.GetItem().m_ItemCount);
51 return FoundPlayer ? 15 : 0;
55 return (NumberOfEntities != 0) ? 15 : 0;
59 return std::min(
static_cast<unsigned char>(
CeilC(NumberOfEntities / 10.f)),
static_cast<unsigned char>(15));
63 return std::min(
static_cast<unsigned char>(NumberOfEntities),
static_cast<unsigned char>(15));
67 ASSERT(!
"Unhandled/unimplemented block in pressure plate handler!");
84 ASSERT(!
"No on sound for this one!");
101 ASSERT(!
"No off sound for this one!");
115 return (IsLinked && (a_QueryPosition != (a_Position +
OffsetYM))) ? 0 :
DataForChunk(a_Chunk).GetCachedPowerData(a_Position);
124 const auto PreviousPower = ChunkData.GetCachedPowerData(a_Position);
127 const auto DelayInfo = ChunkData.GetMechanismDelayInfo(a_Position);
130 if (DelayInfo ==
nullptr)
140 ChunkData.m_MechanismDelays[a_Position] = std::make_pair(5,
true);
145 ChunkData.SetCachedPowerData(a_Position,
PowerLevel);
157 bool HasExitedMinimumOnDelayPhase;
158 std::tie(DelayTicks, HasExitedMinimumOnDelayPhase) = *DelayInfo;
170 if (!HasExitedMinimumOnDelayPhase)
173 *DelayInfo = std::make_pair(0,
true);
180 ChunkData.SetCachedPowerData(a_Position,
PowerLevel);
188 if (HasExitedMinimumOnDelayPhase)
194 *DelayInfo = std::make_pair(5,
false);
202 ChunkData.SetCachedPowerData(a_Position,
PowerLevel);
211 ChunkData.m_MechanismDelays.erase(a_Position);
214 ChunkData.SetCachedPowerData(a_Position,
PowerLevel);
@ E_META_PRESSURE_PLATE_DEPRESSED
@ E_META_PRESSURE_PLATE_RAISED
@ E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE
@ E_BLOCK_STONE_PRESSURE_PLATE
@ E_BLOCK_WOODEN_PRESSURE_PLATE
@ E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
std::enable_if< std::is_arithmetic< T >::value, C >::type CeilC(T a_Value)
Ceils a value, then casts it to C (an int by default).
auto & DataForChunk(const cChunk &a_Chunk)
constexpr std::array< Vector3i, 6 > RelativeAdjacents
constexpr Vector3i OffsetYM
void UpdateAdjustedRelatives(const cChunk &a_Chunk, const cChunk &a_TickingChunk, const Vector3i a_Position, const ArrayType &a_Relative)
Vector3< double > Vector3d
unsigned char Power(const BlockState Block)
static const char * GetClickOnSound(BLOCKTYPE a_BlockType)
static void ForValidSourcePositions(const cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, ForEachSourceCallback &Callback)
static unsigned char GetPowerLevel(const cChunk &Chunk, const Vector3i Position, const BLOCKTYPE BlockType)
static void Update(cChunk &a_Chunk, cChunk &CurrentlyTicking, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const PowerLevel Power)
static PowerLevel GetPowerDeliveredToPosition(const cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked)
static const char * GetClickOffSound(BLOCKTYPE a_BlockType)
Represents two sets of coords, minimum and maximum for each direction.
cChunkCoords GetPos() const
bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback) const
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox.
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
cWorld * GetWorld(void) const
static Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition, cChunkCoords a_ChunkCoords)
Converts relative block coordinates into absolute coordinates with a known chunk location.
bool IsPlayer(void) const
bool IsPickup(void) const
float GetHealth(void) const
Returns the health of this entity.
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override