2019-02-01 17:19:20 +00:00
|
|
|
|
namespace RobloxFiles.DataTypes
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
public class UDim
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
|
|
|
|
public readonly float Scale;
|
|
|
|
|
public readonly int Offset;
|
|
|
|
|
|
2019-11-01 02:40:31 +00:00
|
|
|
|
public override string ToString() => $"{Scale}, {Offset}";
|
|
|
|
|
|
2019-01-26 00:39:37 +00:00
|
|
|
|
public UDim(float scale = 0, int offset = 0)
|
|
|
|
|
{
|
|
|
|
|
Scale = scale;
|
|
|
|
|
Offset = offset;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-01 02:40:31 +00:00
|
|
|
|
internal UDim(Attribute attr)
|
|
|
|
|
{
|
|
|
|
|
Scale = attr.readFloat();
|
|
|
|
|
Offset = attr.readInt();
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-26 00:39:37 +00:00
|
|
|
|
public static UDim operator+(UDim a, UDim b)
|
|
|
|
|
{
|
|
|
|
|
return new UDim(a.Scale + b.Scale, a.Offset + b.Offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static UDim operator-(UDim a, UDim b)
|
|
|
|
|
{
|
|
|
|
|
return new UDim(a.Scale - b.Scale, a.Offset - b.Offset);
|
|
|
|
|
}
|
2020-09-13 01:16:19 +00:00
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
int hash = Scale.GetHashCode()
|
|
|
|
|
^ Offset.GetHashCode();
|
|
|
|
|
|
|
|
|
|
return hash;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
if (!(obj is UDim))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
var other = obj as UDim;
|
|
|
|
|
|
|
|
|
|
if (!Scale.Equals(other.Scale))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!Offset.Equals(other.Offset))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-01-26 00:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|