ProjectDDD/Assets/_DDD/_Scripts/Utilities/Extenstions.cs

26 lines
666 B
C#
Raw Normal View History

2025-08-26 04:59:03 +00:00
using System;
using System.Collections.Generic;
namespace DDD
{
public static class IntExtensions
{
public static string ToGold(this int gold)
{
return $"{gold} G";
}
}
public static class EnumExtensions
{
public static IEnumerable<T> GetFlags<T>(this T input) where T : Enum
{
foreach (T value in Enum.GetValues(typeof(T)))
{
int intValue = Convert.ToInt32(value);
int inputValue = Convert.ToInt32(input);
if (intValue != 0 && (inputValue & intValue) == intValue) yield return value;
}
}
}
}