class CCTLiquidFrameProbe
CCTLiquidFrameProbe › Managed
Frame scoped, shared cache of the expensive liquid target queries.
ActionManagerClient.FindContextualUserActions() runs once per frame and feeds the very same PlayerBase, ActionTarget and item to every registered ActionInput, which then calls ActionBase.Can() on each of its candidate actions. With bare hands next to water that means CCTLiquid.Can() runs 4-6 times per frame (drink pond, wash hands, wash head, eat snow, wash hands snow, ...), and with a container in hands another few (fill, mix mortar, wet clothing) - every one of them tracing the exact same cursor position.
The engine queries those conditions need depend only on player + target object + component index + cursor hit position + surface detection type and *not* on the action's liquid mask, max distance or vertical reach. So they are evaluated once per frame and shared, while each condition still applies its own mask and reach checks on the cached values.
Result: N liquid conditions per frame cost 2 GetSurface + 1 raycast in total instead of 2N + N.
Everything is lazy: a payload is only queried when the first condition of the frame actually reaches that check, so an early rejecting frame stays cheap.
Constructors 1
void CCTLiquidFrameProbe()Show 14 more
, new TIntArray(), RaycastRVParams.flags, SurfaceDetectionParameters.includeWater, m_ComponentIndices, m_RaycastParams, m_RaycastResults, m_SurfaceParams, m_SurfaceParamsNoWater, m_SurfaceResult, SurfaceDetectionParameters.rsd, RaycastRVParams.sorted, SurfaceDetectionParameters.syncMode, RaycastRVParams.type, and vector.ZeroMembers 41
protected static ref CCTLiquidFrameProbe m_Instanceprotected PlayerBase m_PlayerIdentity of the currently cached frame. The tick time is a secondary guard only - the primary invalidation is the explicit InvalidateFrame() from ActionManagerBase.Update(), because GetTickTime() is a float and its resolution degrades below one frame on long running servers.
protected vector m_HitPositionprotected bool m_HasFrameprotected bool m_LiquidSurfaceQueriedCursor liquid surface (includeWater).
protected bool m_LiquidSurfaceValidprotected float m_LiquidSurfaceHeightprotected int m_LiquidSurfaceTypeprotected bool m_LiquidSurfaceHasTypeprotected bool m_NonWaterSurfaceQueriedCursor terrain/roadway surface (no water), for the water-below-grass test.
protected bool m_NonWaterSurfaceValidprotected float m_NonWaterSurfaceHeightprotected bool m_ClearPathQueriedLine of sight to the liquid point. Memoized on the tested position.
protected vector m_ClearPathPositionprotected bool m_ClearPathValueprotected bool m_SeaLevelsQueriedSea levels, world constants but re-read once per frame.
protected float m_SeaLevelprotected float m_SeaLevelMaxprotected bool m_WaterLevelQueriedPlayer water level. Memoized on (player, playerPos) rather than on the Begin() frame key, because it depends only on where the player stands and not on the target being evaluated.
protected PlayerBase m_WaterLevelPlayerprotected vector m_WaterLevelPosprotected vector m_WaterLevelValueprotected bool m_WellQueriedWell liquid source components. Memoized on the tested object + component.
protected Object m_WellObjectprotected int m_WellComponentIndexprotected bool m_WellValueprotected ref SurfaceDetectionParameters m_SurfaceParamsScratch buffers, one set for the whole game instead of one per condition.
protected ref SurfaceDetectionParameters m_SurfaceParamsNoWaterprotected ref SurfaceDetectionResult m_SurfaceResultprotected ref RaycastRVParams m_RaycastParamsprotected ref array<ref RaycastRVResult> m_RaycastResultsprotected ref TIntArray m_ComponentIndicesstatic int m_StatFramesDIAG_DEVELOPERframes in which the probe was rebuilt
static int m_StatBeginCallsDIAG_DEVELOPERCan() calls that touched the probe
static int m_StatCacheHitsDIAG_DEVELOPERCan() calls served from the cached frame
static int m_StatSurfaceTracesDIAG_DEVELOPERShow 1 more
, TraceNonWaterSurface()static int m_StatRaycastsDIAG_DEVELOPERstatic int m_StatWaterLevelQueriesDIAG_DEVELOPERMethods 15
static CCTLiquidFrameProbe GetInstance()bool Begin(PlayerBase player, Object targetObject, int componentIndex, vector hitPosition, SurfaceDetectionType surfaceDetectionType)Declares the inputs the calling condition is about to evaluate. If they match the currently cached frame everything below is served from the cache, otherwise the cache is dropped.
Returns: true when the cached frame was reused
Liquid surface under the cached cursor position.
Show 4 more
, m_LiquidSurfaceHeight, m_LiquidSurfaceQueried, m_LiquidSurfaceType, and m_LiquidSurfaceValidHighest non-liquid surface under the cached cursor position.
Show 2 more
, m_NonWaterSurfaceQueried, and m_NonWaterSurfaceValidbool HasClearPath(PlayerBase player, vector surfacePos)Show 2 more
, m_SeaLevelMax, and m_SeaLevelsQueriedvoid GetPlayerWaterLevel(notnull PlayerBase player, out vector waterInfo)Shared water level under the player, as returned by HumanCommandSwim.WaterLevelCheck: (totalWaterDepth, characterDepth, 0).
Several liquid actions resolve their stance from this every frame (see ActionBase.Can() -> GetClosestPossibleStance() -> GetStanceMask()), all with the same arguments, so the query is done once per frame and shared.
Show 4 more
, m_WaterLevelPlayer, m_WaterLevelPos, m_WaterLevelQueried, and m_WaterLevelValueIs the aimed at component one of the well's liquid source components.
bool TraceLiquidSurface(vector probePosition, out float surfaceHeight, out int liquidType, out bool hasSurfaceType)Uncached surface trace at an arbitrary position, for the camera ray march in CCTLiquidSyntheticCursor which samples many different positions.
The result object is reused, never read a stale surface.
bool TraceClearPath(PlayerBase player, vector surfacePos)Check if we have the same or an other liquid surface
void Invalidate()Drops the cached frame. Called once per action manager update, and usable from anywhere that changes the world mid frame.
static void InvalidateFrame()No-op when no liquid condition has ever run, so the hook in ActionManagerBase.Update() does not create the probe for nothing.
static void ResetStats()DIAG_DEVELOPERShow 3 more
, m_StatRaycasts, m_StatSurfaceTraces, and m_StatWaterLevelQueriesstatic string GetStatsString()DIAG_DEVELOPER