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

Function SpawnPlayerWaterSurfaceEffects

TombEngine/Game/effects/effects.cpp:2004–2054  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2002}
2003
2004void SpawnPlayerWaterSurfaceEffects(const ItemInfo& item, int waterHeight, int waterDepth)
2005{
2006 const auto& player = GetLaraInfo(item);
2007
2008 // Player underwater or in fly mode; return early.
2009 if (player.Control.WaterStatus == WaterStatus::Underwater ||
2010 player.Control.WaterStatus == WaterStatus::FlyCheat)
2011 return;
2012
2013 // Get point collision.
2014 auto pointColl0 = GetPointCollision(item, 0, 0, -(LARA_HEIGHT / 2));
2015 auto pointColl1 = GetPointCollision(item, 0, 0, item.Animation.Velocity.y);
2016
2017 // In swamp; return early.
2018 if (TestEnvironment(ENV_FLAG_SWAMP, pointColl1.GetRoomNumber()))
2019 return;
2020
2021 bool isWater0 = TestEnvironment(ENV_FLAG_WATER, pointColl0.GetRoomNumber());
2022 bool isWater1 = TestEnvironment(ENV_FLAG_WATER, pointColl1.GetRoomNumber());
2023
2024 // Spawn splash.
2025 if (!isWater0 && isWater1 &&
2026 item.Animation.Velocity.y > 0.0f && SplashCount == 0 &&
2027 player.Control.WaterStatus != WaterStatus::TreadWater)
2028 {
2029 SplashSetup.Position = Vector3(item.Pose.Position.x, waterHeight - 1, item.Pose.Position.z);
2030 SplashSetup.InnerRadius = 16;
2031 SplashSetup.SplashPower = item.Animation.Velocity.z;
2032
2033 SetupSplash(&SplashSetup, pointColl0.GetRoomNumber());
2034 SplashCount = 16;
2035 }
2036 // Spawn ripple.
2037 else if (isWater1)
2038 {
2039 if (Wibble & 0xF)
2040 return;
2041
2042 if (Random::TestProbability(1 / 2000.0f) && item.Animation.ActiveState == LS_IDLE)
2043 return;
2044
2045 int flags = (item.Animation.ActiveState == LS_IDLE) ?
2046 (int)RippleFlags::LowOpacity :
2047 (int)RippleFlags::SlowFade | (int)RippleFlags::LowOpacity;
2048
2049 SpawnRipple(
2050 Vector3(item.Pose.Position.x, waterHeight - 1, item.Pose.Position.z),
2051 item.RoomNumber, Random::GenerateFloat(112.0f, 128.0f),
2052 flags);
2053 }
2054}

Callers 1

LaraControlFunction · 0.85

Calls 8

GetPointCollisionFunction · 0.85
TestEnvironmentFunction · 0.85
SetupSplashFunction · 0.85
TestProbabilityFunction · 0.85
SpawnRippleFunction · 0.85
GenerateFloatFunction · 0.85
Vector3Function · 0.50
GetRoomNumberMethod · 0.45

Tested by

no test coverage detected