Code/SboxSuperuser/Engine/Props/ScenePropWorld.cs

Adapter implementing IPropWorld by destroying scene objects. Looks up each Guid in the active scene's Directory and calls Destroy, returning the count removed.

using Sandbox;

namespace SboxSuperuser.Engine.Props;

/// <summary>Removes props from the active scene by their object IDs.</summary>
internal sealed class ScenePropWorld : IPropWorld
{
	public int Remove( IReadOnlyList<Guid> objects )
	{
		var removed = 0;
		foreach ( var id in objects )
		{
			if ( Game.ActiveScene?.Directory.FindByGuid( id ) is not { } gameObject || !gameObject.IsValid() ) continue;
			gameObject.Destroy();
			removed++;
		}
		return removed;
	}
}