cards/CardBear.cs

A card type for a card game. On a Reveal event it has a 20% chance to trigger when the revealed card is food or a beverage, then waits and asks Manager to shake this card.

using Sandbox;
using System.Threading.Tasks;

public class CardBear : Card
{
	public override bool IsAlive => true;

	public override bool ShouldHandleEvent( EventType eventType )
	{
		return eventType == EventType.Reveal && Manager.Instance.RevealedCard.IsFoodOrBeverage && Game.Random.Float( 0f, 1f ) < 0.2f;
	}

	public override async Task HandleEventAsync( EventType eventType )
	{
		await Task.DelayRealtime( 100 );

		await Manager.Instance.ShakeCard( this );

		await Task.DelayRealtime( 600 );
	}
}