Add files via upload

This commit is contained in:
celisej567
2021-08-05 17:54:51 +03:00
committed by GitHub
parent d58ad89d11
commit 76b55e2a87
57 changed files with 5632 additions and 0 deletions

41
code/ui/CurrentTool.cs Normal file
View File

@@ -0,0 +1,41 @@
using Sandbox;
using Sandbox.Tools;
using Sandbox.UI;
using Sandbox.UI.Construct;
public class CurrentTool : Panel
{
public Label Title;
public Label Description;
public CurrentTool()
{
Title = Add.Label( "Tool", "title" );
Description = Add.Label( "This is a tool", "description" );
}
public override void Tick()
{
var tool = GetCurrentTool();
SetClass( "active", tool != null );
if ( tool != null )
{
Title.SetText( tool.ClassInfo.Title );
Description.SetText( tool.ClassInfo.Description );
}
}
BaseTool GetCurrentTool()
{
var player = Local.Pawn;
if ( player == null ) return null;
var inventory = player.Inventory;
if ( inventory == null ) return null;
if ( inventory.Active is not Tool tool ) return null;
return tool?.CurrentTool;
}
}