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

Commit

Permalink
✨ Add Type properties to custom hook metadata classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chasmical committed Jul 30, 2023
1 parent f5d4a23 commit cc7fbfd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions RogueLibsCore/Hooks/Effects/CustomEffectMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace RogueLibsCore
/// </summary>
public sealed class CustomEffectMetadata
{
public Type Type { get; }
/// <summary>
/// <para>Gets the custom effect's name.</para>
/// </summary>
Expand Down Expand Up @@ -69,6 +70,7 @@ private CustomEffectMetadata(Type type)
if (!typeof(CustomEffect).IsAssignableFrom(type))
throw new ArgumentException($"The specified {nameof(type)} is not a {nameof(CustomEffect)}.", nameof(type));

Type = type;
EffectNameAttribute? attr = type.GetCustomAttributes<EffectNameAttribute>().FirstOrDefault();
Name = attr?.Name ?? type.Name;

Expand Down
2 changes: 2 additions & 0 deletions RogueLibsCore/Hooks/Items/CustomItemMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace RogueLibsCore
/// </summary>
public sealed class CustomItemMetadata
{
public Type Type { get; }
/// <summary>
/// <para>Gets the custom item's name.</para>
/// </summary>
Expand Down Expand Up @@ -69,6 +70,7 @@ private CustomItemMetadata(Type type)
if (!typeof(CustomItem).IsAssignableFrom(type))
throw new ArgumentException($"{nameof(type)} does not inherit from {nameof(CustomItem)}!", nameof(type));

Type = type;
ItemNameAttribute? nameAttr = type.GetCustomAttributes<ItemNameAttribute>().FirstOrDefault();
Name = nameAttr?.Name ?? type.Name;

Expand Down
2 changes: 2 additions & 0 deletions RogueLibsCore/Hooks/Traits/CustomTraitMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace RogueLibsCore
/// </summary>
public sealed class CustomTraitMetadata
{
public Type Type { get; }
/// <summary>
/// <para>Gets the custom trait's name.</para>
/// </summary>
Expand Down Expand Up @@ -58,6 +59,7 @@ private CustomTraitMetadata(Type type)
if (!typeof(CustomTrait).IsAssignableFrom(type))
throw new ArgumentException($"The specified type is not a {nameof(CustomTrait)}!", nameof(type));

Type = type;
TraitNameAttribute? nameAttr = type.GetCustomAttributes<TraitNameAttribute>().FirstOrDefault();
Name = nameAttr?.Name ?? type.Name;
}
Expand Down
2 changes: 2 additions & 0 deletions RogueLibsCore/Misc/CustomDisasterMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace RogueLibsCore
/// </summary>
public sealed class CustomDisasterMetadata
{
public Type Type { get; }
/// <summary>
/// <para>Gets the custom disaster's name.</para>
/// </summary>
Expand Down Expand Up @@ -56,6 +57,7 @@ private CustomDisasterMetadata(Type type)
if (!typeof(CustomDisaster).IsAssignableFrom(type))
throw new ArgumentException($"The specified type is not a {nameof(CustomDisaster)}!", nameof(type));

Type = type;
DisasterNameAttribute? nameAttr = type.GetCustomAttributes<DisasterNameAttribute>().FirstOrDefault();
Name = nameAttr?.Name ?? type.Name;
}
Expand Down

0 comments on commit cc7fbfd

Please sign in to comment.