diff --git a/Directory.Build.targets b/Directory.Build.targets index 38f22b4..d961ed5 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -19,4 +19,9 @@ + + + + + \ No newline at end of file diff --git a/SecretAPI/Features/DecalHelpers.cs b/SecretAPI/Features/DecalHelpers.cs index ce5f76e..acd9fac 100644 --- a/SecretAPI/Features/DecalHelpers.cs +++ b/SecretAPI/Features/DecalHelpers.cs @@ -1,10 +1,12 @@ namespace SecretAPI.Features; using System; +using CommandSystem.Commands.RemoteAdmin.Cleanup; using Decals; using InventorySystem.Items; using InventorySystem.Items.Autosync; using InventorySystem.Items.Firearms.Modules; +using LabApi.Features.Wrappers; using Mirror; using RelativePositioning; using UnityEngine; @@ -86,6 +88,21 @@ public static void SpawnDecalFromDirection(Vector3 position, Vector3 direction, public static void SpawnDecalFromDirection(Vector3 position, Quaternion direction, DecalPoolType type = DecalPoolType.Blood) => GetDecalMessage(position, position - (direction * Vector3.forward), type).SendToAuthenticated(); + /// + /// Cleans up decals for all players. + /// + /// The to cleanup. + /// The amount of that decal to cleanup. + public static void CleanupDecals(DecalPoolType decalType, int amount = int.MaxValue) => new DecalCleanupMessage(decalType, amount).SendToAuthenticated(); + + /// + /// Cleans up decals for a specific player. + /// + /// The player to clean up decals for. + /// The to cleanup. + /// The amount of that decal to cleanup. + public static void CleanUpDecals(this Player player, DecalPoolType decalType, int amount = int.MaxValue) => new DecalCleanupMessage(decalType, amount).SendToHubsConditionally(hub => hub == player.ReferenceHub); + private static AutoSyncData GetAutoSyncData() { if (autoSyncData != null) diff --git a/SecretAPI/Features/IPriority.cs b/SecretAPI/Features/IPriority.cs index 6f0666b..24214c6 100644 --- a/SecretAPI/Features/IPriority.cs +++ b/SecretAPI/Features/IPriority.cs @@ -1,7 +1,7 @@ namespace SecretAPI.Features; /// -/// Handles IPriority. +/// Handles priority on certain things. /// public interface IPriority { diff --git a/SecretAPI/Features/IRegister.cs b/SecretAPI/Features/IRegister.cs index 91bb494..a5a5bab 100644 --- a/SecretAPI/Features/IRegister.cs +++ b/SecretAPI/Features/IRegister.cs @@ -2,11 +2,13 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; /// /// Interface used to define a type that should auto register. /// +/// This supports , will default to 0 if not implemented. // TODO: Source generate this public interface IRegister { @@ -25,7 +27,7 @@ public interface IRegister /// public void TryUnregister() { - // default empty to prevent breaking change + // default to empty } /// @@ -38,6 +40,7 @@ public static void RegisterAll(Assembly? assembly = null) registerables.TryAdd(assembly, new()); + List registers = new(); foreach (Type type in assembly.GetTypes()) { if (type.IsAbstract || type.IsInterface) @@ -46,10 +49,14 @@ public static void RegisterAll(Assembly? assembly = null) if (!typeof(IRegister).IsAssignableFrom(type)) continue; - object obj = Activator.CreateInstance(type); - if (obj is not IRegister register) + if (Activator.CreateInstance(type) is not IRegister register) continue; + registers.Add(register); + } + + foreach (IRegister register in registers.OrderBy(x => x is IPriority priority ? priority.Priority : 0)) + { registerables[assembly].Add(register); register.TryRegister(); } diff --git a/SecretAPI/Features/Registry.cs b/SecretAPI/Features/Registry.cs index 2aae151..8103a70 100644 --- a/SecretAPI/Features/Registry.cs +++ b/SecretAPI/Features/Registry.cs @@ -1,11 +1,13 @@ namespace SecretAPI.Features; +using System; using System.Collections.Generic; /// /// Handles the registration of objects and ids. /// /// The type of the registry. +[Obsolete("This will be removed in 4.0")] public static class Registry { /// diff --git a/SecretAPI/Features/UserSettings/CustomButtonSetting.cs b/SecretAPI/Features/UserSettings/CustomButtonSetting.cs index df65faa..b79dc4e 100644 --- a/SecretAPI/Features/UserSettings/CustomButtonSetting.cs +++ b/SecretAPI/Features/UserSettings/CustomButtonSetting.cs @@ -56,6 +56,11 @@ protected CustomButtonSetting(int? id, string label, string buttonText, float? h /// public bool EverPressed => LastPressWatch.IsRunning; + /// + /// Gets the amount of times the button has been pressed. + /// + public uint TimesPressed { get; private set; } + /// /// Gets or sets the text of the button. /// @@ -82,6 +87,13 @@ public float RequiredHoldTime } } + /// + protected override void HandleBeforeSettingUpdate() + { + base.HandleBeforeSettingUpdate(); + TimesPressed++; + } + /// /// Sends an update to that or has updated. ///