Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/tests/test_Position.h
Show All 30 Lines | entity_pos_t GetWaterLevel(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z)) const override | ||||
return entity_pos_t::FromInt(100); | return entity_pos_t::FromInt(100); | ||||
} | } | ||||
float GetExactWaterLevel(float UNUSED(x), float UNUSED(z)) const override | float GetExactWaterLevel(float UNUSED(x), float UNUSED(z)) const override | ||||
{ | { | ||||
return 100.f; | return 100.f; | ||||
} | } | ||||
void RecomputeWaterData() override | virtual void SetWaterLevel(entity_pos_t UNUSED(h)) | ||||
{ | |||||
} | |||||
void SetWaterLevel(entity_pos_t UNUSED(h)) override | |||||
{ | { | ||||
} | } | ||||
}; | }; | ||||
class TestCmpPosition : public CxxTest::TestSuite | class TestCmpPosition : public CxxTest::TestSuite | ||||
{ | { | ||||
public: | public: | ||||
void setUp() | void setUp() | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | public: | ||||
void test_water() | void test_water() | ||||
{ | { | ||||
ComponentTestHelper test(g_ScriptContext); | ComponentTestHelper test(g_ScriptContext); | ||||
MockTerrain terrain; | MockTerrain terrain; | ||||
test.AddMock(SYSTEM_ENTITY, IID_Terrain, terrain); | test.AddMock(SYSTEM_ENTITY, IID_Terrain, terrain); | ||||
MockWater water; | MockWater water; | ||||
test.AddMock(SYSTEM_ENTITY, IID_WaterManager, water); | test.AddMock(SYSTEM_ENTITY, IID_WaterRenderer, water); | ||||
vladislavbelov: Should be `IID_Water`. | |||||
ICmpPosition* cmp = test.Add<ICmpPosition>(CID_Position, "<Anchor>upright</Anchor><Altitude>23</Altitude><Floating>true</Floating><FloatDepth>1</FloatDepth>"); | ICmpPosition* cmp = test.Add<ICmpPosition>(CID_Position, "<Anchor>upright</Anchor><Altitude>23</Altitude><Floating>true</Floating><FloatDepth>1</FloatDepth>"); | ||||
// Move into the world, the fixed height uses the water level minus the float depth as a base | // Move into the world, the fixed height uses the water level minus the float depth as a base | ||||
cmp->JumpTo(entity_pos_t::FromInt(0), entity_pos_t::FromInt(0)); | cmp->JumpTo(entity_pos_t::FromInt(0), entity_pos_t::FromInt(0)); | ||||
TS_ASSERT(cmp->IsInWorld()); | TS_ASSERT(cmp->IsInWorld()); | ||||
TS_ASSERT(cmp->CanFloat()); | TS_ASSERT(cmp->CanFloat()); | ||||
TS_ASSERT_EQUALS(cmp->GetHeightOffset(), entity_pos_t::FromInt(23)); | TS_ASSERT_EQUALS(cmp->GetHeightOffset(), entity_pos_t::FromInt(23)); | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Should be IID_Water.