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); } } }