cards/CardCompass.cs

A card definition for a memory-match card game called CardCompass. On a mismatch involving this card, it picks a random other card of the same type and animates toward it while an event message and a 'compass' sound play.

Rough Code
using Sandbox;
using System.Threading.Tasks;

public class CardCompass : Card
{
	public override bool ShouldHandleEvent( EventType eventType )
	{
		return eventType == EventType.Mismatch && Manager.Instance.ChosenCards.Contains(this ) && !Manager.Instance.IsMismatchALockedMatch;
	}

	public override async Task HandleEventAsync( EventType eventType )
	{
		var otherCard = Manager.Instance.ChosenCards[0] == this ? Manager.Instance.ChosenCards[1] : Manager.Instance.ChosenCards[0];

		var matches = Manager.Instance.GetCardsOfType( otherCard.CardType, except: otherCard );
		if ( matches.Count == 0 )
			return;

		var match = matches[Game.Random.Int( 0, matches.Count - 1 )];

		Manager.Instance.PushEventMessage( this, eventType );

		await Task.DelayRealtime( 300 );

		MoveToPos( LocalPosition + (match.LocalPosition - LocalPosition).Normal * 5f, 0.25f, EasingType.QuadInOut, removeControlAfter: true );

		Manager.Instance.PlayCardSfx( "compass", this, volume: 1.1f, pitch: Game.Random.Float( 0.85f, 0.95f ) );

		await Task.DelayRealtime( 500 );

		Manager.Instance.PopEventMessage();
	}
}