mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 00:08:05 -04:00
* Added a platform level chatbox that games can use * Published games do not have this * Newly published projects have it enabled by default, if the game is networked * Check out the Platform page in Project Settings to turn it off * Party chat uses this, you can also switch between party / game chat if eligible using TAB You can use `Sandbox.Platform.Chat.AddText( ... )` to add system text for notifications or other things. This has blocking behaviour built-in, and you can disable the chat in your settings menu. You can listen to chat messages using `IChatEvent.OnChatMessage`, so if you want to filter for stuff like team chat, add commands to your game, you can do that. We have potential plans for first-party commands / chat channels in the future.
32 lines
837 B
C#
32 lines
837 B
C#
using Sandbox.Network;
|
|
|
|
namespace Sandbox;
|
|
|
|
public abstract partial class Connection
|
|
{
|
|
/// <summary>
|
|
/// Key-value store for connections. Not to be mistaken with <see cref="Info"/> which is sent from the client and can be used for things like avatar customization.
|
|
/// This is not shared to other connections.
|
|
/// </summary>
|
|
internal Dictionary<string, object> KeyValues { get; } = new();
|
|
|
|
/// <summary>
|
|
/// Get a typed value from the connection's key-value store.
|
|
/// </summary>
|
|
internal T Get<T>( string key, T defaultValue = default )
|
|
{
|
|
if ( KeyValues.TryGetValue( key, out var val ) && val is T typed )
|
|
return typed;
|
|
|
|
return defaultValue;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set a typed value in the connection's key-value store.
|
|
/// </summary>
|
|
internal void Set<T>( string key, T value )
|
|
{
|
|
KeyValues[key] = value;
|
|
}
|
|
}
|