mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-16 02:09:20 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
64 lines
1.2 KiB
C#
64 lines
1.2 KiB
C#
using System.Collections.Immutable;
|
|
|
|
namespace Sandbox.UI;
|
|
|
|
[SkipHotload]
|
|
internal struct GradientInfo
|
|
{
|
|
|
|
public float Angle;
|
|
public Length OffsetX;
|
|
public Length OffsetY;
|
|
public RadialSizeMode SizeMode;
|
|
public GradientTypes GradientType;
|
|
public ImmutableArray<Styles.GradientColorOffset> ColorOffsets;
|
|
|
|
public void CopyFrom( GradientInfo other )
|
|
{
|
|
ColorOffsets = ImmutableArray<Styles.GradientColorOffset>.Empty;
|
|
|
|
if ( !other.ColorOffsets.IsDefaultOrEmpty )
|
|
{
|
|
ColorOffsets = ColorOffsets.AddRange( other.ColorOffsets );
|
|
}
|
|
|
|
Angle = other.Angle;
|
|
SizeMode = other.SizeMode;
|
|
OffsetX = other.OffsetX;
|
|
OffsetY = other.OffsetY;
|
|
GradientType = other.GradientType;
|
|
}
|
|
|
|
public void AddFrom( GradientInfo other )
|
|
{
|
|
if ( other.ColorOffsets.IsDefaultOrEmpty )
|
|
return;
|
|
|
|
CopyFrom( other );
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
if ( ColorOffsets.IsDefaultOrEmpty )
|
|
return 0;
|
|
|
|
return HashCode.Combine( Angle, SizeMode, OffsetX, OffsetY, GradientType, ColorOffsets );
|
|
}
|
|
|
|
public enum RadialSizeMode
|
|
{
|
|
FarthestSide = 0,
|
|
FarthestCorner = 1,
|
|
ClosestSide = 2,
|
|
ClosestCorner = 3,
|
|
Circle = 4
|
|
}
|
|
|
|
public enum GradientTypes
|
|
{
|
|
Linear = 0,
|
|
Radial = 1
|
|
}
|
|
|
|
}
|