Extension methods for SceneTrace that apply GridBuilder generation filters to a scene trace, converting grid settings like StaticOnly and include/exclude tag lists into SceneTrace calls.
using Sandbox;
namespace GridAStar;
public static partial class TraceExtensions
{
/// <summary>
/// Apply a grid's generation filters to a scene trace. Scene-System port: legacy <c>StaticOnly()</c>
/// becomes <c>IgnoreDynamic()</c>. Tag filters are only applied when non-empty (an empty
/// <c>WithAllTags</c> would otherwise filter against nothing).
/// </summary>
public static SceneTrace WithGridSettings( this SceneTrace self, GridBuilder settings )
{
if ( settings.StaticOnly )
self = self.IgnoreDynamic();
// ANY of the include tags (not all) - the floor may be tagged "world" while props are "solid", and
// requiring both would match nothing. Legacy used WithAllTags but its maps used a single floor tag.
if ( settings.TagsToInclude.Count > 0 )
self = self.WithAnyTags( settings.TagsToInclude.ToArray() );
if ( settings.TagsToExclude.Count > 0 )
self = self.WithoutTags( settings.TagsToExclude.ToArray() );
return self;
}
}