Effects/Ring/AoeRing.razor
@using Sandbox;
@inherits PanelComponent
@namespace PlanetMeat
<root style="border-color: @(RingColor.Hex)">
<div class="data">
<div class="label" style="color: @(TextColor.Hex)">@Label</div>
</div>
</root>
@code
{
private static GameObject Prefab => GameObject.GetPrefab("tools/ring.prefab");
public static AoeRing Create(Vector3 position, float radius, string label = "")
{
var go = Prefab.Clone(position.WithZ(position.z + 2.0f), new Angles(-90.0f, 0.0f, 0.0f));
if (go.Components.Get<AoeRing>() is AoeRing ring)
{
ring.Radius = radius;
ring.Label = label;
return ring;
}
return null;
}
[Property] public string Label { get; set; } = "";
[Property] public Color RingColor { get; set; } = Color.White;
[Property] public Color TextColor { get; set; } = Color.White;
public float Radius
{
get;
set
{
field = value;
if (Components.Get<WorldPanel>() is WorldPanel panel)
panel.PanelSize = 40.0f * System.MathF.Max(0.0f, value);
}
}
protected override int BuildHash() => System.HashCode.Combine(Label);
}