using Newtonsoft.Json; using RhythmBase.Components; namespace RhythmBase.Events { /// /// Represents a base action for a row event. /// public abstract class BaseRowAction : BaseEvent { /// /// Gets or sets the parent row event collection. /// [JsonIgnore] public RowEventCollection? Parent { get => _parent; internal set { if (_parent != null) { _parent.Remove(this); value?.Add(this); } _parent = value; } } /// /// Gets the room associated with this action. /// [JsonIgnore] public RDSingleRoom Room => _parent?.Rooms ?? RDSingleRoom.Default; /// /// /// 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); } } /// /// Gets the row index. This function is obsolete and may be removed in the next release. Use Index instead. /// [JsonIgnore] [Obsolete("This function is obsolete and may be removed in the next release. Use Index instead.")] public int Row { get; } /// /// Gets the index of the row in the parent collection. /// [JsonProperty("row", DefaultValueHandling = DefaultValueHandling.Include)] public int Index => Parent?.Index ?? -1; /// /// Clones this event and its basic properties. Clone will be added to the level. /// /// Type that will be generated. /// A new instance of . public new TEvent Clone() where TEvent : BaseRowAction, new() { TEvent Temp = base.Clone(); Temp.Parent = Parent; return Temp; } /// /// Clones this event and assigns it to a specified row event collection. /// /// Type that will be generated. /// The row event collection to assign the clone to. /// A new instance of . internal TEvent Clone(RowEventCollection row) where TEvent : BaseRowAction, new() { TEvent Temp = base.Clone(row.Parent ?? throw new RhythmBase.Exceptions.RhythmBaseException()); Temp.Parent = row; return Temp; } internal RowEventCollection? _parent; } }