Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpPosition.cpp
Show First 20 Lines • Show All 434 Lines • ▼ Show 20 Lines | virtual void SetHeightFixed(entity_pos_t y) | ||||
// subtract the absolute height and replace it with a new absolute height | // subtract the absolute height and replace it with a new absolute height | ||||
m_LastYDifference = y - GetHeightFixed(); | m_LastYDifference = y - GetHeightFixed(); | ||||
m_Y += m_LastYDifference; | m_Y += m_LastYDifference; | ||||
AdvertiseInterpolatedPositionChanges(); | AdvertiseInterpolatedPositionChanges(); | ||||
} | } | ||||
virtual entity_pos_t GetHeightFixed() const | virtual entity_pos_t GetHeightFixed() const | ||||
{ | { | ||||
return GetHeightFixed(m_X, m_Z); | |||||
} | |||||
virtual entity_pos_t GetHeightFixed(entity_pos_t x, entity_pos_t z) const | |||||
{ | |||||
if (!m_RelativeToGround) | if (!m_RelativeToGround) | ||||
return m_Y; | return m_Y; | ||||
// relative to the ground, so the fixed height = ground height + m_Y | // relative to the ground, so the fixed height = ground height + m_Y | ||||
// except when floating, when the fixed height = water level - float depth + m_Y | // except when floating, when the fixed height = water level - float depth + m_Y | ||||
entity_pos_t baseY; | entity_pos_t baseY; | ||||
CmpPtr<ICmpTerrain> cmpTerrain(GetSystemEntity()); | CmpPtr<ICmpTerrain> cmpTerrain(GetSystemEntity()); | ||||
if (cmpTerrain) | if (cmpTerrain) | ||||
baseY = cmpTerrain->GetGroundLevel(m_X, m_Z); | baseY = cmpTerrain->GetGroundLevel(x, z); | ||||
if (m_Floating) | if (m_Floating) | ||||
{ | { | ||||
CmpPtr<ICmpWaterManager> cmpWaterManager(GetSystemEntity()); | CmpPtr<ICmpWaterManager> cmpWaterManager(GetSystemEntity()); | ||||
if (cmpWaterManager) | if (cmpWaterManager) | ||||
baseY = std::max(baseY, cmpWaterManager->GetWaterLevel(m_X, m_Z) - m_FloatDepth); | baseY = std::max(baseY, cmpWaterManager->GetWaterLevel(x, z) - m_FloatDepth); | ||||
} | } | ||||
return m_Y + baseY; | return m_Y + baseY; | ||||
} | } | ||||
virtual bool IsHeightRelative() const | virtual bool IsHeightRelative() const | ||||
{ | { | ||||
return m_RelativeToGround; | return m_RelativeToGround; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | public: | ||||
virtual CFixedVector3D GetPreviousPosition() const | virtual CFixedVector3D GetPreviousPosition() const | ||||
{ | { | ||||
if (!m_InWorld) | if (!m_InWorld) | ||||
{ | { | ||||
LOGERROR("CCmpPosition::GetPreviousPosition called on entity when IsInWorld is false"); | LOGERROR("CCmpPosition::GetPreviousPosition called on entity when IsInWorld is false"); | ||||
return CFixedVector3D(); | return CFixedVector3D(); | ||||
} | } | ||||
return CFixedVector3D(m_PrevX, GetHeightFixed(), m_PrevZ); | return CFixedVector3D(m_PrevX, GetHeightFixed(m_PrevX, m_PrevZ), m_PrevZ); | ||||
} | } | ||||
virtual CFixedVector2D GetPreviousPosition2D() const | virtual CFixedVector2D GetPreviousPosition2D() const | ||||
{ | { | ||||
if (!m_InWorld) | if (!m_InWorld) | ||||
{ | { | ||||
LOGERROR("CCmpPosition::GetPreviousPosition2D called on entity when IsInWorld is false"); | LOGERROR("CCmpPosition::GetPreviousPosition2D called on entity when IsInWorld is false"); | ||||
return CFixedVector2D(); | return CFixedVector2D(); | ||||
▲ Show 20 Lines • Show All 454 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator