Tofu/TofuCollect8.cs

Component attached to a game object that listens for trigger enter events to mark tofu #8 collected. On trigger it increments a global TofuCount, sets Tofu8collect flag, and plays a configured sound. On update it destroys the GameObject if the Tofu8collect flag is set.

Networking
using Sandbox;

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

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

		}
	}
}