A UI PanelComponent Razor file that renders an absolute-positioned root element for a grid cell flash effect and destroys itself after a set duration. It exposes properties for CSS class, duration, screen position and cell size, starts a timer on start, and removes the component when the time elapses.
@using Sandbox;
@using Sandbox.UI;
@inherits PanelComponent
<root class="@CssClass" style="position:absolute;left:@(ScreenX.ToString("F0"))px;top:@(ScreenY.ToString("F0"))px;width:110px;height:110px;pointer-events:none;border-radius:14px;z-index:8;"></root>
@code {
public string CssClass { get; set; } = "";
public float Duration { get; set; } = 0.6f;
public float ScreenX { get; set; }
public float ScreenY { get; set; }
public float CellSize { get; set; } = 110f;
float _startTime;
protected override void OnStart()
{
_startTime = Time.Now;
}
protected override void OnUpdate()
{
if ( Time.Now >= _startTime + Duration )
GameObject.Destroy();
}
}