Story/Chapters/0/IntroCinematicComponent.cs
using Opium;
using Sandbox;
using Sandbox.UI;
using System.Threading;

public sealed class IntroCinematicComponent : Component
{
	[Property] public GameObject Player { get; set; }
	[Property] public SoundEvent StartSound { get; set; }

	SoundHandle soundHandle;

	CancellationTokenSource token = new CancellationTokenSource(); 

	protected override void OnEnabled()
	{
		HandleSubtitles( token );

		if ( StartSound is not null )
		{
			soundHandle = Sound.Play( StartSound );
		}

		// Mark the start time for leaderboards
		LeaderboardSystem.MarkStartTime();
	}

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

		if ( Input.Pressed( "Jump" ) )
		{
			token.Cancel();
			End();
		}
	}

	public void CreatePlayer()
	{
		var player = Player.Clone();
		player.Transform.Position = Transform.Position;
		player.Transform.Rotation = Transform.Rotation;
	}

	async Task Delay( float time, CancellationTokenSource token )
	{
		await GameTask.DelaySeconds( time );
	}

	public async void HandleSubtitles( CancellationTokenSource token )
	{
		await Delay( 1f, token );
		if ( token.IsCancellationRequested ) return;
		SubtitleSystem.AddSubtitle( "CRACKHEAD #3", "No, no!", 2 );

		await Delay( 1f, token );
		if ( token.IsCancellationRequested ) return;

		SubtitleSystem.AddSubtitle( "CRACKHEAD #3", "Fuck sake, he's got the bag!", 2 );

		await Delay( 2f, token );
		if ( token.IsCancellationRequested ) return;

		SubtitleSystem.AddSubtitle( "CRACKHEAD #1", "Fucking GET HIM!", 1.5F );

		await Delay( 1.2f, token );
		if ( token.IsCancellationRequested ) return;
		SubtitleSystem.AddSubtitle( "CRACKHEAD #3", "Hey cunt, we have your fucking name!", 4 );

		await Delay( 4f, token );
		if ( token.IsCancellationRequested ) return;
		SubtitleSystem.AddSubtitle( "CRACKHEAD #1", "Chase him, get him, get him!", 4 );

		await Delay( 2f, token );
		if ( token.IsCancellationRequested ) return;
		SubtitleSystem.AddSubtitle( "CRACKHEAD #2", "You have no fucking idea who you're messing with..", 3 );

		await Delay( 3f, token );
		if ( token.IsCancellationRequested ) return;
		SubtitleSystem.AddSubtitle( "CRACKHEAD #1", "Who-whoa whoa, whoa whoa!", 3 );

		await Delay( 3f, token );
		if ( token.IsCancellationRequested ) return;
		SubtitleSystem.AddSubtitle( "CRACKHEAD #3", "You stupid fuck!", 2 );

		await Delay( 2f, token );
		if ( token.IsCancellationRequested ) return;

		End();
	}

	void End()
	{
		soundHandle?.Stop( 0.5f );
		GameObject.Destroy();
		CreatePlayer();
	}
}