2019-03-28 11:14:03 +01:00
|
|
|
using JetBrains.Annotations;
|
2023-02-12 13:15:09 +11:00
|
|
|
using Robust.Client.Graphics;
|
|
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
2018-08-09 20:22:54 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.IconSmoothing
|
2018-08-09 20:22:54 +02:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Makes sprites of other grid-aligned entities like us connect.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// The system is based on Baystation12's smoothwalling, and thus will work with those.
|
|
|
|
|
/// To use, set <c>base</c> equal to the prefix of the corner states in the sprite base RSI.
|
|
|
|
|
/// Any objects with the same <c>key</c> will connect.
|
|
|
|
|
/// </remarks>
|
2019-07-31 15:02:36 +02:00
|
|
|
[RegisterComponent]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class IconSmoothComponent : Component
|
2018-08-09 20:22:54 +02:00
|
|
|
{
|
2023-04-10 15:37:03 +10:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("enabled")]
|
|
|
|
|
public bool Enabled = true;
|
|
|
|
|
|
2022-06-20 12:14:35 +12:00
|
|
|
public (EntityUid?, Vector2i)? LastPosition;
|
2019-03-28 11:14:03 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// We will smooth with other objects with the same key.
|
|
|
|
|
/// </summary>
|
2023-01-27 15:03:42 +11:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("key")]
|
2023-08-22 18:14:33 -07:00
|
|
|
public string? SmoothKey { get; private set; }
|
2018-08-09 20:22:54 +02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Prepended to the RSI state.
|
|
|
|
|
/// </summary>
|
2023-01-27 15:03:42 +11:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("base")]
|
2023-08-22 18:14:33 -07:00
|
|
|
public string StateBase { get; private set; } = string.Empty;
|
2018-08-09 20:22:54 +02:00
|
|
|
|
2023-03-10 16:41:22 +11:00
|
|
|
[DataField("shader", customTypeSerializer:typeof(PrototypeIdSerializer<ShaderPrototype>))]
|
|
|
|
|
public string? Shader;
|
|
|
|
|
|
2018-08-09 20:22:54 +02:00
|
|
|
/// <summary>
|
2019-03-28 11:14:03 +01:00
|
|
|
/// Mode that controls how the icon should be selected.
|
2018-08-09 20:22:54 +02:00
|
|
|
/// </summary>
|
2023-01-27 15:03:42 +11:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("mode")]
|
2022-05-16 11:43:47 +10:00
|
|
|
public IconSmoothingMode Mode = IconSmoothingMode.Corners;
|
2018-08-09 20:22:54 +02:00
|
|
|
|
2019-03-28 11:14:03 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Used by <see cref="IconSmoothSystem"/> to reduce redundant updates.
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal int UpdateGeneration { get; set; }
|
|
|
|
|
}
|
2018-08-09 20:22:54 +02:00
|
|
|
|
2019-03-28 11:14:03 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Controls the mode with which icon smoothing is calculated.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[PublicAPI]
|
2020-12-04 11:57:33 +01:00
|
|
|
public enum IconSmoothingMode : byte
|
2019-03-28 11:14:03 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 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.
|
|
|
|
|
/// </summary>
|
|
|
|
|
Corners,
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 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.
|
|
|
|
|
/// </summary>
|
|
|
|
|
CardinalFlags,
|
2020-12-26 19:24:03 +11:00
|
|
|
|
2023-01-27 15:03:42 +11:00
|
|
|
/// <summary>
|
|
|
|
|
/// The icon represents a triangular sprite with only 2 states, representing South / East being occupied or not.
|
|
|
|
|
/// </summary>
|
|
|
|
|
Diagonal,
|
|
|
|
|
|
2020-12-26 19:24:03 +11:00
|
|
|
/// <summary>
|
|
|
|
|
/// Where this component contributes to our neighbors being calculated but we do not update our own sprite.
|
|
|
|
|
/// </summary>
|
|
|
|
|
NoSprite,
|
2018-08-09 20:22:54 +02:00
|
|
|
}
|
|
|
|
|
}
|