Convert datatypes to classes instead of structs.
This commit is contained in:
parent
795018e243
commit
f7184eb8f8
@ -415,7 +415,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
|||||||
g = color3uint8_G[i],
|
g = color3uint8_G[i],
|
||||||
b = color3uint8_B[i];
|
b = color3uint8_B[i];
|
||||||
|
|
||||||
return Color3.fromRGB(r, g, b);
|
return Color3.FromRGB(r, g, b);
|
||||||
});
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// This is an auto-generated list of all available enums on Roblox!
|
// This is an auto-generated list of all available enums on Roblox!
|
||||||
// Updated as of 0.369.1.273919
|
// Updated as of 0.370.0.274702
|
||||||
|
|
||||||
namespace RobloxFiles.Enums
|
namespace RobloxFiles.Enums
|
||||||
{
|
{
|
||||||
@ -806,7 +806,8 @@ namespace RobloxFiles.Enums
|
|||||||
Players = 7,
|
Players = 7,
|
||||||
Chat = 15,
|
Chat = 15,
|
||||||
Avatar,
|
Avatar,
|
||||||
Analytics = 22
|
Analytics = 22,
|
||||||
|
Localization = 24
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum HumanoidDisplayDistanceType
|
public enum HumanoidDisplayDistanceType
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using RobloxFiles.DataTypes.Utility;
|
using RobloxFiles.Utility;
|
||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
@ -35,7 +35,7 @@ namespace RobloxFiles.DataTypes
|
|||||||
Name = name;
|
Name = name;
|
||||||
Number = number;
|
Number = number;
|
||||||
|
|
||||||
Color = Color3.fromRGB(r, g, b);
|
Color = Color3.FromRGB(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BrickColor()
|
static BrickColor()
|
||||||
|
@ -20,6 +20,13 @@ namespace RobloxFiles.DataTypes
|
|||||||
public Vector3 RightVector => new Vector3( m11, m21, m31);
|
public Vector3 RightVector => new Vector3( m11, m21, m31);
|
||||||
public Vector3 UpVector => new Vector3( m12, m22, m32);
|
public Vector3 UpVector => new Vector3( m12, m22, m32);
|
||||||
|
|
||||||
|
public CFrame()
|
||||||
|
{
|
||||||
|
m14 = 0;
|
||||||
|
m24 = 0;
|
||||||
|
m34 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public CFrame(Vector3 pos)
|
public CFrame(Vector3 pos)
|
||||||
{
|
{
|
||||||
m14 = pos.X;
|
m14 = pos.X;
|
||||||
@ -27,6 +34,14 @@ namespace RobloxFiles.DataTypes
|
|||||||
m34 = pos.Z;
|
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)
|
public CFrame(Vector3 eye, Vector3 look)
|
||||||
{
|
{
|
||||||
Vector3 zAxis = (eye - look).Unit;
|
Vector3 zAxis = (eye - look).Unit;
|
||||||
@ -54,13 +69,6 @@ namespace RobloxFiles.DataTypes
|
|||||||
m31 = xAxis.Z; m32 = yAxis.Z; m33 = zAxis.Z; m34 = eye.Z;
|
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)
|
public CFrame(float nx, float ny, float nz, float i, float j, float k, float w)
|
||||||
{
|
{
|
||||||
float ii = i * i;
|
float ii = i * i;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct Color3
|
public class Color3
|
||||||
{
|
{
|
||||||
public readonly float R, G, B;
|
public readonly float R, G, B;
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ namespace RobloxFiles.DataTypes
|
|||||||
return string.Join(", ", R, G, B);
|
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);
|
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));
|
int i = (int)Math.Min(5, Math.Floor(6.0 * h));
|
||||||
float f = 6.0f * h - i;
|
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);
|
float val = Math.Max(Math.Max(color.R, color.G), color.B);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct ColorSequence
|
public class ColorSequence
|
||||||
{
|
{
|
||||||
public readonly ColorSequenceKeypoint[] Keypoints;
|
public readonly ColorSequenceKeypoint[] Keypoints;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ namespace RobloxFiles.DataTypes
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Join(" ", Keypoints);
|
return string.Join<ColorSequenceKeypoint>(" ", Keypoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct ColorSequenceKeypoint
|
public class ColorSequenceKeypoint
|
||||||
{
|
{
|
||||||
public readonly float Time;
|
public readonly float Time;
|
||||||
public readonly Color3 Value;
|
public readonly Color3 Value;
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct NumberRange
|
public class NumberRange
|
||||||
{
|
{
|
||||||
public readonly float Min;
|
public readonly float Min;
|
||||||
public readonly float Max;
|
public readonly float Max;
|
||||||
|
|
||||||
public NumberRange(float min, float max)
|
public NumberRange(float min = 0, float max = 0)
|
||||||
{
|
{
|
||||||
if (max - min < 0)
|
if (max - min < 0)
|
||||||
throw new Exception("NumberRange: invalid range");
|
throw new Exception("NumberRange: invalid range");
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct NumberSequence
|
public class NumberSequence
|
||||||
{
|
{
|
||||||
public readonly NumberSequenceKeypoint[] Keypoints;
|
public readonly NumberSequenceKeypoint[] Keypoints;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ namespace RobloxFiles.DataTypes
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Join(" ", Keypoints);
|
return string.Join<NumberSequenceKeypoint>(" ", Keypoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct NumberSequenceKeypoint
|
public class NumberSequenceKeypoint
|
||||||
{
|
{
|
||||||
public readonly float Time;
|
public readonly float Time;
|
||||||
public readonly float Value;
|
public readonly float Value;
|
||||||
|
@ -1,38 +1,28 @@
|
|||||||
using RobloxFiles.Enums;
|
using RobloxFiles.Enums;
|
||||||
using RobloxFiles.DataTypes.Utility;
|
using RobloxFiles.Utility;
|
||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct PhysicalProperties
|
public class PhysicalProperties
|
||||||
{
|
{
|
||||||
public readonly float Density;
|
public readonly float Density = 1.0f;
|
||||||
public readonly float Friction;
|
public readonly float Friction = 1.0f;
|
||||||
public readonly float Elasticity;
|
public readonly float Elasticity = 0.5f;
|
||||||
|
|
||||||
public readonly float FrictionWeight;
|
public readonly float FrictionWeight = 1.0f;
|
||||||
public readonly float ElasticityWeight;
|
public readonly float ElasticityWeight = 1.0f;
|
||||||
|
|
||||||
public PhysicalProperties(Material material)
|
public PhysicalProperties(Material material)
|
||||||
{
|
{
|
||||||
|
if (MaterialInfo.FrictionWeightMap.ContainsKey(material))
|
||||||
|
FrictionWeight = MaterialInfo.FrictionWeightMap[material];
|
||||||
|
|
||||||
Density = MaterialInfo.DensityMap[material];
|
Density = MaterialInfo.DensityMap[material];
|
||||||
Friction = MaterialInfo.FrictionMap[material];
|
Friction = MaterialInfo.FrictionMap[material];
|
||||||
Elasticity = MaterialInfo.ElasticityMap[material];
|
Elasticity = MaterialInfo.ElasticityMap[material];
|
||||||
|
|
||||||
FrictionWeight = 1;
|
|
||||||
ElasticityWeight = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhysicalProperties(float density, float friction, float elasticity)
|
public PhysicalProperties(float density, float friction, float elasticity, float frictionWeight = 1f, float elasticityWeight = 1f)
|
||||||
{
|
|
||||||
Density = density;
|
|
||||||
Friction = friction;
|
|
||||||
Elasticity = elasticity;
|
|
||||||
|
|
||||||
FrictionWeight = 1;
|
|
||||||
ElasticityWeight = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PhysicalProperties(float density, float friction, float elasticity, float frictionWeight, float elasticityWeight)
|
|
||||||
{
|
{
|
||||||
Density = density;
|
Density = density;
|
||||||
Friction = friction;
|
Friction = friction;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct Ray
|
public class Ray
|
||||||
{
|
{
|
||||||
public readonly Vector3 Origin;
|
public readonly Vector3 Origin;
|
||||||
public readonly Vector3 Direction;
|
public readonly Vector3 Direction;
|
||||||
@ -33,15 +33,19 @@
|
|||||||
|
|
||||||
public Vector3 ClosestPoint(Vector3 point)
|
public Vector3 ClosestPoint(Vector3 point)
|
||||||
{
|
{
|
||||||
Vector3 offset = point - Origin;
|
Vector3 result = Origin;
|
||||||
float diff = offset.Dot(Direction) / Direction.Dot(Direction);
|
float t = Direction.Dot(point - result);
|
||||||
return Origin + (diff * Direction);
|
|
||||||
|
if (t >= 0)
|
||||||
|
result += (Direction * t);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float Distance(Vector3 point)
|
public float Distance(Vector3 point)
|
||||||
{
|
{
|
||||||
Vector3 projected = ClosestPoint(point);
|
Vector3 closestPoint = ClosestPoint(point);
|
||||||
return (point - projected).Magnitude;
|
return (closestPoint - point).Magnitude;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct Rect
|
public class Rect
|
||||||
{
|
{
|
||||||
public readonly Vector2 Min;
|
public readonly Vector2 Min;
|
||||||
public readonly Vector2 Max;
|
public readonly Vector2 Max;
|
||||||
@ -8,7 +8,7 @@
|
|||||||
public float Width => (Max - Min).X;
|
public float Width => (Max - Min).X;
|
||||||
public float Height => (Max - Min).Y;
|
public float Height => (Max - Min).Y;
|
||||||
|
|
||||||
public Rect(Vector2? min, Vector2? max)
|
public Rect(Vector2 min = null, Vector2 max = null)
|
||||||
{
|
{
|
||||||
Min = min ?? Vector2.Zero;
|
Min = min ?? Vector2.Zero;
|
||||||
Max = max ?? Vector2.Zero;
|
Max = max ?? Vector2.Zero;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct Region3
|
public class Region3
|
||||||
{
|
{
|
||||||
public readonly CFrame CFrame;
|
public readonly CFrame CFrame;
|
||||||
public readonly Vector3 Size;
|
public readonly Vector3 Size;
|
||||||
|
@ -10,7 +10,7 @@ namespace RobloxFiles.DataTypes
|
|||||||
{
|
{
|
||||||
public readonly Vector3int16 Min, Max;
|
public readonly Vector3int16 Min, Max;
|
||||||
|
|
||||||
public Region3int16(Vector3int16? min, Vector3int16? max)
|
public Region3int16(Vector3int16 min = null, Vector3int16 max = null)
|
||||||
{
|
{
|
||||||
Min = min ?? new Vector3int16();
|
Min = min ?? new Vector3int16();
|
||||||
Max = max ?? new Vector3int16();
|
Max = max ?? new Vector3int16();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct UDim
|
public class UDim
|
||||||
{
|
{
|
||||||
public readonly float Scale;
|
public readonly float Scale;
|
||||||
public readonly int Offset;
|
public readonly int Offset;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct UDim2
|
public class UDim2
|
||||||
{
|
{
|
||||||
public readonly UDim X, Y;
|
public readonly UDim X, Y;
|
||||||
|
|
||||||
public UDim Width => X;
|
public UDim Width => X;
|
||||||
public UDim Height => Y;
|
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);
|
X = new UDim(scaleX, offsetX);
|
||||||
Y = new UDim(scaleY, offsetY);
|
Y = new UDim(scaleY, offsetY);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct Vector2
|
public class Vector2
|
||||||
{
|
{
|
||||||
public readonly float X, Y;
|
public readonly float X, Y;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ using RobloxFiles.Enums;
|
|||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct Vector3
|
public class Vector3
|
||||||
{
|
{
|
||||||
public readonly float X, Y, Z;
|
public readonly float X, Y, Z;
|
||||||
|
|
||||||
|
@ -2,10 +2,17 @@
|
|||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
{
|
{
|
||||||
public struct Vector3int16
|
public class Vector3int16
|
||||||
{
|
{
|
||||||
public readonly short X, Y, Z;
|
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)
|
public Vector3int16(short x = 0, short y = 0, short z = 0)
|
||||||
{
|
{
|
||||||
X = x;
|
X = x;
|
||||||
|
@ -5,12 +5,11 @@ using System.Runtime.InteropServices;
|
|||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("RobloxFiles")]
|
[assembly: AssemblyTitle("Roblox File Format")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("Implementation of Roblox's File Format in C# for .NET 4.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("Written by CloneTrooper1019")]
|
||||||
[assembly: AssemblyProduct("RobloxFiles")]
|
[assembly: AssemblyProduct("Roblox File Format")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>1</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<StartupObject />
|
<StartupObject />
|
||||||
@ -86,7 +86,7 @@
|
|||||||
<Compile Include="DataTypes\PhysicalProperties.cs" />
|
<Compile Include="DataTypes\PhysicalProperties.cs" />
|
||||||
<Compile Include="DataTypes\Ray.cs" />
|
<Compile Include="DataTypes\Ray.cs" />
|
||||||
<Compile Include="DataTypes\Region3int16.cs" />
|
<Compile Include="DataTypes\Region3int16.cs" />
|
||||||
<Compile Include="DataTypes\Utility\BrickColors.cs" />
|
<Compile Include="Utility\BrickColors.cs" />
|
||||||
<Compile Include="DataTypes\Vector3int16.cs" />
|
<Compile Include="DataTypes\Vector3int16.cs" />
|
||||||
<Compile Include="DataTypes\Rect.cs" />
|
<Compile Include="DataTypes\Rect.cs" />
|
||||||
<Compile Include="DataTypes\Region3.cs" />
|
<Compile Include="DataTypes\Region3.cs" />
|
||||||
@ -94,9 +94,8 @@
|
|||||||
<Compile Include="DataTypes\UDim2.cs" />
|
<Compile Include="DataTypes\UDim2.cs" />
|
||||||
<Compile Include="DataTypes\Vector2.cs" />
|
<Compile Include="DataTypes\Vector2.cs" />
|
||||||
<Compile Include="DataTypes\Vector3.cs" />
|
<Compile Include="DataTypes\Vector3.cs" />
|
||||||
<Compile Include="DataTypes\Utility\MaterialInfo.cs" />
|
<Compile Include="Utility\MaterialInfo.cs" />
|
||||||
<Compile Include="DataTypes\Utility\Quaternion.cs" />
|
<Compile Include="Utility\Quaternion.cs" />
|
||||||
<Compile Include="UnitTest.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="XmlFormat\XmlPropertyTokens.cs" />
|
<Compile Include="XmlFormat\XmlPropertyTokens.cs" />
|
||||||
<Compile Include="XmlFormat\XmlDataReader.cs" />
|
<Compile Include="XmlFormat\XmlDataReader.cs" />
|
||||||
@ -128,9 +127,6 @@
|
|||||||
<Compile Include="XmlFormat\PropertyTokens\Vector2.cs" />
|
<Compile Include="XmlFormat\PropertyTokens\Vector2.cs" />
|
||||||
<Compile Include="XmlFormat\PropertyTokens\Vector3.cs" />
|
<Compile Include="XmlFormat\PropertyTokens\Vector3.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Packages.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
|
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
|
19
UnitTest.cs
19
UnitTest.cs
@ -1,19 +0,0 @@
|
|||||||
#if DEBUG
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace RobloxFiles
|
|
||||||
{
|
|
||||||
// This is a placeholder.
|
|
||||||
internal class UnitTest
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
if (args.Length > 0)
|
|
||||||
{
|
|
||||||
RobloxFile file = new RobloxFile(args[0]);
|
|
||||||
Debugger.Break();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,8 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using RobloxFiles.DataTypes;
|
using RobloxFiles.DataTypes;
|
||||||
|
|
||||||
namespace RobloxFiles.DataTypes.Utility
|
namespace RobloxFiles.Utility
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This static class defines all of Roblox's built-in BrickColor data.
|
||||||
|
/// It is used primarily by the BrickColor DataType.
|
||||||
|
/// </summary>
|
||||||
public static class BrickColors
|
public static class BrickColors
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -33,10 +38,10 @@ namespace RobloxFiles.DataTypes.Utility
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This contains a list of all available BrickColors on Roblox.
|
/// This contains a list of all defined BrickColors on Roblox.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public static IReadOnlyCollection<BrickColor> ColorMap = new List<BrickColor>()
|
public static IReadOnlyList<BrickColor> ColorMap = new List<BrickColor>()
|
||||||
{
|
{
|
||||||
new BrickColor( 1, 0xF2F3F3, "White"),
|
new BrickColor( 1, 0xF2F3F3, "White"),
|
||||||
new BrickColor( 2, 0xA1A5A2, "Grey"),
|
new BrickColor( 2, 0xA1A5A2, "Grey"),
|
@ -1,10 +1,17 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using RobloxFiles.Enums;
|
using RobloxFiles.Enums;
|
||||||
|
|
||||||
namespace RobloxFiles.DataTypes.Utility
|
namespace RobloxFiles.Utility
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class defines several dictionaries of metadata for Roblox materials.
|
||||||
|
/// It is primarily used for the PhysicalProperties DataType.
|
||||||
|
/// </summary>
|
||||||
public static class MaterialInfo
|
public static class MaterialInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A dictionary mapping materials to their default Density.
|
||||||
|
/// </summary>
|
||||||
public static IReadOnlyDictionary<Material, float> DensityMap = new Dictionary<Material, float>()
|
public static IReadOnlyDictionary<Material, float> DensityMap = new Dictionary<Material, float>()
|
||||||
{
|
{
|
||||||
{Material.Air, 0.01f},
|
{Material.Air, 0.01f},
|
||||||
@ -45,6 +52,9 @@ namespace RobloxFiles.DataTypes.Utility
|
|||||||
{Material.WoodPlanks, 0.35f},
|
{Material.WoodPlanks, 0.35f},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A dictionary mapping materials to their default Elasticity.
|
||||||
|
/// </summary>
|
||||||
public static IReadOnlyDictionary<Material, float> ElasticityMap = new Dictionary<Material, float>()
|
public static IReadOnlyDictionary<Material, float> ElasticityMap = new Dictionary<Material, float>()
|
||||||
{
|
{
|
||||||
{Material.Air, 0.01f},
|
{Material.Air, 0.01f},
|
||||||
@ -85,6 +95,9 @@ namespace RobloxFiles.DataTypes.Utility
|
|||||||
{Material.WoodPlanks, 0.20f},
|
{Material.WoodPlanks, 0.20f},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A dictionary mapping materials to their default Friction.
|
||||||
|
/// </summary>
|
||||||
public static IReadOnlyDictionary<Material, float> FrictionMap = new Dictionary<Material, float>()
|
public static IReadOnlyDictionary<Material, float> FrictionMap = new Dictionary<Material, float>()
|
||||||
{
|
{
|
||||||
{Material.Air, 0.01f},
|
{Material.Air, 0.01f},
|
||||||
@ -124,5 +137,20 @@ namespace RobloxFiles.DataTypes.Utility
|
|||||||
{Material.Wood, 0.48f},
|
{Material.Wood, 0.48f},
|
||||||
{Material.WoodPlanks, 0.48f},
|
{Material.WoodPlanks, 0.48f},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A dictionary mapping materials to their default Friction.<para/>
|
||||||
|
/// NOTE: This only maps materials that have different FrictionWeights. If it isn't in here, assume their FrictionWeight is 1.
|
||||||
|
/// </summary>
|
||||||
|
public static IReadOnlyDictionary<Material, float> FrictionWeightMap = new Dictionary<Material, float>()
|
||||||
|
{
|
||||||
|
{Material.Asphalt, 0.30f},
|
||||||
|
{Material.Basalt, 0.30f},
|
||||||
|
{Material.Brick, 0.30f},
|
||||||
|
{Material.Concrete, 0.30f},
|
||||||
|
{Material.Ice, 3.00f},
|
||||||
|
{Material.Sand, 5.00f},
|
||||||
|
{Material.Sandstone, 5.00f},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
namespace RobloxFiles.DataTypes.Utility
|
namespace RobloxFiles.DataTypes.Utility
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Quaternion is a utility used by the CFrame DataType to handle rotation interpolation.
|
||||||
|
/// It can be used as an independent Quaternion implementation if you so please!
|
||||||
|
/// </summary>
|
||||||
public class Quaternion
|
public class Quaternion
|
||||||
{
|
{
|
||||||
public readonly float X;
|
public readonly float X, Y, Z, W;
|
||||||
public readonly float Y;
|
|
||||||
public readonly float Z;
|
|
||||||
public readonly float W;
|
|
||||||
|
|
||||||
public float Magnitude
|
public float Magnitude
|
||||||
{
|
{
|
||||||
@ -41,8 +42,7 @@ namespace RobloxFiles.DataTypes.Utility
|
|||||||
CFrame matrix = (cf - cf.Position);
|
CFrame matrix = (cf - cf.Position);
|
||||||
float[] ac = cf.GetComponents();
|
float[] ac = cf.GetComponents();
|
||||||
|
|
||||||
float m41 = ac[0], m42 = ac[1], m43 = ac[2],
|
float m11 = ac[3], m12 = ac[4], m13 = ac[5],
|
||||||
m11 = ac[3], m12 = ac[4], m13 = ac[5],
|
|
||||||
m21 = ac[6], m22 = ac[7], m23 = ac[8],
|
m21 = ac[6], m22 = ac[7], m23 = ac[8],
|
||||||
m31 = ac[9], m32 = ac[10], m33 = ac[11];
|
m31 = ac[9], m32 = ac[10], m33 = ac[11];
|
||||||
|
|
@ -20,7 +20,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
uint g = (value >> 8) & 0xFF;
|
uint g = (value >> 8) & 0xFF;
|
||||||
uint b = value & 0xFF;
|
uint b = value & 0xFF;
|
||||||
|
|
||||||
prop.Value = Color3.fromRGB(r, g, b);
|
prop.Value = Color3.FromRGB(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -9,22 +9,16 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
private static string[] Fields = new string[2] { "origin", "direction" };
|
private static string[] Fields = new string[2] { "origin", "direction" };
|
||||||
|
|
||||||
public bool ReadToken(Property prop, XmlNode token)
|
public bool ReadToken(Property prop, XmlNode token)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Vector3[] read = new Vector3[Fields.Length];
|
Vector3[] read = new Vector3[Fields.Length];
|
||||||
|
|
||||||
for (int i = 0; i < read.Length; i++)
|
for (int i = 0; i < read.Length; i++)
|
||||||
{
|
{
|
||||||
string field = Fields[i];
|
string field = Fields[i];
|
||||||
try
|
|
||||||
{
|
|
||||||
var fieldToken = token[field];
|
var fieldToken = token[field];
|
||||||
Vector3? vector3 = Vector3Token.ReadVector3(fieldToken);
|
read[i] = Vector3Token.ReadVector3(fieldToken);
|
||||||
read[i] = vector3.Value;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 origin = read[0],
|
Vector3 origin = read[0],
|
||||||
@ -36,5 +30,10 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,22 +9,16 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
private static string[] Fields = new string[2] { "min", "max" };
|
private static string[] Fields = new string[2] { "min", "max" };
|
||||||
|
|
||||||
public bool ReadToken(Property prop, XmlNode token)
|
public bool ReadToken(Property prop, XmlNode token)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Vector2[] read = new Vector2[Fields.Length];
|
Vector2[] read = new Vector2[Fields.Length];
|
||||||
|
|
||||||
for (int i = 0; i < read.Length; i++)
|
for (int i = 0; i < read.Length; i++)
|
||||||
{
|
{
|
||||||
string field = Fields[i];
|
string field = Fields[i];
|
||||||
try
|
|
||||||
{
|
|
||||||
var fieldToken = token[field];
|
var fieldToken = token[field];
|
||||||
Vector2? vector2 = Vector2Token.ReadVector2(fieldToken);
|
read[i] = Vector2Token.ReadVector2(fieldToken);
|
||||||
read[i] = vector2.Value;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 min = read[0],
|
Vector2 min = read[0],
|
||||||
@ -36,5 +30,10 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
{
|
{
|
||||||
public string Token => "UDim";
|
public string Token => "UDim";
|
||||||
|
|
||||||
public static UDim? ReadUDim(XmlNode token, string prefix = "")
|
public static UDim ReadUDim(XmlNode token, string prefix = "")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -27,13 +27,13 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
|
|
||||||
public bool ReadToken(Property property, XmlNode token)
|
public bool ReadToken(Property property, XmlNode token)
|
||||||
{
|
{
|
||||||
UDim? result = ReadUDim(token);
|
UDim result = ReadUDim(token);
|
||||||
bool success = result.HasValue;
|
bool success = (result != null);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
property.Type = PropertyType.UDim;
|
property.Type = PropertyType.UDim;
|
||||||
property.Value = result.Value;
|
property.Value = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -9,13 +9,13 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
|
|
||||||
public bool ReadToken(Property property, XmlNode token)
|
public bool ReadToken(Property property, XmlNode token)
|
||||||
{
|
{
|
||||||
UDim? xDim = UDimToken.ReadUDim(token, "X");
|
UDim xUDim = UDimToken.ReadUDim(token, "X");
|
||||||
UDim? yDim = UDimToken.ReadUDim(token, "Y");
|
UDim yUDim = UDimToken.ReadUDim(token, "Y");
|
||||||
|
|
||||||
if (xDim != null && yDim != null)
|
if (xUDim != null && yUDim != null)
|
||||||
{
|
{
|
||||||
property.Type = PropertyType.UDim2;
|
property.Type = PropertyType.UDim2;
|
||||||
property.Value = new UDim2(xDim.Value, yDim.Value);
|
property.Value = new UDim2(xUDim, yUDim);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
public string Token => "Vector2";
|
public string Token => "Vector2";
|
||||||
private static string[] Coords = new string[2] { "X", "Y" };
|
private static string[] Coords = new string[2] { "X", "Y" };
|
||||||
|
|
||||||
public static Vector2? ReadVector2(XmlNode token)
|
public static Vector2 ReadVector2(XmlNode token)
|
||||||
{
|
{
|
||||||
float[] xy = new float[2];
|
float[] xy = new float[2];
|
||||||
|
|
||||||
@ -33,13 +33,13 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
|
|
||||||
public bool ReadToken(Property property, XmlNode token)
|
public bool ReadToken(Property property, XmlNode token)
|
||||||
{
|
{
|
||||||
Vector2? result = ReadVector2(token);
|
Vector2 result = ReadVector2(token);
|
||||||
bool success = result.HasValue;
|
bool success = (result != null);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
property.Type = PropertyType.Vector2;
|
property.Type = PropertyType.Vector2;
|
||||||
property.Value = result.Value;
|
property.Value = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -8,7 +8,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
public string Token => "Vector3";
|
public string Token => "Vector3";
|
||||||
private static string[] Coords = new string[3] { "X", "Y", "Z" };
|
private static string[] Coords = new string[3] { "X", "Y", "Z" };
|
||||||
|
|
||||||
public static Vector3? ReadVector3(XmlNode token)
|
public static Vector3 ReadVector3(XmlNode token)
|
||||||
{
|
{
|
||||||
float[] xyz = new float[3];
|
float[] xyz = new float[3];
|
||||||
|
|
||||||
@ -32,13 +32,13 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
|
|||||||
|
|
||||||
public bool ReadToken(Property property, XmlNode token)
|
public bool ReadToken(Property property, XmlNode token)
|
||||||
{
|
{
|
||||||
Vector3? result = ReadVector3(token);
|
Vector3 result = ReadVector3(token);
|
||||||
bool success = result.HasValue;
|
bool success = (result != null);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
property.Type = PropertyType.Vector3;
|
property.Type = PropertyType.Vector3;
|
||||||
property.Value = result.Value;
|
property.Value = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -26,7 +26,7 @@ namespace RobloxFiles.XmlFormat
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
throw new Exception("XmlRobloxFile: Could not read XML!");
|
throw new Exception("XmlRobloxFile: Could not read provided buffer as XML!");
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlNode roblox = Root.FirstChild;
|
XmlNode roblox = Root.FirstChild;
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="lz4net" version="1.0.15.93" targetFramework="net452" />
|
|
||||||
</packages>
|
|
Loading…
Reference in New Issue
Block a user