Warning.cs
using Sandbox.UI;
using SpriteTools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using static Manager;

public class Warning : Component
{
	[Property] public SpriteRendererLayer Sprite { get; set; }

	private TimeSince _spawnTime;
	public float Lifetime { get; set; }
	public Vector2 Velocity { get; set; }
	public Color ColorA { get; set; }
	public Color ColorB { get; set; }

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

		LocalRotation = new Angles( 0f, -90f, 0f );
		LocalScale = new Vector3( Game.Random.Float( 0.65f, 0.75f ), Game.Random.Float( 0.7f, 0.9f ), 1f ) * Globals.SPRITE_SCALE;
		_spawnTime = 0f;

		if ( Game.Random.Float( 0f, 1f ) < 0.5f )
			Sprite.SpriteFlags = SpriteFlags.HorizontalFlip;

		Velocity = new Vector2( 0f, 0.15f );
	}

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

		WorldPosition += (Vector3)Velocity * Time.Delta;
		Velocity *= (1f - Time.Delta * 0.5f);
		//WorldPosition = WorldPosition.WithZ( Globals.GetZPos( WorldPosition.y ) );

		var color = Color.Lerp( ColorA, ColorB, Utils.Map(0.5f + Utils.FastSin(_spawnTime * 16f) * 0.5f, 0f, 1f, 0f, 1f, EasingType.QuartOut) );
		var opacity = Utils.Map( _spawnTime, 0f, 0.2f, 0f, 1f ) * Utils.Map( _spawnTime, 0f, Lifetime - 0.03f, 1f, 0f );
		Sprite.Tint = color.WithAlpha( opacity );

		Sprite.LocalScale = (0.75f + Utils.Map( 0.5f + Utils.FastSin( _spawnTime * 16f ) * 0.5f, 0f, 1f, 0f, 1f, EasingType.QuartOut ) * 0.1f) * Globals.SPRITE_SCALE;

		if ( _spawnTime > Lifetime )
		{
			Manager.Instance.RemoveWarning( this );
			GameObject.Destroy();
		}
	}
}