v1.6.17.0 (Unto the Breach update)
This commit is contained in:
@@ -7,8 +7,13 @@ namespace Barotrauma.Extensions
|
||||
public static Color Multiply(this Color color, float value, bool onlyAlpha = false)
|
||||
{
|
||||
return onlyAlpha ?
|
||||
new Color(color.R, color.G, color.B, (byte)(color.A * value)) :
|
||||
new Color((byte)(color.R * value), (byte)(color.G * value), (byte)(color.B * value), (byte)(color.A * value));
|
||||
new Color(color.R, color.G, color.B, MultiplyComponent(color.A, value)) :
|
||||
new Color(MultiplyComponent(color.R, value), MultiplyComponent(color.G, value), MultiplyComponent(color.B, value), MultiplyComponent(color.A, value));
|
||||
|
||||
static byte MultiplyComponent(float colorComponent, float multiplier)
|
||||
{
|
||||
return (byte)MathHelper.Clamp(colorComponent * multiplier, 0.0f, 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public static Color Multiply(this Color thisColor, Color color)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma.Extensions
|
||||
{
|
||||
@@ -36,5 +37,13 @@ namespace Barotrauma.Extensions
|
||||
int flagValue = Convert.ToInt32(flag);
|
||||
return (T)(object)(enumValue & ~flagValue);
|
||||
}
|
||||
|
||||
public static IEnumerable<T> GetIndividualFlags<T>(T flagsEnum) where T : Enum
|
||||
{
|
||||
foreach (T value in Enum.GetValues(typeof(T)))
|
||||
{
|
||||
if (flagsEnum.HasFlag(value)) { yield return value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user