MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / GetWaterBottomHeight

Method GetWaterBottomHeight

TombEngine/Game/collision/Point.cpp:201–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199 }
200
201 int PointCollisionData::GetWaterBottomHeight()
202 {
203 if (_waterBottomHeight.has_value())
204 return *_waterBottomHeight;
205
206 FloorInfo* sector = nullptr;
207 auto* room = &g_Level.Rooms[_roomNumber];
208 short roomNumber = _roomNumber;
209
210 int adjoiningRoomNumber = NO_VALUE;
211 do
212 {
213 int x = (_position.x - room->Position.x) / BLOCK(1);
214 int z = (_position.z - room->Position.z) / BLOCK(1);
215
216 if (z <= 0)
217 {
218 z = 0;
219 if (x < 1)
220 {
221 x = 1;
222 }
223 else if (x > (room->XSize - 2))
224 {
225 x = room->XSize - 2;
226 }
227 }
228 else if (z >= (room->ZSize - 1))
229 {
230 z = room->ZSize - 1;
231 if (x < 1)
232 {
233 x = 1;
234 }
235 else if (x > (room->XSize - 2))
236 {
237 x = room->XSize - 2;
238 }
239 }
240 else if (x < 0)
241 {
242 x = 0;
243 }
244 else if (x >= room->XSize)
245 {
246 x = room->XSize - 1;
247 }
248
249 sector = &room->Sectors[z + (x * room->ZSize)];
250 adjoiningRoomNumber = sector->SidePortalRoomNumber;
251 if (adjoiningRoomNumber != NO_VALUE)
252 {
253 roomNumber = adjoiningRoomNumber;
254 room = &g_Level.Rooms[adjoiningRoomNumber];
255 }
256 }
257 while (adjoiningRoomNumber != NO_VALUE);
258

Callers 5

DoVehicleWaterMovementFunction · 0.80
IsCrocodileInWaterFunction · 0.80
TestLaraWaterDepthFunction · 0.80
DoLaraFallDamageFunction · 0.80
GetPlayerWaterDataFunction · 0.80

Calls 8

TestEnvironmentFunction · 0.85
GetPointCollisionFunction · 0.85
GetSectorFunction · 0.85
GetFloorFunction · 0.85
GetNextRoomNumberMethod · 0.80
GetSurfaceHeightMethod · 0.80
has_valueMethod · 0.45
GetFloorHeightMethod · 0.45

Tested by 1

TestLaraWaterDepthFunction · 0.64