Utils/MoneyEffect.cs
public sealed class MoneyEffect : Component
{
[Property] ParticleEffect Effect { get; set; }
[Property] ParticleTextRenderer TextRenderer { get; set; }
public Color TintColor { get; set; } = Color.White;
public string Text { get; set; } = "$1";
public bool PlaySound { get; set; } = true;
protected override void OnStart()
{
base.OnStart();
Effect.Tint = TintColor;
var _text = new TextRendering.Scope( Text, Color.White, 64 );
_text.FontSize = 64;
_text.FontName = "Poppins";
_text.FontWeight = 750;
_text.Outline = new TextRendering.Outline { Color = Color.Black, Enabled = true, Size = 10 };
TextRenderer.Text = _text;
TextRenderer.Scale = 2f;
Sound.Play( "money_spent_01", WorldPosition + Vector3.Up * 100f );
}
/// <summary>
/// Broadcast a money effect object to all players.
/// </summary>
[Rpc.Broadcast( NetFlags.HostOnly )]
public static void Broadcast( Vector3 position, string text, Color color )
{
var money = GameObject.GetPrefab( "prefabs/gameplay/money_spent_01.prefab" )
.Clone( position );
if ( !money.IsValid() )
return;
var effect = money.GetComponent<MoneyEffect>();
effect.Text = text;
effect.TintColor = color;
}
}