Skip to content

Commit

Permalink
Merge branch 'apis-rework' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Rysik5318 authored Feb 17, 2024
2 parents dd25dab + 698c323 commit 30b26aa
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Exiled.API/Features/Core/Generic/EnumClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Exiled.API.Features.Core.Generic
using System.Reflection;

using Exiled.API.Features.Core.Generic.Pools;

using Exiled.API.Interfaces;
using LiteNetLib.Utils;

/// <summary>
Expand All @@ -22,7 +22,7 @@ namespace Exiled.API.Features.Core.Generic
/// </summary>
/// <typeparam name="TSource">The type of the source object to handle the instance of.</typeparam>
/// <typeparam name="TObject">The type of the child object to handle the instance of.</typeparam>
public abstract class EnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>
public abstract class EnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>, IEnumClass
where TSource : Enum
where TObject : EnumClass<TSource, TObject>
{
Expand Down
4 changes: 2 additions & 2 deletions Exiled.API/Features/Core/Generic/UniqueUnmanagedEnumClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Exiled.API.Features.Core.Generic
using System.Reflection;

using Exiled.API.Features.Core.Generic.Pools;

using Exiled.API.Interfaces;
using LiteNetLib.Utils;

/// <summary>
Expand All @@ -22,7 +22,7 @@ namespace Exiled.API.Features.Core.Generic
/// </summary>
/// <typeparam name="TSource">The type of the <see langword="unmanaged"/> source object to handle the instance of.</typeparam>
/// <typeparam name="TObject">The type of the child object to handle the instance of.</typeparam>
public abstract class UniqueUnmanagedEnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>, IConvertible
public abstract class UniqueUnmanagedEnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>, IConvertible, IEnumClass
where TSource : unmanaged, IComparable, IFormattable, IConvertible, IComparable<TSource>, IEquatable<TSource>
where TObject : UniqueUnmanagedEnumClass<TSource, TObject>
{
Expand Down
4 changes: 2 additions & 2 deletions Exiled.API/Features/Core/Generic/UnmanagedEnumClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Exiled.API.Features.Core.Generic
using System.Reflection;

using Exiled.API.Features.Core.Generic.Pools;

using Exiled.API.Interfaces;
using LiteNetLib.Utils;

/// <summary>
Expand All @@ -22,7 +22,7 @@ namespace Exiled.API.Features.Core.Generic
/// </summary>
/// <typeparam name="TSource">The type of the <see langword="unmanaged"/> source object to handle the instance of.</typeparam>
/// <typeparam name="TObject">The type of the child object to handle the instance of.</typeparam>
public abstract class UnmanagedEnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>, IConvertible
public abstract class UnmanagedEnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>, IConvertible, IEnumClass
where TSource : unmanaged, IComparable, IFormattable, IConvertible, IComparable<TSource>, IEquatable<TSource>
where TObject : UnmanagedEnumClass<TSource, TObject>
{
Expand Down
5 changes: 0 additions & 5 deletions Exiled.API/Features/Pickups/Pickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ internal Pickup(ItemType type)
/// <returns>A randomly selected <see cref="Pickup"/> object.</returns>
public static Pickup Random => BaseToPickup.Random().Value;

/// <summary>
/// Gets the <see cref="UnityEngine.GameObject"/> of the Pickup.
/// </summary>
public override GameObject GameObject => GameObject;

/// <summary>
/// Gets the <see cref="UnityEngine.Rigidbody"/> of the Pickup.
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions Exiled.API/Interfaces/IEnumClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// -----------------------------------------------------------------------
// <copyright file="IEnumClass.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Interfaces
{
/// <summary>
/// An interface for all enum classes.
/// </summary>
public interface IEnumClass
{
}
}
16 changes: 16 additions & 0 deletions Exiled.Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ namespace Exiled.Events
{
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;

using API.Enums;
using API.Features;
using CentralAuth;
using Exiled.API.Interfaces;
using Exiled.Events.Features;
using HarmonyLib;
using InventorySystem.Items.Pickups;
Expand Down Expand Up @@ -83,6 +86,19 @@ public override void OnEnabled()
ServerConsole.ReloadServerName();

EventManager.RegisterEvents<Handlers.Player>(this);

foreach (Type type in typeof(IEnumClass).Assembly.GetTypes().Where(x => x.GetInterface(nameof(IEnumClass)) == typeof(IEnumClass)))
{
FieldInfo[] fieldInfos = type.GetFields();

if (fieldInfos.All(x => !x.IsInitOnly))
continue;

foreach (FieldInfo field in fieldInfos.Where(x => x.IsStatic))
{
field.GetValue(null);
}
}
}

/// <inheritdoc/>
Expand Down

0 comments on commit 30b26aa

Please sign in to comment.