0.447.1.411123

This commit is contained in:
CloneTrooper1019
2020-09-12 20:16:19 -05:00
parent 0312a1559c
commit 4240337863
37 changed files with 663 additions and 89 deletions

View File

@ -47,7 +47,20 @@ namespace RobloxFiles.DataTypes
ByPalette = BrickColors.PaletteMap.Select(number => ByNumber[number]).ToList();
}
public override int GetHashCode()
{
return Number;
}
public override bool Equals(object obj)
{
if (!(obj is BrickColor))
return false;
var bc = obj as BrickColor;
return Number == bc.Number;
}
public static BrickColor FromName(string name)
{
BrickColor result = null;

View File

@ -38,6 +38,40 @@ namespace RobloxFiles.DataTypes
public Vector3 ColumnY => new Vector3(m21, m22, m23);
public Vector3 ColumnZ => new Vector3(m31, m32, m33);
public override int GetHashCode()
{
var components = GetComponents();
int hashCode = 0;
foreach (float component in components)
hashCode ^= component.GetHashCode();
return hashCode;
}
public override bool Equals(object obj)
{
if (!(obj is CFrame))
return false;
var other = obj as CFrame;
var compA = GetComponents();
var compB = other.GetComponents();
for (int i = 0; i < 12; i++)
{
float a = compA[i],
b = compB[i];
if (a.Equals(b))
continue;
return false;
}
return true;
}
public CFrame()
{
m14 = 0;

View File

@ -20,7 +20,26 @@ namespace RobloxFiles.DataTypes
g = G.GetHashCode(),
b = B.GetHashCode();
return (r ^ g ^ b);
return r ^ g ^ b;
}
public override bool Equals(object obj)
{
if (!(obj is Color3))
return false;
var other = obj as Color3;
if (!R.Equals(other.R))
return false;
if (!G.Equals(other.G))
return false;
if (!B.Equals(other.B))
return false;
return true;
}
internal Color3(Attribute attr)

View File

@ -18,7 +18,18 @@
public override int GetHashCode()
{
return (R << 24) | (G << 8) | B;
return (R << 16) | (G << 8) | B;
}
public override bool Equals(object obj)
{
if (!(obj is Color3uint8))
return false;
int rgb0 = GetHashCode(),
rgb1 = obj.GetHashCode();
return rgb0.Equals(rgb1);
}
public static implicit operator Color3(Color3uint8 color)

View File

@ -28,6 +28,41 @@ namespace RobloxFiles.DataTypes
};
}
public override int GetHashCode()
{
int hash = 0;
foreach (var keypoint in Keypoints)
hash ^= keypoint.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is ColorSequence))
return false;
var colorSeq = obj as ColorSequence;
var otherKeys = colorSeq.Keypoints;
if (Keypoints.Length != otherKeys.Length)
return false;
for (int i = 0; i < Keypoints.Length; i++)
{
var keyA = Keypoints[i];
var keyB = otherKeys[i];
if (keyA.Equals(keyB))
continue;
return false;
}
return true;
}
public ColorSequence(ColorSequenceKeypoint[] keypoints)
{
int numKeys = keypoints.Length;

View File

@ -25,5 +25,33 @@
Time = attr.readFloat();
Value = new Color3(attr);
}
public override int GetHashCode()
{
int hash = Time.GetHashCode()
^ Value.GetHashCode()
^ Envelope.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is ColorSequenceKeypoint))
return false;
var otherKey = obj as ColorSequenceKeypoint;
if (!Time.Equals(otherKey.Time))
return false;
if (!Value.Equals(otherKey.Value))
return false;
if (!Envelope.Equals(otherKey.Envelope))
return false;
return true;
}
}
}

View File

@ -23,5 +23,19 @@
{
return new Content(url);
}
public override int GetHashCode()
{
return Url.GetHashCode();
}
public override bool Equals(object obj)
{
if (!(obj is Content))
return false;
var content = obj as Content;
return Url.Equals(content.Url);
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.Diagnostics.Contracts;
namespace RobloxFiles.DataTypes
{
@ -15,31 +16,38 @@ namespace RobloxFiles.DataTypes
Max = num;
}
private static void checkRange(float min, float max)
{
if (max - min >= 0)
return;
throw new Exception("NumberRange: invalid range");
}
public NumberRange(float min = 0, float max = 0)
{
checkRange(min, max);
Contract.Requires(max - min >= 0, "Max must be greater than min.");
Contract.EndContractBlock();
Min = min;
Max = max;
}
internal NumberRange(Attribute attr)
internal NumberRange(Attribute attr) : this(attr.readFloat(), attr.readFloat())
{
float min = attr.readFloat();
float max = attr.readFloat();
}
checkRange(min, max);
public override int GetHashCode()
{
return Min.GetHashCode() ^ Max.GetHashCode();
}
Min = min;
Max = max;
public override bool Equals(object obj)
{
if (!(obj is NumberRange))
return false;
var other = obj as NumberRange;
if (!Min.Equals(other.Min))
return false;
if (!Max.Equals(other.Max))
return false;
return true;
}
}
}

