using Newtonsoft.Json;
using RhythmBase.Components;
using RhythmBase.Converters;
namespace RhythmBase.Events
{
///
/// Represents a floating text event in a room.
///
public class FloatingText : BaseEvent, IRoomEvent,IDurationEvent
{
///
/// Gets the type of the event.
///
public override EventType Type { get; } = EventType.FloatingText;
///
/// Gets the tab associated with the event.
///
public override Tabs Tab { get; } = Tabs.Actions;
///
/// Gets the list of child advance texts.
///
[JsonIgnore]
public List Children => _children;
///
/// Gets or sets the room associated with the event.
///
public RDRoom Rooms { get; set; } = new RDRoom(true, new byte[1]);
///
/// Gets or sets the fade out rate of the text.
///
public float FadeOutRate { get; set; }
float IDurationEvent.Duration => FadeOutRate;
///
/// Gets or sets the color of the text.
///
public PaletteColor Color { get; set; } = new PaletteColor(true)
{
Color = RDColor.White,
};
///
/// Gets or sets the angle of the text.
///
public float Angle { get; set; }
///
/// Gets or sets the size of the text.
///
public uint Size { get; set; }
///
/// Gets or sets the outline color of the text.
///
public PaletteColor OutlineColor { get; set; } = new PaletteColor(true)
{
Color = RDColor.Black,
};
///
/// Gets the ID of the event.
///
[JsonProperty]
internal int Id => (int)GeneratedId;
///
/// Gets or sets the position of the text.
///
public RDPoint TextPosition { get; set; } = new RDPoint(new float?(50f), new float?(50f));
///
/// Gets or sets the anchor style of the text.
///
public AnchorStyle Anchor { get; set; }
///
/// Specifies the anchor style of the text.
///
[JsonConverter(typeof(AnchorStyleConverter))]
[Flags]
public enum AnchorStyle
{
///
/// The lower anchor style.
///
Lower = 1,
///
/// The upper anchor style.
///
Upper = 2,
///
/// The left anchor style.
///
Left = 4,
///
/// The right anchor style.
///
Right = 8,
///
/// The center anchor style.
///
Center = 0
}
///
/// Gets or sets the mode of the text.
///
public OutMode Mode { get; set; } = OutMode.FadeOut;
///
/// Gets or sets a value indicating whether to show child texts.
///
public bool ShowChildren { get; set; } = false;
///
/// Gets or sets the text content.
///
public string Text { get; set; } = "等呀等得好心慌……";
///
/// Initializes a new instance of the class.
///
public FloatingText()
{
GeneratedId = _PrivateId;
_PrivateId = checked((uint)(unchecked((ulong)_PrivateId) + 1UL));
}
///
/// Returns a string that represents the current object.
///
/// A string that represents the current object.
public override string ToString() => base.ToString() + $" {Text}";
private static uint _PrivateId = 0U;
private readonly uint GeneratedId;
private readonly List _children = [];
///
/// Specifies the mode of the text.
///
[Flags]
public enum OutMode
{
///
/// The text will fade out gradually.
///
FadeOut = 0,
///
/// The text will hide abruptly.
///
HideAbruptly = 1
}
}
}