Park/Buildings/Toilet.cs
namespace HC3;

public sealed class Toilet : Component, IBuildingEvents
{
	[Property] public SoundEvent FlushSound { get; set; }
	[Property] public ModelRenderer Renderer { get; set; }

	[Property] public GameObject Poo { get; set; }
	[Property] public SoundEvent PooSound { get; set; }

	void IBuildingEvents.OnGuestLeave( Guest guest )
	{
		GameObject.PlaySound( FlushSound );
		Renderer.SetBodyGroup( 0, 0 );

		// Relieve the guest
		var need = guest.Needs.GetNeed( "toilet" );
		if ( need != null )
		{
			need.Level = 0f;
		}

		// 5% chance of a stinky poo
		if ( Game.Random.Float() <= 0.05f )
		{
			CreateStinkyPoo();
		}
	}

	void CreateStinkyPoo()
	{
		Poo.Clone( WorldPosition + Vector3.Up * 32f );
		GameObject.PlaySound( PooSound );

		// Temporary, should set a state on the Toilet so it has to be cleaned, but for now just do this
		Renderer.SetBodyGroup( 0, 1 );
		Invoke( 30, () => Renderer.SetBodyGroup( 0, 0 ) );
	}
}