A component that listens for trigger enter/exit events for a player. It forwards ladder enter/exit events to the PlayerBase unless the player is in noclip or is 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 );
}
}