mirror of https://github.com/OpenRCT2/OpenRCT2.git
Add getter and setter for location in SpriteBase
This commit is contained in:
parent
a2ebec8676
commit
ed4d8b4552
|
@ -644,17 +644,6 @@ static void SpriteSpatialMove(SpriteBase* sprite, const CoordsXY& newLoc)
|
|||
SpriteSpatialInsert(sprite, newLoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a sprite to a new location, invalidates the current position if valid
|
||||
* and also the new position.
|
||||
*
|
||||
* rct2: 0x0069E9D3
|
||||
*
|
||||
* @param x (ax)
|
||||
* @param y (cx)
|
||||
* @param z (dx)
|
||||
* @param sprite (esi)
|
||||
*/
|
||||
void SpriteBase::MoveTo(const CoordsXYZ& newLocation)
|
||||
{
|
||||
if (x != LOCATION_NULL)
|
||||
|
@ -685,6 +674,18 @@ void SpriteBase::MoveTo(const CoordsXYZ& newLocation)
|
|||
}
|
||||
}
|
||||
|
||||
CoordsXYZ SpriteBase::GetLocation() const
|
||||
{
|
||||
return { x, y, z };
|
||||
}
|
||||
|
||||
void SpriteBase::SetLocation(const CoordsXYZ& newLocation)
|
||||
{
|
||||
x = static_cast<int16_t>(newLocation.x);
|
||||
y = static_cast<int16_t>(newLocation.y);
|
||||
z = static_cast<int16_t>(newLocation.z);
|
||||
}
|
||||
|
||||
void sprite_set_coordinates(const CoordsXYZ& spritePos, SpriteBase* sprite)
|
||||
{
|
||||
auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), spritePos);
|
||||
|
|
|
@ -30,7 +30,24 @@ struct SpriteBase
|
|||
|
||||
uint8_t sprite_direction;
|
||||
|
||||
/**
|
||||
* Moves a sprite to a new location, invalidates the current position if valid
|
||||
* and also the new position.
|
||||
*
|
||||
* rct2: 0x0069E9D3
|
||||
*/
|
||||
void MoveTo(const CoordsXYZ& newLocation);
|
||||
|
||||
/**
|
||||
* Sets the entity location without screen invalidation.
|
||||
*/
|
||||
void SetLocation(const CoordsXYZ& newLocation);
|
||||
|
||||
/**
|
||||
* Gets the entity current location.
|
||||
*/
|
||||
CoordsXYZ GetLocation() const;
|
||||
|
||||
void Invalidate();
|
||||
template<typename T> bool Is() const;
|
||||
template<typename T> T* As()
|
||||
|
|
Loading…
Reference in New Issue