diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index f49b01c..fea7d43 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -20,9 +20,11 @@ namespace RDTKEditor /// public partial class MainWindow : Window { - private Assistant Assistant = new(Assistant.Qwen_3); - private SKSizeI _vsScale = new(1600,900); + private readonly Assistant Assistant = new(Assistant.Qwen_3); + private SKSizeI _vsScale = new(1600, 900); private readonly RDTKView viewModel = new(); + private readonly List _selectedEvents = []; + internal readonly Dictionary _eventPanel = []; public MainWindow() { InitializeComponent(); @@ -80,7 +82,17 @@ namespace RDTKEditor } private void About(object sender, RoutedEventArgs e) { - OnUpdateEventProperties(GetProperties(new MoveRow())); + if (_selectedEvents.Count == 0) + { + MessageBox.Show("请先选择一个事件。", "提示", MessageBoxButton.OK, MessageBoxImage.Information); + return; + } + if (_selectedEvents.Count == 1) + { + OnUpdateEventProperties(_selectedEvents[0], GetProperties(_selectedEvents[0])); + } + else + { } private RDTKProperty[] GetProperties(BaseEvent e) @@ -137,30 +149,33 @@ namespace RDTKEditor internal void OnUpdateEventProperties(RDTKProperty[] properties) { ItemProperties.Items.Clear(); + StackPanel[] panel = new StackPanel[properties.Length]; + if (_eventPanel.ContainsKey(baseEvent.GetType())) + { + + } + else + { foreach (var property in properties) { - StackPanel stackPanel; - switch (property.Type) + StackPanel stackPanel = property.Type switch { - case RDPropertyType.Bool: - stackPanel = new() - { - Orientation = Orientation.Horizontal, - FlowDirection = FlowDirection.LeftToRight, - Children = + RDPropertyType.Bool => new() + { + Orientation = Orientation.Horizontal, + FlowDirection = FlowDirection.LeftToRight, + Children = { new Label(){Content = property.Name}, new CheckBox() { IsChecked = bool.Parse( property.Value), } }, - }; - break; - case RDPropertyType.Enum: - stackPanel = new() - { - AllowDrop = true, - Orientation = Orientation.Horizontal, - FlowDirection = FlowDirection.LeftToRight, - Children = + }, + RDPropertyType.Enum => new() + { + AllowDrop = true, + Orientation = Orientation.Horizontal, + FlowDirection = FlowDirection.LeftToRight, + Children = { new Label(){Content = property.Name}, new ComboBox() @@ -169,33 +184,28 @@ namespace RDTKEditor SelectedValue = property.Value, } }, - }; - break; - case RDPropertyType.String: - stackPanel = new() - { - AllowDrop = true, - Orientation = Orientation.Horizontal, - FlowDirection = FlowDirection.LeftToRight, - Children = + }, + RDPropertyType.String => new() + { + AllowDrop = true, + Orientation = Orientation.Horizontal, + FlowDirection = FlowDirection.LeftToRight, + Children = { new Label(){Content = property.Name}, new TextBox() { Text = property.Value, } }, - }; - break; - default: - stackPanel = new() - { - Orientation = Orientation.Horizontal, - Children = + }, + _ => new() + { + Orientation = Orientation.Horizontal, + Children = { new Label(){Content = property.Name}, new Label(){Content = property.Value} } - }; - break; - } + }, + }; foreach (var child in stackPanel.Children) { switch (child) @@ -229,10 +239,43 @@ namespace RDTKEditor ItemProperties.Items.Add(stackPanel); property.PropertyChanged += (e, s) => UpdateEvent(); } + + } } private void UpdateEvent() { - MessageBox.Show("Update Event"); + if (_selectedEvents.Count == 0) + return; + else if (_selectedEvents.Count == 1){ + var e = _selectedEvents[0]; + foreach (var property in ItemProperties.Items) + { + if (property is StackPanel stackPanel) + { + foreach (var child in stackPanel.Children) + { + switch (child) + { + case CheckBox checkBox: + e.GetType().GetProperty(stackPanel.Name)?.SetValue(e, checkBox.IsChecked); + break; + case TextBox textBox: + e.GetType().GetProperty(stackPanel.Name)?.SetValue(e, textBox.Text); + break; + case ComboBox comboBox: + e.GetType().GetProperty(stackPanel.Name)?.SetValue(e, comboBox.SelectedValue); + break; + default: + break; + } + } + } + } + } + else + { + } + } private void UpdateTimeLine() { diff --git a/RDTKEditor.csproj b/RDTKEditor.csproj index 8a08df3..f76e346 100644 --- a/RDTKEditor.csproj +++ b/RDTKEditor.csproj @@ -10,9 +10,10 @@ - - - + + + + diff --git a/RhythmBaseCore/Adofai/Components/ADBeat.cs b/RhythmBaseCore/Adofai/Components/ADBeat.cs deleted file mode 100644 index 1e7dffc..0000000 --- a/RhythmBaseCore/Adofai/Components/ADBeat.cs +++ /dev/null @@ -1,269 +0,0 @@ -using RhythmBase.Adofai.Utils; -using RhythmBase.Exceptions; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Adofai.Components -{ - /// - /// Represents a beat in the ADLevel. - /// - public struct ADBeat : IComparable, IEquatable - { - internal readonly ADLevel? baseLevel => _calculator?.Collection; - - /// - /// Gets or sets the beat only value. - /// - public readonly float BeatOnly - { - get => _beat + 1f; - - set - { - } - } - - /// - /// Gets or sets the time span. - /// - public readonly TimeSpan TimeSpan - { - get => _timeSpan; - - set - { - } - } - - /// - /// Initializes a new instance of the struct with a specified beat. - /// - /// The beat value. - public ADBeat(float beat) - { - this = default; - _beat = beat; - _isBeatLoaded = true; - } - - /// - /// Initializes a new instance of the struct with a specified time span. - /// - /// The time span value. - public ADBeat(TimeSpan timeSpan) - { - this = default; - _timeSpan = timeSpan; - _isTimeSpanLoaded = true; - } - - /// - /// Initializes a new instance of the struct with a specified calculator and beat. - /// - /// The beat calculator. - /// The beat value. - public ADBeat(ADBeatCalculator calculator, float beat) - { - this = default; - _calculator = calculator; - _beat = beat; - _isBeatLoaded = true; - } - - /// - /// Initializes a new instance of the struct with a specified calculator and time span. - /// - /// The beat calculator. - /// The time span value. - /// Thrown when the time span is less than zero. - public ADBeat(ADBeatCalculator calculator, TimeSpan timeSpan) - { - this = default; - if (timeSpan < TimeSpan.Zero) - { - throw new OverflowException(string.Format("The time must not be less than zero, but {0} is given", timeSpan)); - } - _calculator = calculator; - _timeSpan = timeSpan; - _isTimeSpanLoaded = true; - } - /// - /// Construct a beat of the 1st beat from the calculator - /// - /// Specified calculator. - /// The first beat tied to the level. - public static ADBeat Default(ADBeatCalculator calculator) - { - ADBeat Default = new(calculator, 1f); - return Default; - } - /// - /// Determine if two beats come from the same level - /// - /// A beat. - /// Another beat. - /// If true, an exception will be thrown when two beats do not come from the same level. - /// - public static bool FromSameLevel(ADBeat a, ADBeat b, bool @throw = false) - { - bool flag = a.baseLevel.Equals(b.baseLevel); - bool FromSameLevel; - if (flag) - { - FromSameLevel = true; - } - else - { - if (@throw) - { - throw new RhythmBaseException("Beats must come from the same ADLevel."); - } - FromSameLevel = false; - } - return FromSameLevel; - } - /// - /// Determine if two beats are from the same level. - ///
- /// If any of them does not come from any level, it will also return true. - ///
- /// A beat. - /// Another beat. - /// If true, an exception will be thrown when two beats do not come from the same level. - /// - public static bool FromSameLevelOrNull(ADBeat a, ADBeat b, bool @throw = false) => a.baseLevel == null || b.baseLevel == null || FromSameLevel(a, b, @throw); - - public readonly bool FromSameLevel(ADBeat b, bool @throw = false) => FromSameLevel(this, b, @throw); - /// - /// Determine if two beats are from the same level. - ///
- /// If any of them does not come from any level, it will also return true. - ///
- /// Another beat. - /// If true, an exception will be thrown when two beats do not come from the same level. - /// - public readonly bool FromSameLevelOrNull(ADBeat b, bool @throw = false) => baseLevel == null || b.baseLevel == null || FromSameLevel(b, @throw); - /// - /// Returns a new instance of unbinding the level. - /// - /// A new instance of unbinding the level. - public readonly ADBeat WithoutBinding() - { - ADBeat result = this; - result._calculator = null; - return result; - } - - private readonly void IfNullThrowException() - { - if (IsEmpty) - { - throw new InvalidRDBeatException(); - } - } - /// - /// Refresh the cache. - /// - public void ResetCache() - { - float i = BeatOnly; - _isTimeSpanLoaded = false; - } - - internal void ResetBPM() - { - _isBeatLoaded = true; - _isTimeSpanLoaded = false; - _isBpmLoaded = false; - } - - internal void ResetCPB() => _isBeatLoaded = true; - - /// - /// Gets a value indicating whether this instance is empty. - /// - /// - /// true if this instance is empty; otherwise, false. - /// - public readonly bool IsEmpty - { - get - { - return _calculator == null || (!_isBeatLoaded && !_isTimeSpanLoaded); - } - } - - /// - public static ADBeat operator +(ADBeat a, float b) - { - ADBeat result = new(a._calculator, a.BeatOnly + b); - return result; - } - - /// - public static ADBeat operator +(ADBeat a, TimeSpan b) - { - ADBeat result = new(a._calculator, a.TimeSpan + b); - return result; - } - - /// - public static ADBeat operator -(ADBeat a, float b) - { - ADBeat result = new(a._calculator, a.BeatOnly - b); - return result; - } - - /// - public static ADBeat operator -(ADBeat a, TimeSpan b) - { - ADBeat result = new(a._calculator, a.TimeSpan - b); - return result; - } - /// - public static bool operator >(ADBeat a, ADBeat b) => FromSameLevel(a, b, true) && a.BeatOnly > b.BeatOnly; - /// - - public static bool operator <(ADBeat a, ADBeat b) => FromSameLevel(a, b, true) && a.BeatOnly < b.BeatOnly; - /// - - public static bool operator >=(ADBeat a, ADBeat b) => FromSameLevel(a, b, true) && a.BeatOnly >= b.BeatOnly; - /// - - public static bool operator <=(ADBeat a, ADBeat b) => FromSameLevel(a, b, true) && a.BeatOnly <= b.BeatOnly; - - /// - public static bool operator ==(ADBeat a, ADBeat b) => (FromSameLevel(a, b, true) && a._beat == b._beat) || (a._isTimeSpanLoaded && b._isTimeSpanLoaded && a._timeSpan == b._timeSpan) || a.BeatOnly == b.BeatOnly; - - /// - public static bool operator !=(ADBeat a, ADBeat b) => !(a == b); - - /// - public readonly int CompareTo(ADBeat other) => checked((int)Math.Round((double)unchecked(_beat - other._beat))); - - /// - public override readonly string ToString() => string.Format("[{0}]", BeatOnly); - - /// - public override readonly bool Equals([NotNull] object obj) => obj.GetType() == typeof(ADBeat) && Equals((obj != null) ? ((ADBeat)obj) : default); - - /// - public readonly bool Equals(ADBeat other) => this == other; - - /// - public override readonly int GetHashCode() => HashCode.Combine(BeatOnly, baseLevel); - - internal ADBeatCalculator? _calculator; - - private bool _isBeatLoaded; - - private bool _isTimeSpanLoaded; - - private bool _isBpmLoaded; - - private float _beat; - - private TimeSpan _timeSpan; - - private float _bpm; - } -} diff --git a/RhythmBaseCore/Adofai/Components/ADLevel.cs b/RhythmBaseCore/Adofai/Components/ADLevel.cs deleted file mode 100644 index 1d5d78a..0000000 --- a/RhythmBaseCore/Adofai/Components/ADLevel.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Microsoft.VisualBasic.CompilerServices; -using Newtonsoft.Json; -using RhythmBase.Adofai.Converters; -using RhythmBase.Adofai.Events; -using RhythmBase.Adofai.Utils; -using RhythmBase.Exceptions; -using RhythmBase.Settings; -namespace RhythmBase.Adofai.Components -{ - /// - /// Adofal level. - /// - public class ADLevel : ADTileCollection - { - /// - /// Level settings. - /// - public ADSettings Settings { get; set; } - /// - /// Level decoration collection. - /// - public List Decorations { get; set; } - /// - /// Level file path. - /// - [JsonIgnore] - public string Path => _path; - /// - /// Level directory path. - /// - [JsonIgnore] - public string Directory => System.IO.Path.GetDirectoryName(_path); - /// - /// Get all the events of the level. - /// - public override IEnumerable Events - { - get - { - foreach (ADBaseEvent tile in base.Events) - yield return tile; - foreach (ADBaseEvent tile2 in Decorations) - yield return tile2; - } - } - /// - /// The calculator that comes with the level. - /// - [JsonIgnore] - public ADBeatCalculator Calculator { get; } - public ADLevel() - { - Settings = new ADSettings(); - Decorations = []; - Calculator = new ADBeatCalculator(this); - } - public ADLevel(IEnumerable items) - { - Settings = new ADSettings(); - Decorations = []; - Calculator = new ADBeatCalculator(this); - foreach (ADTile tile in items) - Add(tile); - } - /// - /// The default level within the game. - /// - public static ADLevel Default => []; - /// - /// Read from file as level. - /// Use default input settings. - /// Supports .rdlevel, .rdzip, .zip file extension. - /// - /// File path. - /// An instance of a level that reads from a file. - public static ADLevel Read(string filepath) => Read(filepath, new LevelReadOrWriteSettings()); - /// - /// Read from file as level. - /// Supports .rdlevel, .rdzip, .zip file extension. - /// - /// File path. - /// Input settings. - /// An instance of a level that reads from a file. - public static ADLevel Read(string filepath, LevelReadOrWriteSettings settings) - { - JsonSerializer LevelSerializer = new(); - LevelSerializer.Converters.Add(new ADLevelConverter(filepath, settings)); - string extension = System.IO.Path.GetExtension(filepath); - if (extension != ".adofai") - { - throw new RhythmBaseException("File not supported."); - } - return LevelSerializer.Deserialize(new JsonTextReader(File.OpenText(filepath)))!; - } - internal string _path; - } -} diff --git a/RhythmBaseCore/Adofai/Components/ADSettings.cs b/RhythmBaseCore/Adofai/Components/ADSettings.cs deleted file mode 100644 index 057ff0b..0000000 --- a/RhythmBaseCore/Adofai/Components/ADSettings.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Collections.Generic; -using RhythmBase.Adofai.Events; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Adofai.Components -{ - public class ADSettings - { - public ADSettings() - { - RequiredMods = []; - } - - public int Version { get; set; } - - public string Artist { get; set; } - - public SpecialArtistTypes SpecialArtistType { get; set; } - - public string ArtistPermission { get; set; } - - public string Song { get; set; } - - public string Author { get; set; } - - public bool SeparateCountdownTime { get; set; } - - public string PreviewImage { get; set; } - - public string PreviewIcon { get; set; } - - public RDColor PreviewIconColor { get; set; } - - public float PreviewSongStart { get; set; } - - public float PreviewSongDuration { get; set; } - - public bool SeizureWarning { get; set; } - - public string LevelDesc { get; set; } - - public string LevelTags { get; set; } - - public string ArtistLinks { get; set; } - - public int Difficulty { get; set; } - - public List RequiredMods { get; set; } - - public string SongFilename { get; set; } - - public float Bpm { get; set; } - - public float Volume { get; set; } - - public float Offset { get; set; } - - public float Pitch { get; set; } - - public string Hitsound { get; set; } - - public float HitsoundVolume { get; set; } - - public float CountdownTicks { get; set; } - - public ADTrackColorTypes TrackColorType { get; set; } - - public RDColor TrackColor { get; set; } - - public RDColor SecondaryTrackColor { get; set; } - - public float TrackColorAnimDuration { get; set; } - - public ADTrackColorPulses TrackColorPulse { get; set; } - - public float TrackPulseLength { get; set; } - - public ADTrackStyles TrackStyle { get; set; } - - public ADTrackAnimationTypes TrackAnimation { get; set; } - - public int BeatsAhead { get; set; } - - public ADTrackDisappearAnimationTypes TrackDisappearAnimation { get; set; } - - public int BeatsBehind { get; set; } - - public RDColor BackgroundColor { get; set; } - - public bool ShowDefaultBGIfNoImage { get; set; } - - public string BgImage { get; set; } - - public RDColor BgImageColor { get; set; } - - public RDPointI Parallax { get; set; } - - public BgDisplayModes BgDisplayMode { get; set; } - - public bool LockRot { get; set; } - - public bool LoopBG { get; set; } - - public float ScalingRatio { get; set; } - - public ADCameraRelativeTo RelativeTo { get; set; } - - public RDPointI Position { get; set; } - - public float Rotation { get; set; } - - public float Zoom { get; set; } - - public string BgVideo { get; set; } - - public bool LoopVideo { get; set; } - - public int VidOffset { get; set; } - - public bool FloorIconOutlines { get; set; } - - public bool StickToFloors { get; set; } - - public EaseType PlanetEase { get; set; } - - public int PlanetEaseParts { get; set; } - - public ADEasePartBehaviors PlanetEasePartBehavior { get; set; } - - public RDColor DefaultTextColor { get; set; } - - public RDColor DefaultTextShadowColor { get; set; } - - public string CongratsText { get; set; } - - public string PerfectText { get; set; } - - public bool LegacyFlash { get; set; } - - public bool LegacyCamRelativeTo { get; set; } - - public bool LegacySpriteTiles { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Components/ADTileCollection.cs b/RhythmBaseCore/Adofai/Components/ADTileCollection.cs deleted file mode 100644 index 5aefbec..0000000 --- a/RhythmBaseCore/Adofai/Components/ADTileCollection.cs +++ /dev/null @@ -1,43 +0,0 @@ -using RhythmBase.Adofai.Events; -using System.Collections; -namespace RhythmBase.Adofai.Components -{ - public abstract class ADTileCollection : ICollection - { - protected ADTileCollection() - { - tileOrder = []; - IsReadOnly = false; - EndTile = []; - } - public int Count => tileOrder.Count; - public bool IsReadOnly { get; } - public ADTile EndTile { get; } - public ADTile this[int index] => index == tileOrder.Count ? EndTile : tileOrder[index]; - public virtual IEnumerable Events - { - get - { - foreach (ADTile tile in tileOrder) - foreach (ADBaseTileEvent action in tile) - yield return action; - foreach (ADBaseTileEvent action2 in EndTile) - yield return action2; - } - } - public void Add(ADTile item) => tileOrder.Add(item); - public void Clear() => tileOrder.Clear(); - public void CopyTo(ADTile[] array, int arrayIndex) => tileOrder.CopyTo(array, arrayIndex); - public bool Contains(ADTile item) => tileOrder.Contains(item); - public bool Remove(ADTile item) => tileOrder.Remove(item); - public IEnumerator GetEnumerator() => tileOrder.GetEnumerator(); - /// - /// Get the index of tile. - /// - /// The index of tile. - /// - public int IndexOf(ADTile item) => item == EndTile ? Count : tileOrder.IndexOf(item); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - internal List tileOrder; - } -} diff --git a/RhythmBaseCore/Adofai/Components/ADTrackAnimationTypes.cs b/RhythmBaseCore/Adofai/Components/ADTrackAnimationTypes.cs deleted file mode 100644 index 6f20529..0000000 --- a/RhythmBaseCore/Adofai/Components/ADTrackAnimationTypes.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Components -{ - public enum ADTrackAnimationTypes - { - None, - Assemble, - Assemble_Far, - Extend, - Grow, - Grow_Spin, - Fade, - Drop, - Rise - } -} diff --git a/RhythmBaseCore/Adofai/Components/ADTrackDisappearAnimationTypes.cs b/RhythmBaseCore/Adofai/Components/ADTrackDisappearAnimationTypes.cs deleted file mode 100644 index b49db41..0000000 --- a/RhythmBaseCore/Adofai/Components/ADTrackDisappearAnimationTypes.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Components -{ - public enum ADTrackDisappearAnimationTypes - { - None, - Scatter, - Scatter_Far, - Retract, - Shrink, - Shrink_Spin, - Fade - } -} diff --git a/RhythmBaseCore/Adofai/Components/ADTypedList.cs b/RhythmBaseCore/Adofai/Components/ADTypedList.cs deleted file mode 100644 index 5e497c6..0000000 --- a/RhythmBaseCore/Adofai/Components/ADTypedList.cs +++ /dev/null @@ -1,28 +0,0 @@ -using RhythmBase.Adofai.Events; -using System.Collections; -namespace RhythmBase.Adofai.Components -{ - public class ADTypedList : IEnumerable where TEvent : ADBaseEvent - { - public ADTypedList() - { - list = []; - _types = []; - } - public void Add(TEvent item) - { - list.Add(item); - _types.Add(item.Type); - } - public object Remove(TEvent item) - { - _types.Remove(item.Type); - return list.Remove(item); - } - public override string ToString() => string.Format("Count = {0}", list.Count); - public IEnumerator GetEnumerator() => list.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => list.GetEnumerator(); - private readonly List list; - protected internal HashSet _types; - } -} diff --git a/RhythmBaseCore/Adofai/Components/BgDisplayModes.cs b/RhythmBaseCore/Adofai/Components/BgDisplayModes.cs deleted file mode 100644 index 408ddaa..0000000 --- a/RhythmBaseCore/Adofai/Components/BgDisplayModes.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Components -{ - public enum BgDisplayModes - { - FitToScreen, - Unscaled, - Tiled - } -} diff --git a/RhythmBaseCore/Adofai/Converters/ADBaseEventConverter.cs b/RhythmBaseCore/Adofai/Converters/ADBaseEventConverter.cs deleted file mode 100644 index 38b093f..0000000 --- a/RhythmBaseCore/Adofai/Converters/ADBaseEventConverter.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using Microsoft.VisualBasic.CompilerServices; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Adofai.Components; -using RhythmBase.Adofai.Events; -using RhythmBase.Adofai.Utils; -using RhythmBase.Settings; -namespace RhythmBase.Adofai.Converters -{ - internal class ADBaseEventConverter(ADLevel level, LevelReadOrWriteSettings inputSettings) : JsonConverter where TEvent : ADBaseEvent - { - public override bool CanRead - { - get - { - return _canread; - } - } - - public override bool CanWrite - { - get - { - return _canwrite; - } - } - public override void WriteJson(JsonWriter writer, TEvent? value, JsonSerializer serializer) => throw new NotImplementedException(); - - public override TEvent ReadJson(JsonReader reader, Type objectType, TEvent? existingValue, bool hasExistingValue, JsonSerializer serializer) => GetDeserializedObject((JObject)JToken.ReadFrom(reader), objectType, existingValue, hasExistingValue, serializer); - - public virtual TEvent GetDeserializedObject(JObject jobj, Type objectType, TEvent existingValue, bool hasExistingValue, JsonSerializer serializer) - { - Type SubClassType = Utils.Utils.ADConvertToType(jobj["eventType"].ToObject()); - _canread = false; - existingValue = Conversions.ToGenericParameter((SubClassType != null) ? jobj.ToObject(SubClassType, serializer) : jobj.ToObject(serializer)); - _canread = true; - return existingValue; - } - - public virtual JObject SetSerializedObject(TEvent value, JsonSerializer serializer) - { - _canwrite = false; - JObject JObj = JObject.FromObject(value, serializer); - _canwrite = true; - JObj.Remove("type"); - JToken s = JObj.First; - s.AddBeforeSelf(new JProperty("eventType", value.Type.ToString())); - return JObj; - } - - protected readonly ADLevel level = level; - - protected readonly LevelReadOrWriteSettings settings = inputSettings; - - protected bool _canread = true; - - protected bool _canwrite = true; - } -} diff --git a/RhythmBaseCore/Adofai/Converters/ADBaseTileEventConverter.cs b/RhythmBaseCore/Adofai/Converters/ADBaseTileEventConverter.cs deleted file mode 100644 index 859efb2..0000000 --- a/RhythmBaseCore/Adofai/Converters/ADBaseTileEventConverter.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Adofai.Components; -using RhythmBase.Adofai.Events; -using RhythmBase.Adofai.Utils; -using RhythmBase.Settings; -namespace RhythmBase.Adofai.Converters -{ - internal class ADBaseTileEventConverter(ADLevel level, LevelReadOrWriteSettings inputSettings) : ADBaseEventConverter(level, inputSettings) where TEvent : ADBaseTileEvent - { - public override TEvent GetDeserializedObject(JObject jobj, Type objectType, TEvent existingValue, bool hasExistingValue, JsonSerializer serializer) - { - JToken jtoken = jobj["floor"]; - int? parentIndex = (jtoken != null) ? new int?(jtoken.ToObject()) : null; - _canread = false; - if (Utils.Utils.ADConvertToType(jobj["eventType"].ToObject()) == typeof(ADCustomEvent)) - { - existingValue = (TEvent)(object)new ADCustomTileEventConverter(level, settings).GetDeserializedObject(jobj, objectType, null, hasExistingValue, serializer); - } - else - { - jobj.Remove("floor"); - existingValue = base.GetDeserializedObject(jobj, objectType, existingValue, hasExistingValue, serializer); - } - _canread = true; - if (parentIndex != null) - { - existingValue.Parent = level[parentIndex.Value]; - existingValue.Parent.Add((ADBaseTileEvent)(object)existingValue); - } - return existingValue; - } - public override JObject SetSerializedObject(TEvent value, JsonSerializer serializer) - { - JObject jobj = base.SetSerializedObject(value, serializer); - JToken s = jobj.First; - s.AddBeforeSelf(new JProperty("floor", level.tileOrder.IndexOf(value.Parent))); - return jobj; - } - } -} diff --git a/RhythmBaseCore/Adofai/Converters/ADCustomEventConverter.cs b/RhythmBaseCore/Adofai/Converters/ADCustomEventConverter.cs deleted file mode 100644 index d998d91..0000000 --- a/RhythmBaseCore/Adofai/Converters/ADCustomEventConverter.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Adofai.Components; -using RhythmBase.Adofai.Events; -using RhythmBase.Settings; -namespace RhythmBase.Adofai.Converters -{ - internal class ADCustomEventConverter(ADLevel level, LevelReadOrWriteSettings settings) : ADBaseEventConverter(level, settings) - { - public override ADCustomEvent GetDeserializedObject(JObject jobj, Type objectType, ADCustomEvent existingValue, bool hasExistingValue, JsonSerializer serializer) => new() - { - Data = jobj - }; - } -} diff --git a/RhythmBaseCore/Adofai/Converters/ADCustomTileEventConverter.cs b/RhythmBaseCore/Adofai/Converters/ADCustomTileEventConverter.cs deleted file mode 100644 index 0601803..0000000 --- a/RhythmBaseCore/Adofai/Converters/ADCustomTileEventConverter.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Adofai.Components; -using RhythmBase.Adofai.Events; -using RhythmBase.Settings; -namespace RhythmBase.Adofai.Converters -{ - internal class ADCustomTileEventConverter(ADLevel level, LevelReadOrWriteSettings settings) : ADBaseTileEventConverter(level, settings) - { - public override ADCustomTileEvent GetDeserializedObject(JObject jobj, Type objectType, ADCustomTileEvent existingValue, bool hasExistingValue, JsonSerializer serializer) => new() - { - Parent = level[jobj["floor"].ToObject()], - Data = jobj - }; - } -} diff --git a/RhythmBaseCore/Adofai/Converters/ADLevelConverter.cs b/RhythmBaseCore/Adofai/Converters/ADLevelConverter.cs deleted file mode 100644 index 6c5b689..0000000 --- a/RhythmBaseCore/Adofai/Converters/ADLevelConverter.cs +++ /dev/null @@ -1,87 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Serialization; -using RhythmBase.Adofai.Components; -using RhythmBase.Adofai.Events; -using RhythmBase.Adofai.Utils; -using RhythmBase.Extensions; -using RhythmBase.Converters; -using RhythmBase.Settings; -namespace RhythmBase.Adofai.Converters -{ - internal class ADLevelConverter(string location, LevelReadOrWriteSettings settings) : JsonConverter - { - public override void WriteJson(JsonWriter writer, ADLevel? value, JsonSerializer serializer) - { - JsonSerializerSettings AllInOneSerializer = new() - { - ContractResolver = new CamelCasePropertyNamesContractResolver(), - Formatting = Formatting.None - }; - IList converters = AllInOneSerializer.Converters; - converters.Add(new StringEnumConverter()); - converters.Add(new ColorConverter()); - writer.Formatting = settings.Indented ? Formatting.Indented : Formatting.None; - writer.WriteStartObject(); - writer.WritePropertyName("angleData"); - writer.WriteStartArray(); - foreach (ADTile item in value!) - writer.WriteRawValue(JsonConvert.SerializeObject(item.Angle, Formatting.None)); - writer.WriteEndArray(); - writer.WritePropertyName("settings"); - writer.WriteRawValue(JsonConvert.SerializeObject(value.Settings, Formatting.Indented, AllInOneSerializer)); - writer.WritePropertyName("actions"); - writer.WriteStartArray(); - foreach (ADTile item2 in value) - writer.WriteRawValue(JsonConvert.SerializeObject(item2, Formatting.None, AllInOneSerializer)); - writer.WriteEndArray(); - writer.WritePropertyName("decorations"); - writer.WriteStartArray(); - foreach (ADBaseEvent item3 in value.Decorations) - writer.WriteRawValue(JsonConvert.SerializeObject(item3, Formatting.None, AllInOneSerializer)); - writer.WriteEndArray(); - writer.WriteEndObject(); - writer.Close(); - } - public override ADLevel ReadJson(JsonReader reader, Type objectType, ADLevel? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - ADLevel outLevel = new() - { - _path = fileLocation - }; - JsonSerializer AllInOneSerializer = outLevel.GetSerializer(settings); - JArray JActions = []; - JArray JDecorations = []; - while (reader.Read()) - { - string name = (string)reader.Value!; - reader.Read(); - object left = name; - switch (name) - { - case "settings": - JObject jobj = JObject.Load(reader); - outLevel.Settings = jobj.ToObject(AllInOneSerializer)!; - break; - case "angleData": - JArray jobj2 = JArray.Load(reader); - //outLevel.AddRange(jobj2.ToObject>(AllInOneSerializer)!); - break; - case "actions": - JActions = JArray.Load(reader); - break; - case "decorations": - JDecorations = JArray.Load(reader); - break; - } - } - reader.Close(); - JActions.ToObject>(AllInOneSerializer); - outLevel.Decorations.AddRange(JDecorations.ToObject>(AllInOneSerializer)!); - return outLevel; - } - private readonly string fileLocation = location; - private readonly LevelReadOrWriteSettings settings = settings; - } -} diff --git a/RhythmBaseCore/Adofai/Converters/ADTileConverter.cs b/RhythmBaseCore/Adofai/Converters/ADTileConverter.cs deleted file mode 100644 index ffadb5d..0000000 --- a/RhythmBaseCore/Adofai/Converters/ADTileConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Adofai.Components; -using RhythmBase.Adofai.Events; -namespace RhythmBase.Adofai.Converters -{ - internal class ADTileConverter(ADLevel level) : JsonConverter - { - public override void WriteJson(JsonWriter writer, ADTile value, JsonSerializer serializer) => throw new NotImplementedException(); - - public override ADTile ReadJson(JsonReader reader, Type objectType, ADTile existingValue, bool hasExistingValue, JsonSerializer serializer) => new() - { - Angle = JToken.Load(reader).ToObject(), - Parent = level - }; - - private readonly ADLevel level = level; - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADAddDecoration.cs b/RhythmBaseCore/Adofai/Events/ADAddDecoration.cs deleted file mode 100644 index edb4422..0000000 --- a/RhythmBaseCore/Adofai/Events/ADAddDecoration.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using RhythmBase.Components; -namespace RhythmBase.Adofai.Events -{ - public class ADAddDecoration : ADBaseTileEvent - { - public ADAddDecoration() - { - Type = ADEventType.AddDecoration; - } - - public override ADEventType Type { get; } - - public string DecorationImage { get; set; } - - public RDPointN Position { get; set; } - - public ADDecorationRelativeTo RelativeTo { get; set; } - - public RDSizeN PivotOffset { get; set; } - - public float Rotation { get; set; } - - public bool LockRotation { get; set; } - - public RDSizeN Scale { get; set; } - - public bool LockScale { get; set; } - - public RDSizeN Tile { get; set; } - - public RDColor Color { get; set; } - - public float Opacity { get; set; } - - public int Depth { get; set; } - - public RDSizeN Parallax { get; set; } - - public RDSizeN ParallaxOffset { get; set; } - - public string Tag { get; set; } - - public bool ImageSmoothing { get; set; } - - public BlendModes BlendMode { get; set; } - - public MaskingTypes MaskingType { get; set; } - - public bool UseMaskingDepth { get; set; } - - public int MaskingFrontDepth { get; set; } - - public int MaskingBackDepth { get; set; } - - public HitboxTypes Hitbox { get; set; } - - public string HitboxEventTag { get; set; } - - public FailHitboxTypes FailHitboxType { get; set; } - - public RDSizeN FailHitboxScale { get; set; } - - public RDSizeN FailHitboxOffset { get; set; } - - public int FailHitboxRotation { get; set; } - - public string Components { get; set; } - - public enum BlendModes - { - None, - Darken, - Multiply, - ColorBurn, - LinearBurn, - DarkerColor, - Lighten, - Screen, - ColorDodge, - LinearDodge, - LighterColor, - Overlay, - SoftLight, - HardLight, - VividLight, - LinearLight, - PinLight, - HardMix, - Difference, - Exclusion, - Subtract, - Divide, - Hue, - Saturation, - Color, - Luminosity - } - - public enum MaskingTypes - { - None, - Mask, - VisibleInsideMask, - VisibleOutsideMask - } - - public enum HitboxTypes - { - None, - Kill, - Event - } - - public enum FailHitboxTypes - { - Box, - Circle, - Capsule - } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADAddObject.cs b/RhythmBaseCore/Adofai/Events/ADAddObject.cs deleted file mode 100644 index 9b36410..0000000 --- a/RhythmBaseCore/Adofai/Events/ADAddObject.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using RhythmBase.Components; -namespace RhythmBase.Adofai.Events -{ - public class ADAddObject : ADBaseEvent - { - public ADAddObject() - { - Type = ADEventType.AddObject; - } - - public override ADEventType Type { get; } - - public ObjectTypes ObjectType { get; set; } - - public PlanetColorTypes PlanetColorType { get; set; } - - public RDColor PlanetColor { get; set; } - - public RDColor PlanetTailColor { get; set; } - - public TrackTypes TrackType { get; set; } - - public float TrackAngle { get; set; } - - public ADTrackColorTypes TrackColorType { get; set; } - - public RDColor TrackColor { get; set; } - - public RDColor SecondaryTrackColor { get; set; } - - public float TrackColorAnimDuration { get; set; } - - public float TrackOpacity { get; set; } - - public ADTrackStyles TrackStyle { get; set; } - - public string TrackIcon { get; set; } - - public float TrackIconAngle { get; set; } - - public bool TrackRedSwirl { get; set; } - - public bool TrackGraySetSpeedIcon { get; set; } - - public float TrackSetSpeedIconBpm { get; set; } - - public bool TrackGlowEnabled { get; set; } - - public RDColor TrackGlowColor { get; set; } - - public RDPointN Position { get; set; } - - public ADCameraRelativeTo RelativeTo { get; set; } - - public RDSizeN PivotOffset { get; set; } - - public float Rotation { get; set; } - - public bool LockRotation { get; set; } - - public RDSizeN Scale { get; set; } - - public bool LockScale { get; set; } - - public int Depth { get; set; } - - public RDSizeN Parallax { get; set; } - - public RDSizeN ParallaxOffset { get; set; } - - public string Tag { get; set; } - - public enum ObjectTypes - { - Floor, - Planet - } - - public enum PlanetColorTypes - { - DefaultRed, - planetColorType, - Gold, - Overseer, - Custom - } - - public enum TrackTypes - { - Normal, - Midspin - } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADAddText.cs b/RhythmBaseCore/Adofai/Events/ADAddText.cs deleted file mode 100644 index c82c2e4..0000000 --- a/RhythmBaseCore/Adofai/Events/ADAddText.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using RhythmBase.Components; -namespace RhythmBase.Adofai.Events -{ - public class ADAddText : ADBaseEvent - { - public ADAddText() - { - Type = ADEventType.AddText; - } - - public override ADEventType Type { get; } - - public string DecText { get; set; } - - public string Font { get; set; } - - public RDPointN Position { get; set; } - - public ADCameraRelativeTo RelativeTo { get; set; } - - public RDSizeN PivotOffset { get; set; } - - public float Rotation { get; set; } - - public bool LockRotation { get; set; } - - public RDSizeN Scale { get; set; } - - public bool LockScale { get; set; } - - public RDColor Color { get; set; } - - public float Opacity { get; set; } - - public int Depth { get; set; } - - public RDSizeN Parallax { get; set; } - - public RDSizeN ParallaxOffset { get; set; } - - public string Tag { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADAnimateTrack.cs b/RhythmBaseCore/Adofai/Events/ADAnimateTrack.cs deleted file mode 100644 index 0be0b7f..0000000 --- a/RhythmBaseCore/Adofai/Events/ADAnimateTrack.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using Newtonsoft.Json; -namespace RhythmBase.Adofai.Events -{ - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class ADAnimateTrack : ADBaseTileEvent - { - public ADAnimateTrack() - { - Type = ADEventType.AnimateTrack; - } - - public override ADEventType Type { get; } - - public TrackAnimations? TrackAnimation { get; set; } - - public TrackDisappearAnimations? TrackDisappearAnimation { get; set; } - - public int BeatsAhead { get; set; } - - public int BeatsBehind { get; set; } - - public enum TrackAnimations - { - None, - Assemble, - Assemble_Far, - Extend, - Grow, - Grow_Spin, - Fade, - Drop, - Rise - } - - public enum TrackDisappearAnimations - { - None, - Scatter, - Scatter_Far, - Retract, - Shrink, - Shrink_Spin, - Fade - } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADAutoPlayTiles.cs b/RhythmBaseCore/Adofai/Events/ADAutoPlayTiles.cs deleted file mode 100644 index d28c99e..0000000 --- a/RhythmBaseCore/Adofai/Events/ADAutoPlayTiles.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADAutoPlayTiles : ADBaseTileEvent - { - public ADAutoPlayTiles() - { - Type = ADEventType.AutoPlayTiles; - } - - public override ADEventType Type { get; } - - public bool Enabled { get; set; } - - public bool ShowStatusText { get; set; } - - public bool SafetyTiles { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADBaseEvent.cs b/RhythmBaseCore/Adofai/Events/ADBaseEvent.cs deleted file mode 100644 index 34e01d6..0000000 --- a/RhythmBaseCore/Adofai/Events/ADBaseEvent.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public abstract class ADBaseEvent - { - public abstract ADEventType Type { get; } - - public override string ToString() => Type.ToString(); - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADBaseTaggedTileAction.cs b/RhythmBaseCore/Adofai/Events/ADBaseTaggedTileAction.cs deleted file mode 100644 index 4dcddc1..0000000 --- a/RhythmBaseCore/Adofai/Events/ADBaseTaggedTileAction.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public abstract class ADBaseTaggedTileAction : ADBaseTileEvent - { - public float AngleOffset { get; set; } - - public string EventTag { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADBaseTileEvent.cs b/RhythmBaseCore/Adofai/Events/ADBaseTileEvent.cs deleted file mode 100644 index 73e02cb..0000000 --- a/RhythmBaseCore/Adofai/Events/ADBaseTileEvent.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using Newtonsoft.Json; -namespace RhythmBase.Adofai.Events -{ - public abstract class ADBaseTileEvent : ADBaseEvent - { - [JsonIgnore] - public ADTile Parent { get; set; } - - public override string ToString() => string.Format("{0}", Type); - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADBloom.cs b/RhythmBaseCore/Adofai/Events/ADBloom.cs deleted file mode 100644 index e9dbe26..0000000 --- a/RhythmBaseCore/Adofai/Events/ADBloom.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - public class ADBloom : ADBaseTaggedTileAction, IEaseEvent - { - public ADBloom() - { - Type = ADEventType.Bloom; - } - - public override ADEventType Type { get; } - - public bool Enabled { get; set; } - - public int Threshold { get; set; } - - public int Intensity { get; set; } - - public RDColor Color { get; set; } - - public float Duration { get; set; } - - public EaseType Ease { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADBookmark.cs b/RhythmBaseCore/Adofai/Events/ADBookmark.cs deleted file mode 100644 index 75638d3..0000000 --- a/RhythmBaseCore/Adofai/Events/ADBookmark.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADBookmark : ADBaseTileEvent - { - public ADBookmark() - { - Type = ADEventType.Bookmark; - } - - public override ADEventType Type { get; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADCameraRelativeTo.cs b/RhythmBaseCore/Adofai/Events/ADCameraRelativeTo.cs deleted file mode 100644 index 9bc7773..0000000 --- a/RhythmBaseCore/Adofai/Events/ADCameraRelativeTo.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public enum ADCameraRelativeTo - { - Player, - Tile, - Global, - LastPosition, - LastPositionNoRotation - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADCheckpoint.cs b/RhythmBaseCore/Adofai/Events/ADCheckpoint.cs deleted file mode 100644 index 0de90a0..0000000 --- a/RhythmBaseCore/Adofai/Events/ADCheckpoint.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADCheckpoint : ADBaseTileEvent - { - public ADCheckpoint() - { - Type = ADEventType.Checkpoint; - } - - public override ADEventType Type { get; } - - public int TileOffset { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADColorTrack.cs b/RhythmBaseCore/Adofai/Events/ADColorTrack.cs deleted file mode 100644 index 2abd58b..0000000 --- a/RhythmBaseCore/Adofai/Events/ADColorTrack.cs +++ /dev/null @@ -1,34 +0,0 @@ -using RhythmBase.Components; -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADColorTrack : ADBaseTileEvent - { - public ADColorTrack() - { - Type = ADEventType.ColorTrack; - } - - public override ADEventType Type { get; } - - public ADTrackColorTypes TrackColorType { get; set; } - - public RDColor TrackColor { get; set; } - - public RDColor SecondaryTrackColor { get; set; } - - public float TrackColorAnimDuration { get; set; } - - public ADTrackColorPulses TrackColorPulse { get; set; } - - public float TrackPulseLength { get; set; } - - public ADTrackStyles TrackStyle { get; set; } - - public string TrackTexture { get; set; } - - public float TrackTextureScale { get; set; } - - public float TrackGlowIntensity { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADCustomBackground.cs b/RhythmBaseCore/Adofai/Events/ADCustomBackground.cs deleted file mode 100644 index 0d6d80f..0000000 --- a/RhythmBaseCore/Adofai/Events/ADCustomBackground.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using RhythmBase.Components; -namespace RhythmBase.Adofai.Events -{ - public class ADCustomBackground : ADBaseTaggedTileAction - { - public ADCustomBackground() - { - Type = ADEventType.CustomBackground; - } - - public override ADEventType Type { get; } - - public RDColor Color { get; set; } - - public string BgImage { get; set; } - - public RDColor ImageColor { get; set; } - - public RDPoint Parallax { get; set; } - - public BgDisplayModes BgDisplayMode { get; set; } - - public bool ImageSmoothing { get; set; } - - public bool LockRot { get; set; } - - public bool LoopBG { get; set; } - - public float ScalingRatio { get; set; } - - public enum BgDisplayModes - { - FitToScreen, - Unscaled, - Tiled - } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADCustomEvent.cs b/RhythmBaseCore/Adofai/Events/ADCustomEvent.cs deleted file mode 100644 index dd56a7e..0000000 --- a/RhythmBaseCore/Adofai/Events/ADCustomEvent.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -namespace RhythmBase.Adofai.Events -{ - public class ADCustomEvent : ADBaseEvent - { - public ADCustomEvent() - { - Type = ADEventType.CustomEvent; - } - - public override ADEventType Type { get; } - - [JsonIgnore] - public string ActureType - { - get - { - return Data["eventType"].ToString(); - } - } - - public JObject Data { get; set; } - - public override string ToString() => ActureType; - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADCustomTileEvent.cs b/RhythmBaseCore/Adofai/Events/ADCustomTileEvent.cs deleted file mode 100644 index d5ba446..0000000 --- a/RhythmBaseCore/Adofai/Events/ADCustomTileEvent.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -namespace RhythmBase.Adofai.Events -{ - public class ADCustomTileEvent : ADBaseTileEvent - { - public ADCustomTileEvent() - { - Type = ADEventType.CustomTileEvent; - } - - public override ADEventType Type { get; } - - [JsonIgnore] - public string ActureType - { - get - { - return Data["eventType"].ToString(); - } - } - - public JObject Data { get; set; } - - public override string ToString() => string.Format("{0}({1}): {2}", Parent.Index, Parent.Angle, ActureType); - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADDecorationRelativeTo.cs b/RhythmBaseCore/Adofai/Events/ADDecorationRelativeTo.cs deleted file mode 100644 index 0aa3092..0000000 --- a/RhythmBaseCore/Adofai/Events/ADDecorationRelativeTo.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public enum ADDecorationRelativeTo - { - Tile, - Global, - RedPlanet, - BluePlanet, - GreenPlanet, - Camera, - CameraAspect, - LastPosition - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADEasePartBehaviors.cs b/RhythmBaseCore/Adofai/Events/ADEasePartBehaviors.cs deleted file mode 100644 index 6ae39f8..0000000 --- a/RhythmBaseCore/Adofai/Events/ADEasePartBehaviors.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public enum ADEasePartBehaviors - { - Repeat, - Mirror - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADEditorComment.cs b/RhythmBaseCore/Adofai/Events/ADEditorComment.cs deleted file mode 100644 index 2fedaf2..0000000 --- a/RhythmBaseCore/Adofai/Events/ADEditorComment.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADEditorComment : ADBaseTileEvent - { - public ADEditorComment() - { - Type = ADEventType.EditorComment; - } - - public override ADEventType Type { get; } - - public string Comment { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADEventType.cs b/RhythmBaseCore/Adofai/Events/ADEventType.cs deleted file mode 100644 index bd44502..0000000 --- a/RhythmBaseCore/Adofai/Events/ADEventType.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public enum ADEventType - { - AddDecoration, - AddObject, - AddText, - AnimateTrack, - AutoPlayTiles, - Bloom, - Bookmark, - Checkpoint, - ColorTrack, - CustomBackground, - CustomEvent, - CustomTileEvent, - EditorComment, - Flash, - FreeRoam, - FreeRoamRemove, - FreeRoamTwirl, - HallOfMirrors, - Hide, - Hold, - MoveCamera, - MoveDecorations, - MoveTrack, - MultiPlanet, - Pause, - PlaySound, - PositionTrack, - RecolorTrack, - RepeatEvents, - ScaleMargin, - ScalePlanets, - ScaleRadius, - ScreenScroll, - ScreenTile, - SetConditionalEvents, - SetDefaultText, - SetFilter, - SetHitsound, - SetHoldSound, - SetObject, - SetPlanetRotation, - SetSpeed, - SetText, - ShakeScreen, - Twirl - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADFlash.cs b/RhythmBaseCore/Adofai/Events/ADFlash.cs deleted file mode 100644 index e0ab6c3..0000000 --- a/RhythmBaseCore/Adofai/Events/ADFlash.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - public class ADFlash : ADBaseTaggedTileAction, IEaseEvent - { - public ADFlash() - { - Type = ADEventType.Flash; - } - - public override ADEventType Type { get; } - - public float Duration { get; set; } - - public string Plane { get; set; } - - public RDColor StartColor { get; set; } - - public float StartOpacity { get; set; } - - public RDColor EndColor { get; set; } - - public float EndOpacity { get; set; } - - public EaseType Ease { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADFreeRoam.cs b/RhythmBaseCore/Adofai/Events/ADFreeRoam.cs deleted file mode 100644 index d711305..0000000 --- a/RhythmBaseCore/Adofai/Events/ADFreeRoam.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - public class ADFreeRoam : ADBaseTileEvent, IEaseEvent - { - public ADFreeRoam() - { - Type = ADEventType.FreeRoam; - } - public override ADEventType Type { get; } - public float Duration { get; set; } - public int Size { get; set; } - public int PositionOffset { get; set; } - public int OutTime { get; set; } - [JsonProperty("OutEase")] - public EaseType Ease { get; set; } - public string HitsoundOnBeats { get; set; } - public string HitsoundOffBeats { get; set; } - public int CountdownTicks { get; set; } - public int AngleCorrectionDir { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADFreeRoamRemove.cs b/RhythmBaseCore/Adofai/Events/ADFreeRoamRemove.cs deleted file mode 100644 index 68b949a..0000000 --- a/RhythmBaseCore/Adofai/Events/ADFreeRoamRemove.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADFreeRoamRemove : ADBaseTileEvent - { - public override ADEventType Type { get; } - - public int Position { get; set; } - - public int Size { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADFreeRoamTwirl.cs b/RhythmBaseCore/Adofai/Events/ADFreeRoamTwirl.cs deleted file mode 100644 index 8860b59..0000000 --- a/RhythmBaseCore/Adofai/Events/ADFreeRoamTwirl.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADFreeRoamTwirl : ADBaseTileEvent - { - public ADFreeRoamTwirl() - { - Type = ADEventType.FreeRoamTwirl; - } - - public override ADEventType Type { get; } - - public int Position { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADHallOfMirrors.cs b/RhythmBaseCore/Adofai/Events/ADHallOfMirrors.cs deleted file mode 100644 index a651266..0000000 --- a/RhythmBaseCore/Adofai/Events/ADHallOfMirrors.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADHallOfMirrors : ADBaseTaggedTileAction - { - public ADHallOfMirrors() - { - Type = ADEventType.HallOfMirrors; - } - - public override ADEventType Type { get; } - - public bool Enabled { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADHide.cs b/RhythmBaseCore/Adofai/Events/ADHide.cs deleted file mode 100644 index f7a769b..0000000 --- a/RhythmBaseCore/Adofai/Events/ADHide.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADHide : ADBaseTileEvent - { - public ADHide() - { - Type = ADEventType.Hide; - } - - public override ADEventType Type { get; } - - public bool HideJudgment { get; set; } - - public bool HideTileIcon { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADHold.cs b/RhythmBaseCore/Adofai/Events/ADHold.cs deleted file mode 100644 index 65621e3..0000000 --- a/RhythmBaseCore/Adofai/Events/ADHold.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADHold : ADBaseTileEvent - { - public ADHold() - { - Type = ADEventType.Hold; - } - - public override ADEventType Type { get; } - - public int Duration { get; set; } - - public int DistanceMultiplier { get; set; } - - public bool LandingAnimation { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADMoveCamera.cs b/RhythmBaseCore/Adofai/Events/ADMoveCamera.cs deleted file mode 100644 index cd2cbe8..0000000 --- a/RhythmBaseCore/Adofai/Events/ADMoveCamera.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class ADMoveCamera : ADBaseTaggedTileAction, IEaseEvent - { - public ADMoveCamera() - { - Type = ADEventType.MoveCamera; - } - - public override ADEventType Type { get; } - - public float Duration { get; set; } - - public EaseType Ease { get; set; } - - public bool DontDisable { get; set; } - - public bool MinVfxOnly { get; set; } - - public ADCameraRelativeTo RelativeTo { get; set; } - - public RDPoint? Position { get; set; } - - public float Rotation { get; set; } - - public float Zoom { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADMoveDecorations.cs b/RhythmBaseCore/Adofai/Events/ADMoveDecorations.cs deleted file mode 100644 index 065b1aa..0000000 --- a/RhythmBaseCore/Adofai/Events/ADMoveDecorations.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class ADMoveDecorations : ADBaseTaggedTileAction, IEaseEvent - { - public ADMoveDecorations() - { - Type = ADEventType.MoveDecorations; - } - - public override ADEventType Type { get; } - - public float Duration { get; set; } - - public string Tag { get; set; } - - public EaseType Ease { get; set; } - - public RDPoint? PositionOffset { get; set; } - - public RDPoint? ParallaxOffset { get; set; } - - public bool? Visible { get; set; } - - public ADDecorationRelativeTo? RelativeTo { get; set; } - - public string DecorationImage { get; set; } - - public RDSize? PivotOffset { get; set; } - - public float? RotationOffset { get; set; } - - public RDSize? Scale { get; set; } - - public RDColor? Color { get; set; } - - public float? Opacity { get; set; } - - public int? Depth { get; set; } - - public RDPoint? Parallax { get; set; } - - public MaskingTypes? MaskingType { get; set; } - - public bool? UseMaskingDepth { get; set; } - - public int? MaskingFrontDepth { get; set; } - - public int? MaskingBackDepth { get; set; } - - public enum MaskingTypes - { - None, - Mask, - VisibleInsideMask, - VisibleOutsideMask - } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADMoveTrack.cs b/RhythmBaseCore/Adofai/Events/ADMoveTrack.cs deleted file mode 100644 index 0d36e18..0000000 --- a/RhythmBaseCore/Adofai/Events/ADMoveTrack.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - public class ADMoveTrack : ADBaseTaggedTileAction, IEaseEvent - { - public ADMoveTrack() - { - Type = ADEventType.MoveTrack; - } - - public override ADEventType Type { get; } - - public object StartTile - { - [CompilerGenerated] - get - { - return StartTile; - } - [CompilerGenerated] - set - { - StartTile = RuntimeHelpers.GetObjectValue(value); - } - } - - public object EndTile - { - [CompilerGenerated] - get - { - return EndTile; - } - [CompilerGenerated] - set - { - EndTile = RuntimeHelpers.GetObjectValue(value); - } - } - - public int GapLength { get; set; } - - public float Duration { get; set; } - - public RDPoint PositionOffset { get; set; } - - public EaseType Ease { get; set; } - - public bool MaxVfxOnly { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADMultiPlanet.cs b/RhythmBaseCore/Adofai/Events/ADMultiPlanet.cs deleted file mode 100644 index b122ba6..0000000 --- a/RhythmBaseCore/Adofai/Events/ADMultiPlanet.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADMultiPlanet : ADBaseTileEvent - { - public ADMultiPlanet() - { - Type = ADEventType.MultiPlanet; - } - - public override ADEventType Type { get; } - - public string Planets { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADPause.cs b/RhythmBaseCore/Adofai/Events/ADPause.cs deleted file mode 100644 index eaad1ab..0000000 --- a/RhythmBaseCore/Adofai/Events/ADPause.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADPause : ADBaseTileEvent - { - public ADPause() - { - Type = ADEventType.Pause; - } - - public override ADEventType Type { get; } - - public float Duration { get; set; } - - public int CountdownTicks { get; set; } - - public int AngleCorrectionDir { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADPlaySound.cs b/RhythmBaseCore/Adofai/Events/ADPlaySound.cs deleted file mode 100644 index 4b316aa..0000000 --- a/RhythmBaseCore/Adofai/Events/ADPlaySound.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADPlaySound : ADBaseTaggedTileAction - { - public ADPlaySound() - { - Type = ADEventType.PlaySound; - } - - public override ADEventType Type { get; } - - public string Hitsound { get; set; } - - public int HitsoundVolume { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADPositionTrack.cs b/RhythmBaseCore/Adofai/Events/ADPositionTrack.cs deleted file mode 100644 index e01ad03..0000000 --- a/RhythmBaseCore/Adofai/Events/ADPositionTrack.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using Newtonsoft.Json; -using RhythmBase.Components; -namespace RhythmBase.Adofai.Events -{ - public class ADPositionTrack : ADBaseTileEvent - { - public ADPositionTrack() - { - Type = ADEventType.PositionTrack; - } - - public override ADEventType Type { get; } - - public RDPoint PositionOffset { get; set; } - - public object RelativeTo - { - [CompilerGenerated] - get - { - return RelativeTo; - } - [CompilerGenerated] - set - { - RelativeTo = RuntimeHelpers.GetObjectValue(value); - } - } - - public float Rotation { get; set; } - - public float Scale { get; set; } - - public float Opacity { get; set; } - - public bool JustThisTile { get; set; } - - public bool SditorOnly { get; set; } - - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? StickToFloors { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADRecolorTrack.cs b/RhythmBaseCore/Adofai/Events/ADRecolorTrack.cs deleted file mode 100644 index cefd737..0000000 --- a/RhythmBaseCore/Adofai/Events/ADRecolorTrack.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - public class ADRecolorTrack : ADBaseTaggedTileAction, IEaseEvent - { - public ADRecolorTrack() - { - Type = ADEventType.RecolorTrack; - } - - public override ADEventType Type { get; } - - public object StartTile - { - [CompilerGenerated] - get - { - return StartTile; - } - [CompilerGenerated] - set - { - StartTile = RuntimeHelpers.GetObjectValue(value); - } - } - - public object EndTile - { - [CompilerGenerated] - get - { - return EndTile; - } - [CompilerGenerated] - set - { - EndTile = RuntimeHelpers.GetObjectValue(value); - } - } - - public int GapLength { get; set; } - - public float Duration { get; set; } - - public ADTrackColorTypes TrackColorType { get; set; } - - public RDColor TrackColor { get; set; } - - public RDColor SecondaryTrackColor { get; set; } - - public float TrackColorAnimDuration { get; set; } - - public ADTrackColorPulses TrackColorPulse { get; set; } - - public float TrackPulseLength { get; set; } - - public ADTrackStyles TrackStyle { get; set; } - - public float TrackGlowIntensity { get; set; } - - public EaseType Ease { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADRepeatEvents.cs b/RhythmBaseCore/Adofai/Events/ADRepeatEvents.cs deleted file mode 100644 index 480afb7..0000000 --- a/RhythmBaseCore/Adofai/Events/ADRepeatEvents.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADRepeatEvents : ADBaseTileEvent - { - public ADRepeatEvents() - { - Type = ADEventType.RepeatEvents; - } - - public override ADEventType Type { get; } - - public RepeatTypes RepeatType { get; set; } - - public int Repetitions { get; set; } - - public int FloorCount { get; set; } - - public float Interval { get; set; } - - public bool ExecuteOnCurrentFloor { get; set; } - - public string Tag { get; set; } - - public enum RepeatTypes - { - Beat, - Floor - } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADScaleMargin.cs b/RhythmBaseCore/Adofai/Events/ADScaleMargin.cs deleted file mode 100644 index b0388b9..0000000 --- a/RhythmBaseCore/Adofai/Events/ADScaleMargin.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADScaleMargin : ADBaseTileEvent - { - public ADScaleMargin() - { - Type = ADEventType.ScaleMargin; - } - - public override ADEventType Type { get; } - - public int Scale { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADScalePlanets.cs b/RhythmBaseCore/Adofai/Events/ADScalePlanets.cs deleted file mode 100644 index ee8cd07..0000000 --- a/RhythmBaseCore/Adofai/Events/ADScalePlanets.cs +++ /dev/null @@ -1,31 +0,0 @@ -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - public class ADScalePlanets : ADBaseTaggedTileAction, IEaseEvent - { - public ADScalePlanets() - { - Type = ADEventType.ScalePlanets; - } - - public override ADEventType Type { get; } - - public float Duration { get; set; } - - public TargetPlanets TargetPlanet { get; set; } - - [EaseProperty] - public int Scale { get; set; } - - public EaseType Ease { get; set; } - - public enum TargetPlanets - { - FirePlanet, - IcePlanet, - GreenPlanet, - All - } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADScaleRadius.cs b/RhythmBaseCore/Adofai/Events/ADScaleRadius.cs deleted file mode 100644 index 6e91fc8..0000000 --- a/RhythmBaseCore/Adofai/Events/ADScaleRadius.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADScaleRadius : ADBaseTileEvent - { - public ADScaleRadius() - { - Type = ADEventType.ScaleRadius; - } - - public override ADEventType Type { get; } - - public int Scale { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADScreenScroll.cs b/RhythmBaseCore/Adofai/Events/ADScreenScroll.cs deleted file mode 100644 index 1828fb6..0000000 --- a/RhythmBaseCore/Adofai/Events/ADScreenScroll.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using RhythmBase.Components; -namespace RhythmBase.Adofai.Events -{ - public class ADScreenScroll : ADBaseTaggedTileAction - { - public ADScreenScroll() - { - Type = ADEventType.ScreenScroll; - } - - public override ADEventType Type { get; } - - public RDSizeN Scroll { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADScreenTile.cs b/RhythmBaseCore/Adofai/Events/ADScreenTile.cs deleted file mode 100644 index cf77dd5..0000000 --- a/RhythmBaseCore/Adofai/Events/ADScreenTile.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - public class ADScreenTile : ADBaseTaggedTileAction, IEaseEvent - { - public ADScreenTile() - { - Type = ADEventType.ScreenTile; - } - - public override ADEventType Type { get; } - - public float Duration { get; set; } - - public RDPoint Tile { get; set; } - - public EaseType Ease { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADSetConditionalEvents.cs b/RhythmBaseCore/Adofai/Events/ADSetConditionalEvents.cs deleted file mode 100644 index 0921373..0000000 --- a/RhythmBaseCore/Adofai/Events/ADSetConditionalEvents.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADSetConditionalEvents : ADBaseTileEvent - { - public ADSetConditionalEvents() - { - Type = ADEventType.SetConditionalEvents; - } - - public override ADEventType Type { get; } - - public string PerfectTag { get; set; } - - public string HitTag { get; set; } - - public string EarlyPerfectTag { get; set; } - - public string LatePerfectTag { get; set; } - - public string BarelyTag { get; set; } - - public string VeryEarlyTag { get; set; } - - public string VeryLateTag { get; set; } - - public string MissTag { get; set; } - - public string TooEarlyTag { get; set; } - - public string TooLateTag { get; set; } - - public string LossTag { get; set; } - - public string OnCheckpointTag { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADSetDefaultText.cs b/RhythmBaseCore/Adofai/Events/ADSetDefaultText.cs deleted file mode 100644 index c1bd8da..0000000 --- a/RhythmBaseCore/Adofai/Events/ADSetDefaultText.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class ADSetDefaultText : ADBaseTaggedTileAction, IEaseEvent - { - public ADSetDefaultText() - { - Type = ADEventType.SetDefaultText; - } - - public override ADEventType Type { get; } - - public float Duration { get; set; } - - public EaseType Ease { get; set; } - - public RDColor? DefaultTextColor { get; set; } - - public RDColor? DefaultTextShadowColor { get; set; } - - public RDPoint? LevelTitlePosition { get; set; } - - public string LevelTitleText { get; set; } - - public string CongratsText { get; set; } - - public string PerfectText { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADSetFilter.cs b/RhythmBaseCore/Adofai/Events/ADSetFilter.cs deleted file mode 100644 index ccd187e..0000000 --- a/RhythmBaseCore/Adofai/Events/ADSetFilter.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - public class ADSetFilter : ADBaseTaggedTileAction, IEaseEvent - { - public ADSetFilter() - { - Type = ADEventType.SetFilter; - } - - public override ADEventType Type { get; } - - public Filters Filter { get; set; } - - public string Enabled { get; set; } - - public int Intensity { get; set; } - - public float Duration { get; set; } - - public EaseType Ease { get; set; } - - public string DisableOthers { get; set; } - - public enum Filters - { - Grayscale, - Sepia, - Invert, - VHS, - EightiesTV, - FiftiesTV, - Arcade, - LED, - Rain, - Blizzard, - PixelSnow, - Compression, - Glitch, - Pixelate, - Waves, - Static, - Grain, - MotionBlur, - Fisheye, - Aberration, - Drawing, - Neon, - Handheld, - NightVision, - Funk, - Tunnel, - Weird3D, - Blur, - BlurFocus, - GaussianBlur, - HexagonBlack, - Posterize, - Sharpen, - Contrast, - EdgeBlackLine, - OilPaint, - SuperDot, - WaterDrop, - LightWater, - Petals, - PetalsInstant - } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADSetHitsound.cs b/RhythmBaseCore/Adofai/Events/ADSetHitsound.cs deleted file mode 100644 index 9774ed5..0000000 --- a/RhythmBaseCore/Adofai/Events/ADSetHitsound.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADSetHitsound : ADBaseTileEvent - { - public ADSetHitsound() - { - Type = ADEventType.SetHitsound; - } - - public override ADEventType Type { get; } - - public string GameSound { get; set; } - - public string Hitsound { get; set; } - - public int HitsoundVolume { get; set; } - - public enum GameSounds - { - Hitsound, - Midspin - } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADSetHoldSound.cs b/RhythmBaseCore/Adofai/Events/ADSetHoldSound.cs deleted file mode 100644 index 80e612b..0000000 --- a/RhythmBaseCore/Adofai/Events/ADSetHoldSound.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADSetHoldSound : ADBaseTileEvent - { - public ADSetHoldSound() - { - Type = ADEventType.SetHoldSound; - } - - public override ADEventType Type { get; } - - public string HoldStartSound { get; set; } - - public string HoldLoopSound { get; set; } - - public string HoldEndSound { get; set; } - - public string HoldMidSound { get; set; } - - public string HoldMidSoundType { get; set; } - - public float HoldMidSoundDelay { get; set; } - - public string HoldMidSoundTimingRelativeTo { get; set; } - - public int HoldSoundVolume { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADSetObject.cs b/RhythmBaseCore/Adofai/Events/ADSetObject.cs deleted file mode 100644 index 60667ea..0000000 --- a/RhythmBaseCore/Adofai/Events/ADSetObject.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class ADSetObject : ADBaseTaggedTileAction, IEaseEvent - { - public ADSetObject() - { - Type = ADEventType.SetObject; - } - public override ADEventType Type { get; } - public float Duration { get; set; } - public string Tag { get; set; } - public EaseType Ease { get; set; } - public RDColor? PlanetColor { get; set; } - public RDColor? PlanetTailColor { get; set; } - public float? TrackAngle { get; set; } - public ADTrackColorTypes? TrackColorType { get; set; } - public RDColor? TrackColor { get; set; } - public RDColor? SecondaryTrackColor { get; set; } - public float? TrackColorAnimDuration { get; set; } - public float? TrackOpacity { get; set; } - public ADTrackStyles? TrackStyle { get; set; } - public string TrackIcon { get; set; } - public float? TrackIconAngle { get; set; } - public bool? TrackRedSwirl { get; set; } - public bool? TrackGraySetSpeedIcon { get; set; } - public bool? TrackGlowEnabled { get; set; } - public RDColor? TrackGlowColor { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADSetPlanetRotation.cs b/RhythmBaseCore/Adofai/Events/ADSetPlanetRotation.cs deleted file mode 100644 index 42e9822..0000000 --- a/RhythmBaseCore/Adofai/Events/ADSetPlanetRotation.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADSetPlanetRotation : ADBaseTileEvent - { - public ADSetPlanetRotation() - { - Type = ADEventType.SetPlanetRotation; - } - - public override ADEventType Type { get; } - - public string Ease { get; set; } - - public int EaseParts { get; set; } - - public ADEasePartBehaviors EasePartBehavior { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADSetSpeed.cs b/RhythmBaseCore/Adofai/Events/ADSetSpeed.cs deleted file mode 100644 index 09215f2..0000000 --- a/RhythmBaseCore/Adofai/Events/ADSetSpeed.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADSetSpeed : ADBaseTaggedTileAction - { - public ADSetSpeed() - { - Type = ADEventType.SetSpeed; - } - - public override ADEventType Type { get; } - - public SpeedTypes SpeedType { get; set; } - - public float BeatsPerMinute { get; set; } - - public float BpmMultiplier { get; set; } - - public enum SpeedTypes - { - Bpm, - Multiplier - } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADSetText.cs b/RhythmBaseCore/Adofai/Events/ADSetText.cs deleted file mode 100644 index 058c7c9..0000000 --- a/RhythmBaseCore/Adofai/Events/ADSetText.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADSetText : ADBaseTaggedTileAction - { - public ADSetText() - { - Type = ADEventType.SetText; - } - - public override ADEventType Type { get; } - - public string DecText { get; set; } - - public string Tag { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADShakeScreen.cs b/RhythmBaseCore/Adofai/Events/ADShakeScreen.cs deleted file mode 100644 index 62d3ab9..0000000 --- a/RhythmBaseCore/Adofai/Events/ADShakeScreen.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -namespace RhythmBase.Adofai.Events -{ - public class ADShakeScreen : ADBaseTaggedTileAction, IEaseEvent - { - public ADShakeScreen() - { - Type = ADEventType.ShakeScreen; - } - - public override ADEventType Type { get; } - - public float Duration { get; set; } - - public float Strength { get; set; } - - public float Intensity { get; set; } - - public EaseType Ease { get; set; } - - public float FadeOut { get; set; } - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADTile.cs b/RhythmBaseCore/Adofai/Events/ADTile.cs deleted file mode 100644 index 93de4df..0000000 --- a/RhythmBaseCore/Adofai/Events/ADTile.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Adofai.Components; -namespace RhythmBase.Adofai.Events -{ - public class ADTile : ADTypedList - { - public float Angle - { - get => _angle; - set => _angle = value is > (-360f) and < 360f ? ((value + 540f) % 360f) - 180f : -999f; - } - public bool IsMidSpin => _angle < -180f || _angle > 180f; - public ADBeat Beat => new(Parent?.Calculator!, Index + (_angle / 180f)); - [JsonIgnore] - public ADLevel? Parent { get; set; } - public ADTile() { } - public ADTile(IEnumerable actions) - { - foreach (ADBaseTileEvent i in actions) - { - i.Parent = this; - Add(i); - } - } - public int Index => Parent?.IndexOf(this) ?? -1; - public override string ToString() => string.Format("[{0}]{1}<{2}>{3}", - [ - Index, - Beat, - IsMidSpin ? "MS".PadRight(4) : _angle.ToString().PadLeft(4), - ((IEnumerable)this).Any() ? string.Format(", Count = {0}", ((IEnumerable)this).Count()) : string.Empty - ]); - private float _angle = 0; - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADTileRelativeTo.cs b/RhythmBaseCore/Adofai/Events/ADTileRelativeTo.cs deleted file mode 100644 index 19ceeca..0000000 --- a/RhythmBaseCore/Adofai/Events/ADTileRelativeTo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public enum ADTileRelativeTo - { - ThisTile, - Start, - End - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADTrackColorPulses.cs b/RhythmBaseCore/Adofai/Events/ADTrackColorPulses.cs deleted file mode 100644 index 9783929..0000000 --- a/RhythmBaseCore/Adofai/Events/ADTrackColorPulses.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public enum ADTrackColorPulses - { - None, - Forward, - Backward - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADTrackColorTypes.cs b/RhythmBaseCore/Adofai/Events/ADTrackColorTypes.cs deleted file mode 100644 index d5a7fe7..0000000 --- a/RhythmBaseCore/Adofai/Events/ADTrackColorTypes.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public enum ADTrackColorTypes - { - Single, - Stripes, - Glow, - Blink, - Switch, - Rainbow, - Volume - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADTrackStyles.cs b/RhythmBaseCore/Adofai/Events/ADTrackStyles.cs deleted file mode 100644 index 46306d7..0000000 --- a/RhythmBaseCore/Adofai/Events/ADTrackStyles.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public enum ADTrackStyles - { - Standard, - Neon, - NeonLight, - Basic, - Gems, - Minimal - } -} diff --git a/RhythmBaseCore/Adofai/Events/ADTwirl.cs b/RhythmBaseCore/Adofai/Events/ADTwirl.cs deleted file mode 100644 index 0d52fd7..0000000 --- a/RhythmBaseCore/Adofai/Events/ADTwirl.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -namespace RhythmBase.Adofai.Events -{ - public class ADTwirl : ADBaseTileEvent - { - public ADTwirl() - { - Type = ADEventType.Twirl; - } - - public override ADEventType Type { get; } - } -} diff --git a/RhythmBaseCore/Adofai/Utils/ADBeatCalculator.cs b/RhythmBaseCore/Adofai/Utils/ADBeatCalculator.cs deleted file mode 100644 index 440400a..0000000 --- a/RhythmBaseCore/Adofai/Utils/ADBeatCalculator.cs +++ /dev/null @@ -1,37 +0,0 @@ -using RhythmBase.Adofai.Components; -using RhythmBase.Adofai.Events; -using RhythmBase.Extensions; -namespace RhythmBase.Adofai.Utils -{ - /// - /// Beat Calculator. - /// - public class ADBeatCalculator - { - internal ADBeatCalculator(ADLevel level) - { - Collection = level; - Refresh(); - } - private void Refresh() - { - _DefaultBpm = Collection.Settings.Bpm; - _MidSpins = Collection.Where((i) => i.IsMidSpin).ToList(); - ////this._SetSpeeds = this.Collection.EventsWhere().ToList(); - ////this._Twirls = this.Collection.EventsWhere().ToList(); - ////this._Pauses = this.Collection.EventsWhere().ToList(); - ////this._Holds = this.Collection.EventsWhere().ToList(); - ////this._Freeroams = this.Collection.EventsWhere().ToList(); - } -#pragma warning disable IDE0052 // 删除未读的私有成员 - internal ADLevel Collection; - private float _DefaultBpm = 100; - private List _MidSpins = []; - private readonly List _SetSpeeds = []; - private readonly List _Twirls = []; - private readonly List _Pauses = []; - private readonly List _Holds = []; - private readonly List _Freeroams = []; -#pragma warning restore IDE0052 // 删除未读的私有成员 - } -} diff --git a/RhythmBaseCore/Adofai/Utils/Utils.cs b/RhythmBaseCore/Adofai/Utils/Utils.cs deleted file mode 100644 index 18b5fb6..0000000 --- a/RhythmBaseCore/Adofai/Utils/Utils.cs +++ /dev/null @@ -1,154 +0,0 @@ -using Microsoft.VisualBasic.CompilerServices; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using RhythmBase.Adofai.Components; -using RhythmBase.Adofai.Converters; -using RhythmBase.Adofai.Events; -using RhythmBase.Converters; -using RhythmBase.Events; -using RhythmBase.Exceptions; -using RhythmBase.Settings; -using System.Collections.ObjectModel; -namespace RhythmBase.Adofai.Utils -{ - /// - /// Useful utils. - /// - [StandardModule] - public static class Utils - { - /// - /// Converts a given type to an ADEventType enumeration. - /// - /// The type to convert. - /// The corresponding ADEventType enumeration. - /// Thrown when no matching EventType is found or multiple matching EventTypes are found. - public static ADEventType ADConvertToEnum(Type type) - { - if (ADETypesToEnum == null) - { - if (type.Name.StartsWith("AD")) - { - string name = type.Name[2..]; - if (Enum.TryParse(name, out ADEventType result)) - return result; - } - throw new IllegalEventTypeException(type, "Unable to find a matching EventType."); - } - ADEventType ADConvertToEnum; - try - { - ADConvertToEnum = ADETypesToEnum![type].Single(); - } - catch - { - throw new IllegalEventTypeException(type, "Multiple matching EventTypes were found. Please check if the type is an abstract class type.", new ArgumentException("Multiple matching EventTypes were found. Please check if the type is an abstract class type.", nameof(type))); - } - return ADConvertToEnum; - } - - /// - /// Converts a generic type to an ADEventType enumeration. - /// - /// The type to convert, which must inherit from ADBaseEvent and have a parameterless constructor. - /// The corresponding ADEventType enumeration. - public static ADEventType ConvertToADEnum() where T : ADBaseEvent, new() => ADConvertToEnum(typeof(T)); - - /// - /// Converts a generic type to an array of ADEventType enumerations. - /// - /// The type to convert, which must inherit from BaseEvent. - /// An array of corresponding ADEventType enumerations. - /// Thrown when no matching EventType is found. - public static ADEventType[] ConvertToADEnums() where T : BaseEvent - { - ADEventType[] ConvertToADEnums; - try - { - ConvertToADEnums = ADETypesToEnum[typeof(T)]; - } - catch - { - throw new IllegalEventTypeException(typeof(T), "This exception is not expected. Please contact the developer to handle this exception."); - } - return ConvertToADEnums; - } - - /// - /// Converts a string representation of an ADEventType to a Type. - /// - /// The string representation of the ADEventType. - /// The corresponding Type. - public static Type ADConvertToType(string type) - { - bool flag = Enum.TryParse(type, out ADEventType result); - Type ADConvertToType; - if (flag) - ADConvertToType = ConvertToType(result); - else - ADConvertToType = ConvertToType(ADEventType.CustomEvent); - return ADConvertToType; - } - - /// - /// Converts an ADEventType enumeration to a Type. - /// - /// The ADEventType enumeration to convert. - /// The corresponding Type. - /// Thrown when the type is illegal. - /// Thrown when the value does not exist in the EventType enumeration. - public static Type ConvertToType(this ADEventType type) - { - Type ConvertToType; - if (ADEnumToEType == null) - ConvertToType = Type.GetType(string.Format("{0}.AD{1}", typeof(ADBaseEvent).Namespace, type)) - ?? throw new RhythmBaseException(string.Format("Illegal Type: {0}.", type)); - else - try - { - ConvertToType = ADEnumToEType[type]; - } - catch - { - throw new IllegalEventTypeException(Conversions.ToString((int)type), "This value does not exist in the EventType enumeration."); - } - return ConvertToType; - } - - /// - /// Gets a JsonSerializer configured with the necessary converters for the given ADLevel and settings. - /// - /// The ADLevel instance. - /// The LevelReadOrWriteSettings instance. - /// A configured JsonSerializer instance. - public static JsonSerializer GetSerializer(this ADLevel adlevel, LevelReadOrWriteSettings settings) - { - JsonSerializer AllInOneSerializer = new(); - JsonConverterCollection converters = AllInOneSerializer.Converters; - converters.Add(new StringEnumConverter()); - converters.Add(new ColorConverter()); - converters.Add(new ADTileConverter(adlevel)); - converters.Add(new ADCustomTileEventConverter(adlevel, settings)); - converters.Add(new ADCustomEventConverter(adlevel, settings)); - converters.Add(new ADBaseTileEventConverter(adlevel, settings)); - converters.Add(new ADBaseEventConverter(adlevel, settings)); - return AllInOneSerializer; - } - - private static readonly ReadOnlyCollection ADETypes = (from i in typeof(ADBaseEvent).Assembly.GetTypes() - where i.IsAssignableTo(typeof(ADBaseEvent)) - select i).ToList().AsReadOnly(); - - /// - /// A dictionary that records the correspondence of ADEventType to event types inheriting from ADBaseEvent. - /// - public static readonly ReadOnlyDictionary ADETypesToEnum = ADETypes.ToDictionary((Type i) => i, (Type i) => (from j in ADETypes - where (j == i || j.IsAssignableTo(i)) && !j.IsAbstract - select j).Select((Type j) => ADConvertToEnum(j)).ToArray()).AsReadOnly(); - - /// - /// A dictionary that records the correspondence of event types inheriting from ADBaseEvent to ADEventType. - /// - public static readonly ReadOnlyDictionary ADEnumToEType = Enum.GetValues().ToDictionary((ADEventType i) => i, ConvertToType).AsReadOnly(); - } -} diff --git a/RhythmBaseCore/Components/BaseConditional.cs b/RhythmBaseCore/Components/BaseConditional.cs deleted file mode 100644 index 650a76c..0000000 --- a/RhythmBaseCore/Components/BaseConditional.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Newtonsoft.Json; -namespace RhythmBase.Components -{ - /// - /// Represents a base class for different types of conditions. - /// - public abstract class BaseConditional - { - /// - /// Gets the type of this condition. - /// - public abstract ConditionType Type { get; } - - /// - /// Gets or sets the condition tag. Its role has not been clarified. - /// - public string Tag { get; set; } = ""; - - /// - /// Gets or sets the condition name. - /// - public string Name { get; set; } = ""; - - /// - /// Gets the 1-based serial number of this condition in the parent collection. - /// - public int Id => checked(ParentCollection.IndexOf(this) + 1); - - /// - /// Returns the name of the condition. - /// - /// The name of the condition. - public override string ToString() => Name; - - /// - /// Gets or sets the parent collection of conditions. - /// - [JsonIgnore] - internal List ParentCollection = []; - - /// - /// Specifies the type of condition. - /// - public enum ConditionType - { - /// - /// Condition based on the last hit. - /// - LastHit, - - /// - /// Custom condition. - /// - Custom, - - /// - /// Condition based on the number of times executed. - /// - TimesExecuted, - - /// - /// Condition based on the language. - /// - Language, - - /// - /// Condition based on the player mode. - /// - PlayerMode - } - } -} diff --git a/RhythmBaseCore/Components/Bookmark.cs b/RhythmBaseCore/Components/Bookmark.cs deleted file mode 100644 index 37c2613..0000000 --- a/RhythmBaseCore/Components/Bookmark.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace RhythmBase.Components -{ - /// - /// Represents a bookmark in the rhythm base. - /// - public class Bookmark - { - /// - /// Gets or sets the beat where the bookmark is located. - /// - public RDBeat Beat { get; set; } - - /// - /// Gets or sets the color of the bookmark. - /// - public BookmarkColors Color { get; set; } - - /// - /// Returns a string that represents the current bookmark. - /// - /// A string that represents the current bookmark. - public override string ToString() => string.Format("{0}, {1}", Beat, Color); - - /// - /// Specifies the colors available for bookmarks. - /// - public enum BookmarkColors - { - /// - /// Represents the color blue. - /// - Blue, - /// - /// Represents the color red. - /// - Red, - /// - /// Represents the color yellow. - /// - Yellow, - /// - /// Represents the color green. - /// - Green - } - } -} diff --git a/RhythmBaseCore/Components/ClassicBeatStatus.cs b/RhythmBaseCore/Components/ClassicBeatStatus.cs deleted file mode 100644 index 2453e2a..0000000 --- a/RhythmBaseCore/Components/ClassicBeatStatus.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace RhythmBase.Components -{ - /// - /// Represents the status of a classic beat. - /// - public struct ClassicBeatStatus - { - /// - /// Gets or sets the status type of the beat. - /// - public StatusType Status; - - /// - /// Gets or sets the beat count. - /// - public ushort BeatCount; - - /// - /// Defines the various status types for a classic beat. - /// - public enum StatusType - { -#pragma warning disable CS1591 - Unset = -1, - None, - Synco, - Beat_Open, - Beat_Flash, - Beat_Double_Flash, - Beat_Triple_Flash, - Beat_Close, - X_Open, - X_Flash, - X_Close, - X_Synco_Open, - X_Synco_Flash, - X_Synco_Close, - Up_Open, - Up_Close, - Down_Open, - Down_Close, - Swing_Left, - Swing_Right, - Swing_Bounce, - Held_Start, - Held_End -#pragma warning restore CS1591 - } - } -} diff --git a/RhythmBaseCore/Components/Condition.cs b/RhythmBaseCore/Components/Condition.cs deleted file mode 100644 index d5b6bee..0000000 --- a/RhythmBaseCore/Components/Condition.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Microsoft.VisualBasic.CompilerServices; -using RhythmBase.Exceptions; -using System.Text.RegularExpressions; -namespace RhythmBase.Components -{ - /// - /// The conditions of the event. - /// - public class Condition - { - /// - /// Condition list. - /// - public List<(bool Enabled, BaseConditional Conditional)> ConditionLists; - - /// - /// The time of effectiveness of the condition. - /// - public float Duration { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public Condition() - { - ConditionLists = []; - } - - /// - /// Loads a condition from a string. - /// - /// The text to load the condition from. - /// A new instance of the class. - /// Thrown when the condition is illegal. - internal static Condition Load(string text) - { - Condition @out = new(); - MatchCollection Matches = Regex.Matches(text, "(~?\\d+)(?=[&d])"); - if (Matches.Count > 0) - { - @out.Duration = float.Parse(Regex.Match(text, "[\\d\\.]").Value); - return @out; - } - throw new RhythmBaseException(string.Format("Illegal condition: {0}.", text)); - } - - /// - /// Converts conditions to a string. - /// - /// A string in the format supported by RDLevel. - public string Serialize() => $"{string.Join("&", ConditionLists.Select((i) => (i.Enabled ? "" : "~") + i.Conditional.Id.ToString()))}d{Duration}"; - - /// - public override string ToString() => Serialize(); - } -} diff --git a/RhythmBaseCore/Components/Conditions/CustomCondition.cs b/RhythmBaseCore/Components/Conditions/CustomCondition.cs deleted file mode 100644 index 76a8181..0000000 --- a/RhythmBaseCore/Components/Conditions/CustomCondition.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace RhythmBase.Components.Conditions -{ - /// - /// Represents a custom condition with an expression. - /// - public class CustomCondition : BaseConditional - { - /// - /// Initializes a new instance of the class. - /// - public CustomCondition() - { - Type = ConditionType.Custom; - } - - /// - /// Gets or sets the expression for the custom condition. - /// - /// The expression as a string. - public string Expression { get; set; } = ""; - - /// - /// Gets the type of the condition. - /// - /// The type of the condition, which is . - public override ConditionType Type { get; } - } -} diff --git a/RhythmBaseCore/Components/Conditions/LanguageCondition.cs b/RhythmBaseCore/Components/Conditions/LanguageCondition.cs deleted file mode 100644 index efc0f78..0000000 --- a/RhythmBaseCore/Components/Conditions/LanguageCondition.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Newtonsoft.Json; -namespace RhythmBase.Components.Conditions -{ - /// - /// Represents a condition based on the game language. - /// - public class LanguageCondition : BaseConditional - { - /// - /// Initializes a new instance of the class. - /// - public LanguageCondition() - { - Type = ConditionType.Language; - } - - /// - /// Gets or sets the game language. - /// - [JsonProperty(nameof(Language))] - public Languages Language - { - get; - set; - } - - /// - /// Gets the type of the condition. - /// - public override ConditionType Type { get; } - - /// - /// Represents the supported game languages. - /// - public enum Languages - { - /// - /// English language. - /// - English, - - /// - /// Spanish language. - /// - Spanish, - - /// - /// Portuguese language. - /// - Portuguese, - - /// - /// Simplified Chinese language. - /// - ChineseSimplified, - - /// - /// Traditional Chinese language. - /// - ChineseTraditional, - - /// - /// Korean language. - /// - Korean, - - /// - /// Polish language. - /// - Polish, - - /// - /// Japanese language. - /// - Japanese, - - /// - /// German language. - /// - German - } - } -} diff --git a/RhythmBaseCore/Components/Conditions/LastHitCondition.cs b/RhythmBaseCore/Components/Conditions/LastHitCondition.cs deleted file mode 100644 index 4eaab85..0000000 --- a/RhythmBaseCore/Components/Conditions/LastHitCondition.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace RhythmBase.Components.Conditions -{ - /// - /// Represents a condition based on the last hit in a rhythm game. - /// - public class LastHitCondition : BaseConditional - { - /// - /// Initializes a new instance of the class. - /// - public LastHitCondition() - { - Type = ConditionType.LastHit; - } - - /// - /// Gets the type of the condition. - /// - public override ConditionType Type { get; } - - /// - /// Gets or sets the row where the last hit occurred. - /// - public sbyte Row { get; set; } - - /// - /// Gets or sets the result that determines under what condition the event will be executed. - /// - public HitResult Result { get; set; } - - /// - /// Defines the possible results of a hit. - /// - [Flags] - public enum HitResult - { - /// - /// The hit was perfect. - /// - Perfect = 0, - - /// - /// The hit was slightly early. - /// - SlightlyEarly = 2, - - /// - /// The hit was slightly late. - /// - SlightlyLate = 3, - - /// - /// The hit was very early. - /// - VeryEarly = 4, - - /// - /// The hit was very late. - /// - VeryLate = 5, - - /// - /// The hit was either slightly early or slightly late. - /// - AnyEarlyOrLate = 7, - - /// - /// The hit was missed. - /// - Missed = 15 - } - } -} diff --git a/RhythmBaseCore/Components/Conditions/PlayerModeCondition.cs b/RhythmBaseCore/Components/Conditions/PlayerModeCondition.cs deleted file mode 100644 index c40005d..0000000 --- a/RhythmBaseCore/Components/Conditions/PlayerModeCondition.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace RhythmBase.Components.Conditions -{ - /// - /// Represents a condition based on the player mode. - /// - public class PlayerModeCondition : BaseConditional - { - /// - /// Initializes a new instance of the class. - /// - public PlayerModeCondition() - { - Type = ConditionType.PlayerMode; - } - - /// - /// Gets or sets a value indicating whether two-player mode is enabled. - /// - /// - /// true if two-player mode is enabled; otherwise, false. - /// - public bool TwoPlayerMode { get; set; } - - /// - /// Gets the type of the condition. - /// - /// - /// The type of the condition. - /// - public override ConditionType Type { get; } - } -} diff --git a/RhythmBaseCore/Components/Conditions/TimesExecutedCondition.cs b/RhythmBaseCore/Components/Conditions/TimesExecutedCondition.cs deleted file mode 100644 index e2188e3..0000000 --- a/RhythmBaseCore/Components/Conditions/TimesExecutedCondition.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace RhythmBase.Components.Conditions -{ - /// - /// Represents a condition based on the number of times it has been executed. - /// - public class TimesExecutedCondition : BaseConditional - { - /// - /// Initializes a new instance of the class. - /// - public TimesExecutedCondition() - { - Type = ConditionType.TimesExecuted; - } - - /// - /// Gets or sets the maximum number of executions allowed. - /// - public int MaxTimes { get; set; } - - /// - /// Gets the type of the condition. - /// - public override ConditionType Type { get; } - } -} diff --git a/RhythmBaseCore/Components/DecorationEventCollection.cs b/RhythmBaseCore/Components/DecorationEventCollection.cs deleted file mode 100644 index 3388bb9..0000000 --- a/RhythmBaseCore/Components/DecorationEventCollection.cs +++ /dev/null @@ -1,94 +0,0 @@ -using Microsoft.VisualBasic.CompilerServices; -using Newtonsoft.Json; -using RhythmBase.Events; -using RhythmBase.Exceptions; -namespace RhythmBase.Components -{ - /// - /// A decoration. - /// - [JsonObject] - public class DecorationEventCollection : OrderedEventCollection - { - /// - /// Decorated ID. - /// - [JsonProperty("id")] - public string Id - { - get => _id; - set => _id = value; - } - /// - /// Decoration index. - /// - [JsonProperty("row")] - public int Index => Parent?.Decorations.ToList().IndexOf(this) ?? throw new RhythmBaseException(); - - /// - /// Room. - /// - [JsonProperty("rooms")] - public RDSingleRoom Room { get; set; } - /// - /// The file reference used by the decoration. - /// - [JsonProperty("filename")] - public string Filename { get; set; } = ""; - /// - /// Decoration depth. - /// - public int Depth { get; set; } - /// - /// The filter used for this decoration. - /// - public Filters Filter { get; set; } - /// - /// The initial visibility of this decoration. - /// - public bool Visible { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public DecorationEventCollection() - { - Room = new RDSingleRoom(RDRoomIndex.Room1); - } - /// Decoration room. - internal DecorationEventCollection(RDSingleRoom room) - { - Room = room; - _id = GetHashCode().ToString(); - } - /// - /// Add an event to decoration. - /// - /// Decoration event. - public override void Add(BaseDecorationAction item) - { - item._parent?.Remove(item); - item._parent = this; - Parent?.Add(item); - } - internal void AddSafely(BaseDecorationAction item) => base.Add(item); - /// - /// Remove an event from decoration. - /// - /// A decoration event. - public override bool Remove(BaseDecorationAction item) => Parent?.Remove(item) ?? throw new RhythmBaseException(); - internal bool RemoveSafely(BaseDecorationAction item) => base.Remove(item); - /// - public override string ToString() => string.Format("{0}, {1}, {2}, {3}", - [ - _id, - Index, - Room, - Filename - ]); - internal DecorationEventCollection Clone() => (DecorationEventCollection)MemberwiseClone(); - private string _id = ""; - [JsonIgnore] - internal RDLevel? Parent = null; - } -} diff --git a/RhythmBaseCore/Components/Easing/Ease.cs b/RhythmBaseCore/Components/Easing/Ease.cs deleted file mode 100644 index c0fa924..0000000 --- a/RhythmBaseCore/Components/Easing/Ease.cs +++ /dev/null @@ -1,282 +0,0 @@ -namespace RhythmBase.Components.Easing - -{ - /// - /// The EaseType enumeration represents various types of easing functions. - /// These functions are used to create smooth transitions in animations. - /// - public enum EaseType - { - /// - /// Unset. - /// - Unset = -1, - /// - ///Ease Linear. - /// - Linear, - /// - ///Ease InSine. - /// - InSine, - /// - ///Ease OutSine. - /// - OutSine, - /// - ///Ease InOutSine. - /// - InOutSine, - /// - ///Ease InQuad. - /// - InQuad, - /// - ///Ease OutQuad. - /// - OutQuad, - /// - ///Ease InOutQuad. - /// - InOutQuad, - /// - ///Ease InCubic. - /// - InCubic, - /// - ///Ease OutCubic. - /// - OutCubic, - /// - ///Ease InOutCubic. - /// - InOutCubic, - /// - ///Ease InQuart. - /// - InQuart, - /// - ///Ease OutQuart. - /// - OutQuart, - /// - ///Ease InOutQuart. - /// - InOutQuart, - /// - ///Ease InQuint. - /// - InQuint, - /// - ///Ease OutQuint. - /// - OutQuint, - /// - ///Ease InOutQuint. - /// - InOutQuint, - /// - ///Ease InExpo. - /// - InExpo, - /// - ///Ease OutExpo. - /// - OutExpo, - /// - ///Ease InOutExpo. - /// - InOutExpo, - /// - ///Ease InCirc. - /// - InCirc, - /// - ///Ease OutCirc. - /// - OutCirc, - /// - ///Ease InOutCirc. - /// - InOutCirc, - /// - ///Ease InElastic. - /// - InElastic, - /// - ///Ease OutElastic. - /// - OutElastic, - /// - ///Ease InOutElastic. - /// - InOutElastic, - /// - ///Ease InBack. - /// - InBack, - /// - ///Ease OutBack. - /// - OutBack, - /// - ///Ease InOutBack. - /// - InOutBack, - /// - ///Ease InBounce. - /// - InBounce, - /// - ///Ease OutBounce. - /// - OutBounce, - /// - ///Ease InOutBounce. - /// - InOutBounce, - /// - ///Ease SmoothStep. - /// - SmoothStep, - } - /// - /// Ease Calculate module. - /// - public static class Ease - { - /// - /// Calculates the value with the specified ease type. - /// - /// Ease type. - /// A doubleing-point number in the range of 0 to 1. - /// Easing result. - public static double Calculate(this EaseType type, double x) => type switch - { - EaseType.Unset => EaseFunction.None(x), - EaseType.Linear => EaseFunction.Linear(x), - EaseType.InSine => EaseFunction.InSine(x), - EaseType.OutSine => EaseFunction.OutSine(x), - EaseType.InOutSine => EaseFunction.InOutSine(x), - EaseType.InQuad => EaseFunction.InQuad(x), - EaseType.OutQuad => EaseFunction.OutQuad(x), - EaseType.InOutQuad => EaseFunction.InOutQuad(x), - EaseType.InCubic => EaseFunction.InCubic(x), - EaseType.OutCubic => EaseFunction.OutCubic(x), - EaseType.InOutCubic => EaseFunction.InOutCubic(x), - EaseType.InQuart => EaseFunction.InQuart(x), - EaseType.OutQuart => EaseFunction.OutQuart(x), - EaseType.InOutQuart => EaseFunction.InOutQuart(x), - EaseType.InQuint => EaseFunction.InQuint(x), - EaseType.OutQuint => EaseFunction.OutQuint(x), - EaseType.InOutQuint => EaseFunction.InOutQuint(x), - EaseType.InExpo => EaseFunction.InExpo(x), - EaseType.OutExpo => EaseFunction.OutExpo(x), - EaseType.InOutExpo => EaseFunction.InOutExpo(x), - EaseType.InCirc => EaseFunction.InCirc(x), - EaseType.OutCirc => EaseFunction.OutCirc(x), - EaseType.InOutCirc => EaseFunction.InOutCirc(x), - EaseType.InElastic => EaseFunction.InElastic(x), - EaseType.OutElastic => EaseFunction.OutElastic(x), - EaseType.InOutElastic => EaseFunction.InOutElastic(x), - EaseType.InBack => EaseFunction.InBack(x), - EaseType.OutBack => EaseFunction.OutBack(x), - EaseType.InOutBack => EaseFunction.InOutBack(x), - EaseType.InBounce => EaseFunction.InBounce(x), - EaseType.OutBounce => EaseFunction.OutBounce(x), - EaseType.InOutBounce => EaseFunction.InOutBounce(x), - EaseType.SmoothStep => EaseFunction.SmoothStep(x), - _ => 0, - }; - /// - /// Calculates the value with the specified ease type. - /// - /// Ease type. - /// A doubleing-point number in the range of 0 to 1. - /// The starting value of the easing result. - /// The endding value of the easing result - /// Easing result. - public static double Calculate(this EaseType Type, double x, double from, double to) => Type.Calculate(x) * (to - from) + from; - /// - /// Ease types. - /// - - private static class EaseFunction - { - private const double c1 = 1.525; - private const double c2 = 1.70158; - public static double None(double x) => 0; - public static double Linear(double x) => x; - public static double InSine(double x) => 1 - Math.Cos(x * double.Pi / 2); - public static double OutSine(double x) => Math.Sin(x * double.Pi / 2); - public static double InOutSine(double x) => -(Math.Cos(x * double.Pi) - 1) / 2; - public static double InQuad(double x) => Math.Pow(x, 2); - public static double OutQuad(double x) => 1 - Math.Pow(1 - x, 2); - public static double InOutQuad(double x) => x < 0.5 ? 2 * Math.Pow(x, 2) : 1 - Math.Pow(-2 * x + 2, 2) / 2; - public static double InCubic(double x) => Math.Pow(x, 3); - public static double OutCubic(double x) => 1 - Math.Pow(1 - x, 3); - public static double InOutCubic(double x) => x < 0.5 ? 4 * Math.Pow(x, 3) : 1 - Math.Pow(-2 * x + 2, 3) / 2; - public static double InQuart(double x) => Math.Pow(x, 4); - public static double OutQuart(double x) => 1 - Math.Pow(1 - x, 4); - public static double InOutQuart(double x) => x < 0.5 ? 8 * Math.Pow(x, 4) : 1 - Math.Pow(-2 * x + 2, 4) / 2; - public static double InQuint(double x) => Math.Pow(x, 5); - public static double OutQuint(double x) => 1 - Math.Pow(1 - x, 5); - public static double InOutQuint(double x) => x < 0.5 ? 16 * Math.Pow(x, 5) : 1 - Math.Pow(-2 * x + 2, 5) / 2; - public static double InExpo(double x) => x == 0 ? 0 : Math.Pow(2, 10 * x - 10); - public static double OutExpo(double x) => x == 1 ? 1 : 1 - Math.Pow(2, -10 * x); - public static double InOutExpo(double x) => x == 0 - ? 0 - : x == 1 - ? 1 - : x < 0.5 ? Math.Pow(2, 20 * x - 10) / 2 - : (2 - Math.Pow(2, -20 * x + 10)) / 2; - public static double InCirc(double x) => 1 - Math.Sqrt(1 - Math.Pow(x, 2)); - public static double OutCirc(double x) => Math.Sqrt(1 - Math.Pow(x - 1, 2)); - public static double InOutCirc(double x) => x < 0.5 - ? (1 - Math.Sqrt(1 - Math.Pow(2 * x, 2))) / 2 - : (Math.Sqrt(1 - Math.Pow(-2 * x + 2, 2)) + 1) / 2; - public static double InElastic(double x) => x == 0 - ? 0 - : x == 1 - ? 1 - : -Math.Pow(2, 10 * x - 10) * Math.Sin((x * 10 - 10.75) * (2 * double.Pi / 3)); - public static double OutElastic(double x) => x == 0 - ? 0 - : x == 1 - ? 1 - : Math.Pow(2, -10 * x) * Math.Sin((x * 10 - 0.75) * (2 * double.Pi / 3)) + 1; - public static double InOutElastic(double x) => x == 0 - ? 0 - : x == 1 - ? 1 - : x < 0.5 - ? -(Math.Pow(2, 20 * x - 10) * Math.Sin((20 * x - 11.125) * (2 * double.Pi / 4.5))) / 2 - : Math.Pow(2, -20 * x + 10) * Math.Sin((20 * x - 11.125) * (2 * double.Pi / 4.5)) / 2 + 1; - public static double InBack(double x) => (c2 + 1) * x * x * x - c2 * x * x; - public static double OutBack(double x) => 1 + (c2 + 1) * Math.Pow(x - 1, 3) + c2 * Math.Pow(x - 1, 2); - public static double InOutBack(double x) => x < 0.5 - ? Math.Pow(2 * x, 2) * ((c2 * c1 + 1) * 2 * x - c2 * c1) / 2 - : (Math.Pow(2 * x - 2, 2) * ((c2 * c1 + 1) * (x * 2 - 2) + c2 * c1) + 2) / 2; - public static double InBounce(double x) => - 1 - OutBounce(1 - x); - public static double OutBounce(double x) - { - const double n1 = 7.5625; - const double d1 = 2.75; - return x switch - { - < 1 / d1 => n1 * x * x, - < 2 / d1 => n1 * (x -= 1.5 / d1) * x + 0.75, - < 2.5 / d1 => n1 * (x -= 2.25 / d1) * x + 0.9375, - _ => n1 * (x -= 2.625 / d1) * x + 0.984375, - }; - } - public static double InOutBounce(double x) => - x < 0.5 - ? (1 - OutBounce(1 - 2 * x)) / 2 - : (1 + OutBounce(2 * x - 1)) / 2; - public static double SmoothStep(double x) => - (3 - 2 * x) * Math.Pow(x, 2); - } - } -} diff --git a/RhythmBaseCore/Components/Easing/EaseNode.cs b/RhythmBaseCore/Components/Easing/EaseNode.cs deleted file mode 100644 index 0b22d8b..0000000 --- a/RhythmBaseCore/Components/Easing/EaseNode.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace RhythmBase.Components.Easing -{ - /// - /// Represents a node in the easing process. - /// - /// The target value of the easing node. - public struct EaseNode(float target) - { - /// - /// Gets or sets the time at which the easing node starts. - /// - public float Time { get; set; } = 0; - - /// - /// Gets or sets the target value of the easing node. - /// - public float Target { get; set; } = target; - - /// - /// Gets or sets the duration of the easing node. - /// - public float Duration { get; set; } = 0; - - /// - /// Gets or sets the type of easing to be applied. - /// - public EaseType Type { get; set; } = EaseType.Linear; - } -} diff --git a/RhythmBaseCore/Components/Easing/EasePropertyAttribute.cs b/RhythmBaseCore/Components/Easing/EasePropertyAttribute.cs deleted file mode 100644 index 1f7a13e..0000000 --- a/RhythmBaseCore/Components/Easing/EasePropertyAttribute.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace RhythmBase.Components.Easing -{ - /// - /// An attribute to mark properties for easing functions. - /// - [AttributeUsage(AttributeTargets.Property)] - public class EasePropertyAttribute : Attribute - { - } -} diff --git a/RhythmBaseCore/Components/Easing/EasePropertyColor.cs b/RhythmBaseCore/Components/Easing/EasePropertyColor.cs deleted file mode 100644 index 5f8874e..0000000 --- a/RhythmBaseCore/Components/Easing/EasePropertyColor.cs +++ /dev/null @@ -1,63 +0,0 @@ -using RhythmBase.Events; -using System.Reflection; - -namespace RhythmBase.Components.Easing -{ - /// - /// Represents an easing property with a color value. - /// - public class EasePropertyColor : IEaseProperty - { - private EaseValue _r; - private EaseValue _g; - private EaseValue _b; - private EaseValue _a; - /// - public RDColor GetValue(RDBeat beat) => RDColor.FromRgba( - (byte)Math.Clamp(_r.GetValue(beat.BeatOnly), 0, 255), - (byte)Math.Clamp(_g.GetValue(beat.BeatOnly), 0, 255), - (byte)Math.Clamp(_b.GetValue(beat.BeatOnly), 0, 255), - (byte)Math.Clamp(_a.GetValue(beat.BeatOnly), 0, 255)); - /// - public static bool CanConvert(object data) => data is RDColor; - /// - public static EaseNode?[] Convert(IEaseEvent data, PropertyInfo property) - { - RDColor? value = (RDColor?)property.GetValue(data); - return [ - value?.R is byte vr ? new(vr) { - Duration = data.Duration, - Time = ((BaseEvent)data).Beat.BeatOnly, - Type = data.Ease - } : null, - value?.G is byte vg ? new(vg) { - Duration = data.Duration, - Time = ((BaseEvent)data).Beat.BeatOnly, - Type = data.Ease - } : null, - value?.B is byte vb ? new(vb) { - Duration = data.Duration, - Time = ((BaseEvent)data).Beat.BeatOnly, - Type = data.Ease - } : null, - value?.A is byte va ? new(va) { - Duration = data.Duration, - Time = ((BaseEvent)data).Beat.BeatOnly, - Type = data.Ease - } : null, - ]; - } - /// - public static IEaseProperty CreateEaseProperty(RDColor originalValue, IEaseEvent[] data, PropertyInfo property) - { - EaseNode?[][] nodes = [.. data.Select(d => Convert(d, property))]; - return new EasePropertyColor() - { - _r = new(originalValue.R, [.. nodes.Select(i => i[0]).Where(i => i is not null).Cast()]), - _g = new(originalValue.G, [.. nodes.Select(i => i[1]).Where(i => i is not null).Cast()]), - _b = new(originalValue.B, [.. nodes.Select(i => i[2]).Where(i => i is not null).Cast()]), - _a = new(originalValue.A, [.. nodes.Select(i => i[3]).Where(i => i is not null).Cast()]) - }; - } - } -} diff --git a/RhythmBaseCore/Components/Easing/EasePropertyFloat.cs b/RhythmBaseCore/Components/Easing/EasePropertyFloat.cs deleted file mode 100644 index 80be12c..0000000 --- a/RhythmBaseCore/Components/Easing/EasePropertyFloat.cs +++ /dev/null @@ -1,38 +0,0 @@ -using RhythmBase.Events; -using System.Reflection; - -namespace RhythmBase.Components.Easing -{ - /// - /// Represents an easing property with a float value. - /// - public class EasePropertyFloat : IEaseProperty - { - private EaseValue _value; - /// - public float GetValue(RDBeat beat) => _value.GetValue(beat.BeatOnly); - /// - public static bool CanConvert(object data) => data is float; - /// - public static EaseNode?[] Convert(IEaseEvent data, PropertyInfo property) - { - RDExpression? value = (RDExpression?)property.GetValue(data); - return [ - value is RDExpression v? new EaseNode(v.Value) { - Duration = data.Duration, - Time = ((BaseEvent)data).Beat.BeatOnly, - Type = data.Ease - } : null, - ]; - } - /// - public static IEaseProperty CreateEaseProperty(float originalValue, IEaseEvent[] data, PropertyInfo property) - { - EaseNode?[][] nodes = [.. data.Select(d => Convert(d, property))]; - return new EasePropertyFloat() - { - _value = new(originalValue, [.. nodes.Select(i => i[0]).Where(i => i is not null).Cast()]) - }; - } - } -} diff --git a/RhythmBaseCore/Components/Easing/EasePropertyPoint.cs b/RhythmBaseCore/Components/Easing/EasePropertyPoint.cs deleted file mode 100644 index 38a4087..0000000 --- a/RhythmBaseCore/Components/Easing/EasePropertyPoint.cs +++ /dev/null @@ -1,45 +0,0 @@ -using RhythmBase.Events; -using System.Reflection; - -namespace RhythmBase.Components.Easing -{ - /// - /// Represents an easing property with a point value. - /// - public class EasePropertyPoint : IEaseProperty - { - private EaseValue _x; - private EaseValue _y; - /// - public RDPointN GetValue(RDBeat beat) => new(_x.GetValue(beat.BeatOnly), _y.GetValue(beat.BeatOnly)); - /// - public static bool CanConvert(object data) => data is RDPoint; - /// - public static EaseNode?[] Convert(IEaseEvent data, PropertyInfo property) - { - RDPointE? value = (RDPointE?)property.GetValue(data); - return [ - value?.X?.Value is float vx ? new(vx) { - Duration = data.Duration, - Time = ((BaseEvent)data).Beat.BeatOnly, - Type = data.Ease - } : null, - value?.Y?.Value is float vy ? new(vy) { - Duration = data.Duration, - Time = ((BaseEvent)data).Beat.BeatOnly, - Type = data.Ease - } : null, - ]; - } - /// - public static IEaseProperty CreateEaseProperty(RDPointN originalValue, IEaseEvent[] data, PropertyInfo property) - { - EaseNode?[][] nodes = [.. data.Select(d => Convert(d, property))]; - return new EasePropertyPoint() - { - _x = new(originalValue.X, [.. nodes.Select(i => i[0]).Where(i => i is not null).Cast()]), - _y = new(originalValue.Y, [.. nodes.Select(i => i[1]).Where(i => i is not null).Cast()]) - }; - } - } -} diff --git a/RhythmBaseCore/Components/Easing/EasePropertySize.cs b/RhythmBaseCore/Components/Easing/EasePropertySize.cs deleted file mode 100644 index 013f6e9..0000000 --- a/RhythmBaseCore/Components/Easing/EasePropertySize.cs +++ /dev/null @@ -1,45 +0,0 @@ -using RhythmBase.Events; -using System.Reflection; - -namespace RhythmBase.Components.Easing -{ - /// - /// Represents an easing property with a size value. - /// - public class EasePropertySize : IEaseProperty - { - private EaseValue _width; - private EaseValue _height; - /// - public RDSizeN GetValue(RDBeat beat) => new(_width.GetValue(beat.BeatOnly), _height.GetValue(beat.BeatOnly)); - /// - public static bool CanConvert(object data) => data is RDSize; - /// - public static EaseNode?[] Convert(IEaseEvent data, PropertyInfo property) - { - RDSizeE? value = (RDSizeE?)property.GetValue(data); - return [ - value?.Width?.Value is float vx ? new(vx) { - Duration = data.Duration, - Time = ((BaseEvent)data).Beat.BeatOnly, - Type = data.Ease - } : null, - value?.Height?.Value is float vy ? new(vy) { - Duration = data.Duration, - Time = ((BaseEvent)data).Beat.BeatOnly, - Type = data.Ease - } : null, - ]; - } - /// - public static IEaseProperty CreateEaseProperty(RDSizeN originalValue, IEaseEvent[] data, PropertyInfo property) - { - EaseNode?[][] nodes = [.. data.Select(d => Convert(d, property))]; - return new EasePropertySize() - { - _width = new(originalValue.Width, [.. nodes.Select(i => i[0]).Where(i => i is not null).Cast()]), - _height = new(originalValue.Height, [.. nodes.Select(i => i[1]).Where(i => i is not null).Cast()]) - }; - } - } -} diff --git a/RhythmBaseCore/Components/Easing/EaseValue.cs b/RhythmBaseCore/Components/Easing/EaseValue.cs deleted file mode 100644 index 68aa7a4..0000000 --- a/RhythmBaseCore/Components/Easing/EaseValue.cs +++ /dev/null @@ -1,180 +0,0 @@ -using System.Data; - -namespace RhythmBase.Components.Easing -{ - /// - /// Represents a value that changes over time according to a series of easing nodes. - /// - /// - /// Initializes a new instance of the class with the specified original value and easing nodes. - /// - /// The original value before any easing is applied. - /// The collection of easing nodes that define how the value changes over time. - public struct EaseValue(float originalValue, IEnumerable nodes) - { - /// - /// Gets or sets the collection of easing nodes, ordered by their start time. - /// - public EaseNode[] Nodes { get; set; } = [.. nodes.OrderBy(x => x.Time)]; - /// - /// Gets or sets the original value before any easing is applied. - /// - public float OriginalValue { get; set; } = originalValue; - /// - /// Gets the value at the specified time, taking into account the easing nodes. - /// - /// The time at which to get the value. - /// The value at the specified time. - public readonly float GetValue(float time) - { - if (Nodes.Length == 0 || time <= Nodes[0].Time) - return OriginalValue; - int i = Nodes.Length - 1; - while (i >= 0 && time <= Nodes[i].Time) - i--; - if (Nodes[i].Time + Nodes[i].Duration <= time) - return Nodes[i].Target; - Stack ns = new([Nodes[i]]); - while (--i > -1) - { - if (IsInRange(Nodes[i], ns.Peek().Time)) - { - ns.Push(Nodes[i]); - } - } - float origin = i == -1 ? OriginalValue : Nodes[i + 1].Target; - while (ns.Count > 1) - { - EaseNode node = ns.Pop(); - origin = GetValue(node, ns.Peek().Time, origin); - } - origin = GetValue(ns.Pop(), time, origin); - return origin; - } - /// - /// Determines whether the specified time is within the range of the easing node. - /// - /// The easing node to check. - /// The time to check. - /// true if the time is within the range of the easing node; otherwise, false. - private static bool IsInRange(EaseNode node, float time) => node.Time <= time && time <= node.Time + node.Duration; - /// - /// Calculates the value of the easing node at the specified time. - /// - /// The easing node to calculate the value for. - /// The time at which to calculate the value. - /// The original value before any easing is applied. - /// The calculated value at the specified time. - private static float GetValue(EaseNode node, float time, float origin) => node.Duration == 0 ? node.Target : (float)node.Type.Calculate((time - node.Time) / node.Duration, origin, node.Target); - /// - /// Fits the data points to an easing function with the specified precision. - /// - /// The original value before any easing is applied. - /// The array of time and value pairs to fit. - /// The precision for fitting the data points. - /// An instance that fits the data points. - public static EaseValue Fit(float originalValue, (float time, float value)[] values, float precision = 3f) => Fit(originalValue, values, eases, precision); - /// - /// Fits the data points to an easing function with the specified precision. - /// - /// The original value before any easing is applied. - /// The array of time and value pairs to fit. - /// The precision for fitting the data points. - /// The array of easing types to consider. - /// An instance that fits the data points. - public static EaseValue Fit(float originalValue, (float time, float value)[] values, EaseType[] easeTypes, float precision = 3f) - { - values = [.. values.OrderBy(x => x.time)]; - if (values.Length == 0) - return new EaseValue(originalValue, []); - if (values.Length == 1) - return new EaseValue(originalValue, [new EaseNode(values[0].value) { Duration = values[0].time, Type = EaseType.InOutSine }]); - if (values.Length == 2) - return new EaseValue(originalValue, [new EaseNode(values[0].value) { Time = values[0].time, Duration = values[1].time, Type = EaseType.InOutSine }]); - return Fit([(0, originalValue), .. values], easeTypes, precision); - } - /// - /// Fits the data points to an easing function with the specified precision. - /// - /// The array of time and value pairs to fit. - /// The precision for fitting the data points. - /// An instance that fits the data points. - public static EaseValue Fit((float time, float value)[] values, float precision = 3f) => Fit(values, eases, precision); - /// - /// Fits the data points to an easing function with the specified precision and ease types. - /// - /// The array of time and value pairs to fit. - /// The array of easing types to consider. - /// The precision for fitting the data points. - /// Special thanks to mfgujhgh for the algorithm! - /// An instance that fits the data points. - public static EaseValue Fit((float time, float value)[] values, EaseType[] easeTypes, float precision = 3f) - { - if (easeTypes.Length == 0) - throw new ArgumentException("At least one ease type must be specified.", nameof(easeTypes)); - values = [.. values.OrderBy(x => x.time)]; - int[] steps = new int[values.Length], - p = new int[values.Length]; - EaseType[] pe = new EaseType[values.Length]; - steps[0] = 0; - for (int i = 1; i < values.Length; i++) - { - steps[i] = steps[i - 1] + 1; - p[i] = i - 1; - pe[i] = easeTypes[0]; - for (int j = 0; j < i - 1; j++) - { - if (steps[j] + 1 >= steps[i]) - continue; - EaseType besttype = easeTypes[0]; - float bests = float.MaxValue; - foreach (var e in easeTypes) - { - float s = Check(values, j, i, e, precision); - if (s < bests) - { - bests = s; - besttype = e; - } - } - if (bests < precision && steps[i] > steps[j] + 1) - { - steps[i] = steps[j] + 1; - p[i] = j; - pe[i] = besttype; - } - } - } - EaseNode[] ns = new EaseNode[steps[^1]]; - int k = values.Length - 1; - while (k != 0) - { - ns[--steps[k]] = new EaseNode(values[k].value) - { - Time = values[p[k]].time, - Duration = values[k].time - values[p[k]].time, - Type = pe[k] - }; - k = p[k]; - } - return new EaseValue(values[0].value, ns); - } - private static float Check((float time, float value)[] data, int start, int end, EaseType type, float precision) - { - float s = 0; - for (int i = start + 1; i <= end; i++) - { - float v = data[start].value - + (float)type.Calculate((data[i].time - data[start].time) / (data[end].time - data[start].time)) - * (data[end].value - data[start].value); - s = Math.Max(s, Math.Abs(v - data[i].value)); - if (s > precision) - { - return s; - } - } - return s; - } - private static readonly EaseType[] eases = Enum.GetValues(); - } -} diff --git a/RhythmBaseCore/Components/Easing/IEaseProperty.cs b/RhythmBaseCore/Components/Easing/IEaseProperty.cs deleted file mode 100644 index 4e874ff..0000000 --- a/RhythmBaseCore/Components/Easing/IEaseProperty.cs +++ /dev/null @@ -1,54 +0,0 @@ -using RhythmBase.Events; -using System.Reflection; - -namespace RhythmBase.Components.Easing -{ - /// - /// Represents an easing property. - /// - public interface IEaseProperty - { - } - /// - /// Represents an easing property with a specific value type. - /// - /// The type of the value. - public interface IEaseProperty : IEaseProperty where TValue : new() - { - /// - /// Gets the type of the value. - /// - static Type Type => typeof(TValue); - - /// - /// Gets the value at the specified beat. - /// - /// The beat at which to get the value. - /// The value at the specified beat. - abstract TValue GetValue(RDBeat beat); - - /// - /// Determines whether the specified data can be converted to the value type. - /// - /// The data to check. - /// true if the data can be converted; otherwise, false. - static abstract bool CanConvert(object data); - - /// - /// Converts the specified easing event data to an array of easing nodes. - /// - /// The easing event data to convert. - /// The property information of the easing event. - /// An array of easing nodes. - static abstract EaseNode?[] Convert(IEaseEvent data, PropertyInfo property); - - /// - /// Creates an easing property with the specified original value and easing event data. - /// - /// The original value before any easing is applied. - /// The array of easing event data. - /// The property information of the easing event. - /// An easing property instance. - static abstract IEaseProperty CreateEaseProperty(TValue originalValue, IEaseEvent[] data, PropertyInfo property); - } -} diff --git a/RhythmBaseCore/Components/Filters.cs b/RhythmBaseCore/Components/Filters.cs deleted file mode 100644 index 392f9f7..0000000 --- a/RhythmBaseCore/Components/Filters.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace RhythmBase.Components -{ - /// - /// Specifies the type of render filter to be used. - /// - public enum Filters - { - /// - /// Nearest neighbor filtering. - /// - NearestNeighbor, - - /// - /// Bilinear filtering. - /// - BiliNear - } -} diff --git a/RhythmBaseCore/Components/IRDVortex.cs b/RhythmBaseCore/Components/IRDVortex.cs deleted file mode 100644 index 77d167c..0000000 --- a/RhythmBaseCore/Components/IRDVortex.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Numerics; - -namespace RhythmBase.Components -{ - /// - /// Represents a vortex interface that supports various mathematical operations. - /// - /// The type that implements this interface. - /// The type of the right operand in addition and subtraction operations. - /// The type of the value in multiplication and division operations. - public interface IRDVortex : - IEquatable, - IAdditionOperators, - ISubtractionOperators, - IMultiplyOperators, - IDivisionOperators, - IEqualityOperators - where TSelf : - IEquatable, - IAdditionOperators, - ISubtractionOperators, - IMultiplyOperators, - IDivisionOperators, - IEqualityOperators - { - } -} diff --git a/RhythmBaseCore/Components/OrderedEventCollection.2.cs b/RhythmBaseCore/Components/OrderedEventCollection.2.cs deleted file mode 100644 index 2f03909..0000000 --- a/RhythmBaseCore/Components/OrderedEventCollection.2.cs +++ /dev/null @@ -1,51 +0,0 @@ -using RhythmBase.Events; -namespace RhythmBase.Components -{ - /// - /// Represents a collection of ordered events. - /// - /// The type of event. - public class OrderedEventCollection : OrderedEventCollection, ICollection where TEvent : IBaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public OrderedEventCollection() - { - } - /// - /// Initializes a new instance of the class with the specified items. - /// - /// The items to add to the collection. - public OrderedEventCollection(IEnumerable items) - { - foreach (TEvent item in items) - Add(item); - } - /// - /// Concatenates all events in the collection. - /// - /// An that contains all events in the collection. - public new IEnumerable ConcatAll() => eventsBeatOrder.SelectMany(i => i.Value).Cast(); - /// - /// Adds an event to the collection. - /// - /// The event to add. - public virtual void Add(TEvent item) => Add((IBaseEvent)(object)item); - /// - public virtual bool Contains(TEvent item) => Contains((IBaseEvent)(object)item); - /// - public void CopyTo(TEvent[] array, int arrayIndex) => CopyTo((IBaseEvent[])(object)array, arrayIndex); - /// - public virtual bool Remove(TEvent item) => Remove((BaseEvent)(object)item); - /// - public override string ToString() => string.Format("Count = {0}", Count); - /// - IEnumerator IEnumerable.GetEnumerator() - { - foreach (KeyValuePair> pair in eventsBeatOrder) - foreach (TEvent item in pair.Value.Select(v => (TEvent)v)) - yield return item; - } - } -} diff --git a/RhythmBaseCore/Components/OrderedEventCollection.cs b/RhythmBaseCore/Components/OrderedEventCollection.cs deleted file mode 100644 index a382417..0000000 --- a/RhythmBaseCore/Components/OrderedEventCollection.cs +++ /dev/null @@ -1,164 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Events; -using System.Collections; -namespace RhythmBase.Components -{ - /// - /// A collection of events that maintains the sequence of events. - /// - public abstract class OrderedEventCollection : ICollection - { - /// - /// Gets the total count of events in the collection. - /// - [JsonIgnore] - public virtual int Count => eventsBeatOrder.Sum((i) => i.Value.Count()); - - /// - /// Gets a value indicating whether the collection is read-only. - /// - [JsonIgnore] - public bool IsReadOnly { get; } - - /// - /// Returns the beat of the last event. - /// - /// The beat of the last event. - [JsonIgnore] - public RDBeat Length => eventsBeatOrder.LastOrDefault().Value.FirstOrDefault()?.Beat??new(); - - /// - /// Initializes a new instance of the class. - /// - public OrderedEventCollection() - { - eventsBeatOrder = []; - IsReadOnly = false; - } - - /// - /// Initializes a new instance of the class with the specified items. - /// - /// The items to add to the collection. - public OrderedEventCollection(IEnumerable items) - { - eventsBeatOrder = []; - IsReadOnly = false; - foreach (IBaseEvent item in items) - Add(item); - } - - /// - /// Concatenates all events in the collection. - /// - /// A list of all events in the collection. - public IEnumerable ConcatAll() => eventsBeatOrder.SelectMany(i => i.Value).ToList(); - - /// - /// Adds an event to the collection. - /// - /// The event to add. - public void Add(IBaseEvent item) - { - TypedEventCollection list = []; - if (eventsBeatOrder.TryGetValue(item.Beat, out TypedEventCollection? value)) - list = value; - else - eventsBeatOrder.Add(item.Beat, list); - list.Add(item); - } - - /// - /// Clears all events from the collection. - /// - public void Clear() => eventsBeatOrder.Clear(); - - /// - /// Determines whether the collection contains a specific event. - /// - /// The event to locate in the collection. - /// true if the event is found in the collection; otherwise, false. - public virtual bool Contains(IBaseEvent item) => eventsBeatOrder.ContainsKey(item.Beat) && eventsBeatOrder[item.Beat].Contains(item); - - /// - /// Copies the elements of the collection to an array, starting at a particular array index. - /// - /// The array to copy the elements to. - /// The zero-based index in the array at which copying begins. - public void CopyTo(IBaseEvent[] array, int arrayIndex) - { - ArgumentNullException.ThrowIfNull(array); - if (arrayIndex < 0 || arrayIndex > array.Length) - throw new ArgumentOutOfRangeException(nameof(arrayIndex)); - if (array.Length - arrayIndex < Count) - throw new ArgumentException("The number of elements in the source collection is greater than the available space from arrayIndex to the end of the destination array."); - - foreach (var pair in eventsBeatOrder) - { - foreach (var item in pair.Value) - { - array[arrayIndex++] = item; - } - } - } - /// - /// Removes the first occurrence of a specific event from the collection. - /// - /// The event to remove from the collection. - /// true if the event was successfully removed; otherwise, false. - internal bool Remove(IBaseEvent item) - { - bool Remove; - if (Contains(item)) - { - bool result = eventsBeatOrder[item.Beat].Remove(item); - if (!eventsBeatOrder[item.Beat].Any()) - eventsBeatOrder.Remove(item.Beat); - Remove = result; - } - else - Remove = false; - return Remove; - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// An enumerator for the collection. - public IEnumerator GetEnumerator() - { - foreach (KeyValuePair> pair in eventsBeatOrder) - foreach (IBaseEvent item in pair.Value) - yield return item; - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// An enumerator for the collection. - IEnumerator IEnumerable.GetEnumerator() - { - foreach (KeyValuePair> pair in eventsBeatOrder) - foreach (IBaseEvent item in pair.Value) - yield return item; - } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => string.Format("Count = {0}", Count); - - /// - /// Removes the first occurrence of a specific event from the collection. - /// - /// The event to remove from the collection. - /// true if the event was successfully removed; otherwise, false. - bool ICollection.Remove(IBaseEvent item) => throw new NotImplementedException(); - - /// - /// The dictionary that maintains the order of events based on their beats. - /// - internal SortedDictionary> eventsBeatOrder; - } -} diff --git a/RhythmBaseCore/Components/PaletteColor.cs b/RhythmBaseCore/Components/PaletteColor.cs deleted file mode 100644 index e43fef5..0000000 --- a/RhythmBaseCore/Components/PaletteColor.cs +++ /dev/null @@ -1,84 +0,0 @@ -namespace RhythmBase.Components -{ - /// - /// Palette color - /// - /// - /// - /// - /// Specifies whether this object supports alpha channel. - public class PaletteColor(bool enableAlpha) - { - /// - /// Get or set a custom color. - /// - public RDColor? Color - { - get - { - RDColor? Color = new RDColor?(EnablePanel ? parent[_panel] : default); - return Color; - } - set - { - _panel = -1; - _color = EnableAlpha - ? value - : value == null - ? null - : new RDColor?(value.GetValueOrDefault().WithAlpha(byte.MaxValue)); - } - } - /// - /// Go back to or set the palette color index. - /// - public int PaletteIndex - { - get => _panel; - set - { - if (value >= 0) - { - _color = null; - _panel = value; - } - } - } - /// - /// Specifies whether this object supports alpha channel. - /// - /// - public bool EnableAlpha { get; } = enableAlpha; - /// - /// Specifies whether this object is used for this color. - /// - public bool EnablePanel - { - get - { - return PaletteIndex >= 0; - } - } - /// - /// The actual color of this object.
- /// If comes from a palette, it's a palette color. - /// If not, it's a custom color. - ///
- public RDColor Value - { - get - { - return (EnablePanel ? (parent[_panel]) : _color ?? throw new RhythmBase.Exceptions.RhythmBaseException()); - } - } - - /// - public override string ToString() => EnablePanel ? string.Format("{0}: {1}", _panel, Value) : Value.ToString(); - - private int _panel; - - private RDColor? _color; - - internal RDColor[] parent = []; - } -} diff --git a/RhythmBaseCore/Components/RDAudio.cs b/RhythmBaseCore/Components/RDAudio.cs deleted file mode 100644 index c9c95e5..0000000 --- a/RhythmBaseCore/Components/RDAudio.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -namespace RhythmBase.Components; - -/// -/// Represents an audio file with properties for volume, pitch, pan, and offset. -/// -public class RDAudio -{ - /// - /// Initializes a new instance of the class with default values. - /// - public RDAudio() { } - - /// - /// Gets or sets the file name of the audio. - /// - public string Filename { get; set; } = ""; - - /// - /// Gets or sets the volume of the audio. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public int Volume { get; set; } = 100; - - /// - /// Gets or sets the pitch of the audio. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public int Pitch { get; set; } = 100; - - /// - /// Gets or sets the pan of the audio. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public int Pan { get; set; } - - /// - /// Gets or sets the offset of the audio. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - [JsonConverter(typeof(MilliSecondConverter))] - public TimeSpan Offset { get; set; } - - /// - /// Gets a value indicating whether the file is a valid audio file based on its extension. - /// - [JsonIgnore] - public bool IsFile => sourceArray.Contains(Path.GetExtension(Filename)); - - private static readonly string[] sourceArray = - [ - ".mp3", - ".wav", - ".ogg", - ".aif", - ".aiff" - ]; - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => Filename; -} diff --git a/RhythmBaseCore/Components/RDBeat.cs b/RhythmBaseCore/Components/RDBeat.cs deleted file mode 100644 index f018933..0000000 --- a/RhythmBaseCore/Components/RDBeat.cs +++ /dev/null @@ -1,445 +0,0 @@ -using RhythmBase.Exceptions; -using RhythmBase.Utils; -using System.Diagnostics.CodeAnalysis; -using System.Numerics; -namespace RhythmBase.Components -{ - /// - /// A beat. - /// - public struct RDBeat : IComparable, IEquatable, IComparisonOperators - { - internal readonly RDLevel? BaseLevel => _calculator?.Collection; - /// - /// Whether this beat cannot be calculated. - /// - [MemberNotNullWhen(false, nameof(_calculator))] - public readonly bool IsEmpty => _calculator == null || (!_isBeatLoaded && !_isBarBeatLoaded && !_isTimeSpanLoaded); - /// - /// The total number of beats from this moment to the beginning of the level. - /// - public float BeatOnly - { - get - { - IfNullThrowException(); - if (!_isBeatLoaded) - { - if (_isBarBeatLoaded) - _beat = _calculator!.BarBeatToBeatOnly(_BarBeat.Bar, _BarBeat.Beat) - 1f; - else if (_isTimeSpanLoaded) - _beat = _calculator!.TimeSpanToBeatOnly(_TimeSpan) - 1f; - _isBeatLoaded = true; - } - return _beat + 1f; - } - } - /// - /// The actual bar and beat of this moment. - /// - public (uint bar, float beat) BarBeat - { - get - { - IfNullThrowException(); - if (!_isBarBeatLoaded) - { - if (_isBeatLoaded) - _BarBeat = _calculator!.BeatOnlyToBarBeat(_beat + 1f); - else if (_isTimeSpanLoaded) - { - _beat = _calculator!.TimeSpanToBeatOnly(_TimeSpan) - 1f; - _isBeatLoaded = true; - _BarBeat = _calculator.BeatOnlyToBarBeat(_beat + 1f); - } - _isBarBeatLoaded = true; - } - return _BarBeat; - } - } - /// - /// The total amount of time from the beginning of the level to this beat. - /// - public TimeSpan TimeSpan - { - get - { - IfNullThrowException(); - if (!_isTimeSpanLoaded) - { - if (_isBeatLoaded) - _TimeSpan = _calculator!.BeatOnlyToTimeSpan(_beat + 1f); - else - { - if (_isBarBeatLoaded) - { - _beat = _calculator!.BarBeatToBeatOnly(_BarBeat.Bar, _BarBeat.Beat) - 1f; - _isBeatLoaded = true; - _TimeSpan = _calculator.BeatOnlyToTimeSpan(_beat + 1f); - } - } - _isTimeSpanLoaded = true; - } - return _TimeSpan; - } - } - /// - /// The number of beats per minute followed at this moment. - /// - public float BPM - { - get - { - if (!_isBPMLoaded) - { - _BPM = _calculator?.BeatsPerMinuteOf(this) ?? throw new InvalidRDBeatException(); - _isBPMLoaded = true; - } - return _BPM; - } - } - /// - /// The number of beats per bar followed at this moment. - /// - public float CPB - { - get - { - if (!_isCPBLoaded) - { - _CPB = (uint)Math.Round(_calculator?.CrotchetsPerBarOf(this) ?? throw new InvalidRDBeatException()); - _isCPBLoaded = true; - } - return _CPB; - } - } - /// - /// Construct an instance without specifying a calculator. - /// - /// The total number of beats from this moment to the beginning of the level. - public RDBeat(float beatOnly) - { - this = default; - if (beatOnly < 1) - throw new OverflowException(string.Format("The beat must not be less than 1, but {0} is given", beatOnly)); - _beat = beatOnly - 1f; - _isBeatLoaded = true; - } - /// - /// Constructs an instance of RDBeat with the specified bar and beat. - /// - /// The actual bar of this moment. Must be greater than or equal to 1. - /// The actual beat of this moment. Must be greater than or equal to 1. - /// Thrown when the bar or beat is less than 1. - public RDBeat(uint bar, float beat) - { - this = default; - if (bar < 1) - throw new OverflowException(string.Format("The bar must not be less than 1, but {0} is given", bar)); - if (beat < 1) - throw new OverflowException(string.Format("The beat must not be less than 1, but {0} is given", beat)); - _BarBeat = new ValueTuple(bar, beat); - _isBarBeatLoaded = true; - } - /// - /// Constructs an instance of RDBeat with the specified time span. - /// - /// The total amount of time from the start of the level to the moment. - /// Thrown when the time span is less than zero. - public RDBeat(TimeSpan timeSpan) - { - this = default; - if (timeSpan < TimeSpan.Zero) - throw new OverflowException(string.Format("The time must not be less than zero, but {0} is given", timeSpan)); - _TimeSpan = timeSpan; - _isTimeSpanLoaded = true; - } - /// - /// Construct an instance with specifying a calculator. - /// - /// Specified calculator. - /// The total number of beats from this moment to the beginning of the level. - public RDBeat(BeatCalculator? calculator, float beatOnly) - { - this = new RDBeat(beatOnly); - _calculator = calculator; - } - /// - /// Construct an instance with specifying a calculator. - /// - /// Specified calculator. - /// The actual bar of this moment. - /// The actual beat of this moment. - public RDBeat(BeatCalculator calculator, uint bar, float beat) - { - this = new RDBeat(bar, beat); - _calculator = calculator; - _beat = _calculator.BarBeatToBeatOnly(bar, beat) - 1f; - } - /// - /// Construct an instance with specifying a calculator. - /// - /// Specified calculator. - /// The total amount of time from the start of the level to the moment - public RDBeat(BeatCalculator calculator, TimeSpan timeSpan) - { - this = new RDBeat(timeSpan); - _calculator = calculator; - _beat = _calculator.TimeSpanToBeatOnly(timeSpan) - 1f; - } - /// - /// Construct an instance with specifying a calculator. - /// - /// Specified calculator. - /// Another instance. - public RDBeat(BeatCalculator calculator, RDBeat beat) - { - this = default; - if (beat._isBeatLoaded) - { - if (beat._beat < 0f) - throw new OverflowException(string.Format("The beat must not be less than 1, but {0} is given", beat._beat)); - _beat = beat._beat; - _isBeatLoaded = true; - _calculator = calculator; - } - else if (beat._isBarBeatLoaded) - { - if (beat._BarBeat.Bar < 1) - throw new OverflowException(string.Format("The bar must not be less than 1, but {0} is given", beat._BarBeat.Bar)); - if (beat._BarBeat.Beat < 1) - throw new OverflowException(string.Format("The beat must not be less than 1, but {0} is given", beat._BarBeat.Beat)); - _BarBeat = beat._BarBeat; - _isBarBeatLoaded = true; - _calculator = calculator; - _beat = _calculator.BarBeatToBeatOnly(beat._BarBeat.Bar, beat._BarBeat.Beat) - 1f; - } - else if (beat._isTimeSpanLoaded) - { - if (beat._TimeSpan < TimeSpan.Zero) - throw new OverflowException(string.Format("The time must not be less than zero, but {0} is given", beat._TimeSpan)); - _TimeSpan = beat._TimeSpan; - _isTimeSpanLoaded = true; - _calculator = calculator; - _beat = _calculator.TimeSpanToBeatOnly(TimeSpan) - 1f; - } - } - /// - /// Construct a beat of the 1st beat from the calculator - /// - /// Specified calculator. - /// The first beat tied to the level. - public static RDBeat Default(BeatCalculator calculator) - { - RDBeat Default = new(calculator, 1f); - return Default; - } - /// - /// Determine if two beats come from the same level - /// - /// A beat. - /// Another beat. - /// If true, an exception will be thrown when two beats do not come from the same level. - /// - public static bool FromSameLevel(RDBeat a, RDBeat b, bool @throw = false) => - (a._calculator?.Equals(b._calculator) ?? true) - || (@throw ? throw new RhythmBaseException("Beats must come from the same RDLevel.") : false); - /// - /// Determine if two beats are from the same level. - ///
- /// If any of them does not come from any level, it will also return true. - ///
- /// A beat. - /// Another beat. - /// If true, an exception will be thrown when two beats do not come from the same level. - /// - public static bool FromSameLevelOrNull(RDBeat a, RDBeat b, bool @throw = false) => a._calculator == null || b._calculator == null || FromSameLevel(a, b, @throw); - /// - /// Determine if two beats are from the same level. - /// - /// Another beat. - /// If true, an exception will be thrown when two beats do not come from the same level. - /// - [MemberNotNullWhen(true)] - public readonly bool FromSameLevel(RDBeat b, bool @throw = false) => FromSameLevel(this, b, @throw); - /// - /// Determine if two beats are from the same level. - ///
- /// If any of them does not come from any level, it will also return true. - ///
- /// Another beat. - /// If true, an exception will be thrown when two beats do not come from the same level. - /// - public readonly bool FromSameLevelOrNull(RDBeat b, bool @throw = false) => BaseLevel == null || b.BaseLevel == null || FromSameLevel(b, @throw); - /// - /// Returns a new instance of unbinding the level. - /// - /// A new instance of unbinding the level. - public readonly RDBeat WithoutBinding() - { - RDBeat result = this; - if (result._calculator != null) - result.Cache(); - result._calculator = null; - return result; - } - /// - /// 校验这个实例是否缺少在转换单位时必需的参数并抛出异常 - /// - /// - internal readonly void IfNullThrowException() - { - if (IsEmpty) - { - throw new InvalidRDBeatException(); - } - } - /// - /// Refresh the cache. - /// - public void ResetCache() - { - object __ = BeatOnly; - _isBarBeatLoaded = false; - _isTimeSpanLoaded = false; - } - /// - /// Caches the current state of the beat by accessing its properties. - /// - /// Thrown when the beat cannot be calculated. - public void Cache() - { - IfNullThrowException(); - object __ = BeatOnly; - __ = BarBeat; - __ = TimeSpan; - } - /// - /// - /// - internal void ResetBPM() - { - if (!_isBeatLoaded) - _beat = (_calculator?.TimeSpanToBeatOnly(_TimeSpan) - 1f) ?? throw new InvalidRDBeatException(); - _isBeatLoaded = true; - _isTimeSpanLoaded = false; - _isBPMLoaded = false; - } - internal void ResetCPB() - { - if (!_isBeatLoaded) - _beat = (_calculator?.BarBeatToBeatOnly(_BarBeat.Bar, _BarBeat.Beat) - 1f) ?? throw new InvalidRDBeatException(); - _isBeatLoaded = true; - _isBarBeatLoaded = false; - _isCPBLoaded = false; - } - /// - public static RDBeat operator +(RDBeat a, float b) - { - RDBeat result; - if (!a.IsEmpty) - result = new RDBeat(a._calculator, a.BeatOnly + b); - else - { - if (!a._isBeatLoaded) - throw new ArgumentNullException(nameof(a), "The beat cannot be calculate."); - result = new RDBeat(a._beat + b); - } - return result; - } - /// - public static RDBeat operator +(RDBeat a, TimeSpan b) - { - RDBeat result; - if (!a.IsEmpty) - result = new RDBeat(a._calculator, a.TimeSpan + b); - else - { - if (!a._isBeatLoaded) - throw new ArgumentNullException(nameof(a), "The beat cannot be calculate."); - result = new RDBeat(a._TimeSpan + b); - } - return result; - } - /// - public static RDBeat operator -(RDBeat a, float b) - { - RDBeat result; - if (!a.IsEmpty) - result = new RDBeat(a._calculator, a.BeatOnly - b); - else - { - if (!a._isBeatLoaded) - throw new ArgumentNullException(nameof(a), "The beat cannot be calculate."); - result = new RDBeat(a._beat - b); - } - return result; - } - /// - public static RDBeat operator -(RDBeat a, TimeSpan b) - { - RDBeat result; - if (!a.IsEmpty) - result = new RDBeat(a._calculator, a.TimeSpan - b); - else - { - if (!a._isBeatLoaded) - throw new ArgumentNullException(nameof(a), "The beat cannot be calculate."); - result = new RDBeat(a._TimeSpan - b); - } - return result; - } - /// - public static bool operator >(RDBeat a, RDBeat b) => FromSameLevel(a, b, true) && a.BeatOnly > b.BeatOnly; - /// - public static bool operator <(RDBeat a, RDBeat b) => FromSameLevel(a, b, true) && a.BeatOnly < b.BeatOnly; - /// - public static bool operator >=(RDBeat a, RDBeat b) => FromSameLevel(a, b, true) && a.BeatOnly >= b.BeatOnly; - /// - public static bool operator <=(RDBeat a, RDBeat b) => FromSameLevel(a, b, true) && a.BeatOnly <= b.BeatOnly; - /// - public static bool operator ==(RDBeat a, RDBeat b) => (FromSameLevel(a, b, true) && a._beat == b._beat) || (a._isBarBeatLoaded && b._isBarBeatLoaded && a._BarBeat.Bar == b._BarBeat.Bar && a._BarBeat.Beat == b._BarBeat.Beat) || (a._isTimeSpanLoaded && b._isTimeSpanLoaded && a._TimeSpan == b._TimeSpan) || a.BeatOnly == b.BeatOnly; - /// - public static bool operator !=(RDBeat a, RDBeat b) => !(a == b); - /// - public override string ToString() - { - string ToString; - if (IsEmpty) - ToString = string.Format("[{0},{1},{2}]", _isBeatLoaded ? _beat.ToString() : "?", _isBarBeatLoaded ? _BarBeat.ToString() : "?", _isTimeSpanLoaded ? _TimeSpan.ToString() : "?"); - else - ToString = string.Format("[{0},{1}]", BarBeat.bar, BarBeat.beat); - return ToString; - } - /// - public readonly override bool Equals([NotNullWhen(true)] object? obj) => obj is RDBeat e && Equals(e); - /// - public readonly bool Equals(RDBeat other) => this == other; - /// - public override int GetHashCode() => HashCode.Combine(BeatOnly, BaseLevel); - /// - public int CompareTo(RDBeat other) - { - float result = BeatOnly - other.BeatOnly; - int CompareTo; - if (result > 0f) - CompareTo = 1; - else if (result < 0f) - CompareTo = -1; - else - CompareTo = 0; - return CompareTo; - } - internal BeatCalculator? _calculator; - private bool _isBeatLoaded; - private bool _isBarBeatLoaded; - private bool _isTimeSpanLoaded; - private bool _isBPMLoaded; - private bool _isCPBLoaded; - private float _beat; - private (uint Bar, float Beat) _BarBeat; - private TimeSpan _TimeSpan; - private float _BPM; - private uint _CPB; - } -} diff --git a/RhythmBaseCore/Components/RDCharacter.cs b/RhythmBaseCore/Components/RDCharacter.cs deleted file mode 100644 index 2d5e23e..0000000 --- a/RhythmBaseCore/Components/RDCharacter.cs +++ /dev/null @@ -1,52 +0,0 @@ - -namespace RhythmBase.Components; - -/// -/// A Character. -/// -public readonly struct RDCharacter -{ - /// - /// Whether in-game character or customized character(sprite). - /// - public bool IsCustom { get; } - /// - /// In-game character. - ///
- /// If using a customized character, this value will be empty - ///
- public RDCharacters? Character { get; } - /// - /// Customized character(sprite). - ///
- /// If using an in-game character, this value will be empty - ///
- public string? CustomCharacter { get; } - /// - /// Construct an in-game character. - /// - /// Character type. - public RDCharacter(RDCharacters character) - { - IsCustom = false; - Character = character; - } - /// - /// Construct a customized character. - /// - /// A sprite. - public RDCharacter(string character) - { - IsCustom = true; - CustomCharacter = character; - } - /// - public static implicit operator RDCharacter(RDCharacters character) => new(character); - /// - public static implicit operator RDCharacter(string character) => new(character); - /// - public override readonly string ToString() => (IsCustom - ? (CustomCharacter) - : Character?.ToString()) - ?? "[Null]"; -} diff --git a/RhythmBaseCore/Components/RDCharacters.cs b/RhythmBaseCore/Components/RDCharacters.cs deleted file mode 100644 index 5cee747..0000000 --- a/RhythmBaseCore/Components/RDCharacters.cs +++ /dev/null @@ -1,96 +0,0 @@ -namespace RhythmBase.Components -{ - /// - /// In-game character. - /// - public enum RDCharacters - { -#pragma warning disable CS1591 - Adog, - Allison, - Athlete, - AthletePhysio, - Barista, - Beat, -#if DEBUG - BlankCPU, -#endif - Bodybuilder, - Boy, - BoyRaya, - BoyTangzhuang, - Buro, -#if DEBUG - Canary, -#endif - Clef, - Cockatiel, - ColeGuitar, - ColeSynth, - Controller, -#if DEBUG - Custom, -#endif - DancingCouple, - Edega, - Farmer, - FarmerAlternate, - Girl, - GirlCNY, - HoodieBoy, - HoodieBoyAlternate, - HoodieBoyBlue, - Ian, - IanBubble, - Janitor, - Kanye, - Lucia, - LuckyBag, - LuckyBaseball, - LuckyIce, -#if DEBUG - LuckyJersey, -#endif - Lune, - Marija, - Miner, - MrsStevendog, - MrsStevenson, - MrStevendog, - MrStevenson, - NicoleCigs, - NicoleCoffee, - NicoleMints, - None, - Oriole, -#if DEBUG - Otto, -#endif - Owl, - Paige, - Parrot, - Player, - Politician, - Purritician, - Quaver, - Rin, - Rodney, - Saturday, - Samurai, - SamuraiBaseball, - SamuraiBlue, - SamuraiBoss, - SamuraiBossAlt, - SamuraiGirl, - SamuraiGreen, - SamuraiPirate, - SamuraiYellow, - SmokinBarista, - Tentacle, - Treble, - Weeknd, -#if DEBUG - Wren -#endif - } -} diff --git a/RhythmBaseCore/Components/RDColor.cs b/RhythmBaseCore/Components/RDColor.cs deleted file mode 100644 index f1181c2..0000000 --- a/RhythmBaseCore/Components/RDColor.cs +++ /dev/null @@ -1,1420 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Numerics; - -namespace RhythmBase.Components -{ - /// - /// Represents a color with red, green, blue, and alpha components. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDColor(uint hex) : - IEqualityOperators, - IEquatable, IFormattable - { - /// - /// #AARRGGBB - /// - private uint color = hex; - /// - /// Gets or sets the alpha component of the color. - /// - public byte A - { - readonly get => (byte)((color >> 24) & 0xFFu); - set => color = (color & 0x00FFFFFFu) | ((uint)value << 24); - } - /// - /// Gets or sets the red component of the color. - /// - public byte R - { - readonly get => (byte)((color >> 16) & 0xFFu); - set => color = (color & 0xFF00FFFFu) | ((uint)value << 16); - } - /// - /// Gets or sets the green component of the color. - /// - public byte G - { - readonly get => (byte)((color >> 8) & 0xFFu); - set => color = (color & 0xFFFF00FFu) | ((uint)value << 8); - } - /// - /// Gets or sets the blue component of the color. - /// - public byte B - { - readonly get => (byte)(color & 0xFFu); - set => color = (color & 0xFFFFFF00u) | value; - } - /// - /// Returns a new RDColor instance with the specified alpha value. - /// - /// The alpha value to set. - /// A new RDColor instance with the specified alpha value. - public readonly RDColor WithAlpha(byte alpha) => new((color & 0x00FFFFFFu) | ((uint)alpha << 24)); - /// - /// Returns a new RDColor instance with the specified red value. - /// - /// The red value to set. - /// A new RDColor instance with the specified red value. - public readonly RDColor WithRed(byte red) => new((color & 0xFF00FFFFu) | ((uint)red << 16)); - /// - /// Returns a new RDColor instance with the specified green value. - /// - /// The green value to set. - /// A new RDColor instance with the specified green value. - public readonly RDColor WithGreen(byte green) => new((color & 0xFFFF00FFu) | ((uint)green << 8)); - /// - /// Returns a new RDColor instance with the specified blue value. - /// - /// The blue value to set. - /// A new RDColor instance with the specified blue value. - public readonly RDColor WithBlue(byte blue) => new((color & 0xFFFFFF00u) | blue); - /// - /// Converts the color to HSL (Hue, Saturation, Lightness) color space. - /// - /// The hue component. - /// The saturation component. - /// The lightness component. - public readonly void ToHsl(out float h, out float s, out float l) - { - float r = this.R / 255f; - float g = this.G / 255f; - float b = this.B / 255f; - - float max = Math.Max(r, Math.Max(g, b)); - float min = Math.Min(r, Math.Min(g, b)); - float delta = max - min; - - h = 0; - if (delta != 0) - { - if (max == r) - { - h = (g - b) / delta + (g < b ? 6 : 0); - } - else if (max == g) - { - h = (b - r) / delta + 2; - } - else - { - h = (r - g) / delta + 4; - } - h /= 6; - } - - l = (max + min) / 2; - s = delta == 0 ? 0 : delta / (1 - Math.Abs(2 * l - 1)); - - h *= 360; - s *= 100; - l *= 100; - } - /// - /// Converts the color to HSV (Hue, Saturation, Value) color space. - /// - /// The hue component. - /// The saturation component. - /// The value component. - public readonly void ToHsv(out float h, out float s, out float v) - { - float r = this.R / 255f; - float g = this.G / 255f; - float b = this.B / 255f; - - float max = Math.Max(r, Math.Max(g, b)); - float min = Math.Min(r, Math.Min(g, b)); - float delta = max - min; - - h = 0f; - if (delta != 0) - { - if (max == r) - { - h = (g - b) / delta + (g < b ? 6 : 0); - } - else if (max == g) - { - h = (b - r) / delta + 2; - } - else if (max == b) - { - h = (r - g) / delta + 4; - } - h /= 6; - } - - s = max == 0 ? 0 : delta / max; - v = max; - - h *= 360; - s *= 100; - v *= 100; - } - - /// - /// Creates an RDColor instance from RGBA values. - /// - /// Red component - /// Green component - /// Blue component - /// Alpha component (default is 255) - /// RDColor instance - public static RDColor FromRgba(byte r, byte g, byte b, byte a = 255) => new((uint)(a << 24 | r << 16 | g << 8 | b)); - /// - /// Creates an RDColor instance from a hexadecimal string. - /// Supports hexadecimal strings of length 3, 4, 6, or 8. - /// - /// Hexadecimal string - /// RDColor instance - /// Thrown when the hexadecimal string length is not 3, 4, 6, or 8 - public static RDColor FromRgba(string hex) - { - if (TryFromRgba(hex, out RDColor color)) - return color; - throw new ArgumentException("Hex string must be 3, 4, 6, or 8 characters long."); - } - /// - /// Tries to create an RDColor instance from a hexadecimal string. - /// Supports hexadecimal strings of length 3, 4, 6, or 8. - /// - /// The hexadecimal string representing the color. - /// When this method returns, contains the RDColor instance created from the hexadecimal string, if the conversion succeeded, or the default value if the conversion failed. - /// true if the hexadecimal string was converted successfully; otherwise, false. - public static bool TryFromRgba(string hex, [MaybeNullWhen(false)] out RDColor color) - { - hex = hex.Trim(); - if (hex.StartsWith('#')) - hex = hex[1..]; - string? hex2 = hex.Length switch - { - 3 => $"FF{hex[0]}{hex[0]}{hex[1]}{hex[1]}{hex[2]}{hex[2]}", - 4 => $"{hex[3]}{hex[3]}{hex[0]}{hex[0]}{hex[1]}{hex[1]}{hex[2]}{hex[2]}", - 6 => $"FF{hex}", - 8 => $"{hex[6..8]}{hex[0..6]}", - _ => null, - }; - if (hex2 is null) - { - color = default; - return false; - } - color = new RDColor(Convert.ToUInt32(hex2, 16)); - return true; - } - /// - /// Creates an RDColor instance from a 32-bit RGBA value. - /// - /// The 32-bit RGBA value. - /// A new RDColor instance. - public static RDColor FromRgba(uint hex) - { - uint argb = (hex & 0x00FFFFFFu) | ((hex & 0xFFu) << 24); - return new RDColor(argb); - } - /// - /// Creates an RDColor instance from ARGB values. - /// - /// Alpha component - /// Red component - /// Green component - /// Blue component - /// RDColor instance - public static RDColor FromArgb(byte a, byte r, byte g, byte b) => new((uint)(a << 24 | r << 16 | g << 8 | b)); - /// - /// Creates an RDColor instance from a hexadecimal string in ARGB format. - /// Supports hexadecimal strings of length 3, 4, 6, or 8. - /// - /// Hexadecimal string - /// RDColor instance - /// Thrown when the hexadecimal string length is not 3, 4, 6, or 8 - public static RDColor FromArgb(string hex) - { - hex = hex.Trim(); - if (hex.StartsWith('#')) - hex = hex[1..]; - - hex = hex.Length switch - { - 3 => $"FF{hex[0]}{hex[0]}{hex[1]}{hex[1]}{hex[2]}{hex[2]}", - 4 => $"{hex[0]}{hex[0]}{hex[1]}{hex[1]}{hex[2]}{hex[2]}{hex[3]}{hex[3]}", - 6 => $"FF{hex}", - 8 => hex, - _ => throw new ArgumentException("Hex string must be 3, 4, 6, or 8 characters long."), - }; - - return new RDColor(Convert.ToUInt32(hex, 16)); - } - /// - /// Tries to create an RDColor instance from a hexadecimal string. - /// Supports hexadecimal strings of length 3, 4, 6, or 8. - /// - /// The hexadecimal string representing the color. - /// When this method returns, contains the RDColor instance created from the hexadecimal string, if the conversion succeeded, or the default value if the conversion failed. - /// true if the hexadecimal string was converted successfully; otherwise, false. - public static bool TryFromArgb(string hex, [MaybeNullWhen(false)] out RDColor color) - { - hex = hex.Trim(); - if (hex.StartsWith('#')) - hex = hex[1..]; - string? hex2 = hex.Length switch - { - 3 => $"FF{hex[0]}{hex[0]}{hex[1]}{hex[1]}{hex[2]}{hex[2]}", - 4 => $"{hex[0]}{hex[0]}{hex[1]}{hex[1]}{hex[2]}{hex[2]}{hex[3]}{hex[3]}", - 6 => $"FF{hex}", - 8 => hex, - _ => null, - }; - if (hex2 is null) - { - color = default; - return false; - } - color = new RDColor(Convert.ToUInt32(hex2, 16)); - return true; - } - /// - /// Creates an instance from a 32-bit ARGB value. - /// - /// The 32-bit ARGB value. - /// A new instance. - public static RDColor FromArgb(uint hex) => new(hex); - /// - /// Creates an RDColor object from the HSL color space. - /// - /// Hue (0-360) - /// Saturation (0-1) - /// Lightness (0-1) - /// Alpha (0-255) - /// Corresponding RDColor object - public static RDColor FromHsl(float h, float s, float l, byte a = 255) - { - h /= 360; - s /= 100; - l /= 100; - float r, g, b; - if (s == 0) - { - r = g = b = l; // achromatic - } - else - { - static float hue2rgb(float p, float q, float t) - { - if (t < 0) t += 1; - if (t > 1) t -= 1; - if (t < 1 / 6.0) return p + (q - p) * 6 * t; - if (t < 1 / 2.0) return q; - if (t < 2 / 3.0) return p + (q - p) * (2 / 3.0f - t) * 6; - return p; - } - - float q = l < 0.5 ? l * (1 + s) : l + s - l * s; - float p = 2 * l - q; - r = hue2rgb(p, q, h + 1 / 3.0f); - g = hue2rgb(p, q, h); - b = hue2rgb(p, q, h - 1 / 3.0f); - } - - return new RDColor((uint)(a << 24 | (int)(r * 255) << 16 | (int)(g * 255) << 8 | (int)(b * 255))); - } - /// - /// Creates an RDColor object from HSV values. - /// - /// Hue (0-360) - /// Saturation (0-1) - /// Value (0-1) - /// Alpha (0-255) - /// Returns an RDColor object. - public static RDColor FromHsv(float h, float s, float v, byte a = 255) - { - h /= 360; - s /= 100; - v /= 100; - - int hi = (int)(h * 6); - float f = h * 6 - hi; - float p = v * (1 - s); - float q = v * (1 - f * s); - float t = v * (1 - (1 - f) * s); - - float r = 0, g = 0, b = 0; - switch (hi % 6) - { - case 0: r = v; g = t; b = p; break; - case 1: r = q; g = v; b = p; break; - case 2: r = p; g = v; b = t; break; - case 3: r = p; g = q; b = v; break; - case 4: r = t; g = p; b = v; break; - case 5: r = v; g = p; b = q; break; - } - - return new RDColor((uint)(a << 24 | (int)(r * 255) << 16 | (int)(g * 255) << 8 | (int)(b * 255))); - } - /// - /// Creates an RDColor instance from a color name. - /// - /// The name of the color. - /// An RDColor instance corresponding to the specified color name. - /// Thrown when the color name is invalid. - public static RDColor FromName(string name) - { - if (TryFromName(name, out RDColor color)) - return color; - throw new ArgumentException($"Invalid color name: {name}."); - } - /// - /// Tries to create an RDColor instance from a color name. - /// - /// The name of the color. - /// When this method returns, contains the RDColor instance created from the color name, if the conversion succeeded, or the default value if the conversion failed. - /// true if the color name was converted successfully; otherwise, false. - public static bool TryFromName(string name, [MaybeNullWhen(false)] out RDColor color) - { - RDColor? color2 = name.ToLower() switch - { - "aliceblue" => AliceBlue, - "antiquewhite" => AntiqueWhite, - "aqua" => Aqua, - "aquamarine" => Aquamarine, - "azure" => Azure, - "beige" => Beige, - "bisque" => Bisque, - "black" => Black, - "blanchedalmond" => BlanchedAlmond, - "blue" => Blue, - "blueviolet" => BlueViolet, - "brown" => Brown, - "burlywood" => BurlyWood, - "cadetblue" => CadetBlue, - "chartreuse" => Chartreuse, - "chocolate" => Chocolate, - "coral" => Coral, - "cornflowerblue" => CornflowerBlue, - "cornsilk" => Cornsilk, - "crimson" => Crimson, - "cyan" => Cyan, - "darkblue" => DarkBlue, - "darkcyan" => DarkCyan, - "darkgoldenrod" => DarkGoldenrod, - "darkgray" => DarkGray, - "darkgreen" => DarkGreen, - "darkkhaki" => DarkKhaki, - "darkmagenta" => DarkMagenta, - "darkolivegreen" => DarkOliveGreen, - "darkorange" => DarkOrange, - "darkorchid" => DarkOrchid, - "darkred" => DarkRed, - "darksalmon" => DarkSalmon, - "darkseagreen" => DarkSeaGreen, - "darkslateblue" => DarkSlateBlue, - "darkslategray" => DarkSlateGray, - "darkturquoise" => DarkTurquoise, - "darkviolet" => DarkViolet, - "deeppink" => DeepPink, - "deepskyblue" => DeepSkyBlue, - "dimgray" => DimGray, - "dodgerblue" => DodgerBlue, - "firebrick" => Firebrick, - "floralwhite" => FloralWhite, - "forestgreen" => ForestGreen, - "fuchsia" => Fuchsia, - "gainsboro" => Gainsboro, - "ghostwhite" => GhostWhite, - "gold" => Gold, - "goldenrod" => Goldenrod, - "gray" => Gray, - "green" => Green, - "greenyellow" => GreenYellow, - "honeydew" => Honeydew, - "hotpink" => HotPink, - "indianred" => IndianRed, - "indigo" => Indigo, - "ivory" => Ivory, - "khaki" => Khaki, - "lavender" => Lavender, - "lavenderblush" => LavenderBlush, - "lawngreen" => LawnGreen, - "lemonchiffon" => LemonChiffon, - "lightblue" => LightBlue, - "lightcoral" => LightCoral, - "lightcyan" => LightCyan, - "lightgoldenrodyellow" => LightGoldenrodYellow, - "lightgray" => LightGray, - "lightgreen" => LightGreen, - "lightpink" => LightPink, - "lightsalmon" => LightSalmon, - "lightseagreen" => LightSeaGreen, - "lightskyblue" => LightSkyBlue, - "lightslategray" => LightSlateGray, - "lightsteelblue" => LightSteelBlue, - "lightyellow" => LightYellow, - "lime" => Lime, - "limegreen" => LimeGreen, - "linen" => Linen, - "magenta" => Magenta, - "maroon" => Maroon, - "mediumaquamarine" => MediumAquamarine, - "mediumblue" => MediumBlue, - "mediumorchid" => MediumOrchid, - "mediumpurple" => MediumPurple, - "mediumseagreen" => MediumSeaGreen, - "mediumslateblue" => MediumSlateBlue, - "mediumspringgreen" => MediumSpringGreen, - "mediumturquoise" => MediumTurquoise, - "mediumvioletred" => MediumVioletRed, - "midnightblue" => MidnightBlue, - "mintcream" => MintCream, - "mistyrose" => MistyRose, - "moccasin" => Moccasin, - "navajowhite" => NavajoWhite, - "navy" => Navy, - "oldlace" => OldLace, - "olive" => Olive, - "olivedrab" => OliveDrab, - "orange" => Orange, - "orangered" => OrangeRed, - "orchid" => Orchid, - "palegoldenrod" => PaleGoldenrod, - "palegreen" => PaleGreen, - "paleturquoise" => PaleTurquoise, - "palevioletred" => PaleVioletRed, - "papayawhip" => PapayaWhip, - "peachpuff" => PeachPuff, - "peru" => Peru, - "pink" => Pink, - "plum" => Plum, - "powderblue" => PowderBlue, - "purple" => Purple, - "red" => Red, - "rosybrown" => RosyBrown, - "royalblue" => RoyalBlue, - "saddlebrown" => SaddleBrown, - "salmon" => Salmon, - "sandybrown" => SandyBrown, - "seagreen" => SeaGreen, - "seashell" => SeaShell, - "sienna" => Sienna, - "silver" => Silver, - "skyblue" => SkyBlue, - "slateblue" => SlateBlue, - "slategray" => SlateGray, - "snow" => Snow, - "springgreen" => SpringGreen, - "steelblue" => SteelBlue, - "tan" => Tan, - "teal" => Teal, - "thistle" => Thistle, - "tomato" => Tomato, - "turquoise" => Turquoise, - "violet" => Violet, - "wheat" => Wheat, - "white" => White, - "whitesmoke" => WhiteSmoke, - "yellow" => Yellow, - "yellowgreen" => YellowGreen, - "transparent" => Transparent, - "empty" => Empty, - _ => null, - }; - if (color2 is null) - { - color = default; - return false; - } - color = color2.Value; - return true; - } - /// - /// Tries to get the name(s) of the color. - /// - /// When this method returns, contains the name(s) of the color if the conversion succeeded, or an empty array if the conversion failed. - /// true if the color name(s) were found; otherwise, false. - /// - /// For colors with multiple names, the CMYK name is preferred. - /// - public readonly bool TryGetName([NotNullWhen(true)] out string[] names) - { - names = color switch - { - 4293982463u => ["AliceBlue"], - 4294634455u => ["AntiqueWhite"], - 4278255615u => ["Cyan", "Aqua"], - 4286578644u => ["Aquamarine"], - 4293984255u => ["Azure"], - 4294309340u => ["Beige"], - 4294960324u => ["Bisque"], - 4278190080u => ["Black"], - 4294962125u => ["BlanchedAlmond"], - 4278190335u => ["Blue"], - 4287245282u => ["BlueViolet"], - 4289014314u => ["Brown"], - 4292786311u => ["BurlyWood"], - 4284456608u => ["CadetBlue"], - 4286578432u => ["Chartreuse"], - 4291979550u => ["Chocolate"], - 4294934352u => ["Coral"], - 4284782061u => ["CornflowerBlue"], - 4294965468u => ["Cornsilk"], - 4292613180u => ["Crimson"], - 4278190219u => ["DarkBlue"], - 4278225803u => ["DarkCyan"], - 4290283019u => ["DarkGoldenrod"], - 4289309097u => ["DarkGray"], - 4278215680u => ["DarkGreen"], - 4290623339u => ["DarkKhaki"], - 4287299723u => ["DarkMagenta"], - 4283788079u => ["DarkOliveGreen"], - 4294937600u => ["DarkOrange"], - 4288230092u => ["DarkOrchid"], - 4287299584u => ["DarkRed"], - 4293498490u => ["DarkSalmon"], - 4287609995u => ["DarkSeaGreen"], - 4282924427u => ["DarkSlateBlue"], - 4281290575u => ["DarkSlateGray"], - 4278243025u => ["DarkTurquoise"], - 4287889619u => ["DarkViolet"], - 4294907027u => ["DeepPink"], - 4278239231u => ["DeepSkyBlue"], - 4285098345u => ["DimGray"], - 4280193279u => ["DodgerBlue"], - 4289864226u => ["Firebrick"], - 4294966000u => ["FloralWhite"], - 4280453922u => ["ForestGreen"], - 4294902015u => ["Magenta", "Fuchsia"], - 4292664540u => ["Gainsboro"], - 4294506751u => ["GhostWhite"], - 4294956800u => ["Gold"], - 4292519200u => ["Goldenrod"], - 4286611584u => ["Gray"], - 4278222848u => ["Green"], - 4289593135u => ["GreenYellow"], - 4293984240u => ["Honeydew"], - 4294928820u => ["HotPink"], - 4291648604u => ["IndianRed"], - 4283105410u => ["Indigo"], - 4294967280u => ["Ivory"], - 4293977740u => ["Khaki"], - 4293322490u => ["Lavender"], - 4294963445u => ["LavenderBlush"], - 4286381056u => ["LawnGreen"], - 4294965965u => ["LemonChiffon"], - 4289583334u => ["LightBlue"], - 4293951616u => ["LightCoral"], - 4292935679u => ["LightCyan"], - 4294638290u => ["LightGoldenrodYellow"], - 4292072403u => ["LightGray"], - 4287688336u => ["LightGreen"], - 4294948545u => ["LightPink"], - 4294942842u => ["LightSalmon"], - 4280332970u => ["LightSeaGreen"], - 4287090426u => ["LightSkyBlue"], - 4286023833u => ["LightSlateGray"], - 4289774814u => ["LightSteelBlue"], - 4294967264u => ["LightYellow"], - 4278255360u => ["Lime"], - 4281519410u => ["LimeGreen"], - 4294635750u => ["Linen"], - 4286578688u => ["Maroon"], - 4284927402u => ["MediumAquamarine"], - 4278190285u => ["MediumBlue"], - 4290401747u => ["MediumOrchid"], - 4287852763u => ["MediumPurple"], - 4282168177u => ["MediumSeaGreen"], - 4286277870u => ["MediumSlateBlue"], - 4278254234u => ["MediumSpringGreen"], - 4282962380u => ["MediumTurquoise"], - 4291237253u => ["MediumVioletRed"], - 4279834992u => ["MidnightBlue"], - 4294311930u => ["MintCream"], - 4294960353u => ["MistyRose"], - 4294960309u => ["Moccasin"], - 4294958765u => ["NavajoWhite"], - 4278190208u => ["Navy"], - 4294833638u => ["OldLace"], - 4286611456u => ["Olive"], - 4285238819u => ["OliveDrab"], - 4294944000u => ["Orange"], - 4294919424u => ["OrangeRed"], - 4292505814u => ["Orchid"], - 4293847210u => ["PaleGoldenrod"], - 4288215960u => ["PaleGreen"], - 4289720046u => ["PaleTurquoise"], - 4292571283u => ["PaleVioletRed"], - 4294963157u => ["PapayaWhip"], - 4294957753u => ["PeachPuff"], - 4291659071u => ["Peru"], - 4294951115u => ["Pink"], - 4292714717u => ["Plum"], - 4289781990u => ["PowderBlue"], - 4286578816u => ["Purple"], - 4294901760u => ["Red"], - 4290547599u => ["RosyBrown"], - 4282477025u => ["RoyalBlue"], - 4287317267u => ["SaddleBrown"], - 4294606962u => ["Salmon"], - 4294222944u => ["SandyBrown"], - 4281240407u => ["SeaGreen"], - 4294964718u => ["SeaShell"], - 4288696877u => ["Sienna"], - 4290822336u => ["Silver"], - 4287090411u => ["SkyBlue"], - 4285160141u => ["SlateBlue"], - 4285563024u => ["SlateGray"], - 4294966010u => ["Snow"], - 4278255487u => ["SpringGreen"], - 4282811060u => ["SteelBlue"], - 4291998860u => ["Tan"], - 4278222976u => ["Teal"], - 4292394968u => ["Thistle"], - 4294927175u => ["Tomato"], - 4282441936u => ["Turquoise"], - 4293821166u => ["Violet"], - 4294303411u => ["Wheat"], - uint.MaxValue => ["White"], - 4294309365u => ["WhiteSmoke"], - 4294967040u => ["Yellow"], - 4288335154u => ["YellowGreen"], - 16777215u => ["Transparent"], - 0u => ["Empty"], - _ => [], - }; - if (names.Length == 0) - return false; - return true; - } - /// - public static bool operator ==(RDColor left, RDColor right) => left.color == right.color; - /// - public static bool operator !=(RDColor left, RDColor right) => left.color != right.color; - /// - public override readonly string ToString() => ToString("#AARRGGBB"); - private readonly string GetDebuggerDisplay() => ToString(); - /// - public readonly bool Equals(RDColor other) => color == other.color; - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDColor e && Equals(e); - /// - public override readonly int GetHashCode() => color.GetHashCode(); - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) => - (formatProvider ?? new RDColorFormatInfo()).GetFormat(typeof(ICustomFormatter)) is ICustomFormatter formatter - ? formatter.Format(format, this, formatProvider) - : ToString(); - /// - public readonly string ToString(string? format) => ToString(format, null); - - /// - ///Gets the predefined color of alice blue, or #FFF0F8FF. - /// - public static readonly RDColor AliceBlue = new(4293982463u); - - /// - ///Gets the predefined color of antique white, or #FFFAEBD7. - /// - public static readonly RDColor AntiqueWhite = new(4294634455u); - - /// - ///Gets the predefined color of aqua, or #FF00FFFF. - /// - public static readonly RDColor Aqua = new(4278255615u); - - /// - ///Gets the predefined color of aquamarine, or #FF7FFFD4. - /// - public static readonly RDColor Aquamarine = new(4286578644u); - - /// - ///Gets the predefined color of azure, or #FFF0FFFF. - /// - public static readonly RDColor Azure = new(4293984255u); - - /// - ///Gets the predefined color of beige, or #FFF5F5DC. - /// - public static readonly RDColor Beige = new(4294309340u); - - /// - ///Gets the predefined color of bisque, or #FFFFE4C4. - /// - public static readonly RDColor Bisque = new(4294960324u); - - /// - ///Gets the predefined color of black, or #FF000000. - /// - public static readonly RDColor Black = new(4278190080u); - - /// - ///Gets the predefined color of blanched almond, or #FFFFEBCD. - /// - public static readonly RDColor BlanchedAlmond = new(4294962125u); - - /// - ///Gets the predefined color of blue, or #FF0000FF. - /// - public static readonly RDColor Blue = new(4278190335u); - - /// - ///Gets the predefined color of blue violet, or #FF8A2BE2. - /// - public static readonly RDColor BlueViolet = new(4287245282u); - - /// - ///Gets the predefined color of brown, or #FFA52A2A. - /// - public static readonly RDColor Brown = new(4289014314u); - - /// - ///Gets the predefined color of burly wood, or #FFDEB887. - /// - public static readonly RDColor BurlyWood = new(4292786311u); - - /// - ///Gets the predefined color of cadet blue, or #FF5F9EA0. - /// - public static readonly RDColor CadetBlue = new(4284456608u); - - /// - ///Gets the predefined color of chartreuse, or #FF7FFF00. - /// - public static readonly RDColor Chartreuse = new(4286578432u); - - /// - ///Gets the predefined color of chocolate, or #FFD2691E. - /// - public static readonly RDColor Chocolate = new(4291979550u); - - /// - ///Gets the predefined color of coral, or #FFFF7F50. - /// - public static readonly RDColor Coral = new(4294934352u); - - /// - ///Gets the predefined color of cornflower blue, or #FF6495ED. - /// - public static readonly RDColor CornflowerBlue = new(4284782061u); - - /// - ///Gets the predefined color of cornsilk, or #FFFFF8DC. - /// - public static readonly RDColor Cornsilk = new(4294965468u); - - /// - ///Gets the predefined color of crimson, or #FFDC143C. - /// - public static readonly RDColor Crimson = new(4292613180u); - - /// - ///Gets the predefined color of cyan, or #FF00FFFF. - /// - public static readonly RDColor Cyan = new(4278255615u); - - /// - ///Gets the predefined color of dark blue, or #FF00008B. - /// - public static readonly RDColor DarkBlue = new(4278190219u); - - /// - ///Gets the predefined color of dark cyan, or #FF008B8B. - /// - public static readonly RDColor DarkCyan = new(4278225803u); - - /// - ///Gets the predefined color of dark goldenrod, or #FFB8860B. - /// - public static readonly RDColor DarkGoldenrod = new(4290283019u); - - /// - ///Gets the predefined color of dark gray, or #FFA9A9A9. - /// - public static readonly RDColor DarkGray = new(4289309097u); - - /// - ///Gets the predefined color of dark green, or #FF006400. - /// - public static readonly RDColor DarkGreen = new(4278215680u); - - /// - ///Gets the predefined color of dark khaki, or #FFBDB76B. - /// - public static readonly RDColor DarkKhaki = new(4290623339u); - - /// - ///Gets the predefined color of dark magenta, or #FF8B008B. - /// - public static readonly RDColor DarkMagenta = new(4287299723u); - - /// - ///Gets the predefined color of dark olive green, or #FF556B2F. - /// - public static readonly RDColor DarkOliveGreen = new(4283788079u); - - /// - ///Gets the predefined color of dark orange, or #FFFF8C00. - /// - public static readonly RDColor DarkOrange = new(4294937600u); - - /// - ///Gets the predefined color of dark orchid, or #FF9932CC. - /// - public static readonly RDColor DarkOrchid = new(4288230092u); - - /// - ///Gets the predefined color of dark red, or #FF8B0000. - /// - public static readonly RDColor DarkRed = new(4287299584u); - - /// - ///Gets the predefined color of dark salmon, or #FFE9967A. - /// - public static readonly RDColor DarkSalmon = new(4293498490u); - - /// - ///Gets the predefined color of dark sea green, or #FF8FBC8B. - /// - public static readonly RDColor DarkSeaGreen = new(4287609995u); - - /// - ///Gets the predefined color of dark slate blue, or #FF483D8B. - /// - public static readonly RDColor DarkSlateBlue = new(4282924427u); - - /// - ///Gets the predefined color of dark slate gray, or #FF2F4F4F. - /// - public static readonly RDColor DarkSlateGray = new(4281290575u); - - /// - ///Gets the predefined color of dark turquoise, or #FF00CED1. - /// - public static readonly RDColor DarkTurquoise = new(4278243025u); - - /// - ///Gets the predefined color of dark violet, or #FF9400D3. - /// - public static readonly RDColor DarkViolet = new(4287889619u); - - /// - ///Gets the predefined color of deep pink, or #FFFF1493. - /// - public static readonly RDColor DeepPink = new(4294907027u); - - /// - ///Gets the predefined color of deep sky blue, or #FF00BFFF. - /// - public static readonly RDColor DeepSkyBlue = new(4278239231u); - - /// - ///Gets the predefined color of dim gray, or #FF696969. - /// - public static readonly RDColor DimGray = new(4285098345u); - - /// - ///Gets the predefined color of dodger blue, or #FF1E90FF. - /// - public static readonly RDColor DodgerBlue = new(4280193279u); - - /// - ///Gets the predefined color of firebrick, or #FFB22222. - /// - public static readonly RDColor Firebrick = new(4289864226u); - - /// - ///Gets the predefined color of floral white, or #FFFFFAF0. - /// - public static readonly RDColor FloralWhite = new(4294966000u); - - /// - ///Gets the predefined color of forest green, or #FF228B22. - /// - public static readonly RDColor ForestGreen = new(4280453922u); - - /// - ///Gets the predefined color of fuchsia, or #FFFF00FF. - /// - public static readonly RDColor Fuchsia = new(4294902015u); - - /// - ///Gets the predefined color of gainsboro, or #FFDCDCDC. - /// - public static readonly RDColor Gainsboro = new(4292664540u); - - /// - ///Gets the predefined color of ghost white, or #FFF8F8FF. - /// - public static readonly RDColor GhostWhite = new(4294506751u); - - /// - ///Gets the predefined color of gold, or #FFFFD700. - /// - public static readonly RDColor Gold = new(4294956800u); - - /// - ///Gets the predefined color of goldenrod, or #FFDAA520. - /// - public static readonly RDColor Goldenrod = new(4292519200u); - - /// - ///Gets the predefined color of gray, or #FF808080. - /// - public static readonly RDColor Gray = new(4286611584u); - - /// - ///Gets the predefined color of green, or #FF008000. - /// - public static readonly RDColor Green = new(4278222848u); - - /// - ///Gets the predefined color of green yellow, or #FFADFF2F. - /// - public static readonly RDColor GreenYellow = new(4289593135u); - - /// - ///Gets the predefined color of honeydew, or #FFF0FFF0. - /// - public static readonly RDColor Honeydew = new(4293984240u); - - /// - ///Gets the predefined color of hot pink, or #FFFF69B4. - /// - public static readonly RDColor HotPink = new(4294928820u); - - /// - ///Gets the predefined color of indian red, or #FFCD5C5C. - /// - public static readonly RDColor IndianRed = new(4291648604u); - - /// - ///Gets the predefined color of indigo, or #FF4B0082. - /// - public static readonly RDColor Indigo = new(4283105410u); - - /// - ///Gets the predefined color of ivory, or #FFFFFFF0. - /// - public static readonly RDColor Ivory = new(4294967280u); - - /// - ///Gets the predefined color of khaki, or #FFF0E68C. - /// - public static readonly RDColor Khaki = new(4293977740u); - - /// - ///Gets the predefined color of lavender, or #FFE6E6FA. - /// - public static readonly RDColor Lavender = new(4293322490u); - - /// - ///Gets the predefined color of lavender blush, or #FFFFF0F5. - /// - public static readonly RDColor LavenderBlush = new(4294963445u); - - /// - ///Gets the predefined color of lawn green, or #FF7CFC00. - /// - public static readonly RDColor LawnGreen = new(4286381056u); - - /// - ///Gets the predefined color of lemon chiffon, or #FFFFFACD. - /// - public static readonly RDColor LemonChiffon = new(4294965965u); - - /// - ///Gets the predefined color of light blue, or #FFADD8E6. - /// - public static readonly RDColor LightBlue = new(4289583334u); - - /// - ///Gets the predefined color of light coral, or #FFF08080. - /// - public static readonly RDColor LightCoral = new(4293951616u); - - /// - ///Gets the predefined color of light cyan, or #FFE0FFFF. - /// - public static readonly RDColor LightCyan = new(4292935679u); - - /// - ///Gets the predefined color of light goldenrod yellow, or #FFFAFAD2. - /// - public static readonly RDColor LightGoldenrodYellow = new(4294638290u); - - /// - ///Gets the predefined color of light gray, or #FFD3D3D3. - /// - public static readonly RDColor LightGray = new(4292072403u); - - /// - ///Gets the predefined color of light green, or #FF90EE90. - /// - public static readonly RDColor LightGreen = new(4287688336u); - - /// - ///Gets the predefined color of light pink, or #FFFFB6C1. - /// - public static readonly RDColor LightPink = new(4294948545u); - - /// - ///Gets the predefined color of light salmon, or #FFFFA07A. - /// - public static readonly RDColor LightSalmon = new(4294942842u); - - /// - ///Gets the predefined color of light sea green, or #FF20B2AA. - /// - public static readonly RDColor LightSeaGreen = new(4280332970u); - - /// - ///Gets the predefined color of light sky blue, or #FF87CEFA. - /// - public static readonly RDColor LightSkyBlue = new(4287090426u); - - /// - ///Gets the predefined color of light slate gray, or #FF778899. - /// - public static readonly RDColor LightSlateGray = new(4286023833u); - - /// - ///Gets the predefined color of light steel blue, or #FFB0C4DE. - /// - public static readonly RDColor LightSteelBlue = new(4289774814u); - - /// - ///Gets the predefined color of light yellow, or #FFFFFFE0. - /// - public static readonly RDColor LightYellow = new(4294967264u); - - /// - ///Gets the predefined color of lime, or #FF00FF00. - /// - public static readonly RDColor Lime = new(4278255360u); - - /// - ///Gets the predefined color of lime green, or #FF32CD32. - /// - public static readonly RDColor LimeGreen = new(4281519410u); - - /// - ///Gets the predefined color of linen, or #FFFAF0E6. - /// - public static readonly RDColor Linen = new(4294635750u); - - /// - ///Gets the predefined color of magenta, or #FFFF00FF. - /// - public static readonly RDColor Magenta = new(4294902015u); - - /// - ///Gets the predefined color of maroon, or #FF800000. - /// - public static readonly RDColor Maroon = new(4286578688u); - - /// - ///Gets the predefined color of medium aquamarine, or #FF66CDAA. - /// - public static readonly RDColor MediumAquamarine = new(4284927402u); - - /// - ///Gets the predefined color of medium blue, or #FF0000CD. - /// - public static readonly RDColor MediumBlue = new(4278190285u); - - /// - ///Gets the predefined color of medium orchid, or #FFBA55D3. - /// - public static readonly RDColor MediumOrchid = new(4290401747u); - - /// - ///Gets the predefined color of medium purple, or #FF9370DB. - /// - public static readonly RDColor MediumPurple = new(4287852763u); - - /// - ///Gets the predefined color of medium sea green, or #FF3CB371. - /// - public static readonly RDColor MediumSeaGreen = new(4282168177u); - - /// - ///Gets the predefined color of medium slate blue, or #FF7B68EE. - /// - public static readonly RDColor MediumSlateBlue = new(4286277870u); - - /// - ///Gets the predefined color of medium spring green, or #FF00FA9A. - /// - public static readonly RDColor MediumSpringGreen = new(4278254234u); - - /// - ///Gets the predefined color of medium turquoise, or #FF48D1CC. - /// - public static readonly RDColor MediumTurquoise = new(4282962380u); - - /// - ///Gets the predefined color of medium violet red, or #FFC71585. - /// - public static readonly RDColor MediumVioletRed = new(4291237253u); - - /// - ///Gets the predefined color of midnight blue, or #FF191970. - /// - public static readonly RDColor MidnightBlue = new(4279834992u); - - /// - ///Gets the predefined color of mint cream, or #FFF5FFFA. - /// - public static readonly RDColor MintCream = new(4294311930u); - - /// - ///Gets the predefined color of misty rose, or #FFFFE4E1. - /// - public static readonly RDColor MistyRose = new(4294960353u); - - /// - ///Gets the predefined color of moccasin, or #FFFFE4B5. - /// - public static readonly RDColor Moccasin = new(4294960309u); - - /// - ///Gets the predefined color of navajo white, or #FFFFDEAD. - /// - public static readonly RDColor NavajoWhite = new(4294958765u); - - /// - ///Gets the predefined color of navy, or #FF000080. - /// - public static readonly RDColor Navy = new(4278190208u); - - /// - ///Gets the predefined color of old lace, or #FFFDF5E6. - /// - public static readonly RDColor OldLace = new(4294833638u); - - /// - ///Gets the predefined color of olive, or #FF808000. - /// - public static readonly RDColor Olive = new(4286611456u); - - /// - ///Gets the predefined color of olive drab, or #FF6B8E23. - /// - public static readonly RDColor OliveDrab = new(4285238819u); - - /// - ///Gets the predefined color of orange, or #FFFFA500. - /// - public static readonly RDColor Orange = new(4294944000u); - - /// - ///Gets the predefined color of orange red, or #FFFF4500. - /// - public static readonly RDColor OrangeRed = new(4294919424u); - - /// - ///Gets the predefined color of orchid, or #FFDA70D6. - /// - public static readonly RDColor Orchid = new(4292505814u); - - /// - ///Gets the predefined color of pale goldenrod, or #FFEEE8AA. - /// - public static readonly RDColor PaleGoldenrod = new(4293847210u); - - /// - ///Gets the predefined color of pale green, or #FF98FB98. - /// - public static readonly RDColor PaleGreen = new(4288215960u); - - /// - ///Gets the predefined color of pale turquoise, or #FFAFEEEE. - /// - public static readonly RDColor PaleTurquoise = new(4289720046u); - - /// - ///Gets the predefined color of pale violet red, or #FFDB7093. - /// - public static readonly RDColor PaleVioletRed = new(4292571283u); - - /// - ///Gets the predefined color of papaya whip, or #FFFFEFD5. - /// - public static readonly RDColor PapayaWhip = new(4294963157u); - - /// - ///Gets the predefined color of peach puff, or #FFFFDAB9. - /// - public static readonly RDColor PeachPuff = new(4294957753u); - - /// - ///Gets the predefined color of peru, or #FFCD853F. - /// - public static readonly RDColor Peru = new(4291659071u); - - /// - ///Gets the predefined color of pink, or #FFFFC0CB. - /// - public static readonly RDColor Pink = new(4294951115u); - - /// - ///Gets the predefined color of plum, or #FFDDA0DD. - /// - public static readonly RDColor Plum = new(4292714717u); - - /// - ///Gets the predefined color of powder blue, or #FFB0E0E6. - /// - public static readonly RDColor PowderBlue = new(4289781990u); - - /// - ///Gets the predefined color of purple, or #FF800080. - /// - public static readonly RDColor Purple = new(4286578816u); - - /// - ///Gets the predefined color of red, or #FFFF0000. - /// - public static readonly RDColor Red = new(4294901760u); - - /// - ///Gets the predefined color of rosy brown, or #FFBC8F8F. - /// - public static readonly RDColor RosyBrown = new(4290547599u); - - /// - ///Gets the predefined color of royal blue, or #FF4169E1. - /// - public static readonly RDColor RoyalBlue = new(4282477025u); - - /// - ///Gets the predefined color of saddle brown, or #FF8B4513. - /// - public static readonly RDColor SaddleBrown = new(4287317267u); - - /// - ///Gets the predefined color of salmon, or #FFFA8072. - /// - public static readonly RDColor Salmon = new(4294606962u); - - /// - ///Gets the predefined color of sandy brown, or #FFF4A460. - /// - public static readonly RDColor SandyBrown = new(4294222944u); - - /// - ///Gets the predefined color of sea green, or #FF2E8B57. - /// - public static readonly RDColor SeaGreen = new(4281240407u); - - /// - ///Gets the predefined color of sea shell, or #FFFFF5EE. - /// - public static readonly RDColor SeaShell = new(4294964718u); - - /// - ///Gets the predefined color of sienna, or #FFA0522D. - /// - public static readonly RDColor Sienna = new(4288696877u); - - /// - ///Gets the predefined color of silver, or #FFC0C0C0. - /// - public static readonly RDColor Silver = new(4290822336u); - - /// - ///Gets the predefined color of sky blue, or #FF87CEEB. - /// - public static readonly RDColor SkyBlue = new(4287090411u); - - /// - ///Gets the predefined color of slate blue, or #FF6A5ACD. - /// - public static readonly RDColor SlateBlue = new(4285160141u); - - /// - ///Gets the predefined color of slate gray, or #FF708090. - /// - public static readonly RDColor SlateGray = new(4285563024u); - - /// - ///Gets the predefined color of snow, or #FFFFFAFA. - /// - public static readonly RDColor Snow = new(4294966010u); - - /// - ///Gets the predefined color of spring green, or #FF00FF7F. - /// - public static readonly RDColor SpringGreen = new(4278255487u); - - /// - ///Gets the predefined color of steel blue, or #FF4682B4. - /// - public static readonly RDColor SteelBlue = new(4282811060u); - - /// - ///Gets the predefined color of tan, or #FFD2B48C. - /// - public static readonly RDColor Tan = new(4291998860u); - - /// - ///Gets the predefined color of teal, or #FF008080. - /// - public static readonly RDColor Teal = new(4278222976u); - - /// - ///Gets the predefined color of thistle, or #FFD8BFD8. - /// - public static readonly RDColor Thistle = new(4292394968u); - - /// - ///Gets the predefined color of tomato, or #FFFF6347. - /// - public static readonly RDColor Tomato = new(4294927175u); - - /// - ///Gets the predefined color of turquoise, or #FF40E0D0. - /// - public static readonly RDColor Turquoise = new(4282441936u); - - /// - ///Gets the predefined color of violet, or #FFEE82EE. - /// - public static readonly RDColor Violet = new(4293821166u); - - /// - ///Gets the predefined color of wheat, or #FFF5DEB3. - /// - public static readonly RDColor Wheat = new(4294303411u); - - /// - ///Gets the predefined color of white, or #FFFFFFFF. - /// - public static readonly RDColor White = new(uint.MaxValue); - - /// - ///Gets the predefined color of white smoke, or #FFF5F5F5. - /// - public static readonly RDColor WhiteSmoke = new(4294309365u); - - /// - ///Gets the predefined color of yellow, or #FFFFFF00. - /// - public static readonly RDColor Yellow = new(4294967040u); - - /// - ///Gets the predefined color of yellow green, or #FF9ACD32. - /// - public static readonly RDColor YellowGreen = new(4288335154u); - - /// - ///Gets the predefined color of white transparent, or #00FFFFFF. - /// - public static readonly RDColor Transparent = new(16777215u); - - /// - ///Gets the predefined empty color (black transparent), or #00000000. - /// - public static readonly RDColor Empty = new(0u); - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Components/RDColorFormatInfo.cs b/RhythmBaseCore/Components/RDColorFormatInfo.cs deleted file mode 100644 index 1f5889a..0000000 --- a/RhythmBaseCore/Components/RDColorFormatInfo.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Text.RegularExpressions; - -namespace RhythmBase.Components -{ - /// - /// Provides a custom format provider for RDColor. - /// - internal class RDColorFormatInfo : IFormatProvider - { - /// - public object? GetFormat(Type? formatType) => formatType == typeof(ICustomFormatter) ? new RDColorFormatter() : (object?)null; - } - - /// - /// Custom formatter for RDColor. - /// - internal class RDColorFormatter : ICustomFormatter, IFormatProvider - { - /// - public string Format(string? format, object? arg, IFormatProvider? formatProvider) - { - return arg is RDColor color - ? format switch - { - "RRGGBB" => $"{color.R:X2}{color.G:X2}{color.B:X2}", - "RRGGBBAA" => $"{color.R:X2}{color.G:X2}{color.B:X2}{color.A:X2}", - "AARRGGBB" => $"{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}", - "#RRGGBB" => $"#{color.R:X2}{color.G:X2}{color.B:X2}", - "#RRGGBBAA" => $"#{color.R:X2}{color.G:X2}{color.B:X2}{color.A:X2}", - "#AARRGGBB" => $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}", - "rrggbb" => $"{color.R:x2}{color.G:x2}{color.B:x2}", - "rrggbbaa" => $"{color.R:x2}{color.G:x2}{color.B:x2}{color.A:x2}", - "aarrggbb" => $"{color.A:x2}{color.R:x2}{color.G:x2}{color.B:x2}", - "#rrggbb" => $"#{color.R:x2}{color.G:x2}{color.B:x2}", - "#rrggbbaa" => $"#{color.R:x2}{color.G:x2}{color.B:x2}{color.A:x2}", - "#aarrggbb" => $"#{color.A:x2}{color.R:x2}{color.G:x2}{color.B:x2}", - "R,G,B" or "r,g,b" => $"{color.R},{color.G},{color.B}", - "R,G,B,A" or "r,g,b,a" => $"{color.R},{color.G},{color.B},{color.A}", - "A,R,G,B" or "a,r,g,b" => $"{color.A},{color.R},{color.G},{color.B}", - "RGB" or "rgb" => $"R:{color.R},G:{color.G},B:{color.B}", - "RGBA" or "rgba" => $"R:{color.R},G:{color.G},B:{color.B},A:{color.A}", - "ARGB" or "argb" or _ => $"A:{color.A},R:{color.R},G:{color.G},B:{color.B}", - } - : arg?.ToString() ?? string.Empty; - } - - private static string ReplaceColorComponent(string format, char component, int value) - { - int startIndex = 0; - while ((startIndex = format.IndexOf(component, startIndex)) != -1) - { - int length = 1; - while (startIndex + length < format.Length && format[startIndex + length] == component) - { - length++; - } - string replacement = char.IsUpper(component) ? value.ToString($"X{length}") : value.ToString(); - format = string.Concat(format.AsSpan(0, startIndex), replacement, format.AsSpan(startIndex + length)); - startIndex += replacement.Length; - } - return format; - } - - /// - public object? GetFormat(Type? formatType) => formatType == typeof(ICustomFormatter) ? this : (object?)null; - } -} diff --git a/RhythmBaseCore/Components/RDExpression.cs b/RhythmBaseCore/Components/RDExpression.cs deleted file mode 100644 index 96a8997..0000000 --- a/RhythmBaseCore/Components/RDExpression.cs +++ /dev/null @@ -1,456 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Numerics; -namespace RhythmBase.Components -{ - /// - /// An Expression - /// - [JsonConverter(typeof(ExpressionConverter))] - public struct RDExpression : INumber - { - /// - /// Gets the numeric value of the expression. - /// - public float NumericValue { get; } - /// - /// Gets the expression value as a string. - /// - public readonly string ExpressionValue - { - get - { - bool isNumeric = IsNumeric; - string ExpressionValue = isNumeric ? NumericValue.ToString() : _exp; - return ExpressionValue; - } - } - /// - /// Gets the evaluated value of the expression. - /// - public readonly float Value => IsNumeric ? NumericValue : Calculate(ExpressionValue); - private static float Calculate(string exp) - { - if (string.IsNullOrWhiteSpace(exp)) - return 0; - if (float.TryParse(exp, out float result)) - return result; - return 0; - } - static RDExpression INumberBase.One => 1; - static int INumberBase.Radix => 10; - /// - /// Gets the additive identity for the type. - /// - public static RDExpression Zero => 0; - static RDExpression IAdditiveIdentity.AdditiveIdentity => 0; - static RDExpression IMultiplicativeIdentity.MultiplicativeIdentity => 1; - /// - /// Initializes a new instance of the struct with a numeric value. - /// - /// The numeric value of the expression. - public RDExpression(float value) - { - this = default; - IsNumeric = true; - NumericValue = value; - } - /// - /// Initializes a new instance of the struct with a string value. - /// - /// The string value of the expression. - public RDExpression([AllowNull] string value) - { - IsNumeric = float.TryParse(value, out float numeric); - if (IsNumeric) - NumericValue = numeric; - else - _exp = value ?? ""; - } - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDExpression e && Equals(e); - /// - public readonly bool Equals(RDExpression other) => (IsNumeric == other.IsNumeric && NumericValue == other.NumericValue) || _exp == other._exp; - /// - public override readonly int GetHashCode() - { - HashCode hash = default; - hash.Add(ExpressionValue); - return hash.ToHashCode(); - } - /// - public override readonly string ToString() => ExpressionValue; - /// - /// Converts a string to a nullable RDExpression. - /// - /// The string to convert. - /// A nullable RDExpression if the string is not null or empty; otherwise, null. - public static RDExpression? Nullable(string s) => s != null && s.Length != 0 ? new RDExpression?(new RDExpression(s)) : null; - - readonly int IComparable.CompareTo(object? obj) - { - if (obj is RDExpression other) - { - return CompareTo(other); - } - throw new ArgumentException("Object is not a RDExpression"); - } - /// - public readonly int CompareTo(RDExpression other) - { - if (IsNumeric && other.IsNumeric) - { - return NumericValue.CompareTo(other.NumericValue); - } - return string.Compare(ExpressionValue, other.ExpressionValue, StringComparison.Ordinal); - } - - static RDExpression INumberBase.Abs(RDExpression value) - { - return value.IsNumeric ? new RDExpression(Math.Abs(value.NumericValue)) : value; - } - - static bool INumberBase.IsCanonical(RDExpression value) - { - return true; - } - - static bool INumberBase.IsComplexNumber(RDExpression value) - { - return false; - } - - static bool INumberBase.IsEvenInteger(RDExpression value) - { - return value.IsNumeric && value.NumericValue % 2 == 0; - } - - static bool INumberBase.IsFinite(RDExpression value) - { - return value.IsNumeric && !float.IsInfinity(value.NumericValue); - } - - static bool INumberBase.IsImaginaryNumber(RDExpression value) - { - return false; - } - - static bool INumberBase.IsInfinity(RDExpression value) - { - return value.IsNumeric && float.IsInfinity(value.NumericValue); - } - - static bool INumberBase.IsInteger(RDExpression value) - { - return value.IsNumeric && value.NumericValue == Math.Floor(value.NumericValue); - } - - static bool INumberBase.IsNaN(RDExpression value) - { - return value.IsNumeric && float.IsNaN(value.NumericValue); - } - - static bool INumberBase.IsNegative(RDExpression value) - { - return value.IsNumeric ? value.NumericValue < 0 : Calculate(value.ExpressionValue) < 0; - } - - static bool INumberBase.IsNegativeInfinity(RDExpression value) - { - return value.IsNumeric && float.IsNegativeInfinity(value.NumericValue); - } - - static bool INumberBase.IsNormal(RDExpression value) - { - return value.IsNumeric && !float.IsSubnormal(value.NumericValue); - } - - static bool INumberBase.IsOddInteger(RDExpression value) - { - return value.IsNumeric && value.NumericValue % 2 != 0; - } - - static bool INumberBase.IsPositive(RDExpression value) - { - return value.IsNumeric ? value.NumericValue > 0 : Calculate(value.ExpressionValue) > 0; - } - - static bool INumberBase.IsPositiveInfinity(RDExpression value) - { - return value.IsNumeric && float.IsPositiveInfinity(value.NumericValue); - } - - static bool INumberBase.IsRealNumber(RDExpression value) - { - return value.IsNumeric; - } - - static bool INumberBase.IsSubnormal(RDExpression value) - { - return value.IsNumeric && float.IsSubnormal(value.NumericValue); - } - - static bool INumberBase.IsZero(RDExpression value) - { - return value.IsNumeric ? value.NumericValue == 0 : Calculate(value.ExpressionValue) == 0; - } - static RDExpression INumberBase.MaxMagnitude(RDExpression x, RDExpression y) - { - return x.IsNumeric && y.IsNumeric ? (Math.Abs(x.NumericValue) > Math.Abs(y.NumericValue) ? x : y) : throw new NotImplementedException(); - } - - static RDExpression INumberBase.MaxMagnitudeNumber(RDExpression x, RDExpression y) - { - return x.IsNumeric && y.IsNumeric ? (Math.Abs(x.NumericValue) > Math.Abs(y.NumericValue) ? x : y) : throw new NotImplementedException(); - } - - static RDExpression INumberBase.MinMagnitude(RDExpression x, RDExpression y) - { - return x.IsNumeric && y.IsNumeric ? (Math.Abs(x.NumericValue) < Math.Abs(y.NumericValue) ? x : y) : throw new NotImplementedException(); - } - - static RDExpression INumberBase.MinMagnitudeNumber(RDExpression x, RDExpression y) - { - return x.IsNumeric && y.IsNumeric ? (Math.Abs(x.NumericValue) < Math.Abs(y.NumericValue) ? x : y) : throw new NotImplementedException(); - } - - static RDExpression INumberBase.Parse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider) - { - if (float.TryParse(s, style, provider, out float result)) - { - return new RDExpression(result); - } - throw new FormatException("Input string was not in a correct format."); - } - static RDExpression INumberBase.Parse(string s, NumberStyles style, IFormatProvider? provider) - { - if (float.TryParse(s, style, provider, out float result)) - { - return new RDExpression(result); - } - throw new FormatException("Input string was not in a correct format."); - } - static bool INumberBase.TryConvertFromChecked(TOther value, out RDExpression result) - { - result = new RDExpression(); - return false; - } - - static bool INumberBase.TryConvertFromSaturating(TOther value, out RDExpression result) - { - result = new RDExpression(); - return false; - } - - static bool INumberBase.TryConvertFromTruncating(TOther value, out RDExpression result) - { - result = new RDExpression(); - return false; - } - - static bool INumberBase.TryConvertToChecked(RDExpression value, out TOther result) - { - result = default!; - return false; - } - - static bool INumberBase.TryConvertToSaturating(RDExpression value, out TOther result) - { - result = default!; - return false; - } - - static bool INumberBase.TryConvertToTruncating(RDExpression value, out TOther result) - { - result = default!; - return false; - } - - static bool INumberBase.TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out RDExpression result) - { - result = new(s.ToString()); - return true; - } - - static bool INumberBase.TryParse(string? s, NumberStyles style, IFormatProvider? provider, out RDExpression result) - { - result = new(s ?? "0"); - return true; - } - - readonly bool ISpanFormattable.TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - return NumericValue.TryFormat(destination, out charsWritten, format, provider); - } - - readonly string IFormattable.ToString(string? format, IFormatProvider? formatProvider) - { - return NumericValue.ToString(format, formatProvider); - } - - static RDExpression ISpanParsable.Parse(ReadOnlySpan s, IFormatProvider? provider) - { - if (float.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider, out float result)) - { - return new RDExpression(result); - } - throw new FormatException("Input string was not in a correct format."); - } - - static bool ISpanParsable.TryParse(ReadOnlySpan s, IFormatProvider? provider, out RDExpression result) - { - if (float.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider, out float numericResult)) - { - result = new RDExpression(numericResult); - return true; - } - result = default; - return false; - } - - static RDExpression IParsable.Parse(string s, IFormatProvider? provider) - { - if (float.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider, out float result)) - { - return new RDExpression(result); - } - throw new FormatException("Input string was not in a correct format."); - } - - static bool IParsable.TryParse(string? s, IFormatProvider? provider, out RDExpression result) - { - if (float.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, provider, out float numericResult)) - { - result = new RDExpression(numericResult); - return true; - } - result = default; - return false; - } - /// - public static RDExpression operator +(RDExpression left, float right) => left.IsNumeric - ? new RDExpression(left.NumericValue + right) - : new RDExpression(string.Format("{0}+{1}", left.ExpressionValue, right)); - /// - public static RDExpression operator +(float left, RDExpression right) => right.IsNumeric - ? new RDExpression(left + right.NumericValue) - : new RDExpression(string.Format("{0}+{1}", left, right.ExpressionValue)); - /// - public static RDExpression operator +(RDExpression left, RDExpression right) => left.IsNumeric && right.IsNumeric - ? new RDExpression(left.NumericValue + right.NumericValue) - : new RDExpression(string.Format("{0}+{1}", left.ExpressionValue, right.ExpressionValue)); - /// - public static RDExpression operator -(RDExpression left, float right) => left.IsNumeric - ? new RDExpression(left.NumericValue - right) - : new RDExpression(string.Format("{0}-{1}", left.ExpressionValue, right)); - /// - public static RDExpression operator -(float left, RDExpression right) => right.IsNumeric - ? new RDExpression(left - right.NumericValue) - : new RDExpression(string.Format("{0}-{1}", left, right.ExpressionValue)); - /// - public static RDExpression operator -(RDExpression left, RDExpression right) => left.IsNumeric && right.IsNumeric - ? new RDExpression(left.NumericValue - right.NumericValue) - : new RDExpression(string.Format("{0}-{1}", left.ExpressionValue, right.ExpressionValue)); - /// - public static RDExpression operator *(RDExpression left, float right) => left.IsNumeric - ? new RDExpression(left.NumericValue * right) - : new RDExpression(string.Format("({0})*{1}", left.ExpressionValue, right)); - /// - public static RDExpression operator *(float left, RDExpression right) => right.IsNumeric - ? new RDExpression(left * right.NumericValue) - : new RDExpression(string.Format("{0}*({1})", left, right.ExpressionValue)); - /// - public static RDExpression operator *(RDExpression left, RDExpression right) => left.IsNumeric && right.IsNumeric - ? new RDExpression(left.NumericValue * right.NumericValue) - : new RDExpression(string.Format("({0})*({1})", left.ExpressionValue, right.ExpressionValue)); - /// - public static RDExpression operator /(RDExpression left, float right) => left.IsNumeric - ? new RDExpression(left.NumericValue / right) - : new RDExpression(string.Format("({0})/{1}", left.ExpressionValue, right)); - /// - public static RDExpression operator /(float left, RDExpression right) => right.IsNumeric - ? new RDExpression(left / right.NumericValue) - : new RDExpression(string.Format("{0}/({1})", left, right.ExpressionValue)); - /// - public static RDExpression operator /(RDExpression left, RDExpression right) => left.IsNumeric && right.IsNumeric - ? new RDExpression(left.NumericValue / right.NumericValue) - : new RDExpression(string.Format("({0})/({1})", left.ExpressionValue, right.ExpressionValue)); - /// - public static bool operator ==(RDExpression left, RDExpression right) => left.Equals(right); - /// - public static bool operator !=(RDExpression left, RDExpression right) => !(left == right); - /// - public static implicit operator RDExpression(float v) => new(v); - /// - public static implicit operator RDExpression(string v) => new(v); - - static bool IComparisonOperators.operator >(RDExpression left, RDExpression right) - { - return left.CompareTo(right) > 0; - } - - static bool IComparisonOperators.operator >=(RDExpression left, RDExpression right) - { - return left.CompareTo(right) >= 0; - } - - static bool IComparisonOperators.operator <(RDExpression left, RDExpression right) - { - return left.CompareTo(right) < 0; - } - - static bool IComparisonOperators.operator <=(RDExpression left, RDExpression right) - { - return left.CompareTo(right) <= 0; - } - - static RDExpression IModulusOperators.operator %(RDExpression left, RDExpression right) - { - if (left.IsNumeric && right.IsNumeric) - { - return new RDExpression(left.NumericValue % right.NumericValue); - } - throw new NotImplementedException("Modulus operator is not implemented for non-numeric expressions."); - } - - static RDExpression IDecrementOperators.operator --(RDExpression value) - { - if (value.IsNumeric) - { - return new RDExpression(value.NumericValue - 1); - } - throw new NotImplementedException("Decrement operator is not implemented for non-numeric expressions."); - } - - static RDExpression IIncrementOperators.operator ++(RDExpression value) - { - if (value.IsNumeric) - { - return new RDExpression(value.NumericValue + 1); - } - throw new NotImplementedException("Increment operator is not implemented for non-numeric expressions."); - } - - static RDExpression IUnaryNegationOperators.operator -(RDExpression value) - { - if (value.IsNumeric) - { - return new RDExpression(-value.NumericValue); - } - throw new NotImplementedException("Unary negation operator is not implemented for non-numeric expressions."); - } - - static RDExpression IUnaryPlusOperators.operator +(RDExpression value) - { - return value; - } - - private readonly string _exp = ""; - /// - /// - /// - public bool IsNumeric { get; private set; } = false; - } -} diff --git a/RhythmBaseCore/Components/RDHit.cs b/RhythmBaseCore/Components/RDHit.cs deleted file mode 100644 index 675553f..0000000 --- a/RhythmBaseCore/Components/RDHit.cs +++ /dev/null @@ -1,51 +0,0 @@ -using RhythmBase.Events; -namespace RhythmBase.Components -{ - /// - /// Represents the moment a beat is hit in the rhythm game. - /// - public struct RDHit - { - /// - /// Gets the moment of pressing the beat. - /// - public RDBeat Beat { get; } - /// - /// Gets the length of time the player held the beat. - /// - public float Hold { get; } - /// - /// Gets the source event for this hit. - /// - public BaseBeat Parent { get; } - /// - /// Gets a value indicating whether this hit needs to be held down continuously. - /// - public readonly bool Holdable - { - get - { - return Hold > 0f; - } - } - /// - /// Initializes a new instance of the struct. - /// - /// The source event for this hit. - /// The moment of pressing the beat. - /// The length of time the player held the beat. - public RDHit(BaseBeat parent, RDBeat beat, float hold = 0f) - { - this = default; - Parent = parent; - Beat = beat; - Hold = hold; - } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override readonly string ToString() => string.Format("{{{0}, {1}}}", Beat, Parent); - } -} diff --git a/RhythmBaseCore/Components/RDLang/RDExpressionToken.cs b/RhythmBaseCore/Components/RDLang/RDExpressionToken.cs deleted file mode 100644 index 24a97e4..0000000 --- a/RhythmBaseCore/Components/RDLang/RDExpressionToken.cs +++ /dev/null @@ -1,52 +0,0 @@ -using sly.lexer; - -namespace RhythmBase.Components.RDLang -{ - internal enum RDExpressionToken - { - [Lexeme(@"[0-9]+(\.[0-9]+)?")] - Number, - [Lexeme("[i][0-9]")] - VariableInt, - [Lexeme("[f][0-9]")] - VariableFloat, - [Lexeme("[b][0-9]")] - VariableBoolean, - [Lexeme(@"\+")] - Add, - [Lexeme("-")] - Subtract, - [Lexeme(@"\*")] - Multiply, - [Lexeme("/")] - Divide, - [Lexeme("true")] - True, - [Lexeme("false")] - False, - [Lexeme("=")] - Assignment, - [Lexeme(">=")] - GreaterThanOrEqual, - [Lexeme("<=")] - LessThanOrEqual, - [Lexeme(">")] - GreaterThan, - [Lexeme("<")] - LessThan, - [Lexeme(",")] - Comma, - [Lexeme(@"[A-Za-z0-9]+(?=\()")] - Identifier, - [Lexeme(@"\(")] - LeftParenthesis, - [Lexeme(@"\)")] - RightParenthesis, - [Lexeme(@"[A-Za-z0-9]+")] - PlainString, - [Lexeme(@"[A-Za-z0-9\+]+(?=\s*[\),])|""([A-Za-z0-9\+]+)""|str:([A-Za-z0-9\+]+)")] - String, - [Lexeme(@"[ \t\r\n]", IsSkippable = true)] - Whitespace, - } -} diff --git a/RhythmBaseCore/Components/RDLang/RDLang.cs b/RhythmBaseCore/Components/RDLang/RDLang.cs deleted file mode 100644 index ecaf7d9..0000000 --- a/RhythmBaseCore/Components/RDLang/RDLang.cs +++ /dev/null @@ -1,47 +0,0 @@ -using sly.parser; -using sly.parser.generator; - -namespace RhythmBase.Components.RDLang -{ - /// - /// RDLang class provides functionality to parse and evaluate expressions written in a custom language. - /// - public static class RDLang - { - private static readonly RDVariables variables = new(); - private static readonly RDLangParser parserInstance; - /// - /// Gets the collection of variables used in the custom language. - /// - /// - /// The collection of variables. - /// - public static RDVariables Variables { get => variables; } - /// - /// Lazy-initialized parser for the custom language expressions. - /// - internal static Lazy> Parser = new(() => - { - var builder = new ParserBuilder(); - var build = builder.BuildParser(parserInstance, ParserType.LL_RECURSIVE_DESCENT, "expression"); - var parser = build.Result; - return parser; - }); - static RDLang() - { - parserInstance = new RDLangParser() { Variables = variables }; - } - /// - /// Tries to parse the given code string into a float result. - /// - /// The code string to parse. - /// The parsed float result if the parsing is successful. - /// True if parsing is successful; otherwise, false. - public static bool TryRun(string code, out float result) - { - var parseResult = Parser.Value.Parse(code); - result = parseResult.Result; - return parseResult.IsOk; - } - } -} diff --git a/RhythmBaseCore/Components/RDLang/RDLangParser.cs b/RhythmBaseCore/Components/RDLang/RDLangParser.cs deleted file mode 100644 index e1ab9e8..0000000 --- a/RhythmBaseCore/Components/RDLang/RDLangParser.cs +++ /dev/null @@ -1,187 +0,0 @@ -using sly.lexer; -using sly.parser.generator; - -namespace RhythmBase.Components.RDLang -{ - internal class RDLangParser - { - internal const string PlainString = ""; - private static List> TokenList { get; set; } = []; - public required RDVariables Variables { get; set; } - [NodeName("integer")] - [Production("primary: Number")] - public static float Primary(Token intToken) => float.Parse(intToken.Value); - [NodeName("boolean")] - [Production("primary: True")] - [Production("primary: False")] - public static float Boolean(Token token) => token.TokenID switch - { - RDExpressionToken.True => 1.0f, - RDExpressionToken.False => 0.0f, - _ => throw new InvalidOperationException("Invalid boolean token") - }; - [NodeName("group")] - [Production("primary: LeftParenthesis [d] expression RightParenthesis [d]")] - public static float Group(float groupValue) => groupValue; - [NodeName("addOrSubstract")] - [Production("expression : term Add expression")] - [Production("expression : term Subtract expression")] - public static float Expression(float left, Token operatorToken, float right) => operatorToken.TokenID switch - { - RDExpressionToken.Add => left + right, - RDExpressionToken.Subtract => left - right, - _ => throw new InvalidOperationException("Invalid operator") - }; - [NodeName("expression")] - [Production("expression : term")] - public static float Expression_Term(float termValue) => termValue; - [NodeName("multOrDivide")] - [Production("term : factor Multiply term")] - [Production("term : factor Divide term")] - public static float Term(float left, Token operatorToken, float right) => operatorToken.TokenID switch - { - RDExpressionToken.Multiply => left * right, - RDExpressionToken.Divide => left / right, - _ => throw new InvalidOperationException("Invalid operator") - }; - [NodeName("term")] - [Production("term : factor")] - public static float TermFactor(float factorValue) => factorValue; - [NodeName("primary")] - [Production("factor : primary")] - public static float PrimaryFactor(float primValue) => primValue; - [NodeName("negate")] - [Production("factor : Add factor")] - [Production("factor : Subtract factor")] - public static float Factor(Token symbolToken, float factorValue) => symbolToken.TokenID switch - { - RDExpressionToken.Add => factorValue, - RDExpressionToken.Subtract => -factorValue, - _ => throw new InvalidOperationException("Invalid operator") - }; - [NodeName("primary")] - [Production("primary: VariableInt")] - [Production("primary: VariableFloat")] - [Production("primary: VariableBoolean")] - [Production("primary: PlainString")] - public float PrimaryVariable(Token variableToken) - { - return variableToken.TokenID switch - { - RDExpressionToken.VariableInt => Variables.i[int.Parse(variableToken.Value[1..])], - RDExpressionToken.VariableFloat => Variables.f[int.Parse(variableToken.Value[1..])], - RDExpressionToken.VariableBoolean => Variables.b[int.Parse(variableToken.Value[1..])] ? 1.0f : 0.0f, - RDExpressionToken.PlainString => (float)Variables[variableToken.Value], - _ => throw new InvalidOperationException("Invalid variable type"), - }; - } - [NodeName("string")] - [Production("argument: String")] - public static float String(Token stringToken) - { - TokenList.Add(new(RDExpressionToken.String, - stringToken.Value switch - { - ['s', 't', 'r', ':', ..] => stringToken.Value[4..], - ['"', .., '"'] => stringToken.Value[1..^1], - _ => stringToken.Value, - }, - new())); - return 1; - } - [NodeName("compare")] - [Production("expression: term GreaterThanOrEqual expression")] - [Production("expression: term GreaterThan expression")] - [Production("expression: term LessThanOrEqual expression")] - [Production("expression: term LessThan expression")] - public static float Compare(float left, Token operatorToken, float right) - { - var result = operatorToken.TokenID switch - { - RDExpressionToken.GreaterThan => left > right, - RDExpressionToken.GreaterThanOrEqual => left >= right, - RDExpressionToken.LessThan => left < right, - RDExpressionToken.LessThanOrEqual => left <= right, - _ => throw new InvalidOperationException("Invalid operator") - }; - return result ? 1.0f : 0.0f; - } - [NodeName("assignment")] - [Production("primary: VariableInt Assignment expression")] - [Production("primary: VariableFloat Assignment expression")] - [Production("primary: VariableBoolean Assignment expression")] - [Production("primary: PlainString Assignment expression")] - public float Assignment(Token nameToken, Token _, float expression) - { - var variableName = nameToken.Value; - switch (variableName[0]) - { - case 'i': - Variables.i[int.Parse(variableName[1..])] = (int)expression; - break; - case 'f': - Variables.f[int.Parse(variableName[1..])] = expression; - break; - case 'b': - Variables.b[int.Parse(variableName[1..])] = expression != 0.0f; - break; - default: - Variables[variableName] = expression; - break; - } - return expression; - } - [NodeName("function_call")] - [Production("primary: Identifier LeftParenthesis [d] functionRight")] - public static float FunctionCallWithArguments(Token identifierToken, float _) => EvaluateFunction(identifierToken.Value, TokenList); - [NodeName("function_right")] - [Production("functionRight: RightParenthesis [d]")] - public static float FunctionCall() => 0; - [NodeName("function_right")] - [Production("functionRight: Number RightParenthesis [d]")] - [Production("functionRight: PlainString RightParenthesis [d]")] - public static float FunctionEnd(Token valueToken) - { - TokenList.Add(valueToken); - return 1; - } - [NodeName("arguments")] - [Production("functionRight: Number Comma [d] functionRight")] - [Production("functionRight: String Comma [d] functionRight")] - [Production("functionRight: PlainString Comma [d] functionRight")] - public static float ArgumentListWithComma(Token valueToken, float argument) - { - TokenList.Add(valueToken); - return 1 + argument; - } - [NodeName("arguments")] - [Production("functionRight: expression Comma [d] functionRight")] - public static float ArgumentListWithComma2(float arg, float argument) - { - TokenList.Add(new(RDExpressionToken.Number,arg.ToString(),new())); - return 1 + argument; - } - private static float EvaluateFunction(string functionName, List> tokenList) - { - return functionName switch - { - "Rand" => (float)(TokenList.Count == 1 - ? int.TryParse(tokenList[0].Value, out int result) - ? RDVariables.Rand(result) - : throw new ArgumentException("Invalid argument type for Rand function") - : throw new ArgumentException("Invalid argument count for Rand function")), - "atLeastRank" => (TokenList.Count == 1 - ? RDVariables.atLeastRank(tokenList[0].Value) - ? 1.0f - : 0.0f - : throw new ArgumentException("Invalid argument count for atLeastRank function")), - "atLeastNPerfects" => (TokenList.Count == 2 - ? RDVariables.atLeastNPerfects(int.Parse(tokenList[0].Value), int.Parse(tokenList[1].Value)) - ? 1.0f - : 0.0f - : throw new ArgumentException("Invalid argument count for atLeastNPerfects function")), - _ => throw new InvalidOperationException($"Unknown function: {functionName}"), - }; - } - } -} diff --git a/RhythmBaseCore/Components/RDLevel.cs b/RhythmBaseCore/Components/RDLevel.cs deleted file mode 100644 index da1f68f..0000000 --- a/RhythmBaseCore/Components/RDLevel.cs +++ /dev/null @@ -1,695 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Converters; -using RhythmBase.Events; -using RhythmBase.Exceptions; -using RhythmBase.Extensions; -using RhythmBase.Settings; -using RhythmBase.Utils; - -using System.Diagnostics.CodeAnalysis; -using System.IO.Compression; -namespace RhythmBase.Components -{ - /// - /// Rhythm Doctor level. - /// - public class RDLevel : OrderedEventCollection, IDisposable - { - /// - /// The calculator that comes with the level. - /// - [JsonIgnore] - public BeatCalculator Calculator { get; } - /// - /// Level Settings. - /// - public Settings Settings { get; set; } - internal List ModifiableRows { get; } = new List(16); - internal List ModifiableDecorations { get; } = []; - /// - /// Level tile collection. - /// - public IReadOnlyList Rows => ModifiableRows.AsReadOnly(); - /// - /// Level decoration collection. - /// - public IReadOnlyList Decorations => ModifiableDecorations.AsReadOnly(); - /// - /// Level condition collection. - /// - public List Conditionals { get; } - /// - /// Level bookmark collection. - /// - public List Bookmarks { get; } - /// - /// Level colorPalette collection. - /// - public RDColor[] ColorPalette - { - get => colorPalette; - set => colorPalette = value.Length == 21 ? value : throw new RhythmBaseException(); - } - /// - /// Level file path. - /// - [JsonIgnore] - public string Path => _path; - /// - /// Level directory path. - /// - [JsonIgnore] - public string Directory => System.IO.Path.GetDirectoryName(_path)!; - /// - /// Default beats with levels. - /// The beat is 1. - /// - [JsonIgnore] - public RDBeat DefaultBeat => Calculator.BeatOf(1f); - /// - /// Initializes a new instance of the class. - /// - public RDLevel() - { - _path = ""; - Variables = new RDVariables(); - Calculator = new BeatCalculator(this); - Settings = new Settings(); - Conditionals = []; - Bookmarks = []; - ColorPalette = new RDColor[21]; - } - - /// - /// Initializes a new instance of the class with the specified items. - /// - /// The items to add to the level. - public RDLevel(IEnumerable items) : this() - { - foreach (IBaseEvent item in items) - Add(item); - } - /// - /// The default level within the game. - /// - public static RDLevel Default - { - get - { - RDLevel rdlevel = []; - rdlevel.ColorPalette = - [ - RDColor.Black, - RDColor.White, - new(0xFF7F7F7Fu), - new(0xFFC3C3C3u), - new(0xFF880015u), - new(0xFFB97A57u), - RDColor.Red, - - new(0xFFFFAEC9u), - new(0xFFFF7F27u), - new(0xFFFFC90Eu), - new(0xFFFFF200u), - new(0xFFEFE4B0u), - new(0xFF22B14Cu), - new(0xFFB5E61Du), - - new(0xFF00A2E8u), - new(0xFF99D9EAu), - new(0xFF3F48CCu), - new(0xFF7092BEu), - new(0xFFA349A4u), - new(0xFFC8BFE7u), - new(0x00000000u) - ]; - - rdlevel.Settings.RankMaxMistakes = [ - 20, - 15, - 10, - 5 - ]; - - rdlevel.Settings.RankDescription = [ - "Better call 911, now!", - "Ugh, you can do better", - "Not bad I guess...", - "We make a good team!", - "You are really good!", - "Wow! That's awesome!!" - ]; - - PlaySong playsong = new(); - SetTheme settheme = new(); - playsong.Song = new RDAudio() { Filename = "sndOrientalTechno" }; - settheme.Preset = SetTheme.Theme.OrientalTechno; - rdlevel.AddRange([playsong, settheme]); - RowEventCollection samurai = rdlevel.CreateRow(new RDSingleRoom(RDRoomIndex.Room1), RDCharacters.Samurai); - samurai.Sound.Filename = "Shaker"; - samurai.Add(new AddClassicBeat()); - return rdlevel; - } - } - /// - /// Create a decoration and add it to the level. - /// - /// The room where this decoration is in. - /// The sprite referenced by this decoration. - /// Decoration that created and added to the level. - public DecorationEventCollection CreateDecoration(RDSingleRoom room, [NotNull] string sprite) - { - DecorationEventCollection temp = new(room) - { - Parent = this, - Filename = sprite - }; - ModifiableDecorations.Add(temp); - return temp; - } - /// - /// Clone the decoration and add it to the level. - /// - /// Decoration that was copied. - /// - public DecorationEventCollection CloneDecoration(DecorationEventCollection decoration) - { - DecorationEventCollection temp = decoration.Clone(); - ModifiableDecorations.Add(temp); - return temp; - } - /// - /// Remove the decoration from the level. - /// - /// The decoration to be removed. - /// - public bool RemoveDecoration(DecorationEventCollection decoration) - { - if (Decorations.Contains(decoration)) - { - this.RemoveRange(decoration); - return ModifiableDecorations.Remove(decoration); - } - else - return false; - } - /// - /// Create a row and add it to the level. - /// - /// The room where this row is in. - /// The character used by this row. - /// Row that created and added to the level. - public RowEventCollection CreateRow(RDSingleRoom room, RDCharacter character) - { - RowEventCollection temp = new() - { - Character = character, - Rooms = room, - Parent = this - }; - temp.Parent = this; - ModifiableRows.Add(temp); - return temp; - } - /// - /// Remove the row from the level. - /// - /// The row to be removed. - /// - public bool RemoveRow(RowEventCollection row) - { - if (Rows.Contains(row)) - { - this.RemoveRange(row); - return ModifiableRows.Remove(row); - } - else - return false; - } - /// - /// Read from file as level. - /// Use default input settings. - /// Supports .rdlevel, .rdzip, .zip file extension. - /// - /// File path. - /// The minimum level version number supported by this library is 54. - /// - /// File not supported. - /// An instance of a level that reads from a file. - public static RDLevel Read(string filepath) => Read(filepath, new LevelReadOrWriteSettings()); - /// - /// Read from file as level. - /// Supports .rdlevel, .rdzip, .zip file extension. - /// - /// File path. - /// Input settings. - /// The minimum level version number supported by this library is 54. - /// - /// File not supported. - /// An instance of a level that reads from a file. - public static RDLevel Read(string filepath, LevelReadOrWriteSettings settings) - { - JsonSerializer LevelSerializer = new(); - LevelSerializer.Converters.Add(new RDLevelConverter(filepath, settings)); - string extension = System.IO.Path.GetExtension(filepath); - RDLevel? Read; - if (extension != ".rdzip" && extension != ".zip") - { - if (extension != ".rdlevel") - throw new RhythmBaseException("File not supported."); - settings.OnBeforeReading(); - Read = LevelSerializer.Deserialize(new JsonTextReader(File.OpenText(filepath))); - settings.OnAfterReading(); - } - else - Read = ReadFromZip(filepath, settings); - return Read ?? []; - } - /// - /// Reads an RDLevel from a TextReader with the specified filepath and settings. - /// - /// The TextReader to read from. - /// The filepath of the RDLevel. - /// The settings to use for reading the RDLevel. - /// The deserialized RDLevel object. - /// Thrown when the file cannot be read. - public static RDLevel Read(TextReader reader, string filepath, LevelReadOrWriteSettings settings) - { - JsonSerializer LevelSerializer = new(); - LevelSerializer.Converters.Add(new RDLevelConverter(filepath, settings)); - RDLevel Read; - Read = LevelSerializer.Deserialize(new JsonTextReader(reader)) ?? throw new RhythmBaseException("Cannot read the file."); - return Read; - } - - /// - /// Reads an RDLevel from a TextReader with the specified settings. - /// - /// The TextReader to read from. - /// The settings to use for reading the RDLevel. - /// The deserialized RDLevel object. - /// Thrown when the file cannot be read. - public static RDLevel Read(TextReader reader, LevelReadOrWriteSettings settings) => Read(reader, "", settings); - /// - /// Read from a zip file as a level. - /// - /// The path to the zip file. - /// An instance of RDLevel that reads from a zip file. - public static RDLevel ReadFromZip(string filepath) => ReadFromZip(filepath, new LevelReadOrWriteSettings()); - - /// - /// Read from a zip file as a level with specific settings. - /// - /// The path to the zip file. - /// The settings for reading the level. - /// An instance of RDLevel that reads from a zip file with specific settings. - public static RDLevel ReadFromZip(string filepath, LevelReadOrWriteSettings settings) => ReadFromZip(File.OpenRead(filepath), settings); - /// - /// Read from a zip file as a level. - /// - /// The stream of the zip file. - /// An instance of RDLevel that reads from a zip file. - public static RDLevel ReadFromZip(Stream stream) => ReadFromZip(stream, new LevelReadOrWriteSettings()); - - /// - /// Read from a zip file as a level with specific settings. - /// - /// The stream of the zip file. - /// The settings for reading the level. - /// An instance of RDLevel that reads from a zip file with specific settings. - public static RDLevel ReadFromZip(Stream stream, LevelReadOrWriteSettings settings) - { - DirectoryInfo tempDirectory = new(System.IO.Path.Combine(System.IO.Path.GetTempPath(), "RhythmBaseTemp_" + System.IO.Path.GetRandomFileName())); - tempDirectory.Create(); - RDLevel ReadFromZip; - try - { - ZipFile.ExtractToDirectory(stream, tempDirectory.FullName); - ReadFromZip = Read(tempDirectory.GetFiles().Single(i => i.Extension == ".rdlevel").FullName, settings); - ReadFromZip.isZip = true; - } - catch (InvalidOperationException ex) - { - tempDirectory.Delete(true); - throw new RhythmBaseException("More than one RDLevel file has been found.", ex); - } - catch (Exception ex2) - { - tempDirectory.Delete(true); - throw new RhythmBaseException("Cannot extract the file.", ex2); - } - return ReadFromZip; - } - private JsonSerializer Serializer(LevelReadOrWriteSettings settings) => new() - { - Converters = { new RDLevelConverter(_path, settings) } - }; - /// - /// Save the level. - /// Use default output settings. - /// - /// File path. - /// Overwriting is disabled by the settings and a file with the same name already exists. - public void Write(string filepath) => Write(filepath, new LevelReadOrWriteSettings()); - /// - /// Save the level. - /// - /// File path. - /// Output settings. - /// Overwriting is disabled by the settings and a file with the same name already exists. - public void Write(string filepath, LevelReadOrWriteSettings settings) - { - using StreamWriter file = File.CreateText(filepath); - Write(file, settings); - } - /// - /// Save the level to a text writer. - /// Use default output settings. - /// - /// The text writer to write the level to. - public void Write(TextWriter stream) => Write(stream, new LevelReadOrWriteSettings()); - - /// - /// Save the level to a text writer. - /// - /// The text writer to write the level to. - /// The settings for writing the level. - public void Write(TextWriter stream, LevelReadOrWriteSettings settings) - { - using JsonTextWriter writer = new(stream); - settings.OnBeforeWriting(); - Serializer(settings).Serialize(writer, this); - settings.OnAfterWriting(); - } - - /// - /// Save the level to a stream. - /// Use default output settings. - /// - /// The stream to write the level to. - public void Write(Stream stream) => Write(new StreamWriter(stream, leaveOpen: true), new LevelReadOrWriteSettings()); - - /// - /// Save the level to a stream. - /// - /// The stream to write the level to. - /// The settings for writing the level. - public void Write(Stream stream, LevelReadOrWriteSettings settings) => Write(new StreamWriter(stream), settings); - /// - /// Convert to JObject type. - /// - /// A JObject type that stores all the data for the level. - public JObject ToJObject() => ToJObject(new LevelReadOrWriteSettings()); - /// - /// Convert to JObject type. - /// - /// A JObject type that stores all the data for the level. - public JObject ToJObject(LevelReadOrWriteSettings settings) => JObject.FromObject(this, new JsonSerializer - { - Converters = { new RDLevelConverter(Path, settings) } - }); - /// - /// Convert to a string that can be read by the game. - /// Use default output settings. - /// - /// Level string. - public string ToRDLevelJson() => ToRDLevelJson(new LevelReadOrWriteSettings()); - /// - /// Convert to a string that can be read by the game. - /// - /// Output settings. - /// Level string. - public string ToRDLevelJson(LevelReadOrWriteSettings settings) - { - StringWriter file = new(); - Write(file, settings); - file.Close(); - return file.ToString(); - } - /// - /// Add event to the level. - /// - /// Event to be added. - /// - public override void Add(IBaseEvent item) - { - //添加默认节拍 - if (((BaseEvent)item)._beat.IsEmpty) - ((BaseEvent)item)._beat._calculator = Calculator; - //部分事件只能在小节的开头 - if (item is IBarBeginningEvent @event && ((BaseEvent)item)._beat.BarBeat.beat != 1f) - throw new IllegalBeatException(@event); - //更改节拍的关联关卡 - ((BaseEvent)item)._beat._calculator = Calculator; - ((BaseEvent)item)._beat.ResetCache(); - if (item.Type == EventType.Comment && ((Comment)item).Parent == null) - //注释事件可能在精灵板块,也可能不在 - base.Add(item); - else if (item.Type == EventType.TintRows && ((TintRows)item).Parent == null) - base.Add(item); - else if (EventTypeUtils.RowTypes.Contains(item.Type)) - { - BaseRowAction rowAction = (BaseRowAction)item; - if (rowAction.Parent == null) - throw new UnreadableEventException("The Parent property of this event should not be null. Call RowEventCollection.Add() instead.", item); - //添加至对应轨道 - rowAction.Parent.AddSafely((BaseRowAction)item); - base.Add(item); - } - else if (EventTypeUtils.DecorationTypes.Contains(item.Type)) - { - BaseDecorationAction decoAction = (BaseDecorationAction)item; - if (decoAction.Parent == null) - throw new UnreadableEventException("The Parent property of this event should not be null. Call DecorationEventCollection.Add() instead.", item); - //添加至对应精灵 - decoAction.Parent.AddSafely((BaseDecorationAction)item); - base.Add(item); - } - //BPM 和 CPB - else if (item.Type == EventType.SetCrotchetsPerBar) - AddSetCrotchetsPerBar((SetCrotchetsPerBar)item); - else if (EventTypeUtils.ToEnums().Contains(item.Type)) - AddBaseBeatsPerMinute((BaseBeatsPerMinute)item); - // 其他 - else - base.Add(item); - } - /// - /// Determine if the level contains this event. - /// - /// Event. - /// - public override bool Contains(IBaseEvent item) => (Utils.EventTypeUtils.RowTypes.Contains(item.Type) - && Rows.Any((RowEventCollection i) => i.Contains(item))) || (Utils.EventTypeUtils.DecorationTypes.Contains(item.Type) && Decorations.Any((DecorationEventCollection i) => i.Contains(item))) || base.Contains(item); - /// - /// Remove event from the level. - /// - /// Event to be removed. - /// - public override bool Remove(IBaseEvent item) - { - bool Remove; - if (Utils.EventTypeUtils.RowTypes.Contains(item.Type) - && Rows.Any((RowEventCollection i) => i.RemoveSafely((BaseRowAction)item))) - { - base.Remove(item); - ((BaseEvent)item)._beat._calculator = null; - Remove = true; - } - else if (Utils.EventTypeUtils.DecorationTypes.Contains(item.Type) - && Decorations.Any((DecorationEventCollection i) => i.RemoveSafely((BaseDecorationAction)item))) - { - base.Remove(item); - ((BaseEvent)item)._beat._calculator = null; - Remove = true; - } - else if (Contains(item)) - { - if (item.Type == EventType.SetCrotchetsPerBar) - Remove = RemoveSetCrotchetsPerBar((SetCrotchetsPerBar)item); - else if (Utils.EventTypeUtils.ToEnums().Contains(item.Type)) - Remove = RemoveBaseBeatsPerMinute((BaseBeatsPerMinute)item); - else - { - bool result = base.Remove(item); - ((BaseEvent)item)._beat._calculator = null; - Remove = result; - } - } - else - Remove = false; - return Remove; - } - /// - /// Gets the status of the level at the specified beat. - /// - /// The beat at which to get the status. - /// A new instance of representing the status at the specified beat. - internal RDStatus GetStatus(RDBeat beat) - { - return new() - { - Beat = beat, - RoomStatus = [ - new(){ - Beat = beat, - RunningVFXs = this.Where(i=>i.Rooms.Contains(RDRoomIndex.Room1)&& i.VFXDuration().Contains(beat), new RDRange(null,beat)) - }, - new(){ - Beat = beat, - RunningVFXs = this.Where(i=>i.Rooms.Contains(RDRoomIndex.Room2)&& i.VFXDuration().Contains(beat), new RDRange(null,beat)) - }, - new(){ - Beat = beat, - RunningVFXs = this.Where(i=>i.Rooms.Contains(RDRoomIndex.Room3)&& i.VFXDuration().Contains(beat), new RDRange(null,beat)) - }, - new(){ - Beat = beat, - RunningVFXs = this.Where(i=>i.Rooms.Contains(RDRoomIndex.Room4)&& i.VFXDuration().Contains(beat), new RDRange(null,beat)) - }, - new(){ - Beat = beat, - RunningVFXs = this.Where(i=>i.Rooms.Contains(RDRoomIndex.RoomTop)&& i.VFXDuration().Contains(beat), new RDRange(null,beat)) - } - ], - }; - } - private void AddSetCrotchetsPerBar(SetCrotchetsPerBar item) - { - SetCrotchetsPerBar? frt = item.FrontOrDefault(); - SetCrotchetsPerBar? nxt = item.NextOrDefault(); - //更新拍号 - RefreshCPBs(item._beat); - //添加事件 - base.Add(item); - //更新计算器 - Calculator.Refresh(); - if (nxt != null) - { - BaseEvent? nxtE = item.After().FirstOrDefault((BaseEvent i) => i is IBarBeginningEvent && - i.Type != EventType.SetCrotchetsPerBar && - i._beat < nxt._beat); - float interval = ((nxtE != null) ? nxtE._beat.BeatOnly : nxt._beat.BeatOnly) - item._beat.BeatOnly; - float c = interval % item.CrotchetsPerBar; - if (c > 0f) - { - c = (c < 2f) ? (c + item.CrotchetsPerBar) : c; - base.Add(new SetCrotchetsPerBar - { - _beat = item._beat + interval - c, - _crotchetsPerBar = checked((uint)Math.Round((double)unchecked(c - 1f))) - }); - } - else if (nxt.CrotchetsPerBar == item.CrotchetsPerBar) - base.Remove(nxt); - if (nxtE != null) - base.Add(new SetCrotchetsPerBar - { - _beat = nxtE._beat, - _crotchetsPerBar = frt?.CrotchetsPerBar ?? 8 - 1 - }); - } - // 更新计算器 - Calculator.Refresh(); - } - private bool RemoveSetCrotchetsPerBar(SetCrotchetsPerBar item) - { - SetCrotchetsPerBar? frt = item.FrontOrDefault(); - SetCrotchetsPerBar? nxt = item.NextOrDefault(); - if (nxt != null) - { - BaseEvent? nxtE = item.After().FirstOrDefault((BaseEvent i) => i is IBarBeginningEvent && - i.Type != EventType.SetCrotchetsPerBar && - i._beat < nxt._beat); - uint cpb = item.CrotchetsPerBar; - int interval = (int)((nxtE ?? nxt)._beat.BeatOnly - item._beat.BeatOnly); - long c = interval % frt?.CrotchetsPerBar ?? 8; - if (c > 0) - { - c = c < 2 ? c + item.CrotchetsPerBar : c; - if (c == nxt.CrotchetsPerBar) - base.Remove(nxt); - base.Add(new SetCrotchetsPerBar() - { - _beat = item._beat + interval - c, - _crotchetsPerBar = (uint)(c - 1) - }); - } - else - { - if (nxtE != null && nxt.CrotchetsPerBar == (frt?.CrotchetsPerBar ?? 8)) - { - base.Remove(nxt); - } - } - if (nxtE != null) - base.Add(new SetCrotchetsPerBar - { - _beat = nxtE._beat, - _crotchetsPerBar = ((frt != null) ? frt.CrotchetsPerBar : 8u - 1u) - }); - Calculator.Refresh(); - } - //更新计算器 - Calculator.Refresh(); - bool result = base.Remove(item); - RefreshCPBs(item.Beat); - item._beat._calculator = null; - Calculator.Refresh(); - return result; - } - private void AddBaseBeatsPerMinute(BaseBeatsPerMinute item) - { - RefreshBPMs(item.Beat); - base.Add(item); - Calculator.Refresh(); - } - private bool RemoveBaseBeatsPerMinute(BaseBeatsPerMinute item) - { - bool result = base.Remove(item); - Calculator.Refresh(); - RefreshBPMs(item.Beat); - item._beat._calculator = null; - return result; - } - private void RefreshBPMs(RDBeat start) - { - foreach (var item in eventsBeatOrder.Keys) - item.ResetBPM(); - foreach (var item in this.Where(i => i.Beat > start)) - item.Beat.ResetBPM(); - foreach (var item in Bookmarks) - item.Beat.ResetBPM(); - } - private void RefreshCPBs(RDBeat start) - { - foreach (var item in eventsBeatOrder.Keys) - item.ResetCPB(); - foreach (var item in this.Where(i => i.Beat > start)) - item.Beat.ResetCPB(); - foreach (var item in Bookmarks) - item.Beat.ResetCPB(); - } - /// - public void Dispose() - { - if (isZip) - { - System.IO.Directory.Delete(Directory, true); - } - GC.SuppressFinalize(this); - } - /// - public override string ToString() => $"\"{Settings.Song}\" Count = {Count}"; - internal string _path; - private bool isZip = false; - private RDColor[] colorPalette = new RDColor[21]; - - /// - /// Variables. - /// - [JsonIgnore] - public readonly RDVariables Variables; - } -} diff --git a/RhythmBaseCore/Components/RDPoint.cs b/RhythmBaseCore/Components/RDPoint.cs deleted file mode 100644 index 931c0c4..0000000 --- a/RhythmBaseCore/Components/RDPoint.cs +++ /dev/null @@ -1,175 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using RhythmBase.Extensions; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// A point whose horizontal and vertical coordinates are nullable - /// - [JsonConverter(typeof(RDPointsConverter))] - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDPoint(float? x, float? y) : IRDVortex, IRDVortex - { - /// - /// Initializes a new instance of the struct with the specified size. - /// - /// The size to initialize the point with. - public RDPoint(RDSize sz) : this(sz.Width, sz.Height) { } - - /// - /// Gets a value indicating whether this point is empty. - /// - public readonly bool IsEmpty => X == null && Y == null; - - /// - /// Gets or sets the X coordinate of the point. - /// - public float? X { get; set; } = x; - - /// - /// Gets or sets the Y coordinate of the point. - /// - public float? Y { get; set; } = y; - - /// - /// Offsets the point by the specified point. - /// - /// The point to offset by. - public void Offset(RDPoint p) - { - X += p.X; - Y += p.Y; - } - - /// - /// Offsets the point by the specified amounts. - /// - /// The amount to offset the X coordinate. - /// The amount to offset the Y coordinate. - public void Offset(float? dx, float? dy) - { - X += dx; - Y += dy; - } - - /// - /// Adds the specified size to the point. - /// - /// The point to add to. - /// The size to add. - /// A new point that is the result of the addition. - public static RDPoint Add(RDPoint pt, RDSizeI sz) => new( - pt.X + sz.Width, pt.Y + sz.Height - ); - - /// - /// Adds the specified size to the point. - /// - /// The point to add to. - /// The size to add. - /// A new point that is the result of the addition. - public static RDPoint Add(RDPoint pt, RDSize sz) => new( - pt.X + sz.Width, pt.Y + sz.Height - ); - - /// - /// Subtracts the specified size from the point. - /// - /// The point to subtract from. - /// The size to subtract. - /// A new point that is the result of the subtraction. - public static RDPoint Subtract(RDPoint pt, RDSizeI sz) => new( - pt.X - sz.Width, pt.Y - sz.Height - ); - - /// - /// Subtracts the specified size from the point. - /// - /// The point to subtract from. - /// The size to subtract. - /// A new point that is the result of the subtraction. - public static RDPoint Subtract(RDPoint pt, RDSize sz) => new( - pt.X - sz.Width, pt.Y - sz.Height - ); - - /// - /// Multiplies the point by the specified matrix. - /// - /// The matrix to multiply by. - /// A new point that is the result of the multiplication. - /// Thrown when the matrix is not a 2x2 matrix. - public readonly RDPoint MultipyByMatrix(float[,] matrix) - { - if (matrix.Rank == 2 && matrix.Length == 4) - { - RDPoint MultipyByMatrix = new(X * matrix[0, 0] + Y * matrix[1, 0], X * matrix[0, 1] + Y * matrix[1, 1]); - return MultipyByMatrix; - } - throw new Exception("Matrix not match, 2*2 matrix expected."); - } - /// - /// Rotate. - /// - public readonly RDPoint Rotate(float angle) - { - float[,] array = new float[2, 2]; - array[0, 0] = (float)Math.Cos((double)angle); - array[0, 1] = (float)Math.Sin((double)angle); - array[1, 0] = (float)-(float)Math.Sin((double)angle); - array[1, 1] = (float)Math.Cos((double)angle); - return MultipyByMatrix(array); - } - /// - /// Rotate at a given pivot. - /// - /// Given pivot. - /// Angle. - /// - public readonly RDPoint Rotate(RDPointN pivot, float angle) => (this - new RDSizeN(pivot)).Rotate(angle) + new RDSizeN(pivot); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDPoint e && Equals(e); - /// - public override readonly int GetHashCode() - { - HashCode h = default; - h.Add(X); - h.Add(Y); - return h.ToHashCode(); - } - /// - public override readonly string ToString() => $"[{X?.ToString() ?? "null"}, {Y?.ToString() ?? "null"}]"; - /// - public readonly bool Equals(RDPoint other) => other.X.NullableEquals(X) && other.Y.NullableEquals(Y); - /// - public static RDPoint operator +(RDPoint pt, RDSizeI sz) => Add(pt, sz); - /// - public static RDPoint operator +(RDPoint pt, RDSize sz) => Add(pt, sz); - /// - public static RDPoint operator -(RDPoint pt, RDSizeI sz) => Subtract(pt, sz); - /// - public static RDPoint operator -(RDPoint pt, RDSize sz) => Subtract(pt, sz); - /// - public static RDPoint operator *(RDPoint pt, float? x) => new(pt.X * x, pt.Y * x); - /// - public static RDPoint operator /(RDPoint pt, float? x) => new(pt.X / x, pt.Y / x); - /// - public static bool operator ==(RDPoint left, RDPoint right) => left.Equals(right); - /// - public static bool operator !=(RDPoint left, RDPoint right) => !left.Equals(right); - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// A new with the same coordinates as the input . - public static implicit operator RDPointE(RDPoint p) => new(p.X, p.Y); - /// - /// Explicitly converts an to an . - /// - /// The to convert. - /// A new with the same coordinates as the input . - public static explicit operator RDSize(RDPoint p) => new(p.X, p.Y); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDPointE.cs b/RhythmBaseCore/Components/RDPointE.cs deleted file mode 100644 index 9055539..0000000 --- a/RhythmBaseCore/Components/RDPointE.cs +++ /dev/null @@ -1,237 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// A point whose horizontal and vertical coordinates are nullable - /// - [JsonConverter(typeof(RDPointsConverter))] - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDPointE(RDExpression? x, RDExpression? y) : - IRDVortex, - IRDVortex, - IRDVortex - { - /// - /// Initializes a new instance of the struct with the specified size. - /// - /// The size to initialize the point with. - public RDPointE(RDSize sz) : this(sz.Width, sz.Height) { } - - /// - /// Initializes a new instance of the struct with the specified coordinates. - /// - /// The x-coordinate. - /// The y-coordinate. - public RDPointE(float x, float y) : this((RDExpression)x, (RDExpression)y) { } - - /// - /// Initializes a new instance of the struct with the specified x-coordinate and y-coordinate. - /// - /// The x-coordinate. - /// The y-coordinate. - public RDPointE(RDExpression? x, float y) : this(x, (RDExpression)y) { } - - /// - /// Initializes a new instance of the struct with the specified x-coordinate and y-coordinate. - /// - /// The x-coordinate. - /// The y-coordinate. - public RDPointE(float x, RDExpression? y) : this((RDExpression)x, y) { } - - /// - /// Initializes a new instance of the struct with the specified x-coordinate and y-coordinate. - /// - /// The x-coordinate. - /// The y-coordinate. - public RDPointE(string x, float y) : this((RDExpression)x, (RDExpression)y) { } - - /// - /// Initializes a new instance of the struct with the specified x-coordinate and y-coordinate. - /// - /// The x-coordinate. - /// The y-coordinate. - public RDPointE(float x, string y) : this((RDExpression)x, (RDExpression)y) { } - - /// - /// Initializes a new instance of the struct with the specified x-coordinate and y-coordinate. - /// - /// The x-coordinate. - /// The y-coordinate. - public RDPointE(string x, RDExpression? y) : this((RDExpression)x, y) { } - - /// - /// Initializes a new instance of the struct with the specified x-coordinate and y-coordinate. - /// - /// The x-coordinate. - /// The y-coordinate. - public RDPointE(RDExpression? x, string y) : this(x, (RDExpression)y) { } - - /// - /// Initializes a new instance of the struct with the specified x-coordinate and y-coordinate. - /// - /// The x-coordinate. - /// The y-coordinate. - public RDPointE(string x, string y) : this((RDExpression)x, (RDExpression)y) { } - - /// - /// Initializes a new instance of the struct with the specified point. - /// - /// The point to initialize the point with. - public RDPointE(RDPointI p) : this(p.X, p.Y) { } - - /// - /// Initializes a new instance of the struct with the specified point. - /// - /// The point to initialize the point with. - public RDPointE(RDPoint p) : this(p.X, p.Y) { } - /// - public readonly bool IsEmpty => X == null && Y == null; - - /// - public RDExpression? X { get; set; } = x; - - /// - public RDExpression? Y { get; set; } = y; - - /// - /// Offsets the point by the specified point. - /// - /// The point to offset by. - public void Offset(RDPoint p) - { - X += p.X; - Y += p.Y; - } - - /// - /// Offsets the point by the specified amounts. - /// - /// The amount to offset the x-coordinate. - /// The amount to offset the y-coordinate. - public void Offset(float? dx, float? dy) - { - X += dx; - Y += dy; - } - - /// - /// Adds the specified size to the point. - /// - /// The point to add to. - /// The size to add. - /// The resulting point. - public static RDPointE Add(RDPointE pt, RDSizeI sz) => new( - pt.X + sz.Width, pt.Y + sz.Height - ); - - /// - public static RDPointE Add(RDPointE pt, RDSize sz) => new( - pt.X + sz.Width, pt.Y + sz.Height - ); - - /// - public static RDPointE Add(RDPointE pt, RDSizeE sz) => new( - pt.X + sz.Width, pt.Y + sz.Height - ); - - /// - /// Subtracts the specified size from the point. - /// - /// The point to subtract from. - /// The size to subtract. - /// The resulting point. - public static RDPointE Subtract(RDPointE pt, RDSizeI sz) => new( - pt.X - sz.Width, pt.Y - sz.Height - ); - - /// - public static RDPointE Subtract(RDPointE pt, RDSize sz) => new( - pt.X - sz.Width, pt.Y - sz.Height - ); - - /// - public static RDPointE Subtract(RDPointE pt, RDSizeE sz) => new( - pt.X - sz.Width, pt.Y - sz.Height - ); - - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDPointE e && Equals(e); - - /// - public override readonly int GetHashCode() => HashCode.Combine(X, Y); - - /// - public override readonly string ToString() => $"[{(X?.ExpressionValue) ?? "null"},{(Y?.ExpressionValue) ?? "null"}]"; - - /// - public readonly bool Equals(RDPointE other) => other.X == X && other.Y == Y; - - /// - /// Multiplies the point by the specified matrix. - /// - /// The matrix to multiply by. - /// The resulting point. - /// Thrown when the matrix is not 2x2. - public readonly RDPointE MultipyByMatrix(RDExpression[,] matrix) - { - if (matrix.Rank == 2 && matrix.Length == 4) - { - RDPointE MultipyByMatrix = new( - X * matrix[0, 0] + Y * matrix[1, 0], - X * matrix[0, 1] + Y * matrix[1, 1]); - return MultipyByMatrix; - } - throw new Exception("Matrix not match, 2*2 matrix expected."); - } - /// - /// Rotate. - /// - public readonly RDPointE Rotate(float angle) - { - RDExpression[,] array = new RDExpression[2, 2]; - array[0, 0] = (float)Math.Cos((double)angle); - array[0, 1] = (float)Math.Sin((double)angle); - array[1, 0] = (float)-(float)Math.Sin((double)angle); - array[1, 1] = (float)Math.Cos((double)angle); - return MultipyByMatrix(array); - } - /// - /// Rotate at a given pivot. - /// - /// Given pivot. - /// Angle. - /// - public readonly RDPointE Rotate(RDPointE pivot, float angle) => (this - new RDSizeE(pivot)).Rotate(angle) + new RDSizeE(pivot); - /// - public static RDPointE operator +(RDPointE pt, RDSizeI sz) => Add(pt, sz); - /// - public static RDPointE operator +(RDPointE pt, RDSize sz) => Add(pt, sz); - /// - public static RDPointE operator +(RDPointE pt, RDSizeE sz) => Add(pt, sz); - /// - public static RDPointE operator -(RDPointE pt, RDSizeI sz) => Subtract(pt, sz); - /// - public static RDPointE operator -(RDPointE pt, RDSize sz) => Subtract(pt, sz); - /// - public static RDPointE operator -(RDPointE pt, RDSizeE sz) => Subtract(pt, sz); - /// - public static RDPointE operator *(RDPointE pt, RDExpression x) => new(pt.X * x, pt.Y * x); - /// - public static RDPointE operator /(RDPointE pt, RDExpression x) => new(pt.X / x, pt.Y / x); - /// - public static bool operator ==(RDPointE left, RDPointE right) => left.Equals(right); - /// - public static bool operator !=(RDPointE left, RDPointE right) => !left.Equals(right); - - /// - /// Converts the specified to an . - /// - /// The point to convert. - /// An that represents the converted point. - public static explicit operator RDSizeE(RDPointE p) => new(p); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDPointI.cs b/RhythmBaseCore/Components/RDPointI.cs deleted file mode 100644 index 2dc2827..0000000 --- a/RhythmBaseCore/Components/RDPointI.cs +++ /dev/null @@ -1,201 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// A point whose horizontal and vertical coordinates are nullable - /// - [JsonConverter(typeof(RDPointsConverter))] - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDPointI(int? x, int? y) : IRDVortex - { - /// - /// Initializes a new instance of the struct with the specified size. - /// - /// The size to initialize the point with. - public RDPointI(RDSizeI sz) : this(sz.Width, sz.Height) { } - - /// - /// Initializes a new instance of the struct with the specified nullable size. - /// - /// The nullable size to initialize the point with. - public RDPointI(RDSizeN sz) : this( - (int)Math.Round((double)sz.Width), - (int)Math.Round((double)sz.Height)) - { } - - /// - /// Gets a value indicating whether this point is empty. - /// - public readonly bool IsEmpty => X == null && Y == null; - - /// - /// Gets or sets the X coordinate of this point. - /// - public int? X { get; set; } = x; - - /// - /// Gets or sets the Y coordinate of this point. - /// - public int? Y { get; set; } = y; - - /// - /// Offsets this point by the specified point. - /// - /// The point to offset by. - public void Offset(RDPointI p) - { - X += p.X; - Y += p.Y; - } - - /// - /// Offsets this point by the specified amounts. - /// - /// The amount to offset the X coordinate. - /// The amount to offset the Y coordinate. - public void Offset(int? dx, int? dy) - { - X += dx; - Y += dy; - } - - /// - /// Returns a new point that is the ceiling of the specified point. - /// - /// The point to ceiling. - /// A new point that is the ceiling of the specified point. - public static RDPointI Ceiling(RDPoint value) => new( - (value.X == null) ? null : (int)Math.Ceiling((double)value.X), - (value.Y == null) ? null : (int)Math.Ceiling((double)value.Y) - ); - - /// - /// Adds the specified size to the specified point. - /// - /// The point to add to. - /// The size to add. - /// A new point that is the sum of the specified point and size. - public static RDPointI Add(RDPointI pt, RDSizeI sz) => new( - pt.X + sz.Width, pt.Y + sz.Height - ); - - /// - /// Returns a new point that is the truncated value of the specified point. - /// - /// The point to truncate. - /// A new point that is the truncated value of the specified point. - public static RDPointI Truncate(RDPoint value) => new( - (value.X == null) ? null : (int)Math.Truncate((double)value.X), - (value.Y == null) ? null : (int)Math.Truncate((double)value.Y) - ); - - /// - /// Subtracts the specified size from the specified point. - /// - /// The point to subtract from. - /// The size to subtract. - /// A new point that is the difference of the specified point and size. - public static RDPointI Subtract(RDPointI pt, RDSizeI sz) => new( - pt.X - sz.Width, pt.Y - sz.Height - ); - - /// - /// Returns a new point that is the rounded value of the specified point. - /// - /// The point to round. - /// A new point that is the rounded value of the specified point. - public static RDPointI Round(RDPoint value) => new( - ((value.X == null) ? null : (int)Math.Round((double)value.X.Value)), - ((value.Y == null) ? null : (int)Math.Round((double)value.Y.Value)) - ); - - /// - /// Multiplies this point by the specified matrix. - /// - /// The matrix to multiply by. - /// A new point that is the result of the multiplication. - /// Thrown when the matrix is not a 2x2 matrix. - public readonly RDPoint MultipyByMatrix(float[,] matrix) - { - if (matrix.Rank == 2 && matrix.Length == 4) - { - int? num = X; - float? num2 = (num == null ? null : num) * matrix[0, 0]; - num = Y; - float? x = num2 + ((num == null ? null : num) * matrix[1, 0]); - num = X; - float? num3 = (num == null ? null : num) * matrix[0, 1]; - num = Y; - RDPoint MultipyByMatrix = new(x, num3 + ((num != null) ? num : null) * matrix[1, 1]); - return MultipyByMatrix; - } - throw new Exception("Matrix not match, 2*2 matrix expected."); - } - - /// - /// Rotates this point by the specified angle. - /// - /// The angle to rotate by. - /// A new point that is the result of the rotation. - public readonly RDPoint Rotate(float angle) - { - float[,] array = new float[2, 2]; - array[0, 0] = (float)Math.Cos((double)angle); - array[0, 1] = (float)Math.Sin((double)angle); - array[1, 0] = (float)-(float)Math.Sin((double)angle); - array[1, 1] = (float)Math.Cos((double)angle); - return MultipyByMatrix(array); - } - /// - /// Rotate at a given pivot. - /// - /// Given pivot. - /// Angle. - /// - public readonly RDPoint Rotate(RDPointN pivot, float angle) => ((RDPoint)this - new RDSizeN(pivot)).Rotate(angle) + new RDSizeN(pivot); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDPointI e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(X, Y); - /// - public override readonly string ToString() => $"[{(X?.ToString()) ?? "null"},{(Y?.ToString()) ?? "null"}]"; - /// - public readonly bool Equals(RDPointI other) => other.X == X && other.Y == Y; - /// - public static RDPointI operator +(RDPointI pt, RDSizeI sz) => Add(pt, sz); - /// - public static RDPointI operator -(RDPointI pt, RDSizeI sz) => Subtract(pt, sz); - /// - public static RDPointI operator *(RDPointI pt, int? x) => new(pt.X * x, pt.Y * x); - /// - public static RDPointI operator /(RDPointI pt, int? x) => new(pt.X / x, pt.Y / x); - /// - public static bool operator ==(RDPointI left, RDPointI right) => left.Equals(right); - /// - public static bool operator !=(RDPointI left, RDPointI right) => !left.Equals(right); - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// A new with the same coordinates as the input . - public static implicit operator RDPoint(RDPointI p) => new(p.X, p.Y); - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// A new with the same coordinates as the input . - public static implicit operator RDPointE(RDPointI p) => new(p.X, p.Y); - - /// - /// Explicitly converts an to an . - /// - /// The to convert. - /// A new with the same dimensions as the input . - public static explicit operator RDSizeI(RDPointI p) => new(p); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDPointN.cs b/RhythmBaseCore/Components/RDPointN.cs deleted file mode 100644 index 2b547d1..0000000 --- a/RhythmBaseCore/Components/RDPointN.cs +++ /dev/null @@ -1,196 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// A point whose horizontal and vertical coordinates are non-nullable - /// - [JsonConverter(typeof(RDPointsConverter))] - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDPointN(float x, float y) : IRDVortex, IRDVortex - { - /// - /// Initializes a new instance of the struct with the specified size. - /// - /// The size to initialize the point with. - public RDPointN(RDSizeN sz) : this(sz.Width, sz.Height) { } - - /// - /// Gets or sets the X coordinate of the point. - /// - public float X { get; set; } = x; - - /// - /// Gets or sets the Y coordinate of the point. - /// - public float Y { get; set; } = y; - - /// - /// Offsets the point by the specified size. - /// - /// The size to offset the point by. - public void Offset(RDSizeN p) - { - X += p.Width; - Y += p.Height; - } - - /// - /// Offsets the point by the specified point. - /// - /// The point to offset the point by. - public void Offset(RDPointN p) - { - X += p.X; - Y += p.Y; - } - - /// - /// Offsets the point by the specified horizontal and vertical amounts. - /// - /// The horizontal amount to offset the point by. - /// The vertical amount to offset the point by. - public void Offset(float dx, float dy) - { - X += dx; - Y += dy; - } - - /// - /// Adds the specified size to the point. - /// - /// The point to add to. - /// The size to add. - /// A new point that is the result of the addition. - public static RDPointN Add(RDPointN pt, RDSizeNI sz) - { - RDPointN Add = new(pt.X + (float)sz.Width, pt.Y + (float)sz.Height); - return Add; - } - - /// - /// Adds the specified size to the point. - /// - /// The point to add to. - /// The size to add. - /// A new point that is the result of the addition. - public static RDPointN Add(RDPointN pt, RDSizeN sz) - { - RDPointN Add = new(pt.X + sz.Width, pt.Y + sz.Height); - return Add; - } - - /// - /// Subtracts the specified size from the point. - /// - /// The point to subtract from. - /// The size to subtract. - /// A new point that is the result of the subtraction. - public static RDPointN Subtract(RDPointN pt, RDSizeNI sz) - { - RDPointN Subtract = new(pt.X - (float)sz.Width, pt.Y - (float)sz.Height); - return Subtract; - } - - /// - /// Subtracts the specified size from the point. - /// - /// The point to subtract from. - /// The size to subtract. - /// A new point that is the result of the subtraction. - public static RDPointN Subtract(RDPointN pt, RDSizeN sz) - { - RDPointN Subtract = new(pt.X - sz.Width, pt.Y - sz.Height); - return Subtract; - } - - /// - /// Multiplies the point by the specified 2x2 matrix. - /// - /// The 2x2 matrix to multiply the point by. - /// A new point that is the result of the multiplication. - /// Thrown when the matrix is not a 2x2 matrix. - public readonly RDPointN MultipyByMatrix(float[,] matrix) - { - if (matrix.Rank == 2 && matrix.Length == 4) - { - RDPointN MultipyByMatrix = new(X * matrix[0, 0] + Y * matrix[1, 0], X * matrix[0, 1] + Y * matrix[1, 1]); - return MultipyByMatrix; - } - throw new Exception("Matrix not match, 2*2 matrix expected."); - } - /// - /// Rotate. - /// - public readonly RDPointN Rotate(float angle) - { - float[,] array = new float[2, 2]; - array[0, 0] = (float)Math.Cos((double)angle); - array[0, 1] = (float)Math.Sin((double)angle); - array[1, 0] = (float)-(float)Math.Sin((double)angle); - array[1, 1] = (float)Math.Cos((double)angle); - return MultipyByMatrix(array); - } - /// - /// Rotate at a given pivot. - /// - /// Given pivot. - /// Angle. - /// - public readonly RDPointN Rotate(RDPointN pivot, float angle) => (this - new RDSizeN(pivot)).Rotate(angle) + new RDSizeN(pivot); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDPointN e && Equals(e); - /// - public override readonly int GetHashCode() - { - HashCode h = default; - h.Add(X); - h.Add(Y); - return h.ToHashCode(); - } - /// - public override readonly string ToString() => $"[{X}, {Y}]"; - /// - public readonly bool Equals(RDPointN other) => other.X == X && other.Y == Y; - /// - public static RDPointN operator +(RDPointN pt, RDSizeNI sz) => Add(pt, sz); - /// - public static RDPointN operator +(RDPointN pt, RDSizeN sz) => Add(pt, sz); - /// - public static RDPointN operator -(RDPointN pt, RDSizeNI sz) => Subtract(pt, sz); - /// - public static RDPointN operator -(RDPointN pt, RDSizeN sz) => Subtract(pt, sz); - /// - public static RDPointN operator *(RDPointN pt, float x) => new(pt.X * x, pt.Y * x); - /// - public static RDPointN operator /(RDPointN pt, float x) => new(pt.X / x, pt.Y / x); - /// - public static bool operator ==(RDPointN left, RDPointN right) => left.Equals(right); - /// - public static bool operator !=(RDPointN left, RDPointN right) => !left.Equals(right); - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// A new with the same coordinates. - public static implicit operator RDPoint(RDPointN p) => new(new float?(p.X), new float?(p.Y)); - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// A new with the same coordinates. - public static implicit operator RDPointE(RDPointN p) => new(p.X, p.Y); - - /// - /// Explicitly converts an to an . - /// - /// The to convert. - /// A new with the same dimensions. - public static explicit operator RDSizeN(RDPointN p) => new(p.X, p.Y); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDPointNI.cs b/RhythmBaseCore/Components/RDPointNI.cs deleted file mode 100644 index dcbb423..0000000 --- a/RhythmBaseCore/Components/RDPointNI.cs +++ /dev/null @@ -1,200 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// A point whose horizontal and vertical coordinates are non-nullable - /// - [JsonConverter(typeof(RDPointsConverter))] - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDPointNI(int x, int y) : IRDVortex - { - /// - /// Initializes a new instance of the struct with the specified size. - /// - /// The size to initialize the point with. - public RDPointNI(RDSizeNI sz) : this(sz.Width, sz.Height) { } - - /// - /// Gets or sets the X coordinate of the point. - /// - public int X { get; set; } = x; - - /// - /// Gets or sets the Y coordinate of the point. - /// - public int Y { get; set; } = y; - - /// - /// Offsets the point by the specified point. - /// - /// The point to offset by. - public void Offset(RDPointNI p) - { - X += p.X; - Y += p.Y; - } - - /// - /// Offsets the point by the specified size. - /// - /// The size to offset by. - public void Offset(RDSizeNI p) - { - X += p.Width; - Y += p.Height; - } - - /// - /// Offsets the point by the specified horizontal and vertical amounts. - /// - /// The horizontal offset. - /// The vertical offset. - public void Offset(int dx, int dy) - { - X += dx; - Y += dy; - } - - /// - /// Returns a new point with coordinates rounded up to the nearest integer values. - /// - /// The point to round up. - /// A new point with coordinates rounded up. - public static RDPointNI Ceiling(RDPointN value) => new( - (int)Math.Ceiling((double)value.X), - (int)Math.Ceiling((double)value.Y) - ); - - /// - /// Adds the specified size to the point. - /// - /// The point to add to. - /// The size to add. - /// A new point with the size added. - public static RDPointNI Add(RDPointNI pt, RDSizeNI sz) => new( - pt.X + sz.Width, pt.Y + sz.Height - ); - - /// - /// Returns a new point with coordinates truncated to the nearest integer values. - /// - /// The point to truncate. - /// A new point with coordinates truncated. - public static RDPointNI Truncate(RDPointN value) => new( - (int)Math.Truncate((double)value.X), - (int)Math.Truncate((double)value.Y) - ); - - /// - /// Subtracts the specified size from the point. - /// - /// The point to subtract from. - /// The size to subtract. - /// A new point with the size subtracted. - public static RDPointNI Subtract(RDPointNI pt, RDSizeNI sz) => new( - pt.X - sz.Width, pt.Y - sz.Height - ); - - /// - /// Returns a new point with coordinates rounded to the nearest integer values. - /// - /// The point to round. - /// A new point with coordinates rounded. - public static RDPointNI Round(RDPointN value) => new( - (int)Math.Round((double)value.X), - (int)Math.Round((double)value.Y) - ); - - /// - /// Multiplies the point by the specified 2x2 matrix. - /// - /// The 2x2 matrix to multiply by. - /// A new point resulting from the matrix multiplication. - /// Thrown when the matrix is not a 2x2 matrix. - public readonly RDPointN MultipyByMatrix(float[,] matrix) - { - if (matrix.Rank == 2 && matrix.Length == 4) - { - RDPointN MultipyByMatrix = new(X * matrix[0, 0] + (Y * matrix[1, 0]), (X * matrix[0, 1]) + Y * matrix[1, 1]); - return MultipyByMatrix; - } - throw new Exception("Matrix not match, 2*2 matrix expected."); - } - /// - /// Rotate. - /// - public readonly RDPointN Rotate(float angle) - { - float[,] array = new float[2, 2]; - array[0, 0] = (float)Math.Cos((double)angle); - array[0, 1] = (float)Math.Sin((double)angle); - array[1, 0] = -(float)Math.Sin((double)angle); - array[1, 1] = (float)Math.Cos((double)angle); - return MultipyByMatrix(array); - } - /// - /// Rotate at a given pivot. - /// - /// Given pivot. - /// Angle. - /// - public readonly RDPointN Rotate(RDPointN pivot, float angle) => ((RDPointN)this - new RDSizeN(pivot)).Rotate(angle) + new RDSizeN(pivot); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDPointNI e && Equals(e); - /// - public override readonly int GetHashCode() - { - HashCode h = default; - h.Add(X); - h.Add(Y); - return h.ToHashCode(); - } - /// - public override readonly string ToString() => $"[{X}, {Y}]"; - /// - public readonly bool Equals(RDPointNI other) => other.X == X && other.Y == Y; - /// - public static RDPointNI operator +(RDPointNI pt, RDSizeNI sz) => Add(pt, sz); - /// - public static RDPointNI operator -(RDPointNI pt, RDSizeNI sz) => Subtract(pt, sz); - /// - public static RDPointNI operator *(RDPointNI pt, int x) => new(pt.X * x, pt.Y * x); - /// - public static RDPointNI operator /(RDPointNI pt, int x) => new(pt.X / x, pt.Y / x); - /// - public static bool operator ==(RDPointNI left, RDPointNI right) => left.Equals(right); - /// - public static bool operator !=(RDPointNI left, RDPointNI right) => !left.Equals(right); - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// An with the same coordinates. - public static implicit operator RDPointN(RDPointNI p) => new(p.X, p.Y); - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// An with the same coordinates. - public static implicit operator RDPointI(RDPointNI p) => new(new int?(p.X), new int?(p.Y)); - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// An with the same coordinates. - public static implicit operator RDPointE(RDPointNI p) => new(p.X, p.Y); - - /// - /// Explicitly converts an to an . - /// - /// The to convert. - /// An with the same dimensions. - public static explicit operator RDSizeNI(RDPointNI p) => new(p.X, p.Y); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDRange.cs b/RhythmBaseCore/Components/RDRange.cs deleted file mode 100644 index 533eafa..0000000 --- a/RhythmBaseCore/Components/RDRange.cs +++ /dev/null @@ -1,92 +0,0 @@ -using RhythmBase.Exceptions; -namespace RhythmBase.Components -{ - /// - /// Beat range. - /// - public struct RDRange - { - /// - /// Start beat. - /// - public RDBeat? Start { get; } - /// - /// End beat. - /// - public RDBeat? End { get; } - /// - /// Beat interval. - /// - public readonly float BeatInterval - { - get - { - bool flag = Start != null && End != null; - float BeatInterval; - if (flag) - { - BeatInterval = End!.Value.BeatOnly - Start!.Value.BeatOnly; - } - else - { - BeatInterval = float.PositiveInfinity; - } - return BeatInterval; - } - } - /// - /// Time interval. - /// - /// - public readonly TimeSpan TimeInterval - { - get - { - bool flag = Start != null && End != null; - TimeSpan TimeInterval; - if (flag) - { - if (Start!.Value.BeatOnly == End!.Value.BeatOnly) - { - TimeInterval = TimeSpan.Zero; - } - else - { - TimeInterval = End.Value.TimeSpan - Start.Value.TimeSpan; - } - } - else - { - TimeInterval = TimeSpan.MaxValue; - } - return TimeInterval; - } - } - /// Start beat. - /// End beat. - public RDRange(RDBeat? start, RDBeat? end) - { - this = default; - if (start != null && end != null && !((RDBeat)start).FromSameLevelOrNull((RDBeat)end)) - { - throw new RhythmBaseException("RDIndexes must come from the same RDLevel."); - } - if (start != null && end != null && start > end) - { - Start = end; - End = start; - } - else - { - Start = start; - End = end; - } - } - /// - /// Determines whether the specified beat is within the range. - /// - /// The beat to check. - /// True if the beat is within the range; otherwise, false. - public readonly bool Contains(RDBeat b) => (Start == null || Start < b) && (End == null || b < End); - } -} diff --git a/RhythmBaseCore/Components/RDRect.cs b/RhythmBaseCore/Components/RDRect.cs deleted file mode 100644 index e1c0344..0000000 --- a/RhythmBaseCore/Components/RDRect.cs +++ /dev/null @@ -1,268 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// Represents a rectangle defined by its left, top, right, and bottom edges. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDRect(float? left, float? top, float? right, float? bottom) : IEquatable - { - /// - /// Gets or sets the left edge of the rectangle. - /// - public float? Left { get; set; } = left; - - /// - /// Gets or sets the right edge of the rectangle. - /// - public float? Right { get; set; } = right; - - /// - /// Gets or sets the top edge of the rectangle. - /// - public float? Top { get; set; } = top; - - /// - /// Gets or sets the bottom edge of the rectangle. - /// - public float? Bottom { get; set; } = bottom; - - /// - /// Gets the point at the left-bottom corner of the rectangle. - /// - public readonly RDPoint LeftBottom { get => new(Left, Bottom); } - - /// - /// Gets the point at the right-bottom corner of the rectangle. - /// - public readonly RDPoint RightBottom { get => new(Right, Bottom); } - - /// - /// Gets the point at the left-top corner of the rectangle. - /// - public readonly RDPoint LeftTop { get => new(Left, Top); } - - /// - /// Gets the point at the right-top corner of the rectangle. - /// - public readonly RDPoint RightTop { get => new(Right, Top); } - - /// - /// Gets the width of the rectangle. - /// - public readonly float? Width => Right - Left; - - /// - /// Gets the height of the rectangle. - /// - public readonly float? Height => Top - Bottom; - - /// - /// Initializes a new instance of the struct with the specified location and size. - /// - /// The location of the rectangle. - /// The size of the rectangle. - public RDRect(RDPoint? location, RDSize? size) : this(location?.X, location?.Y + size?.Height, location?.X + size?.Width, location?.Y) { } - - /// - /// Initializes a new instance of the struct with the specified size. - /// - /// The size of the rectangle. - public RDRect(RDSize size) : this(new float?(0f), size.Height, size.Width, new float?(0f)) { } - - /// - /// Initializes a new instance of the struct with the specified width and height. - /// - /// The width of the rectangle. - /// The height of the rectangle. - public RDRect(float? width, float? height) : this(new float?(0f), height, width, new float?(0f)) { } - - /// - /// Gets the location of the rectangle. - /// - public readonly RDPoint Location => new(Left, Bottom); - - /// - /// Gets the size of the rectangle. - /// - public readonly RDSize Size => new(Width, Height); - - /// - /// Inflates the specified rectangle by the specified size. - /// - /// The rectangle to inflate. - /// The size to inflate by. - /// The inflated rectangle. - public static RDRect Inflate(RDRect rect, RDSize size) - { - RDRect result = new(rect.Left, rect.Top, rect.Right, rect.Bottom); - result.Inflate(size); - return result; - } - - /// - /// Inflates the specified rectangle by the specified width and height. - /// - /// The rectangle to inflate. - /// The width to inflate by. - /// The height to inflate by. - /// The inflated rectangle. - public static RDRect Inflate(RDRect rect, float? x, float? y) - { - RDRect result = new(rect.Left, rect.Top, rect.Right, rect.Bottom); - result.Inflate(x, y); - return result; - } - - /// - /// Returns the union of two rectangles. - /// - /// The first rectangle. - /// The second rectangle. - /// The union of the two rectangles. - public static RDRect Union(RDRect rect1, RDRect rect2) - { - RDRect Union = new(new float?((rect1.Left == null || rect2.Left == null) ? 0f : Math.Min(rect1.Left.Value, rect2.Left.Value)), new float?((rect1.Top == null || rect2.Top == null) ? 0f : Math.Min(rect1.Top.Value, rect2.Top.Value)), new float?((rect1.Right == null || rect2.Right == null) ? 0f : Math.Min(rect1.Right.Value, rect2.Right.Value)), new float?((rect1.Bottom == null || rect2.Bottom == null) ? 0f : Math.Min(rect1.Bottom.Value, rect2.Bottom.Value))); - return Union; - } - - /// - /// Returns the intersection of two rectangles. - /// - /// The first rectangle. - /// The second rectangle. - /// The intersection of the two rectangles. - public static RDRect Intersect(RDRect rect1, RDRect rect2) => rect1.IntersectsWithInclusive(rect2) ? new RDRect(new float?((rect1.Left == null || rect2.Left == null) ? 0f : Math.Max(rect1.Left.Value, rect2.Left.Value)), new float?((rect1.Top == null || rect2.Top == null) ? 0f : Math.Max(rect1.Top.Value, rect2.Top.Value)), new float?((rect1.Right == null || rect2.Right == null) ? 0f : Math.Min(rect1.Right.Value, rect2.Right.Value)), new float?((rect1.Bottom == null || rect2.Bottom == null) ? 0f : Math.Min(rect1.Bottom.Value, rect2.Bottom.Value))) : default; - - /// - /// Truncates the edges of the specified rectangle. - /// - /// The rectangle to truncate. - /// The truncated rectangle. - public static RDRect Truncate(RDRect rect) - { - RDRect Truncate = new( - rect.Left == null ? null : (float)Math.Truncate((double)rect.Left), - rect.Top == null ? null : (float)Math.Truncate((double)rect.Top), - rect.Right == null ? null : (float)Math.Truncate((double)rect.Right), - rect.Bottom == null ? null : (float)Math.Truncate((double)rect.Bottom)); - return Truncate; - } - - /// - /// Offsets the rectangle by the specified width and height. - /// - /// The width to offset by. - /// The height to offset by. - public void Offset(float? x, float? y) - { - Left += x; - Top += y; - Right += x; - Bottom += y; - } - - /// - /// Offsets the rectangle by the specified point. - /// - /// The point to offset by. - public void Offset(RDPoint p) => Offset(p.X, p.Y); - - /// - /// Inflates the rectangle by the specified size. - /// - /// The size to inflate by. - public void Inflate(RDSize size) - { - Left -= size.Width; - Top += size.Height; - Right += size.Width; - Bottom -= size.Height; - } - - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The width to inflate by. - /// The height to inflate by. - public void Inflate(float? width, float? height) - { - Left -= width; - Top += height; - Right += width; - Bottom -= height; - } - - /// - /// Determines whether the rectangle contains the specified point. - /// - /// The x-coordinate of the point. - /// The y-coordinate of the point. - /// true if the rectangle contains the point; otherwise, false. - public readonly bool Contains(float? x, float? y) => Left < x && x < Right && Bottom < y && y < Top; - - /// - /// Determines whether the rectangle contains the specified point. - /// - /// The point to check. - /// true if the rectangle contains the point; otherwise, false. - public readonly bool Contains(RDPoint p) => Contains(p.X, p.Y); - - /// - /// Determines whether the rectangle contains the specified rectangle. - /// - /// The rectangle to check. - /// true if the rectangle contains the specified rectangle; otherwise, false. - public readonly bool Contains(RDRect rect) => Left < rect.Left && rect.Right < Right && Bottom < rect.Bottom && rect.Top < Top; - - /// - /// Returns the union of this rectangle and the specified rectangle. - /// - /// The rectangle to union with. - /// The union of the two rectangles. - public readonly RDRect Union(RDRect rect) => Union(this, rect); - - /// - /// Returns the intersection of this rectangle and the specified rectangle. - /// - /// The rectangle to intersect with. - /// The intersection of the two rectangles. - public readonly object Intersect(RDRect rect) => Intersect(this, rect); - - /// - /// Determines whether this rectangle intersects with the specified rectangle. - /// - /// The rectangle to check. - /// true if the rectangles intersect; otherwise, false. - public readonly bool IntersectsWith(RDRect rect) => Left < rect.Right && Right > rect.Left && Top < rect.Bottom && Bottom > rect.Top; - - /// - /// Determines whether this rectangle intersects with the specified rectangle, including edges. - /// - /// The rectangle to check. - /// true if the rectangles intersect; otherwise, false. - public readonly bool IntersectsWithInclusive(RDRect rect) => Left <= rect.Right && Right >= rect.Left && Top <= rect.Bottom && Bottom >= rect.Top; - - /// - public static bool operator ==(RDRect rect1, RDRect rect2) => rect1.Equals(rect2); - - /// - public static bool operator !=(RDRect rect1, RDRect rect2) => !rect1.Equals(rect2); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDRect e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Left, Top, Right, Bottom); - /// - public override readonly string ToString() => $"{{Location=[{Left?.ToString() ?? "null"},{Bottom?.ToString() ?? "null"}],Size=[{Width?.ToString() ?? "null"},{Height?.ToString() ?? "null"}]}}"; - /// - public readonly bool Equals(RDRect other) => Left == other.Left && Top == other.Top && Right == other.Right && Bottom == other.Bottom; - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// The converted . - public static implicit operator RDRectE(RDRect rect) => new(rect.Left, rect.Top, rect.Right, rect.Bottom); - private readonly string GetDebuggerDisplay() => ToString(); - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Components/RDRectE.cs b/RhythmBaseCore/Components/RDRectE.cs deleted file mode 100644 index 125e4d8..0000000 --- a/RhythmBaseCore/Components/RDRectE.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// Represents a rectangle defined by four expressions: left, top, right, and bottom. - /// - /// The left expression of the rectangle. - /// The top expression of the rectangle. - /// The right expression of the rectangle. - /// The bottom expression of the rectangle. - public struct RDRectE(RDExpression? left, RDExpression? top, RDExpression? right, RDExpression? bottom) : IEquatable - { - /// - /// Gets or sets the left expression of the rectangle. - /// - public RDExpression? Left { get; set; } = left; - - /// - /// Gets or sets the right expression of the rectangle. - /// - public RDExpression? Right { get; set; } = right; - - /// - /// Gets or sets the top expression of the rectangle. - /// - public RDExpression? Top { get; set; } = top; - - /// - /// Gets or sets the bottom expression of the rectangle. - /// - public RDExpression? Bottom { get; set; } = bottom; - - /// - /// Gets the left-bottom point of the rectangle. - /// - public readonly RDPointE LeftBottom => new(Left, Bottom); - - /// - /// Gets the right-bottom point of the rectangle. - /// - public readonly RDPointE RightBottom => new(Right, Bottom); - - /// - /// Gets the left-top point of the rectangle. - /// - public readonly RDPointE LeftTop => new(Left, Top); - - /// - /// Gets the right-top point of the rectangle. - /// - public readonly RDPointE RightTop => new(Right, Top); - - /// - /// Gets the width of the rectangle. - /// - public readonly RDExpression? Width => Right - Left; - - /// - /// Gets the height of the rectangle. - /// - public readonly RDExpression? Height => Top - Bottom; - - /// - /// Initializes a new instance of the struct with the specified location and size. - /// - /// The location of the rectangle. - /// The size of the rectangle. - public RDRectE(RDPointE? location, RDSizeE? size) : this(location?.X, location?.Y + size?.Height, location?.X + size?.Width, location?.Y) { } - - /// - /// Initializes a new instance of the struct with the specified size. - /// - /// The size of the rectangle. - public RDRectE(RDSizeE size) : this(new RDExpression?(0f), size.Height, size.Width, new RDExpression?(0f)) { } - - /// - /// Initializes a new instance of the struct with the specified width and height. - /// - /// The width of the rectangle. - /// The height of the rectangle. - public RDRectE(RDExpression? width, RDExpression? height) : this(new RDExpression?(0f), height, width, new RDExpression?(0f)) { } - - /// - /// Gets the location of the rectangle. - /// - public readonly RDPointE Location => new(Left, Bottom); - - /// - /// Gets the size of the rectangle. - /// - public readonly RDSizeE Size => new(Width, Height); - - /// - /// Inflates the specified rectangle by the specified size. - /// - /// The rectangle to inflate. - /// The size to inflate by. - /// The inflated rectangle. - public static RDRectE Inflate(RDRectE rect, RDSizeE size) - { - RDRectE result = new(rect.Left, rect.Top, rect.Right, rect.Bottom); - result.Inflate(size); - return result; - } - /// - /// Inflates the specified rectangle by the specified width and height. - /// - /// The rectangle to inflate. - /// The width to inflate by. - /// The height to inflate by. - /// The inflated rectangle. - public static RDRectE Inflate(RDRectE rect, RDExpression? x, RDExpression? y) - { - RDRectE result = new(rect.Left, rect.Top, rect.Right, rect.Bottom); - result.Inflate(x, y); - return result; - } - - /// - /// Truncates the specified rectangle. - /// - /// The rectangle to truncate. - /// The truncated rectangle. - public static RDRectE Truncate(RDRectE rect) => new(rect.Left, rect.Top, rect.Right, rect.Bottom); - - /// - /// Offsets the rectangle by the specified width and height. - /// - /// The width to offset by. - /// The height to offset by. - public void Offset(RDExpression? x, RDExpression? y) - { - Left += x; - Top += y; - Right += x; - Bottom += y; - } - /// - /// Offsets the rectangle by the specified point. - /// - /// The point to offset by. - public void Offset(RDPointE p) => Offset(p.X, p.Y); - /// - /// Inflates the rectangle by the specified size. - /// - /// The size to inflate by. - public void Inflate(RDSizeE size) - { - Left -= size.Width; - Top += size.Height; - Right += size.Width; - Bottom -= size.Height; - } - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The width to inflate by. - /// The height to inflate by. - public void Inflate(RDExpression? width, RDExpression? height) - { - Left -= width; - Top += height; - Right += width; - Bottom -= height; - } - /// - public static bool operator ==(RDRectE rect1, RDRectE rect2) => rect1.Equals(rect2); - /// - public static bool operator !=(RDRectE rect1, RDRectE rect2) => !rect1.Equals(rect2); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDRectE e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Left, Top, Right, Bottom); - /// - public override readonly string ToString() => $"{{Location=[{Left},{Bottom}],Size=[{Width},{Height}]}}"; - /// - public readonly bool Equals(RDRectE other) => Left == other.Left && Top == other.Top && Right == other.Right && Bottom == other.Bottom; - } -} diff --git a/RhythmBaseCore/Components/RDRectI.cs b/RhythmBaseCore/Components/RDRectI.cs deleted file mode 100644 index 2da32cf..0000000 --- a/RhythmBaseCore/Components/RDRectI.cs +++ /dev/null @@ -1,287 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// Represents a rectangle structure containing left, top, right, and bottom boundary values. - /// - /// The left boundary of the rectangle. - /// The top boundary of the rectangle. - /// The right boundary of the rectangle. - /// The bottom boundary of the rectangle. - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDRectI(int? left, int? top, int? right, int? bottom) : IEquatable - { - /// - /// Gets or sets the left boundary of the rectangle. - /// - public int? Left { get; set; } = left; - - /// - /// Gets or sets the right boundary of the rectangle. - /// - public int? Right { get; set; } = right; - - /// - /// Gets or sets the top boundary of the rectangle. - /// - public int? Top { get; set; } = top; - - /// - /// Gets or sets the bottom boundary of the rectangle. - /// - public int? Bottom { get; set; } = bottom; - - /// - /// Gets the bottom-left corner point of the rectangle. - /// - public readonly RDPointI LeftBottom { get => new(Left, Bottom); } - - /// - /// Gets the bottom-right corner point of the rectangle. - /// - public readonly RDPointI RightBottom { get => new(Right, Bottom); } - - /// - /// Gets the top-left corner point of the rectangle. - /// - public readonly RDPointI LeftTop { get => new(Left, Top); } - - /// - /// Gets the top-right corner point of the rectangle. - /// - public readonly RDPointI RightTop { get => new(Right, Top); } - - /// - /// Gets the width of the rectangle. - /// - public readonly int? Width => checked(Right - Left); - - /// - /// Gets the height of the rectangle. - /// - public readonly int? Height => checked(Top - Bottom); - - /// - /// Initializes a new instance of the rectangle with the specified location and size. - /// - /// The location of the rectangle. - /// The size of the rectangle. - public RDRectI(RDPointI? location, RDSizeI? size) : this(location?.X, location?.Y + size?.Height, location?.X + size?.Width, location?.Y) { } - - /// - /// Initializes a new instance of the rectangle with the specified size. - /// - /// The size of the rectangle. - public RDRectI(RDSizeI? size) : this(0, size?.Height, size?.Width, 0) { } - - /// - /// Initializes a new instance of the rectangle with the specified width and height. - /// - /// The width of the rectangle. - /// The height of the rectangle. - public RDRectI(int? width, int? height) : this(0, height, width, 0) { } - /// - /// Gets the location of the rectangle. - /// - public readonly RDPointI? Location => Left is null && Right is null ? null : new(Left, Bottom); - - /// - /// Gets the size of the rectangle. - /// - public readonly RDSizeI? Size => Width is null && Height is null ? null : new(Width, Height); - - /// - /// Inflates the rectangle by the specified size. - /// - /// The rectangle to inflate. - /// The size to inflate by. - /// The inflated rectangle. - public static RDRectI Inflate(RDRectI rect, RDSizeI size) - { - RDRectI result = new(rect.Left, rect.Top, rect.Right, rect.Bottom); - result.Inflate(size); - return result; - } - - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The rectangle to inflate. - /// The width to inflate by. - /// The height to inflate by. - /// The inflated rectangle. - public static RDRectI Inflate(RDRectI rect, int? x, int? y) - { - RDRectI result = new(rect.Left, rect.Top, rect.Right, rect.Bottom); - result.Inflate(x, y); - return result; - } - - /// - /// Converts the specified RDRect to RDRectI using ceiling. - /// - /// The RDRect to convert. - /// The converted RDRectI. - public static RDRectI Ceiling(RDRect rect) => Ceiling(rect, false); - - /// - /// Converts the specified RDRect to RDRectI using ceiling, and specifies whether to expand outwards. - /// - /// The RDRect to convert. - /// Whether to expand outwards. - /// The converted RDRectI. - public static RDRectI Ceiling(RDRect rect, bool outwards) => new( - rect.Left == null ? null : (int)(outwards && rect.Width > 0 ? Math.Floor((double)rect.Left) : Math.Ceiling((double)rect.Left)), - rect.Top == null ? null : (int)(outwards && rect.Height > 0 ? Math.Floor((double)rect.Top) : Math.Ceiling((double)rect.Top)), - rect.Right == null ? null : (int)(outwards && rect.Width < 0 ? Math.Floor((double)rect.Right) : Math.Ceiling((double)rect.Right)), - rect.Bottom == null ? null : (int)(outwards && rect.Height < 0 ? Math.Floor((double)rect.Bottom) : Math.Ceiling((double)rect.Bottom))); - - /// - /// Converts the specified RDRect to RDRectI using floor. - /// - /// The RDRect to convert. - /// The converted RDRectI. - public static RDRectI Floor(RDRect rect) => Ceiling(rect, false); - - /// - /// Converts the specified RDRect to RDRectI using floor, and specifies whether to shrink inwards. - /// - /// The RDRect to convert. - /// Whether to shrink inwards. - /// The converted RDRectI. - public static RDRectI Floor(RDRect rect, bool inwards) => new( - rect.Left == null ? null : (int)(inwards && rect.Width > 0 ? Math.Ceiling((double)rect.Left) : Math.Floor((double)rect.Left)), - rect.Top == null ? null : (int)(inwards && rect.Height > 0 ? Math.Ceiling((double)rect.Top) : Math.Floor((double)rect.Top)), - rect.Right == null ? null : (int)(inwards && rect.Width < 0 ? Math.Ceiling((double)rect.Right) : Math.Floor((double)rect.Right)), - rect.Bottom == null ? null : (int)(inwards && rect.Height < 0 ? Math.Ceiling((double)rect.Bottom) : Math.Floor((double)rect.Bottom))); - - /// - /// Converts the specified RDRect to RDRectI using rounding. - /// - /// The RDRect to convert. - /// The converted RDRectI. - public static RDRectI Round(RDRect rect) => new( - new int?((int)Math.Round((rect.Left == null) ? 0.0 : Math.Round((double)rect.Left.Value))), - new int?((int)Math.Round((rect.Top == null) ? 0.0 : Math.Round((double)rect.Top.Value))), - new int?((int)Math.Round((rect.Right == null) ? 0.0 : Math.Round((double)rect.Right.Value))), - new int?((int)Math.Round((rect.Bottom == null) ? 0.0 : Math.Round((double)rect.Bottom.Value)))); - - /// - /// Returns a new RDRectI that is the union of two rectangles. - /// - /// The first rectangle. - /// The second rectangle. - /// The union of the two rectangles. - public static RDRectI Union(RDRectI rect1, RDRectI rect2) => new( - new int?((rect1.Left == null || rect2.Left == null) ? 0 : Math.Min(rect1.Left.Value, rect2.Left.Value)), - new int?((rect1.Top == null || rect2.Top == null) ? 0 : Math.Min(rect1.Top.Value, rect2.Top.Value)), - new int?((rect1.Right == null || rect2.Right == null) ? 0 : Math.Min(rect1.Right.Value, rect2.Right.Value)), - new int?((rect1.Bottom == null || rect2.Bottom == null) ? 0 : Math.Min(rect1.Bottom.Value, rect2.Bottom.Value))); - - /// - /// Returns a new RDRectI that is the intersection of two rectangles. - /// - /// The first rectangle. - /// The second rectangle. - /// The intersection of the two rectangles. - public static RDRectI Intersect(RDRectI rect1, RDRectI rect2) => rect1.IntersectsWithInclusive(rect2) ? new RDRectI( - new int?((rect1.Left == null || rect2.Left == null) ? 0 : Math.Max(rect1.Left.Value, rect2.Left.Value)), - new int?((rect1.Top == null || rect2.Top == null) ? 0 : Math.Max(rect1.Top.Value, rect2.Top.Value)), - new int?((rect1.Right == null || rect2.Right == null) ? 0 : Math.Min(rect1.Right.Value, rect2.Right.Value)), - new int?((rect1.Bottom == null || rect2.Bottom == null) ? 0 : Math.Min(rect1.Bottom.Value, rect2.Bottom.Value))) : default; - - /// - /// Converts the specified RDRect to RDRectI by truncating the decimal part. - /// - /// The RDRect to convert. - /// The converted RDRectI. - public static RDRectI Truncate(RDRect rect) => new( - (int?)rect.Left, - (int?)rect.Top, - (int?)rect.Right, - (int?)rect.Bottom); - - /// - /// Offsets the rectangle by the specified amounts. - /// - /// The horizontal offset. - /// The vertical offset. - public void Offset(int? x, int? y) - { - Left += x; - Top += y; - Right += x; - Bottom += y; - } - /// - /// Moves the rectangle by the specified point. - /// - /// The point containing the offset. - public void Offset(RDPointI p) => Offset(p.X, p.Y); - - /// - /// Inflates the rectangle by the specified size. - /// - /// The size to inflate by. - public void Inflate(RDSizeI size) - { - Left -= size.Width; - Top += size.Height; - Right += size.Width; - Bottom -= size.Height; - } - - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The width to inflate by. - /// The height to inflate by. - public void Inflate(int? width, int? height) - { - Left -= width; - Top += height; - Right += width; - Bottom -= height; - } - /// - /// Returns a new RDRectI that is the union of the current rectangle and the specified rectangle. - /// - /// The rectangle to merge with. - /// The union of the two rectangles. - public readonly RDRectI Union(RDRectI rect) => Union(this, rect); - /// - /// Determines whether the current rectangle intersects with the specified rectangle (including edges). - /// - /// The rectangle to check. - /// true if the two rectangles intersect (including edges); otherwise, false. - public readonly bool IntersectsWithInclusive(RDRectI rect) => Left <= rect.Right && Right >= rect.Left && Top <= rect.Bottom && Bottom >= rect.Top; - /// - public static bool operator ==(RDRectI rect1, RDRectI rect2) => rect1.Equals(rect2); - /// - public static bool operator !=(RDRectI rect1, RDRectI rect2) => !rect1.Equals(rect2); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDRectI e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Left, Top, Right, Bottom); - /// - public override readonly string ToString() => $"{{Location=[{Left},{Bottom}],Size=[{Width},{Height}]}}"; - /// - public readonly bool Equals(RDRectI other) => Left == other.Left && Top == other.Top && Right == other.Right && Bottom == other.Bottom; - - /// - /// Implicitly converts an to an . - /// - /// The instance to convert. - /// The converted instance. - public static implicit operator RDRect(RDRectI rect) => new(rect.Left, rect.Top, rect.Right, rect.Bottom); - - /// - /// Implicitly converts an to an . - /// - /// The instance to convert. - /// The converted instance. - public static implicit operator RDRectE(RDRectI rect) => new(rect.Left, rect.Top, rect.Right, rect.Bottom); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDRectN.cs b/RhythmBaseCore/Components/RDRectN.cs deleted file mode 100644 index b11666b..0000000 --- a/RhythmBaseCore/Components/RDRectN.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// Represents a rectangle defined by its left, top, right, and bottom edges. - /// - /// The left edge of the rectangle. - /// The top edge of the rectangle. - /// The right edge of the rectangle. - /// The bottom edge of the rectangle. - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDRectN(float left, float top, float right, float bottom) - { - /// - /// Gets or sets the left edge of the rectangle. - /// - public float Left { get; set; } = left; - - /// - /// Gets or sets the right edge of the rectangle. - /// - public float Right { get; set; } = top; - - /// - /// Gets or sets the top edge of the rectangle. - /// - public float Top { get; set; } = right; - - /// - /// Gets or sets the bottom edge of the rectangle. - /// - public float Bottom { get; set; } = bottom; - - /// - /// Gets the point at the left-bottom corner of the rectangle. - /// - public readonly RDPointN LeftBottom => new(Left, Bottom); - - /// - /// Gets the point at the right-bottom corner of the rectangle. - /// - public readonly RDPointN RightBottom => new(Right, Bottom); - - /// - /// Gets the point at the left-top corner of the rectangle. - /// - public readonly RDPointN LeftTop => new(Left, Top); - - /// - /// Gets the point at the right-top corner of the rectangle. - /// - public readonly RDPointN RightTop => new(Right, Top); - - /// - /// Gets the width of the rectangle. - /// - public readonly float Width => Right - Left; - - /// - /// Gets the height of the rectangle. - /// - public readonly float Height => Top - Bottom; - - /// - /// Initializes a new instance of the struct with the specified location and size. - /// - /// The location of the rectangle. - /// The size of the rectangle. - public RDRectN(RDPointN location, RDSizeN size) : this(location.X, location.Y + size.Height, location.X + size.Width, location.Y) { } - - /// - /// Initializes a new instance of the struct with the specified size. - /// - /// The size of the rectangle. - public RDRectN(RDSizeN size) : this(0f, size.Height, size.Width, 0f) { } - - /// - /// Initializes a new instance of the struct with the specified width and height. - /// - /// The width of the rectangle. - /// The height of the rectangle. - public RDRectN(float width, float height) : this(0f, height, width, 0f) { } - - /// - /// Gets the location of the rectangle as an . - /// - public readonly RDPointNI Location => new((int)Math.Round((double)Left), (int)Math.Round((double)Bottom)); - - /// - /// Gets the size of the rectangle as an . - /// - public readonly RDSizeNI Size => (new RDSizeNI((int)Math.Round((double)Width), (int)Math.Round((double)Height))); - - /// - /// Inflates the specified rectangle by the specified size. - /// - /// The rectangle to inflate. - /// The size to inflate by. - /// The inflated rectangle. - public static RDRectN Inflate(RDRectN rect, RDSizeNI size) - { - RDRectN result = new(rect.Left, rect.Top, rect.Right, rect.Bottom); - result.Inflate(size); - return result; - } - - /// - /// Inflates the specified rectangle by the specified width and height. - /// - /// The rectangle to inflate. - /// The width to inflate by. - /// The height to inflate by. - /// The inflated rectangle. - public static RDRectN Inflate(RDRectN rect, float x, float y) - { - RDRectN result = new(rect.Left, rect.Top, rect.Right, rect.Bottom); - result.Inflate(x, y); - return result; - } - - /// - /// Determines whether the rectangle contains the specified point. - /// - /// The x-coordinate of the point. - /// The y-coordinate of the point. - /// true if the rectangle contains the point; otherwise, false. - public readonly bool Contains(float x, float y) => Left < x && x < Right && Bottom < y && y < Top; - - /// - /// Determines whether the rectangle contains the specified point. - /// - /// The point to check. - /// true if the rectangle contains the point; otherwise, false. - public readonly bool Contains(RDPointN p) => Left < p.X && p.X < Right && Bottom < p.Y && p.Y < Top; - - /// - /// Determines whether the rectangle contains the specified rectangle. - /// - /// The rectangle to check. - /// true if the rectangle contains the specified rectangle; otherwise, false. - public readonly bool Contains(RDRectN rect) => Left < rect.Left && rect.Right < Right && Bottom < rect.Bottom && rect.Top < Top; - - /// - /// Returns the union of two rectangles. - /// - /// The first rectangle. - /// The second rectangle. - /// The union of the two rectangles. - public static RDRectN Union(RDRectN rect1, RDRectN rect2) => new(Math.Min(rect1.Left, rect2.Left), Math.Max(rect1.Top, rect2.Top), Math.Max(rect1.Right, rect2.Right), Math.Min(rect1.Bottom, rect2.Bottom)); - - /// - /// Returns the intersection of two rectangles. - /// - /// The first rectangle. - /// The second rectangle. - /// The intersection of the two rectangles, or the default rectangle if they do not intersect. - public static RDRectN Intersect(RDRectN rect1, RDRectN rect2) => rect1.IntersectsWithInclusive(rect2) ? new RDRectN( - Math.Max(rect1.Left, rect2.Left), - Math.Max(rect1.Top, rect2.Top), - Math.Min(rect1.Right, rect2.Right), - Math.Min(rect1.Bottom, rect2.Bottom)) : default; - - /// - /// Truncates the specified rectangle. - /// - /// The rectangle to truncate. - /// The truncated rectangle. - public static RDRectN Truncate(RDRectN rect) => new(rect.Left, rect.Top, rect.Right, rect.Bottom); - - /// - /// Offsets the rectangle by the specified amount. - /// - /// The amount to offset by along the x-axis. - /// The amount to offset by along the y-axis. - public void Offset(float x, float y) - { - Left += x; - Top += y; - Right += x; - Bottom += y; - } - - /// - /// Offsets the rectangle by the specified point. - /// - /// The point to offset by. - public void Offset(RDPointN p) => Offset(p.X, p.Y); - - /// - /// Inflates the rectangle by the specified size. - /// - /// The size to inflate by. - public void Inflate(RDSizeN size) - { - Left -= size.Width; - Top += size.Height; - Right += size.Width; - Bottom -= size.Height; - } - - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The width to inflate by. - /// The height to inflate by. - public void Inflate(float width, float height) - { - Left -= width; - Top += height; - Right += width; - Bottom -= height; - } - /// - /// Returns the union of this rectangle with the specified rectangle. - /// - /// The rectangle to union with. - /// The union of the two rectangles. - public readonly RDRectN Union(RDRectN rect) => Union(this, rect); - /// - /// Determines whether this rectangle intersects with the specified rectangle, including the edges. - /// - /// The rectangle to check for intersection. - /// true if the rectangles intersect; otherwise, false. - public readonly bool IntersectsWithInclusive(RDRectN rect) => Left <= rect.Right && Right >= rect.Left && Top <= rect.Bottom && Bottom >= rect.Top; - /// - public static bool operator ==(RDRectN rect1, RDRectN rect2) => rect1.Equals(rect2); - /// - public static bool operator !=(RDRectN rect1, RDRectN rect2) => !rect1.Equals(rect2); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDRectN e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Left, Top, Right, Bottom); - /// - public override readonly string ToString() => $"{{Location=[{Left},{Bottom}],Size=[{Width},{Height}]}}"; - /// - public readonly bool Equals(RDRectN other) => Left == other.Left && Top == other.Top && Right == other.Right && Bottom == other.Bottom; - - /// - /// Converts an to an . - /// - /// The to convert. - /// An that represents the same rectangle. - public static implicit operator RDRect(RDRectN rect) => new(rect.Left, rect.Top, rect.Right, rect.Bottom); - - /// - /// Converts an to an . - /// - /// The to convert. - /// An that represents the same rectangle. - public static implicit operator RDRectE(RDRectN rect) => new(rect.Left, rect.Top, rect.Right, rect.Bottom); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDRectNI.cs b/RhythmBaseCore/Components/RDRectNI.cs deleted file mode 100644 index bb27474..0000000 --- a/RhythmBaseCore/Components/RDRectNI.cs +++ /dev/null @@ -1,333 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// Represents a rectangle defined by its left, top, right, and bottom coordinates. - /// - /// The left coordinate of the rectangle. - /// The top coordinate of the rectangle. - /// The right coordinate of the rectangle. - /// The bottom coordinate of the rectangle. - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDRectNI(int left, int top, int right, int bottom) : IEquatable - { - /// - /// Gets or sets the left coordinate of the rectangle. - /// - public int Left { get; set; } = left; - - /// - /// Gets or sets the right coordinate of the rectangle. - /// - public int Right { get; set; } = right; - - /// - /// Gets or sets the top coordinate of the rectangle. - /// - public int Top { get; set; } = top; - - /// - /// Gets or sets the bottom coordinate of the rectangle. - /// - public int Bottom { get; set; } = bottom; - - /// - /// Gets the bottom-left point of the rectangle. - /// - public readonly RDPointNI LeftBottom => new(Left, Bottom); - - /// - /// Gets the bottom-right point of the rectangle. - /// - public readonly RDPointNI RightBottom => new(Right, Bottom); - - /// - /// Gets the top-left point of the rectangle. - /// - public readonly RDPointNI LeftTop => new(Left, Top); - - /// - /// Gets the top-right point of the rectangle. - /// - public readonly RDPointNI RightTop => new(Right, Top); - - /// - /// Gets the width of the rectangle. - /// - public readonly int Width => Right - Left; - - /// - /// Gets the height of the rectangle. - /// - public readonly int Height => Top - Bottom; - - /// - /// Initializes a new instance of the struct with the specified location and size. - /// - /// The location of the rectangle. - /// The size of the rectangle. - public RDRectNI(RDPointNI location, RDSizeNI size) : this(location.X, location.Y + size.Height, location.X + size.Width, location.Y) { } - - /// - /// Initializes a new instance of the struct with the specified size. - /// - /// The size of the rectangle. - public RDRectNI(RDSizeNI size) : this(0, size.Height, size.Width, 0) { } - - /// - /// Initializes a new instance of the struct with the specified width and height. - /// - /// The width of the rectangle. - /// The height of the rectangle. - public RDRectNI(int width, int height) : this(0, height, width, 0) { } - - /// - /// Gets the location of the rectangle. - /// - public readonly RDPointNI Location => new(Left, Bottom); - - /// - /// Gets the size of the rectangle. - /// - public readonly RDSizeNI Size => new(Width, Height); - - /// - /// Inflates the specified rectangle by the specified size. - /// - /// The rectangle to inflate. - /// The size to inflate by. - /// The inflated rectangle. - public static RDRectNI Inflate(RDRectNI rect, RDSizeNI size) - { - RDRectNI result = new(rect.Left, rect.Top, rect.Right, rect.Bottom); - result.Inflate(size); - return result; - } - - /// - /// Inflates the specified rectangle by the specified amounts. - /// - /// The rectangle to inflate. - /// The amount to inflate the width by. - /// The amount to inflate the height by. - /// The inflated rectangle. - public static RDRectNI Inflate(RDRectNI rect, int x, int y) - { - RDRectNI result = new(rect.Left, rect.Top, rect.Right, rect.Bottom); - result.Inflate(x, y); - return result; - } - /// - /// Returns a rectangle structure that represents the smallest possible rectangle that can contain the specified rectangle, with each value rounded up to the nearest integer. - /// - /// The rectangle to be rounded up. - /// A new rectangle structure with each value rounded up to the nearest integer. - public static RDRectNI Ceiling(RDRectN rect) => Ceiling(rect, false); - - /// - /// Returns a rectangle structure that represents the smallest possible rectangle that can contain the specified rectangle, with each value rounded up or down to the nearest integer. - /// - /// The rectangle to be rounded. - /// If true, values are rounded outwards; otherwise, they are rounded inwards. - /// A new rectangle structure with each value rounded to the nearest integer. - public static RDRectNI Ceiling(RDRectN rect, bool outwards) => new( - (int)Math.Round((outwards && rect.Width > 0f) ? Math.Floor((double)rect.Left) : Math.Ceiling((double)rect.Left)), - (int)Math.Round((outwards && rect.Height > 0f) ? Math.Floor((double)rect.Top) : Math.Ceiling((double)rect.Top)), - (int)Math.Round((outwards && rect.Width < 0f) ? Math.Floor((double)rect.Right) : Math.Ceiling((double)rect.Right)), - (int)Math.Round((outwards && rect.Height < 0f) ? Math.Floor((double)rect.Bottom) : Math.Ceiling((double)rect.Bottom))); - - /// - /// Returns a rectangle structure that represents the largest possible rectangle that can fit within the specified rectangle, with each value rounded down to the nearest integer. - /// - /// The rectangle to be rounded down. - /// A new rectangle structure with each value rounded down to the nearest integer. - public static RDRectNI Floor(RDRectN rect) => Ceiling(rect, false); - - /// - /// Returns a rectangle structure that represents the largest possible rectangle that can fit within the specified rectangle, with each value rounded up or down to the nearest integer. - /// - /// The rectangle to be rounded. - /// If true, values are rounded inwards; otherwise, they are rounded outwards. - /// A new rectangle structure with each value rounded to the nearest integer. - public static RDRectNI Floor(RDRectN rect, bool inwards) => new( - (int)Math.Round((inwards && rect.Width > 0f) ? Math.Ceiling((double)rect.Left) : Math.Floor((double)rect.Left)), - (int)Math.Round((inwards && rect.Height > 0f) ? Math.Ceiling((double)rect.Top) : Math.Floor((double)rect.Top)), - (int)Math.Round((inwards && rect.Width < 0f) ? Math.Ceiling((double)rect.Right) : Math.Floor((double)rect.Right)), - (int)Math.Round((inwards && rect.Height < 0f) ? Math.Ceiling((double)rect.Bottom) : Math.Floor((double)rect.Bottom))); - - /// - /// Returns a rectangle structure that represents the specified rectangle, with each value rounded to the nearest integer. - /// - /// The rectangle to be rounded. - /// A new rectangle structure with each value rounded to the nearest integer. - public static RDRectNI Round(RDRectN rect) => new( - (int)Math.Round((double)rect.Left), - (int)Math.Round((double)rect.Top), - (int)Math.Round((double)rect.Right), - (int)Math.Round((double)rect.Bottom)); - - /// - /// Returns a rectangle structure that represents the union of two rectangles. The union is the smallest rectangle that contains both rectangles. - /// - /// The first rectangle. - /// The second rectangle. - /// A new rectangle structure that represents the union of the two rectangles. - public static RDRectNI Union(RDRectNI rect1, RDRectNI rect2) => new( - Math.Min(rect1.Left, rect2.Left), - Math.Max(rect1.Top, rect2.Top), - Math.Max(rect1.Right, rect2.Right), - Math.Min(rect1.Bottom, rect2.Bottom)); - - /// - /// Returns a rectangle structure that represents the intersection of two rectangles. The intersection is the largest rectangle that is contained within both rectangles. - /// - /// The first rectangle. - /// The second rectangle. - /// A new rectangle structure that represents the intersection of the two rectangles, or the default rectangle if there is no intersection. - public static RDRectNI Intersect(RDRectNI rect1, RDRectNI rect2) => rect1.IntersectsWithInclusive(rect2) ? new RDRectNI( - Math.Max(rect1.Left, rect2.Left), - Math.Max(rect1.Top, rect2.Top), - Math.Min(rect1.Right, rect2.Right), - Math.Min(rect1.Bottom, rect2.Bottom)) : default; - - /// - /// Returns a rectangle structure that represents the specified rectangle, with each value truncated to the nearest integer. - /// - /// The rectangle to be truncated. - /// A new rectangle structure with each value truncated to the nearest integer. - public static RDRectNI Truncate(RDRectN rect) => new( - (int)Math.Round((double)rect.Left), - (int)Math.Round((double)rect.Top), - (int)Math.Round((double)rect.Right), - (int)Math.Round((double)rect.Bottom)); - - /// - /// Moves the rectangle by the specified horizontal and vertical amounts. - /// - /// The amount to move the rectangle horizontally. - /// The amount to move the rectangle vertically. - public void Offset(int x, int y) - { - Left += x; - Top += y; - Right += x; - Bottom += y; - } - - /// - /// Moves the rectangle by the specified point. - /// - /// The point to move the rectangle by. - public void Offset(RDPointNI p) => Offset(p.X, p.Y); - - /// - /// Inflates the rectangle by the specified size. - /// - /// The size to inflate the rectangle by. - public void Inflate(RDSizeNI size) - { - Left -= size.Width; - Top += size.Height; - Right += size.Width; - Bottom -= size.Height; - } - - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The amount to inflate the rectangle's width by. - /// The amount to inflate the rectangle's height by. - public void Inflate(int width, int height) - { - Left -= width; - Top += height; - Right += width; - Bottom -= height; - } - - /// - /// Determines whether the rectangle contains the specified point. - /// - /// The x-coordinate of the point. - /// The y-coordinate of the point. - /// True if the rectangle contains the point; otherwise, false. - public readonly bool Contains(int x, int y) => Left < x && x < Right && Bottom < y && y < Top; - - /// - /// Determines whether the rectangle contains the specified point. - /// - /// The point to check. - /// True if the rectangle contains the point; otherwise, false. - public readonly bool Contains(RDPointN p) => (float)Left < p.X && p.X < (float)Right && (float)Bottom < p.Y && p.Y < (float)Top; - - /// - /// Determines whether the rectangle contains the specified rectangle. - /// - /// The rectangle to check. - /// True if the rectangle contains the specified rectangle; otherwise, false. - public readonly bool Contains(RDRectNI rect) => Left < rect.Left && rect.Right < Right && Bottom < rect.Bottom && rect.Top < Top; - - /// - /// Returns a rectangle structure that represents the union of this rectangle and the specified rectangle. - /// - /// The rectangle to union with. - /// A new rectangle structure that represents the union of the two rectangles. - public readonly RDRectNI Union(RDRectNI rect) => Union(this, rect); - - /// - /// Returns a rectangle structure that represents the intersection of this rectangle and the specified rectangle. - /// - /// The rectangle to intersect with. - /// A new rectangle structure that represents the intersection of the two rectangles, or the default rectangle if there is no intersection. - public readonly object Intersect(RDRectNI rect) => Intersect(this, rect); - - /// - /// Determines whether this rectangle intersects with the specified rectangle. - /// - /// The rectangle to check for intersection. - /// True if the rectangles intersect; otherwise, false. - public readonly bool IntersectsWith(RDRectNI rect) => Left < rect.Right && Right > rect.Left && Top < rect.Bottom && Bottom > rect.Top; - - /// - /// Determines whether this rectangle intersects with the specified rectangle, including the edges. - /// - /// The rectangle to check for intersection. - /// True if the rectangles intersect, including the edges; otherwise, false. - public readonly bool IntersectsWithInclusive(RDRectNI rect) => Left <= rect.Right && Right >= rect.Left && Top <= rect.Bottom && Bottom >= rect.Top; - /// - public static bool operator ==(RDRectNI rect1, RDRectNI rect2) => rect1.Equals(rect2); - /// - public static bool operator !=(RDRectNI rect1, RDRectNI rect2) => !rect1.Equals(rect2); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDRectNI e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Left, Top, Right, Bottom); - /// - public override readonly string ToString() => $"{{Location=[{Left},{Bottom}],Size=[{Width},{Height}]}}"; - /// - public readonly bool Equals(RDRectNI other) => Left == other.Left && Top == other.Top && Right == other.Right && Bottom == other.Bottom; - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// An that represents the same rectangle. - public static implicit operator RDRectN(RDRectNI rect) => new(rect.Left, rect.Top, rect.Right, rect.Bottom); - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// An that represents the same rectangle. - public static implicit operator RDRectI(RDRectNI rect) => new(rect.Left, rect.Top, rect.Right, rect.Bottom); - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// An that represents the same rectangle. - public static implicit operator RDRectE(RDRectNI rect) => new(rect.Left, rect.Top, rect.Right, rect.Bottom); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDRoom.cs b/RhythmBaseCore/Components/RDRoom.cs deleted file mode 100644 index 7e5183e..0000000 --- a/RhythmBaseCore/Components/RDRoom.cs +++ /dev/null @@ -1,155 +0,0 @@ -using Microsoft.VisualBasic.CompilerServices; -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Numerics; -using System.Runtime.CompilerServices; -namespace RhythmBase.Components -{ - /// - /// Represents a room that can be applied to multiple rooms. - /// - [JsonConverter(typeof(RoomConverter))] - public struct RDRoom : IEqualityOperators, IEquatable - { - /// - /// Indicates if the top room can be applied. - /// - public bool EnableTop { get; } - - /// - /// Gets or sets whether the specified room is enabled. - /// - /// The index of the room. - /// True if the room is enabled; otherwise, false. - [IndexerName("Room")] - public bool this[byte Index] - { - readonly get => _data.HasFlag((RDRoomIndex)(1 << Index)); - set - { - if (!(Index >= 4 && !EnableTop)) - _data = value ? (_data | (RDRoomIndex)(1 << (int)Index)) : (_data & (RDRoomIndex)(1 << (int)Index)); - } - } - - /// - /// Gets the list of enabled rooms. - /// - public readonly List Rooms - { - get - { - RDRoomIndex indexes = _data; - return Enumerable - .Range(0, 5) - .Where(x => indexes.HasFlag((RDRoomIndex)(1 << x))) - .Select(x => (byte)x) - .ToList(); - } - } - - /// - public override readonly string ToString() => string.Format("[{0}]", string.Join(",", Rooms)); - - /// - /// Returns an instance with only room 1 enabled. - /// - /// An instance with only room 1 enabled. - public static RDRoom Default() => new(false, []) - { - _data = RDRoomIndex.Room1 - }; - - /// - /// Initializes a new instance of the struct. - /// - /// Indicates if the top room can be applied. - public RDRoom(bool enableTop) => EnableTop = enableTop; - - /// - /// Initializes a new instance of the struct with specified rooms. - /// - /// Indicates if the top room can be applied. - /// The rooms to be enabled. - public RDRoom(bool enableTop, params byte[] rooms) - { - this = default; - EnableTop = enableTop; - int num = rooms.Length; - if (num != 0) - if (num != 1) - foreach (byte item in rooms) - this[item] = true; - else - this[rooms.Single()] = true; - else - _data = RDRoomIndex.RoomNotAvaliable; - } - - /// - /// Checks if the specified rooms are included. - /// - /// The rooms to check. - /// True if the rooms are included; otherwise, false. - public readonly bool Contains(RDRoom rooms) - { - if (_data == RDRoomIndex.RoomNotAvaliable) - return false; - else - { - for (int i = 0; i < 5; i++) - { - if (this[(byte)i] != rooms[(byte)i]) - break; - if (i > 4) - return true; - } - return false; - } - } - /// - /// Checks if the specified room is included. - /// - /// The room to check. - /// True if the room is included; otherwise, false. - public readonly bool Contains(RDRoomIndex room) - { - return _data.HasFlag(room); - } - - /// - public static bool operator ==(RDRoom R1, RDRoom R2) => R1._data == R2._data; - - /// - public static bool operator !=(RDRoom R1, RDRoom R2) => !(R1 == R2); - - /// - /// Implicitly converts a SingleRoom to a Room. - /// - /// The SingleRoom instance to convert. - /// A Room instance. - public static implicit operator RDRoom(RDSingleRoom room) => new(room.EnableTop, [0, ((byte)room.Room)]); - - /// - /// Explicitly converts a Room to a SingleRoom. - /// - /// The Room instance to convert. - /// A SingleRoom instance. - /// Thrown when the Room contains more than one room. - public static explicit operator RDSingleRoom(RDRoom room) => - room.Rooms.Count == 1 - ? new RDSingleRoom(room.Rooms.Single()) - : throw new Exceptions.RhythmBaseException(); - - /// - public override readonly bool Equals(object? obj) => obj is RDRoom e && Equals(e); - - /// - public override readonly int GetHashCode() => HashCode.Combine(_data); - - /// - public readonly bool Equals(RDRoom other) => this == other; - - private RDRoomIndex _data; - } -} diff --git a/RhythmBaseCore/Components/RDRoomIndex.cs b/RhythmBaseCore/Components/RDRoomIndex.cs deleted file mode 100644 index ef19441..0000000 --- a/RhythmBaseCore/Components/RDRoomIndex.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace RhythmBase.Components -{ - /// - /// Represents the index of a room with various possible values. - /// - [Flags] - public enum RDRoomIndex : byte - { - /// - /// No room selected. - /// - None = 0b0000_0000, - - /// - /// Represents Room 1. - /// - Room1 = 0b0000_0001, - - /// - /// Represents Room 2. - /// - Room2 = 0b0000_0010, - - /// - /// Represents Room 3. - /// - Room3 = 0b0000_0100, - - /// - /// Represents Room 4. - /// - Room4 = 0b0000_1000, - - /// - /// Represents the top room. - /// - RoomTop = 0b0001_0000, - - /// - /// Indicates that the room is not available. - /// - RoomNotAvaliable = byte.MaxValue, - } -} diff --git a/RhythmBaseCore/Components/RDRotatedRect.cs b/RhythmBaseCore/Components/RDRotatedRect.cs deleted file mode 100644 index 9e430f2..0000000 --- a/RhythmBaseCore/Components/RDRotatedRect.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// Represents a rotated rectangle with non-integer coordinates. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDRotatedRect(RDPoint location, RDSize size, RDPoint? pivot, float? angle = 0) : IEquatable - { - /// - /// Gets or sets the location of the rectangle. - /// - public RDPoint? Location { get; set; } = location; - - /// - /// Gets or sets the size of the rectangle. - /// - public RDSize? Size { get; set; } = size; - - /// - /// Gets or sets the pivot point of the rotation. - /// - public RDPoint? Pivot { get; set; } = pivot; - - /// - /// Gets or sets the angle of rotation in degrees. - /// - public float? Angle { get; set; } = angle; - - /// - /// Gets the rectangle without rotation. - /// - public readonly RDRect WithoutRotate => new(Location - (RDSize?)Pivot, Size); - - /// - /// IItializes a new instance of the struct. - /// - /// The rectangle. - /// The pivot point. - /// The angle of rotation. - public RDRotatedRect(RDRect rect, RDPoint? pivot, float angle) : this(rect.Location, rect.Size, pivot, angle) { } - - /// - /// IItializes a new instance of the struct. - /// - /// The rectangle. - public RDRotatedRect(RDRect rect) : this(rect.Location, rect.Size, default, 0f) { } - - /// - /// Inflates the specified rectangle by the specified size. - /// - /// The rectangle to inflate. - /// The size to inflate by. - /// The inflated rectangle. - public static RDRotatedRect Inflate(RDRotatedRect rect, RDSize size) - { - RDRotatedRect result = rect; - result.Inflate(size); - return result; - } - - /// - /// Inflates the specified rectangle by the specified width and height. - /// - /// The rectangle to inflate. - /// The width to inflate by. - /// The height to inflate by. - /// The inflated rectangle. - public static RDRotatedRect Inflate(RDRotatedRect rect, int x, int y) - { - RDRotatedRect result = rect; - result.Inflate(x, y); - return result; - } - - /// - /// Offsets the rectangle by the specified x and y values. - /// - /// The x value to offset by. - /// The y value to offset by. - public void Offset(float? x, float? y) => Location += new RDSize(x, y); - - /// - /// Offsets the rectangle by the specified point. - /// - /// The point to offset by. - public void Offset(RDPoint p) => Offset(p.X, p.Y); - - /// - /// Inflates the rectangle by the specified size. - /// - /// The size to inflate by. - public void Inflate(RDSize size) - { - Size += new RDSize(size.Width * 2, size.Height * 2); - Pivot -= new RDSize(size.Width, size.Height); - } - - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The width to inflate by. - /// The height to inflate by. - public void Inflate(float? width, float? height) - { - Size += new RDSize(width * 2, height * 2); - Pivot -= new RDSize(width, height); - } - /// - public static bool operator ==(RDRotatedRect rect1, RDRotatedRect rect2) => rect1.Equals(rect2); - /// - public static bool operator !=(RDRotatedRect rect1, RDRotatedRect rect2) => !rect1.Equals(rect2); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDRotatedRect e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Location, Size, Pivot, Angle); - /// - public override readonly string ToString() => $"{{Location=[{Location}],Size=[{Size}],Pivot[{Pivot}],Angle={Angle}}}"; - /// - public readonly bool Equals(RDRotatedRect other) => - Location == other.Location && - Size == other.Size && Pivot - == other.Pivot && - Angle == other.Angle; - private readonly string GetDebuggerDisplay() => ToString(); - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Components/RDRotatedRectE.cs b/RhythmBaseCore/Components/RDRotatedRectE.cs deleted file mode 100644 index 6d8b037..0000000 --- a/RhythmBaseCore/Components/RDRotatedRectE.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// Represents a rotated rectangle with non-integer coordinates. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDRotatedRectE(RDPointE? location, RDSizeE? size, RDPointE? pivot, RDExpression? angle = null) : IEquatable - { - /// - /// Gets or sets the location of the rectangle. - /// - public RDPointE? Location { get; set; } = location; - - /// - /// Gets or sets the size of the rectangle. - /// - public RDSizeE? Size { get; set; } = size; - - /// - /// Gets or sets the pivot point of the rotation. - /// - public RDPointE? Pivot { get; set; } = pivot; - - /// - /// Gets or sets the angle of rotation in degrees. - /// - public RDExpression? Angle { get; set; } = angle; - - /// - /// Gets the rectangle without rotation. - /// - public readonly RDRectE? WithoutRotate => Location is null && Pivot is null && Size is null ? null : new(Location - (RDSizeE)(Pivot??default), Size); - - /// - /// IItializes a new instance of the struct. - /// - /// The rectangle. - /// The pivot point. - /// The angle of rotation. - public RDRotatedRectE(RDRectE? rect, RDPointE? pivot, float angle) : this(rect?.Location, rect?.Size, pivot, angle) { } - - /// - /// IItializes a new instance of the struct. - /// - /// The rectangle. - public RDRotatedRectE(RDRectE? rect) : this(rect?.Location, rect?.Size, null, 0f) { } - - /// - /// Inflates the specified rectangle by the specified size. - /// - /// The rectangle to inflate. - /// The size to inflate by. - /// The inflated rectangle. - public static RDRotatedRectE Inflate(RDRotatedRectE rect, RDSizeE size) - { - RDRotatedRectE result = rect; - result.Inflate(size); - return result; - } - - /// - /// Inflates the specified rectangle by the specified width and height. - /// - /// The rectangle to inflate. - /// The width to inflate by. - /// The height to inflate by. - /// The inflated rectangle. - public static RDRotatedRectE Inflate(RDRotatedRectE rect, int x, int y) - { - RDRotatedRectE result = rect; - result.Inflate(x, y); - return result; - } - - /// - /// Offsets the rectangle by the specified x and y values. - /// - /// The x value to offset by. - /// The y value to offset by. - public void Offset(RDExpression? x, RDExpression? y) => Location += (RDSizeE)new RDPointE(x, y); - - /// - /// Offsets the rectangle by the specified point. - /// - /// The point to offset by. - public void Offset(RDPointE p) => Offset(p.X, p.Y); - - /// - /// Inflates the rectangle by the specified size. - /// - /// The size to inflate by. - public void Inflate(RDSizeE size) - { - Size += new RDSizeE(size.Width * 2, size.Height * 2); - Pivot -= (RDSizeE)new RDPointE(size.Width, size.Height); - } - - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The width to inflate by. - /// The height to inflate by. - public void Inflate(int width, int height) - { - Size += new RDSizeE(width * 2, height * 2); - Pivot -= (RDSizeE)new RDPointE(width, height); - } - /// - public static bool operator ==(RDRotatedRectE rect1, RDRotatedRectE rect2) => rect1.Equals(rect2); - /// - public static bool operator !=(RDRotatedRectE rect1, RDRotatedRectE rect2) => !rect1.Equals(rect2); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDRotatedRectE e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Location, Size, Pivot, Angle); - /// - public override readonly string ToString() => $"{{Location=[{Location}],Size=[{Size}],Pivot[{Pivot}],Angle={Angle}}}"; - /// - public readonly bool Equals(RDRotatedRectE other) => - Location == other.Location && - Size == other.Size && Pivot - == other.Pivot && - Angle == other.Angle; - private readonly string GetDebuggerDisplay() => ToString(); - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Components/RDRotatedRectI.cs b/RhythmBaseCore/Components/RDRotatedRectI.cs deleted file mode 100644 index dd1c52a..0000000 --- a/RhythmBaseCore/Components/RDRotatedRectI.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// Represents a rotated rectangle with non-integer coordinates. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDRotatedRectI(RDPointI? location, RDSizeI? size, RDPointI? pivot, float? angle = 0) : IEquatable - { - /// - /// Gets or sets the location of the rectangle. - /// - public RDPointI? Location { get; set; } = location; - - /// - /// Gets or sets the size of the rectangle. - /// - public RDSizeI? Size { get; set; } = size; - - /// - /// Gets or sets the pivot point of the rotation. - /// - public RDPointI? Pivot { get; set; } = pivot; - - /// - /// Gets or sets the angle of rotation in degrees. - /// - public float? Angle { get; set; } = angle; - - /// - /// Gets the rectangle without rotation. - /// - public readonly RDRectI? WithoutRotate => Location is null && Pivot is null && Size is null ? null : new(Location - (RDSizeI?)Pivot, Size); - - /// - /// IItializes a new instance of the struct. - /// - /// The rectangle. - /// The pivot point. - /// The angle of rotation. - public RDRotatedRectI(RDRectI? rect, RDPointI? pivot, float angle) : this(rect?.Location, rect?.Size, pivot, angle) { } - - /// - /// IItializes a new instance of the struct. - /// - /// The rectangle. - public RDRotatedRectI(RDRectI? rect) : this(rect?.Location, rect?.Size, null, 0f) { } - - /// - /// Inflates the specified rectangle by the specified size. - /// - /// The rectangle to inflate. - /// The size to inflate by. - /// The inflated rectangle. - public static RDRotatedRectI Inflate(RDRotatedRectI rect, RDSizeI size) - { - RDRotatedRectI result = rect; - result.Inflate(size); - return result; - } - - /// - /// Inflates the specified rectangle by the specified width and height. - /// - /// The rectangle to inflate. - /// The width to inflate by. - /// The height to inflate by. - /// The inflated rectangle. - public static RDRotatedRectI Inflate(RDRotatedRectI rect, int x, int y) - { - RDRotatedRectI result = rect; - result.Inflate(x, y); - return result; - } - - /// - /// Offsets the rectangle by the specified x and y values. - /// - /// The x value to offset by. - /// The y value to offset by. - public void Offset(int? x, int? y) => Location += (RDSizeI)new RDPointI(x, y); - - /// - /// Offsets the rectangle by the specified point. - /// - /// The point to offset by. - public void Offset(RDPointI p) => Offset(p.X, p.Y); - - /// - /// Inflates the rectangle by the specified size. - /// - /// The size to inflate by. - public void Inflate(RDSizeI size) - { - Size += new RDSizeI(size.Width * 2, size.Height * 2); - Pivot -= (RDSizeI)new RDPointI(size.Width, size.Height); - } - - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The width to inflate by. - /// The height to inflate by. - public void Inflate(int width, int height) - { - Size += new RDSizeI(width * 2, height * 2); - Pivot -= (RDSizeI)new RDPointI(width, height); - } - /// - public static bool operator ==(RDRotatedRectI rect1, RDRotatedRectI rect2) => rect1.Equals(rect2); - /// - public static bool operator !=(RDRotatedRectI rect1, RDRotatedRectI rect2) => !rect1.Equals(rect2); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDRotatedRectI e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Location, Size, Pivot, Angle); - /// - public override readonly string ToString() => $"{{Location=[{Location}],Size=[{Size}],Pivot[{Pivot}],Angle={Angle}}}"; - /// - public readonly bool Equals(RDRotatedRectI other) => - Location == other.Location && - Size == other.Size && Pivot - == other.Pivot && - Angle == other.Angle; - private readonly string GetDebuggerDisplay() => ToString(); - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Components/RDRotatedRectN.cs b/RhythmBaseCore/Components/RDRotatedRectN.cs deleted file mode 100644 index 0c064c2..0000000 --- a/RhythmBaseCore/Components/RDRotatedRectN.cs +++ /dev/null @@ -1,213 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; - -namespace RhythmBase.Components -{ - /// - /// Represents a rotated rectangle with non-nullable float coordinates. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDRotatedRectN(RDPointN location, RDSizeN size, RDPointN pivot, float angle = 0) : IEquatable - { - /// - /// Gets or sets the location of the rectangle. - /// - public RDPointN Location { get; set; } = location; - - /// - /// Gets or sets the size of the rectangle. - /// - public RDSizeN Size { get; set; } = size; - - /// - /// Gets or sets the pivot point of the rotation. - /// - public RDPointN Pivot { get; set; } = pivot; - - /// - /// Gets or sets the angle of rotation in radians. - /// - public float Angle { get; set; } = angle; - - /// - /// Gets the top-left point of the rotated rectangle. - /// - public readonly RDPointN LeftTop => (Location - (RDSizeN)Pivot + new RDSizeN(0, Size.Height)).Rotate(Location, Angle); - - /// - /// Gets the top-right point of the rotated rectangle. - /// - public readonly RDPointN RightTop => (Location - (RDSizeN)Pivot + Size).Rotate(Location, Angle); - - /// - /// Gets the bottom-left point of the rotated rectangle. - /// - public readonly RDPointN LeftBottom => (Location - (RDSizeN)Pivot).Rotate(Location, Angle); - - /// - /// Gets the bottom-right point of the rotated rectangle. - /// - public readonly RDPointN RightBottom => (Location - (RDSizeN)Pivot + new RDSizeN(Size.Width, 0)).Rotate(Location, Angle); - - /// - /// Gets the rectangle without rotation. - /// - public readonly RDRectN WithoutRotate => new(Location - (RDSizeN)Pivot, Size); - - /// - /// Initializes a new instance of the struct. - /// - /// The rectangle. - /// The pivot point. - /// The angle of rotation. - public RDRotatedRectN(RDRectN rect, RDPointN pivot, float angle) : this(rect.Location, rect.Size, pivot, angle) { } - - /// - /// Initializes a new instance of the struct. - /// - /// The rectangle. - public RDRotatedRectN(RDRectN rect) : this(rect.Location, rect.Size, default, 0f) { } - - /// - /// Inflates the specified rectangle by the specified size. - /// - /// The rectangle to inflate. - /// The size to inflate by. - /// The inflated rectangle. - public static RDRotatedRectN Inflate(RDRotatedRectN rect, RDSizeN size) - { - RDRotatedRectN result = rect; - result.Inflate(size); - return result; - } - - /// - /// Inflates the specified rectangle by the specified width and height. - /// - /// The rectangle to inflate. - /// The width to inflate by. - /// The height to inflate by. - /// The inflated rectangle. - public static RDRotatedRectN Inflate(RDRotatedRectN rect, int x, int y) - { - RDRotatedRectN result = rect; - result.Inflate(x, y); - return result; - } - - /// - /// Offsets the rectangle by the specified x and y values. - /// - /// The x value to offset by. - /// The y value to offset by. - public void Offset(float x, float y) => Location += (RDSizeN)new RDPointN(x, y); - - /// - /// Offsets the rectangle by the specified point. - /// - /// The point to offset by. - public void Offset(RDPointN p) => Offset(p.X, p.Y); - - /// - /// Inflates the rectangle by the specified size. - /// - /// The size to inflate by. - public void Inflate(RDSizeN size) - { - Size += new RDSizeN(size.Width * 2, size.Height * 2); - Pivot -= (RDSizeN)new RDPointN(size.Width, size.Height); - } - - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The width to inflate by. - /// The height to inflate by. - public void Inflate(float width, float height) - { - Size += new RDSizeN(width * 2, height * 2); - Pivot -= (RDSizeN)new RDPointN(width, height); - } - - /// - /// Determines whether the rectangle contains the specified point. - /// - /// The x coordinate of the point. - /// The y coordinate of the point. - /// true if the rectangle contains the point; otherwise, false. - public readonly bool Contains(float x, float y) => WithoutRotate.Contains(new RDPointN(x, y).Rotate(-Angle)); - - /// - /// Determines whether the rectangle contains the specified point. - /// - /// The point. - /// true if the rectangle contains the point; otherwise, false. - public readonly bool Contains(RDPointN p) => WithoutRotate.Contains(p.Rotate(-Angle)); - - /// - /// Determines whether the rectangle contains the specified rotated rectangle. - /// - /// The rotated rectangle. - /// true if the rectangle contains the rotated rectangle; otherwise, false. - public readonly bool Contains(RDRotatedRectN rect) => Contains(rect.LeftTop) && - Contains(rect.RightTop) && - Contains(rect.LeftBottom) && - Contains(rect.RightBottom); - - /// - /// Determines whether the rectangle intersects with the specified rotated rectangle. - /// - /// The rotated rectangle. - /// true if the rectangle intersects with the rotated rectangle; otherwise, false. - public readonly bool IntersectsWith(RDRotatedRectN rect) => Contains(rect.LeftTop) || - Contains(rect.RightTop) || - Contains(rect.LeftBottom) || - Contains(rect.RightBottom); - - /// - /// Determines whether two rotated rectangles are equal. - /// - /// The first rotated rectangle. - /// The second rotated rectangle. - /// true if the rectangles are equal; otherwise, false. - public static bool operator ==(RDRotatedRectN rect1, RDRotatedRectN rect2) => rect1.Equals(rect2); - - /// - /// Determines whether two rotated rectangles are not equal. - /// - /// The first rotated rectangle. - /// The second rotated rectangle. - /// true if the rectangles are not equal; otherwise, false. - public static bool operator !=(RDRotatedRectN rect1, RDRotatedRectN rect2) => !rect1.Equals(rect2); - - /// - /// Determines whether the specified object is equal to the current object. - /// - /// The object to compare with the current object. - /// true if the specified object is equal to the current object; otherwise, false. - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDRotatedRectN e && Equals(e); - - /// - /// Serves as the default hash function. - /// - /// A hash code for the current object. - public override readonly int GetHashCode() => HashCode.Combine(Location, Size, Pivot, Angle); - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override readonly string ToString() => $"{{Location=[{Location}],Size=[{Size}],Pivot[{Pivot}],Angle={Angle}}}"; - - /// - /// Determines whether the specified is equal to the current . - /// - /// The to compare with the current . - /// true if the specified is equal to the current ; otherwise, false. - public readonly bool Equals(RDRotatedRectN other) => Location == other.Location && - Size == other.Size && Pivot - == other.Pivot && - Angle == other.Angle; - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDRotatedRectNI.cs b/RhythmBaseCore/Components/RDRotatedRectNI.cs deleted file mode 100644 index ba48a76..0000000 --- a/RhythmBaseCore/Components/RDRotatedRectNI.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// Represents a rotated rectangle with non-integer coordinates. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDRotatedRectNI(RDPointNI location, RDSizeNI size, RDPointNI pivot, float angle) : IEquatable - { - /// - /// Gets or sets the location of the rectangle. - /// - public RDPointNI Location { get; set; } = location; - - /// - /// Gets or sets the size of the rectangle. - /// - public RDSizeNI Size { get; set; } = size; - - /// - /// Gets or sets the pivot point of the rotation. - /// - public RDPointNI Pivot { get; set; } = pivot; - - /// - /// Gets or sets the angle of rotation in degrees. - /// - public float Angle { get; set; } = angle; - - /// - /// Gets the top-left point of the rotated rectangle. - /// - public readonly RDPointN LeftTop => (Location - (RDSizeNI)Pivot + new RDSizeNI(0, Size.Height)).Rotate(Location, Angle); - - /// - /// Gets the top-right point of the rotated rectangle. - /// - public readonly RDPointN RightTop => (Location - (RDSizeNI)Pivot + Size).Rotate(Location, Angle); - - /// - /// Gets the bottom-left point of the rotated rectangle. - /// - public readonly RDPointN LeftBottom => (Location - (RDSizeNI)Pivot).Rotate(Location, Angle); - - /// - /// Gets the bottom-right point of the rotated rectangle. - /// - public readonly RDPointN RightBottom => (Location - (RDSizeNI)Pivot + new RDSizeNI(Size.Width, 0)).Rotate(Location, Angle); - - /// - /// Gets the rectangle without rotation. - /// - public readonly RDRectNI WithoutRotate => new(Location - (RDSizeNI)Pivot, Size); - - /// - /// Initializes a new instance of the struct. - /// - /// The rectangle. - /// The pivot point. - /// The angle of rotation. - public RDRotatedRectNI(RDRectNI rect, RDPointNI pivot, float angle) : this(rect.Location, rect.Size, pivot, angle) { } - - /// - /// Initializes a new instance of the struct. - /// - /// The rectangle. - public RDRotatedRectNI(RDRectNI rect) : this(rect.Location, rect.Size, default, 0f) { } - - /// - /// Inflates the specified rectangle by the specified size. - /// - /// The rectangle to inflate. - /// The size to inflate by. - /// The inflated rectangle. - public static RDRotatedRectNI Inflate(RDRotatedRectNI rect, RDSizeNI size) - { - RDRotatedRectNI result = rect; - result.Inflate(size); - return result; - } - - /// - /// Inflates the specified rectangle by the specified width and height. - /// - /// The rectangle to inflate. - /// The width to inflate by. - /// The height to inflate by. - /// The inflated rectangle. - public static RDRotatedRectNI Inflate(RDRotatedRectNI rect, int x, int y) - { - RDRotatedRectNI result = rect; - result.Inflate(x, y); - return result; - } - - /// - /// Offsets the rectangle by the specified x and y values. - /// - /// The x value to offset by. - /// The y value to offset by. - public void Offset(int x, int y) => Location += (RDSizeNI)new RDPointNI(x, y); - - /// - /// Offsets the rectangle by the specified point. - /// - /// The point to offset by. - public void Offset(RDPointNI p) => Offset(p.X, p.Y); - - /// - /// Inflates the rectangle by the specified size. - /// - /// The size to inflate by. - public void Inflate(RDSizeNI size) - { - Size += new RDSizeNI(size.Width * 2, size.Height * 2); - Pivot -= (RDSizeNI)new RDPointNI(size.Width, size.Height); - } - - /// - /// Inflates the rectangle by the specified width and height. - /// - /// The width to inflate by. - /// The height to inflate by. - public void Inflate(int width, int height) - { - Size += new RDSizeNI(width * 2, height * 2); - Pivot -= (RDSizeNI)new RDPointNI(width, height); - } - - /// - /// Determines whether the rectangle contains the specified point. - /// - /// The x coordinate of the point. - /// The y coordinate of the point. - /// true if the rectangle contains the point; otherwise, false. - public readonly bool Contains(int x, int y) => WithoutRotate.Contains(new RDPointN((float)x, (float)y).Rotate(-Angle)); - - /// - /// Determines whether the rectangle contains the specified point. - /// - /// The point. - /// true if the rectangle contains the point; otherwise, false. - public readonly bool Contains(RDPointN p) => WithoutRotate.Contains(p.Rotate(-Angle)); - - /// - /// Determines whether the rectangle contains the specified rotated rectangle. - /// - /// The rotated rectangle. - /// true if the rectangle contains the rotated rectangle; otherwise, false. - public readonly bool Contains(RDRotatedRectNI rect) => - Contains(rect.LeftTop) && - Contains(rect.RightTop) && - Contains(rect.LeftBottom) && - Contains(rect.RightBottom); - - /// - /// Determines whether the rectangle intersects with the specified rotated rectangle. - /// - /// The rotated rectangle. - /// true if the rectangle intersects with the rotated rectangle; otherwise, false. - public readonly bool IntersectsWith(RDRotatedRectNI rect) => - Contains(rect.LeftTop) || - Contains(rect.RightTop) || - Contains(rect.LeftBottom) || - Contains(rect.RightBottom); - /// - public static bool operator ==(RDRotatedRectNI rect1, RDRotatedRectNI rect2) => rect1.Equals(rect2); - /// - public static bool operator !=(RDRotatedRectNI rect1, RDRotatedRectNI rect2) => !rect1.Equals(rect2); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDRotatedRectNI e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Location, Size, Pivot, Angle); - /// - public override readonly string ToString() => $"{{Location=[{Location}],Size=[{Size}],Pivot[{Pivot}],Angle=[{Angle}]}}"; - /// - public readonly bool Equals(RDRotatedRectNI other) => - Location == other.Location && - Size == other.Size && Pivot - == other.Pivot && - Angle == other.Angle; - private readonly string GetDebuggerDisplay() => ToString(); - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Components/RDSingleRoom.cs b/RhythmBaseCore/Components/RDSingleRoom.cs deleted file mode 100644 index 8b3d142..0000000 --- a/RhythmBaseCore/Components/RDSingleRoom.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -namespace RhythmBase.Components -{ - /// - /// Represents a single room that can be applied to one room only. - /// - [JsonConverter(typeof(RoomConverter))] - public struct RDSingleRoom(RDRoomIndex index) : IEquatable - { - /// - /// Gets a value indicating whether it can be used in the top room. - /// - public bool EnableTop { get; } - - /// - /// Gets or sets the applied room. - /// - public RDRoomIndex Room - { - readonly get => _data; - set => _data = value; - } - - /// - /// Gets or sets the applied room index as a byte. - /// - public byte Value - { - readonly get - { - for (int i = 0; i < 5; i++) - { - if (_data == (RDRoomIndex)(1 << i)) - return (byte)i; - } - return byte.MaxValue; - } - set => _data = (RDRoomIndex)(1 << value); - } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override readonly string ToString() => string.Format("[{0}]", _data); - - /// - /// Gets the default single room which represents room 0. - /// - public static RDSingleRoom Default => new((RDRoomIndex)255); - - /// - /// Initializes a new instance of the struct with the specified room index. - /// - /// The room index. - public RDSingleRoom(byte room) : this((RDRoomIndex)(1 << (int)room)) { } - - /// - public static bool operator ==(RDSingleRoom R1, RDSingleRoom R2) => R1._data == R2._data; - - /// - public static bool operator !=(RDSingleRoom R1, RDSingleRoom R2) => R1._data != R2._data; - - /// - public static implicit operator RDSingleRoom(RDRoomIndex room) => new(room); - - /// - public override readonly bool Equals(object? obj) => obj is RDSingleRoom e && Equals(e); - - /// - public override readonly int GetHashCode() => HashCode.Combine(_data); - - /// - public readonly bool Equals(RDSingleRoom other) => _data == other._data; - - private RDRoomIndex _data = index; - } -} diff --git a/RhythmBaseCore/Components/RDSize.cs b/RhythmBaseCore/Components/RDSize.cs deleted file mode 100644 index 55c9e0d..0000000 --- a/RhythmBaseCore/Components/RDSize.cs +++ /dev/null @@ -1,105 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// A size whose horizontal and vertical coordinates are nullable - /// - [JsonConverter(typeof(RDPointsConverter))] - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDSize(float? width, float? height) : IRDVortex - { - /// - /// Initializes a new instance of the struct with the specified point. - /// - /// The point to initialize the size with. - public RDSize(RDPoint pt) : this(pt.X, pt.Y) { } - - /// - /// Gets a value indicating whether this size is empty (both width and height are null). - /// - public readonly bool IsEmpty => Width == null && Height == null; - - /// - /// Gets or sets the width of the size. - /// - public float? Width { get; set; } = width; - - /// - /// Gets or sets the height of the size. - /// - public float? Height { get; set; } = height; - - /// - /// Gets the area of the size. - /// - public readonly float? Area => Width * Height; - - /// - /// Adds two sizes together. - /// - /// The first size. - /// The second size. - /// The sum of the two sizes. - public static RDSize Add(RDSize sz1, RDSize sz2) => new(sz1.Width + sz2.Width, sz1.Height + sz2.Height); - - /// - /// Subtracts one size from another. - /// - /// The first size. - /// The second size. - /// The difference between the two sizes. - public static RDSize Subtract(RDSize sz1, RDSize sz2) => new(sz1.Width - sz2.Width, sz1.Height - sz2.Height); - /// - public override readonly int GetHashCode() => HashCode.Combine(Width, Height); - /// - public override readonly string ToString() => $"[{Width},{Height}]"; - /// - public readonly bool Equals(RDSize other) => Width == other.Width && Height == other.Height; - - /// - /// Converts this size to an . - /// - /// An that represents this size. - public readonly RDSizeI ToSize() => new((int?)Width, (int?)Height); - - /// - /// Converts this size to an . - /// - /// An that represents this size. - public readonly RDPoint ToPointF() => new(Width, Height); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDSize e && Equals(e); - /// - public static RDSize operator +(RDSize sz1, RDSize sz2) => Add(sz1, sz2); - /// - public static RDSize operator -(RDSize sz1, RDSize sz2) => Subtract(sz1, sz2); - /// - public static RDSize operator *(float left, RDSize right) => new(left * right.Width, left * right.Height); - /// - public static RDSize operator *(RDSize left, float? right) => new(left.Width * right, left.Height * right); - /// - public static RDSize operator /(RDSize left, float? right) => new(left.Width / right, left.Height / right); - /// - public static bool operator ==(RDSize sz1, RDSize sz2) => sz1.Equals(sz2); - /// - public static bool operator !=(RDSize sz1, RDSize sz2) => !sz1.Equals(sz2); - - /// - /// Performs an implicit conversion from to . - /// - /// The size to convert. - /// An that represents the converted size. - public static implicit operator RDSizeE(RDSize size) => new(size.Width, size.Height); - - /// - /// Performs an explicit conversion from to . - /// - /// The size to convert. - /// An that represents the converted size. - public static explicit operator RDPoint(RDSize size) => new(size.Width, size.Height); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDSizeE.cs b/RhythmBaseCore/Components/RDSizeE.cs deleted file mode 100644 index 1be5fd7..0000000 --- a/RhythmBaseCore/Components/RDSizeE.cs +++ /dev/null @@ -1,204 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// A size whose horizontal and vertical coordinates are nullable - /// - [JsonConverter(typeof(RDPointsConverter))] - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDSizeE(RDExpression? width, RDExpression? height) : - IRDVortex, - IRDVortex, - IRDVortex - { - /// - /// Initializes a new instance of the struct with specified width and height as floats. - /// - /// The width as a float. - /// The height as a float. - public RDSizeE(float width, float height) : this((RDExpression)width, (RDExpression)height) { } - - /// - /// Initializes a new instance of the struct with specified width as an RDExpression and height as a float. - /// - /// The width as an RDExpression. - /// The height as a float. - public RDSizeE(RDExpression? width, float height) : this(width, (RDExpression)height) { } - - /// - /// Initializes a new instance of the struct with specified width as a float and height as an RDExpression. - /// - /// The width as a float. - /// The height as an RDExpression. - public RDSizeE(float width, RDExpression? height) : this((RDExpression)width, height) { } - - /// - /// Initializes a new instance of the struct with specified width as a string and height as a float. - /// - /// The width as a string. - /// The height as a float. - public RDSizeE(string width, float height) : this((RDExpression)width, (RDExpression)height) { } - - /// - /// Initializes a new instance of the struct with specified width as a float and height as a string. - /// - /// The width as a float. - /// The height as a string. - public RDSizeE(float width, string height) : this((RDExpression)width, (RDExpression)height) { } - - /// - /// Initializes a new instance of the struct with specified width and height as strings. - /// - /// The width as a string. - /// The height as a string. - public RDSizeE(string width, string height) : this((RDExpression)width, (RDExpression)height) { } - - /// - /// Initializes a new instance of the struct with specified width as a string and height as an RDExpression. - /// - /// The width as a string. - /// The height as an RDExpression. - public RDSizeE(string width, RDExpression? height) : this((RDExpression)width, height) { } - - /// - /// Initializes a new instance of the struct with specified width as an RDExpression and height as a string. - /// - /// The width as an RDExpression. - /// The height as a string. - public RDSizeE(RDExpression? width, string height) : this(width, (RDExpression)height) { } - - /// - /// Initializes a new instance of the struct from an instance. - /// - /// The instance. - public RDSizeE(RDSizeI p) : this((RDExpression?)p.Width, (RDExpression?)p.Height) { } - - /// - /// Initializes a new instance of the struct from an instance. - /// - /// The instance. - public RDSizeE(RDSize p) : this((RDExpression?)p.Width, (RDExpression?)p.Height) { } - - /// - /// Initializes a new instance of the struct from an instance. - /// - /// The instance. - public RDSizeE(RDPointI p) : this((RDExpression?)p.X, (RDExpression?)p.Y) { } - - /// - /// Initializes a new instance of the struct from an instance. - /// - /// The instance. - public RDSizeE(RDPoint p) : this((RDExpression?)p.X, (RDExpression?)p.Y) { } - - /// - /// Initializes a new instance of the struct from an instance. - /// - /// The instance. - public RDSizeE(RDPointE p) : this(p.X, p.Y) { } - - /// - /// Gets a value indicating whether this instance is empty. - /// - public readonly bool IsEmpty => Width == null && Height == null; - - /// - /// Gets or sets the width. - /// - public RDExpression? Width { get; set; } = width; - - /// - /// Gets or sets the height. - /// - public RDExpression? Height { get; set; } = height; - - /// - /// Gets the area of the size. - /// - public readonly RDExpression? Area => Width * Height; - - /// - /// Adds two instances and returns the result. - /// - /// The first instance. - /// The second instance. - /// The result of the addition. - public static RDSizeE Add(RDSizeE sz1, RDSize sz2) => new(sz1.Width + sz2.Width, sz1.Height + sz2.Height); - - /// - /// Adds two instances and returns the result. - /// - /// The first instance. - /// The second instance. - /// The result of the addition. - public static RDSizeE Add(RDSizeE sz1, RDSizeE sz2) => new(sz1.Width + sz2.Width, sz1.Height + sz2.Height); - - /// - /// Subtracts one instance from another instance and returns the result. - /// - /// The first instance. - /// The second instance. - /// The result of the subtraction. - public static RDSizeE Subtract(RDSizeE sz1, RDSize sz2) => new(sz1.Width - sz2.Width, sz1.Height - sz2.Height); - - /// - /// Subtracts one instance from another instance and returns the result. - /// - /// The first instance. - /// The second instance. - /// The result of the subtraction. - public static RDSizeE Subtract(RDSizeE sz1, RDSizeE sz2) => new(sz1.Width - sz2.Width, sz1.Height - sz2.Height); - /// - public override readonly int GetHashCode() => HashCode.Combine(Width, Height); - /// - public override readonly string ToString() => $"[{Width},{Height}]"; - /// - public readonly bool Equals(RDSizeE other) => Width == other.Width && Height == other.Height; - /// - public readonly RDPointE ToRDPointE() => new(Width, Height); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDSize e && Equals(e); - /// - public static RDSizeE operator +(RDSizeE sz1, RDSizeI sz2) => Add(sz1, sz2); - /// - public static RDSizeE operator +(RDSizeE sz1, RDSize sz2) => Add(sz1, sz2); - /// - public static RDSizeE operator +(RDSizeE sz1, RDSizeE sz2) => Add(sz1, sz2); - /// - public static RDSizeE operator -(RDSizeE sz1, RDSizeI sz2) => Subtract(sz1, sz2); - /// - public static RDSizeE operator -(RDSizeE sz1, RDSize sz2) => Subtract(sz1, sz2); - /// - public static RDSizeE operator -(RDSizeE sz1, RDSizeE sz2) => Subtract(sz1, sz2); - /// - public static RDSizeE operator *(int left, RDSizeE right) => new(left * right.Width, left * right.Height); - /// - public static RDSizeE operator *(RDSizeE left, int right) => new(left.Width * right, left.Height * right); - /// - public static RDSizeE operator *(float left, RDSizeE right) => new(left * right.Width, left * right.Height); - /// - public static RDSizeE operator *(RDSizeE left, float right) => new(left.Width * right, left.Height * right); - /// - public static RDSizeE operator *(RDExpression left, RDSizeE right) => new(left * right.Width, left * right.Height); - /// - public static RDSizeE operator *(RDSizeE left, RDExpression right) => new(left.Width * right, left.Height * right); - /// - public static RDSizeE operator /(RDSizeE left, float right) => new(left.Width / right, left.Height / right); - /// - public static RDSizeE operator /(RDSizeE left, RDExpression right) => new(left.Width / right, left.Height / right); - /// - public static bool operator ==(RDSizeE sz1, RDSizeE sz2) => sz1.Equals(sz2); - /// - public static bool operator !=(RDSizeE sz1, RDSizeE sz2) => !sz1.Equals(sz2); - /// - /// Converts an instance to an instance explicitly. - /// - /// The instance to convert. - /// An instance with the same width and height as the instance. - public static explicit operator RDPointE(RDSizeE size) => new(size.Width, size.Height); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDSizeI.cs b/RhythmBaseCore/Components/RDSizeI.cs deleted file mode 100644 index 2161148..0000000 --- a/RhythmBaseCore/Components/RDSizeI.cs +++ /dev/null @@ -1,130 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// A size whose horizontal and vertical coordinates are nullable - /// - [JsonConverter(typeof(RDPointsConverter))] - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDSizeI(int? width, int? height) : IRDVortex - { - /// - /// Initializes a new instance of the struct with the specified point. - /// - /// The point to initialize the size with. - public RDSizeI(RDPointI pt) : this(pt.X, pt.Y) { } - - /// - /// Gets a value indicating whether this size is empty (both width and height are null). - /// - public readonly bool IsEmpty => Width == null && Height == null; - - /// - /// Gets or sets the width of the size. - /// - public int? Width { get; set; } = width; - - /// - /// Gets or sets the height of the size. - /// - public int? Height { get; set; } = height; - - /// - /// Gets the area of the size (width multiplied by height). - /// - public readonly int? Area => Width * Height; - - /// - /// Adds two sizes together. - /// - /// The first size. - /// The second size. - /// The sum of the two sizes. - public static RDSizeI Add(RDSizeI sz1, RDSizeI sz2) => new(sz1.Width + sz2.Width, sz1.Height + sz2.Height); - - /// - /// Truncates the specified size to the nearest integer values. - /// - /// The size to truncate. - /// The truncated size. - public static RDSizeI Truncate(RDSize value) => new( - (int)Math.Round((value.Width == null) ? 0.0 : Math.Truncate((double)value.Width.Value)), - (int)Math.Round((value.Height == null) ? 0.0 : Math.Truncate((double)value.Height.Value))); - - /// - /// Subtracts one size from another. - /// - /// The size to subtract from. - /// The size to subtract. - /// The difference between the two sizes. - public static RDSizeI Subtract(RDSizeI sz1, RDSizeI sz2) => new(sz1.Width - sz2.Width, sz1.Height - sz2.Height); - - /// - /// Rounds the specified size up to the nearest integer values. - /// - /// The size to round up. - /// The rounded size. - public static RDSizeI Ceiling(RDSize value) => new( - (int)Math.Round((value.Width == null) ? 0.0 : Math.Ceiling((double)value.Width.Value)), - (int)Math.Round((value.Height == null) ? 0.0 : Math.Ceiling((double)value.Height.Value))); - - /// - /// Rounds the specified size to the nearest integer values. - /// - /// The size to round. - /// The rounded size. - public static RDSizeI Round(RDSize value) => new( - new int?((int)Math.Round((value.Width == null) ? 0.0 : Math.Round((double)value.Width.Value))), - new int?((int)Math.Round((value.Height == null) ? 0.0 : Math.Round((double)value.Height.Value)))); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDSizeI e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Width, Height); - /// - public override readonly string ToString() => $"[{Width},{Height}]"; - /// - public readonly bool Equals(RDSizeI other) => Width == other.Width && Height == other.Height; - /// - public static RDSizeI operator +(RDSizeI sz1, RDSizeI sz2) => Add(sz1, sz2); - /// - public static RDSizeI operator -(RDSizeI sz1, RDSizeI sz2) => Subtract(sz1, sz2); - /// - public static RDSize operator *(float left, RDSizeI right) => new(left * right.Width, left * right.Height); - /// - public static RDSize operator *(RDSizeI left, float right) => new(left.Width * right, left.Height * right); - /// - public static RDSizeI operator *(int left, RDSizeI right) => new(left * right.Width, left * right.Height); - /// - public static RDSizeI operator *(RDSizeI left, int? right) => new(left.Width * right, left.Height * right); - /// - public static RDSize operator /(RDSizeI left, float right) => new(left.Width / right, left.Height / right); - /// - public static RDSizeI operator /(RDSizeI left, int? right) => new(left.Width / right, left.Height / right); - /// - public static bool operator ==(RDSizeI sz1, RDSizeI sz2) => sz1.Equals(sz2); - /// - public static bool operator !=(RDSizeI sz1, RDSizeI sz2) => !sz1.Equals(sz2); - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// A new with the same width and height. - public static implicit operator RDSize(RDSizeI p) => new(p.Width, p.Height); - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// A new with the same width and height. - public static implicit operator RDSizeE(RDSizeI p) => new(p.Width, p.Height); - /// - /// Explicitly converts an to an . - /// - /// The to convert. - /// A new with the same width and height. - public static explicit operator RDPointI(RDSizeI size) => new(size.Width, size.Height); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDSizeN.cs b/RhythmBaseCore/Components/RDSizeN.cs deleted file mode 100644 index 8e1dfd8..0000000 --- a/RhythmBaseCore/Components/RDSizeN.cs +++ /dev/null @@ -1,104 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// A size whose horizontal and vertical coordinates are non-nullable - /// - [JsonConverter(typeof(RDPointsConverter))] - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDSizeN(float width, float height) : IRDVortex - { - /// - /// Initializes a new instance of the struct with the specified point. - /// - /// The point to initialize the size with. - public RDSizeN(RDPointN pt) : this(pt.X, pt.Y) { } - - /// - /// Gets or sets the width of the size. - /// - public float Width { get; set; } = width; - - /// - /// Gets or sets the height of the size. - /// - public float Height { get; set; } = height; - - /// - /// Gets the area of the size. - /// - public readonly float Area => Width * Height; - - /// - /// Adds two sizes together. - /// - /// The first size. - /// The second size. - /// The result of adding the two sizes. - public static RDSizeN Add(RDSizeN sz1, RDSizeN sz2) => new(sz1.Width + sz2.Width, sz1.Height + sz2.Height); - - /// - /// Subtracts one size from another. - /// - /// The size to subtract from. - /// The size to subtract. - /// The result of subtracting the second size from the first size. - public static RDSizeN Subtract(RDSizeN sz1, RDSizeN sz2) => new(sz1.Width - sz2.Width, sz1.Height - sz2.Height); - /// - public override readonly int GetHashCode() => HashCode.Combine(Width, Height); - /// - public override readonly string ToString() => $"[{Width},{Height}]"; - /// - public readonly bool Equals(RDSizeN other) => Width == other.Width && Height == other.Height; - /// - /// Converts the current size to an integer size. - /// - /// A new instance with the width and height rounded to the nearest integer. - public readonly RDSizeNI ToSizeI() => new((int)Math.Round((double)Width), (int)Math.Round((double)Height)); - /// - /// Converts the current size to a point. - /// - /// A new instance with the width as the X coordinate and the height as the Y coordinate. - public readonly RDPointN ToPoint() => new(Width, Height); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDSizeN e && Equals(e); - /// - public static RDSizeN operator +(RDSizeN sz1, RDSizeN sz2) => Add(sz1, sz2); - /// - public static RDSizeN operator -(RDSizeN sz1, RDSizeN sz2) => Subtract(sz1, sz2); - /// - public static RDSizeN operator *(float left, RDSizeN right) => new(left * right.Width, left * right.Height); - /// - public static RDSizeN operator *(RDSizeN left, float right) => new(left.Width * right, left.Height * right); - /// - public static RDSizeN operator /(RDSizeN left, float right) => new(left.Width / right, left.Height / right); - /// - public static bool operator ==(RDSizeN sz1, RDSizeN sz2) => sz1.Equals(sz2); - /// - public static bool operator !=(RDSizeN sz1, RDSizeN sz2) => !sz1.Equals(sz2); - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// A new instance. - public static implicit operator RDSize(RDSizeN size) => new(new float?(size.Width), new float?(size.Height)); - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// A new instance. - public static implicit operator RDSizeE(RDSizeN size) => new(size.Width, size.Height); - - /// - /// Explicitly converts an to an . - /// - /// The to convert. - /// A new instance. - public static explicit operator RDPointN(RDSizeN size) => new(size.Width, size.Height); - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDSizeNI.cs b/RhythmBaseCore/Components/RDSizeNI.cs deleted file mode 100644 index 5c95b29..0000000 --- a/RhythmBaseCore/Components/RDSizeNI.cs +++ /dev/null @@ -1,145 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Components -{ - /// - /// A size whose horizontal and vertical coordinates are non-nullable - /// - [JsonConverter(typeof(RDPointsConverter))] - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDSizeNI(int width, int height) : IRDVortex - { - /// - /// Initializes a new instance of the struct with the specified point. - /// - /// The point to initialize the size with. - public RDSizeNI(RDPointNI pt) : this(pt.X, pt.Y) { } - - /// - /// Gets or sets the width of the size. - /// - public int Width { get; set; } = width; - - /// - /// Gets or sets the height of the size. - /// - public int Height { get; set; } = height; - - /// - /// Gets the area of the size. - /// - public readonly int Area => Width * Height; - - /// - /// Gets the screen size. - /// - public static RDSizeNI Screen => new(352, 198); - - /// - /// Adds two sizes together. - /// - /// The first size. - /// The second size. - /// The sum of the two sizes. - public static RDSizeNI Add(RDSizeNI sz1, RDSizeNI sz2) => new(sz1.Width + sz2.Width, sz1.Height + sz2.Height); - - /// - /// Truncates the specified size to integer values. - /// - /// The size to truncate. - /// The truncated size. - public static RDSizeNI Truncate(RDSizeN value) => new((int)value.Width, (int)value.Height); - - /// - /// Subtracts one size from another. - /// - /// The first size. - /// The second size. - /// The difference between the two sizes. - public static RDSizeNI Subtract(RDSizeNI sz1, RDSizeNI sz2) => new(sz1.Width - sz2.Width, sz1.Height - sz2.Height); - - /// - /// Rounds up the specified size to the nearest integer values. - /// - /// The size to round up. - /// The rounded-up size. - public static RDSizeNI Ceiling(RDSizeN value) => new( - (int)Math.Ceiling((double)value.Width), - (int)Math.Ceiling((double)value.Height)); - - /// - /// Rounds the specified size to the nearest integer values. - /// - /// The size to round. - /// The rounded size. - public static RDSizeNI Round(RDSizeN value) => new( - (int)Math.Round((double)value.Width), - (int)Math.Round((double)value.Height)); - /// - /// Converts the current size to a point. - /// - /// A with the same width and height as the current size. - public readonly RDPointNI ToPoint() => new(Width, Height); - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDSizeNI e && Equals(e); - /// - public override readonly int GetHashCode() => HashCode.Combine(Width, Height); - /// - public override readonly string ToString() => $"[{Width},{Height}]"; - /// - public readonly bool Equals(RDSizeNI other) => Width == other.Width && Height == other.Height; - /// - public static RDSizeNI operator +(RDSizeNI sz1, RDSizeNI sz2) => Add(sz1, sz2); - /// - public static RDSizeNI operator -(RDSizeNI sz1, RDSizeNI sz2) => Subtract(sz1, sz2); - /// - public static RDSizeN operator *(float left, RDSizeNI right) => new(left * right.Width, left * right.Height); - /// - public static RDSizeN operator *(RDSizeNI left, float right) => new(left.Width * right, left.Height * right); - /// - public static RDSizeNI operator *(int left, RDSizeNI right) => new(left * right.Width, left * right.Height); - /// - public static RDSizeNI operator *(RDSizeNI left, int right) => new(left.Width * right, left.Height * right); - /// - public static RDSizeN operator /(RDSizeNI left, float right) => new(left.Width / right, left.Height / right); - /// - public static RDSizeNI operator /(RDSizeNI left, int right) => new( - left.Width / right, - left.Height / right); - /// - public static bool operator ==(RDSizeNI sz1, RDSizeNI sz2) => sz1.Equals(sz2); - /// - public static bool operator !=(RDSizeNI sz1, RDSizeNI sz2) => !sz1.Equals(sz2); - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// An with the same width and height as the input. - public static implicit operator RDSizeN(RDSizeNI p) => new(p.Width, p.Height); - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// An with the same width and height as the input. - public static implicit operator RDSizeI(RDSizeNI p) => new(p.Width, p.Height); - - /// - /// Implicitly converts an to an . - /// - /// The to convert. - /// An with the same width and height as the input. - public static implicit operator RDSizeE(RDSizeNI p) => new(p.Width, p.Height); - - /// - /// Explicitly converts an to an . - /// - /// The to convert. - /// An with the same width and height as the input. - public static explicit operator RDPointNI(RDSizeNI size) => new(size.Width, size.Height); - - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RDStatus.cs b/RhythmBaseCore/Components/RDStatus.cs deleted file mode 100644 index 85e13b6..0000000 --- a/RhythmBaseCore/Components/RDStatus.cs +++ /dev/null @@ -1,36 +0,0 @@ -using RhythmBase.Events; - -namespace RhythmBase.Components -{ - /// - /// Record the status of RDLevel moment - /// - public readonly record struct RDStatus() - { - /// - /// Gets the beat information. - /// - public RDBeat Beat { get; internal init; } - - /// - /// Gets the room status information. - /// - public RoomStatus[] RoomStatus { get; internal init; } - } - - /// - /// Represents the status of a room. - /// - public readonly record struct RoomStatus - { - /// - /// Gets the beat information. - /// - public RDBeat Beat { get; internal init; } - - /// - /// Gets the running VFX presets. - /// - public IEnumerable RunningVFXs { get; internal init; } - } -} diff --git a/RhythmBaseCore/Components/RDVariables.cs b/RhythmBaseCore/Components/RDVariables.cs deleted file mode 100644 index b5e5cdb..0000000 --- a/RhythmBaseCore/Components/RDVariables.cs +++ /dev/null @@ -1,219 +0,0 @@ -using System.Reflection; -namespace RhythmBase.Components -{ - /// - /// Variables. - /// - public sealed class RDVariables - { - /// - /// Enumeration representing different ranks. - /// - public enum RDRank - { - /// - /// S+ rank. - /// - SPlus, - /// - /// S rank. - /// - S, - /// - /// A rank. - /// - A, - /// - /// B rank. - /// - B, - /// - /// C rank. - /// - C, - /// - /// D rank. - /// - D, - /// - /// F rank. - /// - F, - } -#pragma warning disable CS1591 -#pragma warning disable IDE1006 - public RDVariables() - { - i = new int[10]; - f = new float[10]; - b = new bool[10]; - } - public static int Rand(int value) => - (value > 0 - ? Random.Shared.Next(1, value) - : -Random.Shared.Next(1, -value) - ) + 1; - public static bool atLeastRank(string rank) => rank switch - { - "S+" => SimulateCurrentRank <= RDRank.SPlus, - "S" => SimulateCurrentRank <= RDRank.S, - "A" => SimulateCurrentRank <= RDRank.A, - "B" => SimulateCurrentRank <= RDRank.B, - "C" => SimulateCurrentRank <= RDRank.C, - "D" => SimulateCurrentRank <= RDRank.D, - "F" => SimulateCurrentRank <= RDRank.F, - _ => throw new ArgumentException("Invalid rank"), - }; - public static bool atLeastNPerfects(int hitsToCheck, int numberOfPerfects) => numberOfPerfects / (float)hitsToCheck > SimulateAtLeastNPerfectsSuccessRate; - public object this[string variableName] - { - get => variableName switch - { - ['i', char ii] => i[ii - '0'], - ['f', char fi] => f[fi - '0'], - ['b', char bi] => b[bi - '0'], - _ => GetType().GetField(variableName)?.GetValue(this)!, - }; - set - { - switch (variableName) - { - case ['i', char ii]: - i[ii - '0'] = value is int v1 ? v1 : throw new ArgumentException("Value is not an integer."); - break; - case ['f', char fi]: - f[fi] = value is float v2 ? v2 : throw new ArgumentException("Value is not a float."); - break; - case ['b', char bi]: - b[bi] = value is bool v3 ? v3 : throw new ArgumentException("Value is not a boolean."); - break; - default: - FieldInfo? field = GetType().GetField(variableName); - field?.SetValue(this, value); - break; - - } - } - } - /// - /// Integer variables. - /// - public readonly int[] i; - /// - /// Float variables. - /// - public readonly float[] f; - /// - /// Boolean variables. - /// - public readonly bool[] b; - - public int barNumber; - - public int buttonPressCount; - - public int missesToCrackHeart; - - public int numEarlyHits; - - public int numLateHits; - - public int numMisses; - - public int numPerfectHits; - - public float bpm; - - public float deltaTime; - - public float levelSpeed; - - public float numMistakes; - - public float numMistakesP1; - - public float numMistakesP2; - - public float shockwaveDistortionMultiplier; - - public float shockwaveDurationMultiplier; - - public float shockwaveSizeMultiplier; - - public float statusSignWidth; - - public bool activeDialogues; - - public bool activeDialoguesImmediately; - - public bool alternativeMatrix; - - public bool anyPlayerPress; - - public bool autoplay; - - public bool booleansDefaultToTrue; - - public bool charsOnlyOnStart; - - public bool cpuIsP2On2P; - - public bool disableRowChangeWarningFlashes; - - public bool downPress; - - public bool hideHandsOnStart; - - public bool invisibleChars; - - public bool invisibleHeart; - - public bool leftPress; - - public bool noBananaBeats; - - public bool noHands; - - public bool noHitFlashBorder; - - public bool noHitStrips; - - public bool noOneshotShadows; - - public bool noRowAnimsOnStart; - - public bool noSmartJudgment; - - public bool p1IsPressed; - - public bool p1Press; - - public bool p1Release; - - public bool p2IsPressed; - - public bool p2Press; - - public bool p2Release; - - public bool rightPress; - - public bool rotateShake; - - public bool rowReflectionsJumping; - - public bool skippableRankScreen; - - public bool skipRankText; - - public bool smoothShake; - - public bool upPress; - - public bool useFlashFontForFloatingText; - - public bool wobblyLines; - public static float SimulateAtLeastNPerfectsSuccessRate { get; set; } = 0.9f; - public static RDRank SimulateCurrentRank { get; set; } = RDRank.S; - } -} diff --git a/RhythmBaseCore/Components/RichText/IRDRichStringStyle.cs b/RhythmBaseCore/Components/RichText/IRDRichStringStyle.cs deleted file mode 100644 index 454d022..0000000 --- a/RhythmBaseCore/Components/RichText/IRDRichStringStyle.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Numerics; - -namespace RhythmBase.Components.RichText -{ - /// - /// Defines the interface for rich string styles. - /// - /// The type that implements this interface. - public interface IRDRichStringStyle : IEqualityOperators, IEquatable - where TSelf : IRDRichStringStyle - { - /// - /// Determines whether the specified object is equal to the current object. - /// - /// The object to compare with the current object. - /// True if the specified object is equal to the current object; otherwise, false. - bool Equals([NotNullWhen(true)] object? obj) => obj is TSelf e && Equals(e); - - /// - /// Gets the closing tag for the specified name. - /// - /// The name of the tag. - /// The closing tag for the specified name. - static string GetCloseTag(string name) => $""; - - /// - /// Gets the opening tag for the specified name and optional argument. - /// - /// The name of the tag. - /// The optional argument for the tag. - /// The opening tag for the specified name and optional argument. - static string GetOpenTag(string name, string? arg = null)=> arg is null ? $"<{name}>" : $"<{name}={arg}>"; - - /// - /// Generates an XML tag representing the differences between two instances. - /// - /// The initial instance. - /// The modified instance. - /// A string containing the XML tag that represents the differences between the two instances. - static abstract string GetXmlTag(TSelf before, TSelf after); - - /// - /// Resets the property of the rich string style based on the provided name. - /// - /// The name of the property to reset. - /// True if the property was successfully reset; otherwise, false. - bool ResetProperty(string name); - - /// - /// Sets the property of the rich string style based on the provided name and value. - /// - /// The name of the property to set. - /// The value to set for the property. - /// True if the property was successfully set; otherwise, false. - bool SetProperty(string name, string value); - - /// - /// Tries to add a tag to the specified string based on the provided name and boolean values. - /// - /// The string to which the tag will be added. - /// The name of the tag. - /// A boolean value indicating whether the tag is before. - /// A boolean value indicating whether the tag is after. - static void TryAddTag(ref string tag, string name, bool before, bool after) - { - if (before != after) - tag += after - ? GetOpenTag(name) - : GetCloseTag(name); - } - - /// - /// Tries to add a tag to the specified string based on the provided name and optional string values. - /// - /// The string to which the tag will be added. - /// The name of the tag. - /// An optional string value indicating the tag before. - /// An optional string value indicating the tag after. - static void TryAddTag(ref string tag, string name, string? before, string? after) - { - if (before != after) - tag += after is null - ? GetCloseTag(name) - : before is null - ? GetOpenTag(name, after) - : GetCloseTag(name) + GetOpenTag(name, after); - } - /// - /// Gets a value indicating whether the style has a phrase. - /// - static abstract bool HasPhrase { get; } - } -} diff --git a/RhythmBaseCore/Components/RichText/IRDRichTextLine.cs b/RhythmBaseCore/Components/RichText/IRDRichTextLine.cs deleted file mode 100644 index ca804bb..0000000 --- a/RhythmBaseCore/Components/RichText/IRDRichTextLine.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace RhythmBase.Components.RichText -{ - /// - /// Represents a line of rich text with a specific style. - /// - /// The type of the style applied to the rich text. - public interface IRDRichTextLine where TStyle : IRDRichStringStyle, new() - { - /// - /// Gets or sets the at the specified index. - /// - /// The index of the rich text line. - /// The rich text line at the specified index. - RDLine this[Index index] { get; set; } - /// - /// Gets or sets the within the specified range. - /// - /// The range of the rich text lines. - /// The rich text lines within the specified range. - RDLine this[Range range] { get; set; } - /// - /// Gets the length of the rich text line. - /// - int Length { get; } - /// - /// Concatenates multiple instances into a single instance. - /// - /// The rich text lines to concatenate. - /// A new containing the concatenated content. - static abstract RDLine Concat(params RDLine[] lines); - /// - /// Deserializes a string into an . - /// - /// The string to deserialize. - /// A new containing the deserialized content. - static abstract RDLine Deserialize(string text); - /// - /// Serializes the current instance to a string. - /// - /// A string representation of the current instance. - string Serialize(); - } -} diff --git a/RhythmBaseCore/Components/RichText/RDDialogueBlock.cs b/RhythmBaseCore/Components/RichText/RDDialogueBlock.cs deleted file mode 100644 index 04b2f53..0000000 --- a/RhythmBaseCore/Components/RichText/RDDialogueBlock.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.Text; - -namespace RhythmBase.Components.RichText -{ - /// - /// Represents a line of dialogue, which consists of multiple dialogue components. - /// - public class RDDialogueBlock - { - /// - /// Gets or sets the character speaking the dialogue line. - /// - public string? Character { get; set; } - /// - /// Gets or sets the expression of the character. - /// - public string? Expression { get; set; } - /// - /// Gets or sets the content of the dialogue line. - /// - /// - /// The content of the dialogue line, represented as an . - /// - public RDLine Content { get; set; } = ""; - /// - /// Serializes the dialogue line to a string. - /// - /// A string representation of the dialogue line. - public string Serialize() - { - var sb = new StringBuilder(); - if (!string.IsNullOrWhiteSpace(Character)) - { - sb.Append(Character); - if (!string.IsNullOrWhiteSpace(Expression)) - { - sb.Append('_').Append(Expression); - } - sb.Append(':'); - } - sb.Append(Content.Serialize()); - return sb.ToString(); - } - /// - /// Deserializes a string into a instance. - /// - /// The string to deserialize. - /// A new containing the deserialized content. - /// Thrown when the input string is null. - /// Thrown when the input string has an invalid format. - public static RDDialogueBlock Deserialize(string str) - { - str = str.Trim(); - RDDialogueBlock line = new(); - int mi = str.IndexOf(':'); - if (mi != -1) - { - string character = str[..mi]; - if (character.Contains('_')) - { - string[] parts = character.Split('_', 2); - character = parts[0]; - line.Expression = parts[1]; - } - line.Character = character; - } - line.Content = RDLine.Deserialize(str[(mi + 1)..]); - return line; - } - /// - /// Deserializes a string into a instance, using a lookup of valid expressions. - /// - /// The string to deserialize. - /// A lookup of valid expressions for each character. - /// A new containing the deserialized content. - /// Thrown when the input string is null. - /// Thrown when the input string has an invalid format. - public static RDDialogueBlock Deserialize(string str, ILookup expressions) - { - str = str.Trim(); - RDDialogueBlock line = new(); - int mi = str.IndexOf(':'); - if (mi != -1) - { - string character = str[..mi]; - string expression = ""; - if (character.Contains('_')) - { - string[] parts = character.Split('_', 2); - character = parts[0]; - expression = parts[1]; - } - else - character = str; - if (!expressions.Contains(character)) - { - line.Content = RDLine.Deserialize(str); - return line; - } - line.Character = character; - if (expressions[character].Contains(expression)) - line.Expression = expression; - } - line.Content = RDLine.Deserialize(str[(mi + 1)..]); - return line; - } - /// - public override string ToString() => $"{Character}({Expression}):{Content}"; - } -} diff --git a/RhythmBaseCore/Components/RichText/RDDialogueExchange.cs b/RhythmBaseCore/Components/RichText/RDDialogueExchange.cs deleted file mode 100644 index 199b10e..0000000 --- a/RhythmBaseCore/Components/RichText/RDDialogueExchange.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace RhythmBase.Components.RichText -{ - /// - /// Represents a list of dialogue lines. - /// - public class RDDialogueExchange : List - { - /// - /// Serializes the dialogue list to a string. - /// - /// A string representation of the dialogue list. - public string Serialize() => string.Join('\n', this.Select(i => i.Serialize())); - /// - /// Deserializes a string into a instance. - /// - /// The string to deserialize. - /// A new containing the deserialized dialogue lines. - public static RDDialogueExchange Deserialize(string text) => [.. text.Split("\r\n", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(RDDialogueBlock.Deserialize)]; - /// - /// Deserializes a string into a instance, using a lookup of valid expressions. - /// - /// The string to deserialize. - /// A lookup of valid expressions for each character. - /// A new containing the deserialized dialogue lines. - /// Thrown when the input string is null. - /// Thrown when the input string has an invalid format. - public static RDDialogueExchange Deserialize(string text, ILookup expressions) => [.. text.Split("\r\n", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(i => RDDialogueBlock.Deserialize(i, expressions))]; - /// - public override string ToString() => string.Join('\n', this.Select(i => i.ToString())); - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Components/RichText/RDDialoguePhraseStyle.cs b/RhythmBaseCore/Components/RichText/RDDialoguePhraseStyle.cs deleted file mode 100644 index 0077d30..0000000 --- a/RhythmBaseCore/Components/RichText/RDDialoguePhraseStyle.cs +++ /dev/null @@ -1,276 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace RhythmBase.Components.RichText -{ - /// - /// Represents the style of a rich string. - /// - public struct RDDialoguePhraseStyle : IRDRichStringStyle - { - /// - /// Gets or sets the color of the text. - /// - public RDColor? Color { get; set; } - /// - /// Gets or sets the speed of the text animation. - /// - public float? Speed { get; set; } - /// - /// Gets or sets the volume of the text. - /// - public float? Volume { get; set; } - /// - /// Gets or sets the pitch of the text. - /// - public float? Pitch { get; set; } - /// - /// Gets or sets the pitch range of the text. - /// - public float? PitchRange { get; set; } - /// - /// Gets or sets a value indicating whether the text should shake. - /// - public bool Shake { get; set; } - /// - /// Gets or sets the radius of the shake effect. - /// - public float? ShakeRadius { get; set; } - /// - /// Gets or sets a value indicating whether the text should have a wave effect. - /// - public bool Wave { get; set; } - /// - /// Gets or sets the height of the wave effect. - /// - public float? WaveHeight { get; set; } - /// - /// Gets or sets the speed of the wave effect. - /// - public float? WaveSpeed { get; set; } - /// - /// Gets or sets a value indicating whether the text should have a swirl effect. - /// - public bool Swirl { get; set; } - /// - /// Gets or sets the radius of the swirl effect. - /// - public float? SwirlRadius { get; set; } - /// - /// Gets or sets the speed of the swirl effect. - /// - public float? SwirlSpeed { get; set; } - /// - /// Gets or sets a value indicating whether the text should be sticky. - /// - public bool Sticky { get; set; } - /// - /// Gets or sets a value indicating whether the text should be loud. - /// - public bool Loud { get; set; } - /// - /// Gets or sets a value indicating whether the text should be bold. - /// - public bool Bold { get; set; } - /// - /// Gets or sets a value indicating whether the text should be whispered. - /// - public bool Whisper { get; set; } - /// - public static bool HasPhrase => true; - /// - /// Sets the property of the rich string style based on the provided name and value. - /// - /// The name of the property to set. - /// The value to set for the property. - /// True if the property was successfully set; otherwise, false. - public bool SetProperty(string name, string value) - { - switch (name) - { - case "color": - if (RDColor.TryFromName(value, out RDColor color)) - Color = color; - else if (RDColor.TryFromRgba(value, out color)) - Color = color; - else - return false; - break; - case "speed": - Speed = float.Parse(value); - break; - case "volume": - Volume = float.Parse(value); - break; - case "pitch": - Pitch = float.Parse(value); - break; - case "pitchRange": - PitchRange = float.Parse(value); - break; - case "shake": - Shake = bool.Parse(value); - break; - case "shakeRadius": - ShakeRadius = float.Parse(value); - break; - case "wave": - Wave = bool.Parse(value); - break; - case "waveHeight": - WaveHeight = float.Parse(value); - break; - case "waveSpeed": - WaveSpeed = float.Parse(value); - break; - case "swirl": - Swirl = bool.Parse(value); - break; - case "swirlRadius": - SwirlRadius = float.Parse(value); - break; - case "swirlSpeed": - SwirlSpeed = float.Parse(value); - break; - case "sticky": - Sticky = bool.Parse(value); - break; - case "loud": - Loud = bool.Parse(value); - break; - case "bold": - Bold = bool.Parse(value); - break; - case "whisper": - Whisper = bool.Parse(value); - break; - default: - return false; - } - return true; - } - /// - /// Removes the property of the rich string style based on the provided name. - /// - /// The name of the property to remove. - /// True if the property was successfully removed; otherwise, false. - public bool ResetProperty(string name) - { - switch (name) - { - case "color": - Color = null; - break; - case "speed": - Speed = null; - break; - case "volume": - Volume = null; - break; - case "pitch": - Pitch = null; - break; - case "pitchRange": - PitchRange = null; - break; - case "shake": - Shake = false; - break; - case "shakeRadius": - ShakeRadius = null; - break; - case "wave": - Wave = false; - break; - case "waveHeight": - WaveHeight = null; - break; - case "waveSpeed": - WaveSpeed = null; - break; - case "swirl": - Swirl = false; - break; - case "swirlRadius": - SwirlRadius = null; - break; - case "swirlSpeed": - SwirlSpeed = null; - break; - case "sticky": - Sticky = false; - break; - case "loud": - Loud = false; - break; - case "bold": - Bold = false; - break; - case "whisper": - Whisper = false; - break; - default: - return false; - } - return true; - } - /// - public static string GetXmlTag(RDDialoguePhraseStyle before, RDDialoguePhraseStyle after) - { - string tag = ""; - IRDRichStringStyle.TryAddTag(ref tag, "color", - before.Color?.TryGetName(out string[] namesbefore) == true - ? namesbefore[0].ToLower() - : before.Color?.ToString(before.Color?.A == 255 ? "#RRGGBB" : "#RRGGBBAA"), - after.Color?.TryGetName(out string[] namesafter) == true - ? namesafter[0].ToLower() - : after.Color?.ToString(after.Color?.A == 255 ? "#RRGGBB" : "#RRGGBBAA")); - IRDRichStringStyle.TryAddTag(ref tag, "speed", before.Speed?.ToString(), after.Speed?.ToString()); - IRDRichStringStyle.TryAddTag(ref tag, "volume", before.Volume?.ToString(), after.Volume?.ToString()); - IRDRichStringStyle.TryAddTag(ref tag, "pitch", before.Pitch?.ToString(), after.Pitch?.ToString()); - IRDRichStringStyle.TryAddTag(ref tag, "pitchRange", before.PitchRange?.ToString(), after.PitchRange?.ToString()); - IRDRichStringStyle.TryAddTag(ref tag, "shake", before.Shake, after.Shake); - IRDRichStringStyle.TryAddTag(ref tag, "shakeRadius", before.ShakeRadius?.ToString(), after.ShakeRadius?.ToString()); - IRDRichStringStyle.TryAddTag(ref tag, "wave", before.Wave, after.Wave); - IRDRichStringStyle.TryAddTag(ref tag, "waveHeight", before.WaveHeight?.ToString(), after.WaveHeight?.ToString()); - IRDRichStringStyle.TryAddTag(ref tag, "waveSpeed", before.WaveSpeed?.ToString(), after.WaveSpeed?.ToString()); - IRDRichStringStyle.TryAddTag(ref tag, "swirl", before.Swirl, after.Swirl); - IRDRichStringStyle.TryAddTag(ref tag, "swirlRadius", before.SwirlRadius?.ToString(), after.SwirlRadius?.ToString()); - IRDRichStringStyle.TryAddTag(ref tag, "swirlSpeed", before.SwirlSpeed?.ToString(), after.SwirlSpeed?.ToString()); - IRDRichStringStyle.TryAddTag(ref tag, "sticky", before.Sticky, after.Sticky); - IRDRichStringStyle.TryAddTag(ref tag, "loud", before.Loud, after.Loud); - IRDRichStringStyle.TryAddTag(ref tag, "bold", before.Bold, after.Bold); - IRDRichStringStyle.TryAddTag(ref tag, "whisper", before.Whisper, after.Whisper); - return tag; - } - /// - public static bool operator ==(RDDialoguePhraseStyle left, RDDialoguePhraseStyle right) => - left.Color == right.Color - && left.Speed == right.Speed - && left.Volume == right.Volume - && left.Pitch == right.Pitch - && left.PitchRange == right.PitchRange - && left.Shake == right.Shake - && left.ShakeRadius == right.ShakeRadius - && left.Wave == right.Wave - && left.WaveHeight == right.WaveHeight - && left.WaveSpeed == right.WaveSpeed - && left.Swirl == right.Swirl - && left.SwirlRadius == right.SwirlRadius - && left.SwirlSpeed == right.SwirlSpeed - && left.Sticky == right.Sticky - && left.Loud == right.Loud - && left.Bold == right.Bold - && left.Whisper == right.Whisper; - /// - public static bool operator !=(RDDialoguePhraseStyle left, RDDialoguePhraseStyle right) => !(left == right); - /// - public readonly override bool Equals([NotNullWhen(true)] object? obj) => obj is RDDialoguePhraseStyle e && base.Equals(e); - /// - public readonly bool Equals(RDDialoguePhraseStyle other) => this == other; - /// - public readonly override int GetHashCode() - { - return base.GetHashCode(); - } - } -} diff --git a/RhythmBaseCore/Components/RichText/RDDialogueTone.cs b/RhythmBaseCore/Components/RichText/RDDialogueTone.cs deleted file mode 100644 index ea82848..0000000 --- a/RhythmBaseCore/Components/RichText/RDDialogueTone.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace RhythmBase.Components.RichText -{ - /// - /// Enum representing the different types of rich string events. - /// - public enum RDDialogueToneType - { - /// - /// Static event type. - /// - Static, - /// - /// Flash event type. - /// - Flash, - /// - /// Very slow event type. - /// - VerySlow, - /// - /// Slow event type. - /// - Slow, - /// - /// Normal event type. - /// - Normal, - /// - /// Fast event type. - /// - Fast, - /// - /// Very fast event type. - /// - VeryFast, - /// - /// Very very fast event type. - /// - VeryVeryFast, - /// - /// Excited event type. - /// - Excited, - /// - /// Shout event type. - /// - Shout, - /// - /// Shake event type. - /// - Shake, - /// - /// Pause event type. - /// - Pause, - } - /// - /// Class representing a rich string event. - /// - /// Rich string event type. - /// Rich string event index. - public record struct RDDialogueTone(RDDialogueToneType Type, int Index) - { - /// - /// Gets the pause duration for the dialogue event. - /// - public int? Pause { get; init; } - /// - /// Serializes the rich string event type to its corresponding string representation. - /// - /// A string representation of the rich string event type. - /// Thrown when the event type is not implemented. - public string Serialize() => "[" + Type switch - { - RDDialogueToneType.Static => "static", - RDDialogueToneType.Flash => "flash", - RDDialogueToneType.VerySlow => "vslow", - RDDialogueToneType.Slow => "slow", - RDDialogueToneType.Normal => "normal", - RDDialogueToneType.Fast => "fast", - RDDialogueToneType.VeryFast => "vfast", - RDDialogueToneType.VeryVeryFast => "vvvfast", - RDDialogueToneType.Excited => "excited", - RDDialogueToneType.Shout => "shout", - RDDialogueToneType.Shake => "shake", - RDDialogueToneType.Pause => Pause?.ToString(), - _ => throw new NotImplementedException(), - } + "]"; - /// - /// Creates a new instance of based on the provided type and index. - /// - /// The string representation of the event type. - /// The index of the event. - /// The created instance if successful, otherwise null. - /// True if the event was successfully created, otherwise false. - public static bool Create(string type, int index, [NotNullWhen(true)] out RDDialogueTone? result) - { - RDDialogueToneType? eventType = type switch - { - "static" => RDDialogueToneType.Static, - "flash" => RDDialogueToneType.Flash, - "vslow" => RDDialogueToneType.VerySlow, - "slow" => RDDialogueToneType.Slow, - "normal" => RDDialogueToneType.Normal, - "fast" => RDDialogueToneType.Fast, - "vfast" => RDDialogueToneType.VeryFast, - "vvvfast" => RDDialogueToneType.VeryVeryFast, - "excited" => RDDialogueToneType.Excited, - "shout" => RDDialogueToneType.Shout, - "shake" => RDDialogueToneType.Shake, - _ => null, - }; - if (eventType is null) - { - if (int.TryParse(type, out int pause)) - { - result = new(RDDialogueToneType.Pause, index) { Pause = pause }; - return true; - } - result = null; - return false; - } - result = new(eventType.Value, index); - return true; - } - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Components/RichText/RDLine.cs b/RhythmBaseCore/Components/RichText/RDLine.cs deleted file mode 100644 index fccaad0..0000000 --- a/RhythmBaseCore/Components/RichText/RDLine.cs +++ /dev/null @@ -1,260 +0,0 @@ -using System.Diagnostics; -using System.Text; - -namespace RhythmBase.Components.RichText -{ - /// - /// Represents a list of rich text strings. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDLine() - : IRDRichTextLine - where TStyle : IRDRichStringStyle, new() - { - /// - /// Gets or sets the list of rich text strings. - /// - private RDPhrase[] texts = []; - /// - /// The length of the string. - /// - public readonly int Length => texts.Sum(i => i.Length); - /// - /// Gets or sets the at the specified index. - /// - /// The index of the to get or set. - /// The at the specified index. - /// Thrown when the index is out of range. - public RDLine this[Index index] - { - get - { - int i = index.GetOffset(Length); - if (Length <= i) - throw new ArgumentOutOfRangeException(nameof(index)); - int ti = 0; - while (texts[ti].Length < i) - { - i -= texts[ti].Length; - ti++; - } - RDLine line = new() - { - texts = [texts[ti][i]] - }; - return line; - } - set - { - int i = index.GetOffset(Length); - if (Length <= i) - throw new ArgumentOutOfRangeException(nameof(index)); - texts = Concat([this[..i], value, this[(i + 1)..]]).texts; - } - } - /// - /// Gets or sets the within the specified range. - /// - /// The range of the to get or set. - /// The within the specified range. - /// Thrown when the range is out of bounds. - public RDLine this[Range range] - { - get - { - int start = range.Start.GetOffset(Length); - int end = range.End.GetOffset(Length); - if (!(start <= end && end <= Length)) - throw new ArgumentOutOfRangeException(nameof(range)); - int ti = 0, tstart, tend; - RDPhrase[] strings = []; - while (texts[ti].Length <= start) - { - start -= texts[ti].Length; - end -= texts[ti].Length; - ti++; - } - tstart = ti; - while (texts[ti].Length < end) - { - end -= texts[ti].Length; - ti++; - } - tend = ti; - if (tstart == tend) - strings = [texts[tstart][start..end]]; - else - { - for (int i = tstart + 1; i < tend; i++) - strings = [.. strings, texts[i]]; - strings = [texts[tstart][start..], .. strings, texts[tend][..end]]; - } - RDLine line = new() - { - texts = strings - }; - return line; - } - set - { - int start = range.Start.GetOffset(Length); - int end = range.End.GetOffset(Length); - if (!(start < end && end <= Length)) - throw new ArgumentOutOfRangeException(nameof(range)); - texts = Concat([this[..start], value, this[end..]]).texts; - } - } - /// - public static RDLine Concat(params RDLine[] lines) - { - RDPhrase[] texts = [.. lines[0].texts]; - foreach (RDLine line in lines[1..]) - { - if (texts[^1].Style == line.texts[0].Style) - { - RDPhrase before = texts[^1], after = line.texts[0]; - RDPhrase richString = new(before.Text + after.Text) - { - Style = before.Style, - Events = [.. before.Events, .. after.Events.Select(i => new RDDialogueTone(i.Type, i.Index + before.Length) { Pause = i.Pause })] - }; - texts = [.. texts[..^1], richString, .. line.texts[1..]]; - } - else - texts = [.. texts, .. line.texts]; - } - return new() { texts = texts }; - } - /// - /// Implicitly converts a to a . - /// - /// The to convert. - /// A new containing the specified . - public static implicit operator RDLine(RDPhrase text) => new() { texts = [text] }; - /// - /// Implicitly converts a to a . - /// - /// The to convert. - /// A new containing the specified . - public static implicit operator RDLine(RDPhrase[] texts) => new() { texts = texts }; - /// - /// Implicitly converts a to a . - /// - /// The to convert. - /// A new containing the specified . - public static implicit operator RDLine(string text) => new() { texts = [new RDPhrase(text)] }; - /// - /// Deserializes a string into an . - /// - /// The string to deserialize. - /// A new containing the deserialized content. - /// Thrown when the input text is null. - /// Thrown when the input text has an invalid format. - static public RDLine Deserialize(string text) - { - RDLine line = ""; - TStyle style = new(); - int start = 0; - while (start < text.Length) - { - TStyle tempStyle = style; - int end = text.IndexOf('<', start); - if (end == -1) - { - line += DeserializeStringPart(text[start..], tempStyle); - break; - } - int start2 = text.IndexOf('>', end); - int end2 = text.IndexOf('<', end + 1); - if (start2 == -1) - break; - if (end2 != -1 && end2 < start2) - { - line += DeserializeStringPart(text[start..end2], tempStyle); - start = end2; - continue; - } - string textpart = text[start..end]; - line += DeserializeStringPart(textpart, tempStyle); - string[] keyvalue = text[(end + 1)..start2].Split('=', 2); - if (keyvalue[0].StartsWith('/') && style.ResetProperty(keyvalue[0][1..])) - start = start2 + 1; - else if (style.SetProperty(keyvalue[0], keyvalue.Length == 2 ? keyvalue[1] : "true")) - start = start2 + 1; - else - start = start2 + 1; - } - return line; - } - private static RDPhrase DeserializeStringPart(string text, TStyle style) - { - if (!TStyle.HasPhrase) - return new RDPhrase(text) { Style = style }; - int pstart = 0; - RDDialogueTone[] events = []; - while (pstart < text.Length) - { - int pend = text.IndexOf('[', pstart); - if (pend == -1) - { - break; - } - int pstart2 = text.IndexOf(']', pend); - int pend2 = text.IndexOf('[', pend + 1); - if (pstart2 == -1) - break; - if (pend2 != -1 && pend2 < pstart2) - { - pstart = pend2 + 1; - continue; - } - string btag = text[(pend + 1)..pstart2]; - if (RDDialogueTone.Create(btag, pend, out RDDialogueTone? e) && e is RDDialogueTone ei) - events = [.. events, ei]; - text = text[..pend] + text[(pstart2 + 1)..]; - } - return new RDPhrase(text) { Style = style, Events = events }; - } - /// - /// Serializes the current instance to a string. - /// - /// A string representation of the current instance. - /// - /// The serialization process converts the rich text line into a string format, including any styling information. - /// - public readonly string Serialize() - { - StringBuilder sb = new(); - TStyle style = new(); - int ci = 0; - foreach (RDPhrase str in texts) - { - sb.Append(TStyle.GetXmlTag(style, str.Style)); - string part = str.Text; - int offset = 0; - foreach (RDDialogueTone e in str.Events) - { - string serialized = e.Serialize(); - part = part.Insert(e.Index + offset, serialized); - offset += serialized.Length; - } - sb.Append(part); - ci += str.Length; - style = str.Style; - } - sb.Append(TStyle.GetXmlTag(style, new())); - return sb.ToString(); - } - /// - /// Concatenates two instances. - /// - /// The left . - /// The right . - /// A new that is the result of concatenating the two specified instances. - public static RDLine operator +(RDLine left, RDLine right) => Concat([.. left.texts, .. right.texts]); - /// - public override readonly string ToString() => string.Join("", texts); - /// - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RichText/RDPhrase.cs b/RhythmBaseCore/Components/RichText/RDPhrase.cs deleted file mode 100644 index 0d3909a..0000000 --- a/RhythmBaseCore/Components/RichText/RDPhrase.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Numerics; - -namespace RhythmBase.Components.RichText -{ - - /// - /// Represents a rich text string with various styling options. - /// - /// The text content of the rich string. - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public struct RDPhrase(string text) - : IEqualityOperators, RDPhrase, bool>, - IEquatable> - where TStyle : IRDRichStringStyle, new() - { - /// - /// Gets the text content of the rich string. - /// - public string Text { get; internal set; } = text; - /// - /// Gets or sets the events associated with the rich string. - /// - public RDDialogueTone[] Events { get; init; } = []; - /// - /// Gets the length of the text content. - /// - /// The number of characters in the text content. - public readonly int Length => Text.Length; - /// - /// Gets the rich string at the specified index. - /// - /// The index of the character. - /// A new with the character at the specified index. - public RDPhrase this[Index index] - { - get - { - return new RDPhrase - { - Text = Text[index].ToString(), - Style = Style, - Events = GetEvents(index.GetOffset(Length), 1) - }; - } - } - - /// - /// Gets the rich string within the specified range. - /// - /// The range of characters. - /// A new with the characters within the specified range. - public RDPhrase this[Range range] - { - get - { - RDPhrase style = new() - { - Text = Text[range], - Style = Style, - Events = GetEvents(range.Start.GetOffset(Length), range.End.GetOffset(Length) - range.Start.GetOffset(Length)) - }; - return style; - } - } - private readonly RDDialogueTone[] GetEvents(int start, int length) => Events - .Where(e => e.Index >= start && e.Index < start + length) - .Select(e => new RDDialogueTone(e.Type, e.Index - start)) - .ToArray(); - /// - /// Gets a new with the same style as the current instance. - /// - public TStyle Style { get; init; } = new(); - /// - /// Initializes a new instance of the struct with an empty text. - /// - public RDPhrase() : this("") { } - /// - /// Implicitly converts a string to an . - /// - /// The text to convert. - /// A new instance with the specified text. - public static implicit operator RDPhrase(string text) => new() { Text = text }; - /// - public static bool operator ==(RDPhrase left, RDPhrase right) => left.Text == right.Text && left.Style == right.Style; - /// - public static bool operator !=(RDPhrase left, RDPhrase right) => !(left == right); - /// - public readonly bool Equals(RDPhrase other) => this == other; - /// - public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is RDPhrase && base.Equals(obj); - /// - public override readonly int GetHashCode() => Text.GetHashCode(); - /// - public override readonly string ToString() => Text; - /// - private readonly string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Components/RichText/RDRichStringStyle.cs b/RhythmBaseCore/Components/RichText/RDRichStringStyle.cs deleted file mode 100644 index b9b1fa8..0000000 --- a/RhythmBaseCore/Components/RichText/RDRichStringStyle.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace RhythmBase.Components.RichText -{ - /// - /// Represents a rich string style. - /// - public struct RDRichStringStyle : IRDRichStringStyle - { - /// - /// 获取或设置文本的颜色。 - /// - public RDColor? Color { get; set; } - /// - public static bool HasPhrase => false; - /// - public static string GetXmlTag(RDRichStringStyle before, RDRichStringStyle after) - { - string tag = ""; - IRDRichStringStyle.TryAddTag(ref tag, "color", - before.Color?.TryGetName(out string[] namesbefore) == true - ? namesbefore[0].ToLower() - : before.Color?.ToString(before.Color?.A == 255 ? "#RRGGBB" : "#RRGGBBAA"), - after.Color?.TryGetName(out string[] namesafter) == true - ? namesafter[0].ToLower() - : after.Color?.ToString(after.Color?.A == 255 ? "#RRGGBB" : "#RRGGBBAA")); - return tag; - } - /// - public readonly bool Equals(RDRichStringStyle other) => this == other; - /// - public readonly override bool Equals([NotNullWhen(true)] object? obj) => obj is RDRichStringStyle e && Equals(e); - /// - public bool ResetProperty(string name) - { - switch (name) - { - case "color": - Color = null; - break; - default: - return false; - } - return true; - } - /// - public bool SetProperty(string name, string value) - { - switch (name) - { - case "color": - if (RDColor.TryFromName(value, out RDColor color)) - Color = color; - else if (RDColor.TryFromRgba(value, out color)) - Color = color; - else - return false; - break; - default: - return false; - } - return true; - } - /// - public static bool operator ==(RDRichStringStyle left, RDRichStringStyle right) => left.Color == right.Color; - /// - public static bool operator !=(RDRichStringStyle left, RDRichStringStyle right) => !(left == right); - /// - public readonly override int GetHashCode() => Color.GetHashCode(); - } -} diff --git a/RhythmBaseCore/Components/RowEventCollection.cs b/RhythmBaseCore/Components/RowEventCollection.cs deleted file mode 100644 index 02fd55f..0000000 --- a/RhythmBaseCore/Components/RowEventCollection.cs +++ /dev/null @@ -1,184 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using RhythmBase.Events; -using RhythmBase.Exceptions; -namespace RhythmBase.Components -{ - /// - /// A collection of row events. - /// - [JsonObject] - public class RowEventCollection : OrderedEventCollection - { - /// - /// Gets or sets the character associated with the row. - /// - public RDCharacter Character { get; set; } - - /// - /// Gets or sets the type of the row. - /// - public RowType RowType - { - get => _rowType; - set - { - if (value != _rowType) - { - Clear(); - _rowType = value; - } - } - } - - /// - /// Gets the index of the row. - /// - [JsonProperty("row", DefaultValueHandling = DefaultValueHandling.Include)] - public sbyte Index => (sbyte)(Parent?.ModifiableRows.IndexOf(this) ?? throw new RhythmBaseException()); - - /// - /// Gets or sets the rooms associated with the row. - /// - public RDSingleRoom Rooms { get; set; } - - /// - /// Gets or sets a value indicating whether the row is hidden at the start. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public bool HideAtStart { get; set; } - - /// - /// Gets or sets the initial player mode for the row. - /// - public PlayerType Player { get; set; } = PlayerType.P1; - - /// - /// Gets the initial beat sound for the row. - /// - [JsonIgnore] - public RDAudio Sound { get; set; } - - /// - /// Gets or sets a value indicating whether the beats are muted. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public bool MuteBeats { get; set; } - - /// - /// Gets or sets the row to mimic. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public sbyte RowToMimic { get; set; } - - /// - /// Gets or sets the name of the pulse sound. - /// - public string PulseSound - { - get => Sound.Filename; - set => Sound.Filename = value; - } - - /// - /// Gets or sets the volume of the pulse sound. - /// - public int PulseSoundVolume - { - get => Sound.Volume; - set => Sound.Volume = value; - } - - /// - /// Gets or sets the pitch of the pulse sound. - /// - public int PulseSoundPitch - { - get => Sound.Pitch; - set => Sound.Pitch = value; - } - - /// - /// Gets or sets the pan of the pulse sound. - /// - public int PulseSoundPan - { - get => Sound.Pan; - set => Sound.Pan = value; - } - - /// - /// Gets or sets the offset of the pulse sound. - /// - [JsonConverter(typeof(MilliSecondConverter))] - public TimeSpan PulseSoundOffset - { - get => Sound.Offset; - set => Sound.Offset = value; - } - - /// - /// Initializes a new instance of the class. - /// - internal RowEventCollection() - { - Rooms = new RDSingleRoom(RDRoomIndex.Room1); - Sound = new RDAudio(); - RowToMimic = -1; - } - - /// - /// Adds an item to the row. - /// - /// The row event to add. - public override void Add(BaseRowAction item) - { - if (item is not BaseBeat || - (item is BaseBeat && ( - ((item.Type - is EventType.AddClassicBeat - or EventType.AddFreeTimeBeat - or EventType.PulseFreeTimeBeat - or EventType.SetRowXs - ) && RowType is RowType.Classic) || - ((item.Type - is EventType.AddOneshotBeat - or EventType.SetOneshotWave - ) && RowType is RowType.Oneshot) - )) - ) - { - item._parent?.Remove(item); - item._parent = this; - Parent?.Add(item); - return; - } - throw new IllegalRowEventTypeException(item.Type, RowType); - } - - /// - /// Adds an item to the row safely. - /// - /// The row event to add. - internal void AddSafely(BaseRowAction item) => base.Add(item); - - /// - /// Removes an item from the row. - /// - /// The row event to remove. - /// True if the item was successfully removed; otherwise, false. - public override bool Remove(BaseRowAction item) => Parent?.Remove(item) ?? throw new RhythmBaseException(); - - /// - /// Removes an item from the row safely. - /// - /// The row event to remove. - /// True if the item was successfully removed; otherwise, false. - internal bool RemoveSafely(BaseRowAction item) => base.Remove(item); - - private RowType _rowType; - - [JsonIgnore] - internal RDLevel? Parent = null; - } -} diff --git a/RhythmBaseCore/Components/Settings.cs b/RhythmBaseCore/Components/Settings.cs deleted file mode 100644 index 42b7861..0000000 --- a/RhythmBaseCore/Components/Settings.cs +++ /dev/null @@ -1,225 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -namespace RhythmBase.Components -{ - /// - /// Level settings. - /// - public class Settings - { - private int[] rankMaxMistakes = new int[4]; - private string[] rankDescription = ["", "", "", "", "", ""]; - - /// - /// Level settings. - /// - public Settings() - { - Version = 61; - Artist = ""; - Song = ""; - SpecialArtistType = SpecialArtistTypes.None; - ArtistPermission = ""; - ArtistLinks = ""; - Author = ""; - Difficulty = DifficultyLevel.Medium; - SeizureWarning = false; - PreviewImage = ""; - SyringeIcon = ""; - PreviewSong = ""; - Description = ""; - Tags = ""; - Separate2PLevelFilename = ""; - CanBePlayedOn = LevelPlayedMode.OnePlayerOnly; - FirstBeatBehavior = FirstBeatBehaviors.RunNormally; - MultiplayerAppearance = MultiplayerAppearances.HorizontalStrips; - LevelVolume = 1f; - } - /// - /// The version number of the level. - /// The minimum level version number supported by this library is 55. - /// - public int Version { get; set; } - /// - /// Song artist. - /// - public string Artist { get; set; } - /// - /// Song name. - /// - public string Song { get; set; } - /// - /// Special artist type. - /// - public SpecialArtistTypes SpecialArtistType { get; set; } - /// - /// File path for proof of artist's permission. - /// - public string ArtistPermission { get; set; } - /// - /// Artist links. - /// - public string ArtistLinks { get; set; } - /// - /// Level author. - /// - public string Author { get; set; } - /// - /// Level difficulty. - /// - public DifficultyLevel Difficulty { get; set; } - /// - /// Show seizure warning. - /// - public bool SeizureWarning { get; set; } - /// - /// Preview image file path. - /// - public string PreviewImage { get; set; } - /// - /// Syringe packaging image file path. - /// - public string SyringeIcon { get; set; } - /// - /// The file path of the music used for previewing. - /// - public string PreviewSong { get; set; } - /// - /// Start time of preview music. - /// - [JsonConverter(typeof(SecondConverter))] - public TimeSpan PreviewSongStartTime { get; set; } - /// - /// Duration of preview music. - /// - [JsonConverter(typeof(SecondConverter))] - public TimeSpan PreviewSongDuration { get; set; } - /// - /// Hue offset or grayscale of the level name on the syringe. - /// - [JsonProperty("songNameHue")] - public float SongNameHueOrGrayscale { get; set; } - /// - /// Whether grayscale is enabled. - /// - public bool SongLabelGrayscale { get; set; } - /// - /// Level description. - /// - public string Description { get; set; } - /// - /// Level tags. - /// - public string Tags { get; set; } - /// - /// Separate two-player level file paths. - /// It is uncertain if this attribute is still being used. - /// - public string Separate2PLevelFilename { get; set; } - /// - /// Level play mode. - /// - public LevelPlayedMode CanBePlayedOn { get; set; } - /// - /// Behavior of the first beat of the level. - /// - public FirstBeatBehaviors FirstBeatBehavior { get; set; } - /// - /// Appearance of the level in multiplayer mode. - /// - public MultiplayerAppearances MultiplayerAppearance { get; set; } - /// - /// A percentage value indicating the total volume of the level. - /// - public float LevelVolume { get; set; } - /// - /// Maximum number of mistakes per rank. - /// - public int[] RankMaxMistakes - { - get => rankMaxMistakes; - set => rankMaxMistakes = value.Length == 4 ? value : throw new RhythmBase.Exceptions.RhythmBaseException(); - } - /// - /// Description of each rank. - /// - public string[] RankDescription - { - get => rankDescription; - set => rankDescription = value.Length == 6 ? value : throw new RhythmBase.Exceptions.RhythmBaseException(); - } - /// - /// Mods enabled for the level. - /// - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public List Mods { get; set; } = []; - /// - /// Difficulty level of the level. - /// - public enum DifficultyLevel - { - /// - /// Easy difficulty. - /// - Easy, - /// - /// Medium difficulty. - /// - Medium, - /// - /// Tough difficulty. - /// - Tough, - /// - /// Very tough difficulty. - /// - VeryTough - } - /// - /// Play mode of the level. - /// - public enum LevelPlayedMode - { - /// - /// Can be played by one player only. - /// - OnePlayerOnly, - /// - /// Can be played by two players only. - /// - TwoPlayerOnly, - /// - /// Can be played in both one-player and two-player modes. - /// - BothModes - } - /// - /// Behavior of the first beat of the level. - /// - public enum FirstBeatBehaviors - { - /// - /// Run normally. - /// - RunNormally, - /// - /// Run events on prebar. - /// - RunEventsOnPrebar - } - /// - /// Appearance of the level in multiplayer mode. - /// - public enum MultiplayerAppearances - { - /// - /// Horizontal strips appearance. - /// - HorizontalStrips, - /// - /// No special appearance. - /// - Nothing - } - } -} diff --git a/RhythmBaseCore/Components/SoundSubType.cs b/RhythmBaseCore/Components/SoundSubType.cs deleted file mode 100644 index 30ee5d3..0000000 --- a/RhythmBaseCore/Components/SoundSubType.cs +++ /dev/null @@ -1,107 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -namespace RhythmBase.Components -{ - /// - /// Subtypes of sound effects. - /// - public class SoundSubType - { - /// - /// Initializes a new instance of the class. - /// - public SoundSubType() - { - Audio = new RDAudio(); - } - - /// - /// Gets or sets the referenced audio. - /// - public RDAudio Audio { get; set; } - - /// - /// Gets or sets the sound effect name. - /// - public SoundTypes GroupSubtype { get; set; } - - /// - /// Gets or sets a value indicating whether this is used. - /// - public bool Used { get; set; } - - /// - /// Gets or sets the filename of the audio. - /// - [JsonProperty] - public string Filename - { - get => Audio.Filename; - set => Audio.Filename = value; - } - - /// - /// Gets or sets the volume of the audio. - /// - [JsonProperty] - public int Volume - { - get - { - return Audio.Volume; - } - set - { - Audio.Volume = value; - } - } - - /// - /// Gets or sets the pitch of the audio. - /// - [JsonProperty] - public int Pitch - { - get - { - return Audio.Pitch; - } - set - { - Audio.Pitch = value; - } - } - - /// - /// Gets or sets the pan of the audio. - /// - [JsonProperty] - public int Pan - { - get - { - return Audio.Pan; - } - set - { - Audio.Pan = value; - } - } - - /// - /// Gets or sets the offset of the audio. - /// - [JsonConverter(typeof(MilliSecondConverter))] - public TimeSpan Offset - { - get - { - return Audio.Offset; - } - set - { - Audio.Offset = value; - } - } - } -} diff --git a/RhythmBaseCore/Components/SoundTypes.cs b/RhythmBaseCore/Components/SoundTypes.cs deleted file mode 100644 index 96f5b12..0000000 --- a/RhythmBaseCore/Components/SoundTypes.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace RhythmBase.Components -{ - /// - /// Defines the types of sounds. - /// - public enum SoundTypes - { -#pragma warning disable CS1591 - ClapSoundP1Classic, - ClapSoundP2Classic, - ClapSoundP1Oneshot, - ClapSoundP2Oneshot, - SmallMistake = 20, - BigMistake, - Hand1PopSound, - Hand2PopSound, - HeartExplosion, - HeartExplosion2, - HeartExplosion3, - ClapSoundHoldLongEnd, - ClapSoundHoldLongStart, - ClapSoundHoldShortEnd, - ClapSoundHoldShortStart, - PulseSoundHoldStart, - PulseSoundHoldShortEnd, - PulseSoundHoldEnd, - PulseSoundHoldStartAlt, - PulseSoundHoldShortEndAlt, - PulseSoundHoldEndAlt, - ClapSoundCPUClassic, - ClapSoundCPUOneshot, - ClapSoundHoldLongEndP2, - ClapSoundHoldLongStartP2, - ClapSoundHoldShortEndP2, - ClapSoundHoldShortStartP2, - PulseSoundHoldStartP2, - PulseSoundHoldShortEndP2, - PulseSoundHoldEndP2, - PulseSoundHoldStartAltP2, - PulseSoundHoldShortEndAltP2, - PulseSoundHoldEndAltP2, - FreezeshotSoundCueLow, - FreezeshotSoundCueHigh, - FreezeshotSoundRiser, - FreezeshotSoundCymbal, - BurnshotSoundCueLow, - BurnshotSoundCueHigh, - BurnshotSoundRiser, - BurnshotSoundCymbal, - ClapSoundHold, - PulseSoundHold, - ClapSoundHoldP2, - PulseSoundHoldP2, - FreezeshotSound, - BurnshotSound, - Skipshot -#pragma warning restore CS1591 - } -} - diff --git a/RhythmBaseCore/Components/SpecialArtistTypes.cs b/RhythmBaseCore/Components/SpecialArtistTypes.cs deleted file mode 100644 index 0422c01..0000000 --- a/RhythmBaseCore/Components/SpecialArtistTypes.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace RhythmBase.Components -{ - /// - /// Enum representing special types of artists. - /// - public enum SpecialArtistTypes - { - /// - /// No special artist type. - /// - None, - - /// - /// The author is also the artist. - /// - AuthorIsArtist, - - /// - /// The artist's work is under a public license. - /// - PublicLicense - } -} diff --git a/RhythmBaseCore/Components/TypedEventCollection.cs b/RhythmBaseCore/Components/TypedEventCollection.cs deleted file mode 100644 index ad78920..0000000 --- a/RhythmBaseCore/Components/TypedEventCollection.cs +++ /dev/null @@ -1,33 +0,0 @@ -using RhythmBase.Events; -using System.Collections; -namespace RhythmBase.Components -{ - internal class TypedEventCollection : IEnumerable where TEvent : IBaseEvent - { - public TypedEventCollection() - { - list = []; - _types = []; - } - public void Add(TEvent item) - { - list.Add(item); - _types.Add(item.Type); - } - public bool Remove(TEvent item) - { - _types.Remove(item.Type); - return list.Remove(item); - } - public bool BeforeThan(IBaseEvent item1, IBaseEvent item2) => - list.IndexOf((TEvent)(object)item1) < list.IndexOf((TEvent)(object)item2); - public override string ToString() => - string.Format("{0}Count={1}", (_types.Contains(EventType.SetBeatsPerMinute) || _types.Contains(EventType.PlaySong)) ? "BPM, " : (_types.Contains(EventType.SetCrotchetsPerBar) ? "CPB, " : ""), list.Count); - public IEnumerator GetEnumerator() => - list.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => - list.GetEnumerator(); - private readonly List list; - protected internal HashSet _types; - } -} diff --git a/RhythmBaseCore/Converters/AnchorStyleConverter.cs b/RhythmBaseCore/Converters/AnchorStyleConverter.cs deleted file mode 100644 index c92e861..0000000 --- a/RhythmBaseCore/Converters/AnchorStyleConverter.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.VisualBasic.CompilerServices; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Events; -using System.Text.RegularExpressions; -namespace RhythmBase.Converters -{ - internal partial class AnchorStyleConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, FloatingText.AnchorStyle value, JsonSerializer serializer) - { - var horizontal = value & (FloatingText.AnchorStyle.Left | FloatingText.AnchorStyle.Right); - var vertical = value & (FloatingText.AnchorStyle.Upper | FloatingText.AnchorStyle.Lower); - writer.WriteValue( - (vertical == 0 ? - "Middle" - : vertical.ToString()) - + horizontal.ToString() - ); - } - - public override FloatingText.AnchorStyle ReadJson(JsonReader reader, Type objectType, FloatingText.AnchorStyle existingValue, bool hasExistingValue, JsonSerializer serializer) - { - JToken token = JToken.ReadFrom(reader); - string JString = token.ToObject() ?? throw new Exceptions.ConvertingException("Cannot read the anchor."); - Match match = AnchorStyleRegex().Match(JString); - if (!match.Success) - throw new Exceptions.ConvertingException(token, $"Illegal Anchor: {JString}"); - FloatingText.AnchorStyle result = FloatingText.AnchorStyle.Center; - - result |= match.Groups[1].Value switch - { - "Upper" => FloatingText.AnchorStyle.Upper, - "Lower" => FloatingText.AnchorStyle.Lower, - _ => 0, - }; - - result |= match.Groups[2].Value switch - { - "Left" => FloatingText.AnchorStyle.Left, - "Right" => FloatingText.AnchorStyle.Right, - _ => 0, - }; - - return result; - } - - [GeneratedRegex("(Upper|Middle|Lower)(Left|Center|Right)")] - private static partial Regex AnchorStyleRegex(); - } -} diff --git a/RhythmBaseCore/Converters/AssetConverter.cs b/RhythmBaseCore/Converters/AssetConverter.cs deleted file mode 100644 index 2ead793..0000000 --- a/RhythmBaseCore/Converters/AssetConverter.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace RhythmBase.Converters -{ -} diff --git a/RhythmBaseCore/Converters/AudioConverter.cs b/RhythmBaseCore/Converters/AudioConverter.cs deleted file mode 100644 index 2ead793..0000000 --- a/RhythmBaseCore/Converters/AudioConverter.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace RhythmBase.Converters -{ -} diff --git a/RhythmBaseCore/Converters/BaseDecorationActionConverter.cs b/RhythmBaseCore/Converters/BaseDecorationActionConverter.cs deleted file mode 100644 index cbd5a7d..0000000 --- a/RhythmBaseCore/Converters/BaseDecorationActionConverter.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Settings; -using System.Diagnostics; -namespace RhythmBase.Converters -{ - internal class BaseDecorationActionConverter(RDLevel level, LevelReadOrWriteSettings inputSettings) : BaseEventConverter(level, inputSettings) where TEvent : BaseDecorationAction - { - public override TEvent? GetDeserializedObject(JObject jobj, Type objectType, TEvent? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - TEvent? obj = base.GetDeserializedObject(jobj, objectType, existingValue, hasExistingValue, serializer); - if (obj is null) return obj; - string decoId = jobj["target"]?.ToObject()!; - DecorationEventCollection? Parent = level.ModifiableDecorations.FirstOrDefault(i => i.Id == decoId); - if (Parent == null && obj.Type != EventType.Comment) - switch (settings.UnreadableEventsHandling) - { - case UnreadableEventHandling.Store: - settings.UnreadableEvents.Add((jobj,$"Cannot find the decoration with id {decoId}.")); - return default; - case UnreadableEventHandling.ThrowException: -#if DEBUG - Debugger.Log(2, "cate", ""); - return default; -#else - throw new ConvertingException(string.Format("Cannot find the decoration \"{0}\" at {1}", jobj["target"], obj)); -#endif - } - obj._parent = Parent!; - return obj; - } - } -} diff --git a/RhythmBaseCore/Converters/BaseEventConverter.cs b/RhythmBaseCore/Converters/BaseEventConverter.cs deleted file mode 100644 index 697d28e..0000000 --- a/RhythmBaseCore/Converters/BaseEventConverter.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Exceptions; -using RhythmBase.Settings; -namespace RhythmBase.Converters -{ - internal class BaseEventConverter(RDLevel level, LevelReadOrWriteSettings inputSettings) : JsonConverter where TEvent : IBaseEvent - { - public override bool CanRead => _canread; - public override bool CanWrite => _canwrite; - public override void WriteJson(JsonWriter writer, TEvent? value, JsonSerializer serializer) - { - if (value == null) - throw new ConvertingException(($"Event is null")); - serializer.Formatting = Formatting.None; - writer.WriteRawValue(JsonConvert.SerializeObject(SetSerializedObject(value, serializer))); - serializer.Formatting = Formatting.Indented; - } - public override TEvent? ReadJson(JsonReader reader, Type objectType, TEvent? existingValue, bool hasExistingValue, JsonSerializer serializer) => GetDeserializedObject((JObject)JToken.ReadFrom(reader), objectType, existingValue, hasExistingValue, serializer); - public virtual TEvent? GetDeserializedObject(JObject jobj, Type objectType, TEvent? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - JToken? typeToken = (jobj["type"]) - ?? throw new Exceptions.ConvertingException(jobj, new Exception($"Missing property \"{jobj["type"]}\". path \"{jobj.Path}\"")); - Type SubClassType = Utils.EventTypeUtils.ToType(typeToken.ToObject() - ?? throw new Exceptions.ConvertingException(jobj, new Exception($"Missing property \"{typeToken}\". path \"{jobj.Path}\""))); - if (SubClassType == null) - if (jobj["target"] != null) - SubClassType = typeof(CustomDecorationEvent); - else if (jobj["row"] != null) - SubClassType = typeof(CustomRowEvent); - else - SubClassType = typeof(CustomEvent); - _canread = false; - existingValue = (TEvent?)jobj.ToObject(SubClassType, serializer) - ?? throw new ConvertingException(jobj, new Exception($"Cannot convert this event: \"{jobj}\". path \"{jobj.Path}\"")); - _canread = true; - ((BaseEvent)(object)existingValue)._beat = level.Calculator.BeatOf( - uint.Parse(((string?)jobj["bar"]) - ?? throw new Exception($"Missing property \"{jobj["bar"]}\".path \"{jobj.Path}\"")), - float.Parse((string?)jobj["beat"] ?? 1.ToString())); - return existingValue; - } - public virtual JObject SetSerializedObject(TEvent value, JsonSerializer serializer) - { - _canwrite = false; - JObject JObj = JObject.FromObject(value, serializer); - _canwrite = true; - JObj.Remove("type"); - ValueTuple b = value.Beat.BarBeat; - JToken s = JObj.First ?? throw new ConvertingException($"Internal error: Missing properties. path \"{JObj.Path}\""); - s.AddBeforeSelf(new JProperty("bar", b.Item1)); - if (value is not IBarBeginningEvent) - s.AddBeforeSelf(new JProperty("beat", b.Item2)); - s.AddBeforeSelf(new JProperty("type", value.Type.ToString())); - if (JObj.Value("tag") is string str && string.IsNullOrEmpty(str)) - JObj.Property("tag")?.Remove(); - return JObj; - } - protected readonly RDLevel level = level; - protected readonly LevelReadOrWriteSettings settings = inputSettings; - private bool _canread = true; - private bool _canwrite = true; - } -} diff --git a/RhythmBaseCore/Converters/BaseRowActionConverter.cs b/RhythmBaseCore/Converters/BaseRowActionConverter.cs deleted file mode 100644 index 386b39e..0000000 --- a/RhythmBaseCore/Converters/BaseRowActionConverter.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Exceptions; -using RhythmBase.Settings; -namespace RhythmBase.Converters -{ - internal class BaseRowActionConverter(RDLevel level, LevelReadOrWriteSettings inputSettings) : BaseEventConverter(level, inputSettings) where TEvent : BaseRowAction - { - public override TEvent? GetDeserializedObject(JObject jobj, Type objectType, TEvent? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - TEvent? obj = base.GetDeserializedObject(jobj, objectType, existingValue, hasExistingValue, serializer); - if (obj is null) return obj; - short rowId = jobj["row"]?.ToObject() ?? throw new ConvertingException("Cannot read the property row."); - if (rowId == -1) - { - if (obj.Type != EventType.TintRows) - { - switch (settings.UnreadableEventsHandling) - { - case UnreadableEventHandling.Store: - settings.UnreadableEvents.Add((jobj, $"Cannot find the row with id {rowId}.")); - return default; - case UnreadableEventHandling.ThrowException: - throw new ConvertingException($"Cannot find the row \"{jobj["target"]}\" at {obj}"); - } - } - } - else if (rowId >= level.Rows.Count) - { - switch (settings.UnreadableEventsHandling) - { - case UnreadableEventHandling.Store: - settings.UnreadableEvents.Add((jobj, $"The row id {rowId} out of range.")); - return default; - case UnreadableEventHandling.ThrowException: - throw new ConvertingException($"The row id {rowId} out of range."); - } - } - else - { - RowEventCollection Parent = level.ModifiableRows[(int)rowId]; - obj._parent = Parent; - } - return obj; - } - } -} diff --git a/RhythmBaseCore/Converters/BookmarkConverter.cs b/RhythmBaseCore/Converters/BookmarkConverter.cs deleted file mode 100644 index 1358359..0000000 --- a/RhythmBaseCore/Converters/BookmarkConverter.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Utils; -namespace RhythmBase.Converters -{ - internal class BookmarkConverter(BeatCalculator calculator) : JsonConverter - { - public override void WriteJson(JsonWriter writer, Bookmark? value, JsonSerializer serializer) - { - var beat = value?.Beat.BarBeat ??throw new RhythmBase.Exceptions.ConvertingException("Cannot write the bookmark."); - writer.WriteStartObject(); - writer.WritePropertyName("bar"); - writer.WriteValue(beat.bar); - writer.WritePropertyName("beat"); - writer.WriteValue(beat.beat); - writer.WritePropertyName("color"); - writer.WriteValue((int)value.Color); - writer.WriteEndObject(); - } - - public override Bookmark ReadJson(JsonReader reader, Type objectType, Bookmark? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - JToken jobj = JToken.ReadFrom(reader); - return new Bookmark - { - Beat = calculator.BeatOf(jobj["bar"]!.ToObject(), jobj["beat"]!.ToObject()), - Color = Enum.Parse((string)jobj["color"]!) - }; - } - - private readonly BeatCalculator calculator = calculator; - } -} diff --git a/RhythmBaseCore/Converters/CharacterConverter.cs b/RhythmBaseCore/Converters/CharacterConverter.cs deleted file mode 100644 index 5324a55..0000000 --- a/RhythmBaseCore/Converters/CharacterConverter.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -namespace RhythmBase.Converters -{ - internal class CharacterConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, RDCharacter value, JsonSerializer serializer) - { - writer.WriteValue( - value.IsCustom - ? value.CustomCharacter == null - ? "" - : $"custom:{value.CustomCharacter}" - : value.Character.ToString()); - } - - public override RDCharacter ReadJson(JsonReader reader, Type objectType, RDCharacter existingValue, bool hasExistingValue, JsonSerializer serializer) - { - string value = JToken.ReadFrom(reader).ToObject()!; - RDCharacter ReadJson; - if (value.StartsWith("custom:")) - { - string name = value[7..]; - ReadJson = name; - } - else - { - ReadJson = Enum.Parse(value); - } - return ReadJson; - } - } -} diff --git a/RhythmBaseCore/Converters/ColorConverter.cs b/RhythmBaseCore/Converters/ColorConverter.cs deleted file mode 100644 index 8fee6f1..0000000 --- a/RhythmBaseCore/Converters/ColorConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; - -using System.Text.RegularExpressions; -namespace RhythmBase.Converters -{ - internal class ColorConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, RDColor value, JsonSerializer serializer) => writer.WriteValue(value.ToString("rrggbbaa")); - - public override RDColor ReadJson(JsonReader reader, Type objectType, RDColor existingValue, bool hasExistingValue, JsonSerializer serializer) - { - string JString = JToken.Load(reader).Value() ?? throw new RhythmBase.Exceptions.ConvertingException("Cannot read the color."); - return RDColor.FromRgba(JString); - } - } -} diff --git a/RhythmBaseCore/Converters/ConditionConverter.cs b/RhythmBaseCore/Converters/ConditionConverter.cs deleted file mode 100644 index de8b41b..0000000 --- a/RhythmBaseCore/Converters/ConditionConverter.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using System.Text.RegularExpressions; -namespace RhythmBase.Converters -{ - internal partial class ConditionConverter(List Conditionals) : JsonConverter - { - public override void WriteJson(JsonWriter writer, Condition? value, JsonSerializer serializer) => writer.WriteValue(value!.Serialize()); - public override Condition ReadJson(JsonReader reader, Type objectType, Condition? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - string s = JToken.Load(reader).ToObject()!; - Condition Value = new(); - //MatchCollection ConditionIds = ConditionsRegex().Matches(J); - //foreach (Match match in ConditionIds) - //{ - // BaseConditional Parent = (from i in conditionals - // where i.Id == int.Parse(ConditionIndexRegex().Match(match.Value).Value) - // select i).First(); - // Value.ConditionLists.Add(new ValueTuple(match.Value[0] != '~', Parent)); - //} - //Value.Duration = float.Parse (ConditionDurationRegex().Match(J).Value); - int p = 0; - do - { - bool active = ReadActive(s, ref p); - int index = ReadInt(s, ref p) - 1; - if (index < conditionals.Count) - { - Value.ConditionLists.Add((active, conditionals[index])); - } - } - while (!ReadIsEndList(s, ref p)); - Value.Duration = ReadFloat(s, ref p); - - return Value; - } - private static int ReadInt(string s, ref int p) - { - int r = 0; - while (p < s.Length && char.IsAsciiDigit(s[p])) - { - r *= 10; - r += s[p] - '0'; - p++; - } - return r; - } - private static float ReadFloat(string s, ref int p) - { - float r = ReadInt(s, ref p); - if (p < s.Length && s[p] == '.') - { - p++; - float f = 0.1f; - while (p < s.Length && char.IsAsciiDigit(s[p])) - { - r += f * (s[p] - '0'); - f *= 0.1f; - p++; - } - } - return r; - } - private static bool ReadActive(string s, ref int p) - { - if (p >= s.Length || s[p] == '~') - { - p++; - return false; - } - return true; - } - - private static bool ReadIsEndList(string s, ref int p) => p < s.Length && s[p++] == 'd'; - - private readonly List conditionals = Conditionals; - [GeneratedRegex("~?\\d+(?=[&d])")] - private static partial Regex ConditionsRegex(); - [GeneratedRegex("\\d+")] - private static partial Regex ConditionIndexRegex(); - [GeneratedRegex("(?<=d)[\\d\\.]+")] - private static partial Regex ConditionDurationRegex(); - } -} diff --git a/RhythmBaseCore/Converters/ConditionalConverter.cs b/RhythmBaseCore/Converters/ConditionalConverter.cs deleted file mode 100644 index fcbee48..0000000 --- a/RhythmBaseCore/Converters/ConditionalConverter.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Serialization; -using RhythmBase.Components; -namespace RhythmBase.Converters -{ - internal class ConditionalConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, BaseConditional? value, JsonSerializer serializer) => writer.WriteRawValue(JsonConvert.SerializeObject(value, new JsonSerializerSettings - { - Converters = { new StringEnumConverter() }, - ContractResolver = new CamelCasePropertyNamesContractResolver() - })); - - public override BaseConditional ReadJson(JsonReader reader, Type objectType, BaseConditional? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - JObject J = JObject.Load(reader); - Type? SubClassType = Type.GetType($"{typeof(BaseConditional).Namespace}.Conditions.{J["type"]}Condition"); - return SubClassType == null - ? throw new Exceptions.ConvertingException(J, new Exception($"Unreadable condition: \"{J["type"]}\". path \"{reader.Path}\"")) - : (BaseConditional)J.ToObject(SubClassType)!; - } - } -} diff --git a/RhythmBaseCore/Converters/CustomDecorationEventConverter.cs b/RhythmBaseCore/Converters/CustomDecorationEventConverter.cs deleted file mode 100644 index cb44915..0000000 --- a/RhythmBaseCore/Converters/CustomDecorationEventConverter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Settings; -namespace RhythmBase.Converters -{ - internal class CustomDecorationEventConverter(RDLevel level, LevelReadOrWriteSettings inputSettings) : BaseDecorationActionConverter(level, inputSettings) - { - public override CustomDecorationEvent? GetDeserializedObject(JObject jobj, Type objectType, CustomDecorationEvent? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - CustomDecorationEvent? result = base.GetDeserializedObject(jobj, objectType, existingValue, hasExistingValue, serializer); - if (result != null) - result.Data = jobj; - return result; - } - - public override JObject SetSerializedObject(CustomDecorationEvent value, JsonSerializer serializer) - { - JObject jobj = base.SetSerializedObject(value, serializer); - JToken data = value.Data.DeepClone(); - foreach (KeyValuePair item in jobj) - { - data[item.Key] = item.Value; - } - return (JObject)data; - } - } -} diff --git a/RhythmBaseCore/Converters/CustomEventConverter.cs b/RhythmBaseCore/Converters/CustomEventConverter.cs deleted file mode 100644 index 0fe47f3..0000000 --- a/RhythmBaseCore/Converters/CustomEventConverter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Settings; -namespace RhythmBase.Converters -{ - internal class CustomEventConverter(RDLevel level, LevelReadOrWriteSettings inputSettings) : BaseEventConverter(level, inputSettings) - { - public override CustomEvent? GetDeserializedObject(JObject jobj, Type objectType, CustomEvent? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - CustomEvent? result = base.GetDeserializedObject(jobj, objectType, existingValue, hasExistingValue, serializer); - if(result == null) return null; - result.Data = jobj; - return result; - } - - public override JObject SetSerializedObject(CustomEvent value, JsonSerializer serializer) - { - JObject jobj = base.SetSerializedObject(value, serializer); - JObject data = (JObject)value.Data.DeepClone(); - foreach (KeyValuePair item in data) - { - jobj[item.Key] = item.Value; - } - return jobj; - } - } -} diff --git a/RhythmBaseCore/Converters/CustomRowEventConverter.cs b/RhythmBaseCore/Converters/CustomRowEventConverter.cs deleted file mode 100644 index db95276..0000000 --- a/RhythmBaseCore/Converters/CustomRowEventConverter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Settings; -namespace RhythmBase.Converters -{ - internal class CustomRowEventConverter(RDLevel level, LevelReadOrWriteSettings inputSettings) : BaseRowActionConverter(level, inputSettings) - { - public override CustomRowEvent? GetDeserializedObject(JObject jobj, Type objectType, CustomRowEvent? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - CustomRowEvent? result = base.GetDeserializedObject(jobj, objectType, existingValue, hasExistingValue, serializer); - if (result == null) return null; - result.Data = jobj; - return result; - } - - public override JObject SetSerializedObject(CustomRowEvent value, JsonSerializer serializer) - { - JObject jobj = base.SetSerializedObject(value, serializer); - JToken data = value.Data.DeepClone(); - foreach (KeyValuePair item in jobj) - { - data[item.Key] = item.Value; - } - return (JObject)data; - } - } -} diff --git a/RhythmBaseCore/Converters/DialogueListConverter.cs b/RhythmBaseCore/Converters/DialogueListConverter.cs deleted file mode 100644 index 448f8c6..0000000 --- a/RhythmBaseCore/Converters/DialogueListConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using RhythmBase.Components.RichText; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Newtonsoft.Json; -using System.Threading.Tasks; - -namespace RhythmBase.Converters -{ - internal class DialogueListConverter : JsonConverter - { - public override RDDialogueExchange? ReadJson(JsonReader reader, Type objectType, RDDialogueExchange? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - throw new NotImplementedException(); - } - - public override void WriteJson(JsonWriter writer, RDDialogueExchange? value, JsonSerializer serializer) => writer.WriteRawValue(value?.Serialize()); - } -} diff --git a/RhythmBaseCore/Converters/ExpressionConverter.cs b/RhythmBaseCore/Converters/ExpressionConverter.cs deleted file mode 100644 index 93a160d..0000000 --- a/RhythmBaseCore/Converters/ExpressionConverter.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.VisualBasic.CompilerServices; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Extensions; -namespace RhythmBase.Converters -{ - internal class ExpressionConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, RDExpression value, JsonSerializer serializer) - { - if (value.IsNumeric) - { - writer.WriteRawValue(value.NumericValue.ToString()); - } - else - { - if (value.ExpressionValue.IsNullOrEmpty()) - { - writer.WriteNull(); - } - else - { - writer.WriteValue(string.Format("{{{0}}}", value.ExpressionValue)); - } - } - } - - public override RDExpression ReadJson(JsonReader reader, Type objectType, RDExpression existingValue, bool hasExistingValue, JsonSerializer serializer) - { - string js = JToken.ReadFrom(reader).ToObject() ?? throw new RhythmBase.Exceptions.ConvertingException("Cannot read the expression."); - RDExpression ReadJson = new(js.TrimStart('{').TrimEnd('}')); - return ReadJson; - } - } -} diff --git a/RhythmBaseCore/Converters/LimitedListConverter.cs b/RhythmBaseCore/Converters/LimitedListConverter.cs deleted file mode 100644 index 2ead793..0000000 --- a/RhythmBaseCore/Converters/LimitedListConverter.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace RhythmBase.Converters -{ -} diff --git a/RhythmBaseCore/Converters/MilliSecondConverter.cs b/RhythmBaseCore/Converters/MilliSecondConverter.cs deleted file mode 100644 index 574ef20..0000000 --- a/RhythmBaseCore/Converters/MilliSecondConverter.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RhythmBase.Converters -{ - internal class MilliSecondConverter : TimeConverter - { - public MilliSecondConverter() : base(TimeType.MiliSecond) - { - } - } -} diff --git a/RhythmBaseCore/Converters/PanelColorConverter.cs b/RhythmBaseCore/Converters/PanelColorConverter.cs deleted file mode 100644 index cd55eae..0000000 --- a/RhythmBaseCore/Converters/PanelColorConverter.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Extensions; - -using System.Text.RegularExpressions; -namespace RhythmBase.Converters -{ - internal partial class PanelColorConverter : JsonConverter - { - internal PanelColorConverter(RDColor[] list) - { - parent = list; - } - - public override void WriteJson(JsonWriter writer, PaletteColor? value, JsonSerializer serializer) - { - if (value?.EnablePanel ?? throw new NotImplementedException()) - { - writer.WriteValue(string.Format("pal{0}", value.PaletteIndex)); - } - else - { - string s = value.Value.ToString().Replace("#", ""); - string alpha = s[..2]; - string rgb = s[2..]; - if (value.EnableAlpha) - { - writer.WriteValue(rgb + alpha); - } - else - { - writer.WriteValue(rgb); - } - } - } - - public override PaletteColor ReadJson(JsonReader reader, Type objectType, PaletteColor? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - JToken token = JToken.Load(reader); - string? JString = token.Value(); - if (JString.IsNullOrEmpty()) - { - throw new Exceptions.ConvertingException(token, new Exception($"Unreadable color: \"{token}\". path \"{reader.Path}\"")); - } - Match reg = PaletteColorRegex().Match(JString); - existingValue!.parent = parent; - if (reg.Success) - { - existingValue.PaletteIndex = int.Parse(reg.Groups[1].Value); - } - else - { - string s = JString.Replace("#", ""); - string alpha = ""; - if (s.Length > 6) - { - alpha = s[6..]; - } - string rgb = s[..6]; - if (s.Length > 6) - { - existingValue.Color = new RDColor?(RDColor.FromArgb(alpha + rgb)); - } - else - { - existingValue.Color = new RDColor?(RDColor.FromRgba(rgb)); - } - } - return existingValue; - } - - private readonly RDColor[] parent; - - [GeneratedRegex("pal(\\d+)")] - private static partial Regex PaletteColorRegex(); - } -} diff --git a/RhythmBaseCore/Converters/PatternConverter.cs b/RhythmBaseCore/Converters/PatternConverter.cs deleted file mode 100644 index 1723114..0000000 --- a/RhythmBaseCore/Converters/PatternConverter.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Events; -namespace RhythmBase.Converters -{ - internal class PatternConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, Patterns[]? value, JsonSerializer serializer) => writer.WriteValue(Utils.Utils.GetPatternString(value ?? throw new RhythmBase.Exceptions.ConvertingException($"Pattern cannot be null."))); - - public override Patterns[] ReadJson(JsonReader reader, Type objectType, Patterns[]? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - string? pattern = JToken.ReadFrom(reader).ToObject(); - if (pattern == null || pattern.Length != 6) - throw new Exceptions.ConvertingException($"Invalid pattern: {pattern}"); - existingValue ??= new Patterns[6]; - for (int i = 0; i < 6; i++) - { - existingValue[i] = pattern[i] switch - { - 'x' => Patterns.X, - 'u' => Patterns.Up, - 'd' => Patterns.Down, - 'b' => Patterns.Banana, - 'r' => Patterns.Return, - '-' => Patterns.None, - _ => throw new Exceptions.ConvertingException($"Invalid pattern character: {pattern[i]}") - }; - } - return existingValue; - } - } -} diff --git a/RhythmBaseCore/Converters/RDContractResolver.cs b/RhythmBaseCore/Converters/RDContractResolver.cs deleted file mode 100644 index 560d9bf..0000000 --- a/RhythmBaseCore/Converters/RDContractResolver.cs +++ /dev/null @@ -1,148 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Extensions; -using System.Reflection; -namespace RhythmBase.Converters -{ - internal class RDContractResolver : DefaultContractResolver - { - public static RDContractResolver Instance { get; } = new RDContractResolver(); - public RDContractResolver() : base() - { - NamingStrategy = new CamelCaseNamingStrategy(); - } - protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) - { - JsonProperty p = base.CreateProperty(member, memberSerialization); - Predicate? f = null; - if (p.DeclaringType == typeof(RowEventCollection)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(RowEventCollection.RowToMimic) => i => ((RowEventCollection)i).RowToMimic >= 0, - _ => null - }; - if (p.DeclaringType?.IsAssignableTo(typeof(BaseEvent)) == true) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(BaseEvent.Active) => i => !((BaseEvent)i).Active, - _ => null - }; - if (p.DeclaringType == typeof(MoveRow)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(MoveRow.CustomPosition) => i => ((MoveRow)i).Target == MoveRow.Targets.WholeRow, - _ => null - }; - if (p.DeclaringType == typeof(SetVFXPreset)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(SetVFXPreset.Enable) => i => (i is SetVFXPreset e) && e.Preset is not SetVFXPreset.Presets.DisableAll, - nameof(SetVFXPreset.Threshold) => i => (i is SetVFXPreset e) && e.Enable && e.Preset == SetVFXPreset.Presets.Bloom, - nameof(SetVFXPreset.Intensity) => i => (i is SetVFXPreset e) && e.Enable && durationPresets.Contains(e.Preset) && e.Preset is not (SetVFXPreset.Presets.TileN or SetVFXPreset.Presets.CustomScreenScroll), - nameof(SetVFXPreset.Color) => i => (i is SetVFXPreset e) && e.Enable && (e.Preset is SetVFXPreset.Presets.Bloom or SetVFXPreset.Presets.Tutorial), - nameof(SetVFXPreset.FloatX) or - nameof(SetVFXPreset.FloatY) => i => (i is SetVFXPreset e) && e.Enable && (e.Preset is SetVFXPreset.Presets.TileN or SetVFXPreset.Presets.CustomScreenScroll), - nameof(SetVFXPreset.Ease) => i => (i is SetVFXPreset e) && e.Enable && durationPresets.Contains(e.Preset), - nameof(SetVFXPreset.Duration) => i => (i is SetVFXPreset e) && e.Enable && durationPresets.Contains(e.Preset), - _ => null - }; - if (p.DeclaringType == typeof(TintRows)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(TintRows.Ease) or nameof(TintRows.Duration) => i => (i is TintRows e) && e.Duration != 0f, - _ => null - }; - if (p.DeclaringType == typeof(Tint)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(Tint.Ease) or nameof(Tint.Duration) => i => (i is Tint e) && e.Duration != 0f, - _ => null - }; - if (p.DeclaringType == typeof(Tile)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(Tile.TilingType) => i => (i is Tile e) && e.Speed is not null, - nameof(Tile.Interval) => i => (i is Tile e) && e.TilingType == Tile.TilingTypes.Pulse, - _ => null - }; - if (p.DeclaringType == typeof(SoundSubType)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(SoundSubType.Filename) or - nameof(SoundSubType.Pan) or - nameof(SoundSubType.Offset) => i => (i is SoundSubType e) && e.Used, - nameof(SoundSubType.Volume) => i => (i is SoundSubType e) && e.Used && e.Volume != 100, - nameof(SoundSubType.Pitch) => i => (i is SoundSubType e) && e.Used && e.Pitch != 100, - _ => null - }; - if (p.DeclaringType == typeof(SetGameSound)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(SetGameSound.Filename) or - nameof(SetGameSound.Pan) or - nameof(SetGameSound.Offset) => i => (i is SetGameSound e) && - e.SoundType is not ( - SoundTypes.ClapSoundHold or - SoundTypes.FreezeshotSound or - SoundTypes.BurnshotSound), - nameof(SetGameSound.Volume) => i => (i is SetGameSound e) && - e.SoundType is not ( - SoundTypes.ClapSoundHold or - SoundTypes.FreezeshotSound or - SoundTypes.BurnshotSound) && e.Volume != 100, - nameof(SetGameSound.Pitch) => i => (i is SetGameSound e) && - e.SoundType is not ( - SoundTypes.ClapSoundHold or - SoundTypes.FreezeshotSound or - SoundTypes.BurnshotSound) && e.Pitch != 100, - _ => null - }; - if (p.DeclaringType == typeof(SetCountingSound)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(SetCountingSound.VoiceSource) => i => (i is SetCountingSound e) && e.VoiceSource == SetCountingSound.VoiceSources.Custom, - _ => null - }; - if (p.DeclaringType == typeof(AddOneshotBeat)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(AddOneshotBeat.Skipshot) => i => (i is AddOneshotBeat e) && e.Skipshot, - nameof(AddOneshotBeat.FreezeBurnMode) => i => (i is AddOneshotBeat e) && e.FreezeBurnMode != null, - _ => null - }; - if (p.DeclaringType == typeof(Comment)) - f = p.PropertyName!.ToUpperCamelCase() switch - { - nameof(Comment.Target) => i => (i is Comment e) && e.Tab == Tabs.Decorations, - _ => null - }; - if (f != null) - p.ShouldSerialize = f; - return p; - } - private static readonly SetVFXPreset.Presets[] durationPresets = - [ - SetVFXPreset.Presets.HueShift, - SetVFXPreset.Presets.Brightness, - SetVFXPreset.Presets.Contrast, - SetVFXPreset.Presets.Saturation, - SetVFXPreset.Presets.Rain, - SetVFXPreset.Presets.Bloom, - SetVFXPreset.Presets.TileN, - SetVFXPreset.Presets.CustomScreenScroll, - SetVFXPreset.Presets.JPEG, - SetVFXPreset.Presets.Mosaic, - SetVFXPreset.Presets.ScreenWaves, - SetVFXPreset.Presets.Grain, - SetVFXPreset.Presets.Blizzard, - SetVFXPreset.Presets.Drawing, - SetVFXPreset.Presets.Aberration, - SetVFXPreset.Presets.Blur, - SetVFXPreset.Presets.RadialBlur, - SetVFXPreset.Presets.Dots, - SetVFXPreset.Presets.Tutorial, - ]; - } -} diff --git a/RhythmBaseCore/Converters/RDLevelConverter.cs b/RhythmBaseCore/Converters/RDLevelConverter.cs deleted file mode 100644 index 60fd049..0000000 --- a/RhythmBaseCore/Converters/RDLevelConverter.cs +++ /dev/null @@ -1,196 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Exceptions; -using RhythmBase.Extensions; -using RhythmBase.Settings; -using RhythmBase.Utils; - -namespace RhythmBase.Converters -{ - internal class RDLevelConverter : JsonConverter - { - public RDLevelConverter(string location, LevelReadOrWriteSettings settings) - { - fileLocation = location; - this.settings = settings; - } - public RDLevelConverter(LevelReadOrWriteSettings settings) - { - this.settings = settings; - this.settings.PreloadAssets = false; - } - public override void WriteJson(JsonWriter writer, RDLevel? value, JsonSerializer serializer) - { - JsonSerializerSettings AllInOneSerializer = value!.GetSerializer(settings); - writer.Formatting = settings.Indented ? Formatting.Indented : Formatting.None; - writer.WriteStartObject(); - writer.WritePropertyName("settings"); - writer.WriteRawValue(JsonConvert.SerializeObject(value!.Settings, Formatting.Indented, AllInOneSerializer)); - writer.WritePropertyName("rows"); - writer.WriteStartArray(); - foreach (RowEventCollection item in value.Rows) - writer.WriteRawValue(JsonConvert.SerializeObject(item, Formatting.None, AllInOneSerializer)); - writer.WriteEndArray(); - writer.WritePropertyName("decorations"); - writer.WriteStartArray(); - foreach (DecorationEventCollection item2 in value.Decorations) - writer.WriteRawValue(JsonConvert.SerializeObject(item2, Formatting.None, AllInOneSerializer)); - writer.WriteEndArray(); - writer.WritePropertyName("events"); - writer.WriteStartArray(); - foreach (IBaseEvent item3 in ((settings.InactiveEventsHandling == InactiveEventsHandling.Retain) ? value.Where(i => i.Active) : value.AsEnumerable())) - writer.WriteRawValue(JsonConvert.SerializeObject(item3, Formatting.None, AllInOneSerializer)); - writer.WriteEndArray(); - writer.WritePropertyName("conditionals"); - writer.WriteStartArray(); - foreach (BaseConditional item4 in value.Conditionals) - writer.WriteRawValue(JsonConvert.SerializeObject(item4, Formatting.None, AllInOneSerializer)); - writer.WriteEndArray(); - writer.WritePropertyName("bookmarks"); - writer.WriteStartArray(); - foreach (Bookmark item5 in value.Bookmarks) - writer.WriteRawValue(JsonConvert.SerializeObject(item5, Formatting.None, AllInOneSerializer)); - writer.WriteEndArray(); - writer.WritePropertyName("colorPalette"); - writer.WriteStartArray(); - foreach (RDColor item6 in value.ColorPalette) - writer.WriteRawValue(JsonConvert.SerializeObject(item6, Formatting.None, AllInOneSerializer)); - writer.WriteEndArray(); - writer.WriteEndObject(); - writer.Close(); - } - public override RDLevel ReadJson(JsonReader reader, Type objectType, RDLevel? existingValue, bool hasExistingValue, JsonSerializer serializer) - { - RDLevel outLevel = new() - { - _path = fileLocation - }; - JsonSerializer AllInOneSerializer = JsonSerializer.Create(outLevel.GetSerializer(settings)); - JArray JEvents = []; - JArray JBookmarks = []; - while (reader.Read()) - { - string name = (string)reader.Value!; - reader.Read(); - switch (name) - { - case "settings": - JObject jobj = JObject.Load(reader); - JToken? Mods = jobj["mods"]; - if (Mods?.Type == JTokenType.String) - jobj["mods"] = new JArray(Mods); - outLevel.Settings = jobj.ToObject(AllInOneSerializer)!; - break; - case "rows": - JArray jarr1 = JArray.Load(reader); - outLevel.ModifiableRows.AddRange(jarr1.ToObject>(AllInOneSerializer)!); - foreach (RowEventCollection row in outLevel.ModifiableRows) - { - row.Parent = outLevel; - } - break; - case "decorations": - JArray jarr2 = JArray.Load(reader); - outLevel.ModifiableDecorations.AddRange(jarr2.ToObject>(AllInOneSerializer)!); - foreach (DecorationEventCollection deco in outLevel.ModifiableDecorations) - { - deco.Parent = outLevel; - } - break; - case "conditionals": - JArray jarr3 = JArray.Load(reader); - outLevel.Conditionals.AddRange(jarr3.ToObject>(AllInOneSerializer)!); - foreach (BaseConditional condi in outLevel.Conditionals) - condi.ParentCollection = outLevel.Conditionals; - break; - case "colorPalette": - JArray jarr4 = JArray.Load(reader); - RDColor[] array = jarr4.ToObject(AllInOneSerializer) ?? throw new ConvertingException("Cannot read the color palette."); - if (array.Length == 21) - for (int i = 0; i < array.Length; i++) - outLevel.ColorPalette[i] = array[i]; - break; - case "events": - JEvents = JArray.Load(reader); - break; - case "bookmarks": - JBookmarks = JArray.Load(reader); - break; - default: - break; - } - } - reader.Close(); - RDLevel ReadJson; - try - { - List<(FloatingText @event, int id)> FloatingTextCollection = []; - List<(AdvanceText @event, int id)> AdvanceTextCollection = []; - foreach (JToken item in JEvents) - { - if (!(settings.InactiveEventsHandling > InactiveEventsHandling.Retain && (item["active"]?.Value() ?? false))) - { - Type eventType = Utils.EventTypeUtils.ToType((string)item["type"]!); - if (eventType == null) - { - BaseEvent TempEvent; - if (item["target"] != null) - TempEvent = item.ToObject(AllInOneSerializer)!; - else if (item["row"] != null) - TempEvent = item.ToObject(AllInOneSerializer)!; - else - TempEvent = item.ToObject(AllInOneSerializer)!; - if (settings.InactiveEventsHandling == InactiveEventsHandling.Store && !TempEvent.Active) - settings.InactiveEvents.Add(TempEvent); - else - outLevel.Add(TempEvent); - } - else - { - BaseEvent TempEvent2 = (BaseEvent)item.ToObject(eventType, AllInOneSerializer)!; - if (TempEvent2 != null) - { - if (TempEvent2.Type != EventType.CustomEvent) - { - EventType type = TempEvent2.Type; - switch (type) - { - case EventType.FloatingText: - FloatingTextCollection.Add(((FloatingText)TempEvent2, (int)item["id"]!)); - break; - case EventType.AdvanceText: - AdvanceTextCollection.Add(((AdvanceText)TempEvent2, (int)item["id"]!)); - break; - } - } - if (settings.InactiveEventsHandling == InactiveEventsHandling.Store && !TempEvent2.Active) - settings.InactiveEvents.Add(TempEvent2); - else - outLevel.Add(TempEvent2); - } - } - } - } - foreach (var (@event, id) in AdvanceTextCollection) - { - FloatingText Parent = FloatingTextCollection.First(((FloatingText @event, int id) i) => i.id == id).@event; - Parent.Children.Add(@event); - @event.Parent = Parent; - } - outLevel.Bookmarks.AddRange(JBookmarks.ToObject>(AllInOneSerializer)!); - ReadJson = outLevel; - } - catch (Exception ex) - { - if (outLevel.Settings.Version < 55) - throw new VersionTooLowException(outLevel.Settings.Version, ex); - throw new ConvertingException(ex); - } - return ReadJson; - } - private readonly string fileLocation = ""; - private readonly LevelReadOrWriteSettings settings; - } -} diff --git a/RhythmBaseCore/Converters/RDPointsConverter.cs b/RhythmBaseCore/Converters/RDPointsConverter.cs deleted file mode 100644 index 5542d95..0000000 --- a/RhythmBaseCore/Converters/RDPointsConverter.cs +++ /dev/null @@ -1,118 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Extensions; -using System.Diagnostics.CodeAnalysis; -namespace RhythmBase.Converters -{ - internal class RDPointsConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) - { - writer.WriteStartArray(); - if (value is RDPointNI v1) - { - writer.WriteValue(v1.X); - writer.WriteValue(v1.Y); - } - else if (value is RDPointN v2) - { - writer.WriteValue(v2.X); - writer.WriteValue(v2.Y); - } - else if (value is RDPointI v3) - { - writer.WriteValue(v3.X); - writer.WriteValue(v3.Y); - } - else if (value is RDPoint v4) - { - writer.WriteValue(v4.X); - writer.WriteValue(v4.Y); - } - else if (value is RDPointE v5) - { - if (v5.X != null) - writer.WriteValue(v5.X.Value.IsNumeric ? v5.X.Value.NumericValue : v5.X.Value.ExpressionValue); - else - writer.WriteNull(); - if (v5.Y != null) - writer.WriteValue(v5.Y.Value.IsNumeric ? v5.Y.Value.NumericValue : v5.Y.Value.ExpressionValue); - else - writer.WriteNull(); - } - else if (value is RDSizeNI v6) - { - writer.WriteValue(v6.Width); - writer.WriteValue(v6.Height); - } - else if (value is RDSizeN v7) - { - writer.WriteValue(v7.Width); - writer.WriteValue(v7.Height); - } - else if (value is RDSizeI v8) - { - writer.WriteValue(v8.Width); - writer.WriteValue(v8.Height); - } - else if (value is RDSize v9) - { - writer.WriteValue(v9.Width); - writer.WriteValue(v9.Height); - } - else if (value is RDSizeE v10) - { - RDSizeE temp2 = (value != null) ? v10 : default; - if (temp2.Width != null) - writer.WriteValue(temp2.Width.Value.IsNumeric ? temp2.Width.Value.NumericValue : temp2.Width.Value.ExpressionValue); - else - writer.WriteNull(); - if (temp2.Height != null) - writer.WriteValue(temp2.Height.Value.IsNumeric ? temp2.Height.Value.NumericValue : temp2.Height.Value.ExpressionValue); - else - writer.WriteNull(); - } - else - throw new NotImplementedException(); - writer.WriteEndArray(); - } - public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) - { - JToken ja = JToken.ReadFrom(reader); - object ReadJson; - if (objectType == typeof(RDPointNI) || objectType == typeof(RDPointNI?)) - ReadJson = new RDPointNI(ja[0]!.ToObject(), ja[1]!.ToObject()); - else if (objectType == typeof(RDPointN) || objectType == typeof(RDPointN?)) - ReadJson = new RDPointN(ja[0]!.ToObject(), ja[1]!.ToObject()); - else if (objectType == typeof(RDPointI) || objectType == typeof(RDPointI?)) - ReadJson = new RDPointI(ja[0]?.ToObject(), ja[1]?.ToObject()); - else if (objectType == typeof(RDPoint) || objectType == typeof(RDPoint?)) - ReadJson = new RDPoint(ja[0]?.ToObject(), ja[1]?.ToObject()); - else if (objectType == typeof(RDPointE) || objectType == typeof(RDPointE?)) - ReadJson = new RDPointE(new RDExpression?(ja[0]!.ToString().IsNullOrEmpty() - ? default - : ja[0]!.ToObject()), new RDExpression?(ja[1]!.ToString().IsNullOrEmpty() - ? default - : ja[1]!.ToObject())); - else if (objectType == typeof(RDSizeNI) || objectType == typeof(RDSizeNI?)) - ReadJson = new RDSizeNI(ja[0]!.ToObject(), ja[1]!.ToObject()); - else if (objectType == typeof(RDSizeN) || objectType == typeof(RDSizeN?)) - ReadJson = new RDSizeN(ja[0]!.ToObject(), ja[1]!.ToObject()); - else if (objectType == typeof(RDSizeI) || objectType == typeof(RDSizeI?)) - ReadJson = new RDSizeI(ja[0]?.ToObject(), ja[1]?.ToObject()); - else if (objectType == typeof(RDSize) || objectType == typeof(RDSize?)) - ReadJson = new RDSize(ja[0]?.ToObject(), ja[1]?.ToObject()); - else if (objectType == typeof(RDSizeE) || objectType == typeof(RDSizeE?)) - ReadJson = new RDSizeE(new RDExpression?(ja[0]!.ToString().IsNullOrEmpty() - ? default - : ja[0]!.ToObject()), new RDExpression?(ja[1]!.ToString().IsNullOrEmpty() - ? default - : ja[1]!.ToObject())); - else - throw new NotImplementedException(); - return ReadJson; - } - public override bool CanConvert(Type objectType) => throw new NotImplementedException(); - } -} diff --git a/RhythmBaseCore/Converters/RoomConverter.cs b/RhythmBaseCore/Converters/RoomConverter.cs deleted file mode 100644 index fbf805e..0000000 --- a/RhythmBaseCore/Converters/RoomConverter.cs +++ /dev/null @@ -1,74 +0,0 @@ -using Microsoft.VisualBasic.CompilerServices; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -namespace RhythmBase.Converters -{ - internal class RoomConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) - { - Type type = value!.GetType(); - if (type == typeof(RDRoom)) - { - writer.WriteStartArray(); - foreach (int item in (((RDRoom?)value) ?? default).Rooms) - writer.WriteValue(item); - writer.WriteEndArray(); - } - else if (type == typeof(RDSingleRoom)) - { - writer.WriteStartArray(); - writer.WriteValue((((RDSingleRoom?)value) ?? default).Value); - writer.WriteEndArray(); - } - else - throw new NotImplementedException(); - } - public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) - { - JToken token = JArray.Load(reader); - byte[]? J = token.ToObject(); - if (J == null) - throw new Exceptions.ConvertingException(token, new Exception($"Unreadable room: \"{J}\". path \"{reader.Path}\"")); - - bool flag = objectType == typeof(RDRoom); - object ReadJson; - if (flag) - { - bool enableTop; - if (existingValue != null) - { - object obj = existingValue; - enableTop = ((obj != null) ? ((RDRoom)obj) : default).EnableTop; - } - else - { - enableTop = true; - } - existingValue = new RDRoom(enableTop); - foreach (byte item in J) - { - NewLateBinding.LateIndexSet(existingValue, - [ - item, - true - ], null); - } - ReadJson = existingValue; - } - else - { - flag = objectType == typeof(RDSingleRoom); - if (!flag) - { - throw new NotImplementedException(); - } - ReadJson = new RDSingleRoom(J.Single()); - } - return ReadJson; - } - - public override bool CanConvert(Type objectType) => objectType == typeof(RDRoom) || objectType == typeof(RDSingleRoom); - } -} diff --git a/RhythmBaseCore/Converters/SecondConverter.cs b/RhythmBaseCore/Converters/SecondConverter.cs deleted file mode 100644 index d0e2681..0000000 --- a/RhythmBaseCore/Converters/SecondConverter.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace RhythmBase.Converters -{ - internal class SecondConverter : TimeConverter - { - public SecondConverter() : base(TimeType.Second) - { - } - } -} diff --git a/RhythmBaseCore/Converters/TabsConverter.cs b/RhythmBaseCore/Converters/TabsConverter.cs deleted file mode 100644 index 607be9e..0000000 --- a/RhythmBaseCore/Converters/TabsConverter.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Events; -namespace RhythmBase.Converters -{ - internal class TabsConverter : JsonConverter - { - public override void WriteJson(JsonWriter writer, Tabs value, JsonSerializer serializer) => writer.WriteValue(TabNames[(int)value]); - - public override Tabs ReadJson(JsonReader reader, Type objectType, Tabs existingValue, bool hasExistingValue, JsonSerializer serializer) - { - string value = JToken.Load(reader).ToObject()??throw new RhythmBase.Exceptions.ConvertingException("Cannot read the tab."); - int t = TabNames.ToList().IndexOf(value); - bool flag = t >= 0; - Tabs ReadJson; - if (flag) - { - ReadJson = (Tabs)t; - } - else - { - ReadJson = Tabs.Unknown; - } - return ReadJson; - } - - private static readonly string[] TabNames = - [ - "Song", - "Rows", - "Actions", - "Sprites", - "Rooms" - ]; - } -} diff --git a/RhythmBaseCore/Converters/TagActionConverter.cs b/RhythmBaseCore/Converters/TagActionConverter.cs deleted file mode 100644 index 85e02f8..0000000 --- a/RhythmBaseCore/Converters/TagActionConverter.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Settings; -namespace RhythmBase.Converters -{ - internal class TagActionConverter(RDLevel level, LevelReadOrWriteSettings inputSettings) : BaseEventConverter(level, inputSettings) - { - public override JObject SetSerializedObject(TagAction value, JsonSerializer serializer) - { - JObject jobj = base.SetSerializedObject(value, serializer); - if (value.Tag == null) - { - jobj.Remove("tag"); - } - else - { - jobj["tag"] = value.Tag; - } - jobj["Tag"] = value.ActionTag; - return jobj; - } - } -} diff --git a/RhythmBaseCore/Converters/TimeConverter.cs b/RhythmBaseCore/Converters/TimeConverter.cs deleted file mode 100644 index 7a24fd1..0000000 --- a/RhythmBaseCore/Converters/TimeConverter.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -namespace RhythmBase.Converters -{ - internal abstract class TimeConverter : JsonConverter - { - public TimeConverter() - { - _timeType = TimeType.MiliSecond; - } - - public TimeConverter(TimeType type) - { - _timeType = type; - } - - public override void WriteJson(JsonWriter writer, TimeSpan value, JsonSerializer serializer) - { - switch (_timeType) - { - case TimeType.Hour: - writer.WriteValue(value.TotalHours); - break; - case TimeType.Minute: - writer.WriteValue(value.TotalMinutes); - break; - case TimeType.Second: - writer.WriteValue(value.TotalSeconds); - break; - case TimeType.MiliSecond: - writer.WriteValue((int)value.TotalMilliseconds); - break; - case TimeType.Microsecond: - writer.WriteValue((int)value.TotalMicroseconds); - break; - default: - break; - } - } - - public override TimeSpan ReadJson(JsonReader reader, Type objectType, TimeSpan existingValue, bool hasExistingValue, JsonSerializer serializer) - { - float value = JToken.ReadFrom(reader).ToObject(); - return _timeType switch - { - TimeType.Hour => TimeSpan.FromHours((double)value), - TimeType.Minute => TimeSpan.FromMinutes((double)value), - TimeType.Second => TimeSpan.FromSeconds((double)value), - TimeType.MiliSecond => TimeSpan.FromMilliseconds((int)value), - TimeType.Microsecond => TimeSpan.FromMicroseconds((int)value), - _ => throw new NotImplementedException() - }; - } - - private readonly TimeType _timeType; - - public enum TimeType - { - Hour, - Minute, - Second, - MiliSecond, - Microsecond - } - } -} diff --git a/RhythmBaseCore/Events/AddClassicBeat.cs b/RhythmBaseCore/Events/AddClassicBeat.cs deleted file mode 100644 index a1b6378..0000000 --- a/RhythmBaseCore/Events/AddClassicBeat.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Extensions; -using System.Diagnostics; -namespace RhythmBase.Events -{ - /// - /// Represents an event to add a classic beat. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public class AddClassicBeat : BaseBeat - { - /// - /// Initializes a new instance of the class. - /// - public AddClassicBeat() { } - - /// - /// Gets or sets the tick value. - /// - public float Tick { get; set; } = 1f; - - /// - /// Gets or sets the swing value. - /// - public float Swing { get; set; } - - /// - /// Gets or sets the hold value. - /// - public float Hold { get; set; } - - /// - /// Gets or sets the classic beat pattern. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public ClassicBeatPatterns? SetXs { get; set; } - /// - public override EventType Type { get; } = EventType.AddClassicBeat; - /// - public override string ToString() => base.ToString() + - $" {Utils.Utils.GetPatternString(this.RowXs())} {((Swing is 0.5f or 0f) ? "" : " Swing")}"; - - /// - /// Defines the classic beat patterns. - /// - public enum ClassicBeatPatterns - { - /// - /// No change in the beat pattern. - /// - NoChange, - - /// - /// Three beat pattern. - /// - ThreeBeat, - - /// - /// Four beat pattern. - /// - FourBeat - } - private string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Events/AddFreeTimeBeat.cs b/RhythmBaseCore/Events/AddFreeTimeBeat.cs deleted file mode 100644 index b364070..0000000 --- a/RhythmBaseCore/Events/AddFreeTimeBeat.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Diagnostics; - -namespace RhythmBase.Events -{ - /// - /// Represents an event to add a free time beat. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public class AddFreeTimeBeat : BaseBeat - { - /// - /// Initializes a new instance of the class. - /// - public AddFreeTimeBeat() { } - - /// - /// Gets or sets the hold duration of the beat. - /// - public float Hold { get; set; } - - /// - /// Gets or sets the pulse value of the beat. - /// - public byte Pulse { get; set; } - /// - public override EventType Type { get; } = EventType.AddFreeTimeBeat; - /// - public override string ToString() => base.ToString() + $" {(Pulse + 1)}"; - private string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Events/AddOneshotBeat.cs b/RhythmBaseCore/Events/AddOneshotBeat.cs deleted file mode 100644 index c20084b..0000000 --- a/RhythmBaseCore/Events/AddOneshotBeat.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System.Diagnostics; - -namespace RhythmBase.Events -{ - /// - /// Represents an event to add a one-shot beat. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public class AddOneshotBeat : BaseBeat - { - /// - /// Initializes a new instance of the class. - /// - public AddOneshotBeat() { } - - /// - /// Gets or sets the type of pulse. - /// - public Pulse PulseType { get; set; } - - /// - /// Gets or sets the number of subdivisions. - /// - public byte Subdivisions { get; set; } = 1; - - /// - /// Gets or sets a value indicating whether the subdivision sound is enabled. - /// - public bool SubdivSound { get; set; } - - /// - /// Gets or sets the tick value. - /// - public float Tick { get; set; } - - /// - /// Gets or sets the number of loops. - /// - public uint Loops { get; set; } - - /// - /// Gets or sets the interval value. - /// - public float Interval { get; set; } - - /// - /// Gets or sets a value indicating whether to skip the shot. - /// - public bool Skipshot { get; set; } - - /// - /// Gets or sets the freeze burn mode. - /// - public FreezeBurn? FreezeBurnMode { get; set; } - - /// - /// Gets or sets the delay value. - /// - public float Delay - { - get => _delay; - set => _delay = FreezeBurnMode != FreezeBurn.Freezeshot - ? 0f : value <= 0f - ? 0.5f : value; - } - /// - public override EventType Type { get; } = EventType.AddOneshotBeat; - - /// - public override string ToString() => base.ToString() + $" {FreezeBurnMode} {PulseType}"; - - private float _delay = 0f; - - /// - /// Represents the type of pulse. - /// - /// - /// The pulse type determines the shape of the beat's waveform. - /// - public enum Pulse - { - /// - /// A wave pulse. - /// - Wave, - - /// - /// A square pulse. - /// - Square, - - /// - /// A triangle pulse. - /// - Triangle, - - /// - /// A heart-shaped pulse. - /// - Heart - } - - /// - /// Represents the freeze burn mode. - /// - /// - /// The freeze burn mode determines the effect applied to the beat. - /// - public enum FreezeBurn - { - /// - /// A wave freeze burn mode. - /// - Wave, - - /// - /// A freeze shot mode. - /// - Freezeshot, - - /// - /// A burn shot mode. - /// - Burnshot - } - private string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Events/AdvanceText.cs b/RhythmBaseCore/Events/AdvanceText.cs deleted file mode 100644 index bdae079..0000000 --- a/RhythmBaseCore/Events/AdvanceText.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using System.Diagnostics; -namespace RhythmBase.Events -{ - /// - /// Represents an event that advances text in a room. - /// - [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] - public class AdvanceText : BaseEvent, IRoomEvent,IDurationEvent - { - /// - /// Initializes a new instance of the class. - /// - public AdvanceText() { } - /// - public override EventType Type { get; } = EventType.AdvanceText; - /// - [JsonIgnore] - public RDRoom Rooms - { - get => Parent.Rooms; - set => Parent.Rooms = value; - } - /// - public override Tabs Tab { get; } = Tabs.Actions; - - /// - /// Gets or sets the parent floating text associated with the event. - /// - [JsonIgnore] - public FloatingText Parent { get; internal set; } = new(); - - /// - /// Gets or sets the fade-out duration for the text. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public float FadeOutDuration { get; set; } - float IDurationEvent.Duration => FadeOutDuration; - /// - /// Gets the ID of the parent floating text. - /// - [JsonProperty] - private int Id => Parent.Id; - /// - public override string ToString() => base.ToString() + $" Index:{Parent.Children.IndexOf(this)}"; - private string GetDebuggerDisplay() => ToString(); - } -} diff --git a/RhythmBaseCore/Events/BaseBeat.cs b/RhythmBaseCore/Events/BaseBeat.cs deleted file mode 100644 index 6750fa4..0000000 --- a/RhythmBaseCore/Events/BaseBeat.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an abstract base class for beat actions in a rhythm-based application. - /// - public abstract class BaseBeat : BaseRowAction - { - /// - /// Initializes a new instance of the class and sets the Tab property to Rows. - /// - protected BaseBeat() { } - - /// - /// Gets the tab associated with the beat action, which is always set to Rows. - /// - public override Tabs Tab { get; } = Tabs.Rows; - } -} diff --git a/RhythmBaseCore/Events/BaseBeatsPerMinute.cs b/RhythmBaseCore/Events/BaseBeatsPerMinute.cs deleted file mode 100644 index 7249544..0000000 --- a/RhythmBaseCore/Events/BaseBeatsPerMinute.cs +++ /dev/null @@ -1,68 +0,0 @@ -using RhythmBase.Components; -using RhythmBase.Extensions; -namespace RhythmBase.Events -{ - /// - /// Represents the base class for events that have a beats per minute (BPM) value. - /// - public abstract class BaseBeatsPerMinute : BaseEvent - { - /// - /// Initializes a new instance of the class with a default BPM of 100. - /// - protected BaseBeatsPerMinute() - { - _bpm = Utils.Utils.DefaultBPM; - } - - /// - /// Gets or sets the beat associated with this event. - /// - public override RDBeat Beat - { - get - { - return base.Beat; - } - set - { - base.Beat = value; - ResetTimeLine(); - } - } - - /// - /// Gets or sets the beats per minute (BPM) for this event. - /// - public virtual float BeatsPerMinute - { - get - { - return _bpm; - } - set - { - _bpm = value; - ResetTimeLine(); - } - } - - /// - /// Resets the timeline for all events in the same level that occur after this event. - /// - private void ResetTimeLine() - { - if (Beat.BaseLevel != null) - { - foreach (IBaseEvent item in from i in Beat.BaseLevel - where i.Beat > Beat - select i) - { - item.Beat.ResetBPM(); - } - } - } - - private float _bpm; - } -} diff --git a/RhythmBaseCore/Events/BaseDecorationAction.cs b/RhythmBaseCore/Events/BaseDecorationAction.cs deleted file mode 100644 index c6fe660..0000000 --- a/RhythmBaseCore/Events/BaseDecorationAction.cs +++ /dev/null @@ -1,78 +0,0 @@ -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; - } -} diff --git a/RhythmBaseCore/Events/BaseEvent.cs b/RhythmBaseCore/Events/BaseEvent.cs deleted file mode 100644 index 33fae36..0000000 --- a/RhythmBaseCore/Events/BaseEvent.cs +++ /dev/null @@ -1,119 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Utils; -namespace RhythmBase.Events -{ - /// - /// The base class of the event. - /// All event types inherit directly or indirectly from this. - /// - public abstract class BaseEvent : IBaseEvent - { - /// - /// The base class of the event. - /// All event types inherit directly or indirectly from this. - /// - protected BaseEvent() - { - _beat = new RDBeat(1f); - Active = true; - } - /// - /// Event type. - /// - [JsonIgnore] - public abstract EventType Type { get; } - /// - /// Column to which the event belongs. - /// - [JsonIgnore] - public abstract Tabs Tab { get; } - /// - /// The beat of the event. - /// - [JsonIgnore] - public virtual RDBeat Beat - { - get => _beat; - set - { - if (_beat.BaseLevel == null) - _beat = value.BaseLevel == null ? value : value.WithoutBinding(); - else - { - value = new RDBeat(_beat.BaseLevel.Calculator, value); - _beat.BaseLevel.Remove(this); - value.BaseLevel?.Add(this); - _beat = value; - } - } - } - /// - /// The number of rows this event is on. - /// - public virtual int Y { get; set; } - /// - /// Event tag. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public string Tag { get; set; } = ""; - /// - /// Event conditions. - /// - [JsonProperty("if", DefaultValueHandling = DefaultValueHandling.Ignore)] - public Condition? Condition { get; set; } - /// - /// Indicates whether this event is activated. - /// - public bool Active { get; set; } - /// - /// Clone this event and its basic properties. - /// If it is of the same type as the source event, then it will be cloned. - /// - /// Type that will be generated. - /// A new instance with the same base properties as the source instance. - public virtual TEvent Clone() where TEvent : IBaseEvent, new() - { - if (EventTypeUtils.ToEnum() == Type) - { - TEvent e = (TEvent)MemberwiseClone(); - ((BaseEvent)(object)e)._beat = Beat.WithoutBinding(); - return e; - } - TEvent temp = new() - { - Beat = Beat.WithoutBinding(), - Y = Y, - Tag = Tag, - Condition = Condition, - Active = Active - }; - if (Condition != null) - temp.Condition = new() - { - ConditionLists = [.. Condition.ConditionLists] - }; - return temp; - } - internal virtual TEvent Clone(RDLevel level) where TEvent : IBaseEvent, new() - { - TEvent temp = new() - { - Beat = Beat.WithoutBinding(), - Y = Y, - Tag = Tag, - Condition = Condition, - Active = Active - }; - if (Condition != null) - temp.Condition = new() - { - ConditionLists = [.. Condition.ConditionLists] - }; - return temp; - } - /// - public override string ToString() => $"{Beat} {Type}"; - internal RDBeat _beat; - } -} diff --git a/RhythmBaseCore/Events/BaseRowAction.cs b/RhythmBaseCore/Events/BaseRowAction.cs deleted file mode 100644 index 17d186a..0000000 --- a/RhythmBaseCore/Events/BaseRowAction.cs +++ /dev/null @@ -1,92 +0,0 @@ -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; - } -} diff --git a/RhythmBaseCore/Events/BaseRowAnimation.cs b/RhythmBaseCore/Events/BaseRowAnimation.cs deleted file mode 100644 index d498d1a..0000000 --- a/RhythmBaseCore/Events/BaseRowAnimation.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents the base class for row animations. - /// - public abstract class BaseRowAnimation : BaseRowAction, IBaseEvent - { - } -} diff --git a/RhythmBaseCore/Events/BassDrop.cs b/RhythmBaseCore/Events/BassDrop.cs deleted file mode 100644 index b43877d..0000000 --- a/RhythmBaseCore/Events/BassDrop.cs +++ /dev/null @@ -1,52 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents a BassDrop event in the rhythm base. - /// - public class BassDrop : BaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public BassDrop() - { - Rooms = new RDRoom(true, new byte[1]); - Type = EventType.BassDrop; - Tab = Tabs.Actions; - } - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the strength of the BassDrop event. - /// - public StrengthType Strength { get; set; } - /// - public override EventType Type { get; } - /// - public override Tabs Tab { get; } - /// - public override string ToString() => base.ToString() + $" {Strength}"; - /// - /// Defines the strength levels for the BassDrop event. - /// - public enum StrengthType - { - /// - /// Low strength. - /// - Low, - - /// - /// Medium strength. - /// - Medium, - - /// - /// High strength. - /// - High - } - } -} diff --git a/RhythmBaseCore/Events/Borders.cs b/RhythmBaseCore/Events/Borders.cs deleted file mode 100644 index 6c28382..0000000 --- a/RhythmBaseCore/Events/Borders.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Specifies the types of borders that can be applied. - /// - public enum Borders - { - /// - /// No border. - /// - None, - - /// - /// An outline border. - /// - Outline, - - /// - /// A glowing border. - /// - Glow - } -} diff --git a/RhythmBaseCore/Events/CallCustomMethod.cs b/RhythmBaseCore/Events/CallCustomMethod.cs deleted file mode 100644 index 3606719..0000000 --- a/RhythmBaseCore/Events/CallCustomMethod.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event that calls a custom method. - /// - public partial class CallCustomMethod : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public CallCustomMethod() { } - - /// - /// Gets or sets the name of the method to be called. - /// - public string MethodName { get; set; } = ""; - - /// - /// Gets or sets the execution time of the method. - /// - public ExecutionTimeOptions ExecutionTime { get; set; } - - /// - /// Gets or sets the sort offset for the event. - /// - public int SortOffset { get; set; } - /// - public override EventType Type { get; } = EventType.CallCustomMethod; - /// - [JsonIgnore] - public RDRoom Rooms { get; set; } = RDRoom.Default(); - /// - public override Tabs Tab { get; } = Tabs.Actions; - /// - public override string ToString() => base.ToString() + $" {MethodName}"; - - /// - /// Specifies the execution time options for the method. - /// - public enum ExecutionTimeOptions - { - /// - /// Execute the method on prebar. - /// - OnPrebar, - - /// - /// Execute the method on bar. - /// - OnBar - } - } -} diff --git a/RhythmBaseCore/Events/ChangePlayersRows.cs b/RhythmBaseCore/Events/ChangePlayersRows.cs deleted file mode 100644 index be5f76d..0000000 --- a/RhythmBaseCore/Events/ChangePlayersRows.cs +++ /dev/null @@ -1,86 +0,0 @@ -namespace RhythmBase.Events -{ - /// - public class ChangePlayersRows : BaseEvent - { - /// - public ChangePlayersRows() - { - Players = new List(16); - CpuMarkers = new List(16); - Type = EventType.ChangePlayersRows; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the list of players. - /// - public List Players { get; set; } - - /// - /// Gets or sets the player mode. - /// - public PlayerModes PlayerMode { get; set; } - - /// - /// Gets or sets the list of CPU markers. - /// - public List CpuMarkers { get; set; } - - /// - public override EventType Type { get; } - - /// - public override Tabs Tab { get; } - - /// - /// Represents the types of CPUs. - /// - public enum CpuType - { - /// - /// No CPU. - /// - None, - /// - /// Otto CPU type. - /// - Otto, - /// - /// Ian CPU type. - /// - Ian, - /// - /// Paige CPU type. - /// - Paige, - /// - /// Edega CPU type. - /// - Edega, - /// - /// Blank CPU type. - /// - BlankCPU, - /// - /// Samurai CPU type. - /// - Samurai - } - - /// - /// Represents the modes of players. - /// - public enum PlayerModes - { - /// - /// Single player mode. - /// - OnePlayer, - /// - /// Two players mode. - /// - TwoPlayers - } - } -} diff --git a/RhythmBaseCore/Events/Comment.cs b/RhythmBaseCore/Events/Comment.cs deleted file mode 100644 index 5598517..0000000 --- a/RhythmBaseCore/Events/Comment.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; - -namespace RhythmBase.Events -{ - /// - public partial class Comment : BaseDecorationAction - { - /// - /// Initializes a new instance of the class. - /// - public Comment() - { - Text = ""; - Color = new PaletteColor(false) - { - Color = RDColor.FromRgba(242, 230, 68) - }; - Type = EventType.Comment; - } - - /// - /// Gets or sets the custom tab. - /// - [JsonProperty("tab")] - public Tabs CustomTab { get; set; } - - /// - [JsonIgnore] - public override Tabs Tab => CustomTab; - - /// - /// Gets or sets a value indicating whether this is shown. - /// - public bool Show { get; set; } - - /// - /// Gets or sets the text of the comment. - /// - public string Text { get; set; } - - /// - public override string Target => base.Target; - - /// - /// Gets or sets the color of the comment. - /// - public PaletteColor Color { get; set; } - - /// - public override EventType Type { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", Text); - } -} diff --git a/RhythmBaseCore/Events/ContentModes.cs b/RhythmBaseCore/Events/ContentModes.cs deleted file mode 100644 index fc67661..0000000 --- a/RhythmBaseCore/Events/ContentModes.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Specifies the different modes for content display. - /// - public enum ContentModes - { - /// - /// Scales the content to fill the available space. - /// - ScaleToFill, - - /// - /// Scales the content to fit within the available space while maintaining the aspect ratio. - /// - AspectFit, - - /// - /// Scales the content to fill the available space while maintaining the aspect ratio. - /// - AspectFill, - - /// - /// Centers the content within the available space without scaling. - /// - Center, - - /// - /// Tiles the content to fill the available space. - /// - Tiled - } -} diff --git a/RhythmBaseCore/Events/CustomDecorationEvent.cs b/RhythmBaseCore/Events/CustomDecorationEvent.cs deleted file mode 100644 index 1a2419a..0000000 --- a/RhythmBaseCore/Events/CustomDecorationEvent.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Exceptions; -using RhythmBase.Extensions; -using RhythmBase.Settings; -namespace RhythmBase.Events -{ - /// - public class CustomDecorationEvent : BaseDecorationAction - { - /// - public override EventType Type { get; } - - /// - /// Gets the actual type of the decoration event. - /// - [JsonIgnore] - public string ActureType - { - get - { - return Data["Type".ToLowerCamelCase()]?.ToString() ?? ""; - } - } - - /// - public override Tabs Tab { get; } - - /// - /// Initializes a new instance of the class. - /// - public CustomDecorationEvent() - { - Data = []; - Type = EventType.CustomDecorationEvent; - Tab = Tabs.Decorations; - } - - /// - /// Initializes a new instance of the class with the specified data. - /// - /// The JSON data for the event. - public CustomDecorationEvent(JObject data) - { - Data = data ?? []; - Type = EventType.CustomDecorationEvent; - Tab = Tabs.Decorations; - Beat = new RDBeat(Data["bar"]?.ToObject() ?? 1, (Data["beat"]?.ToObject() ?? 1f)); - Tag = Data["tag"]?.ToObject() ?? ""; - Condition = Data["condition"] != null - ? Data["condition"] is null ? null : Condition.Load(Data["condition"]!.ToObject() ?? "") - : null; - Active = Data["active"]?.ToObject() ?? true; - } - - /// - public override string ToString() => $"{Beat} *{ActureType}"; - - /// - public virtual bool TryConvert(ref BaseEvent value, ref EventType? type) => TryConvert(ref value, ref type, new LevelReadOrWriteSettings()); - - /// - public virtual bool TryConvert(ref BaseEvent value, ref EventType? type, LevelReadOrWriteSettings settings) => TryConvert(ref value, ref type, settings); - - /// - /// Explicit conversion from to . - /// - /// The instance. - /// Thrown when the row field is missing from the data. - public static explicit operator CustomDecorationEvent(CustomEvent e) - { - return e.Data["row"] != null - ? new CustomDecorationEvent(e.Data) - : throw new RhythmBaseException("The row field is missing from the field contained in this object."); - } - - /// - /// Gets or sets the JSON data for the event. - /// - public JObject Data; - } -} diff --git a/RhythmBaseCore/Events/CustomEvent.cs b/RhythmBaseCore/Events/CustomEvent.cs deleted file mode 100644 index 07ae450..0000000 --- a/RhythmBaseCore/Events/CustomEvent.cs +++ /dev/null @@ -1,112 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Extensions; -using RhythmBase.Settings; -using RhythmBase.Utils; -namespace RhythmBase.Events -{ - /// - /// Represents a custom event in the rhythm base system. - /// - public class CustomEvent : BaseEvent - { - /// - [JsonIgnore] - public override EventType Type => EventType.CustomEvent; - - /// - /// Gets or sets the actual type of the custom event. - /// - [JsonIgnore] - public string ActureType - { - get => Data["Type".ToLowerCamelCase()]?.ToObject() ?? ""; - init => Data["Type".ToLowerCamelCase()] = value; - } - - /// - public override Tabs Tab { get; } - - /// - public override int Y - { - get => (int)(Data["Y".ToLowerCamelCase()] ?? 0); - set => Data["Y".ToLowerCamelCase()] = value; - } - - /// - /// Initializes a new instance of the class. - /// - public CustomEvent() - { - Data = []; - Tab = Tabs.Unknown; - } - - /// - /// Initializes a new instance of the class with the specified data. - /// - /// The data for the custom event. - public CustomEvent(JObject data) - { - Data = data ?? []; - Tab = Tabs.Unknown; - Beat = new RDBeat(Data["bar"]?.ToObject() ?? 1, Data["beat"]?.ToObject() ?? 1f); - Tag = Data["tag"]?.ToObject() ?? ""; - Condition = Data["condition"] == null - ? null - : Condition.Load(Data["condition"]?.ToObject() ?? ""); - Active = Data["active"]?.ToObject() ?? true; - } - - /// - public override string ToString() => $"{Beat} *{ActureType}"; - - /// - /// Tries to convert the current custom event to a base event. - /// - /// The base event to convert to. - /// The type of the event. - /// True if the conversion was successful; otherwise, false. - public virtual bool TryConvert(ref BaseEvent? value, ref EventType? type) => TryConvert(ref value, ref type, new LevelReadOrWriteSettings()); - - /// - /// Tries to convert the current custom event to a base event with the specified settings. - /// - /// The base event to convert to. - /// The type of the event. - /// The settings for reading or writing the level. - /// True if the conversion was successful; otherwise, false. - public virtual bool TryConvert(ref BaseEvent? value, ref EventType? type, LevelReadOrWriteSettings settings) - { - JsonSerializer serializer = JsonSerializer.Create(_beat.BaseLevel?.GetSerializer(settings)); - Type eventType = Utils.EventTypeUtils.ToType(Data["type"]?.ToObject() ?? ""); - bool TryConvert; - if (eventType == null) - { - if (Data["target"] != null) - value = Data.ToObject(serializer); - else if (Data["row"] != null) - value = Data.ToObject(serializer); - else - value = Data.ToObject(serializer); - type = null; - TryConvert = value is not null; - } - else - { - value = (BaseEvent?)Data.ToObject(eventType, serializer); - type = value?.Type; - TryConvert = true; - } - return TryConvert; - } - - /// - /// Gets or sets the data for the custom event. - /// - [JsonIgnore] - public JObject Data { get; set; } - } -} diff --git a/RhythmBaseCore/Events/CustomFlash.cs b/RhythmBaseCore/Events/CustomFlash.cs deleted file mode 100644 index bab234e..0000000 --- a/RhythmBaseCore/Events/CustomFlash.cs +++ /dev/null @@ -1,64 +0,0 @@ -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents a custom flash event. - /// - public class CustomFlash : BaseEvent, IEaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public CustomFlash() - { - Rooms = new RDRoom(true, new byte[1]); - StartColor = new PaletteColor(false); - EndColor = new PaletteColor(false); - Type = EventType.CustomFlash; - Tab = Tabs.Actions; - } - - /// - public RDRoom Rooms { get; set; } - - /// - public EaseType Ease { get; set; } - - /// - /// Gets or sets the start color of the flash. - /// - public PaletteColor StartColor { get; set; } - - /// - /// Gets or sets a value indicating whether the background is affected. - /// - public bool Background { get; set; } - - /// - /// Gets or sets the end color of the flash. - /// - [EaseProperty] - public PaletteColor EndColor { get; set; } - /// - public float Duration { get; set; } - - /// - /// Gets or sets the start opacity of the flash. - /// - public int StartOpacity { get; set; } - - /// - /// Gets or sets the end opacity of the flash. - /// - [EaseProperty] - public int EndOpacity { get; set; } - /// - public override EventType Type { get; } - - /// - public override Tabs Tab { get; } - /// - public override string ToString() => base.ToString() + $" {StartColor} {StartOpacity}%=>{EndColor} {EndOpacity}%"; - } -} diff --git a/RhythmBaseCore/Events/CustomRowEvent.cs b/RhythmBaseCore/Events/CustomRowEvent.cs deleted file mode 100644 index 4dc7f2e..0000000 --- a/RhythmBaseCore/Events/CustomRowEvent.cs +++ /dev/null @@ -1,104 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Exceptions; -using RhythmBase.Extensions; -using RhythmBase.Settings; -namespace RhythmBase.Events -{ - /// - /// Represents a custom row event in the rhythm base. - /// - public class CustomRowEvent : BaseRowAction - { - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the actual type of the event from the data. - /// - [JsonIgnore] - public string ActureType => Data["Type".ToLowerCamelCase()]?.ToString() ?? ""; - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Initializes a new instance of the class. - /// - public CustomRowEvent() - { - Data = []; - Type = EventType.CustomRowEvent; - Tab = Tabs.Rows; - } - - /// - /// Initializes a new instance of the class with the specified data. - /// - /// The data for the event. - public CustomRowEvent(JObject data) - { - Type = EventType.CustomRowEvent; - Tab = Tabs.Rows; - Data = data; - Beat = new RDBeat(Data["bar"]?.ToObject() ?? 1, Data["beat"]?.ToObject() ?? 1f); - Tag = Data["tag"]?.ToObject() ?? ""; - Condition = Data["condition"] == null - ? null - : Condition.Load(Data["condition"]?.ToObject() ?? ""); - Active = Data["active"]?.ToObject() ?? true; - } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => $"{Beat} *{ActureType}"; - - /// - /// Tries to convert the current event to a base event. - /// - /// The base event to convert to. - /// The type of the event. - /// true if the conversion was successful; otherwise, false. - public virtual bool TryConvert(ref BaseEvent value, ref EventType? type) => TryConvert(ref value, ref type, new LevelReadOrWriteSettings()); - - /// - /// Tries to convert the current event to a base event with the specified settings. - /// - /// The base event to convert to. - /// The type of the event. - /// The settings for the conversion. - /// true if the conversion was successful; otherwise, false. - public virtual bool TryConvert(ref BaseEvent value, ref EventType? type, LevelReadOrWriteSettings settings) => TryConvert(ref value, ref type, settings); - - /// - /// Implicitly converts a to a . - /// - /// The custom row event to convert. - public static implicit operator CustomEvent(CustomRowEvent e) => new(e.Data); - - /// - /// Explicitly converts a to a . - /// - /// The custom event to convert. - /// The converted custom row event. - /// Thrown when the row field is missing from the data. - public static explicit operator CustomRowEvent(CustomEvent e) - { - return e.Data["row"] != null - ? new CustomRowEvent(e.Data) - : throw new RhythmBaseException("The row field is missing from the field contained in this object."); - } - - /// - /// Gets or sets the data for the event. - /// - public JObject Data; - } -} diff --git a/RhythmBaseCore/Events/DefaultAudios.cs b/RhythmBaseCore/Events/DefaultAudios.cs deleted file mode 100644 index 7c487c1..0000000 --- a/RhythmBaseCore/Events/DefaultAudios.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Enum representing default audio events in the RhythmBase application. - /// - public enum DefaultAudios - { - /// - /// Base sound for the tutorial house. - /// - sndTutorialHouse_Base, - - /// - /// Rest sound for the tutorial house. - /// - sndTutorialHouse_Rest, - - /// - /// Amen fill sound for the tutorial house. - /// - sndTutorialHouse_AmenFill, - - /// - /// First freeze sound for the tutorial house. - /// - sndTutorialHouse_Freeze1, - - /// - /// Second freeze sound for the tutorial house. - /// - sndTutorialHouse_Freeze2, - - /// - /// CPU freeze sound for the tutorial house. - /// - sndTutorialHouse_FreezeCPU, - - /// - /// First burn sound for the tutorial house. - /// - sndTutorialHouse_Burn1, - - /// - /// Second burn sound for the tutorial house. - /// - sndTutorialHouse_Burn2, - - /// - /// CPU burn sound for the tutorial house. - /// - sndTutorialHouse_BurnCPU - } -} diff --git a/RhythmBaseCore/Events/EventType.cs b/RhythmBaseCore/Events/EventType.cs deleted file mode 100644 index 8235b0a..0000000 --- a/RhythmBaseCore/Events/EventType.cs +++ /dev/null @@ -1,279 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Rhythm Doctor event types. - /// - public enum EventType - { - /// - /// Add a classic beat. - /// - AddClassicBeat, - /// - /// Add a free time beat. - /// - AddFreeTimeBeat, - /// - /// Add a oneshot beat. - /// - AddOneshotBeat, - /// - /// Advance the text. - /// - AdvanceText, - /// - /// Drop the bass. - /// - BassDrop, - /// - /// Call a custom method. - /// - CallCustomMethod, - /// - /// Change the players' rows. - /// - ChangePlayersRows, - /// - /// Add a comment. - /// - Comment, - /// - /// Custom decoration event, from unknown event in the level or user-defined event. - /// - CustomDecorationEvent, - /// - /// Custom event, from unknown event in the level or user-defined event. - /// - CustomEvent, - /// - /// Custom row event, from unknown event in the level or user-defined event. - /// - CustomRowEvent, - /// - /// Custom flash event. - /// - CustomFlash, - /// - /// Fade the room. - /// - FadeRoom, - /// - /// Finish the level. - /// - FinishLevel, - /// - /// Flash the screen. - /// - Flash, - /// - /// Flip the screen. - /// - FlipScreen, - /// - /// Display floating text. - /// - FloatingText, - /// - /// Hide the row. - /// - HideRow, - /// - /// Invert the colors. - /// - InvertColors, - /// - /// Mask the room. - /// - MaskRoom, - /// - /// Move an object. - /// - Move, - /// - /// Move the camera. - /// - MoveCamera, - /// - /// Move the room. - /// - MoveRoom, - /// - /// Move the row. - /// - MoveRow, - /// - /// Narrate row information. - /// - NarrateRowInfo, - /// - /// Start a new window dance. - /// - NewWindowDance, - /// - /// Paint the hands. - /// - PaintHands, - /// - /// Play an animation. - /// - PlayAnimation, - /// - /// Play an expression. - /// - PlayExpression, - /// - /// Play a song. - /// - PlaySong, - /// - /// Play a sound. - /// - PlaySound, - /// - /// Pulse the camera. - /// - PulseCamera, - /// - /// Pulse a free time beat. - /// - PulseFreeTimeBeat, - /// - /// Read the narration. - /// - ReadNarration, - /// - /// Reorder the rooms. - /// - ReorderRooms, - /// - /// Say "Ready, Get Set, Go". - /// - SayReadyGetSetGo, - /// - /// Set the background color. - /// - SetBackgroundColor, - /// - /// Set the beat sound. - /// - SetBeatSound, - /// - /// Set the beats per minute. - /// - SetBeatsPerMinute, - /// - /// Set the clap sounds. - /// - SetClapSounds, - /// - /// Set the counting sound. - /// - SetCountingSound, - /// - /// Set the crotchets per bar. - /// - SetCrotchetsPerBar, - /// - /// Set the foreground. - /// - SetForeground, - /// - /// Set the game sound. - /// - SetGameSound, - /// - /// Set the hand owner. - /// - SetHandOwner, - /// - /// Set the heart explode interval. - /// - SetHeartExplodeInterval, - /// - /// Set the heart explode volume. - /// - SetHeartExplodeVolume, - /// - /// Set the oneshot wave. - /// - SetOneshotWave, - /// - /// Set the play style. - /// - SetPlayStyle, - /// - /// Set the room content mode. - /// - SetRoomContentMode, - /// - /// Set the room perspective. - /// - SetRoomPerspective, - /// - /// Set the row X positions. - /// - SetRowXs, - /// - /// Set the speed. - /// - SetSpeed, - /// - /// Set the theme. - /// - SetTheme, - /// - /// Set the VFX preset. - /// - SetVFXPreset, - /// - /// Set the visibility. - /// - SetVisible, - /// - /// Shake the screen. - /// - ShakeScreen, - /// - /// Show the dialogue. - /// - ShowDialogue, - /// - /// Show the hands. - /// - ShowHands, - /// - /// Show the rooms. - /// - ShowRooms, - /// - /// Show the status sign. - /// - ShowStatusSign, - /// - /// Stutter effect. - /// - Stutter, - /// - /// Tag an action. - /// - TagAction, - /// - /// Text explosion effect. - /// - TextExplosion, - /// - /// Tile effect. - /// - Tile, - /// - /// Tint effect. - /// - Tint, - /// - /// Tint rows effect. - /// - TintRows, -#if DEBUG -#endif - } -} diff --git a/RhythmBaseCore/Events/FadeRoom.cs b/RhythmBaseCore/Events/FadeRoom.cs deleted file mode 100644 index aff0aa8..0000000 --- a/RhythmBaseCore/Events/FadeRoom.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event that fades a room. - /// - public class FadeRoom : BaseEvent, IEaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public FadeRoom() { } - - /// - /// Gets or sets the easing type for the fade effect. - /// - public EaseType Ease { get; set; } - - /// - /// Gets or sets the opacity level for the fade effect. - /// - [EaseProperty] - public uint Opacity { get; set; } - - /// - /// Gets or sets the duration of the fade effect. - /// - public float Duration { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } = EventType.FadeRoom; - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } = Tabs.Rooms; - - /// - /// Gets the room associated with the event. - /// - [JsonIgnore] - public RDRoom Room => new RDSingleRoom((byte)Y); - } -} diff --git a/RhythmBaseCore/Events/FinishLevel.cs b/RhythmBaseCore/Events/FinishLevel.cs deleted file mode 100644 index d946b2c..0000000 --- a/RhythmBaseCore/Events/FinishLevel.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an event that occurs when a level is finished. - /// - public class FinishLevel : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public FinishLevel() - { - Type = EventType.FinishLevel; - Tab = Tabs.Actions; - } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - } -} diff --git a/RhythmBaseCore/Events/Flash.cs b/RhythmBaseCore/Events/Flash.cs deleted file mode 100644 index d5313b2..0000000 --- a/RhythmBaseCore/Events/Flash.cs +++ /dev/null @@ -1,64 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents a Flash event in the rhythm base. - /// - public class Flash : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public Flash() - { - Rooms = new RDRoom(true, new byte[1]); - Type = EventType.Flash; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with the flash event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the duration of the flash event. - /// - public Durations Duration { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", Duration); - - /// - /// Specifies the possible durations for a flash event. - /// - public enum Durations - { - /// - /// A short duration. - /// - Short, - /// - /// A medium duration. - /// - Medium, - /// - /// A long duration. - /// - Long - } - } -} diff --git a/RhythmBaseCore/Events/FlipScreen.cs b/RhythmBaseCore/Events/FlipScreen.cs deleted file mode 100644 index ffd3a6c..0000000 --- a/RhythmBaseCore/Events/FlipScreen.cs +++ /dev/null @@ -1,61 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event that flips the screen in a room. - /// - public class FlipScreen : BaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public FlipScreen() - { - Rooms = new RDRoom(true, new byte[1]); - Type = EventType.FlipScreen; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with this event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets a value indicating whether the screen should be flipped horizontally. - /// - public bool FlipX { get; set; } - - /// - /// Gets or sets a value indicating whether the screen should be flipped vertically. - /// - public bool FlipY { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab where this event is categorized. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() - { - string result = - FlipX - ? FlipY - ? "X" - : "^v" - : FlipY - ? "<>" - : ""; - return base.ToString() + string.Format(" {0}", result); - } - } -} diff --git a/RhythmBaseCore/Events/FloatingText.cs b/RhythmBaseCore/Events/FloatingText.cs deleted file mode 100644 index d35f6f6..0000000 --- a/RhythmBaseCore/Events/FloatingText.cs +++ /dev/null @@ -1,167 +0,0 @@ -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 - } - } -} diff --git a/RhythmBaseCore/Events/HideRow.cs b/RhythmBaseCore/Events/HideRow.cs deleted file mode 100644 index 8f20497..0000000 --- a/RhythmBaseCore/Events/HideRow.cs +++ /dev/null @@ -1,79 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an event to hide a row with specific transitions and visibility options. - /// - public class HideRow : BaseRowAnimation - { - /// - /// Initializes a new instance of the class. - /// - public HideRow() - { - Type = EventType.HideRow; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the transition type for hiding the row. - /// - public Transitions Transition { get; set; } - - /// - /// Gets or sets the visibility state of the row. - /// - public Shows Show { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab category of the event. - /// - public override Tabs Tab { get; } - - /// - /// Defines the possible transition types for hiding the row. - /// - public enum Transitions - { - /// - /// Smooth transition. - /// - Smooth, - /// - /// Instant transition. - /// - Instant, - /// - /// Full transition. - /// - Full - } - - /// - /// Defines the possible visibility states of the row. - /// - public enum Shows - { - /// - /// Row is visible. - /// - Visible, - /// - /// Row is hidden. - /// - Hidden, - /// - /// Only the character is visible. - /// - OnlyCharacter, - /// - /// Only the row is visible. - /// - OnlyRow - } - } -} diff --git a/RhythmBaseCore/Events/IBarBeginningEvent.cs b/RhythmBaseCore/Events/IBarBeginningEvent.cs deleted file mode 100644 index 0177e30..0000000 --- a/RhythmBaseCore/Events/IBarBeginningEvent.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an event that occurs at the beginning of a bar. - /// - public interface IBarBeginningEvent : IBaseEvent - { - } -} diff --git a/RhythmBaseCore/Events/IBaseEvent.cs b/RhythmBaseCore/Events/IBaseEvent.cs deleted file mode 100644 index a44662c..0000000 --- a/RhythmBaseCore/Events/IBaseEvent.cs +++ /dev/null @@ -1,50 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents the base interface for an event in the rhythm base system. - /// - public interface IBaseEvent - { - /// - /// Gets or sets a value indicating whether the event is active. - /// - bool Active { get; set; } - - /// - /// Gets or sets the beat associated with the event. - /// - RDBeat Beat { get; set; } - - /// - /// Gets or sets the condition associated with the event. - /// - Condition? Condition { get; set; } - - /// - /// Gets the tab associated with the event. - /// - Tabs Tab { get; } - - /// - /// Gets or sets the tag associated with the event. - /// - string Tag { get; set; } - - /// - /// Gets the type of the event. - /// - EventType Type { get; } - - /// - /// Gets or sets the Y coordinate of the event. - /// - int Y { get; set; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - string ToString(); - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Events/IDurationEvent.cs b/RhythmBaseCore/Events/IDurationEvent.cs deleted file mode 100644 index 4e5de8f..0000000 --- a/RhythmBaseCore/Events/IDurationEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Interface representing a duration event. - /// - public interface IDurationEvent - { - - /// - /// Gets or sets the duration of the ease event. - /// - float Duration { get; } - } -} diff --git a/RhythmBaseCore/Events/IEaseEvent.cs b/RhythmBaseCore/Events/IEaseEvent.cs deleted file mode 100644 index 94a2889..0000000 --- a/RhythmBaseCore/Events/IEaseEvent.cs +++ /dev/null @@ -1,21 +0,0 @@ -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Interface representing an ease event. - /// - public interface IEaseEvent:IDurationEvent - { - /// - /// Gets or sets the type of easing. - /// - EaseType Ease { get; set; } - ///// - ///// Gets the default ease event. - ///// - ///// - ///// The default ease event. - ///// - //static abstract IEaseEvent DefaultEvent => default; - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Events/IRoomEvent.cs b/RhythmBaseCore/Events/IRoomEvent.cs deleted file mode 100644 index c3650b6..0000000 --- a/RhythmBaseCore/Events/IRoomEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event that occurs in a room. - /// - public interface IRoomEvent : IBaseEvent - { - /// - /// Gets or sets the room associated with the event. - /// - RDRoom Rooms { get; set; } - } -} diff --git a/RhythmBaseCore/Events/ISingleRoomEvent.cs b/RhythmBaseCore/Events/ISingleRoomEvent.cs deleted file mode 100644 index dfce9f1..0000000 --- a/RhythmBaseCore/Events/ISingleRoomEvent.cs +++ /dev/null @@ -1,14 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event that occurs within a single room. - /// - public interface ISingleRoomEvent : IBaseEvent - { - /// - /// Gets or sets the room associated with the event. - /// - RDSingleRoom Room { get; set; } - } -} diff --git a/RhythmBaseCore/Events/InvertColors.cs b/RhythmBaseCore/Events/InvertColors.cs deleted file mode 100644 index 86f047b..0000000 --- a/RhythmBaseCore/Events/InvertColors.cs +++ /dev/null @@ -1,45 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event that inverts colors in a room. - /// - public class InvertColors : BaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public InvertColors() - { - Rooms = new RDRoom(false, new byte[1]); - Type = EventType.InvertColors; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with this event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets a value indicating whether the color inversion is enabled. - /// - public bool Enable { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with this event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + $" {Enable}"; - } -} diff --git a/RhythmBaseCore/Events/MaskRoom.cs b/RhythmBaseCore/Events/MaskRoom.cs deleted file mode 100644 index 8453db2..0000000 --- a/RhythmBaseCore/Events/MaskRoom.cs +++ /dev/null @@ -1,130 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents a MaskRoom event in the RhythmBase system. - /// - public class MaskRoom : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public MaskRoom() - { - KeyColor = new PaletteColor(false); - Type = EventType.MaskRoom; - Tab = Tabs.Rooms; - } - - /// - /// Gets or sets the type of the mask. - /// - public MaskTypes MaskType { get; set; } - - /// - /// Gets or sets the alpha mode. - /// - public AlphaModes AlphaMode { get; set; } - - /// - /// Gets or sets the source room. - /// - public byte SourceRoom { get; set; } - - /// - /// Gets or sets the list of image assets. - /// - public List Image { get; set; } = []; - - /// - /// Gets or sets the frames per second. - /// - public uint Fps { get; set; } - - /// - /// Gets or sets the key color. - /// - public PaletteColor KeyColor { get; set; } - - /// - /// Gets or sets the color cutoff value. - /// - public int ColorCutoff { get; set; } - - /// - /// Gets or sets the color feathering value. - /// - public int ColorFeathering { get; set; } - - /// - /// Gets or sets the content mode. - /// - public ContentModes ContentMode { get; set; } - - /// - /// Gets the event type. - /// - public override EventType Type { get; } - - /// - /// Gets the tab type. - /// - public override Tabs Tab { get; } - - /// - /// Gets the room associated with the event. - /// - [JsonIgnore] - public RDRoom Room => new RDSingleRoom(checked((byte)Y)); - - /// - /// Defines the types of masks available. - /// - public enum MaskTypes - { - /// - /// Uses an image as the mask. - /// - Image, - /// - /// Uses a room as the mask. - /// - Room, - /// - /// Uses a color as the mask. - /// - Color, - /// - /// No mask is applied. - /// - None - } - - /// - /// Defines the alpha modes available. - /// - public enum AlphaModes - { - /// - /// Normal alpha mode. - /// - Normal, - /// - /// Inverted alpha mode. - /// - Inverted - } - - /// - /// Defines the content modes available. - /// - public enum ContentModes - { - /// - /// Scales the content to fill the area. - /// - ScaleToFill - } - } -} diff --git a/RhythmBaseCore/Events/Move.cs b/RhythmBaseCore/Events/Move.cs deleted file mode 100644 index d50b2a2..0000000 --- a/RhythmBaseCore/Events/Move.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents a move event in the rhythm base system. - /// - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class Move : BaseDecorationAction, IEaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public Move() - { - Type = EventType.Move; - Tab = Tabs.Decorations; - } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Gets or sets the position of the move event. - /// - [EaseProperty] - public RDPointE? Position { get; set; } - - /// - /// Gets or sets the scale of the move event. - /// - [EaseProperty] - public RDSizeE? Scale { get; set; } - - /// - /// Gets or sets the angle of the move event. - /// - [EaseProperty] - public RDExpression? Angle { get; set; } - - /// - /// Gets or sets the pivot point of the move event. - /// - [EaseProperty] - public RDPointE? Pivot { get; set; } - - /// - /// Gets or sets the duration of the move event. - /// - public float Duration { get; set; } - - /// - /// Gets or sets the easing type of the move event. - /// - public EaseType Ease { get; set; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString(); - } -} diff --git a/RhythmBaseCore/Events/MoveCamera.cs b/RhythmBaseCore/Events/MoveCamera.cs deleted file mode 100644 index 443b10d..0000000 --- a/RhythmBaseCore/Events/MoveCamera.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event to move the camera. - /// - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class MoveCamera : BaseEvent, IEaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public MoveCamera() - { - Rooms = new RDRoom(true, new byte[1]); - Type = EventType.MoveCamera; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with the event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the camera position. - /// - [EaseProperty] - public RDPointE? CameraPosition { get; set; } - - /// - /// Gets or sets the zoom level. - /// - [EaseProperty] - public int? Zoom { get; set; } - - /// - /// Gets or sets the angle of the camera. - /// - [EaseProperty] - public RDExpression? Angle { get; set; } - - /// - /// Gets or sets the duration of the event. - /// - public float Duration { get; set; } - - /// - /// Gets or sets the easing type of the event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - } -} diff --git a/RhythmBaseCore/Events/MoveRoom.cs b/RhythmBaseCore/Events/MoveRoom.cs deleted file mode 100644 index 210e948..0000000 --- a/RhythmBaseCore/Events/MoveRoom.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event to move a room with easing properties. - /// - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class MoveRoom : BaseEvent, IEaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public MoveRoom() - { - Type = EventType.MoveRoom; - Tab = Tabs.Rooms; - } - - /// - /// Gets or sets the position of the room. - /// - [EaseProperty] - public RDPointE? RoomPosition { get; set; } - - /// - /// Gets or sets the scale of the room. - /// - [EaseProperty] - public RDSizeE? Scale { get; set; } - - /// - /// Gets or sets the angle of the room. - /// - [EaseProperty] - public RDExpression? Angle { get; set; } - - /// - /// Gets or sets the pivot point of the room. - /// - [EaseProperty] - public RDPointE? Pivot { get; set; } - - /// - /// Gets or sets the duration of the move event. - /// - public float Duration { get; set; } - - /// - /// Gets or sets the easing type of the move event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Gets the room associated with the event. - /// - [JsonIgnore] - public RDRoom Rooms => new RDSingleRoom(checked((byte)Y)); - } -} diff --git a/RhythmBaseCore/Events/MoveRow.cs b/RhythmBaseCore/Events/MoveRow.cs deleted file mode 100644 index d081151..0000000 --- a/RhythmBaseCore/Events/MoveRow.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event to move a row with various properties such as position, scale, angle, and pivot. - /// - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class MoveRow : BaseRowAnimation, IEaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public MoveRow() - { - Type = EventType.MoveRow; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets a value indicating whether a custom position is used. - /// - public bool CustomPosition { get; set; } - - /// - /// Gets or sets the target of the move row event. - /// - public Targets Target { get; set; } - - /// - /// Gets or sets the row position. - /// - [EaseProperty] - public RDPointE? RowPosition { get; set; } - - /// - /// Gets or sets the scale. - /// - [EaseProperty] - public RDSizeE? Scale { get; set; } - - /// - /// Gets or sets the angle. - /// - [EaseProperty] - public RDExpression? Angle { get; set; } - - /// - /// Gets or sets the pivot. - /// - [EaseProperty] - public float? Pivot { get; set; } - - /// - /// Gets or sets the duration of the move row event. - /// - public float Duration { get; set; } - - /// - /// Gets or sets the easing type of the move row event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab of the event. - /// - public override Tabs Tab { get; } - - /// - /// Specifies the targets for the move row event. - /// - public enum Targets - { - /// - /// Target the whole row. - /// - WholeRow, - - /// - /// Target the heart. - /// - Heart, - - /// - /// Target the character. - /// - Character - } - } -} diff --git a/RhythmBaseCore/Events/NarrateRowInfo.cs b/RhythmBaseCore/Events/NarrateRowInfo.cs deleted file mode 100644 index 906f840..0000000 --- a/RhythmBaseCore/Events/NarrateRowInfo.cs +++ /dev/null @@ -1,109 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Converters; -namespace RhythmBase.Events -{ - /// - /// Represents an event that narrates row information. - /// - public class NarrateRowInfo : BaseRowAction - { - /// - /// Initializes a new instance of the class. - /// - public NarrateRowInfo() - { - Type = EventType.NarrateRowInfo; - Tab = Tabs.Actions; - CustomPattern = new Patterns[6]; - } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Gets or sets the type of narration information. - /// - public NarrateInfoType InfoType { get; set; } - - /// - /// Gets or sets a value indicating whether the narration is sound only. - /// - public bool SoundOnly { get; set; } - - /// - /// Gets or sets the beats to skip during narration. - /// - [JsonProperty("narrateSkipBeats")] - public NarrateSkipBeats NarrateSkipBeat { get; set; } = NarrateSkipBeats.On; - - /// - /// Gets or sets the custom pattern for the narration. - /// - [JsonConverter(typeof(PatternConverter))] - public Patterns[] CustomPattern { get; set; } - - /// - /// Gets or sets a value indicating whether to skip unstable beats. - /// - public bool SkipsUnstable { get; set; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}:{1}", InfoType, NarrateSkipBeat); - - /// - /// Specifies the type of narration information. - /// - public enum NarrateInfoType - { - /// - /// Indicates a connection event. - /// - Connect, - /// - /// Indicates an update event. - /// - Update, - /// - /// Indicates a disconnection event. - /// - Disconnect, - /// - /// Indicates an online event. - /// - Online, - /// - /// Indicates an offline event. - /// - Offline - } - /// - /// Specifies the beats to skip during narration. - /// - public enum NarrateSkipBeats - { - /// - /// Skip beats is on. - /// - On, - /// - /// Custom skip beats. - /// - Custom, - /// - /// Skip beats is off. - /// - Off, - } - } -} diff --git a/RhythmBaseCore/Events/NewWindowDance.cs b/RhythmBaseCore/Events/NewWindowDance.cs deleted file mode 100644 index 238583d..0000000 --- a/RhythmBaseCore/Events/NewWindowDance.cs +++ /dev/null @@ -1,189 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents a new window dance event. - /// - public class NewWindowDance : BaseEvent, IEaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public NewWindowDance() - { - Amplitude = 0f; - Type = EventType.NewWindowDance; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the preset. - /// - public Presets Preset { get; set; } - - /// - /// Gets or sets the same preset behavior. - /// - public SamePresetBehaviors SamePresetBehavior { get; set; } - - /// - /// Gets or sets the position. - /// - [EaseProperty] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public RDPointE Position { get; set; } - - /// - /// Gets or sets the reference. - /// - public References Reference { get; set; } - - /// - /// Gets or sets a value indicating whether to use a circle. - /// - public bool UseCircle { get; set; } - - /// - /// Gets or sets the speed. - /// - [EaseProperty] - public float Speed { get; set; } - - /// - /// Gets or sets the amplitude. - /// - [EaseProperty] - public float Amplitude { get; set; } - - /// - /// Gets or sets the amplitude vector. - /// - [EaseProperty] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public RDPointE AmplitudeVector { get; set; } - - /// - /// Gets or sets the angle. - /// - [EaseProperty] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public float? Angle { get; set; } - - /// - /// Gets or sets the frequency. - /// - [EaseProperty] - public float Frequency { get; set; } - - /// - /// Gets or sets the period. - /// - [EaseProperty] - public float Period { get; set; } - - /// - /// Gets or sets the ease type. - /// - public EaseTypes EaseType { get; set; } - - /// - /// Gets or sets the sub ease type. - /// - public EaseType SubEase { get; set; } - - /// - /// Gets or sets the duration. - /// - [JsonProperty("easingDuration")] - public float Duration { get; set; } - - /// - /// Gets or sets the ease. - /// - public EaseType Ease { get; set; } - - /// - /// Gets the event type. - /// - public override EventType Type { get; } - - /// - /// Gets the tab. - /// - public override Tabs Tab { get; } - - /// - /// Represents the presets. - /// - public enum Presets - { - /// - /// Move preset. - /// - Move, - /// - /// Sway preset. - /// - Sway, - /// - /// Wrap preset. - /// - Wrap, - /// - /// Ellipse preset. - /// - Ellipse, - /// - /// Shake per preset. - /// - ShakePer - } - - /// - /// Represents the same preset behaviors. - /// - public enum SamePresetBehaviors - { - /// - /// Reset behavior. - /// - Reset, - /// - /// Keep behavior. - /// - Keep - } - - /// - /// Represents the references. - /// - public enum References - { - /// - /// Center reference. - /// - Center, - /// - /// Edge reference. - /// - Edge - } - - /// - /// Represents the ease types. - /// - public enum EaseTypes - { - /// - /// Repeat ease type. - /// - Repeat, - /// - /// Mirror ease type. - /// - Mirror, - } - } -} diff --git a/RhythmBaseCore/Events/PaintHands.cs b/RhythmBaseCore/Events/PaintHands.cs deleted file mode 100644 index d9ee043..0000000 --- a/RhythmBaseCore/Events/PaintHands.cs +++ /dev/null @@ -1,101 +0,0 @@ -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event to paint hands with specified properties. - /// - public class PaintHands : BaseEvent, IEaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public PaintHands() - { - TintColor = new PaletteColor(true); - BorderColor = new PaletteColor(true); - Rooms = new RDRoom(true, new byte[1]); - Type = EventType.PaintHands; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the tint color of the hands. - /// - [EaseProperty] - public PaletteColor TintColor { get; set; } - - /// - /// Gets or sets the easing type for the event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets or sets the border style of the hands. - /// - public Borders Border { get; set; } - - /// - /// Gets or sets the border color of the hands. - /// - [EaseProperty] - public PaletteColor BorderColor { get; set; } - - /// - /// Gets or sets the opacity of the hands. - /// - [EaseProperty] - public int Opacity { get; set; } - - /// - /// Gets or sets a value indicating whether the hands should be tinted. - /// - public bool Tint { get; set; } - - /// - /// Gets or sets the duration of the event. - /// - public float Duration { get; set; } - - /// - /// Gets or sets the rooms associated with the event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the player hands associated with the event. - /// - public PlayerHands Hands { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab category of the event. - /// - public override Tabs Tab { get; } - - /// - /// Specifies the border styles available for the hands. - /// - public enum Borders - { - /// - /// No border. - /// - None, - - /// - /// Outline border. - /// - Outline, - - /// - /// Glow border. - /// - Glow - } - } -} diff --git a/RhythmBaseCore/Events/Patterns.cs b/RhythmBaseCore/Events/Patterns.cs deleted file mode 100644 index 7a37b4c..0000000 --- a/RhythmBaseCore/Events/Patterns.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -namespace RhythmBase.Events -{ - /// - /// Enum representing different rhythm patterns. - /// - [JsonConverter(typeof(PatternConverter))] - public enum Patterns - { - /// - /// No pattern. - /// - None, - /// - /// Pattern X. - /// - X, - /// - /// Pattern Up. - /// - Up, - /// - /// Pattern Down. - /// - Down, - /// - /// Pattern Banana. - /// - Banana, - /// - /// Pattern Return. - /// - Return - } -} diff --git a/RhythmBaseCore/Events/PlayAnimation.cs b/RhythmBaseCore/Events/PlayAnimation.cs deleted file mode 100644 index f5b5cad..0000000 --- a/RhythmBaseCore/Events/PlayAnimation.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Newtonsoft.Json; -namespace RhythmBase.Events -{ - /// - /// Represents an action to play an animation. - /// - public class PlayAnimation : BaseDecorationAction - { - /// - /// Initializes a new instance of the class. - /// - public PlayAnimation() - { - Type = EventType.PlayAnimation; - Tab = Tabs.Decorations; - } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Gets or sets the expression for the animation. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] - public string Expression { get; set; } = ""; - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" Expression:{0}", Expression); - } -} diff --git a/RhythmBaseCore/Events/PlayExpression.cs b/RhythmBaseCore/Events/PlayExpression.cs deleted file mode 100644 index 6c43f9e..0000000 --- a/RhythmBaseCore/Events/PlayExpression.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an event that plays an expression. - /// - public class PlayExpression : BaseRowAnimation - { - /// - /// Initializes a new instance of the class. - /// - public PlayExpression() - { - Type = EventType.PlayExpression; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the expression to be played. - /// - public string Expression { get; set; } = ""; - - /// - /// Gets or sets a value indicating whether to replace the current expression. - /// - public bool Replace { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab where the event is categorized. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + $" {Expression}"; - } -} diff --git a/RhythmBaseCore/Events/PlaySong.cs b/RhythmBaseCore/Events/PlaySong.cs deleted file mode 100644 index 4efbecc..0000000 --- a/RhythmBaseCore/Events/PlaySong.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event to play a song with specific beats per minute and other properties. - /// - public class PlaySong : BaseBeatsPerMinute, IBarBeginningEvent - { - /// - /// Initializes a new instance of the class. - /// - public PlaySong() - { - Type = EventType.PlaySong; - Tab = Tabs.Sounds; - } - - /// - /// Gets or sets the beats per minute (BPM) for the song. - /// - [JsonProperty("bpm")] - public override float BeatsPerMinute - { - get => base.BeatsPerMinute; - set => base.BeatsPerMinute = value; - } - - /// - /// Gets or sets the offset time for the song. - /// - [JsonIgnore] - public TimeSpan Offset - { - get => Song.Offset; - set => Song.Offset = value; - } - - /// - /// Gets or sets a value indicating whether the song should loop. - /// - public bool Loop { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" BPM:{0}, Song:{1}", BeatsPerMinute, Song.Filename); - - /// - /// Gets or sets the song to be played. - /// - public RDAudio Song = new(); - } -} diff --git a/RhythmBaseCore/Events/PlaySound.cs b/RhythmBaseCore/Events/PlaySound.cs deleted file mode 100644 index 0dd8120..0000000 --- a/RhythmBaseCore/Events/PlaySound.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event to play a sound. - /// - public class PlaySound : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public PlaySound() - { - Type = EventType.PlaySound; - Tab = Tabs.Sounds; - } - - /// - /// Gets or sets a value indicating whether the sound is custom. - /// - public bool IsCustom { get; set; } - - /// - /// Gets or sets the type of the custom sound. - /// - public CustomSoundTypes CustomSoundType { get; set; } - - /// - /// Gets or sets the audio sound. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public RDAudio? Sound { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + $" {(IsCustom ? Sound?.ToString() : CustomSoundType.ToString())}"; - - /// - /// Defines the types of custom sounds. - /// - public enum CustomSoundTypes - { - /// - /// Cue sound type. - /// - CueSound, - - /// - /// Music sound type. - /// - MusicSound, - - /// - /// Beat sound type. - /// - BeatSound, - - /// - /// Hit sound type. - /// - HitSound, - - /// - /// Other sound type. - /// - OtherSound - } - } -} diff --git a/RhythmBaseCore/Events/PlayerHands.cs b/RhythmBaseCore/Events/PlayerHands.cs deleted file mode 100644 index 0a8eef4..0000000 --- a/RhythmBaseCore/Events/PlayerHands.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents the hands of a player. - /// - public enum PlayerHands - { - /// - /// The left hand of the player. - /// - Left, - - /// - /// The right hand of the player. - /// - Right, - - /// - /// Both hands of the player. - /// - Both, - - /// - /// Player 1's hand. - /// - p1, - - /// - /// Player 2's hand. - /// - p2 - } -} diff --git a/RhythmBaseCore/Events/PlayerType.cs b/RhythmBaseCore/Events/PlayerType.cs deleted file mode 100644 index 2193f84..0000000 --- a/RhythmBaseCore/Events/PlayerType.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents the type of player in the game. - /// - public enum PlayerType - { - /// - /// Player 1. - /// - P1, - - /// - /// Player 2. - /// - P2, - - /// - /// Computer player. - /// - CPU, - - /// - /// No change in player type. - /// - NoChange - } -} diff --git a/RhythmBaseCore/Events/PulseCamera.cs b/RhythmBaseCore/Events/PulseCamera.cs deleted file mode 100644 index d0b7e92..0000000 --- a/RhythmBaseCore/Events/PulseCamera.cs +++ /dev/null @@ -1,49 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents a camera pulse event in a room. - /// - public class PulseCamera : BaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public PulseCamera() - { - Rooms = new RDRoom(true, new byte[1]); - Type = EventType.PulseCamera; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with the event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the strength of the pulse. - /// - public byte Strength { get; set; } - - /// - /// Gets or sets the count of pulses. - /// - public int Count { get; set; } - - /// - /// Gets or sets the frequency of the pulses. - /// - public float Frequency { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - } -} diff --git a/RhythmBaseCore/Events/PulseFreeTimeBeat.cs b/RhythmBaseCore/Events/PulseFreeTimeBeat.cs deleted file mode 100644 index 924de5d..0000000 --- a/RhythmBaseCore/Events/PulseFreeTimeBeat.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Microsoft.VisualBasic.CompilerServices; -namespace RhythmBase.Events -{ - /// - /// Represents a pulse free time beat event. - /// - public class PulseFreeTimeBeat : BaseBeat - { - /// - /// Initializes a new instance of the class. - /// - public PulseFreeTimeBeat() - { - Type = EventType.PulseFreeTimeBeat; - } - - /// - /// Gets or sets the hold duration. - /// - public float Hold { get; set; } - - /// - /// Gets or sets the action type. - /// - public ActionType Action { get; set; } - - /// - /// Gets or sets the custom pulse value. - /// - public uint CustomPulse { get; set; } - - /// - /// Gets the event type. - /// - public override EventType Type { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() - { - string Out = ""; - switch (Action) - { - case ActionType.Increment: - Out = ">"; - break; - case ActionType.Decrement: - Out = "<"; - break; - case ActionType.Custom: - Out = (CustomPulse + 1).ToString(); - break; - case ActionType.Remove: - Out = "X"; - break; - } - return base.ToString() + $"{Out}"; - } - - /// - /// Defines the action types for the pulse free time beat. - /// - public enum ActionType - { - /// - /// Increment action. - /// - Increment, - /// - /// Decrement action. - /// - Decrement, - /// - /// Custom action. - /// - Custom, - /// - /// Remove action. - /// - Remove - } - } -} diff --git a/RhythmBaseCore/Events/ReadNarration.cs b/RhythmBaseCore/Events/ReadNarration.cs deleted file mode 100644 index 8096241..0000000 --- a/RhythmBaseCore/Events/ReadNarration.cs +++ /dev/null @@ -1,79 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event for reading narration. - /// - public class ReadNarration : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public ReadNarration() - { - Type = EventType.ReadNarration; - Tab = Tabs.Actions; - } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets or sets the text of the narration. - /// - public string Text { get; set; } = ""; - - /// - /// Gets or sets the category of the narration. - /// - public NarrationCategory Category { get; set; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", Text); - - /// - /// Specifies the category of the narration. - /// - public enum NarrationCategory - { - /// - /// Fallback category. - /// - Fallback, - /// - /// Navigation category. - /// - Navigation, - /// - /// Instruction category. - /// - Instruction, - /// - /// Notification category. - /// - Notification, - /// - /// Dialogue category. - /// - Dialogue, - /// - /// Description category. - /// - Description = 6, - /// - /// Subtitles category. - /// - Subtitles - } - } -} diff --git a/RhythmBaseCore/Events/ReorderRooms.cs b/RhythmBaseCore/Events/ReorderRooms.cs deleted file mode 100644 index 4508c7e..0000000 --- a/RhythmBaseCore/Events/ReorderRooms.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an event to reorder rooms. - /// - public class ReorderRooms : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public ReorderRooms() - { - Type = EventType.ReorderRooms; - Tab = Tabs.Rooms; - } - - /// - /// Gets or sets the order of the rooms. - /// - public List Order { get; set; } = []; - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - } -} diff --git a/RhythmBaseCore/Events/RowType.cs b/RhythmBaseCore/Events/RowType.cs deleted file mode 100644 index 1d0590b..0000000 --- a/RhythmBaseCore/Events/RowType.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Specifies the type of row in the rhythm base. - /// - public enum RowType - { - /// - /// Represents a classic row type. - /// - Classic, - - /// - /// Represents a oneshot row type. - /// - Oneshot - } -} diff --git a/RhythmBaseCore/Events/SayReadyGetSetGo.cs b/RhythmBaseCore/Events/SayReadyGetSetGo.cs deleted file mode 100644 index 3730db2..0000000 --- a/RhythmBaseCore/Events/SayReadyGetSetGo.cs +++ /dev/null @@ -1,212 +0,0 @@ -using Newtonsoft.Json; -namespace RhythmBase.Events -{ - /// - /// Represents an event that says "Ready, Get Set, Go" with various voice sources and phrases. - /// - public class SayReadyGetSetGo : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public SayReadyGetSetGo() - { - Type = EventType.SayReadyGetSetGo; - Tab = Tabs.Sounds; - } - - /// - /// Gets or sets the phrase to say. - /// - public Words PhraseToSay { get; set; } - - /// - /// Gets or sets the voice source. - /// - public VoiceSources VoiceSource { get; set; } - - /// - /// Gets or sets the tick value. - /// - public float Tick { get; set; } - - /// - /// Gets or sets the volume. - /// - public uint Volume { get; set; } - - /// - /// Gets the event type. - /// - public override EventType Type { get; } - - /// - /// Gets the tab. - /// - public override Tabs Tab { get; } - - /// - /// Gets a value indicating whether the phrase is splitable. - /// - [JsonIgnore] - public bool Splitable - { - get - { - return PhraseToSay == Words.SayReaDyGetSetGoNew || PhraseToSay == Words.SayGetSetGo || PhraseToSay == Words.SayReaDyGetSetOne || PhraseToSay == Words.SayGetSetOne || PhraseToSay == Words.SayReadyGetSetGo; - } - } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}: {1}", VoiceSource, PhraseToSay); - - /// - /// Represents the phrases that can be said. - /// - public enum Words - { - /// - /// Represents the phrase "Ready, Get Set, Go New". - /// - SayReaDyGetSetGoNew, - /// - /// Represents the phrase "Get Set, Go". - /// - SayGetSetGo, - /// - /// Represents the phrase "Ready, Get Set, One". - /// - SayReaDyGetSetOne, - /// - /// Represents the phrase "Get Set, One". - /// - SayGetSetOne, - /// - /// Represents the phrase "Rea". - /// - JustSayRea, - /// - /// Represents the phrase "Dy". - /// - JustSayDy, - /// - /// Represents the phrase "Get". - /// - JustSayGet, - /// - /// Represents the phrase "Set". - /// - JustSaySet, - /// - /// Represents the phrase "And". - /// - JustSayAnd, - /// - /// Represents the phrase "Go". - /// - JustSayGo, - /// - /// Represents the phrase "Stop". - /// - JustSayStop, - /// - /// Represents the phrase "And Stop". - /// - JustSayAndStop, - /// - /// Represents the count "1". - /// - Count1, - /// - /// Represents the count "2". - /// - Count2, - /// - /// Represents the count "3". - /// - Count3, - /// - /// Represents the count "4". - /// - Count4, - /// - /// Represents the count "5". - /// - Count5, - /// - /// Represents the count "6". - /// - Count6, - /// - /// Represents the count "7". - /// - Count7, - /// - /// Represents the count "8". - /// - Count8, - /// - /// Represents the count "9". - /// - Count9, - /// - /// Represents the count "10". - /// - Count10, - /// - /// Represents the phrase "Ready, Get Set, Go". - /// - SayReadyGetSetGo, - /// - /// Represents the phrase "Ready". - /// - JustSayReady - } - - /// - /// Represents the sources of the voice. - /// - public enum VoiceSources - { - /// - /// Represents the voice source "Nurse". - /// - Nurse, - /// - /// Represents the voice source "Nurse Tired". - /// - NurseTired, - /// - /// Represents the voice source "Nurse Swing". - /// - NurseSwing, - /// - /// Represents the voice source "Nurse Swing Calm". - /// - NurseSwingCalm, - /// - /// Represents the voice source "Ian Excited". - /// - IanExcited, - /// - /// Represents the voice source "Ian Calm". - /// - IanCalm, - /// - /// Represents the voice source "Ian Slow". - /// - IanSlow, - /// - /// Represents the voice source "None Bottom". - /// - NoneBottom, - /// - /// Represents the voice source "None Top". - /// - NoneTop - } - } -} diff --git a/RhythmBaseCore/Events/SetBackgroundColor.cs b/RhythmBaseCore/Events/SetBackgroundColor.cs deleted file mode 100644 index 82ab212..0000000 --- a/RhythmBaseCore/Events/SetBackgroundColor.cs +++ /dev/null @@ -1,134 +0,0 @@ -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the background color. - /// - public class SetBackgroundColor : BaseEvent, IEaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetBackgroundColor() - { - Rooms = new RDRoom(false, new byte[1]); - Color = new PaletteColor(true); - Type = EventType.SetBackgroundColor; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with the event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the easing type for the event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets or sets the content mode for the event. - /// - public ContentModes ContentMode { get; set; } - - /// - /// Gets or sets the filter mode for the event. - /// - public FilterModes Filter { get; set; } - - /// - /// Gets or sets the color for the background. - /// - [EaseProperty] - public PaletteColor Color { get; set; } - - /// - /// Gets or sets the interval for the event. - /// - public float Interval { get; set; } - - /// - /// Gets or sets the background type for the event. - /// - public BackgroundTypes BackgroundType { get; set; } - - /// - /// Gets or sets the duration of the event. - /// - public float Duration { get; set; } - - /// - /// Gets or sets the frames per second for the event. - /// - public int Fps { get; set; } - - /// - /// Gets or sets the list of images for the background. - /// - public List Image { get; set; } = []; - - /// - /// Gets or sets the horizontal scroll value. - /// - [EaseProperty] - public int ScrollX { get; set; } - - /// - /// Gets or sets the vertical scroll value. - /// - [EaseProperty] - public int ScrollY { get; set; } - - /// - /// Gets or sets the tiling type for the background. - /// - public TilingTypes TilingType { get; set; } - - /// - /// Gets the event type. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => BackgroundType == BackgroundTypes.Color - ? base.ToString() + $" {Color}" - : base.ToString() + $" {string.Join(',', Image)}"; - - /// - /// Specifies the types of backgrounds. - /// - public enum BackgroundTypes - { - /// - /// Background is a color. - /// - Color, - - /// - /// Background is an image. - /// - Image - } - - /// - /// Specifies the filter modes. - /// - public enum FilterModes - { - /// - /// Nearest neighbor filtering. - /// - NearestNeighbor - } - } -} diff --git a/RhythmBaseCore/Events/SetBeatSound.cs b/RhythmBaseCore/Events/SetBeatSound.cs deleted file mode 100644 index 79e87ed..0000000 --- a/RhythmBaseCore/Events/SetBeatSound.cs +++ /dev/null @@ -1,34 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an action to set the beat sound in the rhythm base. - /// - public class SetBeatSound : BaseRowAction - { - /// - /// Initializes a new instance of the class. - /// - public SetBeatSound() - { - Sound = new RDAudio(); - Type = EventType.SetBeatSound; - Tab = Tabs.Sounds; - } - - /// - /// Gets or sets the audio sound for the beat. - /// - public RDAudio Sound { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - } -} diff --git a/RhythmBaseCore/Events/SetBeatsPerMinute.cs b/RhythmBaseCore/Events/SetBeatsPerMinute.cs deleted file mode 100644 index e6c274b..0000000 --- a/RhythmBaseCore/Events/SetBeatsPerMinute.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the beats per minute (BPM) in the rhythm base. - /// - public class SetBeatsPerMinute : BaseBeatsPerMinute - { - /// - /// Initializes a new instance of the class. - /// - public SetBeatsPerMinute() - { - Type = EventType.SetBeatsPerMinute; - Tab = Tabs.Sounds; - } - - /// - public override EventType Type { get; } - - /// - public override Tabs Tab { get; } - - /// - public override string ToString() => base.ToString() + $" BPM:{BeatsPerMinute}"; - } -} diff --git a/RhythmBaseCore/Events/SetClapSounds.cs b/RhythmBaseCore/Events/SetClapSounds.cs deleted file mode 100644 index 3182436..0000000 --- a/RhythmBaseCore/Events/SetClapSounds.cs +++ /dev/null @@ -1,48 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event to set clap sounds for different players and CPU. - /// - public class SetClapSounds : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetClapSounds() - { - Type = EventType.SetClapSounds; - Tab = Tabs.Sounds; - } - - /// - /// Gets or sets the clap sound for player 1. - /// - public RDAudio? P1Sound { get; set; } - - /// - /// Gets or sets the clap sound for player 2. - /// - public RDAudio? P2Sound { get; set; } - - /// - /// Gets or sets the clap sound for the CPU. - /// - public RDAudio? CpuSound { get; set; } - - /// - /// Gets or sets the row type for the event. - /// - public RowType RowType { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - } -} diff --git a/RhythmBaseCore/Events/SetCountingSound.cs b/RhythmBaseCore/Events/SetCountingSound.cs deleted file mode 100644 index baad275..0000000 --- a/RhythmBaseCore/Events/SetCountingSound.cs +++ /dev/null @@ -1,158 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an action to set the counting sound in the rhythm base. - /// - public class SetCountingSound : BaseRowAction - { - /// - /// Initializes a new instance of the class. - /// - public SetCountingSound() - { - Volume = 100; - Sounds = new RDAudio[7]; - Type = EventType.SetCountingSound; - Tab = Tabs.Sounds; - } - - /// - /// Gets or sets the voice source for the counting sound. - /// - public VoiceSources VoiceSource { get; set; } - - /// - /// Gets or sets a value indicating whether this is enabled. - /// - public bool Enabled { get; set; } - - /// - /// Gets or sets the subdivision offset for the counting sound. - /// - public float SubdivOffset { get; set; } - - /// - /// Gets or sets the volume of the counting sound. - /// - public int Volume { get; set; } - - /// - /// Gets or sets the list of sounds for the counting sound. - /// - public RDAudio[] Sounds { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Represents the different voice sources for the counting sound. - /// - public enum VoiceSources - { - /// - /// Jyi Count - /// - JyiCount, - /// - /// Jyi Count Fast - /// - JyiCountFast, - /// - /// Jyi Count Calm - /// - JyiCountCalm, - /// - /// Jyi Count Tired - /// - JyiCountTired, - /// - /// Jyi Count Very Tired - /// - JyiCountVeryTired, - /// - /// Jyi Count Japanese - /// - JyiCountJapanese, - /// - /// Ian Count - /// - IanCount, - /// - /// Ian Count Fast - /// - IanCountFast, - /// - /// Ian Count Calm - /// - IanCountCalm, - /// - /// Ian Count Slow - /// - IanCountSlow, - /// - /// Ian Count Slower - /// - IanCountSlower, - /// - /// Whistle Count - /// - WhistleCount, - /// - /// Bird Count - /// - BirdCount, - /// - /// Parrot Count - /// - ParrotCount, - /// - /// Owl Count - /// - OwlCount, - /// - /// Oriole Count - /// - OrioleCount, - /// - /// Wren Count - /// - WrenCount, - /// - /// Canary Count - /// - CanaryCount, - /// - /// Jyi Count Legacy - /// - JyiCountLegacy, - /// - /// Jyi Count English - /// - JyiCountEnglish, - /// - /// Ian Count English - /// - IanCountEnglish, - /// - /// Ian Count English Calm - /// - IanCountEnglishCalm, - /// - /// Ian Count English Slow - /// - IanCountEnglishSlow, - /// - /// Custom - /// - Custom - } - } -} diff --git a/RhythmBaseCore/Events/SetCrotchetsPerBar.cs b/RhythmBaseCore/Events/SetCrotchetsPerBar.cs deleted file mode 100644 index 5b5e16e..0000000 --- a/RhythmBaseCore/Events/SetCrotchetsPerBar.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the number of crotchets per bar. - /// - public class SetCrotchetsPerBar : BaseEvent, IBarBeginningEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetCrotchetsPerBar() - { - _crotchetsPerBar = 7U; - Type = EventType.SetCrotchetsPerBar; - Tab = Tabs.Sounds; - } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Gets or sets the visual beat multiplier. - /// - /// Thrown when the value is less than 1. - public float VisualBeatMultiplier { get; set; } = 1; - - /// - /// Gets or sets the number of crotchets per bar. - /// - public uint CrotchetsPerBar - { - get => (uint)(_crotchetsPerBar + 1); - set - { - _crotchetsPerBar = checked((uint)(unchecked((ulong)value) - 1UL)); - if (_beat._calculator != null) - { - Beat += 0f; - } - } - } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + $" CPB:{_crotchetsPerBar + 1}"; - - /// - /// The number of crotchets per bar. - /// - protected internal uint _crotchetsPerBar; - } -} diff --git a/RhythmBaseCore/Events/SetForeground.cs b/RhythmBaseCore/Events/SetForeground.cs deleted file mode 100644 index 9d0adec..0000000 --- a/RhythmBaseCore/Events/SetForeground.cs +++ /dev/null @@ -1,95 +0,0 @@ -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the foreground in a room. - /// - public class SetForeground : BaseEvent, IEaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetForeground() - { - Rooms = new RDRoom(false, new byte[1]); - Color = new PaletteColor(true); - Type = EventType.SetForeground; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with the event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the content mode for the event. - /// - public ContentModes ContentMode { get; set; } - - /// - /// Gets or sets the tiling type for the event. - /// - public TilingTypes TilingType { get; set; } - - /// - /// Gets or sets the color for the foreground. - /// - [EaseProperty] - public PaletteColor Color { get; set; } - - /// - /// Gets or sets the list of images for the foreground. - /// - public List Image { get; set; } = []; - - /// - /// Gets or sets the frames per second for the foreground animation. - /// - public float Fps { get; set; } - - /// - /// Gets or sets the horizontal scroll value. - /// - [EaseProperty] - public float ScrollX { get; set; } - - /// - /// Gets or sets the vertical scroll value. - /// - [EaseProperty] - public float ScrollY { get; set; } - - /// - /// Gets or sets the duration of the event. - /// - public float Duration { get; set; } - - /// - /// Gets or sets the interval between frames. - /// - public float Interval { get; set; } - - /// - /// Gets or sets the easing type for the event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + $" {Color},{string.Join(',', Image.Select(i => i.ToString()))}"; - } -} diff --git a/RhythmBaseCore/Events/SetGameSound.cs b/RhythmBaseCore/Events/SetGameSound.cs deleted file mode 100644 index d95959b..0000000 --- a/RhythmBaseCore/Events/SetGameSound.cs +++ /dev/null @@ -1,99 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Converters; -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the game sound. - /// - public partial class SetGameSound : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetGameSound() - { - Audio = new RDAudio(); - Type = EventType.SetGameSound; - Tab = Tabs.Sounds; - } - - /// - /// Gets or sets the audio associated with the event. - /// - [JsonIgnore] - private RDAudio Audio { get; set; } - - /// - /// Gets or sets the type of the sound. - /// - public SoundTypes SoundType { get; set; } - - /// - /// Gets or sets the filename of the audio. - /// - public string Filename - { - get => Audio.Filename; - set => Audio.Filename = value; - } - - /// - /// Gets or sets the volume of the audio. - /// - public int Volume - { - get => Audio.Volume; - set => Audio.Volume = value; - } - - /// - /// Gets or sets the pitch of the audio. - /// - public int Pitch - { - get => Audio.Pitch; - set => Audio.Pitch = value; - } - - /// - /// Gets or sets the pan of the audio. - /// - public int Pan - { - get => Audio.Pan; - set => Audio.Pan = value; - } - - /// - /// Gets or sets the offset time of the audio. - /// - [JsonConverter(typeof(MilliSecondConverter))] - public TimeSpan Offset - { - get => Audio.Offset; - set => Audio.Offset = value; - } - - /// - /// Gets or sets the list of sound subtypes. - /// - public List SoundSubtypes { get; set; } = []; - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", SoundType); - } -} diff --git a/RhythmBaseCore/Events/SetHandOwner.cs b/RhythmBaseCore/Events/SetHandOwner.cs deleted file mode 100644 index 0afc817..0000000 --- a/RhythmBaseCore/Events/SetHandOwner.cs +++ /dev/null @@ -1,44 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the owner of a hand in a room. - /// - public class SetHandOwner : BaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetHandOwner() - { - Rooms = new RDRoom(true, new byte[1]); - Type = EventType.SetHandOwner; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the room associated with the event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the hand associated with the event. - /// - public PlayerHands Hand { get; set; } - - /// - /// Gets or sets the character associated with the event. - /// - public RDCharacters Character { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - } -} diff --git a/RhythmBaseCore/Events/SetHeartExplodeInterval.cs b/RhythmBaseCore/Events/SetHeartExplodeInterval.cs deleted file mode 100644 index 6674301..0000000 --- a/RhythmBaseCore/Events/SetHeartExplodeInterval.cs +++ /dev/null @@ -1,63 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the heart explode interval. - /// - public class SetHeartExplodeInterval : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetHeartExplodeInterval() - { - Type = EventType.SetHeartExplodeInterval; - Tab = Tabs.Sounds; - } - - /// - /// Gets or sets the type of interval. - /// - public IntervalTypes IntervalType { get; set; } - - /// - /// Gets or sets the interval value. - /// - public int Interval { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Defines the types of intervals. - /// - public enum IntervalTypes - { - /// - /// Interval of one beat after. - /// - OneBeatAfter, - - /// - /// Instant interval. - /// - Instant, - - /// - /// Gather without ceiling. - /// - GatherNoCeil, - - /// - /// Gather and ceiling. - /// - GatherAndCeil - } - } -} diff --git a/RhythmBaseCore/Events/SetHeartExplodeVolume.cs b/RhythmBaseCore/Events/SetHeartExplodeVolume.cs deleted file mode 100644 index 1fbe9d1..0000000 --- a/RhythmBaseCore/Events/SetHeartExplodeVolume.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the volume of the heart explosion sound. - /// - public class SetHeartExplodeVolume : BaseEvent, IBarBeginningEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetHeartExplodeVolume() - { - Type = EventType.SetHeartExplodeVolume; - Tab = Tabs.Sounds; - } - - /// - /// Gets or sets the volume of the heart explosion sound. - /// - public uint Volume { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - } -} diff --git a/RhythmBaseCore/Events/SetOneshotWave.cs b/RhythmBaseCore/Events/SetOneshotWave.cs deleted file mode 100644 index d5974ce..0000000 --- a/RhythmBaseCore/Events/SetOneshotWave.cs +++ /dev/null @@ -1,72 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an event to set a one-shot wave. - /// - public class SetOneshotWave : BaseBeat - { - /// - /// Initializes a new instance of the class. - /// - public SetOneshotWave() - { - Type = EventType.SetOneshotWave; - } - - /// - /// Gets or sets the type of wave. - /// - public Waves WaveType { get; set; } - - /// - /// Gets or sets the height of the wave. - /// - public int Height { get; set; } - - /// - /// Gets or sets the width of the wave. - /// - public int Width { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Defines the types of waves. - /// - public enum Waves - { - /// - /// Boom and rush wave. - /// - BoomAndRush, - - /// - /// Ball wave. - /// - Ball, - - /// - /// Spring wave. - /// - Spring, - - /// - /// Spike wave. - /// - Spike, - - /// - /// Huge spike wave. - /// - SpikeHuge, - - /// - /// Single wave. - /// - Single - } - } -} diff --git a/RhythmBaseCore/Events/SetPlayStyle.cs b/RhythmBaseCore/Events/SetPlayStyle.cs deleted file mode 100644 index 30b66e5..0000000 --- a/RhythmBaseCore/Events/SetPlayStyle.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Newtonsoft.Json; - -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the play style. - /// - public class SetPlayStyle : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetPlayStyle() - { - Type = EventType.SetPlayStyle; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the play style. - /// - [JsonProperty(nameof(PlayStyle))] - public PlayStyles PlayStyle { get; set; } - - /// - /// Gets or sets the next bar. - /// - [JsonProperty(nameof(NextBar))] - public int NextBar { get; set; } - - /// - /// Gets or sets a value indicating whether the play style is relative. - /// - [JsonProperty(nameof(Relative))] - public bool Relative { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Defines the play styles. - /// - public enum PlayStyles - { - /// - /// Normal play style. - /// - Normal, - - /// - /// Loop play style. - /// - Loop, - - /// - /// Prolong play style. - /// - Prolong, - - /// - /// Immediate play style. - /// - Immediately, - - /// - /// Extra immediate play style. - /// - ExtraImmediately, - - /// - /// Prolong one bar play style. - /// - ProlongOneBar - } - } -} diff --git a/RhythmBaseCore/Events/SetRoomContentMode.cs b/RhythmBaseCore/Events/SetRoomContentMode.cs deleted file mode 100644 index 189cb3d..0000000 --- a/RhythmBaseCore/Events/SetRoomContentMode.cs +++ /dev/null @@ -1,61 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the room content mode. - /// - public class SetRoomContentMode : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetRoomContentMode() - { - Type = EventType.SetRoomContentMode; - Tab = Tabs.Rooms; - } - - /// - /// Gets or sets the mode of the room content. - /// - public Modes Mode { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Gets the room associated with the event. - /// - [JsonIgnore] - public RDRoom Room - { - get - { - return new RDSingleRoom(checked((byte)Y)); - } - } - - /// - /// Defines the modes for room content. - /// - public enum Modes - { -#pragma warning disable CS1591 - Center, - ScaleToFill, - AspectFit, - AspectFill, - Tiled, - Real -#pragma warning restore CS1591 - } - } -} diff --git a/RhythmBaseCore/Events/SetRoomPerspective.cs b/RhythmBaseCore/Events/SetRoomPerspective.cs deleted file mode 100644 index 0d40a96..0000000 --- a/RhythmBaseCore/Events/SetRoomPerspective.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event to set the room perspective. - /// - public class SetRoomPerspective : BaseEvent, IEaseEvent - { - private RDPointE?[] cornerPositions= [ - new(0,0), - new(100,0), - new(0,100), - new(100,100), - ]; - - /// - /// Initializes a new instance of the class. - /// - public SetRoomPerspective() - { - Type = EventType.SetRoomPerspective; - Tab = Tabs.Rooms; - } - - /// - /// Gets or sets the corner positions of the room. - /// - [EaseProperty] - public RDPointE?[] CornerPositions { get => cornerPositions; set => cornerPositions = value.Length == 4?value:throw new RhythmBase.Exceptions.RhythmBaseException(); } - - /// - /// Gets or sets the duration of the event. - /// - public float Duration { get; set; } - - /// - /// Gets or sets the ease type of the event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Gets the room associated with the event. - /// - [JsonIgnore] - public RDRoom Room => new RDSingleRoom(checked((byte)Y)); - } -} diff --git a/RhythmBaseCore/Events/SetRowXs.cs b/RhythmBaseCore/Events/SetRowXs.cs deleted file mode 100644 index 4173fef..0000000 --- a/RhythmBaseCore/Events/SetRowXs.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -using RhythmBase.Extensions; -namespace RhythmBase.Events -{ - /// - public class SetRowXs : BaseBeat - { - /// - public SetRowXs() { } - - /// - public override EventType Type => EventType.SetRowXs; - - /// - /// Gets or sets the pattern. - /// - [JsonConverter(typeof(PatternConverter))] - public Patterns[] Pattern - { - get => _pattern; - set => _pattern = value.Length == 6 ? value : throw new RhythmBase.Exceptions.RhythmBaseException(); - } - - /// - /// Gets or sets the synco beat. - /// - public sbyte SyncoBeat { get; set; } = -1; - - /// - /// Gets or sets the synco swing. - /// - public float SyncoSwing { get; set; } = 0; - - /// - /// Gets or sets a value indicating whether to play the modifier sound. - /// - public bool SyncoPlayModifierSound { get; set; } - - /// - /// Gets or sets the synco volume. - /// - public int SyncoVolume { get; set; } = 100; - - /// - public override string ToString() => base.ToString() + string.Format(" {0}", this.GetPatternString()); - - private Patterns[] _pattern = new Patterns[6]; - } -} diff --git a/RhythmBaseCore/Events/SetSpeed.cs b/RhythmBaseCore/Events/SetSpeed.cs deleted file mode 100644 index 525e2f9..0000000 --- a/RhythmBaseCore/Events/SetSpeed.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event that sets the speed in the rhythm base. - /// - public class SetSpeed : BaseEvent, IEaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetSpeed() - { - Type = EventType.SetSpeed; - Rooms = RDRoom.Default(); - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the type of easing for the event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets or sets the speed for the event. - /// - [EaseProperty] - public float Speed { get; set; } - - /// - /// Gets or sets the duration of the event. - /// - public float Duration { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets or sets the rooms associated with the event. - /// - [JsonIgnore] - public RDRoom Rooms { get; set; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" Speed:{0}", Speed); - } -} diff --git a/RhythmBaseCore/Events/SetTheme.cs b/RhythmBaseCore/Events/SetTheme.cs deleted file mode 100644 index a16cf9b..0000000 --- a/RhythmBaseCore/Events/SetTheme.cs +++ /dev/null @@ -1,117 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event to set a theme in a room. - /// - public class SetTheme : BaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetTheme() - { - Preset = Theme.None; - Type = EventType.SetTheme; - Tab = Tabs.Actions; - Rooms = new RDRoom(false, new byte[1]); - } - - /// - /// Gets or sets the theme preset. - /// - public Theme Preset { get; set; } - - /// - /// Gets or sets the variant of the theme. - /// - public byte Variant { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Gets or sets the rooms associated with the event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets a value indicating whether to skip paint effects. - /// - public bool SkipPaintEffects { get; set; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", Preset); - - /// - /// Represents the available themes. - /// - public enum Theme - { -#pragma warning disable CS1591 - None, - Intimate, - IntimateSimple, - InsomniacDay, - InsomniacNight, - Matrix, - NeonMuseum, - CrossesStraight, - CrossesFalling, - CubesFalling, - CubesFallingNiceBlue, - OrientalTechno, - Kaleidoscope, - PoliticiansRally, - Rooftop, - RooftopSummer, - RooftopAutumn, - BackAlley, - Sky, - NightSky, - HallOfMirrors, - CoffeeShop, - CoffeeShopNight, - Garden, - GardenNight, - TrainDay, - TrainNight, - DesertDay, - DesertNight, - HospitalWard, - HospitalWardNight, - PaigeOffice, - Basement, - ColeWardNight, - ColeWardSunrise, - BoyWard, - GirlWard, - Skyline, - SkylineBlue, - FloatingHeart, - FloatingHeartWithCubes, - FloatingHeartBroken, - FloatingHeartBrokenWithCubes, - ZenGarden, - Space, - Vaporwave, - RollerDisco, - Stadium, - StadiumStormy, - AthleteWard, - AthleteWardNight, - ProceduralTree -#pragma warning restore CS1591 - } - } -} diff --git a/RhythmBaseCore/Events/SetVFXPreset.cs b/RhythmBaseCore/Events/SetVFXPreset.cs deleted file mode 100644 index 73b0cd1..0000000 --- a/RhythmBaseCore/Events/SetVFXPreset.cs +++ /dev/null @@ -1,166 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event to set a VFX preset. - /// - public class SetVFXPreset : BaseEvent, IEaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public SetVFXPreset() - { - Rooms = new RDRoom(true, new byte[1]); - Color = new PaletteColor(false); - Type = EventType.SetVFXPreset; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with the event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the VFX preset. - /// - public Presets Preset { get; set; } - - /// - /// Gets or sets a value indicating whether the VFX is enabled. - /// - public bool Enable { get; set; } - - /// - /// Gets or sets the threshold value for the VFX. - /// - [EaseProperty] - public float Threshold { get; set; } - - /// - /// Gets or sets the intensity of the VFX. - /// - [EaseProperty] - public float Intensity { get; set; } - - /// - /// Gets or sets the color of the VFX. - /// - [EaseProperty] - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)] - public PaletteColor Color { get; set; } - - /// - /// Gets or sets the X coordinate for the VFX. - /// - [EaseProperty] - public float FloatX { get; set; } - - /// - /// Gets or sets the Y coordinate for the VFX. - /// - [EaseProperty] - public float FloatY { get; set; } - - /// - /// Gets or sets the easing type for the VFX. - /// - public EaseType Ease { get; set; } - - /// - /// Gets or sets the duration of the VFX. - /// - public float Duration { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => $"{base.ToString()} {Preset}"; - - /// - /// Enum representing various VFX presets. - /// - public enum Presets - { -#pragma warning disable CS1591 - SilhouettesOnHBeat, - Vignette, - VignetteFlicker, - ColourfulShockwaves, - BassDropOnHit, - ShakeOnHeartBeat, - ShakeOnHit, - WavyRows, - LightStripVert, - VHS, - CutsceneMode, - HueShift, - Brightness, - Contrast, - Saturation, - Noise, - GlitchObstruction, - Rain, - Matrix, - Confetti, - FallingPetals, - FallingPetalsInstant, - FallingPetalsSnow, - Snow, - Bloom, - OrangeBloom, - BlueBloom, - HallOfMirrors, - TileN, - Sepia, - CustomScreenScroll, - JPEG, - NumbersAbovePulses, - Mosaic, - ScreenWaves, - Funk, - Grain, - Blizzard, - Drawing, - Aberration, - Blur, - RadialBlur, - Dots, - DisableAll, - Diamonds, - Tutorial, - Balloons, - - BlackAndWhite, - Blackout, - ScreenScrollX, - ScreenScroll, - ScreenScrollXSansVHS, - ScreenScrollSansVHS, - RowGlowWhite, - RowAllWhite, - RowOutline, - RowShadow, - RowSilhouetteGlow, - RowPlain, - Tile2, - Tile3, - Tile4 -#pragma warning restore CS1591 - } - } -} diff --git a/RhythmBaseCore/Events/SetVisible.cs b/RhythmBaseCore/Events/SetVisible.cs deleted file mode 100644 index cc98418..0000000 --- a/RhythmBaseCore/Events/SetVisible.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents an action to set the visibility of a decoration. - /// - public class SetVisible : BaseDecorationAction - { - /// - /// Initializes a new instance of the class. - /// - public SetVisible() - { - Type = EventType.SetVisible; - Tab = Tabs.Decorations; - } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab to which the event belongs. - /// - public override Tabs Tab { get; } - - /// - /// Gets or sets a value indicating whether the decoration is visible. - /// - public bool Visible { get; set; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", Visible); - } -} diff --git a/RhythmBaseCore/Events/ShakeScreen.cs b/RhythmBaseCore/Events/ShakeScreen.cs deleted file mode 100644 index e368bb5..0000000 --- a/RhythmBaseCore/Events/ShakeScreen.cs +++ /dev/null @@ -1,64 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event that shakes the screen. - /// - public class ShakeScreen : BaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public ShakeScreen() - { - Rooms = new RDRoom(true, new byte[1]); - Type = EventType.ShakeScreen; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with the event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the shake level of the event. - /// - public ShakeLevels ShakeLevel { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", ShakeLevel); - - /// - /// Defines the levels of screen shake. - /// - public enum ShakeLevels - { - /// - /// Low level of screen shake. - /// - Low, - /// - /// Medium level of screen shake. - /// - Medium, - /// - /// High level of screen shake. - /// - High - } - } -} diff --git a/RhythmBaseCore/Events/ShowDialogue.cs b/RhythmBaseCore/Events/ShowDialogue.cs deleted file mode 100644 index 119a301..0000000 --- a/RhythmBaseCore/Events/ShowDialogue.cs +++ /dev/null @@ -1,115 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components.RichText; - -namespace RhythmBase.Events -{ - /// - /// Represents an event to show a dialogue in the game. - /// - public class ShowDialogue : BaseEvent - { - private RDDialogueExchange dialogueList = []; - private string text = ""; - - /// - /// Initializes a new instance of the class. - /// - public ShowDialogue() - { - Speed = 1; - Type = EventType.ShowDialogue; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the text of the dialogue. - /// - public string Text - { - get => text; set - { - text = value; - dialogueList = RDDialogueExchange.Deserialize(value); - } - } - /// - /// Gets or sets the dialogue list. When set, the Text property is updated with the serialized value of the dialogue list. - /// - /// The dialogue list. - [JsonIgnore] - public RDDialogueExchange DialogueList - { - get => dialogueList; set - { - dialogueList = value; - text = dialogueList.Serialize(); - } - } - - /// - /// Gets or sets the side of the panel where the dialogue will be shown. - /// - public Sides PanelSide { get; set; } - - /// - /// Gets or sets the side of the portrait in the dialogue. - /// - public PortraitSides PortraitSide { get; set; } - - /// - /// Gets or sets the speed of the dialogue display. - /// - public int Speed { get; set; } - - /// - /// Gets or sets a value indicating whether text sounds should be played. - /// - public bool PlayTextSounds { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab where the event is categorized. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", Text); - - /// - /// Specifies the sides where the dialogue panel can be shown. - /// - public enum Sides - { - /// - /// The bottom side. - /// - Bottom, - /// - /// The top side. - /// - Top - } - - /// - /// Specifies the sides where the portrait can be shown. - /// - public enum PortraitSides - { - /// - /// The left side. - /// - Left, - /// - /// The right side. - /// - Right - } - } -} diff --git a/RhythmBaseCore/Events/ShowHands.cs b/RhythmBaseCore/Events/ShowHands.cs deleted file mode 100644 index 734e307..0000000 --- a/RhythmBaseCore/Events/ShowHands.cs +++ /dev/null @@ -1,101 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents an event to show hands in a room. - /// - public class ShowHands : BaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public ShowHands() - { - Rooms = new RDRoom(true, new byte[1]); - Type = EventType.ShowHands; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with the event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the action to be performed. - /// - public Actions Action { get; set; } - - /// - /// Gets or sets the hand of the player. - /// - public PlayerHands Hand { get; set; } - - /// - /// Gets or sets a value indicating whether the hands should be aligned. - /// - public bool Align { get; set; } - - /// - /// Gets or sets a value indicating whether the action should be instant. - /// - public bool Instant { get; set; } - - /// - /// Gets or sets the extent of the action. - /// - public Extents Extent { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Defines the possible actions for the event. - /// - public enum Actions - { - /// - /// Show the hands. - /// - Show, - - /// - /// Hide the hands. - /// - Hide, - - /// - /// Raise the hands. - /// - Raise, - - /// - /// Lower the hands. - /// - Lower - } - - /// - /// Defines the possible extents for the action. - /// - public enum Extents - { - /// - /// Full extent. - /// - Full, - - /// - /// Short extent. - /// - Short - } - } -} diff --git a/RhythmBaseCore/Events/ShowRooms.cs b/RhythmBaseCore/Events/ShowRooms.cs deleted file mode 100644 index ac78ab2..0000000 --- a/RhythmBaseCore/Events/ShowRooms.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event to show rooms. - /// - public class ShowRooms : BaseEvent, IEaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public ShowRooms() - { - Rooms = new RDRoom(false, new byte[1]); - Heights = new List(4); - Type = EventType.ShowRooms; - Tab = Tabs.Rooms; - } - - /// - /// Gets or sets the rooms associated with the event. - /// - [JsonProperty] - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the ease type for the event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets or sets the heights associated with the event. - /// - public List Heights { get; set; } - - /// - /// Gets or sets the duration of the transition. - /// - [JsonProperty("transitionTime")] - public float Duration { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - } -} diff --git a/RhythmBaseCore/Events/ShowStatusSign.cs b/RhythmBaseCore/Events/ShowStatusSign.cs deleted file mode 100644 index 5bd5bfa..0000000 --- a/RhythmBaseCore/Events/ShowStatusSign.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Newtonsoft.Json; -namespace RhythmBase.Events -{ - /// - /// Represents an event to show a status sign. - /// - public class ShowStatusSign : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public ShowStatusSign() - { - UseBeats = true; - Narrate = true; - Type = EventType.ShowStatusSign; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets a value indicating whether to use beats. - /// - public bool UseBeats { get; set; } - - /// - /// Gets or sets a value indicating whether to narrate. - /// - public bool Narrate { get; set; } - - /// - /// Gets or sets the text to display. - /// - public string Text { get; set; } = ""; - - /// - /// Gets or sets the duration of the status sign in seconds. - /// - public float Duration { get; set; } - - /// - /// Gets or sets the duration of the status sign as a . - /// - [JsonIgnore] - public TimeSpan TimeDuration - { - get - { - bool useBeats = UseBeats; - TimeSpan TimeDuration; - if (useBeats) - { - TimeDuration = TimeSpan.Zero; - } - else - { - TimeDuration = TimeSpan.FromSeconds((double)Duration); - } - return TimeDuration; - } - set - { - UseBeats = false; - Duration = (float)value.TotalSeconds; - } - } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab of the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", Text); - } -} diff --git a/RhythmBaseCore/Events/Stutter.cs b/RhythmBaseCore/Events/Stutter.cs deleted file mode 100644 index 144e146..0000000 --- a/RhythmBaseCore/Events/Stutter.cs +++ /dev/null @@ -1,75 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents a stutter event in a room. - /// - public class Stutter : BaseEvent, IRoomEvent - { - private float sourceBeat = 1; - - /// - /// Initializes a new instance of the class. - /// - public Stutter() - { - Rooms = new RDRoom(false, new byte[1]); - Type = EventType.Stutter; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the room associated with the stutter event. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the source beat of the stutter event. - /// - public float SourceBeat - { - get => sourceBeat; - set => sourceBeat = (value > 1 && value <= Beat.CPB + 1) ? value : throw new Exceptions.RhythmBaseException("SourceBeat must in CPB."); - } - /// - /// Gets or sets the length of the stutter event. - /// - public float Length { get; set; } - - /// - /// Gets or sets the action of the stutter event. - /// - public Actions Action { get; set; } - - /// - /// Gets or sets the number of loops for the stutter event. - /// - public int Loops { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Defines the possible actions for the stutter event. - /// - public enum Actions - { - /// - /// Add action. - /// - Add, - - /// - /// Cancel action. - /// - Cancel - } - } -} diff --git a/RhythmBaseCore/Events/Tabs.cs b/RhythmBaseCore/Events/Tabs.cs deleted file mode 100644 index a2ecc25..0000000 --- a/RhythmBaseCore/Events/Tabs.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Converters; -namespace RhythmBase.Events -{ - /// - /// Specifies the different tabs available in the RhythmBase application. - /// - [JsonConverter(typeof(TabsConverter))] - public enum Tabs - { - /// - /// Represents the Sounds tab. - /// - Sounds, - /// - /// Represents the Rows tab. - /// - Rows, - /// - /// Represents the Actions tab. - /// - Actions, - /// - /// Represents the Decorations tab. - /// - Decorations, - /// - /// Represents the Rooms tab. - /// - Rooms, - /// - /// Represents an unknown tab. - /// - Unknown - } -} diff --git a/RhythmBaseCore/Events/TagAction.cs b/RhythmBaseCore/Events/TagAction.cs deleted file mode 100644 index da42085..0000000 --- a/RhythmBaseCore/Events/TagAction.cs +++ /dev/null @@ -1,104 +0,0 @@ -using Newtonsoft.Json; -namespace RhythmBase.Events -{ - /// - /// Represents a tag action event. - /// - public class TagAction : BaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public TagAction() - { - Type = EventType.TagAction; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the action associated with the tag. - /// - [JsonIgnore] - public Actions Action { get; set; } - - /// - /// Gets or sets the action tag. - /// - [JsonProperty("Tag")] - public string ActionTag { get; set; } = ""; - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", ActionTag); - - /// - /// Defines the possible actions for a tag. - /// - [Flags] - public enum Actions - { - /// - /// Represents the run action. - /// - Run = 2, - - /// - /// Represents all actions. - /// - All = 1, - - /// - /// Represents the enable action. - /// - Enable = 6, - - /// - /// Represents the disable action. - /// - Disable = 4 - } - - /// - /// Defines special tags for the action. - /// - public enum SpecialTag - { -#pragma warning disable CS1591 - onHit, - onMiss, - onHeldPressHit, - onHeldReleaseHit, - onHeldPressMiss, - onHeldReleaseMiss, - row0, - row1, - row2, - row3, - row4, - row5, - row6, - row7, - row8, - row9, - row10, - row11, - row12, - row13, - row14, - row15 -#pragma warning restore CS1591 - } - } -} diff --git a/RhythmBaseCore/Events/TextExplosion.cs b/RhythmBaseCore/Events/TextExplosion.cs deleted file mode 100644 index 289603f..0000000 --- a/RhythmBaseCore/Events/TextExplosion.cs +++ /dev/null @@ -1,93 +0,0 @@ -using RhythmBase.Components; -namespace RhythmBase.Events -{ - /// - /// Represents a text explosion event in a room. - /// - public class TextExplosion : BaseEvent, IRoomEvent - { - /// - /// Initializes a new instance of the class. - /// - public TextExplosion() - { - Rooms = new RDRoom(false, new byte[1]); - Color = new PaletteColor(false); - Type = EventType.TextExplosion; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the rooms associated with the text explosion. - /// - public RDRoom Rooms { get; set; } - - /// - /// Gets or sets the color of the text explosion. - /// - public PaletteColor Color { get; set; } - - /// - /// Gets or sets the text to be displayed in the explosion. - /// - public string Text { get; set; } = ""; - - /// - /// Gets or sets the direction of the text explosion. - /// - public Directions Direction { get; set; } - - /// - /// Gets or sets the mode of the text explosion. - /// - public Modes Mode { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}", Text); - - /// - /// Specifies the direction of the text explosion. - /// - public enum Directions - { - /// - /// The text explodes to the left. - /// - Left, - - /// - /// The text explodes to the right. - /// - Right - } - - /// - /// Specifies the mode of the text explosion. - /// - public enum Modes - { - /// - /// The text explosion uses one color. - /// - OneColor, - - /// - /// The text explosion uses random colors. - /// - Random - } - } -} diff --git a/RhythmBaseCore/Events/Tile.cs b/RhythmBaseCore/Events/Tile.cs deleted file mode 100644 index 7fe5817..0000000 --- a/RhythmBaseCore/Events/Tile.cs +++ /dev/null @@ -1,91 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents a tile event in the rhythm base system. - /// - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class Tile : BaseDecorationAction, IEaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public Tile() - { - Type = EventType.Tile; - Tab = Tabs.Decorations; - } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab associated with the event. - /// - public override Tabs Tab { get; } - - /// - /// Gets or sets the position of the tile. - /// - [EaseProperty] - public RDPoint? Position { get; set; } - - /// - /// Gets or sets the tiling of the tile. - /// - [EaseProperty] - public RDPoint? Tiling { get; set; } - - /// - /// Gets or sets the speed of the tile. - /// - [EaseProperty] - public RDPoint? Speed { get; set; } - - /// - /// Gets or sets the type of tiling. - /// - public TilingTypes TilingType { get; set; } - - /// - /// Gets or sets the interval for the tiling. - /// - public float Interval { get; set; } - - /// - /// Gets or sets the Y coordinate. Always returns 0. - /// - [JsonIgnore] - public override int Y => 0; - - /// - /// Gets or sets the easing type for the event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets or sets the duration of the event. - /// - public float Duration { get; set; } - - /// - /// Defines the types of tiling available. - /// - public enum TilingTypes - { - /// - /// Represents a scrolling tiling type. - /// - Scroll, - - /// - /// Represents a pulsing tiling type. - /// - Pulse - } - } -} diff --git a/RhythmBaseCore/Events/TilingTypes.cs b/RhythmBaseCore/Events/TilingTypes.cs deleted file mode 100644 index 32f05e5..0000000 --- a/RhythmBaseCore/Events/TilingTypes.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace RhythmBase.Events -{ - /// - /// Represents the types of tiling that can be applied. - /// - public enum TilingTypes - { - /// - /// Tiling type where the content scrolls. - /// - Scroll, - - /// - /// Tiling type where the content pulses. - /// - Pulse - } -} diff --git a/RhythmBaseCore/Events/Tint.cs b/RhythmBaseCore/Events/Tint.cs deleted file mode 100644 index 7d51baa..0000000 --- a/RhythmBaseCore/Events/Tint.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; - -namespace RhythmBase.Events -{ - /// - /// Represents a Tint event which is a type of BaseDecorationAction and implements IEaseEvent. - /// - public class Tint : BaseDecorationAction, IEaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public Tint() - { - BorderColor = new PaletteColor(true); - TintColor = new PaletteColor(true) - { - Color = RDColor.White - }; - Type = EventType.Tint; - Tab = Tabs.Decorations; - } - - /// - /// Gets or sets the ease type for the tint event. - /// - public EaseType Ease { get; set; } - - /// - /// Gets or sets the border type for the tint event. - /// - public Borders Border { get; set; } - - /// - /// Gets or sets the border color for the tint event. - /// - [EaseProperty] - public PaletteColor BorderColor { get; set; } - - /// - /// Gets or sets the opacity for the tint event. - /// - [EaseProperty] - public int Opacity { get; set; } - - /// - /// Gets or sets a value indicating whether this event is a tint. - /// - [JsonProperty("tint")] - public bool IsTint { get; set; } - - /// - /// Gets or sets the tint color for the tint event. - /// - [EaseProperty] - public PaletteColor TintColor { get; set; } - - /// - /// Gets or sets the duration of the tint event. - /// - public float Duration { get; set; } - - /// - /// Gets the type of the event. - /// - public override EventType Type { get; } - - /// - /// Gets the tab where the event is categorized. - /// - public override Tabs Tab { get; } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}{1}", Border, (Border == Borders.None) ? "" : (":" + BorderColor.ToString())); - } -} diff --git a/RhythmBaseCore/Events/TintRows.cs b/RhythmBaseCore/Events/TintRows.cs deleted file mode 100644 index 069f6e2..0000000 --- a/RhythmBaseCore/Events/TintRows.cs +++ /dev/null @@ -1,114 +0,0 @@ -using Newtonsoft.Json; -using RhythmBase.Components; -using RhythmBase.Components.Easing; -namespace RhythmBase.Events -{ - /// - /// Represents an event that tints rows with specified colors and effects. - /// - public class TintRows : BaseRowAnimation, IEaseEvent - { - /// - /// Initializes a new instance of the class. - /// - public TintRows() - { - TintColor = new PaletteColor(true); - BorderColor = new PaletteColor(true); - Type = EventType.TintRows; - Tab = Tabs.Actions; - } - - /// - /// Gets or sets the tint color. - /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public PaletteColor TintColor { get; set; } - - /// - /// Gets or sets the easing type for the animation. - /// - public EaseType Ease { get; set; } - - /// - /// Gets or sets the border style. - /// - public Borders Border { get; set; } - - /// - /// Gets or sets the border color. - /// - [EaseProperty] - public PaletteColor BorderColor { get; set; } - - /// - /// Gets or sets the opacity level. - /// - [EaseProperty] - public int Opacity { get; set; } - - /// - /// Gets or sets a value indicating whether to apply tint. - /// - public bool Tint { get; set; } - - /// - /// Gets or sets the duration of the tint effect. - /// - public float Duration { get; set; } - - /// - /// Gets or sets the row effect. - /// - public RowEffect Effect { get; set; } - - /// - /// Gets the event type. - /// - public override EventType Type { get; } - - /// - /// Gets the tab category. - /// - public override Tabs Tab { get; } - - /// - /// Gets a value indicating whether to tint all rows. - /// - [JsonIgnore] - public bool TintAll - { - get - { - return Parent != null; - } - } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() => base.ToString() + string.Format(" {0}{1}", Border, (Border == Borders.None) ? "" : (":" + BorderColor.ToString())); - - /// - /// Specifies the row effects. - /// - public enum RowEffect - { - /// - /// No effect. - /// - None, - - /// - /// Electric effect. - /// - Electric, - - /// - /// Smoke effect. - /// - Smoke - } - } -} diff --git a/RhythmBaseCore/Exceptions/ConvertingException.cs b/RhythmBaseCore/Exceptions/ConvertingException.cs deleted file mode 100644 index 0c1531e..0000000 --- a/RhythmBaseCore/Exceptions/ConvertingException.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Newtonsoft.Json.Linq; -namespace RhythmBase.Exceptions -{ - /// - /// Represents errors that occur during converting operations. - /// - public class ConvertingException : RhythmBaseException - { -#pragma warning disable IDE0052 // 删除未读的私有成员 - private readonly JToken? _convertingEvent; -#pragma warning restore IDE0052 // 删除未读的私有成员 - /// - /// Initializes a new instance of the class with a specified inner exception. - /// - /// The exception that is the cause of the current exception. - public ConvertingException(Exception innerException) - : base("An exception was thrown on reading the level.", innerException) { } - - /// - /// Initializes a new instance of the class with a specified error message. - /// - /// The message that describes the error. - public ConvertingException(string message) - : base(string.Format("An exception was thrown on reading the event: {0}", message)) { } - - /// - /// Initializes a new instance of the class with a specified event and inner exception. - /// - /// The event that caused the exception. - /// The exception that is the cause of the current exception. - public ConvertingException(JToken @event, Exception innerException) - : base($"An exception was thrown on reading the event. \"{innerException}\"") - { - _convertingEvent = @event; - } - /// - /// Initializes a new instance of the class with a specified event and inner exception. - /// - /// The event that caused the exception. - /// The exception that is the cause of the current exception. - public ConvertingException(JToken @event, string message) - : base($"An exception was thrown on reading the event: {message}") - { - _convertingEvent = @event; - } - } -} diff --git a/RhythmBaseCore/Exceptions/ExpressionException.cs b/RhythmBaseCore/Exceptions/ExpressionException.cs deleted file mode 100644 index 30fffeb..0000000 --- a/RhythmBaseCore/Exceptions/ExpressionException.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace RhythmBase.Exceptions -{ - /// - /// Represents errors that occur during expression evaluation in the RhythmBase application. - /// - public class ExpressionException : RhythmBaseException - { - /// - /// Initializes a new instance of the class. - /// - public ExpressionException() - { - } - - /// - /// Initializes a new instance of the class with a specified error message. - /// - /// The message that describes the error. - public ExpressionException(string message) : base(message) - { - } - } -} diff --git a/RhythmBaseCore/Exceptions/FileExtensionMismatchException.cs b/RhythmBaseCore/Exceptions/FileExtensionMismatchException.cs deleted file mode 100644 index 70567be..0000000 --- a/RhythmBaseCore/Exceptions/FileExtensionMismatchException.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace RhythmBase.Exceptions -{ - /// - /// Exception thrown when a file extension does not match the expected extension. - /// - public class FileExtensionMismatchException : SpriteException - { - /// - /// Initializes a new instance of the class. - /// - public FileExtensionMismatchException() - { - } - - /// - /// Initializes a new instance of the class with a specified error message. - /// - /// The message that describes the error. - public FileExtensionMismatchException(string message) : base(message) - { - } - - /// - /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - /// - /// The message that describes the error. - /// The exception that is the cause of the current exception. - public FileExtensionMismatchException(string message, Exception innerException) : base(message, innerException) - { - } - } -} diff --git a/RhythmBaseCore/Exceptions/IllegalBeatException.cs b/RhythmBaseCore/Exceptions/IllegalBeatException.cs deleted file mode 100644 index 6b276d0..0000000 --- a/RhythmBaseCore/Exceptions/IllegalBeatException.cs +++ /dev/null @@ -1,25 +0,0 @@ -using RhythmBase.Events; -namespace RhythmBase.Exceptions -{ - /// - /// Exception thrown when a beat is placed in an illegal position. - /// - public class IllegalBeatException(IBarBeginningEvent item) : RhythmBaseException - { - /// - /// Gets the error message that explains the reason for the exception. - /// - public override string Message - { - get - { - return string.Format("This beat is invalid, the event {0} only allows the beat to be at the beginning of the bar.", ((BaseEvent)Item).Type); - } - } - - /// - /// Gets the event that caused the exception. - /// - public IBarBeginningEvent Item = item; - } -} diff --git a/RhythmBaseCore/Exceptions/IllegalEventTypeException.cs b/RhythmBaseCore/Exceptions/IllegalEventTypeException.cs deleted file mode 100644 index 3343931..0000000 --- a/RhythmBaseCore/Exceptions/IllegalEventTypeException.cs +++ /dev/null @@ -1,92 +0,0 @@ -using RhythmBase.Extensions; -namespace RhythmBase.Exceptions -{ - /// - /// Exception thrown when an illegal event type is encountered. - /// - public class IllegalEventTypeException : RhythmBaseException - { - /// - /// Gets the error message that explains the reason for the exception. - /// - public override string Message - { - get - { - return string.Format("Illegal type: \"{0}\"{1}", IllegalTypeName, ExtraMessage.IsNullOrEmpty() ? "." : string.Format(", {0}", ExtraMessage)); - } - } - - /// - /// Gets the extra message that provides additional information about the exception. - /// - public string ExtraMessage { get; } - - /// - /// Gets the name of the illegal type that caused the exception. - /// - public string IllegalTypeName { get; } - - /// - /// Initializes a new instance of the class with the specified type. - /// - /// The illegal type that caused the exception. - public IllegalEventTypeException(Type type) : this(type, string.Empty) - { - } - - /// - /// Initializes a new instance of the class with the specified type name. - /// - /// The name of the illegal type that caused the exception. - public IllegalEventTypeException(string type) : this(type, string.Empty) - { - } - - /// - /// Initializes a new instance of the class with the specified type and extra message. - /// - /// The illegal type that caused the exception. - /// The extra message that provides additional information about the exception. - public IllegalEventTypeException(Type type, string extraMessage) - { - IllegalTypeName = type.Name; - ExtraMessage = extraMessage; - } - - /// - /// Initializes a new instance of the class with the specified type name and extra message. - /// - /// The name of the illegal type that caused the exception. - /// The extra message that provides additional information about the exception. - public IllegalEventTypeException(string type, string extraMessage) - { - IllegalTypeName = type; - ExtraMessage = extraMessage; - } - - /// - /// Initializes a new instance of the class with the specified type, extra message, and inner exception. - /// - /// The illegal type that caused the exception. - /// The extra message that provides additional information about the exception. - /// The exception that is the cause of the current exception. - public IllegalEventTypeException(Type type, string extraMessage, Exception innerException) : base("", innerException) - { - IllegalTypeName = type.Name; - ExtraMessage = extraMessage; - } - - /// - /// Initializes a new instance of the class with the specified type name, extra message, and inner exception. - /// - /// The name of the illegal type that caused the exception. - /// The extra message that provides additional information about the exception. - /// The exception that is the cause of the current exception. - public IllegalEventTypeException(string type, string extraMessage, Exception innerException) : base("", innerException) - { - IllegalTypeName = type; - ExtraMessage = extraMessage; - } - } -} diff --git a/RhythmBaseCore/Exceptions/IllegalRowEventTypeException.cs b/RhythmBaseCore/Exceptions/IllegalRowEventTypeException.cs deleted file mode 100644 index 8e5c4e4..0000000 --- a/RhythmBaseCore/Exceptions/IllegalRowEventTypeException.cs +++ /dev/null @@ -1,27 +0,0 @@ -using RhythmBase.Events; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace RhythmBase.Exceptions -{ - /// - /// Represents an exception that is thrown when an illegal row event type is encountered. - /// - public class IllegalRowEventTypeException : RhythmBaseException - { - public EventType EventType { get; } - public RowType RowType { get; } - public override string Message => $"{EventType} is not legal for {RowType} row."; - /// - /// Initializes a new instance of the class. - /// - public IllegalRowEventTypeException(EventType eventType, RowType rowType) - { - EventType = eventType; - RowType = rowType; - } - } -} diff --git a/RhythmBaseCore/Exceptions/InvalidRDBeatException.cs b/RhythmBaseCore/Exceptions/InvalidRDBeatException.cs deleted file mode 100644 index 33e1a2c..0000000 --- a/RhythmBaseCore/Exceptions/InvalidRDBeatException.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace RhythmBase.Exceptions -{ - /// - /// Exception thrown when an invalid RD beat is encountered. - /// - public class InvalidRDBeatException : RhythmBaseException - { - /// - /// Initializes a new instance of the class. - /// - public InvalidRDBeatException() - { - Message = "The beat is invalid, possibly because the beat is not associated with the RDLevel."; - } - - /// - /// Gets the error message that explains the reason for the exception. - /// - public override string Message { get; } - } -} diff --git a/RhythmBaseCore/Exceptions/OverwriteNotAllowedException.cs b/RhythmBaseCore/Exceptions/OverwriteNotAllowedException.cs deleted file mode 100644 index e13a782..0000000 --- a/RhythmBaseCore/Exceptions/OverwriteNotAllowedException.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace RhythmBase.Exceptions -{ - /// - /// Exception thrown when an attempt to overwrite a file is not allowed. - /// - /// - /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - /// - /// The file path that caused the exception. - /// The type that caused the exception. - public class OverwriteNotAllowedException(string filepath, Type referType) : RhythmBaseException(filepath) - { - /// - /// Gets or sets the file path that caused the exception. - /// - public string FilePath { get; set; } = filepath; - - /// - /// Gets the message that describes the current exception. - /// - public override string Message => string.Format("Cannot save file '{0}' because overwriting is disabled by the settings and a file with the same name already exists.\r\nTo correct this, change the path or filename or set the OverWrite property of {1} to false.", FilePath, _referType.Name); - - private readonly Type _referType = referType; - } -} diff --git a/RhythmBaseCore/Exceptions/RhythmBaseException.cs b/RhythmBaseCore/Exceptions/RhythmBaseException.cs deleted file mode 100644 index 5c62fcf..0000000 --- a/RhythmBaseCore/Exceptions/RhythmBaseException.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace RhythmBase.Exceptions -{ - /// - /// Represents errors that occur during application execution in the RhythmBase application. - /// - public class RhythmBaseException : Exception - { - /// - /// Initializes a new instance of the class. - /// - public RhythmBaseException() - { - } - - /// - /// Initializes a new instance of the class with a specified error message. - /// - /// The message that describes the error. - public RhythmBaseException(string message) : base(message) - { - } - - /// - /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - /// - /// The message that describes the error. - /// The exception that is the cause of the current exception, or a null reference if no inner exception is specified. - public RhythmBaseException(string message, Exception innerException) : base(message, innerException) - { - } - } -} diff --git a/RhythmBaseCore/Exceptions/SpriteException.cs b/RhythmBaseCore/Exceptions/SpriteException.cs deleted file mode 100644 index fbd0e04..0000000 --- a/RhythmBaseCore/Exceptions/SpriteException.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace RhythmBase.Exceptions -{ - /// - /// Represents errors that occur during sprite operations. - /// - public class SpriteException : Exception - { - /// - /// Initializes a new instance of the class. - /// - public SpriteException() - { - } - - /// - /// Initializes a new instance of the class with a specified error message. - /// - /// The message that describes the error. - public SpriteException(string message) : base(message) - { - } - - /// - /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - /// - /// The message that describes the error. - /// The exception that is the cause of the current exception, or a null reference if no inner exception is specified. - public SpriteException(string message, Exception innerException) : base(message, innerException) - { - } - } -} diff --git a/RhythmBaseCore/Exceptions/TypeNotSupportedException.cs b/RhythmBaseCore/Exceptions/TypeNotSupportedException.cs deleted file mode 100644 index 41cc38b..0000000 --- a/RhythmBaseCore/Exceptions/TypeNotSupportedException.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace RhythmBase.Exceptions -{ - /// - /// Exception thrown when a type is not supported. - /// - [Serializable] - internal class TypeNotSupportedException : Exception - { - /// - /// Initializes a new instance of the class. - /// - public TypeNotSupportedException() - { - } - - /// - /// Initializes a new instance of the class with a specified error message. - /// - /// The message that describes the error. - public TypeNotSupportedException(string? message) : base(message) - { - } - - /// - /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - /// - /// The message that describes the error. - /// The exception that is the cause of the current exception. - public TypeNotSupportedException(string? message, Exception? innerException) : base(message, innerException) - { - } - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Exceptions/UnreadableEventException.cs b/RhythmBaseCore/Exceptions/UnreadableEventException.cs deleted file mode 100644 index 63e957e..0000000 --- a/RhythmBaseCore/Exceptions/UnreadableEventException.cs +++ /dev/null @@ -1,19 +0,0 @@ -using RhythmBase.Events; -namespace RhythmBase.Exceptions -{ - /// - /// Exception thrown when an event is unreadable. - /// - /// - /// Initializes a new instance of the class with a specified error message and the unreadable event item. - /// - /// The message that describes the error. - /// The unreadable event item. - public class UnreadableEventException(string message, IBaseEvent item) : RhythmBaseException(message) - { - /// - /// Gets the unreadable event item. - /// - public IBaseEvent Item { get; } = item; - } -} diff --git a/RhythmBaseCore/Exceptions/VersionTooLowException.cs b/RhythmBaseCore/Exceptions/VersionTooLowException.cs deleted file mode 100644 index abd7382..0000000 --- a/RhythmBaseCore/Exceptions/VersionTooLowException.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace RhythmBase.Exceptions -{ - /// - /// Exception thrown when the version is too low. - /// - public class VersionTooLowException : RhythmBaseException - { - /// - /// Gets the error message. - /// - public override string Message { get; } - - /// - /// Gets the level version that caused the exception. - /// - public int LevelVersion; - - /// - /// Initializes a new instance of the class with the specified version. - /// - /// The version that is too low. - public VersionTooLowException(int version) - { - Message = string.Format("Might not support. The version {0} is too low. Save this level with the latest version of the game to update the level version.", LevelVersion); - LevelVersion = version; - } - - /// - /// Initializes a new instance of the class with the specified version and inner exception. - /// - /// The version that is too low. - /// The exception that is the cause of the current exception. - public VersionTooLowException(int version, Exception innerException) : base(string.Empty, innerException) - { - Message = string.Format("Might not support. The version {0} is too low. Save this level with the latest version of the game to update the level version.", version); - LevelVersion = version; - } - } -} diff --git a/RhythmBaseCore/Extensions/CallCustomMethod.cs b/RhythmBaseCore/Extensions/CallCustomMethod.cs deleted file mode 100644 index 8e7e2c7..0000000 --- a/RhythmBaseCore/Extensions/CallCustomMethod.cs +++ /dev/null @@ -1,122 +0,0 @@ -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using System.Reflection; -using static RhythmBase.Extensions.Extensions; - -namespace RhythmBase.Events -{ - public partial class CallCustomMethod - { - /// - /// Contains a series of default custom method implementations. - /// - public static class Shared - { -#pragma warning disable CS1591 - public static CallCustomMethod PropertyAssignment(string propertyName, bool value) => new() { MethodName = $"{propertyName.ToLowerCamelCase()} = {value}" }; - public static CallCustomMethod RoomPropertyAssignment(byte room, string propertyName, bool value) => new() { MethodName = $"room[{room}].{propertyName.ToLowerCamelCase()} = {value}" }; - public static CallCustomMethod FunctionCalling(string functionName, params object[] @params) => new() { MethodName = $"{functionName}({ArgumentCombining(@params)})" }; - private static string ArgumentCombining(params object[] @params) => $"{string.Join(", ", @params.Select(i => - i.GetType() == typeof(string) || i.GetType().IsEnum - ? $"str:{i}" - : i.ToString() ?? ""))}"; - public static CallCustomMethod RoomFunctionCalling(byte room, string functionName, params object[] @params) => new() { MethodName = $"room[{room}].{functionName}({ArgumentCombining(@params)})" }; - private static CallCustomMethod VfxFunctionCalling(string functionName, params object[] @params) => new() { MethodName = $"vfx.{functionName}({ArgumentCombining(@params)})" }; - public static CallCustomMethod SetScoreboardLights(bool Mode, string Text) => FunctionCalling(nameof(SetScoreboardLights), Mode, Text); - public static CallCustomMethod InvisibleChars(bool value) => PropertyAssignment(nameof(InvisibleChars), value); - public static CallCustomMethod InvisibleHeart(bool value) => PropertyAssignment(nameof(InvisibleHeart), value); - public static CallCustomMethod NoHitFlashBorder(bool value) => PropertyAssignment(nameof(NoHitFlashBorder), value); - public static CallCustomMethod NoHitStrips(bool value) => PropertyAssignment(nameof(NoHitStrips), value); - public static CallCustomMethod SetOneshotType(int rowID, ShockWaveType wavetype) => FunctionCalling(nameof(SetOneshotType), rowID, wavetype); - public static CallCustomMethod WobblyLines(bool value) => PropertyAssignment(nameof(WobblyLines), value); - public static CallCustomMethod ShockwaveSizeMultiplier(bool value) => PropertyAssignment(nameof(ShockwaveSizeMultiplier), value); - public static CallCustomMethod ShockwaveDistortionMultiplier(bool value) => PropertyAssignment(nameof(ShockwaveDistortionMultiplier), value); - public static CallCustomMethod ShockwaveDurationMultiplier(bool value) => PropertyAssignment(nameof(ShockwaveDurationMultiplier), value); - public static CallCustomMethod MistakeOrHeal(float damageOrHeal) => FunctionCalling(nameof(MistakeOrHeal), damageOrHeal); - public static CallCustomMethod MistakeOrHealP1(float damageOrHeal) => FunctionCalling(nameof(MistakeOrHealP1), damageOrHeal); - public static CallCustomMethod MistakeOrHealP2(float damageOrHeal) => FunctionCalling(nameof(MistakeOrHealP2), damageOrHeal); - public static CallCustomMethod MistakeOrHealSilent(float damageOrHeal) => FunctionCalling(nameof(MistakeOrHealSilent), damageOrHeal); - public static CallCustomMethod MistakeOrHealP1Silent(float damageOrHeal) => FunctionCalling(nameof(MistakeOrHealP1Silent), damageOrHeal); - public static CallCustomMethod MistakeOrHealP2Silent(float damageOrHeal) => FunctionCalling(nameof(MistakeOrHealP2Silent), damageOrHeal); - public static CallCustomMethod SetMistakeWeight(int rowID, float weight) => FunctionCalling(nameof(SetMistakeWeight), rowID, weight); - public static CallCustomMethod DamageHeart(int rowID, float damage) => FunctionCalling(nameof(DamageHeart), rowID, damage); - public static CallCustomMethod HealHeart(int rowID, float damage) => FunctionCalling(nameof(HealHeart), rowID, damage); - public static CallCustomMethod WavyRowsAmplitude(byte roomID, float amplitude) => RoomPropertyAssignment(roomID, nameof(WavyRowsAmplitude), amplitude != 0f); - public static CallCustomMethod WavyRowsFrequency(byte roomID, float frequency) => RoomPropertyAssignment(roomID, nameof(WavyRowsFrequency), frequency != 0f); - public static CallCustomMethod SetShakeIntensityOnHit(byte roomID, int number, int strength) => RoomFunctionCalling(roomID, nameof(SetShakeIntensityOnHit), number, strength); - public static CallCustomMethod ShowPlayerHand(byte roomID, bool isPlayer1, bool isShortArm, bool isInstant) => FunctionCalling(nameof(ShowPlayerHand), roomID, isPlayer1, isShortArm, isInstant); - public static CallCustomMethod TintHandsWithInts(byte roomID, float R, float G, float B, float A) => FunctionCalling(nameof(TintHandsWithInts), roomID, R, G, B, A); - public static CallCustomMethod SetHandsBorderColor(byte roomID, float R, float G, float B, float A, int style) => FunctionCalling(nameof(SetHandsBorderColor), roomID, R, G, B, A, style); - public static CallCustomMethod SetAllHandsBorderColor(float R, float G, float B, float A, int style) => FunctionCalling(nameof(SetAllHandsBorderColor), R, G, B, A, style); - public static CallCustomMethod SetHandToP1(int room, bool rightHand) => FunctionCalling(nameof(SetHandToP1), room, rightHand); - public static CallCustomMethod SetHandToP2(int room, bool rightHand) => FunctionCalling(nameof(SetHandToP2), room, rightHand); - public static CallCustomMethod SetHandToIan(int room, bool rightHand) => FunctionCalling(nameof(SetHandToIan), room, rightHand); - public static CallCustomMethod SetHandToPaige(int room, bool rightHand) => FunctionCalling(nameof(SetHandToPaige), room, rightHand); - public static CallCustomMethod SetShadowRow(int mimickerRowID, int mimickedRowID) => FunctionCalling(nameof(SetShadowRow), mimickerRowID, mimickedRowID); - public static CallCustomMethod UnsetShadowRow(int mimickerRowID, int mimickedRowID) => FunctionCalling(nameof(UnsetShadowRow), mimickerRowID, mimickedRowID); - public static CallCustomMethod ShakeCam(int number, int strength, int roomID) => VfxFunctionCalling(nameof(ShakeCam), number, strength, roomID); - public static CallCustomMethod StopShakeCam(int roomID) => VfxFunctionCalling(nameof(StopShakeCam), roomID); - public static CallCustomMethod ShakeCamSmooth(int duration, int strength, int roomID) => VfxFunctionCalling(nameof(ShakeCamSmooth), duration, strength, roomID); - public static CallCustomMethod ShakeCamRotate(int duration, int strength, int roomID) => VfxFunctionCalling(nameof(ShakeCamRotate), duration, strength, roomID); - public static CallCustomMethod SetKaleidoscopeColor(int roomID, float R1, float G1, float B1, float R2, float G2, float B2) => FunctionCalling(nameof(SetKaleidoscopeColor), roomID, R1, G1, B1, R2, G2, B2); - public static CallCustomMethod SyncKaleidoscopes(int targetRoomID, int otherRoomID) => FunctionCalling(nameof(SyncKaleidoscopes), targetRoomID, otherRoomID); - public static CallCustomMethod SetVignetteAlpha(float alpha, int roomID) => VfxFunctionCalling(nameof(SetVignetteAlpha), alpha, roomID); - public static CallCustomMethod NoOneshotShadows(bool value) => PropertyAssignment(nameof(NoOneshotShadows), value); - public static CallCustomMethod EnableRowReflections(int roomID) => FunctionCalling(nameof(EnableRowReflections), roomID); - public static CallCustomMethod DisableRowReflections(int roomID) => FunctionCalling(nameof(DisableRowReflections), roomID); - public static CallCustomMethod ChangeCharacter(string Name, int roomID) => FunctionCalling(nameof(ChangeCharacter), Name, roomID); - public static CallCustomMethod ChangeCharacter(RDCharacters Name, int roomID) => FunctionCalling(nameof(ChangeCharacter), Name, roomID); - public static CallCustomMethod ChangeCharacterSmooth(string Name, int roomID) => FunctionCalling(nameof(ChangeCharacterSmooth), Name, roomID); - public static CallCustomMethod ChangeCharacterSmooth(RDCharacters Name, int roomID) => FunctionCalling(nameof(ChangeCharacterSmooth), Name, roomID); - public static CallCustomMethod SmoothShake(bool value) => PropertyAssignment(nameof(SmoothShake), value); - public static CallCustomMethod RotateShake(bool value) => PropertyAssignment(nameof(RotateShake), value); - public static CallCustomMethod DisableRowChangeWarningFlashes(bool value) => PropertyAssignment(nameof(DisableRowChangeWarningFlashes), value); - public static CallCustomMethod StatusSignWidth(float value) => PropertyAssignment(nameof(StatusSignWidth), value != 0f); - public static CallCustomMethod SkippableRankScreen(bool value) => PropertyAssignment(nameof(SkippableRankScreen), value); - public static CallCustomMethod MissesToCrackHeart(int value) => PropertyAssignment(nameof(MissesToCrackHeart), value != 0); - public static CallCustomMethod SkipRankText(bool value) => PropertyAssignment(nameof(SkipRankText), value); - public static CallCustomMethod AlternativeMatrix(bool value) => PropertyAssignment(nameof(AlternativeMatrix), value); - public static CallCustomMethod ToggleSingleRowReflections(byte room, byte row, bool value) => FunctionCalling(nameof(ToggleSingleRowReflections), room, row, value); - public static CallCustomMethod SetScrollSpeed(byte roomID, float speed, float duration, EaseType ease) => RoomFunctionCalling(roomID, nameof(SetScrollSpeed), speed, duration, ease); - public static CallCustomMethod SetScrollOffset(byte roomID, float cameraOffset, float duration, EaseType ease) => RoomFunctionCalling(roomID, nameof(SetScrollOffset), cameraOffset, duration, ease); - public static CallCustomMethod DarkenedRollerdisco(byte roomID, float value) => RoomFunctionCalling(roomID, nameof(DarkenedRollerdisco), value); - public static CallCustomMethod CurrentSongVol(float targetVolume, float fadeTimeSeconds) => FunctionCalling(nameof(CurrentSongVol), targetVolume, fadeTimeSeconds); - public static CallCustomMethod PreviousSongVol(float targetVolume, float fadeTimeSeconds) => FunctionCalling(nameof(PreviousSongVol), targetVolume, fadeTimeSeconds); - public static CallCustomMethod EditTree(byte room, string property, float value, float beats, EaseType ease) => RoomFunctionCalling(room, nameof(EditTree), property, value, beats, ease); - public static IEnumerable EditTree(byte room, ProceduralTree treeProperties, float beats, EaseType ease) - { - List L = []; - foreach (FieldInfo p in typeof(ProceduralTree).GetFields()) - { - float? value = (float?)p.GetValue(treeProperties); - if (value != null) - L.Add(EditTree(room, p.Name.ToLowerCamelCase(), (float)value, beats, ease)); - } - return L; - } - public static CallCustomMethod EditTreeColor(byte room, bool location, string color, float beats, EaseType ease) => RoomFunctionCalling(room, nameof(EditTreeColor), location, color, beats, ease); - public struct ProceduralTree - { - /// - /// 过程树的属性 - /// - public float? - BrachedPerlteration, - BranchesPerDivision, - IterationsPerSecond, - Thickness, - TargetLength, - MaxDeviation, - Angle, - CamAngle, - CamDistance, - CamDegreesPerSecond, - CamSpeed, - PulseIntensity, - PulseRate, - PulseWavelength; - } - } - - } -} diff --git a/RhythmBaseCore/Extensions/Comment.cs b/RhythmBaseCore/Extensions/Comment.cs deleted file mode 100644 index 0e7e4ea..0000000 --- a/RhythmBaseCore/Extensions/Comment.cs +++ /dev/null @@ -1,22 +0,0 @@ -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using static RhythmBase.Extensions.Extensions; - -namespace RhythmBase.Events -{ - public partial class Comment - { - /// - /// Contains a series of default custom method implementations. - /// - public static class Shared - { -#pragma warning disable CS1591 - private static Comment FunctionCalling(string name, params object[] @params) => new() { Text = $"()=>{name.ToLowerCamelCase()}({string.Join(',', @params.Select(i => i.ToString()))})" }; - public static Comment TrueCameraMove(int RoomID, RDPointN p, float AnimationDuration, EaseType Ease) => FunctionCalling("TrueCameraMove", (byte)RoomID, p.X, p.Y, AnimationDuration, Ease); - public static Comment Create(Particle particleName, RDPointN p) => FunctionCalling("Create", $"CustomParticles/{particleName}", p.X, p.Y); - public static Comment Shockwave(ShockWaveType type, float value) => FunctionCalling("Shockwave", type, value); - public static Comment WavyRowsAmplitude(byte roomID, float amplitude, float duration) => FunctionCalling("WavyRowsAmplitude", roomID, amplitude, duration); - } - } -} diff --git a/RhythmBaseCore/Extensions/EasePropertyExtensions.cs b/RhythmBaseCore/Extensions/EasePropertyExtensions.cs deleted file mode 100644 index 6e255bb..0000000 --- a/RhythmBaseCore/Extensions/EasePropertyExtensions.cs +++ /dev/null @@ -1,55 +0,0 @@ -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -using System.Reflection; -namespace RhythmBase.Extensions -{ - /// - /// Provides extension methods for retrieving easing properties from events. - /// - public static class EasePropertyExtensions - { - private static readonly Dictionary EaseProperties = []; - /// - /// Retrieves the easing properties of the specified type of event. - /// - /// The type of the event that implements . - /// The collection of events to retrieve the easing properties from. - /// A dictionary containing the names and corresponding easing properties of the specified event type. - /// Thrown when an unsupported property type is encountered. - public static Dictionary GetEaseProperties(this IEnumerable obj) where TEvent : IEaseEvent, new() - { - if (!EaseProperties.TryGetValue(typeof(TEvent), out PropertyInfo[]? properties)) - { - EaseProperties[obj.GetType()] = properties = typeof(TEvent).GetProperties(BindingFlags.Instance | BindingFlags.Public) - .Where(p => p.GetCustomAttribute() != null) - .ToArray(); - } - Dictionary values = []; - foreach (var property in properties) - { - if (property.PropertyType.IsAssignableFrom(typeof(RDExpression))) - { - values[property.Name] = EasePropertyFloat.CreateEaseProperty(0, [.. obj], property); - } - else if (property.PropertyType.IsAssignableFrom(typeof(RDPointE))) - { - values[property.Name] = EasePropertyPoint.CreateEaseProperty(default, [.. obj], property); - } - else if (property.PropertyType.IsAssignableFrom(typeof(RDSizeE))) - { - values[property.Name] = EasePropertySize.CreateEaseProperty(default, [.. obj], property); - } - else if (property.PropertyType.IsAssignableFrom(typeof(RDColor))) - { - values[property.Name] = EasePropertyColor.CreateEaseProperty(default, [.. obj], property); - } - else - { - throw new NotSupportedException($"Unsupported property type {property.PropertyType}"); - } - } - return values; - } - } -} diff --git a/RhythmBaseCore/Extensions/Extensions.cs b/RhythmBaseCore/Extensions/Extensions.cs deleted file mode 100644 index a510996..0000000 --- a/RhythmBaseCore/Extensions/Extensions.cs +++ /dev/null @@ -1,1068 +0,0 @@ -using Microsoft.VisualBasic.CompilerServices; -using Newtonsoft.Json.Linq; -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Exceptions; -using RhythmBase.Utils; - -using System.Diagnostics.CodeAnalysis; -using System.Reflection; -using System.Text.RegularExpressions; -namespace RhythmBase.Extensions -{ - /// - /// Extensions - /// - [StandardModule] - public static partial class Extensions - { - private static (float start, float end) GetRange(OrderedEventCollection e, Index index) - { - (float, float) GetRange; - try - { - IBaseEvent firstEvent = e.First(); - IBaseEvent lastEvent = e.Last(); - GetRange = index.IsFromEnd - ? (lastEvent.Beat._calculator!.BarBeatToBeatOnly((uint)(lastEvent.Beat.BarBeat.bar - index.Value), 1f), - lastEvent.Beat._calculator.BarBeatToBeatOnly((uint)(lastEvent.Beat.BarBeat.bar - index.Value + 1), 1f)) - : (firstEvent.Beat._calculator!.BarBeatToBeatOnly((uint)index.Value, 1f), - firstEvent.Beat._calculator.BarBeatToBeatOnly((uint)(index.Value + 1), 1f)); - } - catch - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - return GetRange; - } - private static (float start, float end) GetRange(OrderedEventCollection e, Range range) - { - (float start, float end) GetRange; - try - { - IBaseEvent firstEvent = e.First(); - IBaseEvent lastEvent = e.Last(); - GetRange = ((range.Start.IsFromEnd - ? lastEvent.Beat._calculator!.BarBeatToBeatOnly((uint)(((ulong)lastEvent.Beat.BarBeat.bar) - (ulong)((long)range.Start.Value)), 1f) - : firstEvent.Beat._calculator!.BarBeatToBeatOnly((uint)Math.Max(range.Start.Value, 1), 1f), - range.End.IsFromEnd - ? lastEvent.Beat._calculator!.BarBeatToBeatOnly((uint)(((ulong)lastEvent.Beat.BarBeat.bar) - (ulong)((long)range.End.Value) + 1UL), 1f) - : firstEvent.Beat._calculator!.BarBeatToBeatOnly((uint)(range.End.Value + 1), 1f))); - } - catch - { - throw new ArgumentOutOfRangeException(nameof(range)); - } - return GetRange; - } - /// - /// Null or equal. - /// - /// one item. - /// another item. - /// - /// - /// When neither item is empty,
Returns true only if both are equal
- /// when one of the two is empty,
Returns true.
- /// when both are empty,
Returns false.
- ///
- ///
- public static bool NullableEquals(this float? e, float? obj) => ((e != null && obj != null) && e.Value == obj.Value) || (e == null && obj == null); - /// - /// - /// - /// - public static bool IsNullOrEmpty([NotNullWhen(false)] this string? e) => e == null || e.Length == 0; - /// - /// Make strings follow the Upper Camel Case. - /// - /// The result. - public static string ToUpperCamelCase(this string e) - { - char[] S = [.. e]; - S[0] = (S[0].ToString().ToUpper()[0]); - return string.Join("", [new string(S)]); - } - /// - /// Make a specific key of a JObject follow the Upper Camel Case. - /// - internal static void ToUpperCamelCase(this JObject e, string key) - { - JToken token = e[key] ?? throw new NullReferenceException(); - e.Remove(key); - e[key.ToUpperCamelCase()] = token; - } - /// - /// Make strings follow the Lower Camel Case. - /// - /// The result. - public static string ToLowerCamelCase(this string e) - { - char[] S = [.. e]; - S[0] = (S[0].ToString().ToLower()[0]); - return string.Join("", [new string(S)]); - } - /// - /// Make a specific key of a JObject follow the Lower Camel Case. - /// - internal static void ToLowerCamelCase(this JObject e, string key) - { - JToken token = e[key] ?? throw new NullReferenceException(); - e.Remove(key); - e[key.ToLowerCamelCase()] = token; - } - /// - /// Convert color format from RGBA to ARGB - /// - public static int RgbaToArgb(this int Rgba) => (Rgba >> 8 & 16777215) | (Rgba << 24 & -16777216); - /// - /// Convert color format from ARGB to RGBA - /// - public static int ArgbToRgba(this int Argb) => (Argb >> 24 & 255) | (Argb << 8 & -256); - /// - /// Calculate the fraction of equal to the nearest floating point number. - /// - /// - /// 2.236f.FixFraction(4) == 2.25f - /// float.Pi.FixFraction(5) == 3.2f - /// float.E.Fixfraction(2) == 2.5f - /// - /// - /// - /// The float number. - /// Indicate what fraction this is. - /// - public static float FixFraction(this float beat, uint splitBase) => (float)(Math.Round((double)(beat * splitBase)) / splitBase); - /// - /// Calculate the fraction of equal to the nearest floating point number. - /// - public static RDBeat FixFraction(this RDBeat beat, uint splitBase) => new(beat.BeatOnly.FixFraction(splitBase)); - /// - /// Converting enumeration constants to in-game colors。 - /// - /// Collection - /// The in-game color. - public static RDColor ToColor(this Bookmark.BookmarkColors e) => e switch - { - Bookmark.BookmarkColors.Blue => RDColor.FromRgba(11, 125, 206), - Bookmark.BookmarkColors.Red => RDColor.FromRgba(219, 41, 41), - Bookmark.BookmarkColors.Yellow => RDColor.FromRgba(212, 212, 51), - Bookmark.BookmarkColors.Green => RDColor.FromRgba(54, 215, 54), - _ => throw new NotSupportedException(), - }; - /// - /// Add a range of events. - /// - /// Collection - /// - public static void AddRange(this OrderedEventCollection e, IEnumerable items) where TEvent : IBaseEvent - { - foreach (TEvent item in items) - e.Add(item); - } - /// - /// Filters a sequence of events based on a predicate. - /// - /// Collection - /// A function to test each event for a condition. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => - ((IEnumerable)e.eventsBeatOrder - .SelectMany(i => i.Value)).Where(predicate); - /// - /// Filters a sequence of events located at a time. - /// - /// Collection - /// Specified beat. - public static IEnumerable Where(this OrderedEventCollection e, RDBeat beat) where TEvent : IBaseEvent - { - IEnumerable Where = []; - if (e.eventsBeatOrder.TryGetValue(beat, out TypedEventCollection? value)) - Where = value.Cast().AsEnumerable(); - return Where; - } - /// - /// Filters a sequence of events located at a range of time. - /// - /// Collection - /// Specified start beat. - /// Specified end beat. - public static IEnumerable Where(this OrderedEventCollection e, RDBeat startBeat, RDBeat endBeat) where TEvent : IBaseEvent => - e.eventsBeatOrder - .TakeWhile(i => i.Key < endBeat) - .SkipWhile(i => i.Key < startBeat) - .SelectMany(i => i.Value.OfType()); - /// - /// Filters a sequence of events located at a bar. - /// - /// Collection - /// Specified bar. - public static IEnumerable Where(this OrderedEventCollection e, Index bar) where TEvent : IBaseEvent - { - var (start, end) = GetRange(e, bar); - return e.eventsBeatOrder - .TakeWhile(i => i.Key.BeatOnly < end) - .SkipWhile(i => i.Key.BeatOnly < start) - .SelectMany(i => i.Value.OfType()); - } - /// - /// Filters a sequence of events located at a range of beat. - /// - /// Collection - /// Specified beat range. - /// - public static IEnumerable Where(this OrderedEventCollection e, RDRange range) where TEvent : IBaseEvent => - (IEnumerable)e.eventsBeatOrder - .TakeWhile(i => range.End == null || i.Key < range.End) - .SkipWhile(i => range.Start != null && i.Key < range.Start) - .SelectMany(i => i.Value); - /// - /// Filters a sequence of events located at a range of bar. - /// - /// Collection - /// Specified bar range. - public static IEnumerable Where(this OrderedEventCollection e, Range bars) where TEvent : IBaseEvent - { - var (start, end) = GetRange(e, bars); - return e.eventsBeatOrder - .TakeWhile(i => i.Key.BeatOnly < end) - .SkipWhile(i => i.Key.BeatOnly < start) - .SelectMany(i => i.Value.OfType()); - } - /// - /// Filters a sequence of events based on a predicate in specified beat. - /// - /// Collection - /// A function to test each event for a condition. - /// Specified beat. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate, RDBeat beat) where TEvent : IBaseEvent => e.Where(beat).Where(predicate); - /// - /// Filters a sequence of events based on a predicate in specified range of beat. - /// - /// Collection - /// A function to test each event for a condition. - /// Specified start beat. - /// Specified end beat. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate, RDBeat startBeat, RDBeat endBeat) where TEvent : IBaseEvent => e.Where(startBeat, endBeat).Where(predicate); - /// - /// Filters a sequence of events based on a predicate in specified range of beat. - /// - /// Collection - /// A function to test each event for a condition. - /// Specified beat range. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate, RDRange range) where TEvent : IBaseEvent => e.Where(range).Where(predicate); - /// - /// Filters a sequence of events based on a predicate in specified bar. - /// - /// Collection - /// A function to test each event for a condition. - /// Specified bar. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate, Index bar) where TEvent : IBaseEvent => e.Where(bar).Where(predicate); - /// - /// Filters a sequence of events based on a predicate in specified range of bar. - /// - /// Collection - /// A function to test each event for a condition. - /// Specified bar range. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate, Range bars) where TEvent : IBaseEvent => e.Where(bars).Where(predicate); - /// - /// Filters a sequence of events in specified event type. - /// - /// - /// Collection - public static IEnumerable Where(this OrderedEventCollection e) where TEvent : IBaseEvent - { - EventType[] enums = EventTypeUtils.ToEnums(); - return e.eventsBeatOrder - .Where(i => i.Value._types - .Any(enums.Contains)) - .SelectMany(i => i.Value).OfType(); - } - /// - /// Filters a sequence of events located at a beat in specified event type. - /// - /// Specified event type. - /// Collection - /// Specified beat. - public static IEnumerable Where(this OrderedEventCollection e, RDBeat beat) where TEvent : IBaseEvent - { - TypedEventCollection value; - return (e.eventsBeatOrder.TryGetValue(beat, out value!) ? value.OfType() : []) ?? []; - } - /// - /// Filters a sequence of events located at a range of beat in specified event type. - /// - /// Specified event type. - /// Collection - /// Specified start beat. - /// Specified end beat. - public static IEnumerable Where(this OrderedEventCollection e, RDBeat startBeat, RDBeat endBeat) where TEvent : IBaseEvent => e.eventsBeatOrder - .TakeWhile(i => i.Key < endBeat) - .SkipWhile(i => i.Key < startBeat) - .SelectMany(i => i.Value.OfType()); - /// - /// Filters a sequence of events located at a bar in specified event type. - /// - /// Specified event type. - /// Collection - /// Specified bar. - public static IEnumerable Where(this OrderedEventCollection e, Index bar) where TEvent : IBaseEvent - { - (float, float) rg = GetRange(e, bar); - return e.eventsBeatOrder - .TakeWhile((KeyValuePair> i) => i.Key.BeatOnly < rg.Item2) - .SkipWhile((KeyValuePair> i) => i.Key.BeatOnly < rg.Item1) - .SelectMany(i => i.Value.OfType()); - } - /// - /// Filters a sequence of events located at a range of beat in specified event type. - /// - /// Specified event type. - /// Collection - /// Specified beat range. - public static IEnumerable Where(this OrderedEventCollection e, RDRange range) where TEvent : IBaseEvent => e.eventsBeatOrder - .TakeWhile(i => range.End == null || i.Key < range.End) - .SkipWhile(i => range.Start != null && i.Key < range.Start) - .SelectMany(i => i.Value.OfType()); - /// - /// Filters a sequence of events located at a range of bar in specified event type. - /// - /// Specified event type. - /// Collection - /// Specified bar range. - public static IEnumerable Where(this OrderedEventCollection e, Range bars) where TEvent : IBaseEvent - { - (float start, float end) = GetRange(e, bars); - return e.eventsBeatOrder - .TakeWhile(i => i.Key.BeatOnly < end) - .SkipWhile(i => i.Key.BeatOnly < start) - .SelectMany(i => i.Value.OfType()); - } - /// - /// Filters a sequence of events based on a predicate located at a range of bar in specified event type. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.Where().Where(predicate); - /// - /// Filters a sequence of events based on a predicate located at a beat in specified event type. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - /// Specified beat. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate, RDBeat beat) where TEvent : IBaseEvent => e.Where(beat).Where(predicate); - /// - /// Filters a sequence of events based on a predicate located at a range of beat in specified event type. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - /// Specified start beat. - /// Specified end beat. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate, RDBeat startBeat, RDBeat endBeat) where TEvent : IBaseEvent => e.Where(startBeat, endBeat).Where(predicate); - /// - /// Filters a sequence of events based on a predicate located at a range of beat in specified event type. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - /// Specified beat range. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate, RDRange range) where TEvent : IBaseEvent => e.Where(range).Where(predicate); - /// - /// Filters a sequence of events based on a predicate located at a bar in specified event type. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - /// Specified bar. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate, Index bar) where TEvent : IBaseEvent => e.Where(bar).Where(predicate); - /// - /// Filters a sequence of events based on a predicate located at a range of bar in specified event type. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - /// Specified bar range. - public static IEnumerable Where(this OrderedEventCollection e, Func predicate, Range bars) where TEvent : IBaseEvent => e.Where(bars).Where(predicate); - /// - /// Remove a sequence of events based on a predicate. - /// - /// Collection - /// A function to test each event for a condition. - public static int RemoveAll(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate))); - /// - /// Remove a sequence of events located at a time. - /// - /// Collection - /// Specified beat. - public static int RemoveAll(this OrderedEventCollection e, RDBeat beat) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(beat))); - /// - /// Remove a sequence of events located at a range of time. - /// - /// Collection - /// Specified start beat. - /// Specified end beat. - public static int RemoveAll(this OrderedEventCollection e, RDBeat startBeat, RDBeat endBeat) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(startBeat, endBeat))); - /// - /// Remove a sequence of events located at a bar. - /// - /// Collection - /// Specified bar. - public static int RemoveAll(this OrderedEventCollection e, Index bar) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(bar))); - /// - /// Remove a sequence of events located at a range of beat. - /// - /// Collection - /// Specified beat range. - /// - public static int RemoveAll(this OrderedEventCollection e, RDRange range) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(range))); - /// - /// Remove a sequence of events located at a range of bar. - /// - /// Collection - /// Specified bar range. - public static int RemoveAll(this OrderedEventCollection e, Range bars) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(bars))); - /// - /// Remove a sequence of events based on a predicate in specified beat. - /// - /// Collection - /// A function to test each event for a condition. - /// Specified beat. - public static int RemoveAll(this OrderedEventCollection e, Func predicate, RDBeat beat) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate, beat))); - /// - /// Remove a sequence of events based on a predicate in specified range of beat. - /// - /// Collection - /// A function to test each event for a condition. - /// Specified start beat. - /// Specified end beat. - public static int RemoveAll(this OrderedEventCollection e, Func predicate, RDBeat startBeat, RDBeat endBeat) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate, startBeat, endBeat))); - /// - /// Remove a sequence of events based on a predicate in specified range of beat. - /// - /// Collection - /// A function to test each event for a condition. - /// Specified beat range. - public static int RemoveAll(this OrderedEventCollection e, Func predicate, RDRange range) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate, range))); - /// - /// Remove a sequence of events based on a predicate in specified bar. - /// - /// Collection - /// A function to test each event for a condition. - /// Specified bar. - public static int RemoveAll(this OrderedEventCollection e, Func predicate, Index bar) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate, bar))); - /// - /// Remove a sequence of events based on a predicate in specified range of bar. - /// - /// Collection - /// A function to test each event for a condition. - /// Specified bar range. - public static int RemoveAll(this OrderedEventCollection e, Func predicate, Range bars) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate, bars))); - /// - /// Remove a sequence of events in specified event type. - /// - /// - /// Collection - public static int RemoveAll(this OrderedEventCollection e) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where())); - /// - /// Remove a sequence of events located at a beat in specified event type. - /// - /// Specified event type. - /// Collection - /// Specified beat. - public static int RemoveAll(this OrderedEventCollection e, RDBeat beat) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(beat))); - /// - /// Remove a sequence of events located at a range of beat in specified event type. - /// - /// Specified event type. - /// Collection - /// Specified start beat. - /// Specified end beat. - public static int RemoveAll(this OrderedEventCollection e, RDBeat startBeat, RDBeat endBeat) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(startBeat, endBeat))); - /// - /// Filters a sequence of events located at a range of beat in specified event type. - /// - /// Specified event type. - /// Collection - /// Specified beat range. - public static int RemoveAll(this OrderedEventCollection e, RDRange range) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(range))); - /// - /// Remove a sequence of events located at a bar in specified event type. - /// - /// Specified event type. - /// Collection - /// Specified bar. - public static int RemoveAll(this OrderedEventCollection e, Index bar) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(bar))); - /// - /// Remove a sequence of events located at a range of bar in specified event type. - /// - /// Specified event type. - /// Collection - /// Specified bar range. - public static int RemoveAll(this OrderedEventCollection e, Range bars) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(bars))); - /// - /// Remove a sequence of events based on a predicate located at a range of bar in specified event type. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - public static int RemoveAll(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate))); - /// - /// Remove a sequence of events based on a predicate located at a beat in specified event type. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - /// Specified beat. - public static int RemoveAll(this OrderedEventCollection e, Func predicate, RDBeat beat) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate, beat))); - /// - /// Remove a sequence of events based on a predicate located at a range of beat in specified event type. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - /// Specified start beat. - /// Specified end beat. - public static int RemoveAll(this OrderedEventCollection e, Func predicate, RDBeat startBeat, RDBeat endBeat) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate, startBeat, endBeat))); - /// - /// Remove a sequence of events based on a predicate located at a range of beat in specified event type. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - /// Specified beat range. - public static int RemoveAll(this OrderedEventCollection e, Func predicate, RDRange range) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate, range))); - /// - /// Filters a sequence of events based on a predicate located at a bar in specified event type. - /// - /// Specified event type. - /// A function to test each event for a condition. - /// Specified bar. - /// Collection - public static int RemoveAll(this OrderedEventCollection e, Func predicate, Index bar) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate, bar))); - /// - /// Filters a sequence of events based on a predicate located at a range of bar in specified event type. - /// - /// Specified event type. - /// A function to test each event for a condition. - /// Specified bar range. - /// Collection - public static int RemoveAll(this OrderedEventCollection e, Func predicate, Range bars) where TEvent : IBaseEvent => e.RemoveRange(new List(e.Where(predicate, bars))); - /// - /// Returns the first element of the collection. - /// - /// Collection - public static TEvent First(this OrderedEventCollection e) where TEvent : IBaseEvent => (TEvent)e.eventsBeatOrder.First().Value.First(); - /// - /// Returns the first element of the collection that satisfies a specified condition. - /// - /// A function to test each event for a condition. - /// Collection - public static TEvent First(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.ConcatAll().First(predicate); - /// - /// Returns the first element of the collection in specified event type. - /// - /// Collection - public static TEvent First(this OrderedEventCollection e) where TEvent : IBaseEvent => e.Where().First(); - /// - /// Returns the first element of the collection that satisfies a specified condition in specified event type. - /// - /// A function to test each event for a condition. - /// Collection - public static TEvent First(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.Where().First(predicate); - /// - /// Returns the first event in the collection or the default value if the collection is empty. - /// - /// The type of event in the collection. - /// The ordered event collection. - /// The first event in the collection or the default value if the collection is empty. - public static TEvent? FirstOrDefault(this OrderedEventCollection e) where TEvent : IBaseEvent - { - TypedEventCollection value = e.eventsBeatOrder.FirstOrDefault().Value; - return (TEvent?)(value?.FirstOrDefault()); - } - /// - /// Returns the first element of the collection, or if collection contains no elements. - /// - /// The default value to return if contains no elements. - /// Collection - public static TEvent? FirstOrDefault(this OrderedEventCollection e, TEvent defaultValue) where TEvent : IBaseEvent => e.ConcatAll().FirstOrDefault(defaultValue); - /// - /// Returns the first element of the collection that satisfies a specified condition, or if matches no elements. - /// - /// A function to test each event for a condition. - /// Collection - public static TEvent? FirstOrDefault(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.ConcatAll().OfType().FirstOrDefault(predicate); - /// - /// Returns the first element of the collection that satisfies a specified condition, or if matches no elements. - /// - /// A function to test each event for a condition. - /// The default value to return if matches no elements. - /// Collection - public static TEvent? FirstOrDefault(this OrderedEventCollection e, Func predicate, TEvent defaultValue) where TEvent : IBaseEvent => e.ConcatAll().FirstOrDefault(predicate, defaultValue); - /// - /// Returns the first element of the collection in specified event type, or if matches no elements. - /// - /// Specified event type. - /// Collection - public static TEvent? FirstOrDefault(this OrderedEventCollection e) where TEvent : IBaseEvent => e.Where().FirstOrDefault(); - /// - /// Returns the first element of the collection in specified event type, or if matches no elements. - /// - /// Specified event type. - /// The default value to return if matches no elements. - /// Collection - public static TEvent? FirstOrDefault(this OrderedEventCollection e, TEvent defaultValue) where TEvent : IBaseEvent => e.Where().FirstOrDefault(defaultValue); - /// - /// Returns the first element of the collection that satisfies a specified condition in specified event type, or if matches no elements. - /// - /// Specified event type. - /// A function to test each event for a condition. - /// Collection - public static TEvent? FirstOrDefault(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.Where().FirstOrDefault(predicate); - /// - /// Returns the first element of the collection that satisfies a specified condition in specified event type, or if matches no elements. - /// - /// Specified event type. - /// A function to test each event for a condition. - /// The default value to return if matches no elements. - /// Collection - public static TEvent? FirstOrDefault(this OrderedEventCollection e, Func predicate, TEvent defaultValue) where TEvent : IBaseEvent => e.Where().FirstOrDefault(predicate, defaultValue); - /// - /// Returns the last element of the collection. - /// - public static TEvent Last(this OrderedEventCollection e) where TEvent : IBaseEvent => (TEvent)e.eventsBeatOrder.Last().Value.Last(); - /// - /// Returns the last element of the collection that satisfies a specified condition. - /// - /// A function to test each event for a condition. - /// Collection - public static TEvent Last(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.ConcatAll().Last(predicate); - /// - /// Returns the last element of the collection in specified event type. - /// - /// Collection - public static TEvent Last(this OrderedEventCollection e) where TEvent : IBaseEvent => e.Where().Last(); - /// - /// Returns the last element of the collection that satisfies a specified condition in specified event type. - /// - /// A function to test each event for a condition. - /// Collection - public static TEvent Last(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.Where().Last(predicate); - /// - /// Returns the last element of the collection, or if collection contains no elements. - /// - public static TEvent? LastOrDefault(this OrderedEventCollection e) where TEvent : IBaseEvent - { - IEnumerable value = e.eventsBeatOrder.LastOrDefault().Value.AsEnumerable(); - return (TEvent?)(value?.LastOrDefault()); - } - /// - /// Returns the last element of the collection, or if collection contains no elements. - /// - /// Collection - /// The default value to return if contains no elements. - public static TEvent LastOrDefault(this OrderedEventCollection e, TEvent defaultValue) where TEvent : IBaseEvent => e.ConcatAll().LastOrDefault(defaultValue); - /// - /// Returns the last element of the collection that satisfies a specified condition, or if matches no elements. - /// - /// Collection - /// A function to test each event for a condition. - public static TEvent? LastOrDefault(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.ConcatAll().LastOrDefault(predicate); - /// - /// Returns the last element of the collection that satisfies a specified condition, or if matches no elements. - /// - /// Collection - /// A function to test each event for a condition. - /// The default value to return if matches no elements. - public static TEvent LastOrDefault(this OrderedEventCollection e, Func predicate, TEvent defaultValue) where TEvent : IBaseEvent => e.ConcatAll().LastOrDefault(predicate, defaultValue); - /// - /// Returns the last element of the collection in specified event type, or if matches no elements. - /// - /// Specified event type. - /// Collection - public static TEvent? LastOrDefault(this OrderedEventCollection e) where TEvent : IBaseEvent => e.Where().LastOrDefault(); - /// - /// Returns the last element of the collection in specified event type, or if matches no elements. - /// - /// Specified event type. - /// Collection - /// The default value to return if matches no elements. - public static TEvent LastOrDefault(this OrderedEventCollection e, TEvent defaultValue) where TEvent : IBaseEvent => e.Where().LastOrDefault(defaultValue); - /// - /// Returns the last element of the collection that satisfies a specified condition in specified event type, or if matches no elements. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - public static TEvent? LastOrDefault(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.Where().LastOrDefault(predicate); - /// - /// Returns the last element of the collection that satisfies a specified condition in specified event type, or if matches no elements. - /// - /// Specified event type. - /// Collection - /// A function to test each event for a condition. - /// The default value to return if matches no elements. - public static TEvent LastOrDefault(this OrderedEventCollection e, Func predicate, TEvent defaultValue) where TEvent : IBaseEvent => e.Where().LastOrDefault(predicate, defaultValue); - /// - /// Returns events from a collection as long as it less than or equal to . - /// - /// Collection - /// Specified beat. - public static IEnumerable TakeWhile(this OrderedEventCollection e, RDBeat beat) where TEvent : IBaseEvent - { - foreach (TEvent item in e.Where()) - if (item.Beat <= beat) yield return item; - else break; - } - /// - /// Returns events from a collection as long as it less than or equal to . - /// - /// Collection - /// Specified bar. - public static IEnumerable TakeWhile(this OrderedEventCollection e, Index bar) where TEvent : IBaseEvent - { - TEvent firstEvent = e.First(); - TEvent lastEvent = e.Last(); - return e.TakeWhile(checked(bar.IsFromEnd - ? lastEvent.Beat._calculator!.BeatOf((uint)(lastEvent.Beat.BarBeat.bar - (uint)bar.Value + 1U), 1f) - : firstEvent.Beat._calculator!.BeatOf((uint)(bar.Value + 1), 1f))); - } - /// - /// Returns events from a collection as long as a specified condition is true. - /// - /// Collection - /// A function to test each event for a condition. - public static IEnumerable TakeWhile(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => - (IEnumerable)e.eventsBeatOrder - .SelectMany(i => i.Value) - .TakeWhile((Func)(object)predicate); - /// - /// Returns events from a collection as long as a specified condition is true and also less than or equal to . - /// - /// A function to test each event for a condition. - /// Collection - /// Specified beat. - public static IEnumerable TakeWhile(this OrderedEventCollection e, Func predicate, RDBeat beat) where TEvent : IBaseEvent => e.TakeWhile(beat).TakeWhile(predicate); - /// - /// Returns events from a collection as long as a specified condition is true and also less than or equal to . - /// - /// A function to test each event for a condition. - /// Collection - /// Specified bar. - public static IEnumerable TakeWhile(this OrderedEventCollection e, Func predicate, Index bar) where TEvent : IBaseEvent => e.TakeWhile(bar).TakeWhile(predicate); - /// - /// Returns events from a collection in specified event type as long as it less than or equal to . - /// - /// Specified event type. - /// Collection - /// Specified beat. - public static IEnumerable TakeWhile(this OrderedEventCollection e, RDBeat beat) where TEvent : IBaseEvent - { - foreach (TEvent item in e.Where()) - if (item.Beat <= beat) yield return item; - else break; - } - /// - /// Returns events from a collection in specified event type as long as it less than or in . - /// - /// Specified event type. - /// Collection - /// Specified bar. - public static IEnumerable TakeWhile(this OrderedEventCollection e, Index bar) where TEvent : IBaseEvent - { - IBaseEvent firstEvent = e.First(); - IBaseEvent lastEvent = e.Last(); - return e.TakeWhile(checked(bar.IsFromEnd - ? lastEvent.Beat._calculator!.BeatOf((uint)(lastEvent.Beat.BarBeat.bar - (ulong)bar.Value + 1U), 1f) - : firstEvent.Beat._calculator!.BeatOf((uint)(bar.Value + 1), 1f))); - } - /// - /// Returns events from a collection in specified event type as long as a specified condition is true. - /// - /// Specified event type. - /// Collection - /// Specified condition. - public static IEnumerable TakeWhile(this OrderedEventCollection e, Func predicate) where TEvent : IBaseEvent => e.Where().TakeWhile(predicate); - /// - /// Returns events from a collection in specified event type as long as a specified condition is true and its beat less than or equal to . - /// - /// Specified event type. - /// Collection - /// Specified condition. - /// Specified beat. - public static IEnumerable TakeWhile(this OrderedEventCollection e, Func predicate, RDBeat beat) where TEvent : IBaseEvent => e.TakeWhile(beat).TakeWhile(predicate); - /// - /// Returns events from a collection in specified event type as long as a specified condition is true and its beat less than or equal to . - /// - /// Specified event type. - /// Collection - /// Specified condition. - /// Specified beat. - public static IEnumerable TakeWhile(this OrderedEventCollection e, Func predicate, Index bar) where TEvent : IBaseEvent => e.TakeWhile(bar).TakeWhile(predicate); - /// - /// Remove a range of events. - /// - /// Collection - /// A range of events. - /// The number of events successfully removed. - public static int RemoveRange(this OrderedEventCollection e, IEnumerable items) where TEvent : IBaseEvent - { - int count = 0; - foreach (var item in items) - count += e.Remove(item) ? 1 : 0; - return count; - } - /// - /// Remove a range of events. - /// - /// Collection - /// A range of events. - /// The number of events successfully removed. - public static int RemoveRange(this OrderedEventCollection e, IEnumerable items) where TEvent : IBaseEvent - { - int count = 0; - foreach (var item in items) - count += e.Remove(item) ? 1 : 0; - return count; - } - - /// - /// Get all the hit of the level. - /// - public static IEnumerable GetHitBeat(this RDLevel e) - { - List L = []; - foreach (RowEventCollection item in e.Rows) - { - L.AddRange(item.HitBeats()); - } - return L; - } - /// - /// Get all the hit event of the level. - /// - public static IEnumerable GetHitEvents(this RDLevel e) => e.Where(IsHitable); - /// - /// Get all events with the specified tag. - /// - /// Collection - /// Tag name. - /// Indicates whether the label is strictly matched. - /// If , determine If it contains the specified tag. - /// If , determine If it Is equal to the specified tag. - /// An , categorized by tag name. - public static IEnumerable> GetTaggedEvents(this OrderedEventCollection e, string name, bool strict) where TEvent : IBaseEvent - { - if (name.IsNullOrEmpty()) - return []; - if (strict) - return e - .Where(i => i.Tag == name).GroupBy(i => i.Tag); - else - return e - .Where(i => i.Tag?.Contains(name) ?? false).GroupBy(i => i.Tag); - } - /// - /// Get all classic beat events and their variants. - /// - private static IEnumerable ClassicBeats(this RowEventCollection e) => e.Where((BaseBeat i) => i.Type == EventType.AddClassicBeat | i.Type == EventType.AddFreeTimeBeat | i.Type == EventType.PulseFreeTimeBeat); - /// - /// Get all oneshot beat events. - /// - private static IEnumerable OneshotBeats(this RowEventCollection e) => e.Where((BaseBeat i) => i.Type == EventType.AddOneshotBeat); - /// - /// Get all hits of all beats. - /// - public static IEnumerable HitBeats(this RowEventCollection e) - { - RowType rowType = e.RowType; - IEnumerable HitBeats; - if (rowType != RowType.Classic) - { - if (rowType != RowType.Oneshot) - throw new RhythmBaseException("How?"); - HitBeats = e.OneshotBeats().SelectMany((BaseBeat i) => i.HitTimes()); - } - else - HitBeats = e.ClassicBeats().SelectMany((BaseBeat i) => i.HitTimes()); - return HitBeats; - } - /// - /// Get an instance of the beat associated with the level. - /// - /// RDLevel - /// Total number of 1-based beats. - public static RDBeat BeatOf(this RDLevel e, float beatOnly) => e.Calculator.BeatOf(beatOnly); - /// - /// Get an instance of the beat associated with the level. - /// - /// RDLevel - /// The 1-based bar. - /// The 1-based beat of the bar. - public static RDBeat BeatOf(this RDLevel e, uint bar, float beat) => e.Calculator.BeatOf(bar, beat); - /// - /// Get an instance of the beat associated with the level. - /// - /// RDLevel - /// Total time span of the beat. - public static RDBeat BeatOf(this RDLevel e, TimeSpan timeSpan) => e.Calculator.BeatOf(timeSpan); - /// - /// Get the row beat status - /// - /// - /// - /// - /// - public static SortedDictionary GetRowBeatStatus(this RowEventCollection e) - { - SortedDictionary L = []; - RowType rowType = e.RowType; - switch (rowType) - { - case RowType.Classic: - int[] value = new int[7]; - L.Add(0f, value); - foreach (IBaseEvent beat in e) - switch (beat.Type) - { - case EventType.AddClassicBeat: - AddClassicBeat trueBeat = (AddClassicBeat)beat; - int i = 0; - do - { - int[] statusArray = L[beat.Beat.BeatOnly] ?? new int[7]; - int[] array = statusArray; - int num = i; - ref int ptr = ref array[num]; - array[num] = ptr + 1; - L[beat.Beat.BeatOnly] = statusArray; - i++; - } - while (i <= 6); - break; - default: - throw new NotImplementedException(); - } - break; - case RowType.Oneshot: - throw new NotImplementedException(); - default: - throw new RhythmBaseException("How"); - } - return L; - } - /// - /// Get all beats of the row. - /// - public static IEnumerable Beats(this RowEventCollection e) - { - RowType rowType = e.RowType; - IEnumerable Beats; - if (rowType != RowType.Classic) - { - if (rowType != RowType.Oneshot) - throw new RhythmBaseException("How?"); - Beats = e.OneshotBeats(); - } - else - Beats = e.ClassicBeats(); - return Beats; - } - - /// - /// Returns all previous events of the same type, including events of the same beat but executed before itself. - /// - public static IEnumerable Before(this TEvent e) where TEvent : IBaseEvent => e.Beat.BaseLevel?.Where(e.Beat.BaseLevel.DefaultBeat, e.Beat) ?? []; - /// - /// Returns all previous events of the specified type, including events of the same beat but executed before itself. - /// - public static IEnumerable Before(this IBaseEvent e) where TEvent : IBaseEvent => e.Beat.BaseLevel?.Where(e.Beat.BaseLevel.DefaultBeat, e.Beat) ?? []; - /// - /// Returns all events of the same type that follow, including events of the same beat but executed after itself. - /// - public static IEnumerable After(this TEvent e) where TEvent : IBaseEvent => e.Beat.BaseLevel?.Where(i => i.Beat > e.Beat) ?? []; - /// - /// Returns all events of the specified type that follow, including events of the same beat but executed after itself. - /// - public static IEnumerable After(this IBaseEvent e) where TEvent : IBaseEvent => e.Beat.BaseLevel?.Where(i => i.Beat > e.Beat) ?? []; - /// - /// Returns the previous event of the same type, including events of the same beat but executed before itself. - /// - public static TEvent Front(this TEvent e) where TEvent : IBaseEvent => e.Before().Last(); - /// - /// Returns the previous event of the specified type, including events of the same beat but executed before itself. - /// - public static TEvent Front(this IBaseEvent e) where TEvent : IBaseEvent => e.Before().Last(); - /// - /// Returns the previous event of the same type, including events of the same beat but executed before itself. Returns if it does not exist. - /// - public static TEvent? FrontOrDefault(this TEvent e) where TEvent : IBaseEvent => e.Before().LastOrDefault(); - /// - /// Returns the previous event of the specified type, including events of the same beat but executed before itself. Returns if it does not exist. - /// - public static TEvent? FrontOrDefault(this IBaseEvent e) where TEvent : IBaseEvent => e.Before().LastOrDefault(); - /// - /// Returns the next event of the same type, including events of the same beat but executed after itself. - /// - public static TEvent Next(this TEvent e) where TEvent : IBaseEvent => e.After().First(); - /// - /// Returns the next event of the specified type, including events of the same beat but executed after itself. - /// - public static TEvent Next(this IBaseEvent e) where TEvent : IBaseEvent => e.After().First(); - /// - /// Returns the next event of the same type, including events of the same beat but executed after itself. Returns if it does not exist. - /// - public static TEvent? NextOrDefault(this TEvent e) where TEvent : IBaseEvent => e.After().FirstOrDefault(); - /// - /// Returns the next event of the specified type, including events of the same beat but executed after itself. Returns if it does not exist. - /// - public static TEvent? NextOrDefault(this IBaseEvent e) where TEvent : IBaseEvent => e.After().FirstOrDefault(); //? - - /// - /// Shallow copy. - /// - public static TEvent MemberwiseClone(this TEvent e) where TEvent : IBaseEvent, new() => (TEvent)e.MClone(); - internal static object MClone(this object e) - { - if (e != null) - { - Type type = e.GetType(); - object copy = Activator.CreateInstance(type)!; - PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - foreach (PropertyInfo p in properties) - { - if (p.CanWrite) - { - p.SetValue(copy, p.GetValue(e)); - } - } - return copy; - } - throw new NullReferenceException(); - } -#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 - public enum Wavetype - { - BoomAndRush, - Spring, - Spike, - SpikeHuge, - Ball, - Single - } - public enum ShockWaveType - { - size, - distortion, - duration - } - public enum Particle - { - HitExplosion, - leveleventexplosion - } -#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 - } -} diff --git a/RhythmBaseCore/Extensions/SpecificEventExtensions.cs b/RhythmBaseCore/Extensions/SpecificEventExtensions.cs deleted file mode 100644 index ff2092f..0000000 --- a/RhythmBaseCore/Extensions/SpecificEventExtensions.cs +++ /dev/null @@ -1,587 +0,0 @@ -using RhythmBase.Components; -using RhythmBase.Components.Easing; -using RhythmBase.Events; -using RhythmBase.Exceptions; -using RhythmBase.Extensions; -using System.Text.RegularExpressions; - -namespace RhythmBase.Extensions -{ - public static partial class Extensions - { - /// - /// Get the pulse sound effect of row beat event. - /// - /// The sound effect of row beat event. - public static RDAudio BeatSound(this BaseBeat e) - { - SetBeatSound? setBeatSound = e.Parent?.LastOrDefault((SetBeatSound i) => i.Beat < e.Beat && i.Active); - return (setBeatSound?.Sound) ?? e.Parent?.Sound ?? throw new NotImplementedException(); - } - /// - /// Getting controlled events. - /// - public static IEnumerable> ControllingEvents(this TagAction e) => e.Beat.BaseLevel?.GetTaggedEvents(e.ActionTag, e.Action.HasFlag(TagAction.Actions.All)) ?? []; - /// - /// Creates a new subordinate to at the specified beat. The new event created will be attempted to be added to the 's source level. - /// - /// RDLevel - /// Specified beat. - public static AdvanceText CreateAdvanceText(this FloatingText e, RDBeat beat) - { - AdvanceText A = new() - { - Parent = e, - Beat = beat.WithoutBinding() - }; - e.Children.Add(A); - return A; - } - /// - /// Get the end beat of the duration. - /// - /// - /// - /// - /// - public static RDBeat DurationOffset(this RDBeat beat, float duration) - { - SetBeatsPerMinute setBPM = beat.BaseLevel?.First((SetBeatsPerMinute i) => i.Beat > beat) ?? throw new InvalidRDBeatException(); - RDBeat DurationOffset = - beat.BarBeat.bar == setBPM.Beat.BarBeat.bar - ? beat + duration - : beat + TimeSpan.FromMinutes(duration / beat.BPM); - return DurationOffset; - } - /// - /// Returns the pulse beat of the specified 0-based index. - /// - /// THIS IS 7TH BEAT GAMES! - public static RDBeat GetBeat(this AddClassicBeat e, byte index) - { - SetRowXs x = e.Parent?.LastOrDefault((SetRowXs i) => i.Active && e.IsBehind(i)) ?? new(); - float Synco = 0 <= x.SyncoBeat && x.SyncoBeat < (sbyte)index ? (float)((x.SyncoSwing == 0f) ? 0.5 : ((double)x.SyncoSwing)) : 0f; - if (index >= 7) - throw new RhythmBaseException("THIS IS 7TH BEAT GAMES!"); - return e.Beat.DurationOffset(e.Tick * ((float)index - Synco)); - } - /// - /// Converts Xs patterns to string form. - /// - public static string GetPatternString(this SetRowXs e) => Utils.Utils.GetPatternString(e.Pattern); - /// - /// Get the sequence of belonging to this , return all of the from the time the pulse was created to the time it was removed or hit. - /// - public static IEnumerable GetPulses(this AddFreeTimeBeat e) - { - List Result = []; - byte pulse = e.Pulse; - if (e.Parent == null) - yield break; - foreach (PulseFreeTimeBeat item in e.Parent.Where(i => i.Active && e.IsInFrontOf(i))) - { - switch (item.Action) - { - case PulseFreeTimeBeat.ActionType.Increment: - pulse += 1; - yield return item; - break; - case PulseFreeTimeBeat.ActionType.Decrement: - pulse = (byte)((pulse > 0b1) ? (pulse - 0b1) : 0b1); - yield return item; - break; - case PulseFreeTimeBeat.ActionType.Custom: - pulse = (byte)item.CustomPulse; - yield return item; - break; - case PulseFreeTimeBeat.ActionType.Remove: - yield return item; - break; - } - if (pulse == 6) - break; - } - } - /// - /// Get the hit sound effect of row beat event. - /// - /// The sound effect of row beat event. - public static RDAudio HitSound(this BaseBeat e) - { - RDAudio DefaultAudio = new() - { - Filename = "sndClapHit", - Offset = TimeSpan.Zero, - Pan = 100, - Pitch = 100, - Volume = 100 - }; - RDAudio? HitSound; - switch (e.Player()) - { - case PlayerType.P1: - { - SetClapSounds? setClapSounds = e.Beat.BaseLevel?.LastOrDefault((SetClapSounds i) => i.Active && i.P1Sound != null); - HitSound = (setClapSounds?.P1Sound) ?? DefaultAudio; - break; - } - case PlayerType.P2: - { - SetClapSounds? setClapSounds2 = e.Beat.BaseLevel?.LastOrDefault((SetClapSounds i) => i.Active && i.P2Sound != null); - HitSound = (setClapSounds2?.P2Sound) ?? DefaultAudio; - break; - } - case PlayerType.CPU: - { - SetClapSounds? setClapSounds3 = e.Beat.BaseLevel?.LastOrDefault((SetClapSounds i) => i.Active && i.CpuSound != null); - HitSound = (setClapSounds3?.CpuSound) ?? DefaultAudio; - break; - } - default: - HitSound = DefaultAudio; - break; - } - return HitSound; - } - /// - /// Get all hits. - /// - public static IEnumerable HitTimes(this AddClassicBeat e) => - new List { new(e, e.GetBeat(6), e.Hold) } - .AsEnumerable(); - /// - /// Get all hits. - /// - public static IEnumerable HitTimes(this AddOneshotBeat e) - { - e._beat.IfNullThrowException(); - List L = []; - uint loops = e.Loops; - for (uint i = 0U; i <= loops; i += 1U) - { - sbyte b = (sbyte)(e.Subdivisions - 1); - for (sbyte j = 0; j <= b; j += 1) - L.Add(new RDHit(e, new RDBeat(e._beat._calculator, e._beat.BeatOnly + i * e.Interval + e.Tick + e.Delay + (float)j * (e.Tick / (float)e.Subdivisions)), 0f)); - } - return L.AsEnumerable(); - } - /// - /// Get all hits. - /// - public static IEnumerable HitTimes(this AddFreeTimeBeat e) => - e.Pulse == 6 - ? [new(e, e.Beat, e.Hold)] - : ([]); - /// - /// Get all hits. - /// - public static IEnumerable HitTimes(this PulseFreeTimeBeat e) => -e.IsHitable() - ? [new(e, e.Beat, e.Hold)] - : ([]); - /// - /// Get all hits. - /// - public static IEnumerable HitTimes(this BaseBeat e) => e.Type switch - { - EventType.AddClassicBeat => ((AddClassicBeat)e).HitTimes(), - EventType.AddFreeTimeBeat => ((AddFreeTimeBeat)e).HitTimes(), - EventType.AddOneshotBeat => ((AddOneshotBeat)e).HitTimes(), - _ => e.Type != EventType.PulseFreeTimeBeat - ? Array.Empty().AsEnumerable() - : ((PulseFreeTimeBeat)e).HitTimes(), - }; - /// - /// Determine if is after - /// - /// - /// If is after , - /// Else, - /// - public static bool IsBehind(this OrderedEventCollection e, IBaseEvent item1, IBaseEvent item2) => (item1.Beat > item2.Beat || (item1.Beat.BeatOnly == item2.Beat.BeatOnly && (e.eventsBeatOrder[item1.Beat].BeforeThan(item2, item1)))); - /// - /// Check if another event is after itself, including events of the same beat but executed after itself. - /// - public static bool IsBehind(this IBaseEvent e, IBaseEvent item) => e.Beat.BaseLevel?.IsBehind(e, item) ?? throw new InvalidRDBeatException(); - /// - /// Check if it can be hit by player. - /// - public static bool IsHitable(this PulseFreeTimeBeat e) - { - int PulseIndexMin = 6; - int PulseIndexMax = 6; - if (e.Parent is null) - return false; - foreach (BaseBeat item in ((IEnumerable)e.Parent - .Where(e.IsBehind, new RDRange(e.Beat, null))) - .Reverse()) - { - EventType type = item.Type; - switch (type) - { - case EventType.AddFreeTimeBeat: - { - AddFreeTimeBeat Temp2 = (AddFreeTimeBeat)item; - if (PulseIndexMin <= (int)Temp2.Pulse & (int)Temp2.Pulse <= PulseIndexMax) - return true; - break; - } - case EventType.PulseFreeTimeBeat: - { - PulseFreeTimeBeat Temp = (PulseFreeTimeBeat)item; - switch (Temp.Action) - { - case PulseFreeTimeBeat.ActionType.Increment: - if (PulseIndexMin > 0) - PulseIndexMin--; - if (!(PulseIndexMax > 0)) - return false; - PulseIndexMax--; - break; - case PulseFreeTimeBeat.ActionType.Decrement: - if (PulseIndexMin > 0) - PulseIndexMin++; - if (!(PulseIndexMax < 6)) - return false; - PulseIndexMax++; - break; - case PulseFreeTimeBeat.ActionType.Custom: - if (!(PulseIndexMin <= Temp.CustomPulse & Temp.CustomPulse <= PulseIndexMax)) - return false; - PulseIndexMin = 0; - PulseIndexMax = 5; - break; - case PulseFreeTimeBeat.ActionType.Remove: - return false; - } - if (PulseIndexMin > PulseIndexMax) - return false; - break; - } - } - } - return false; - } - /// - /// Check if it can be hit by player. - /// - public static bool IsHitable(this AddFreeTimeBeat e) => e.Pulse == 6; - /// - /// Check if it can be hit by player. - /// - public static bool IsHitable(this BaseBeat e) => e.Type switch - { - EventType.AddClassicBeat or EventType.AddOneshotBeat => true, - EventType.AddFreeTimeBeat => ((AddFreeTimeBeat)e).IsHitable(), - _ => e.Type == EventType.PulseFreeTimeBeat && ((PulseFreeTimeBeat)e).IsHitable(), - }; - /// - /// Determine if is in front of - /// - /// - /// If is in front of , - /// Else, - /// - public static bool IsInFrontOf(this OrderedEventCollection e, IBaseEvent item1, IBaseEvent item2) => (item1.Beat < item2.Beat || (item1.Beat.BeatOnly == item2.Beat.BeatOnly && (e.eventsBeatOrder[item1.Beat].BeforeThan(item1, item2)))); - /// - /// Check if another event is in front of itself, including events of the same beat but executed before itself. - /// - public static bool IsInFrontOf(this IBaseEvent e, IBaseEvent item) => e.Beat.BaseLevel?.IsInFrontOf(e, item) ?? throw new InvalidRDBeatException(); - /// - /// Get the total length of the oneshot. - /// - /// - public static float Length(this AddOneshotBeat e) => e.Tick * e.Loops + e.Interval * e.Loops - 1f; - /// - /// Get the total length of the classic beat. - /// - /// - public static float Length(this AddClassicBeat e) - { - float SyncoSwing = e.Parent?.LastOrDefault((SetRowXs i) => i.Active && e.IsBehind(i))?.SyncoSwing ?? 0; - return (float)((double)(e.Tick * 6f) - ((SyncoSwing == 0f) ? 0.5 : ((double)SyncoSwing)) * (double)e.Tick); - } - /// - /// Specifies the position of the image. This method changes both the pivot and the angle to keep the image visually in its original position. - /// - /// Sprite size. - /// RDLevel - /// Specified position. - public static void MovePositionMaintainVisual(this Move e, RDSizeE spriteSize, RDPointE target) - { - if (e.Position != null && e.Pivot != null && e.Angle != null && e.Angle.Value.IsNumeric) - { - e.Position = new RDPointE?(target); - e.Pivot = new RDPointE?((e.VisualPosition(spriteSize) - new RDSizeE(target)).Rotate(e.Angle.Value.NumericValue)); - } - } - /// - /// Specifies the position of the image. This method changes both the pivot and the angle to keep the image visually in its original position. - /// - /// RDLevel - /// Specified position. - public static void MovePositionMaintainVisual(this MoveRoom e, RDSizeE target) - { - if (e.RoomPosition != null && e.Pivot != null && e.Angle != null && e.Angle.Value.IsNumeric) - { - e.RoomPosition = new RDPointE?((RDPointE)target); - e.Pivot = new RDPointE?((e.VisualPosition() - new RDSizeE((RDPointE)target)).Rotate(e.Angle.Value.NumericValue)); - } - } - /// - /// Convert beat pattern to string. - /// - /// The pattern string. - public static string Pattern(this AddClassicBeat e) => Utils.Utils.GetPatternString(e.RowXs()); - /// - /// Get current player of the beat event. - /// - /// - /// - public static PlayerType Player(this BaseBeat e) - { - ChangePlayersRows? changePlayersRows = e.Beat.BaseLevel?.LastOrDefault((ChangePlayersRows i) => i.Active && i.Players[e.Index] != PlayerType.NoChange); - return (changePlayersRows != null) - ? changePlayersRows.Players[e.Index] - : (PlayerType)(e.Parent?.Player ?? throw new NotImplementedException()); - } - /// - /// Get the actual beat pattern. - /// - /// The actual beat pattern. - public static Patterns[] RowXs(this AddClassicBeat e) - { - if (e.SetXs == null) - { - SetRowXs X = e.Parent?.LastOrDefault((SetRowXs i) => i.Active && e.IsBehind(i)) ?? new(); - return X.Pattern; - } - else - { - Patterns[] T = new Patterns[6]; - AddClassicBeat.ClassicBeatPatterns? setXs = e.SetXs; - int? num = (setXs != null) ? new int?((int)setXs.GetValueOrDefault()) : null; - if (((num != null) ? new bool?(num.GetValueOrDefault() == 0) : null).GetValueOrDefault()) - { - T[1] = Patterns.X; - T[2] = Patterns.X; - T[4] = Patterns.X; - T[5] = Patterns.X; - } - else - { - num = (setXs != null) ? new int?((int)setXs.GetValueOrDefault()) : null; - if (!(((num != null) ? new bool?(num.GetValueOrDefault() == 1) : null).GetValueOrDefault())) - { - throw new RhythmBaseException("How?"); - } - T[1] = Patterns.X; - T[3] = Patterns.X; - T[5] = Patterns.X; - } - return T; - } - } - /// - /// Get the special tag of the tag event. - /// - /// special tags. - public static TagAction.SpecialTag[] SpetialTags(this TagAction e) => (TagAction.SpecialTag[])(from i in Enum.GetValues() - where e.ActionTag.Contains(string.Format("[{0}]", i)) - select i); - /// - /// Generate split event instances. - /// - public static IEnumerable Split(this SayReadyGetSetGo e) => e.PhraseToSay switch - { - SayReadyGetSetGo.Words.SayReaDyGetSetGoNew => [ -e.SplitCopy(0f, SayReadyGetSetGo.Words.JustSayRea), -e.SplitCopy(e.Tick, SayReadyGetSetGo.Words.JustSayDy), -e.SplitCopy(e.Tick * 2f, SayReadyGetSetGo.Words.JustSayGet), -e.SplitCopy(e.Tick * 3f, SayReadyGetSetGo.Words.JustSaySet), -e.SplitCopy(e.Tick * 4f, SayReadyGetSetGo.Words.JustSayGo) - ], - SayReadyGetSetGo.Words.SayGetSetGo => [ -e.SplitCopy(0f, SayReadyGetSetGo.Words.JustSayGet), -e.SplitCopy(e.Tick, SayReadyGetSetGo.Words.JustSaySet), -e.SplitCopy(e.Tick * 2f, SayReadyGetSetGo.Words.JustSayGo) - ], - SayReadyGetSetGo.Words.SayReaDyGetSetOne => [ -e.SplitCopy(0f, SayReadyGetSetGo.Words.JustSayRea), -e.SplitCopy(e.Tick, SayReadyGetSetGo.Words.JustSayDy), -e.SplitCopy(e.Tick * 2f, SayReadyGetSetGo.Words.JustSayGet), -e.SplitCopy(e.Tick * 3f, SayReadyGetSetGo.Words.JustSaySet), -e.SplitCopy(e.Tick * 4f, SayReadyGetSetGo.Words.Count1) - ], - SayReadyGetSetGo.Words.SayGetSetOne => [ -e.SplitCopy(0f, SayReadyGetSetGo.Words.JustSayGet), -e.SplitCopy(e.Tick, SayReadyGetSetGo.Words.JustSaySet), -e.SplitCopy(e.Tick * 2f, SayReadyGetSetGo.Words.Count1) - ], - SayReadyGetSetGo.Words.SayReadyGetSetGo => [ -e.SplitCopy(0f, SayReadyGetSetGo.Words.JustSayReady), -e.SplitCopy(e.Tick * 2f, SayReadyGetSetGo.Words.JustSayGet), -e.SplitCopy(e.Tick * 3f, SayReadyGetSetGo.Words.JustSaySet), -e.SplitCopy(e.Tick * 4f, SayReadyGetSetGo.Words.JustSayGo) - ], - _ => [e], - }; - /// - /// Generate split event instances. - /// - public static IEnumerable Split(this AddOneshotBeat e) - { - e._beat.IfNullThrowException(); - List L = []; - uint loops = e.Loops; - for (uint i = 0U; i <= loops; i += 1U) - { - AddOneshotBeat T = e.MemberwiseClone(); - T.Loops = 0U; - T.Interval = 0f; - T.Beat = new RDBeat(e._beat._calculator, unchecked(e.Beat.BeatOnly + i * e.Interval)); - L.Add(T); - } - return L.AsEnumerable(); - } - /// - /// Generate split event instances. Follow the most recently activated Xs. - /// - public static IEnumerable Split(this AddClassicBeat e) - { - SetRowXs x = e.Parent?.LastOrDefault((SetRowXs i) => i.Active && e.IsBehind(i)) ?? new(); - return e.Split(x); - } - /// - /// Generate split event instances. - /// - public static IEnumerable Split(this AddClassicBeat e, SetRowXs Xs) - { - List L = []; - AddFreeTimeBeat Head = e.Clone(); - Head.Pulse = 0; - Head.Hold = e.Hold; - L.Add(Head); - int i = 1; - do - { - if (!(i < 6 && Xs.Pattern[i] == Patterns.X)) - { - PulseFreeTimeBeat Pulse = e.Clone(); - PulseFreeTimeBeat pulseFreeTimeBeat; - (pulseFreeTimeBeat = Pulse).Beat = pulseFreeTimeBeat.Beat + e.Tick * (float)i; - if (i >= (int)Xs.SyncoBeat) - (pulseFreeTimeBeat = Pulse).Beat = pulseFreeTimeBeat.Beat - Xs.SyncoSwing; - if (i % 2 == 1) - (pulseFreeTimeBeat = Pulse).Beat = pulseFreeTimeBeat.Beat + (e.Tick - ((e.Swing == 0f) ? e.Tick : e.Swing)); - Pulse.Hold = e.Hold; - Pulse.Action = PulseFreeTimeBeat.ActionType.Increment; - L.Add(Pulse); - } - i++; - } - while (i <= 6); - return L.AsEnumerable(); - } - /// - /// Calculates the duration of the VFX effect for the given preset. - /// - /// The SetVFXPreset event. - /// An RDRange representing the duration of the VFX effect. - public static RDRange VFXDuration(this SetVFXPreset e) - { - if (e.Preset != SetVFXPreset.Presets.DisableAll && e.Enable) - { - SetVFXPreset? close = e.After().FirstOrDefault(i => - i.Rooms.Contains(e.Rooms) && ( - i.Preset == e.Preset || - i.Preset == SetVFXPreset.Presets.DisableAll - )); - return new(e.Beat, close?.Beat); - } - return new(e.Beat, e.Beat); - } - /// - /// Remove auxiliary symbols. - /// - public static string TextOnly(this ShowDialogue e) - { - string result = e.Text; - foreach (string item in new string[] - { - "shake", - "shakeRadius=\\d+", - "wave", - "waveHeight=\\d+", - "waveSpeed=\\d+", - "swirl", - "swirlRadius=\\d+", - "swirlSpeed=\\d+", - "static" - }) - result = Regex.Replace(result, string.Format("\\[{0}\\]", item), ""); - return result; - } - /// - /// The visual position of the lower left corner of the image. - /// - public static RDPointE VisualPosition(this Move e, RDSizeE spriteSize) - { - RDPointE VisualPosition = default; - if (e.Position != null && e.Pivot != null && e.Angle != null && e.Angle.Value.IsNumeric && e.Scale != null) - { - RDPointE previousPosition = e.Position.Value; - RDExpression? x = e.Pivot?.X * (e.Scale?.Width) * spriteSize.Width / 100f; - RDPointE previousPivot = new(x, e.Pivot?.Y * (e.Scale?.Height) * spriteSize.Height / 100f); - VisualPosition = previousPosition + new RDSizeE(previousPivot.Rotate(e.Angle.Value.NumericValue)); - } - return VisualPosition; - } - /// - /// The visual position of the lower left corner of the image. - /// - public static RDPointE VisualPosition(this MoveRoom e) - { - RDPointE VisualPosition = default; - if (e.RoomPosition != null && e.Pivot != null && e.Angle != null) - { - RDPointE previousPosition = e.RoomPosition.Value; - RDPointE previousPivot = new((e.Pivot?.X) * (e.Scale?.Width), (e.Pivot?.Y) * (e.Scale?.Height)); - VisualPosition = previousPosition + new RDSizeE(previousPivot.Rotate(e.Angle.Value.NumericValue)); - } - return VisualPosition; - } - /// - /// Creates a rotated rectangle for the MoveCamera event. - /// - /// The MoveCamera event. - /// A rotated rectangle representing the camera's position, zoom, and angle. - public static RDRotatedRectE RotatedRect(this MoveCamera e) => new(e.CameraPosition, new(e.Zoom, e.Zoom), null, e.Angle); - /// - /// Creates a rotated rectangle for the MoveRow event. - /// - /// The MoveRow event. - /// A rotated rectangle representing the row's position, scale, pivot, and angle. - public static RDRotatedRectE RotatedRect(this MoveRow e) => new(e.RowPosition, e.Scale, new(e.Pivot, e.Pivot), e.Angle); - /// - /// Creates a rotated rectangle for the MoveRoom event. - /// - /// The MoveRoom event. - /// A rotated rectangle representing the room's position, scale, pivot, and angle. - public static RDRotatedRectE RotatedRect(this MoveRoom e) => new(e.RoomPosition, e.Scale, e.Pivot, e.Angle); - /// - /// Creates a rotated rectangle for the Move event. - /// - /// The Move event. - /// A rotated rectangle representing the position, scale, pivot, and angle. - public static RDRotatedRectE RotatedRect(this Move e) => new(e.Position, e.Scale, e.Pivot, e.Angle); - private static SayReadyGetSetGo SplitCopy(this SayReadyGetSetGo e, float extraBeat, SayReadyGetSetGo.Words word) - { - SayReadyGetSetGo Temp = e.Clone(); - Temp.Beat += extraBeat; - Temp.PhraseToSay = word; - Temp.Volume = e.Volume; - return Temp; - } - } -} \ No newline at end of file diff --git a/RhythmBaseCore/RhythmBase.csproj b/RhythmBaseCore/RhythmBase.csproj deleted file mode 100644 index 3c6d4c4..0000000 --- a/RhythmBaseCore/RhythmBase.csproj +++ /dev/null @@ -1,43 +0,0 @@ - - - net8.0 - enable - enable - RhythmBase - RhythmBase - True - RhythmToolkit - 1.1.0-beta1 - obugs - A package that can be used to help with the development of support tools for the Rhythm Doctor game levels. - https://github.com/RDCN-Community-Developers/RadiationTherapy - RhythmToolkit.png - https://github.com/RDCN-Community-Developers/RhythmToolkit.git - True - Preview - - - - - - - - - - - - - - - - - - - - - - True - \ - - - diff --git a/RhythmBaseCore/RhythmToolkit.png b/RhythmBaseCore/RhythmToolkit.png deleted file mode 100644 index 21de3fd..0000000 Binary files a/RhythmBaseCore/RhythmToolkit.png and /dev/null differ diff --git a/RhythmBaseCore/Settings/InactiveEventsHandling.cs b/RhythmBaseCore/Settings/InactiveEventsHandling.cs deleted file mode 100644 index 65795ff..0000000 --- a/RhythmBaseCore/Settings/InactiveEventsHandling.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace RhythmBase.Settings -{ - /// - /// Actions performed on inactive items at read or write times. - /// - public enum InactiveEventsHandling - { - /// - /// Retaining inactivated events to the level on reads. - /// Write inactivated events on writes. - /// - Retain, - /// - /// Dumps inactivated events to on reads and writes. - /// - Store, - /// - /// Ignore inactivation events on reads and writes. - /// - Ignore - } -} diff --git a/RhythmBaseCore/Settings/LevelReadOrWriteSettings.cs b/RhythmBaseCore/Settings/LevelReadOrWriteSettings.cs deleted file mode 100644 index bb5cc51..0000000 --- a/RhythmBaseCore/Settings/LevelReadOrWriteSettings.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Newtonsoft.Json.Linq; -using RhythmBase.Events; -namespace RhythmBase.Settings -{ - /// - /// Level import settings. - /// - public class LevelReadOrWriteSettings - { - /// - /// Event triggered before reading. - /// - public event EventHandler BeforeReading; - /// - /// Event triggered after reading. - /// - public event EventHandler AfterReading; - /// - /// Event triggered before writing. - /// - public event EventHandler BeforeWriting; - /// - /// Event triggered after writing. - /// - public event EventHandler AfterWriting; - /// - /// Initialize. - /// - public LevelReadOrWriteSettings() - { - BeforeReading = delegate { }; - AfterReading = delegate { }; - BeforeWriting = delegate { }; - AfterWriting = delegate { }; - } - /// - /// Enable resource preloading. This may grow read times. - /// Defaults to . - /// - public bool PreloadAssets { get; set; } = false; - /// - /// Action on inactive items on reads or writes. - /// Defaults to . - /// - public InactiveEventsHandling InactiveEventsHandling { get; set; } = InactiveEventsHandling.Retain; - /// - /// Stores unreadable event data when the is . - /// - public List InactiveEvents { get; set; } = []; - /// - /// Action on unreadable events. - /// Defaults to . - /// - public UnreadableEventHandling UnreadableEventsHandling { get; set; } = UnreadableEventHandling.ThrowException; - /// - /// Stores unreadable event data when the is . - /// - /// - public List<(JObject item, string reason)> UnreadableEvents { get; set; } = []; - /// - /// Use indentation. - /// Defaults to . - /// - public bool Indented { get; set; } = true; - internal void OnBeforeReading() - { - BeforeReading?.Invoke(this, EventArgs.Empty); - } - internal void OnAfterReading() - { - AfterReading?.Invoke(this, EventArgs.Empty); - } - internal void OnBeforeWriting() - { - BeforeWriting?.Invoke(this, EventArgs.Empty); - } - internal void OnAfterWriting() - { - AfterWriting?.Invoke(this, EventArgs.Empty); - } - } -} diff --git a/RhythmBaseCore/Settings/UnreadableEventHandling.cs b/RhythmBaseCore/Settings/UnreadableEventHandling.cs deleted file mode 100644 index 72f3f8f..0000000 --- a/RhythmBaseCore/Settings/UnreadableEventHandling.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace RhythmBase.Settings -{ - /// - /// Actions performed on items with exceptions during reads. - /// - public enum UnreadableEventHandling - { - /// - /// Stores unreadable events in for restoration. - /// - Store, - /// - /// An exception will be thrown. - /// - ThrowException - } -} diff --git a/RhythmBaseCore/Utils/BeatCalculator.cs b/RhythmBaseCore/Utils/BeatCalculator.cs deleted file mode 100644 index f399df5..0000000 --- a/RhythmBaseCore/Utils/BeatCalculator.cs +++ /dev/null @@ -1,155 +0,0 @@ -using RhythmBase.Components; -using RhythmBase.Events; -using RhythmBase.Extensions; -namespace RhythmBase.Utils -{ - /// - /// Beat calculator. - /// - public class BeatCalculator - { - internal BeatCalculator(RDLevel level) - { - Collection = level; - Refresh(); - } - /// - /// Refresh the cache. - /// - public void Refresh() - { - _BPMList = Collection.Where() - .ToList(); - _CPBList = Collection.Where() - .ToList(); - } - /// - /// Convert beat data. - /// - /// The 1-based bar. - /// The 1-based beat of the bar. - /// Total 1-based beats. - public float BarBeatToBeatOnly(uint bar, float beat) => BarBeatToBeatOnly(bar, beat, _CPBList); - /// - /// Convert beat data. - /// - /// The 1-based bar. - /// The 1-based beat of the bar. - /// Total time span. - public TimeSpan BarBeatToTimeSpan(uint bar, float beat) => BeatOnlyToTimeSpan(BarBeatToBeatOnly(bar, beat)); - /// - /// Convert beat data. - /// - /// Total 1-based beats. - /// The 1-based bar and the 1-based beat of bar. - public (uint bar, float beat) BeatOnlyToBarBeat(float beat) => BeatOnlyToBarBeat(beat, _CPBList); - /// - /// Convert beat data. - /// - /// Total 1-based beats. - /// Total time span. - public TimeSpan BeatOnlyToTimeSpan(float beat) => BeatOnlyToTimeSpan(beat, _BPMList); - /// - /// Convert beat data. - /// - /// Total time span. - /// Total 1-based beats. - public float TimeSpanToBeatOnly(TimeSpan timeSpan) => TimeSpanToBeatOnly(timeSpan, _BPMList); - /// - /// Convert beat data. - /// - /// Total time span. - /// The 1-based bar and the 1-based beat of bar. - public (uint bar, float beat) TimeSpanToBarBeat(TimeSpan timeSpan) => BeatOnlyToBarBeat(TimeSpanToBeatOnly(timeSpan)); - private static float BarBeatToBeatOnly(uint bar, float beat, IEnumerable Collection) - { - (float BeatOnly, uint Bar, uint CPB) foreCPB = new(1f, 1U, 8U); - SetCrotchetsPerBar? LastCPB = Collection.LastOrDefault((SetCrotchetsPerBar i) => i.Active && i.Beat.BarBeat.bar < bar); - if (LastCPB != null) - foreCPB = new(LastCPB.Beat.BeatOnly, LastCPB.Beat.BarBeat.bar, LastCPB.CrotchetsPerBar); - return foreCPB.BeatOnly + (bar - foreCPB.Bar) * foreCPB.CPB + beat - 1f; - } - private static (uint bar, float beat) BeatOnlyToBarBeat(float beat, IEnumerable Collection) - { - (float BeatOnly, uint Bar, uint CPB) foreCPB = new(1f, 1U, 8U); - SetCrotchetsPerBar? LastCPB = Collection.LastOrDefault((SetCrotchetsPerBar i) => i.Active && i.Beat.BeatOnly < beat); - if (LastCPB != null) - foreCPB = new(LastCPB.Beat.BeatOnly, LastCPB.Beat.BarBeat.bar, LastCPB.CrotchetsPerBar); - (uint bar, float beat) result = ((uint)Math.Round(foreCPB.Bar + Math.Floor((double)((beat - foreCPB.BeatOnly) / foreCPB.CPB))), ((beat - foreCPB.BeatOnly) % foreCPB.CPB) + 1f); - return result; - } - private static TimeSpan BeatOnlyToTimeSpan(float beatOnly, IEnumerable BPMCollection) - { - ValueTuple fore = new(1f, Utils.DefaultBPM); - BaseBeatsPerMinute? foreBPM = BPMCollection.FirstOrDefault(); - if (foreBPM != null) - fore = new ValueTuple(foreBPM.Beat.BeatOnly, foreBPM.BeatsPerMinute); - float resultMinute = 0f; - foreach (BaseBeatsPerMinute item in BPMCollection) - if (beatOnly > item.Beat.BeatOnly) - { - resultMinute += (item.Beat.BeatOnly - fore.Item1) / fore.Item2; - fore = new ValueTuple(item.Beat.BeatOnly, item.BeatsPerMinute); - } - resultMinute += (beatOnly - fore.Item1) / fore.Item2; - return TimeSpan.FromMinutes((double)resultMinute); - } - private static float TimeSpanToBeatOnly(TimeSpan timeSpan, IEnumerable BPMCollection) - { - ValueTuple fore = new(1f, Utils.DefaultBPM); - BaseBeatsPerMinute? foreBPM = BPMCollection.FirstOrDefault(); - if (foreBPM != null) - fore = new ValueTuple(foreBPM.Beat.BeatOnly, foreBPM.BeatsPerMinute); - float beatOnly = 1f; - foreach (BaseBeatsPerMinute item in BPMCollection) - if (timeSpan > BeatOnlyToTimeSpan(item.Beat.BeatOnly, BPMCollection)) - beatOnly = (float)((double)beatOnly + (BeatOnlyToTimeSpan(item.Beat.BeatOnly, BPMCollection) - BeatOnlyToTimeSpan(fore.Item1, BPMCollection)).TotalMinutes * (double)fore.Item2); - beatOnly = (float)((double)beatOnly + (timeSpan - BeatOnlyToTimeSpan(fore.Item1, BPMCollection)).TotalMinutes * (double)fore.Item2); - return beatOnly; - } - /// - /// Creates a beat instance. - /// - public RDBeat BeatOf(float beatOnly) => new(this, beatOnly); - /// - /// Creates a beat instance. - /// - public RDBeat BeatOf(uint bar, float beat) => new(this, bar, beat); - /// - /// Creates a beat instance. - /// - public RDBeat BeatOf(TimeSpan timeSpan) => new(this, timeSpan); - /// - /// Creates an interval between two beats. - /// - /// The first beat. - /// The second beat. - /// An RDRange representing the interval between the two beats. - public RDRange IntervalOf(RDBeat beat1, RDBeat beat2) => new(new(this, beat1), new(this, beat2)); - /// - /// Creates an interval between two beats specified by bar and beat. - /// - /// The first beat specified by bar and beat. - /// The second beat specified by bar and beat. - /// An RDRange representing the interval between the two beats. - public RDRange IntervalOf((uint bar, float beat) beat1, (uint bar, float beat) beat2) => IntervalOf(BeatOf(beat1.bar, beat1.beat), BeatOf(beat2.bar, beat2.beat)); - /// - /// Creates an interval between two beats specified by time spans. - /// - /// The first time span. - /// The second time span. - /// An RDRange representing the interval between the two time spans. - public RDRange IntervalOf(TimeSpan timeSpan1, TimeSpan timeSpan2) => IntervalOf(BeatOf(timeSpan1), BeatOf(timeSpan2)); - /// - /// Calculate the BPM of the moment in which the beat is. - /// - public float BeatsPerMinuteOf(RDBeat beat) => _BPMList.LastOrDefault((BaseBeatsPerMinute i) => i.Beat < beat)?.BeatsPerMinute ?? Utils.DefaultBPM; - /// - /// Calculate the CPB of the moment in which the beat is. - /// - public float CrotchetsPerBarOf(RDBeat beat) => _CPBList.LastOrDefault((SetCrotchetsPerBar i) => i.Beat < beat)?.CrotchetsPerBar ?? 8; - internal readonly RDLevel Collection; - private List _BPMList = []; - private List _CPBList = []; - } -} diff --git a/RhythmBaseCore/Utils/EventTypeUtils.cs b/RhythmBaseCore/Utils/EventTypeUtils.cs deleted file mode 100644 index 0444b29..0000000 --- a/RhythmBaseCore/Utils/EventTypeUtils.cs +++ /dev/null @@ -1,249 +0,0 @@ -using RhythmBase.Events; -using RhythmBase.Exceptions; -using System.Collections.ObjectModel; - -namespace RhythmBase.Utils -{ - /// - /// Utility class for converting between event types and enumerations. - /// - public static class EventTypeUtils - { - /// - /// Converts a type to its corresponding EventType enumeration. - /// - /// The type to convert. - /// The corresponding EventType enumeration. - /// Thrown when no matching EventType is found or multiple matching EventTypes are found. - public static EventType ToEnum(Type type) - { - EventType ConvertToEnum; - if (EventType_Enums == null) - { - string name = type.Name; - if (!Enum.TryParse(name, out EventType result)) - { - throw new IllegalEventTypeException(type, "Unable to find a matching EventType."); - } - ConvertToEnum = result; - } - else - { - try - { - ConvertToEnum = EventType_Enums[type].Single(); - } - catch (Exception) - { - throw new IllegalEventTypeException(type, "Multiple matching EventTypes were found. Please check if the type is an abstract class type.", new ArgumentException("Multiple matching EventTypes were found. Please check if the type is an abstract class type.", nameof(type))); - } - } - return ConvertToEnum; - } - - /// - /// Converts a generic event type to its corresponding EventType enumeration. - /// - /// The generic event type to convert. - /// The corresponding EventType enumeration. - public static EventType ToEnum() where TEvent : IBaseEvent, new() => ToEnum(typeof(TEvent)); - - /// - /// Converts a type to an array of corresponding EventType enumerations. - /// - /// The type to convert. - /// An array of corresponding EventType enumerations. - /// Thrown when an unexpected exception occurs. - public static EventType[] ToEnums(Type type) - { - EventType[] ConvertToEnums; - try - { - ConvertToEnums = EventType_Enums[type]; - } - catch (Exception ex) - { - throw new IllegalEventTypeException(type, "This exception is not expected. Please contact the developer to handle this exception.", ex); - } - return ConvertToEnums; - } - - /// - /// Converts a generic event type to an array of corresponding EventType enumerations. - /// - /// The generic event type to convert. - /// An array of corresponding EventType enumerations. - public static EventType[] ToEnums() where TEvent : IBaseEvent => ToEnums(typeof(TEvent)); - - /// - /// Converts a string representation of an event type to its corresponding Type. - /// - /// The string representation of the event type. - /// The corresponding Type. - public static Type ToType(string type) - { - Type ConvertToType; - if (Enum.TryParse(type, out EventType result)) - { - ConvertToType = result.ToType(); - } - else - { - ConvertToType = EventType.CustomEvent.ToType(); - } - return ConvertToType; - } - - /// - /// Converts an EventType enumeration to its corresponding Type. - /// - /// The EventType enumeration to convert. - /// The corresponding Type. - /// Thrown when the value does not exist in the EventType enumeration. - public static Type ToType(this EventType type) - { - Type ConvertToType; - if (Enum_EventType == null) - { - return Type.GetType($"{typeof(IBaseEvent).Namespace}.{type}") ?? throw new RhythmBaseException(string.Format("Illegal Type: {0}.", type)); - } - else - { - try - { - ConvertToType = Enum_EventType[type]; - } - catch - { - throw new IllegalEventTypeException(type.ToString(), "This value does not exist in the EventType enumeration."); - } - } - return ConvertToType; - } - - private static readonly ReadOnlyCollection EventTypes = (from i in typeof(IBaseEvent).Assembly.GetTypes() - where i.IsAssignableTo(typeof(IBaseEvent)) - select i) - .ToList() - .AsReadOnly(); - - /// - /// A dictionary that records the correspondence of event types inheriting from to . - /// - private static readonly ReadOnlyDictionary EventType_Enums = EventTypes.ToDictionary((Type i) => i, (Type i) => (from j in EventTypes - where (j == i || j.IsAssignableTo(i)) && !j.IsAbstract - select j) - .Select((Type j) => ToEnum(j)) - .ToArray()) - .AsReadOnly(); - - /// - /// A dictionary that records the correspondence of to event types inheriting from . - /// - private static readonly ReadOnlyDictionary Enum_EventType = Enum.GetValues().ToDictionary((EventType i) => i, (EventType i) => i.ToType()).AsReadOnly(); - - /// - /// Event types that inherit from . - /// - public static readonly ReadOnlyCollection RowTypes = ToEnums().AsReadOnly(); - - /// - /// Event types that inherit from . - /// - public static readonly ReadOnlyCollection DecorationTypes = ToEnums().AsReadOnly(); - /// - /// Custom event types. - /// - public static ReadOnlyCollection CustomTypes => new( - [ - EventType.CustomEvent, - EventType.CustomRowEvent, - EventType.CustomDecorationEvent, - ]); - /// - /// Event types for gameplay. - /// - public static ReadOnlyCollection EventTypeEnumsForGameplay => new( - [ - EventType.HideRow, - EventType.ChangePlayersRows, - EventType.FinishLevel, - EventType.ShowHands, - EventType.SetHandOwner, - EventType.SetPlayStyle - ]); - - /// - /// Event types for environment. - /// - public static ReadOnlyCollection EventTypeEnumsForEnvironment => new( - [ - EventType.SetTheme, - EventType.SetBackgroundColor, - EventType.SetForeground, - EventType.SetSpeed, - EventType.Flash, - EventType.CustomFlash - ]); - - /// - /// Event types for row effects. - /// - public static ReadOnlyCollection EventTypeEnumsForRowFX => new( - [ - EventType.HideRow, - EventType.MoveRow, - EventType.PlayExpression, - EventType.TintRows - ]); - - /// - /// Event types for camera effects. - /// - public static ReadOnlyCollection EventTypeEnumsForCameraFX => new( - [ - EventType.MoveCamera, - EventType.ShakeScreen, - EventType.FlipScreen, - EventType.PulseCamera - ]); - - /// - /// Event types for visual effects. - /// - public static ReadOnlyCollection EventTypeEnumsForVisualFX => new( - [ - EventType.SetVFXPreset, - EventType.SetSpeed, - EventType.Flash, - EventType.CustomFlash, - EventType.BassDrop, - EventType.InvertColors, - EventType.Stutter, - EventType.PaintHands, - EventType.NewWindowDance - ]); - - /// - /// Event types for text effects. - /// - public static ReadOnlyCollection EventTypeEnumsForText => new( - [ - EventType.TextExplosion, - EventType.ShowDialogue, - EventType.ShowStatusSign, - EventType.FloatingText, - EventType.AdvanceText - ]); - - /// - /// Event types for utility actions. - /// - public static ReadOnlyCollection EventTypeEnumsForUtility => new( - [ - EventType.Comment, - EventType.TagAction, - EventType.CallCustomMethod - ]); - } -} \ No newline at end of file diff --git a/RhythmBaseCore/Utils/Utils.cs b/RhythmBaseCore/Utils/Utils.cs deleted file mode 100644 index 2b6b115..0000000 --- a/RhythmBaseCore/Utils/Utils.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using RhythmBase.Components; -using RhythmBase.Converters; -using RhythmBase.Events; -using RhythmBase.Exceptions; -using RhythmBase.Settings; -namespace RhythmBase.Utils -{ - /// - /// Static class providing utility methods. - /// - public static class Utils - { - /// - /// Converts Xs patterns to string form. - /// - /// List of patterns. - /// String representation of patterns. - public static string GetPatternString(Patterns[] pattern) => string.Join("", - pattern?.Select(p => p switch - { - Patterns.None => "-", - Patterns.X => "x", - Patterns.Up => "u", - Patterns.Down => "d", - Patterns.Banana => "b", - Patterns.Return => "r", - _ => throw new ConvertingException($"Invalid pattern: {p}") - - }) ?? throw new ConvertingException($"Cannot write pattern.")); - - /// - /// Gets the JSON serializer settings for the specified level and settings. - /// - /// The level to serialize. - /// The settings for reading or writing the level. - /// JSON serializer settings. - public static JsonSerializerSettings GetSerializer(this RDLevel rdlevel, LevelReadOrWriteSettings settings) - { - JsonSerializerSettings EventsSerializer = new() - { - ContractResolver = new RDContractResolver() - }; - IList converters = EventsSerializer.Converters; - converters.Add(new PanelColorConverter(rdlevel.ColorPalette)); - converters.Add(new ColorConverter()); - converters.Add(new ConditionalConverter()); - converters.Add(new CharacterConverter()); - converters.Add(new ConditionConverter(rdlevel.Conditionals)); - converters.Add(new TagActionConverter(rdlevel, settings)); - converters.Add(new CustomDecorationEventConverter(rdlevel, settings)); - converters.Add(new CustomRowEventConverter(rdlevel, settings)); - converters.Add(new CustomEventConverter(rdlevel, settings)); - converters.Add(new BaseRowActionConverter(rdlevel, settings)); - converters.Add(new BaseDecorationActionConverter(rdlevel, settings)); - converters.Add(new BaseEventConverter(rdlevel, settings)); - converters.Add(new BookmarkConverter(rdlevel.Calculator)); - converters.Add(new StringEnumConverter()); - return EventsSerializer; - } - /// - /// The default beats per minute. - /// - public const float DefaultBPM = 100f; - /// - /// The default crotchets per bar. - /// - public const int DefaultCPB = 8; - } -} diff --git a/RhythmBaseCore/Utils/VisualUtils.cs b/RhythmBaseCore/Utils/VisualUtils.cs deleted file mode 100644 index 3b2ab1e..0000000 --- a/RhythmBaseCore/Utils/VisualUtils.cs +++ /dev/null @@ -1,82 +0,0 @@ -using RhythmBase.Components; - -namespace RhythmBase.Utils -{ - /// - /// Visual utils. - /// - public static class VisualUtils - { - /// - /// Converts percentage point to pixel point with default screen size (352 * 198). - /// - public static RDPointE PercentToPixel(RDPointE point) => PercentToPixel(point, RDSizeNI.Screen); - - /// - /// Converts percentage point to pixel point with specified size. - /// - /// The percentage point. - /// Specified size. - /// The pixel point. - public static RDPointE PercentToPixel(RDPointE point, RDSizeE size) - { - RDPointE PercentToPixel = new(point.X * size.Width / 100f, point.Y * size.Height / 100f); - return PercentToPixel; - } - - /// - /// Converts pixel point to percentage point with default screen size (352 * 198). - /// - /// The pixel point. - /// The percentage point. - public static (float? X, float? Y) PixelToPercent((float X, float Y) point) => PixelToPercent(point, (352f, 198f)); - - /// - /// Converts pixel point to percentage point with specified size. - /// - /// The pixel point. - /// Specified size. - /// The percentage point. - public static (float? X, float? Y) PixelToPercent((float? X, float? Y) point, (float? X, float? Y) size) - { - (float? X, float? Y) PixelToPercent = (point.X * 100f / size.X, point.Y * 100f / size.Y); - return PixelToPercent; - } - - /// - /// Translates a point in room perspective. - /// - /// The point to translate. - /// The rectangle defining the room perspective. - /// The translated point. - public static RDPointN RoomPerspectiveTranslate(this RDPointN p, RDRectN rect) - { - RDPointN plb = rect.LeftBottom; - RDPointN prb = rect.RightBottom; - RDPointN plt = rect.LeftTop; - RDPointN prt = rect.RightTop; - p = new(p.X, p.Y); - RDPointN p1p2 = prb - (RDSizeN)plb; - RDPointN p1p4 = plt - (RDSizeN)plb; - RDPointN p1p3 = prt - (RDSizeN)plb; - RDPointN pr = plb + new RDSizeN(p1p2.X * p.X, p1p2.Y * p.X) + - new RDSizeN((p1p3.X - p1p2.X - p1p4.X) * p.X * p.Y, (p1p3.Y - p1p2.Y - p1p4.Y) * p.X * p.Y) + - new RDSizeN(p1p4.X * p.Y, p1p4.Y * p.Y); - return pr; - } - - /// - /// Converts degrees to radians. - /// - /// The angle in degrees. - /// The angle in radians. - public static float DegreeToRadius(float degree) => float.Pi * degree / 180f; - - /// - /// Converts radians to degrees. - /// - /// The angle in radians. - /// The angle in degrees. - public static float RadiusToDegree(float radius) => radius * 180f / float.Pi; - } -}