using Newtonsoft.Json;
using RhythmBase.Components;
namespace RhythmBase.Events
{
///
/// Represents the base class for decoration actions in the rhythm base.
///
public abstract class BaseDecorationAction : BaseEvent, IBaseEvent
{
///
/// Gets the parent decoration event collection.
///
[JsonIgnore]
public DecorationEventCollection? Parent => _parent;
///
/// Gets or sets the Y coordinate.
///
[JsonIgnore]
public override int Y { get => base.Y; set => base.Y = value; }
///
/// Gets the target identifier.
///
public virtual string Target => Parent?.Id ?? "";
///
/// Gets or sets the beat associated with this action.
///
///
[JsonIgnore]
public override RDBeat Beat
{
get => _beat;
set => _beat = _beat.BaseLevel == null ?
value.BaseLevel == null ?
value :
value.WithoutBinding() :
new(_beat.BaseLevel.Calculator, value);
}
///
/// Clones this event and its basic properties. The clone will be added to the level.
///
/// The type of event that will be generated.
/// A new instance of .
public new TEvent Clone() where TEvent : BaseDecorationAction, new()
{
TEvent Temp = base.Clone();
Temp._parent = Parent;
return Temp;
}
///
/// Clones this event and its basic properties, associating it with a specific decoration event collection.
///
/// The type of event that will be generated.
/// The decoration event collection to associate with the clone.
/// A new instance of .
internal TEvent Clone(DecorationEventCollection decoration) where TEvent : BaseDecorationAction, new()
{
TEvent Temp = base.Clone(decoration.Parent ?? throw new RhythmBase.Exceptions.RhythmBaseException());
Temp._parent = decoration;
return Temp;
}
///
/// Gets the room associated with this action.
///
[JsonIgnore]
public RDSingleRoom Room => Parent?.Room ?? RDSingleRoom.Default;
///
/// The parent decoration event collection.
///
internal DecorationEventCollection? _parent;
}
}