UI/PumpArt.razor
@using System
@using Sandbox
@using Sandbox.UI
@namespace DesertPump
@inherits Panel

<root class="pumpart @( Silhouette ? "silhouette" : "" )">

	@if ( Artwork is not null )
	{
		<Image Texture="@Artwork" class="photo"></Image>
	}
	else
	{
		<div class="drawing" style="background-image: url( '@ArtPath' );"></div>
	}

</root>

@code
{
	/// <summary>Index into <see cref="PumpModel.All"/>.</summary>
	public int TierIndex { get; set; }

	/// <summary>Draw it as a black cut-out, the way locked pumps show in the collection.</summary>
	public bool Silhouette { get; set; }

	/// <summary>Overrides the drawn artwork entirely, if you'd rather use your own.</summary>
	public Texture Artwork { get; set; }

	PumpModel Pump => PumpModel.Get( TierIndex );

	/// <summary>
	/// One illustration per pump - all 108 of them, and no two the same machine. The
	/// tier owns the palette and what the thing stands on; everything else about a pump
	/// is drawn for the name it carries. See tools/make_pumps.py.
	/// </summary>
	string ArtPath => $"/ui/pumps/pump_{Pump.Index + 1:000}.svg";

	// There used to be a 0.92-1.0 scale ramp by rank here, from back when the nine
	// pumps in a tier were one drawing and the ramp was doing the work of selling a
	// purchase. Every drawing includes the ground it stands on, so scaling the image
	// scaled the ground with it and the desert changed size when you bought a pump.
	// The drawings differ on their own now, so the ramp is gone and the horizon holds.

	protected override int BuildHash() => HashCode.Combine( TierIndex, Silhouette, Artwork );
}