swb_player/PlayerTriggerListener.cs

A component that listens for trigger enter/exit events around a player. It references a PlayerBase and a Collider and calls the player's ladder enter/exit handlers when the other collider has the ladder tag and the player is not in noclip or a bot.

using SWB.Shared;

namespace SWB.Player;

[Group( "SWB" )]
[Title( "PlayerTriggerListener" )]
public class PlayerTriggerListener : Component, Component.ITriggerListener
{
	[Property] public PlayerBase Player { get; set; }
	[Property] public Collider Collider { get; set; }

	public void OnTriggerEnter( Collider other )
	{
		if ( other is null || Player.Noclip ) return;
		if ( other.Tags.Has( TagsHelper.Ladder ) && !Player.IsBot )
			Player.OnLadderEnter( other );
	}

	public void OnTriggerExit( Collider other )
	{
		if ( other is null || Player.Noclip ) return;
		if ( other.Tags.Has( TagsHelper.Ladder ) && !Player.IsBot )
			Player.OnLadderExit( other );
	}
}