Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@
<WriteLinesToFile File="$(Props)" Lines="$(Template)" Condition="!Exists($(Props))" />
<Error Text="The ReferencePath property is not specified! Make sure to set the property in the ReferencePath.props.user file." />
</Target>

<!-- Output dlls into Build folder -->
<Target Name="CopyDll" AfterTargets="Build">
<Copy SourceFiles="$(OutDir)$(TargetFileName)" DestinationFolder="$(SolutionDir)/.builds" />
</Target>
</Project>
17 changes: 17 additions & 0 deletions SecretAPI/Features/DecalHelpers.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();

/// <summary>
/// Cleans up decals for all players.
/// </summary>
/// <param name="decalType">The <see cref="DecalPoolType"/> to cleanup.</param>
/// <param name="amount">The amount of that decal to cleanup.</param>
public static void CleanupDecals(DecalPoolType decalType, int amount = int.MaxValue) => new DecalCleanupMessage(decalType, amount).SendToAuthenticated();

/// <summary>
/// Cleans up decals for a specific player.
/// </summary>
/// <param name="player">The player to clean up decals for.</param>
/// <param name="decalType">The <see cref="DecalPoolType"/> to cleanup.</param>
/// <param name="amount">The amount of that decal to cleanup.</param>
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)
Expand Down
2 changes: 1 addition & 1 deletion SecretAPI/Features/IPriority.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace SecretAPI.Features;

/// <summary>
/// Handles IPriority.
/// Handles priority on certain things.
/// </summary>
public interface IPriority
{
Expand Down
13 changes: 10 additions & 3 deletions SecretAPI/Features/IRegister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

/// <summary>
/// Interface used to define a type that should auto register.
/// </summary>
/// <remarks>This supports <see cref="IPriority"/>, will default to 0 if not implemented.</remarks>
// TODO: Source generate this
public interface IRegister
{
Expand All @@ -25,7 +27,7 @@ public interface IRegister
/// </summary>
public void TryUnregister()
{
// default empty to prevent breaking change
// default to empty
}

/// <summary>
Expand All @@ -38,6 +40,7 @@ public static void RegisterAll(Assembly? assembly = null)

registerables.TryAdd(assembly, new());

List<IRegister> registers = new();
foreach (Type type in assembly.GetTypes())
{
if (type.IsAbstract || type.IsInterface)
Expand All @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions SecretAPI/Features/Registry.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
namespace SecretAPI.Features;

using System;
using System.Collections.Generic;

/// <summary>
/// Handles the registration of objects and ids.
/// </summary>
/// <typeparam name="T">The type of the registry.</typeparam>
[Obsolete("This will be removed in 4.0")]
public static class Registry<T>
{
/// <summary>
Expand Down
12 changes: 12 additions & 0 deletions SecretAPI/Features/UserSettings/CustomButtonSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ protected CustomButtonSetting(int? id, string label, string buttonText, float? h
/// </summary>
public bool EverPressed => LastPressWatch.IsRunning;

/// <summary>
/// Gets the amount of times the button has been pressed.
/// </summary>
public uint TimesPressed { get; private set; }

/// <summary>
/// Gets or sets the text of the button.
/// </summary>
Expand All @@ -82,6 +87,13 @@ public float RequiredHoldTime
}
}

/// <inheritdoc/>
protected override void HandleBeforeSettingUpdate()
{
base.HandleBeforeSettingUpdate();
TimesPressed++;
}

/// <summary>
/// Sends an update to <see cref="CustomSetting.KnownOwner"/> that <see cref="Text"/> or <see cref="RequiredHoldTime"/> has updated.
/// </summary>
Expand Down
Loading