Move TileElementBase to its own file

This commit is contained in:
Michał Janiszewski 2021-02-14 21:23:57 +01:00
parent 6e20f41d3c
commit cef1efea44
3 changed files with 117 additions and 105 deletions

View File

@ -868,8 +868,9 @@
<ClCompile Include="world\Sprite.cpp" />
<ClCompile Include="world\Surface.cpp" />
<ClCompile Include="world\TileElement.cpp" />
<ClCompile Include="world/TileElementBase.cpp" />
<ClCompile Include="world\TileInspector.cpp" />
<ClCompile Include="world\Wall.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
</Project>

View File

@ -18,63 +18,6 @@
#include "Location.hpp"
#include "Scenery.h"
uint8_t TileElementBase::GetType() const
{
return this->type & TILE_ELEMENT_TYPE_MASK;
}
void TileElementBase::SetType(uint8_t newType)
{
this->type &= ~TILE_ELEMENT_TYPE_MASK;
this->type |= (newType & TILE_ELEMENT_TYPE_MASK);
}
Direction TileElementBase::GetDirection() const
{
return this->type & TILE_ELEMENT_DIRECTION_MASK;
}
void TileElementBase::SetDirection(Direction direction)
{
this->type &= ~TILE_ELEMENT_DIRECTION_MASK;
this->type |= (direction & TILE_ELEMENT_DIRECTION_MASK);
}
Direction TileElementBase::GetDirectionWithOffset(uint8_t offset) const
{
return ((this->type & TILE_ELEMENT_DIRECTION_MASK) + offset) & TILE_ELEMENT_DIRECTION_MASK;
}
bool TileElementBase::IsLastForTile() const
{
return (this->Flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0;
}
void TileElementBase::SetLastForTile(bool on)
{
if (on)
Flags |= TILE_ELEMENT_FLAG_LAST_TILE;
else
Flags &= ~TILE_ELEMENT_FLAG_LAST_TILE;
}
bool TileElementBase::IsGhost() const
{
return (this->Flags & TILE_ELEMENT_FLAG_GHOST) != 0;
}
void TileElementBase::SetGhost(bool isGhost)
{
if (isGhost)
{
this->Flags |= TILE_ELEMENT_FLAG_GHOST;
}
else
{
this->Flags &= ~TILE_ELEMENT_FLAG_GHOST;
}
}
bool tile_element_is_underground(TileElement* tileElement)
{
do
@ -167,11 +110,6 @@ void TileElement::ClearAs(uint8_t newType)
std::fill_n(pad_08, sizeof(pad_08), 0x00);
}
void TileElementBase::Remove()
{
tile_element_remove(static_cast<TileElement*>(this));
}
// Rotate both of the values amount
const QuarterTile QuarterTile::Rotate(uint8_t amount) const
{
@ -214,45 +152,3 @@ const QuarterTile QuarterTile::Rotate(uint8_t amount) const
return QuarterTile{ 0 };
}
}
uint8_t TileElementBase::GetOccupiedQuadrants() const
{
return Flags & TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK;
}
void TileElementBase::SetOccupiedQuadrants(uint8_t quadrants)
{
Flags &= ~TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK;
Flags |= (quadrants & TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK);
}
int32_t TileElementBase::GetBaseZ() const
{
return base_height * COORDS_Z_STEP;
}
void TileElementBase::SetBaseZ(int32_t newZ)
{
base_height = (newZ / COORDS_Z_STEP);
}
int32_t TileElementBase::GetClearanceZ() const
{
return clearance_height * COORDS_Z_STEP;
}
void TileElementBase::SetClearanceZ(int32_t newZ)
{
clearance_height = (newZ / COORDS_Z_STEP);
}
uint8_t TileElementBase::GetOwner() const
{
return owner & OWNER_MASK;
}
void TileElementBase::SetOwner(uint8_t newOwner)
{
owner &= ~OWNER_MASK;
owner |= (newOwner & OWNER_MASK);
}

View File

@ -0,0 +1,115 @@
/*****************************************************************************
* Copyright (c) 2014-2021 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "Map.h"
#include "TileElement.h"
uint8_t TileElementBase::GetType() const
{
return this->type & TILE_ELEMENT_TYPE_MASK;
}
void TileElementBase::SetType(uint8_t newType)
{
this->type &= ~TILE_ELEMENT_TYPE_MASK;
this->type |= (newType & TILE_ELEMENT_TYPE_MASK);
}
Direction TileElementBase::GetDirection() const
{
return this->type & TILE_ELEMENT_DIRECTION_MASK;
}
void TileElementBase::SetDirection(Direction direction)
{
this->type &= ~TILE_ELEMENT_DIRECTION_MASK;
this->type |= (direction & TILE_ELEMENT_DIRECTION_MASK);
}
Direction TileElementBase::GetDirectionWithOffset(uint8_t offset) const
{
return ((this->type & TILE_ELEMENT_DIRECTION_MASK) + offset) & TILE_ELEMENT_DIRECTION_MASK;
}
bool TileElementBase::IsLastForTile() const
{
return (this->Flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0;
}
void TileElementBase::SetLastForTile(bool on)
{
if (on)
Flags |= TILE_ELEMENT_FLAG_LAST_TILE;
else
Flags &= ~TILE_ELEMENT_FLAG_LAST_TILE;
}
bool TileElementBase::IsGhost() const
{
return (this->Flags & TILE_ELEMENT_FLAG_GHOST) != 0;
}
void TileElementBase::SetGhost(bool isGhost)
{
if (isGhost)
{
this->Flags |= TILE_ELEMENT_FLAG_GHOST;
}
else
{
this->Flags &= ~TILE_ELEMENT_FLAG_GHOST;
}
}
void TileElementBase::Remove()
{
tile_element_remove(static_cast<TileElement*>(this));
}
uint8_t TileElementBase::GetOccupiedQuadrants() const
{
return Flags & TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK;
}
void TileElementBase::SetOccupiedQuadrants(uint8_t quadrants)
{
Flags &= ~TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK;
Flags |= (quadrants & TILE_ELEMENT_OCCUPIED_QUADRANTS_MASK);
}
int32_t TileElementBase::GetBaseZ() const
{
return base_height * COORDS_Z_STEP;
}
void TileElementBase::SetBaseZ(int32_t newZ)
{
base_height = (newZ / COORDS_Z_STEP);
}
int32_t TileElementBase::GetClearanceZ() const
{
return clearance_height * COORDS_Z_STEP;
}
void TileElementBase::SetClearanceZ(int32_t newZ)
{
clearance_height = (newZ / COORDS_Z_STEP);
}
uint8_t TileElementBase::GetOwner() const
{
return owner & OWNER_MASK;
}
void TileElementBase::SetOwner(uint8_t newOwner)
{
owner &= ~OWNER_MASK;
owner |= (newOwner & OWNER_MASK);
}