Tofu/TofuCollect9.cs

Component attached to a collectible tofu entity. When a trigger enters, it increments a global tofu count, marks the specific tofu-9 as collected, plays a sound, and destroys the game object on the next update if collected.

Networking
using Sandbox;

public sealed class TofuCollect9 : Component, Component.ITriggerListener
{
	[Property] public SoundEvent tofu { get; set; }
	void ITriggerListener.OnTriggerEnter( Collider collision )
	{
		ScoreManager.TofuCount += 1;
		ScoreManager.Tofu9collect = true;
		GameObject.PlaySound( tofu );
	}
	protected override void OnUpdate()
	{

		if ( ScoreManager.Tofu9collect )
		{
			GameObject.Destroy();

		}
	}
}