diff --git a/.gitignore b/.gitignore index f8b00d2..de0d95d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ References/ packages/ RueITests/obj RueITests/bin +ruei-debug.txt +RueIDocFX.dll diff --git a/RueI/RueI.csproj b/RueI/RueI.csproj index 1337714..1c3841d 100644 --- a/RueI/RueI.csproj +++ b/RueI/RueI.csproj @@ -8,7 +8,7 @@ AnyCPU;x64 RueI CC0 1.0 - 2.0.3 + 2.0.4 Rue <3, Override (some help) True True @@ -16,12 +16,12 @@ https://github.com/Ruemena/RueI https://github.com/Ruemena/RueI scpsl;hints;scp;exiled;nwapi - 2.0.3 - 2.0.3 + 2.0.4 + 2.0.4 README.md LICENSE False - fixes and improvements to documentation + various fixes, improvements to docs, new reflection helpers, and general cleanup diff --git a/RueI/RueI/Events/Events.cs b/RueI/RueI/Events/Events.cs index aad27c6..20dc7e3 100644 --- a/RueI/RueI/Events/Events.cs +++ b/RueI/RueI/Events/Events.cs @@ -1,7 +1,7 @@ namespace RueI.Events; /// -/// Provides events for use by other plugins. +/// Provides events for use by plugins using RueI. /// public static class Events { diff --git a/RueI/RueI/Extensions/CollectionExtensions.cs b/RueI/RueI/Extensions/CollectionExtensions.cs deleted file mode 100644 index c18eebb..0000000 --- a/RueI/RueI/Extensions/CollectionExtensions.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace RueI.Extensions; - -/// -/// Provides extensions for working with collections. -/// -internal static class CollectionExtensions -{ - /// - /// Adds multiple items to a collection. - /// - /// The type of item to add. - /// The collection to add the elements to. - /// The items to add. - public static void Add(this ICollection collection, params T[] items) - { - foreach (T item in items) - { - collection.Add(item); - } - } -} diff --git a/RueI/RueI/Extensions/DisplayCoreExtensions.cs b/RueI/RueI/Extensions/DisplayCoreExtensions.cs index 3e3902a..d65cd11 100644 --- a/RueI/RueI/Extensions/DisplayCoreExtensions.cs +++ b/RueI/RueI/Extensions/DisplayCoreExtensions.cs @@ -33,6 +33,7 @@ public static void SetElementOrNew(this DisplayCore core, IElemReference /// Temporarily adds an to a using the specified . + /// This method updates the . /// /// The to add the element to. /// The element to add. @@ -43,6 +44,7 @@ public static void AddTemp(this DisplayCore core, T element, TimeSpan time, T where T : Element, ISettable { core.AddAsReference(elemRef, element); + core.Update(); core.Scheduler.KillJob(elemRef.JobToken); core.Scheduler.Schedule(time, () => core.RemoveReference(elemRef), elemRef.JobToken); @@ -50,13 +52,14 @@ public static void AddTemp(this DisplayCore core, T element, TimeSpan time, T /// /// Temporarily adds a using the provided string and position, or sets it if it already exists. + /// This method updates the . /// /// The to add the element to. /// The content of the element. /// The position of the element. /// How long to keep the element in the for. /// The to use. - public static void ShowTemp(this DisplayCore core, string content, float position, TimeSpan time, TimedElemRef elemRef) + public static void SetElemTemp(this DisplayCore core, string content, float position, TimeSpan time, TimedElemRef elemRef) { core.SetElementOrNew(elemRef, content, position); core.Update(); @@ -67,13 +70,14 @@ public static void ShowTemp(this DisplayCore core, string content, float positio /// /// Temporarily adds a using the provided string and functional position, or sets it if it already exists. + /// This method updates the . /// /// The to add the element to. /// The content of the element. /// The position of the element. /// How long to keep the element in the for. /// The to use. - public static void ShowTempFunctional(this DisplayCore core, string content, float position, TimeSpan time, TimedElemRef elemRef) + public static void SetElemTempFunctional(this DisplayCore core, string content, float position, TimeSpan time, TimedElemRef elemRef) { core.SetElementOrNew(elemRef, content, Ruetility.FunctionalToScaledPosition(position)); core.Update(); diff --git a/RueI/RueI/Extensions/ElementHelpers.cs b/RueI/RueI/Extensions/ElementHelpers.cs index 6e8caee..5ebcd92 100644 --- a/RueI/RueI/Extensions/ElementHelpers.cs +++ b/RueI/RueI/Extensions/ElementHelpers.cs @@ -8,20 +8,6 @@ /// public static class ElementHelpers { - /// - /// Adds an to a . - /// - /// The type of the . - /// The element to add. - /// The to add to. - /// A reference to this element. - public static T AddTo(this T element, IElementContainer container) - where T : Element - { - element.AddTo(container.Elements); - return element; - } - /// /// Filters out all of the disabled s in an . /// diff --git a/RueI/RueI/Extensions/IEnumerableExtensions.cs b/RueI/RueI/Extensions/IEnumerableExtensions.cs index af5976e..b0c76e4 100644 --- a/RueI/RueI/Extensions/IEnumerableExtensions.cs +++ b/RueI/RueI/Extensions/IEnumerableExtensions.cs @@ -1,7 +1,5 @@ namespace RueI.Extensions; -using NorthwoodLib.Pools; - /// /// Provides extensions for working with collections. /// diff --git a/RueI/RueI/Extensions/Intersection.cs b/RueI/RueI/Extensions/Intersection.cs deleted file mode 100644 index 1e1c73a..0000000 --- a/RueI/RueI/Extensions/Intersection.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace RueI.Extensions; - -/// -/// Represents an intersection between a class and an interface. -/// -/// The more derived class. -/// The interface to be derived from. -public class Intersection - where T : class - where TOther : class -{ - private Intersection(T value) - { - Class = value; - Interface = (value as TOther) !; - } - - /// - /// Gets the derived class of the intersection. - /// - public T Class { get; } - - /// - /// Gets the interface of the intersection. - /// - public TOther Interface { get; } - - /// - /// Implicitly casts an intersection to . - /// - /// The intersection to cast. - public static implicit operator T(Intersection intersection) => intersection.Class; - - /// - /// Implicitly casts an intersection to . - /// - /// The intersection to cast. - public static implicit operator TOther(Intersection intersection) => intersection.Interface; - - /// - /// Creates a new intersection for a class. - /// - /// The class to create the intersection for. - /// The value of the intersected type. - /// A new intersection of the two types. - public static Intersection New(TClass value) - where TClass : class, T, TOther - { - return new Intersection(value); - } -} diff --git a/RueI/RueI/Extensions/ReflectionHelpers.cs b/RueI/RueI/Extensions/ReflectionHelpers.cs index 6dab871..8751f21 100644 --- a/RueI/RueI/Extensions/ReflectionHelpers.cs +++ b/RueI/RueI/Extensions/ReflectionHelpers.cs @@ -10,21 +10,33 @@ public static class ReflectionHelpers { /// - /// Gets a that can be used to add an element, with a as a closure. + /// Gets an that can be used to add an element, with a as a closure. /// - /// A that can be used to add an element to a . + /// An that can be used to add an element to a . /// - /// This method is not intended to be used when using RueI as a direct dependency. + /// Every time this method is called, it creates a new . Therefore, every delegate returned by this method + /// represents a unique 'element'. /// public static Action GetElementShower() { TimedElemRef elemRef = new(); - return (hub, content, name, span) => ShowTempFunctional(hub, content, name, span, elemRef); + return (hub, content, name, span) => SetElemTempFunctional(hub, content, name, span, elemRef); } - private static void ShowTempFunctional(ReferenceHub hub, string content, float position, TimeSpan time, object elemRef) + /// + /// Gets a that can be used to easily call . + /// + /// A that itself returns an . + /// + /// The returned by this method is identical to calling . + /// This method serves a helper to easily turn GetElementShower into a , to make + /// reflection easier. + /// + public static Func> GetElemCreator() => GetElementShower; + + private static void SetElemTempFunctional(ReferenceHub hub, string content, float position, TimeSpan time, TimedElemRef elemRef) { DisplayCore core = DisplayCore.Get(hub); - core.ShowTempFunctional(content, position, time, (TimedElemRef)elemRef); + core.SetElemTempFunctional(content, position, time, elemRef); } } diff --git a/RueI/docs.xml b/RueI/docs.xml index 1bb6288..cb1f595 100644 --- a/RueI/docs.xml +++ b/RueI/docs.xml @@ -1,18 +1,5 @@ - - - - - This example demonstrates simple usage of three UpdateTasks. - - - - - - - -