RiverPortion.cs

A Component that listens for trigger enter/exit events for a section of a river. It filters colliders by tag and validity, ignores proxies, and forwards matching Thing objects to the River's OnTriggerEnter and OnTriggerExit handlers.

Reflection
using Sandbox;

public sealed class RiverPortion : Component, Component.ITriggerListener
{
	[Property] public River River { get; set; }

	public List<Thing> Touching = new List<Thing>();
	public List<string> CollideWithTags = new List<string>();

	protected override void OnStart()
	{
		base.OnStart();

		CollideWithTags.Add( "player" );
		CollideWithTags.Add( "enemy" );
		CollideWithTags.Add( "item" );
	}

	void ITriggerListener.OnTriggerEnter( Collider collider )
	{
		if ( !collider.IsTrigger || CollideWithTags.Count == 0 )
			return;

		var thing = collider.GetComponent<Thing>();
		if ( !thing.IsValid() )
			return;

		if ( thing.IsProxy )
			return;

		if ( !thing.Tags.HasAny( CollideWithTags ) )
			return;

		River.OnTriggerEnter( thing );
	}

	void ITriggerListener.OnTriggerExit( Collider collider )
	{
		if ( !collider.IsTrigger || CollideWithTags.Count == 0 )
			return;

		var thing = collider.GetComponent<Thing>();
		if ( !thing.IsValid() )
			return;

		if ( thing.IsProxy )
			return;

		if ( !thing.Tags.HasAny( CollideWithTags ) )
			return;

		River.OnTriggerExit( thing );
	}
}