A component that controls a Decal for a miniboss zone. It tracks time since spawn and linearly fades the decal in over 1.5 seconds by setting the Decal.ColorTint alpha using Utils.Map.
using Sandbox;
public sealed class MinibossZonerDecal : Component
{
[Property] public Decal Decal { get; set; }
private TimeSince _timeSinceSpawn;
protected override void OnStart()
{
base.OnStart();
_timeSinceSpawn = 0f;
}
protected override void OnUpdate()
{
float fadeInDuration = 1.5f;
if ( _timeSinceSpawn < fadeInDuration )
{
Decal.ColorTint = new Color( 0.36f, 0.44f, 1.00f, Utils.Map( _timeSinceSpawn, 0f, fadeInDuration, 0f, 1f ) );
}
}
}