Slipperyfeet
Overview
This component implements a slippiness system for player entities, dynamically adjusting a slippiness value based on movement speed while on slippery surfaces (e.g., ocean ice or ice-covered entities). It accumulates slip when running on ice and decays over time when stationary, triggering a feetslipped event when the value exceeds a defined threshold.
Dependencies & Tags
- Component Dependencies: None (no explicit
inst:AddComponentcalls). - Tags Used: Listens for entities with the
"slipperyfeettarget"tag to determine local slip sources; checks for"nonslipgritpool"tag entities for grit-based nonslip effects. - Tag Adds/Removes: None.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
_sources | SourceModifierList | SourceModifierList(inst, false, SourceModifierList.boolean) | Tracks active slippery sources (e.g., "ocean_ice", "ice_entity"). Boolean list used to gate slippiness accumulation. |
_updating | table | {} | Tracks which update loops are active (e.g., "accumulate", "decay", "checkice"). Keys are string identifiers; values are booleans. |
onicetile | boolean | false | true when the player is standing directly on an ocean ice tile. |
started | boolean | false | Indicates whether the component is actively updating (i.e., listening to state changes). |
threshold | number | TUNING.WILSON_RUN_SPEED * 4 | Minimum slippiness value to trigger the feetslipped event. |
decay_accel | number | TUNING.WILSON_RUN_SPEED * 2 | Acceleration used for decay rate calculation (applied over time). |
decay_spd | number | 0 | Current decay speed (used for linear interpolation of decay over time). |
slippiness | number | 0 | Current accumulated slippiness value. Ranges from 0 (not slippery) upward; triggers feetslipped when exceeding threshold. |
Main Functions
StartSlipperySource(src, key)
- Description: Enables a slippery source (e.g.,
"ocean_ice"or"ice_entity"), activates internal updates, and begins accumulation ofslippinessif not already active. - Parameters:
src(string): The source identifier (e.g.,"ice_entity").key(any, optional): Optional key used forSourceModifierListscoping.
StopSlipperySource(src, key)
- Description: Disables a slippery source. If no sources remain active, stops internal updates and
slippinessaccumulation. - Parameters:
src(string): The source identifier to stop.key(any, optional): Optional key used forSourceModifierListscoping.
GetSlipperyAndNearbyEnts()
- Description: Scans for nearby entities with the
"slipperyfeettarget"tag withinSLIPPERY_CHECK_RADIUS(12 units). Returns the first valid slippery entity (whereIsSlipperyAtPositionreturnstrue) and the first entity found (even if non-slippery). Used for detecting nearby ice patches or entities. - Parameters: None.
SetCurrent(val)
- Description: Sets
slippinesstoval. Ifval > 0, starts thedecayupdate loop; ifval ≥ threshold, pushes thefeetslippedevent. - Parameters:
val(number): The newslippinessvalue.
DoDelta(delta)
- Description: Adjusts
slippinessbydelta, clamping to non-negative values. Handles both accumulation (positivedelta) and decay (negativedelta). - Parameters:
delta(number): Change to apply toslippiness.
CalcAccumulatingSpeed()
- Description: Computes a curved accumulation rate based on movement speed. Formula:
speed² / TUNING.WILSON_RUN_SPEED. Used to increase slippiness faster at higher speeds. - Parameters: None.
StartUpdating_Internal(reason), StopUpdating_Internal(reason)
- Description: Manages component-level update cycles.
StartUpdating_Internalactivatesinst:StartUpdatingComponent, cancelling any slow-check task;StopUpdating_Internaldeactivates updates and restarts the slow-check task if no other updates are running. - Parameters:
reason(string): Identifier for the update loop (e.g.,"accumulate","checkice").
DoDecay(dt)
- Description: Applies decay to
slippinessusing a linearly accelerating speed (decay_spd), based ondecay_accel. Simulates gradual loss of slip effect over time. - Parameters:
dt(number): Delta time (seconds).
OnUpdate(dt)
- Description: Main update loop called every frame when the component is active. Performs:
- Ocean ice tile tracking (stops slip if visually grounded off-ice).
- Slippery entity proximity checks (updates
"ice_entity"source). - Accumulation or decay logic, influenced by grit pools and entity-specific slip rates.
- Parameters:
dt(number): Delta time (seconds).
LongUpdate(dt)
- Description: High-interval update (e.g., for infrequent but precise adjustments). Accumulates slip in a single-frame burst (
FRAMES), or decays ifslippiness > 0. - Parameters:
dt(number): Delta time (seconds).
GetDebugString()
- Description: Returns a formatted debug string showing: current
slippiness,threshold, and either accumulation rate or current decay speed. - Parameters: None.
Events & Listeners
- Listens to
"on_OCEAN_ICE_tile": CallsOnOceanIcewhen the entity enters or exits ocean ice tiles. - Listens to
"newstate": CallsOnNewStateto enable/disable accumulation when the entity enters or exits"running"state (and lacks"noslip"). - Triggers
"feetslipped": Pushed viainst:PushEventwhenslippiness ≥ threshold(withinSetCurrent).