View File

@ -62,5 +62,40 @@ namespace RobloxFiles.DataTypes
Keypoints = keypoints;
}
public override int GetHashCode()
{
int hash = 0;
foreach (var keypoint in Keypoints)
hash ^= keypoint.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is NumberSequence))
return false;
var colorSeq = obj as NumberSequence;
var otherKeys = colorSeq.Keypoints;
if (Keypoints.Length != otherKeys.Length)
return false;
for (int i = 0; i < Keypoints.Length; i++)
{
var keyA = Keypoints[i];
var keyB = otherKeys[i];
if (keyA.Equals(keyB))
continue;
return false;
}
return true;
}
}
}

View File

@ -24,5 +24,33 @@
Time = attr.readFloat();
Value = attr.readFloat();
}
public override int GetHashCode()
{
int hash = Time.GetHashCode()
^ Value.GetHashCode()
^ Envelope.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is NumberSequenceKeypoint))
return false;
var otherKey = obj as NumberSequenceKeypoint;
if (!Time.Equals(otherKey.Time))
return false;
if (!Value.Equals(otherKey.Value))
return false;
if (!Envelope.Equals(otherKey.Envelope))
return false;
return true;
}
}
}

View File

@ -46,5 +46,41 @@ namespace RobloxFiles.DataTypes
FrictionWeight = attr.readFloat();
ElasticityWeight = attr.readFloat();
}
public override int GetHashCode()
{
int hash = Density.GetHashCode()
^ Friction.GetHashCode()
^ Elasticity.GetHashCode()
^ FrictionWeight.GetHashCode()
^ ElasticityWeight.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is PhysicalProperties))
return false;
var other = obj as PhysicalProperties;
if (!Density.Equals(other.Density))
return false;
if (!Friction.Equals(other.Friction))
return false;
if (!Elasticity.Equals(other.Elasticity))
return false;
if (!FrictionWeight.Equals(other.FrictionWeight))
return false;
if (!ElasticityWeight.Equals(other.ElasticityWeight))
return false;
return true;
}
}
}

View File

@ -1,4 +1,5 @@
using System.Text;
using System;
using System.Text;
namespace RobloxFiles.DataTypes
{
@ -50,5 +51,29 @@ namespace RobloxFiles.DataTypes
{
return new ProtectedString(value);
}
public override bool Equals(object obj)
{
if (!(obj is ProtectedString))
return false;
var other = obj as ProtectedString;
var otherBuffer = other.RawBuffer;
if (RawBuffer.Length != otherBuffer.Length)
return false;
for (int i = 0; i < RawBuffer.Length; i++)
if (RawBuffer[i] != otherBuffer[i])
return false;
return true;
}
public override int GetHashCode()
{
var str = Convert.ToBase64String(RawBuffer);
return str.GetHashCode();
}
}
}

View File

@ -40,7 +40,6 @@ namespace RobloxFiles.DataTypes
public Quaternion(CFrame cf)
{
CFrame matrix = (cf - cf.Position);
float[] ac = cf.GetComponents();
float m11 = ac[3], m12 = ac[4], m13 = ac[5],
@ -204,5 +203,37 @@ namespace RobloxFiles.DataTypes
return new Quaternion(s1 * v2 + s2 * v1 + v1.Cross(v2), s1 * s2 - v1.Dot(v2));
}
public override int GetHashCode()
{
int hash = X.GetHashCode()
^ Y.GetHashCode()
^ Z.GetHashCode()
^ W.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is Quaternion))
return false;
var other = obj as Quaternion;
if (!X.Equals(other.X))
return false;
if (!Y.Equals(other.Y))
return false;
if (!Z.Equals(other.Z))
return false;
if (!W.Equals(other.W))
return false;
return true;
}
}
}

View File

@ -50,5 +50,29 @@
Vector3 closestPoint = ClosestPoint(point);
return (point - closestPoint).Magnitude;
}
public override bool Equals(object obj)
{
if (!(obj is Ray))
return false;
var other = obj as Ray;
if (!Origin.Equals(other.Origin))
return false;
if (!Direction.Equals(other.Direction))
return false;
return true;
}
public override int GetHashCode()
{
int hash = Origin.GetHashCode()
^ Direction.GetHashCode();
return hash;
}
}
}

View File

@ -27,5 +27,29 @@
Min = new Vector2(attr);
Max = new Vector2(attr);
}
public override int GetHashCode()
{
int hash = Min.GetHashCode()
^ Max.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is Rect))
return false;
var other = obj as Rect;
if (!Min.Equals(other.Min))
return false;
if (!Max.Equals(other.Max))
return false;
return true;
}
}
}

