class CCTLiquidSyntheticCursor
CCTLiquidSyntheticCursor › CCTLiquid › CCTBase
Liquid target condition with camera based cursor reconstruction.
Some actions (fishing) must be usable while aiming at open water where the engine action cursor returns no hit at all, or returns a synced Y that is off the sea plane. This condition reconstructs a cursor from the camera ray and keeps it stable across frames.
Only actions that actually need this should use it, everything else uses the plain CCTLiquid, which does not run any of the code below.
Constructors 1
void CCTLiquidSyntheticCursor(int allowedLiquidSource, float maximalTargetDistance = UAMaxDistances.DEFAULT, float maxVerticalReach = UAMaxDistances.DEFAULT, SurfaceDetectionType surfaceDetectionType = SurfaceDetectionType.Roadway, bool allowSeaLevelCursorFallback = true)Constants 11
protected const float SEA_FALLBACK_DISTANCE_BUFFER = 1.5protected const float SYNTHETIC_POND_SAMPLE_STEP = 1.0protected const float SYNTHETIC_POND_SURFACE_TOLERANCE = 0.35protected const float SYNTHETIC_POND_FALLBACK_SURFACE_TOLERANCE = 1.75protected const float SYNTHETIC_CURSOR_DISTANCE_BUFFER = 1.5protected const float SEA_CURSOR_STICK_DISTANCE = 0.75protected const int SEA_CURSOR_STICK_TIME_MS = 350protected const float SYNTHETIC_CURSOR_CACHE_AIM_TOLERANCE = 1.75protected const int SYNTHETIC_CURSOR_CACHE_MAX_AGE_MS = 350protected const float SEA_CURSOR_MIN_DOWN_DOT = 0.035protected const float POND_MAX_CAMERA_DIR_Y = 0.15Members 9
protected vector m_LastSyntheticHitCursorprotected bool m_HasLastSyntheticHitCursorprotected int m_LastSyntheticHitCursorTimeprotected float m_SafeSeaDistanceSqDerived once, used by every camera ray path.
protected float m_SafeCursorDistanceprotected float m_StickDistanceSqprotected float m_CacheAimToleranceSqprotected bool m_DebugSyntheticCursorDIAG_DEVELOPERShow 1 more
, TryResolveSyntheticCursor()protected ref array<Shape> m_DebugSyntheticCursorShapesDIAG_DEVELOPERMethods 21
override bool CanContinue(PlayerBase player, ActionTarget target)override protected bool ResolveSyntheticCursor(PlayerBase player, vector playerPos, ActionTarget target, Object targetObj, vector hitPosition)Re-validate during action
Show 2 more
, m_DebugSyntheticCursor, and CCTLiquid.m_LiquidTypeprotected bool TryResolveSyntheticCursor(PlayerBase player, vector playerPos, vector currentHitPosition, out vector resolvedHitPosition, out int resolvedLiquidType)Only relevant when there is no target object at all.
protected bool TryBuildSyntheticCursor(PlayerBase player, vector playerPos, out vector syntheticHitPosition, out int syntheticLiquidType)Validate the generated cursor once.
Show 4 more
, TryGetCameraRay(), CCTLiquid.m_CanBeFreshwater, CCTLiquid.m_CanBeSaltwater, and vector.ZeroLet final validation detect exact liquid type.
Show 1 more
, vector.Zeroprotected bool TryBuildSeaLevelHitPosition(PlayerBase player, vector playerPos, vector cameraPos, vector cameraDir, out vector seaHitPosition)Show 16 more
, DbgUI.End(), string.Format(), GetRaycastTarget(), CCTLiquidFrameProbe.GetSeaLevels(), CCTLiquid.HasClearPathToLiquidSurface(), IsNearlyEqual(), IsSeaHitPositionValid(), DbgUI.Text(), vector.ToString(), vector.ToString(), m_DebugSyntheticCursor, CCTLiquid.m_MaxVerticalReach, CCTLiquid.m_Probe, m_SafeSeaDistanceSq, SEA_CURSOR_MIN_DOWN_DOT, and vector.Zeroprotected bool TryBuildPondHitPosition(PlayerBase player, vector playerPos, vector cameraPos, vector cameraDir, out vector pondHitPosition)Re-validating is only needed when the deadband actually moved the point, which is the uncommon case. This saves a second raycast per frame.
Show 16 more
, DbgUI.End(), string.Format(), GetRaycastTarget(), CCTLiquid.HasClearPathToLiquidSurface(), IsAllowedPondLiquidSurface(), CCTLiquid.IsNearlyZero(), IsValidPondHitPosition(), DbgUI.Text(), CCTLiquid.TryGetLiquidSurfacePosAt(), m_DebugSyntheticCursor, m_SafeCursorDistance, POND_MAX_CAMERA_DIR_Y, SYNTHETIC_POND_FALLBACK_SURFACE_TOLERANCE, SYNTHETIC_POND_SAMPLE_STEP, SYNTHETIC_POND_SURFACE_TOLERANCE, and vector.Zeroprotected bool TryValidateHitCursor(PlayerBase player, vector playerPos, vector hitPosition, out vector resolvedHitPosition, out int resolvedLiquidType)Last chance: use closest sampled surface if it was very close.
protected bool TryValidatePondHitPosition(vector playerPos, vector hitPosition, out vector surfacePos, out int liquidType, int expectedLiquidType = LIQUID_NONE)Freshwater / pond path.
protected bool IsValidPondHitPosition(vector playerPos, vector hitPosition, int liquidType = LIQUID_NONE)If caller expected a specific liquid mask/type, require compatibility.
protected void ClearSyntheticCursorCache()Engine query last.
Show 1 more
, vector.Zeroprotected vector ApplySyntheticHitCursorStability(vector playerPos, vector candidate, int liquidType)protected bool TryUseCachedSyntheticCursor(PlayerBase player, vector playerPos, vector currentHitPosition, out vector resolvedHitPosition, out int resolvedLiquidType)Important: cached cursor must still match current aim.
Show 2 more
, SYNTHETIC_CURSOR_CACHE_AIM_TOLERANCE, and vector.ZeroIf there is no real hit, compare cached point to current camera ray.
Show 2 more
, m_SafeCursorDistance, and vector.ZeroLiquid points are raycast against slightly above the surface.
protected void ClearDebugCursorShapes()DIAG_DEVELOPERShow 1 more
, m_DebugSyntheticCursorShapesprotected void DebugDrawSyntheticCursor(PlayerBase player, vector originalHitPosition, vector cursorHitPosition, bool accepted, string reason, int liquidType = LIQUID_NONE)DIAG_DEVELOPER