Light maintenance
This commit is contained in:
@ -54,10 +54,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is BrickColor))
|
||||
if (!(obj is BrickColor bc))
|
||||
return false;
|
||||
|
||||
var bc = obj as BrickColor;
|
||||
return Number == bc.Number;
|
||||
}
|
||||
|
||||
|
@ -51,10 +51,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is CFrame))
|
||||
if (!(obj is CFrame other))
|
||||
return false;
|
||||
|
||||
var other = obj as CFrame;
|
||||
var compA = GetComponents();
|
||||
var compB = other.GetComponents();
|
||||
|
||||
@ -420,13 +419,24 @@ namespace RobloxFiles.DataTypes
|
||||
return new float[] { m14, m24, m34, m11, m12, m13, m21, m22, m23, m31, m32, m33 };
|
||||
}
|
||||
|
||||
public EulerAngles ToEulerAngles() => new EulerAngles
|
||||
{
|
||||
Yaw = (float)Math.Asin(m13),
|
||||
Pitch = (float)Math.Atan2(-m23, m33),
|
||||
Roll = (float)Math.Atan2(-m12, m11),
|
||||
};
|
||||
|
||||
[Obsolete]
|
||||
public float[] ToEulerAnglesXYZ()
|
||||
{
|
||||
float x = (float)Math.Atan2(-m23, m33);
|
||||
float y = (float)Math.Asin(m13);
|
||||
float z = (float)Math.Atan2(-m12, m11);
|
||||
var result = ToEulerAngles();
|
||||
|
||||
return new float[] { x, y, z };
|
||||
return new float[]
|
||||
{
|
||||
result.Pitch,
|
||||
result.Yaw,
|
||||
result.Roll
|
||||
};
|
||||
}
|
||||
|
||||
public bool IsAxisAligned()
|
||||
|
@ -25,11 +25,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Color3))
|
||||
if (!(obj is Color3 other))
|
||||
return false;
|
||||
|
||||
var other = obj as Color3;
|
||||
|
||||
if (!R.Equals(other.R))
|
||||
return false;
|
||||
|
||||
|
@ -40,10 +40,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is ColorSequence))
|
||||
if (!(obj is ColorSequence colorSeq))
|
||||
return false;
|
||||
|
||||
var colorSeq = obj as ColorSequence;
|
||||
var otherKeys = colorSeq.Keypoints;
|
||||
|
||||
if (Keypoints.Length != otherKeys.Length)
|
||||
|
@ -37,11 +37,9 @@
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is ColorSequenceKeypoint))
|
||||
if (!(obj is ColorSequenceKeypoint otherKey))
|
||||
return false;
|
||||
|
||||
var otherKey = obj as ColorSequenceKeypoint;
|
||||
|
||||
if (!Time.Equals(otherKey.Time))
|
||||
return false;
|
||||
|
||||
|
@ -31,10 +31,9 @@
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Content))
|
||||
if (!(obj is Content content))
|
||||
return false;
|
||||
|
||||
var content = obj as Content;
|
||||
return Url.Equals(content.Url);
|
||||
}
|
||||
}
|
||||
|
9
DataTypes/EulerAngles.cs
Normal file
9
DataTypes/EulerAngles.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct EulerAngles
|
||||
{
|
||||
public float Yaw;
|
||||
public float Pitch;
|
||||
public float Roll;
|
||||
}
|
||||
}
|
@ -36,11 +36,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is NumberRange))
|
||||
if (!(obj is NumberRange other))
|
||||
return false;
|
||||
|
||||
var other = obj as NumberRange;
|
||||
|
||||
if (!Min.Equals(other.Min))
|
||||
return false;
|
||||
|
||||
|
@ -75,11 +75,10 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is NumberSequence))
|
||||
if (!(obj is NumberSequence numberSeq))
|
||||
return false;
|
||||
|
||||
var colorSeq = obj as NumberSequence;
|
||||
var otherKeys = colorSeq.Keypoints;
|
||||
var otherKeys = numberSeq.Keypoints;
|
||||
|
||||
if (Keypoints.Length != otherKeys.Length)
|
||||
return false;
|
||||
|
@ -36,11 +36,9 @@
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is NumberSequenceKeypoint))
|
||||
if (!(obj is NumberSequenceKeypoint otherKey))
|
||||
return false;
|
||||
|
||||
var otherKey = obj as NumberSequenceKeypoint;
|
||||
|
||||
if (!Time.Equals(otherKey.Time))
|
||||
return false;
|
||||
|
||||
|
@ -60,11 +60,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is PhysicalProperties))
|
||||
if (!(obj is PhysicalProperties other))
|
||||
return false;
|
||||
|
||||
var other = obj as PhysicalProperties;
|
||||
|
||||
if (!Density.Equals(other.Density))
|
||||
return false;
|
||||
|
||||
|
@ -54,10 +54,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is ProtectedString))
|
||||
if (!(obj is ProtectedString other))
|
||||
return false;
|
||||
|
||||
var other = obj as ProtectedString;
|
||||
var otherBuffer = other.RawBuffer;
|
||||
|
||||
if (RawBuffer.Length != otherBuffer.Length)
|
||||
|
@ -134,21 +134,21 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public CFrame ToCFrame()
|
||||
{
|
||||
float xc = X * 2f;
|
||||
float yc = Y * 2f;
|
||||
float zc = Z * 2f;
|
||||
float xc = X * 2f,
|
||||
yc = Y * 2f,
|
||||
zc = Z * 2f;
|
||||
|
||||
float xx = X * xc;
|
||||
float xy = X * yc;
|
||||
float xz = X * zc;
|
||||
float xx = X * xc,
|
||||
xy = X * yc,
|
||||
xz = X * zc;
|
||||
|
||||
float wx = W * xc;
|
||||
float wy = W * yc;
|
||||
float wz = W * zc;
|
||||
float wx = W * xc,
|
||||
wy = W * yc,
|
||||
wz = W * zc;
|
||||
|
||||
float yy = Y * yc;
|
||||
float yz = Y * zc;
|
||||
float zz = Z * zc;
|
||||
float yy = Y * yc,
|
||||
yz = Y * zc,
|
||||
zz = Z * zc;
|
||||
|
||||
return new CFrame
|
||||
(
|
||||
@ -195,15 +195,33 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public static Quaternion operator *(Quaternion a, Quaternion b)
|
||||
{
|
||||
Vector3 v1 = new Vector3(a.X, a.Y, a.Z);
|
||||
float s1 = a.W;
|
||||
Vector3 v1 = new Vector3(a.X, a.Y, a.Z),
|
||||
v2 = new Vector3(b.X, b.Y, b.Z);
|
||||
|
||||
Vector3 v2 = new Vector3(b.X, b.Y, b.Z);
|
||||
float s2 = b.W;
|
||||
float s1 = a.W,
|
||||
s2 = b.W;
|
||||
|
||||
return new Quaternion(s1 * v2 + s2 * v1 + v1.Cross(v2), s1 * s2 - v1.Dot(v2));
|
||||
}
|
||||
|
||||
public EulerAngles ToEulerAngles()
|
||||
{
|
||||
var angles = new EulerAngles();
|
||||
|
||||
double sinr_cosp = 2 * (W * X + Y * Z);
|
||||
double cosr_cosp = 1 - 2 * (X * X + Y * Y);
|
||||
angles.Roll = (float)Math.Atan2(sinr_cosp, cosr_cosp);
|
||||
|
||||
double sinp = 2 * (W * Y - Z * X);
|
||||
angles.Pitch = (float)Math.Asin(sinp);
|
||||
|
||||
double siny_cosp = 2 * (W * Z + X * Y);
|
||||
double cosy_cosp = 1 - 2 * (Y * Y + Z * Z);
|
||||
angles.Yaw = (float)Math.Atan2(siny_cosp, cosy_cosp);
|
||||
|
||||
return angles;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hash = X.GetHashCode()
|
||||
@ -216,11 +234,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Quaternion))
|
||||
if (!(obj is Quaternion other))
|
||||
return false;
|
||||
|
||||
var other = obj as Quaternion;
|
||||
|
||||
if (!X.Equals(other.X))
|
||||
return false;
|
||||
|
||||
|
@ -53,11 +53,9 @@
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Ray))
|
||||
if (!(obj is Ray other))
|
||||
return false;
|
||||
|
||||
var other = obj as Ray;
|
||||
|
||||
if (!Origin.Equals(other.Origin))
|
||||
return false;
|
||||
|
||||
|
@ -38,11 +38,9 @@
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Rect))
|
||||
if (!(obj is Rect other))
|
||||
return false;
|
||||
|
||||
var other = obj as Rect;
|
||||
|
||||
if (!Min.Equals(other.Min))
|
||||
return false;
|
||||
|
||||
|
@ -52,11 +52,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Region3))
|
||||
if (!(obj is Region3 other))
|
||||
return false;
|
||||
|
||||
var other = obj as Region3;
|
||||
|
||||
if (!Min.Equals(other.Min))
|
||||
return false;
|
||||
|
||||
|
@ -27,11 +27,9 @@
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Region3int16))
|
||||
if (!(obj is Region3int16 other))
|
||||
return false;
|
||||
|
||||
var other = obj as Region3int16;
|
||||
|
||||
if (!Min.Equals(other.Min))
|
||||
return false;
|
||||
|
||||
|
@ -30,10 +30,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is SharedString))
|
||||
if (!(obj is SharedString other))
|
||||
return false;
|
||||
|
||||
var other = (obj as SharedString);
|
||||
return Key.Equals(other.Key);
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,9 @@
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is UDim))
|
||||
if (!(obj is UDim other))
|
||||
return false;
|
||||
|
||||
var other = obj as UDim;
|
||||
|
||||
if (!Scale.Equals(other.Scale))
|
||||
return false;
|
||||
|
||||
|
@ -47,11 +47,9 @@
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is UDim2))
|
||||
if (!(obj is UDim2 other))
|
||||
return false;
|
||||
|
||||
var other = obj as UDim2;
|
||||
|
||||
if (!X.Equals(other.X))
|
||||
return false;
|
||||
|
||||
|
@ -114,11 +114,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Vector2))
|
||||
if (!(obj is Vector2 other))
|
||||
return false;
|
||||
|
||||
var other = obj as Vector2;
|
||||
|
||||
if (!X.Equals(other.X))
|
||||
return false;
|
||||
|
||||
|
@ -76,11 +76,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Vector2int16))
|
||||
if (!(obj is Vector2int16 other))
|
||||
return false;
|
||||
|
||||
var other = obj as Vector2int16;
|
||||
|
||||
if (!X.Equals(other.X))
|
||||
return false;
|
||||
|
||||
|
@ -171,11 +171,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Vector3))
|
||||
if (!(obj is Vector3 other))
|
||||
return false;
|
||||
|
||||
var other = obj as Vector3;
|
||||
|
||||
if (!X.Equals(other.X))
|
||||
return false;
|
||||
|
||||
|
@ -84,11 +84,9 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Vector3int16))
|
||||
if (!(obj is Vector3int16 other))
|
||||
return false;
|
||||
|
||||
var other = obj as Vector3int16;
|
||||
|
||||
if (!X.Equals(other.X))
|
||||
return false;
|
||||
|
||||
|
Reference in New Issue
Block a user