View File

@ -41,5 +41,29 @@ namespace RobloxFiles.DataTypes
return new Region3(emin, emax);
}
public override int GetHashCode()
{
int hash = Min.GetHashCode()
^ Max.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is Region3))
return false;
var other = obj as Region3;
if (!Min.Equals(other.Min))
return false;
if (!Max.Equals(other.Max))
return false;
return true;
}
}
}

View File

@ -16,5 +16,29 @@
Min = new Vector3int16(attr);
Max = new Vector3int16(attr);
}
public override int GetHashCode()
{
int hash = Min.GetHashCode()
^ Max.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is Region3int16))
return false;
var other = obj as Region3int16;
if (!Min.Equals(other.Min))
return false;
if (!Max.Equals(other.Max))
return false;
return true;
}
}
}

View File

@ -23,6 +23,20 @@ namespace RobloxFiles.DataTypes
public byte[] SharedValue => Find(ComputedKey ?? Key);
public override string ToString() => $"Key: {ComputedKey ?? Key}";
public override int GetHashCode()
{
return Key.GetHashCode();
}
public override bool Equals(object obj)
{
if (!(obj is SharedString))
return false;
var other = (obj as SharedString);
return Key.Equals(other.Key);
}
internal SharedString(string key)
{
Key = key;

View File

@ -28,5 +28,29 @@
{
return new UDim(a.Scale - b.Scale, a.Offset - b.Offset);
}
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;
}
}
}

View File

@ -36,5 +36,29 @@
return new UDim2(scaleX, offsetX, scaleY, offsetY);
}
public override int GetHashCode()
{
int hash = X.GetHashCode()
^ Y.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is UDim2))
return false;
var other = obj as UDim2;
if (!X.Equals(other.X))
return false;
if (!Y.Equals(other.Y))
return false;
return true;
}
}
}

View File

@ -103,5 +103,29 @@ namespace RobloxFiles.DataTypes
{
return this + (other - this) * t;
}
public override int GetHashCode()
{
int hash = X.GetHashCode()
^ Y.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is Vector2))
return false;
var other = obj as Vector2;
if (!X.Equals(other.X))
return false;
if (!Y.Equals(other.Y))
return false;
return true;
}
}
}

View File

@ -65,5 +65,29 @@ namespace RobloxFiles.DataTypes
public static Vector2int16 operator /(Vector2int16 a, Vector2int16 b) => div(a, b);
public static Vector2int16 operator /(Vector2int16 v, short n) => upcastShortOp(v, n, div);
public static Vector2int16 operator /(short n, Vector2int16 v) => upcastShortOp(n, v, div);
public override int GetHashCode()
{
int hash = X.GetHashCode()
^ Y.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is Vector2int16))
return false;
var other = obj as Vector2int16;
if (!X.Equals(other.X))
return false;
if (!Y.Equals(other.Y))
return false;
return true;
}
}
}

View File

@ -66,36 +66,6 @@ namespace RobloxFiles.DataTypes
return new Vector3(coords);
}
public override bool Equals(object obj)
{
if (obj is Vector3)
{
Vector3 other = obj as Vector3;
if (!X.FuzzyEquals(other.X))
return false;
if (!Y.FuzzyEquals(other.Y))
return false;
if (!Z.FuzzyEquals(other.Z))
return false;
return true;
}
return base.Equals(obj);
}
public override int GetHashCode()
{
int x = X.GetHashCode(),
y = Y.GetHashCode(),
z = Z.GetHashCode();
return x ^ y ^ z;
}
private delegate Vector3 Operator(Vector3 a, Vector3 b);
private static Vector3 upcastFloatOp(Vector3 vec, float num, Operator upcast)
@ -189,5 +159,33 @@ namespace RobloxFiles.DataTypes
return result;
}
public override int GetHashCode()
{
int hash = X.GetHashCode()
^ Y.GetHashCode()
^ Z.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is Vector3))
return false;
var other = obj as Vector3;
if (!X.Equals(other.X))
return false;
if (!Y.Equals(other.Y))
return false;
if (!Z.Equals(other.Z))
return false;
return true;
}
}
}

View File

@ -72,5 +72,33 @@ namespace RobloxFiles.DataTypes
public static Vector3int16 operator /(Vector3int16 a, Vector3int16 b) => div(a, b);
public static Vector3int16 operator /(Vector3int16 v, short n) => upcastShortOp(v, n, div);
public static Vector3int16 operator /(short n, Vector3int16 v) => upcastShortOp(n, v, div);
public override int GetHashCode()
{
int hash = X.GetHashCode()
^ Y.GetHashCode()
^ Z.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (!(obj is Vector3int16))
return false;
var other = obj as Vector3int16;
if (!X.Equals(other.X))
return false;
if (!Y.Equals(other.Y))
return false;
if (!Z.Equals(other.Z))
return false;
return true;
}
}
}