Convert datatypes to classes instead of structs.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using RobloxFiles.DataTypes.Utility;
|
||||
using RobloxFiles.Utility;
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
@ -35,7 +35,7 @@ namespace RobloxFiles.DataTypes
|
||||
Name = name;
|
||||
Number = number;
|
||||
|
||||
Color = Color3.fromRGB(r, g, b);
|
||||
Color = Color3.FromRGB(r, g, b);
|
||||
}
|
||||
|
||||
static BrickColor()
|
||||
@ -43,7 +43,7 @@ namespace RobloxFiles.DataTypes
|
||||
ByNumber = BrickColors.ColorMap.ToDictionary(brickColor => brickColor.Number);
|
||||
ByPalette = BrickColors.PaletteMap.Select(number => ByNumber[number]).ToList();
|
||||
}
|
||||
|
||||
|
||||
public static BrickColor FromName(string name)
|
||||
{
|
||||
BrickColor result = null;
|
||||
|
@ -20,6 +20,13 @@ namespace RobloxFiles.DataTypes
|
||||
public Vector3 RightVector => new Vector3( m11, m21, m31);
|
||||
public Vector3 UpVector => new Vector3( m12, m22, m32);
|
||||
|
||||
public CFrame()
|
||||
{
|
||||
m14 = 0;
|
||||
m24 = 0;
|
||||
m34 = 0;
|
||||
}
|
||||
|
||||
public CFrame(Vector3 pos)
|
||||
{
|
||||
m14 = pos.X;
|
||||
@ -27,6 +34,14 @@ namespace RobloxFiles.DataTypes
|
||||
m34 = pos.Z;
|
||||
}
|
||||
|
||||
public CFrame(float nx = 0, float ny = 0, float nz = 0)
|
||||
{
|
||||
m14 = nx;
|
||||
m24 = ny;
|
||||
m34 = nz;
|
||||
}
|
||||
|
||||
|
||||
public CFrame(Vector3 eye, Vector3 look)
|
||||
{
|
||||
Vector3 zAxis = (eye - look).Unit;
|
||||
@ -37,9 +52,9 @@ namespace RobloxFiles.DataTypes
|
||||
{
|
||||
if (zAxis.Y < 0)
|
||||
{
|
||||
xAxis = new Vector3(0, 0, -1);
|
||||
yAxis = new Vector3(1, 0, 0);
|
||||
zAxis = new Vector3(0, -1, 0);
|
||||
xAxis = new Vector3(0, 0, -1);
|
||||
yAxis = new Vector3(1, 0, 0);
|
||||
zAxis = new Vector3(0, -1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -54,13 +69,6 @@ namespace RobloxFiles.DataTypes
|
||||
m31 = xAxis.Z; m32 = yAxis.Z; m33 = zAxis.Z; m34 = eye.Z;
|
||||
}
|
||||
|
||||
public CFrame(float nx = 0, float ny = 0, float nz = 0)
|
||||
{
|
||||
m14 = nx;
|
||||
m24 = ny;
|
||||
m34 = nz;
|
||||
}
|
||||
|
||||
public CFrame(float nx, float ny, float nz, float i, float j, float k, float w)
|
||||
{
|
||||
float ii = i * i;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct Color3
|
||||
public class Color3
|
||||
{
|
||||
public readonly float R, G, B;
|
||||
|
||||
@ -18,12 +18,12 @@ namespace RobloxFiles.DataTypes
|
||||
return string.Join(", ", R, G, B);
|
||||
}
|
||||
|
||||
public static Color3 fromRGB(uint r = 0, uint g = 0, uint b = 0)
|
||||
public static Color3 FromRGB(uint r = 0, uint g = 0, uint b = 0)
|
||||
{
|
||||
return new Color3(r / 255f, g / 255f, b / 255f);
|
||||
}
|
||||
|
||||
public static Color3 fromHSV(float h = 0, float s = 0, float v = 0)
|
||||
public static Color3 FromHSV(float h = 0, float s = 0, float v = 0)
|
||||
{
|
||||
int i = (int)Math.Min(5, Math.Floor(6.0 * h));
|
||||
float f = 6.0f * h - i;
|
||||
@ -51,7 +51,7 @@ namespace RobloxFiles.DataTypes
|
||||
}
|
||||
}
|
||||
|
||||
public static float[] toHSV(Color3 color)
|
||||
public static float[] ToHSV(Color3 color)
|
||||
{
|
||||
float val = Math.Max(Math.Max(color.R, color.G), color.B);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct ColorSequence
|
||||
public class ColorSequence
|
||||
{
|
||||
public readonly ColorSequenceKeypoint[] Keypoints;
|
||||
|
||||
@ -46,7 +46,7 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(" ", Keypoints);
|
||||
return string.Join<ColorSequenceKeypoint>(" ", Keypoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct ColorSequenceKeypoint
|
||||
public class ColorSequenceKeypoint
|
||||
{
|
||||
public readonly float Time;
|
||||
public readonly Color3 Value;
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct NumberRange
|
||||
public class NumberRange
|
||||
{
|
||||
public readonly float Min;
|
||||
public readonly float Max;
|
||||
|
||||
public NumberRange(float min, float max)
|
||||
public NumberRange(float min = 0, float max = 0)
|
||||
{
|
||||
if (max - min < 0)
|
||||
throw new Exception("NumberRange: invalid range");
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct NumberSequence
|
||||
public class NumberSequence
|
||||
{
|
||||
public readonly NumberSequenceKeypoint[] Keypoints;
|
||||
|
||||
@ -46,7 +46,7 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(" ", Keypoints);
|
||||
return string.Join<NumberSequenceKeypoint>(" ", Keypoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct NumberSequenceKeypoint
|
||||
public class NumberSequenceKeypoint
|
||||
{
|
||||
public readonly float Time;
|
||||
public readonly float Value;
|
||||
|
@ -1,38 +1,28 @@
|
||||
using RobloxFiles.Enums;
|
||||
using RobloxFiles.DataTypes.Utility;
|
||||
using RobloxFiles.Utility;
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct PhysicalProperties
|
||||
public class PhysicalProperties
|
||||
{
|
||||
public readonly float Density;
|
||||
public readonly float Friction;
|
||||
public readonly float Elasticity;
|
||||
public readonly float Density = 1.0f;
|
||||
public readonly float Friction = 1.0f;
|
||||
public readonly float Elasticity = 0.5f;
|
||||
|
||||
public readonly float FrictionWeight;
|
||||
public readonly float ElasticityWeight;
|
||||
public readonly float FrictionWeight = 1.0f;
|
||||
public readonly float ElasticityWeight = 1.0f;
|
||||
|
||||
public PhysicalProperties(Material material)
|
||||
{
|
||||
if (MaterialInfo.FrictionWeightMap.ContainsKey(material))
|
||||
FrictionWeight = MaterialInfo.FrictionWeightMap[material];
|
||||
|
||||
Density = MaterialInfo.DensityMap[material];
|
||||
Friction = MaterialInfo.FrictionMap[material];
|
||||
Elasticity = MaterialInfo.ElasticityMap[material];
|
||||
|
||||
FrictionWeight = 1;
|
||||
ElasticityWeight = 1;
|
||||
}
|
||||
|
||||
public PhysicalProperties(float density, float friction, float elasticity)
|
||||
{
|
||||
Density = density;
|
||||
Friction = friction;
|
||||
Elasticity = elasticity;
|
||||
|
||||
FrictionWeight = 1;
|
||||
ElasticityWeight = 1;
|
||||
}
|
||||
|
||||
public PhysicalProperties(float density, float friction, float elasticity, float frictionWeight, float elasticityWeight)
|
||||
public PhysicalProperties(float density, float friction, float elasticity, float frictionWeight = 1f, float elasticityWeight = 1f)
|
||||
{
|
||||
Density = density;
|
||||
Friction = friction;
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct Ray
|
||||
public class Ray
|
||||
{
|
||||
public readonly Vector3 Origin;
|
||||
public readonly Vector3 Direction;
|
||||
@ -33,15 +33,19 @@
|
||||
|
||||
public Vector3 ClosestPoint(Vector3 point)
|
||||
{
|
||||
Vector3 offset = point - Origin;
|
||||
float diff = offset.Dot(Direction) / Direction.Dot(Direction);
|
||||
return Origin + (diff * Direction);
|
||||
Vector3 result = Origin;
|
||||
float t = Direction.Dot(point - result);
|
||||
|
||||
if (t >= 0)
|
||||
result += (Direction * t);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public float Distance(Vector3 point)
|
||||
{
|
||||
Vector3 projected = ClosestPoint(point);
|
||||
return (point - projected).Magnitude;
|
||||
Vector3 closestPoint = ClosestPoint(point);
|
||||
return (closestPoint - point).Magnitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct Rect
|
||||
public class Rect
|
||||
{
|
||||
public readonly Vector2 Min;
|
||||
public readonly Vector2 Max;
|
||||
@ -8,7 +8,7 @@
|
||||
public float Width => (Max - Min).X;
|
||||
public float Height => (Max - Min).Y;
|
||||
|
||||
public Rect(Vector2? min, Vector2? max)
|
||||
public Rect(Vector2 min = null, Vector2 max = null)
|
||||
{
|
||||
Min = min ?? Vector2.Zero;
|
||||
Max = max ?? Vector2.Zero;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct Region3
|
||||
public class Region3
|
||||
{
|
||||
public readonly CFrame CFrame;
|
||||
public readonly Vector3 Size;
|
||||
|
@ -10,7 +10,7 @@ namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public readonly Vector3int16 Min, Max;
|
||||
|
||||
public Region3int16(Vector3int16? min, Vector3int16? max)
|
||||
public Region3int16(Vector3int16 min = null, Vector3int16 max = null)
|
||||
{
|
||||
Min = min ?? new Vector3int16();
|
||||
Max = max ?? new Vector3int16();
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct UDim
|
||||
public class UDim
|
||||
{
|
||||
public readonly float Scale;
|
||||
public readonly int Offset;
|
||||
|
@ -1,13 +1,13 @@
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct UDim2
|
||||
public class UDim2
|
||||
{
|
||||
public readonly UDim X, Y;
|
||||
|
||||
public UDim Width => X;
|
||||
public UDim Height => Y;
|
||||
|
||||
public UDim2(float scaleX, int offsetX, float scaleY, int offsetY)
|
||||
public UDim2(float scaleX = 0, int offsetX = 0, float scaleY = 0, int offsetY = 0)
|
||||
{
|
||||
X = new UDim(scaleX, offsetX);
|
||||
Y = new UDim(scaleY, offsetY);
|
||||
|
@ -1,251 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using RobloxFiles.DataTypes;
|
||||
|
||||
namespace RobloxFiles.DataTypes.Utility
|
||||
{
|
||||
public static class BrickColors
|
||||
{
|
||||
/// <summary>
|
||||
/// This represents Roblox's static palette of BrickColors.
|
||||
/// Each int refers to the `Number` identifying a BrickColor.
|
||||
/// It is used by the BrickColor.palette constructor, which
|
||||
/// is in turn used by the BrickColor.random constructor.
|
||||
/// </summary>
|
||||
|
||||
public static readonly int[] PaletteMap = new int[128]
|
||||
{
|
||||
141, 301, 107, 26, 1012, 303, 1011, 304,
|
||||
28, 1018, 302, 305, 306, 307, 308, 1021,
|
||||
309, 310, 1019, 135, 102, 23, 1010, 312,
|
||||
313, 37, 1022, 1020, 1027, 311, 315, 1023,
|
||||
1031, 316, 151, 317, 318, 319, 1024, 314,
|
||||
1013, 1006, 321, 322, 104, 1008, 119, 323,
|
||||
324, 325, 320, 11, 1026, 1016, 1032, 1015,
|
||||
327, 1005, 1009, 29, 328, 1028, 208, 45,
|
||||
329, 330, 331, 1004, 21, 332, 333, 24,
|
||||
334, 226, 1029, 335, 336, 342, 343, 338,
|
||||
1007, 339, 133, 106, 340, 341, 1001, 1,
|
||||
9, 1025, 337, 344, 345, 1014, 105, 346,
|
||||
347, 348, 349, 1030, 125, 101, 350, 192,
|
||||
351, 352, 353, 354, 1002, 5, 18, 217,
|
||||
355, 356, 153, 357, 358, 359, 360, 38,
|
||||
361, 362, 199, 194, 363, 364, 365, 1003,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// This contains a list of all available BrickColors on Roblox.
|
||||
/// </summary>
|
||||
|
||||
public static IReadOnlyCollection<BrickColor> ColorMap = new List<BrickColor>()
|
||||
{
|
||||
new BrickColor( 1, 0xF2F3F3, "White"),
|
||||
new BrickColor( 2, 0xA1A5A2, "Grey"),
|
||||
new BrickColor( 3, 0xF9E999, "Light yellow"),
|
||||
new BrickColor( 5, 0xD7C59A, "Brick yellow"),
|
||||
new BrickColor( 6, 0xC2DAB8, "Light green (Mint)"),
|
||||
new BrickColor( 9, 0xE8BAC8, "Light reddish violet"),
|
||||
new BrickColor( 11, 0x80BBDB, "Pastel Blue"),
|
||||
new BrickColor( 12, 0xCB8442, "Light orange brown"),
|
||||
new BrickColor( 18, 0xCC8E69, "Nougat"),
|
||||
new BrickColor( 21, 0xC4281C, "Bright red"),
|
||||
new BrickColor( 22, 0xC470A0, "Med. reddish violet"),
|
||||
new BrickColor( 23, 0x0D69AC, "Bright blue"),
|
||||
new BrickColor( 24, 0xF5CD30, "Bright yellow"),
|
||||
new BrickColor( 25, 0x624732, "Earth orange"),
|
||||
new BrickColor( 26, 0x1B2A35, "Black"),
|
||||
new BrickColor( 27, 0x6D6E6C, "Dark grey"),
|
||||
new BrickColor( 28, 0x287F47, "Dark green"),
|
||||
new BrickColor( 29, 0xA1C48C, "Medium green"),
|
||||
new BrickColor( 36, 0xF3CF9B, "Lig. Yellowich orange"),
|
||||
new BrickColor( 37, 0x4B974B, "Bright green"),
|
||||
new BrickColor( 38, 0xA05F35, "Dark orange"),
|
||||
new BrickColor( 39, 0xC1CADE, "Light bluish violet"),
|
||||
new BrickColor( 40, 0xECECEC, "Transparent"),
|
||||
new BrickColor( 41, 0xCD544B, "Tr. Red"),
|
||||
new BrickColor( 42, 0xC1DFF0, "Tr. Lg blue"),
|
||||
new BrickColor( 43, 0x7BB6E8, "Tr. Blue"),
|
||||
new BrickColor( 44, 0xF7F18D, "Tr. Yellow"),
|
||||
new BrickColor( 45, 0xB4D2E4, "Light blue"),
|
||||
new BrickColor( 47, 0xD9856C, "Tr. Flu. Reddish orange"),
|
||||
new BrickColor( 48, 0x84B68D, "Tr. Green"),
|
||||
new BrickColor( 49, 0xF8F184, "Tr. Flu. Green"),
|
||||
new BrickColor( 50, 0xECE8DE, "Phosph. White"),
|
||||
new BrickColor( 100, 0xEEC4B6, "Light red"),
|
||||
new BrickColor( 101, 0xDA867A, "Medium red"),
|
||||
new BrickColor( 102, 0x6E99CA, "Medium blue"),
|
||||
new BrickColor( 103, 0xC7C1B7, "Light grey"),
|
||||
new BrickColor( 104, 0x6B327C, "Bright violet"),
|
||||
new BrickColor( 105, 0xE29B40, "Br. yellowish orange"),
|
||||
new BrickColor( 106, 0xDA8541, "Bright orange"),
|
||||
new BrickColor( 107, 0x008F9C, "Bright bluish green"),
|
||||
new BrickColor( 108, 0x685C43, "Earth yellow"),
|
||||
new BrickColor( 110, 0x435493, "Bright bluish violet"),
|
||||
new BrickColor( 111, 0xBFB7B1, "Tr. Brown"),
|
||||
new BrickColor( 112, 0x6874AC, "Medium bluish violet"),
|
||||
new BrickColor( 113, 0xE5ADC8, "Tr. Medi. reddish violet"),
|
||||
new BrickColor( 115, 0xC7D23C, "Med. yellowish green"),
|
||||
new BrickColor( 116, 0x55A5AF, "Med. bluish green"),
|
||||
new BrickColor( 118, 0xB7D7D5, "Light bluish green"),
|
||||
new BrickColor( 119, 0xA4BD47, "Br. yellowish green"),
|
||||
new BrickColor( 120, 0xD9E4A7, "Lig. yellowish green"),
|
||||
new BrickColor( 121, 0xE7AC58, "Med. yellowish orange"),
|
||||
new BrickColor( 123, 0xD36F4C, "Br. reddish orange"),
|
||||
new BrickColor( 124, 0x923978, "Bright reddish violet"),
|
||||
new BrickColor( 125, 0xEAB892, "Light orange"),
|
||||
new BrickColor( 126, 0xA5A5CB, "Tr. Bright bluish violet"),
|
||||
new BrickColor( 127, 0xDCBC81, "Gold"),
|
||||
new BrickColor( 128, 0xAE7A59, "Dark nougat"),
|
||||
new BrickColor( 131, 0x9CA3A8, "Silver"),
|
||||
new BrickColor( 133, 0xD5733D, "Neon orange"),
|
||||
new BrickColor( 134, 0xD8DD56, "Neon green"),
|
||||
new BrickColor( 135, 0x74869D, "Sand blue"),
|
||||
new BrickColor( 136, 0x877C90, "Sand violet"),
|
||||
new BrickColor( 137, 0xE09864, "Medium orange"),
|
||||
new BrickColor( 138, 0x958A73, "Sand yellow"),
|
||||
new BrickColor( 140, 0x203A56, "Earth blue"),
|
||||
new BrickColor( 141, 0x27462D, "Earth green"),
|
||||
new BrickColor( 143, 0xCFE2F7, "Tr. Flu. Blue"),
|
||||
new BrickColor( 145, 0x7988A1, "Sand blue metallic"),
|
||||
new BrickColor( 146, 0x958EA3, "Sand violet metallic"),
|
||||
new BrickColor( 147, 0x938767, "Sand yellow metallic"),
|
||||
new BrickColor( 148, 0x575857, "Dark grey metallic"),
|
||||
new BrickColor( 149, 0x161D32, "Black metallic"),
|
||||
new BrickColor( 150, 0xABADAC, "Light grey metallic"),
|
||||
new BrickColor( 151, 0x789082, "Sand green"),
|
||||
new BrickColor( 153, 0x957977, "Sand red"),
|
||||
new BrickColor( 154, 0x7B2E2F, "Dark red"),
|
||||
new BrickColor( 157, 0xFFF67B, "Tr. Flu. Yellow"),
|
||||
new BrickColor( 158, 0xE1A4C2, "Tr. Flu. Red"),
|
||||
new BrickColor( 168, 0x756C62, "Gun metallic"),
|
||||
new BrickColor( 176, 0x97695B, "Red flip/flop"),
|
||||
new BrickColor( 178, 0xB48455, "Yellow flip/flop"),
|
||||
new BrickColor( 179, 0x898788, "Silver flip/flop"),
|
||||
new BrickColor( 180, 0xD7A94B, "Curry"),
|
||||
new BrickColor( 190, 0xF9D62E, "Fire Yellow"),
|
||||
new BrickColor( 191, 0xE8AB2D, "Flame yellowish orange"),
|
||||
new BrickColor( 192, 0x694028, "Reddish brown"),
|
||||
new BrickColor( 193, 0xCF6024, "Flame reddish orange"),
|
||||
new BrickColor( 194, 0xA3A2A5, "Medium stone grey"),
|
||||
new BrickColor( 195, 0x4667A4, "Royal blue"),
|
||||
new BrickColor( 196, 0x23478B, "Dark Royal blue"),
|
||||
new BrickColor( 198, 0x8E4285, "Bright reddish lilac"),
|
||||
new BrickColor( 199, 0x635F62, "Dark stone grey"),
|
||||
new BrickColor( 200, 0x828A5D, "Lemon metalic"),
|
||||
new BrickColor( 208, 0xE5E4DF, "Light stone grey"),
|
||||
new BrickColor( 209, 0xB08E44, "Dark Curry"),
|
||||
new BrickColor( 210, 0x709578, "Faded green"),
|
||||
new BrickColor( 211, 0x79B5B5, "Turquoise"),
|
||||
new BrickColor( 212, 0x9FC3E9, "Light Royal blue"),
|
||||
new BrickColor( 213, 0x6C81B7, "Medium Royal blue"),
|
||||
new BrickColor( 216, 0x904C2A, "Rust"),
|
||||
new BrickColor( 217, 0x7C5C46, "Brown"),
|
||||
new BrickColor( 218, 0x96709F, "Reddish lilac"),
|
||||
new BrickColor( 219, 0x6B629B, "Lilac"),
|
||||
new BrickColor( 220, 0xA7A9CE, "Light lilac"),
|
||||
new BrickColor( 221, 0xCD6298, "Bright purple"),
|
||||
new BrickColor( 222, 0xE4ADC8, "Light purple"),
|
||||
new BrickColor( 223, 0xDC9095, "Light pink"),
|
||||
new BrickColor( 224, 0xF0D5A0, "Light brick yellow"),
|
||||
new BrickColor( 225, 0xEBB87F, "Warm yellowish orange"),
|
||||
new BrickColor( 226, 0xFDEA8D, "Cool yellow"),
|
||||
new BrickColor( 232, 0x7DBBDD, "Dove blue"),
|
||||
new BrickColor( 268, 0x342B75, "Medium lilac"),
|
||||
new BrickColor( 301, 0x506D54, "Slime green"),
|
||||
new BrickColor( 302, 0x5B5D69, "Smoky grey"),
|
||||
new BrickColor( 303, 0x0010B0, "Dark blue"),
|
||||
new BrickColor( 304, 0x2C651D, "Parsley green"),
|
||||
new BrickColor( 305, 0x527CAE, "Steel blue"),
|
||||
new BrickColor( 306, 0x335882, "Storm blue"),
|
||||
new BrickColor( 307, 0x102ADC, "Lapis"),
|
||||
new BrickColor( 308, 0x3D1585, "Dark indigo"),
|
||||
new BrickColor( 309, 0x348E40, "Sea green"),
|
||||
new BrickColor( 310, 0x5B9A4C, "Shamrock"),
|
||||
new BrickColor( 311, 0x9FA1AC, "Fossil"),
|
||||
new BrickColor( 312, 0x592259, "Mulberry"),
|
||||
new BrickColor( 313, 0x1F801D, "Forest green"),
|
||||
new BrickColor( 314, 0x9FADC0, "Cadet blue"),
|
||||
new BrickColor( 315, 0x0989CF, "Electric blue"),
|
||||
new BrickColor( 316, 0x7B007B, "Eggplant"),
|
||||
new BrickColor( 317, 0x7C9C6B, "Moss"),
|
||||
new BrickColor( 318, 0x8AAB85, "Artichoke"),
|
||||
new BrickColor( 319, 0xB9C4B1, "Sage green"),
|
||||
new BrickColor( 320, 0xCACBD1, "Ghost grey"),
|
||||
new BrickColor( 321, 0xA75E9B, "Lilac"),
|
||||
new BrickColor( 322, 0x7B2F7B, "Plum"),
|
||||
new BrickColor( 323, 0x94BE81, "Olivine"),
|
||||
new BrickColor( 324, 0xA8BD99, "Laurel green"),
|
||||
new BrickColor( 325, 0xDFDFDE, "Quill grey"),
|
||||
new BrickColor( 327, 0x970000, "Crimson"),
|
||||
new BrickColor( 328, 0xB1E5A6, "Mint"),
|
||||
new BrickColor( 329, 0x98C2DB, "Baby blue"),
|
||||
new BrickColor( 330, 0xFF98DC, "Carnation pink"),
|
||||
new BrickColor( 331, 0xFF5959, "Persimmon"),
|
||||
new BrickColor( 332, 0x750000, "Maroon"),
|
||||
new BrickColor( 333, 0xEFB838, "Gold"),
|
||||
new BrickColor( 334, 0xF8D96D, "Daisy orange"),
|
||||
new BrickColor( 335, 0xE7E7EC, "Pearl"),
|
||||
new BrickColor( 336, 0xC7D4E4, "Fog"),
|
||||
new BrickColor( 337, 0xFF9494, "Salmon"),
|
||||
new BrickColor( 338, 0xBE6862, "Terra Cotta"),
|
||||
new BrickColor( 339, 0x562424, "Cocoa"),
|
||||
new BrickColor( 340, 0xF1E7C7, "Wheat"),
|
||||
new BrickColor( 341, 0xFEF3BB, "Buttermilk"),
|
||||
new BrickColor( 342, 0xE0B2D0, "Mauve"),
|
||||
new BrickColor( 343, 0xD490BD, "Sunrise"),
|
||||
new BrickColor( 344, 0x965555, "Tawny"),
|
||||
new BrickColor( 345, 0x8F4C2A, "Rust"),
|
||||
new BrickColor( 346, 0xD3BE96, "Cashmere"),
|
||||
new BrickColor( 347, 0xE2DCBC, "Khaki"),
|
||||
new BrickColor( 348, 0xEDEAEA, "Lily white"),
|
||||
new BrickColor( 349, 0xE9DADA, "Seashell"),
|
||||
new BrickColor( 350, 0x883E3E, "Burgundy"),
|
||||
new BrickColor( 351, 0xBC9B5D, "Cork"),
|
||||
new BrickColor( 352, 0xC7AC78, "Burlap"),
|
||||
new BrickColor( 353, 0xCABFA3, "Beige"),
|
||||
new BrickColor( 354, 0xBBB3B2, "Oyster"),
|
||||
new BrickColor( 355, 0x6C584B, "Pine Cone"),
|
||||
new BrickColor( 356, 0xA0844F, "Fawn brown"),
|
||||
new BrickColor( 357, 0x958988, "Hurricane grey"),
|
||||
new BrickColor( 358, 0xABA89E, "Cloudy grey"),
|
||||
new BrickColor( 359, 0xAF9483, "Linen"),
|
||||
new BrickColor( 360, 0x966766, "Copper"),
|
||||
new BrickColor( 361, 0x564236, "Dirt brown"),
|
||||
new BrickColor( 362, 0x7E683F, "Bronze"),
|
||||
new BrickColor( 363, 0x69665C, "Flint"),
|
||||
new BrickColor( 364, 0x5A4C42, "Dark taupe"),
|
||||
new BrickColor( 365, 0x6A3909, "Burnt Sienna"),
|
||||
new BrickColor(1001, 0xF8F8F8, "Institutional white"),
|
||||
new BrickColor(1002, 0xCDCDCD, "Mid gray"),
|
||||
new BrickColor(1003, 0x111111, "Really black"),
|
||||
new BrickColor(1004, 0xFF0000, "Really red"),
|
||||
new BrickColor(1005, 0xFFB000, "Deep orange"),
|
||||
new BrickColor(1006, 0xB480FF, "Alder"),
|
||||
new BrickColor(1007, 0xA34B4B, "Dusty Rose"),
|
||||
new BrickColor(1008, 0xC1BE42, "Olive"),
|
||||
new BrickColor(1009, 0xFFFF00, "New Yeller"),
|
||||
new BrickColor(1010, 0x0000FF, "Really blue"),
|
||||
new BrickColor(1011, 0x002060, "Navy blue"),
|
||||
new BrickColor(1012, 0x2154B9, "Deep blue"),
|
||||
new BrickColor(1013, 0x04AFEC, "Cyan"),
|
||||
new BrickColor(1014, 0xAA5500, "CGA brown"),
|
||||
new BrickColor(1015, 0xAA00AA, "Magenta"),
|
||||
new BrickColor(1016, 0xFF66CC, "Pink"),
|
||||
new BrickColor(1017, 0xFFAF00, "Deep orange"),
|
||||
new BrickColor(1018, 0x12EED4, "Teal"),
|
||||
new BrickColor(1019, 0x00FFFF, "Toothpaste"),
|
||||
new BrickColor(1020, 0x00FF00, "Lime green"),
|
||||
new BrickColor(1021, 0x3A7D15, "Camo"),
|
||||
new BrickColor(1022, 0x7F8E64, "Grime"),
|
||||
new BrickColor(1023, 0x8C5B9F, "Lavender"),
|
||||
new BrickColor(1024, 0xAFDDFF, "Pastel light blue"),
|
||||
new BrickColor(1025, 0xFFC9C9, "Pastel orange"),
|
||||
new BrickColor(1026, 0xB1A7FF, "Pastel violet"),
|
||||
new BrickColor(1027, 0x9FF3E9, "Pastel blue-green"),
|
||||
new BrickColor(1028, 0xCCFFCC, "Pastel green"),
|
||||
new BrickColor(1029, 0xFFFFCC, "Pastel yellow"),
|
||||
new BrickColor(1030, 0xFFCC99, "Pastel brown"),
|
||||
new BrickColor(1031, 0x6225D1, "Royal purple"),
|
||||
new BrickColor(1032, 0xFF00BF, "Hot pink"),
|
||||
};
|
||||
}
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using RobloxFiles.Enums;
|
||||
|
||||
namespace RobloxFiles.DataTypes.Utility
|
||||
{
|
||||
public static class MaterialInfo
|
||||
{
|
||||
public static IReadOnlyDictionary<Material, float> DensityMap = new Dictionary<Material, float>()
|
||||
{
|
||||
{Material.Air, 0.01f},
|
||||
{Material.Asphalt, 2.36f},
|
||||
{Material.Basalt, 2.69f},
|
||||
{Material.Brick, 1.92f},
|
||||
{Material.Cobblestone, 2.69f},
|
||||
{Material.Concrete, 2.40f},
|
||||
{Material.CorrodedMetal, 7.85f},
|
||||
{Material.CrackedLava, 2.69f},
|
||||
{Material.DiamondPlate, 7.85f},
|
||||
{Material.Fabric, 0.70f},
|
||||
{Material.Foil, 2.70f},
|
||||
{Material.Glacier, 0.92f},
|
||||
{Material.Glass, 2.40f},
|
||||
{Material.Granite, 2.69f},
|
||||
{Material.Grass, 0.90f},
|
||||
{Material.Ground, 0.90f},
|
||||
{Material.Ice, 0.92f},
|
||||
{Material.LeafyGrass, 0.90f},
|
||||
{Material.Limestone, 2.69f},
|
||||
{Material.Marble, 2.56f},
|
||||
{Material.Metal, 7.85f},
|
||||
{Material.Mud, 0.90f},
|
||||
{Material.Neon, 0.70f},
|
||||
{Material.Pavement, 2.69f},
|
||||
{Material.Pebble, 2.40f},
|
||||
{Material.Plastic, 0.70f},
|
||||
{Material.Rock, 2.69f},
|
||||
{Material.Salt, 2.16f},
|
||||
{Material.Sand, 1.60f},
|
||||
{Material.Sandstone, 2.69f},
|
||||
{Material.Slate, 2.69f},
|
||||
{Material.SmoothPlastic, 0.70f},
|
||||
{Material.Snow, 0.90f},
|
||||
{Material.Water, 1.00f},
|
||||
{Material.Wood, 0.35f},
|
||||
{Material.WoodPlanks, 0.35f},
|
||||
};
|
||||
|
||||
public static IReadOnlyDictionary<Material, float> ElasticityMap = new Dictionary<Material, float>()
|
||||
{
|
||||
{Material.Air, 0.01f},
|
||||
{Material.Asphalt, 0.20f},
|
||||
{Material.Basalt, 0.15f},
|
||||
{Material.Brick, 0.15f},
|
||||
{Material.Cobblestone, 0.17f},
|
||||
{Material.Concrete, 0.20f},
|
||||
{Material.CorrodedMetal, 0.20f},
|
||||
{Material.CrackedLava, 0.15f},
|
||||
{Material.DiamondPlate, 0.25f},
|
||||
{Material.Fabric, 0.05f},
|
||||
{Material.Foil, 0.25f},
|
||||
{Material.Glacier, 0.15f},
|
||||
{Material.Glass, 0.20f},
|
||||
{Material.Granite, 0.20f},
|
||||
{Material.Grass, 0.10f},
|
||||
{Material.Ground, 0.10f},
|
||||
{Material.Ice, 0.15f},
|
||||
{Material.LeafyGrass, 0.10f},
|
||||
{Material.Limestone, 0.15f},
|
||||
{Material.Marble, 0.17f},
|
||||
{Material.Metal, 0.25f},
|
||||
{Material.Mud, 0.07f},
|
||||
{Material.Neon, 0.20f},
|
||||
{Material.Pavement, 0.17f},
|
||||
{Material.Pebble, 0.17f},
|
||||
{Material.Plastic, 0.50f},
|
||||
{Material.Rock, 0.17f},
|
||||
{Material.Salt, 0.05f},
|
||||
{Material.Sand, 0.05f},
|
||||
{Material.Sandstone, 0.15f},
|
||||
{Material.Slate, 0.20f},
|
||||
{Material.SmoothPlastic, 0.50f},
|
||||
{Material.Snow, 0.03f},
|
||||
{Material.Water, 0.01f},
|
||||
{Material.Wood, 0.20f},
|
||||
{Material.WoodPlanks, 0.20f},
|
||||
};
|
||||
|
||||
public static IReadOnlyDictionary<Material, float> FrictionMap = new Dictionary<Material, float>()
|
||||
{
|
||||
{Material.Air, 0.01f},
|
||||
{Material.Asphalt, 0.80f},
|
||||
{Material.Basalt, 0.70f},
|
||||
{Material.Brick, 0.80f},
|
||||
{Material.Cobblestone, 0.50f},
|
||||
{Material.Concrete, 0.70f},
|
||||
{Material.CorrodedMetal, 0.70f},
|
||||
{Material.CrackedLava, 0.65f},
|
||||
{Material.DiamondPlate, 0.35f},
|
||||
{Material.Fabric, 0.35f},
|
||||
{Material.Foil, 0.40f},
|
||||
{Material.Glacier, 0.05f},
|
||||
{Material.Glass, 0.25f},
|
||||
{Material.Granite, 0.40f},
|
||||
{Material.Grass, 0.40f},
|
||||
{Material.Ground, 0.45f},
|
||||
{Material.Ice, 0.02f},
|
||||
{Material.LeafyGrass, 0.40f},
|
||||
{Material.Limestone, 0.50f},
|
||||
{Material.Marble, 0.20f},
|
||||
{Material.Metal, 0.40f},
|
||||
{Material.Mud, 0.30f},
|
||||
{Material.Neon, 0.30f},
|
||||
{Material.Pavement, 0.50f},
|
||||
{Material.Pebble, 0.40f},
|
||||
{Material.Plastic, 0.30f},
|
||||
{Material.Rock, 0.50f},
|
||||
{Material.Salt, 0.50f},
|
||||
{Material.Sand, 0.50f},
|
||||
{Material.Sandstone, 0.50f},
|
||||
{Material.Slate, 0.40f},
|
||||
{Material.SmoothPlastic, 0.20f},
|
||||
{Material.Snow, 0.30f},
|
||||
{Material.Water, 0.00f},
|
||||
{Material.Wood, 0.48f},
|
||||
{Material.WoodPlanks, 0.48f},
|
||||
};
|
||||
}
|
||||
}
|
@ -1,207 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace RobloxFiles.DataTypes.Utility
|
||||
{
|
||||
public class Quaternion
|
||||
{
|
||||
public readonly float X;
|
||||
public readonly float Y;
|
||||
public readonly float Z;
|
||||
public readonly float W;
|
||||
|
||||
public float Magnitude
|
||||
{
|
||||
get
|
||||
{
|
||||
float squared = Dot(this);
|
||||
double magnitude = Math.Sqrt(squared);
|
||||
|
||||
return (float)magnitude;
|
||||
}
|
||||
}
|
||||
|
||||
public Quaternion(float x, float y, float z, float w)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
W = w;
|
||||
}
|
||||
|
||||
public Quaternion(Vector3 qv, float qw)
|
||||
{
|
||||
X = qv.X;
|
||||
Y = qv.Y;
|
||||
Z = qv.Z;
|
||||
W = qw;
|
||||
}
|
||||
|
||||
public Quaternion(CFrame cf)
|
||||
{
|
||||
CFrame matrix = (cf - cf.Position);
|
||||
float[] ac = cf.GetComponents();
|
||||
|
||||
float m41 = ac[0], m42 = ac[1], m43 = ac[2],
|
||||
m11 = ac[3], m12 = ac[4], m13 = ac[5],
|
||||
m21 = ac[6], m22 = ac[7], m23 = ac[8],
|
||||
m31 = ac[9], m32 = ac[10], m33 = ac[11];
|
||||
|
||||
float trace = m11 + m22 + m33;
|
||||
|
||||
if (trace > 0)
|
||||
{
|
||||
float s = (float)Math.Sqrt(1 + trace);
|
||||
float r = 0.5f / s;
|
||||
|
||||
W = s * 0.5f;
|
||||
X = (m32 - m23) * r;
|
||||
Y = (m13 - m31) * r;
|
||||
Z = (m21 - m12) * r;
|
||||
}
|
||||
else
|
||||
{
|
||||
float big = Math.Max(Math.Max(m11, m22), m33);
|
||||
|
||||
if (big == m11)
|
||||
{
|
||||
float s = (float)Math.Sqrt(1 + m11 - m22 - m33);
|
||||
float r = 0.5f / s;
|
||||
|
||||
W = (m32 - m23) * r;
|
||||
X = 0.5f * s;
|
||||
Y = (m21 + m12) * r;
|
||||
Z = (m13 + m31) * r;
|
||||
}
|
||||
else if (big == m22)
|
||||
{
|
||||
float s = (float)Math.Sqrt(1 - m11 + m22 - m33);
|
||||
float r = 0.5f / s;
|
||||
|
||||
W = (m13 - m31) * r;
|
||||
X = (m21 + m12) * r;
|
||||
Y = 0.5f * s;
|
||||
Z = (m32 + m23) * r;
|
||||
}
|
||||
else if (big == m33)
|
||||
{
|
||||
float s = (float)Math.Sqrt(1 - m11 - m22 + m33);
|
||||
float r = 0.5f / s;
|
||||
|
||||
W = (m21 - m12) * r;
|
||||
X = (m13 + m31) * r;
|
||||
Y = (m32 + m23) * r;
|
||||
Z = 0.5f * s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float Dot(Quaternion other)
|
||||
{
|
||||
return (X * other.X) + (Y * other.Y) + (Z * other.Z) + (W * other.W);
|
||||
}
|
||||
|
||||
public Quaternion Lerp(Quaternion other, float alpha)
|
||||
{
|
||||
Quaternion result = this * (1.0f - alpha) + other * alpha;
|
||||
return result / result.Magnitude;
|
||||
}
|
||||
|
||||
public Quaternion Slerp(Quaternion other, float alpha)
|
||||
{
|
||||
float cosAng = Dot(other);
|
||||
|
||||
if (cosAng < 0)
|
||||
{
|
||||
other = -other;
|
||||
cosAng = -cosAng;
|
||||
}
|
||||
|
||||
double ang = Math.Acos(cosAng);
|
||||
|
||||
if (ang >= 0.05f)
|
||||
{
|
||||
float scale0 = (float)Math.Sin((1.0f - alpha) * ang);
|
||||
float scale1 = (float)Math.Sin(alpha * ang);
|
||||
float denom = (float)Math.Sin(ang);
|
||||
|
||||
return ((this * scale0) + (other * scale1)) / denom;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Lerp(other, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
public CFrame ToCFrame()
|
||||
{
|
||||
float xc = X * 2f;
|
||||
float yc = Y * 2f;
|
||||
float zc = Z * 2f;
|
||||
|
||||
float xx = X * xc;
|
||||
float xy = X * yc;
|
||||
float xz = X * zc;
|
||||
|
||||
float wx = W * xc;
|
||||
float wy = W * yc;
|
||||
float wz = W * zc;
|
||||
|
||||
float yy = Y * yc;
|
||||
float yz = Y * zc;
|
||||
float zz = Z * zc;
|
||||
|
||||
return new CFrame
|
||||
(
|
||||
0, 0, 0,
|
||||
|
||||
1f - (yy + zz),
|
||||
xy - wz,
|
||||
xz + wy,
|
||||
|
||||
xy + wz,
|
||||
1f - (xx + zz),
|
||||
yz - wx,
|
||||
|
||||
xz - wy,
|
||||
yz + wx,
|
||||
1f - (xx + yy)
|
||||
);
|
||||
}
|
||||
|
||||
public static Quaternion operator +(Quaternion a, Quaternion b)
|
||||
{
|
||||
return new Quaternion(a.X + b.X, a.Y + b.Y, a.Z + b.Z, a.W + b.W);
|
||||
}
|
||||
|
||||
public static Quaternion operator -(Quaternion a, Quaternion b)
|
||||
{
|
||||
return new Quaternion(a.X - b.X, a.Y - b.Y, a.Z - b.Z, a.W - b.W);
|
||||
}
|
||||
|
||||
public static Quaternion operator *(Quaternion a, float f)
|
||||
{
|
||||
return new Quaternion(a.X * f, a.Y * f, a.Z * f, a.W * f);
|
||||
}
|
||||
|
||||
public static Quaternion operator /(Quaternion a, float f)
|
||||
{
|
||||
return new Quaternion(a.X / f, a.Y / f, a.Z / f, a.W / f);
|
||||
}
|
||||
|
||||
public static Quaternion operator -(Quaternion a)
|
||||
{
|
||||
return new Quaternion(-a.X, -a.Y, -a.Z, -a.W);
|
||||
}
|
||||
|
||||
public static Quaternion operator *(Quaternion a, Quaternion b)
|
||||
{
|
||||
Vector3 v1 = new Vector3(a.X, a.Y, a.Z);
|
||||
float s1 = a.W;
|
||||
|
||||
Vector3 v2 = new Vector3(b.X, b.Y, b.Z);
|
||||
float s2 = b.W;
|
||||
|
||||
return new Quaternion(s1 * v2 + s2 * v1 + v1.Cross(v2), s1 * s2 - v1.Dot(v2));
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct Vector2
|
||||
public class Vector2
|
||||
{
|
||||
public readonly float X, Y;
|
||||
|
||||
|
@ -3,7 +3,7 @@ using RobloxFiles.Enums;
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct Vector3
|
||||
public class Vector3
|
||||
{
|
||||
public readonly float X, Y, Z;
|
||||
|
||||
|
@ -2,10 +2,17 @@
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct Vector3int16
|
||||
public class Vector3int16
|
||||
{
|
||||
public readonly short X, Y, Z;
|
||||
|
||||
public Vector3int16()
|
||||
{
|
||||
X = 0;
|
||||
Y = 0;
|
||||
Z = 0;
|
||||
}
|
||||
|
||||
public Vector3int16(short x = 0, short y = 0, short z = 0)
|
||||
{
|
||||
X = x;
|
||||
|
Reference in New Issue
Block a user