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.
- Listed in Global namespace: E to H
- Inherits or implements
NetworkEntityBehaviour,IGameCondition - Attributes
RequireComponent - Documented in Grab points and hand-touch points, Other systems
Constructors
| Member | What it is |
|---|---|
HandHoverPoint() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
30 private and internal fields
| Member | What it is |
|---|---|
private PlayerEvent activated | Player event invoked on activation. |
private float activationValue | Seconds of charging at full closeness needed to activate. Defaults to 3. |
private ColorLerp attractingHandTouchColor | Colour lerp pulsed by the attracting effect. |
private Coroutine attractingRoutine | Running AttractingRoutine, or null. |
private float autoHoverRadius | Distance from the point at which a nearby hand starts the interaction by itself. |
private float colorMax | Top of the attracting colour pulse. |
private float colorMin | Bottom of the attracting colour pulse. |
private static readonly Dictionary<IPlayer, HandHoverPoint> current | Static map of the hover point each player is using, for isUniquePerPlayer. |
private Hand currentHand | Hand of the current or last interactor. |
private Interactor currentInteractor | Interactor holding the point, or null. |
private float currentStrength | Charge, 0 to 1; activates above 1 on the server. |
private PlayerEvent deactivated | Player event invoked on reset. |
private float decayPerSecond | How fast strength drops once the hand leaves. |
private float frequency | Speed of the attracting colour pulse. |
private HandGestureDefinition gesture | Hand gesture forced while hovering. |
private GameObject handGlyph | Serialized glyph object not used by this class. |
private HandTouchVfxController handTouchVfxController | Plays the activating and completed effects. |
private Func<bool> hasContentCheck | Check behind IsConditionMet. |
private float hoverRadius | Distance at which charging is weakest; beyond it the interaction stops. |
private float idealRadius | Distance at which charging is fastest. |
private Interactable interactable | The Interactable on this object. |
private bool isActivated | True once activated, until deactivated. |
private bool isUniquePerPlayer | If true (default), a player can only use one such point at a time. |
private float previousStrength | Strength last frame, to detect starting and stopping. |
private FloatEvent strengthChanged | Float event invoked with the strength as it changes. |
private MethodSyncStruct<bool> syncActivated | Method sync for the activated flag. |
private MethodSync syncAll | Method sync for the full state, sent to joining players. |
private Transform targetHoverPoint | Where the hand is pulled to and distances are measured from. |
private readonly Dictionary<Collider, Interactor> trackedInteractors | Local hand triggers inside the area, by collider. |
private IUnityUpdateMethod trackHand | Handle of the TrackHand update. |
Properties
| Member | What it is |
|---|---|
Action OnConditionChanged { get; set; } | IGameCondition callback, invoked when the point activates. |
Events
| Member | What it is |
|---|---|
event Action<IPlayer> Activated | Event raised with the player when the point activates. |
event Action<IPlayer> Deactivated | Event raised with the player when the point is reset. |
event Action<float> StrengthChanged | Event raised with the charge strength as it changes. |
Methods
| Member | What 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
| Member | What 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: