Demos/Compass/CompassUI.cs
using Goo;
using Sandbox.Compass;
using Sandbox.UI;
namespace Sandbox;
[Title( "Demo: Compass" ), Category( "UI/Demo" ), Icon( "explore" )]
public sealed class CompassUI : GooPanel<Container>
{
readonly CompassView _view = new();
protected override void OnEnabled()
{
base.OnEnabled();
Panel.Style.Width = Length.Percent( 100 );
Panel.Style.Height = Length.Percent( 100 );
}
protected override void OnUpdate()
{
if ( _view.Tick( Scene, Time.Delta ) ) Rebuild();
base.OnUpdate();
}
protected override Container Build()
{
var root = Hud.Overlay();
root.Children.Add( HudLayout.Anchored( Layout.Anchor.TopCenter, _view.Build(), key: "compass" ) );
return root;
}
}