using JetBrains.Annotations;
using Robust.Client.Graphics;
using Robust.Shared.Prototypes;
namespace Content.Client.IconSmoothing;
///
/// Makes sprites of other grid-aligned entities like us connect.
///
///
/// The system is based on Baystation12's smoothwalling, and thus will work with those.
/// To use, set base equal to the prefix of the corner states in the sprite base RSI.
/// Any objects with the same key will connect.
///
[RegisterComponent]
public sealed partial class IconSmoothComponent : Component
{
[DataField]
public bool Enabled = true;
public (EntityUid?, Vector2i)? LastPosition;
///
/// Objects with this key can smooth with us, and vice versa.
/// TODO: YAML HELL, Make smoothing one way.
///
[DataField("key", required: true)]
public string SmoothKey { get; private set; }
///
/// We will attempt to smooth with any objects that contain these keys.
/// Only works one way, objects with these keys will not smooth with us
///
[DataField]
public List AdditionalKeys = new();
///
/// Index override for our iconsmooth layers. If null, layers will appear on top.
///
[DataField]
public int? Index;
///
/// Prepended to the RSI state.
///
[DataField("base")]
public string StateBase { get; set; } = string.Empty;
[DataField]
public ProtoId? Shader;
///
/// Mode that controls how the icon should be selected.
///
[DataField]
public IconSmoothingMode Mode = IconSmoothingMode.Corners;
///
/// Used by to reduce redundant updates.
///
internal int UpdateGeneration { get; set; }
}
///
/// Controls the mode with which icon smoothing is calculated.
///
[PublicAPI]
public enum IconSmoothingMode : byte
{
///
/// Each icon is made up of 4 corners, each of which can get a different state depending on
/// adjacent entities clockwise, counter-clockwise and diagonal with the corner.
///
Corners,
///
/// There are 16 icons, only one of which is used at once.
/// The icon selected is a bit field made up of the cardinal direction flags that have adjacent entities.
///
CardinalFlags,
///
/// The icon represents a triangular sprite with only 2 states, representing South / East being occupied or not.
///
Diagonal,
///
/// Where this component contributes to our neighbors being calculated but we do not update our own sprite.
///
NoSprite,
}