Skip to content
This repository has been archived by the owner on Dec 30, 2024. It is now read-only.

Commit

Permalink
🧩 Bring IHookFactory<T> back for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Chasmical committed Jul 27, 2023
1 parent 95002a0 commit 9643adc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
11 changes: 11 additions & 0 deletions RogueLibsCore/Compat/IHookFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace RogueLibsCore
{
/// <summary>
/// <para>Represents a hook factory, that creates hooks attachable to instances of type <typeparamref name="T"/>.</para>
/// </summary>
/// <typeparam name="T">The type of objects that the created hooks can be attached to.</typeparam>
[Obsolete("IHookFactory<T> interface was deprecated in RogueLibs v4.0.0. Use the non-generic IHookFactory interface instead.")]
public interface IHookFactory<in T> : IHookFactory where T : notnull { }
}
6 changes: 5 additions & 1 deletion RogueLibsCore/Hooks/HookFactoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ namespace RogueLibsCore
/// <para>Represents a hook factory base. Implements the interfaces, leaving only one abstract method to implement.</para>
/// </summary>
/// <typeparam name="T">The type of objects that the created hooks can be attached to.</typeparam>
public abstract class HookFactoryBase<T> : IHookFactory where T : notnull
public abstract class HookFactoryBase<T>
#pragma warning disable CS0618
: IHookFactory<object>
#pragma warning restore CS0618
where T : notnull
{
/// <summary>
/// <para>Tries to create a hook for the specified <paramref name="instance"/> of type <typeparamref name="T"/>, and returns a value that indicates whether a hook was created successfully.</para>
Expand Down
10 changes: 6 additions & 4 deletions RogueLibsCore/RogueFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,24 @@ internal static void LogError(MethodBase method)

internal const int SpecialInt = -488755541;

#pragma warning disable CS0618
/// <summary>
/// <para>The list of item hook factories, used by RogueLibs.</para>
/// </summary>
public static readonly List<IHookFactory> ItemFactories = new List<IHookFactory>();
public static readonly List<IHookFactory<InvItem>> ItemFactories = new();
/// <summary>
/// <para>The list of trait hook factories, used by RogueLibs.</para>
/// </summary>
public static readonly List<IHookFactory> TraitFactories = new List<IHookFactory>();
public static readonly List<IHookFactory<Trait>> TraitFactories = new();
/// <summary>
/// <para>The list of effect hook factories, used by RogueLibs.</para>
/// </summary>
public static readonly List<IHookFactory> EffectFactories = new List<IHookFactory>();
public static readonly List<IHookFactory<StatusEffect>> EffectFactories = new();
/// <summary>
/// <para>The list of object hook factories, used by RogueLibs.</para>
/// </summary>
public static readonly List<IHookFactory> ObjectFactories = new List<IHookFactory>();
public static readonly List<IHookFactory<PlayfieldObject>> ObjectFactories = new();
#pragma warning restore CS0618

/// <summary>
/// <para>The list of name providers, used by RogueLibs.</para>
Expand Down

0 comments on commit 9643adc

Please sign in to comment.