Skip to main content

HandHoverPoint

A class in Root.Township, the global namespace.

A spot the player holds a hand over until it charges up and activates (the hand-touch points on stations and glyphs). Charging runs on both sides; the server decides activation and syncs it. Also an IGameCondition.

Constructors​

MemberWhat it is
HandHoverPoint()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

30 private and internal fields
MemberWhat it is
private PlayerEvent activatedPlayer event invoked on activation.
private float activationValueSeconds of charging at full closeness needed to activate. Defaults to 3.
private ColorLerp attractingHandTouchColorColour lerp pulsed by the attracting effect.
private Coroutine attractingRoutineRunning AttractingRoutine, or null.
private float autoHoverRadiusDistance from the point at which a nearby hand starts the interaction by itself.
private float colorMaxTop of the attracting colour pulse.
private float colorMinBottom of the attracting colour pulse.
private static readonly Dictionary<IPlayer, HandHoverPoint> currentStatic map of the hover point each player is using, for isUniquePerPlayer.
private Hand currentHandHand of the current or last interactor.
private Interactor currentInteractorInteractor holding the point, or null.
private float currentStrengthCharge, 0 to 1; activates above 1 on the server.
private PlayerEvent deactivatedPlayer event invoked on reset.
private float decayPerSecondHow fast strength drops once the hand leaves.
private float frequencySpeed of the attracting colour pulse.
private HandGestureDefinition gestureHand gesture forced while hovering.
private GameObject handGlyphSerialized glyph object not used by this class.
private HandTouchVfxController handTouchVfxControllerPlays the activating and completed effects.
private Func<bool> hasContentCheckCheck behind IsConditionMet.
private float hoverRadiusDistance at which charging is weakest; beyond it the interaction stops.
private float idealRadiusDistance at which charging is fastest.
private Interactable interactableThe Interactable on this object.
private bool isActivatedTrue once activated, until deactivated.
private bool isUniquePerPlayerIf true (default), a player can only use one such point at a time.
private float previousStrengthStrength last frame, to detect starting and stopping.
private FloatEvent strengthChangedFloat event invoked with the strength as it changes.
private MethodSyncStruct<bool> syncActivatedMethod sync for the activated flag.
private MethodSync syncAllMethod sync for the full state, sent to joining players.
private Transform targetHoverPointWhere the hand is pulled to and distances are measured from.
private readonly Dictionary<Collider, Interactor> trackedInteractorsLocal hand triggers inside the area, by collider.
private IUnityUpdateMethod trackHandHandle of the TrackHand update.

Properties​

MemberWhat it is
Action OnConditionChanged { get; set; }IGameCondition callback, invoked when the point activates.

Events​

MemberWhat it is
event Action<IPlayer> ActivatedEvent raised with the player when the point activates.
event Action<IPlayer> DeactivatedEvent raised with the player when the point is reset.
event Action<float> StrengthChangedEvent raised with the charge strength as it changes.

Methods​

MemberWhat it is
void Deactivate(IPlayer player)Resets the point so it can be charged again and raises Deactivated. The server syncs this to the chunk.
override void Initialize()Creates the syncs and starts the attracting effect.
void InitializeAttractingCheck(Func<bool> hasContentCheck)Sets the check used by IsConditionMet.
bool IsConditionMet()Runs the check given to InitializeAttractingCheck; false if none was set.
override void OnConnected(Player player)Sends strength and activation state to a joining player.
20 private and internal methods
MemberWhat it is
private void Activate()Sets full strength, stops the hand's interaction and plays the completed effect. The server syncs it, reports a hand-touch task and watches for the player leaving.
private void AdjustHandPull(float strength)Pulls the hand's IK target from where it was towards the hover point by a strength.
private IEnumerator AttractingRoutine() (iterator)Client coroutine that pulses the attracting colour between colorMin and colorMax.
private void Awake()Hooks the interactable's filter, start and end events; starts disabled.
private void BeginHandPull()Sets the hover gesture and frees the hand's IK target so it can be pulled.
private bool CheckInteractDistance(float distanceSquared)Stops the interaction if the hand moves further than hoverRadius (not in local tests). Returns true if it stopped.
private void Deactivate()Resets the point so it can be charged again and raises Deactivated. The server syncs this to the chunk.
private void Ended(Interactable interactable, Interactor interactor)When the holding interactor lets go, clears it and releases the hand.
private void EndHandPull()Clears the gesture override and detaches the hand.
private void Filter(Interactor interactor, Interactable interactable, ref bool result)Blocks interaction while activated or held, while a local hand already has over half strength, or when the player is downed.
private void LateUpdate()While held, charges strength by closeness and pulls the hand (server activates above 1). Otherwise decays strength.
private void LosePlayer(NetworkEntity entity, bool isUnload)Deactivates when the activating player's entity is destroyed.
private void OnlyAllowOneInteractionPerPlayer()With isUniquePerPlayer, deactivates or stops the player's other hover point so only one is in use.
private void OnTriggerEnter(Collider other)Starts tracking a local hand trigger entering the area so it can auto-start the interaction.
private void OnTriggerExit(Collider other)Stops tracking a hand; removes the update when none are left.
private void SetAttractingState(bool on)Client: starts the attracting colour pulse.
private void Started(Interactable interactable, Interactor interactor)Takes the first interactor that starts, begins the hand pull and enables charging.
private void SyncActivated(IPlayer player, Stream stream, bool value)Syncs the activated flag; clients activate or deactivate to match.
private void SyncAll(IPlayer player, Stream stream)Syncs strength and activation for joining players.
private void TrackHand()Late update: when a tracked hand's grip gets within autoHoverRadius, starts the interaction for it.

Used in​

Members of other types that take, return or hold a HandHoverPoint: