@using Sandbox; @using Sandbox.UI; @inherits Panel Action?.Invoke())> @if(!string.IsNullOrEmpty(Image)) { }
@code { public string Text { get; set; } = "Hello World!"; public float Duration { get; set; } = 5.0f; public string Image { get; set; } public Action Action { get; set; } TimeSince timeSinceCreated = 0f; float hoverTime = 0f; public override void Tick () { base.Tick(); if ( HasHovered || LoadingScreen.IsVisible ) { if (hoverTime == 0) hoverTime = timeSinceCreated; else timeSinceCreated = hoverTime; } else { hoverTime = 0; } if(timeSinceCreated > Duration) { Delete(); } } protected override int BuildHash () { return System.HashCode.Combine( timeSinceCreated.ToString() ); } }