@using Sandbox; @using Sandbox.UI; @using System.Threading.Tasks; @inherits PanelComponent @namespace Sandbox
@if (IsHoldInteraction) {
Hold
}
@InteractionString
@code { private Texture InputTexture; public string InteractionString {get; set;} private bool IsInteracting = false; public bool IsHoldInteraction = false; public float ProgressionHold = 0; /// /// the hash determines if the system should be rebuilt. If it changes, it will be rebuilt /// protected override int BuildHash() => System.HashCode.Combine( InputTexture, InteractionString, IsHoldInteraction, ProgressionHold); protected override void OnUpdate() { InputTexture = Input.GetGlyph("use", InputGlyphSize.Medium, true); } /// /// Triggers the interaction animation. /// public async Task TriggerInteractAnimation() { if (IsInteracting) return; // Prevent overlapping animations IsInteracting = true; StateHasChanged(); // Wait for the animation duration (e.g., 300ms) await Task.Delay(100); IsInteracting = false; StateHasChanged(); } }