upd
This commit is contained in:
13
Code/UI/ChatHistory.cs
Normal file
13
Code/UI/ChatHistory.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Sandbox;
|
||||
|
||||
public static class ChatHistory
|
||||
{
|
||||
public static List<Chat.Entry> Entries { get; private set; } = new();
|
||||
|
||||
public static void Add(ulong steamid, string author, string message)
|
||||
{
|
||||
Entries.Add(new Chat.Entry(steamid, author, message, 0.0f));
|
||||
}
|
||||
}
|
||||
55
Code/UI/TeleportMazeButton.cs
Normal file
55
Code/UI/TeleportMazeButton.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Sandbox.Gravity;
|
||||
|
||||
namespace Sandbox.UI;
|
||||
|
||||
[Icon( "skip_next" )]
|
||||
public sealed class TeleportMazeButton : InteractionButton
|
||||
{
|
||||
[Property] public Maze Maze { get; set; }
|
||||
[Property] public InteractTeleporter Teleporter { get; set; }
|
||||
|
||||
int maxAttempts = 30;
|
||||
|
||||
public override bool Press( IPressable.Event e )
|
||||
{
|
||||
base.Press( e );
|
||||
if ( Maze.IsValid() )
|
||||
{
|
||||
Maze.RpcRequestMaze();
|
||||
}
|
||||
|
||||
DoTeleport();
|
||||
return true;
|
||||
}
|
||||
|
||||
private async void DoTeleport()
|
||||
{
|
||||
int attempt = 0;
|
||||
|
||||
if ( Maze.IsValid() )
|
||||
{
|
||||
while ( !Maze.IsReady && attempt < maxAttempts )
|
||||
{
|
||||
await Task.Delay( 1000 );
|
||||
attempt++;
|
||||
}
|
||||
|
||||
if ( Maze.IsReady )
|
||||
{
|
||||
// Teleporter.TeleportAll();
|
||||
foreach ( var player in Teleporter.Players )
|
||||
{
|
||||
Teleporter.Teleport( player, Maze.GetRandomCellPosition() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning( "Maze was not ready in time. Teleport aborted." );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Teleporter.TeleportAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user