UI/MansionGame.Ui.cs

UI methods on the MansionGame game class that broadcast client-side visual events. It exposes RPC broadcast methods to show an event log line, a full-screen black fade, a world-space ping, and spawn local money-waft world panels at a position.

Networking
using Sandbox;

namespace BrickJam;

public sealed partial class MansionGame
{
	/// <summary>
	/// Broadcast a coloured event-log line to every client. Replaces the legacy
	/// <c>Eventlog.Send</c> / <c>Player._addEventlog</c> <c>[ClientRpc]</c>.
	/// </summary>
	[Rpc.Broadcast]
	public void ShowEventlog( string text, float time = 8f )
	{
		UI.EventlogBus.Post( text, time );
	}

	/// <summary>Broadcast a full-screen fade (in → hold black → out) to every client.</summary>
	[Rpc.Broadcast]
	public void ShowBlackScreen( float blackDuration = 2f, float startTransition = 1f, float endTransition = 1f )
	{
		UI.BlackScreenBus.Trigger( blackDuration, startTransition, endTransition );
	}

	/// <summary>Broadcast a contextual world ping to every client.</summary>
	[Rpc.Broadcast]
	public void ShowPing( Vector3 worldPosition, int type )
	{
		UI.PingBus.Post( worldPosition, (UI.PingBus.PingType)type );
	}

	/// <summary>Broadcast a money-waft burst at a world position. Each client spawns local panels.</summary>
	[Rpc.Broadcast]
	public void ShowMoneyWaft( Vector3 worldPosition, int value )
	{
		var type = Game.TypeLibrary.GetType( "MoneyWaft" );
		if ( type is null )
			return;

		for ( var i = 0; i < 3; i++ )
		{
			var go = new GameObject( true, $"MoneyWaft:{value}" );
			go.WorldPosition = worldPosition + Vector3.Up * 20f;

			var panel = go.Components.Create<WorldPanel>();
			panel.LookAtCamera = true;
			panel.PanelSize = new Vector2( 400, 200 );

			go.Components.Create( type );
		}
	}
}