Initial commit.
There's a lot of code at play here, so I haven't tested it yet. A good chunk of the components are available though.
This commit is contained in:
2116
Core/Enums.cs
Normal file
2116
Core/Enums.cs
Normal file
File diff suppressed because it is too large
Load Diff
91
Core/Instance.cs
Normal file
91
Core/Instance.cs
Normal file
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace Roblox
|
||||
{
|
||||
public class RobloxInstance
|
||||
{
|
||||
private List<RobloxInstance> _children = new List<RobloxInstance>();
|
||||
private RobloxInstance _parent;
|
||||
|
||||
public string ClassName;
|
||||
public List<RobloxProperty> Properties = new List<RobloxProperty>();
|
||||
|
||||
public bool IsAncestorOf(RobloxInstance other)
|
||||
{
|
||||
while (other != null)
|
||||
{
|
||||
if (other == this)
|
||||
return true;
|
||||
|
||||
other = other.Parent;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsDescendantOf(RobloxInstance other)
|
||||
{
|
||||
return other.IsAncestorOf(this);
|
||||
}
|
||||
|
||||
public RobloxInstance Parent
|
||||
{
|
||||
get { return _parent; }
|
||||
set
|
||||
{
|
||||
if (IsAncestorOf(value))
|
||||
throw new Exception("Parent would result in circular reference.");
|
||||
|
||||
if (Parent == this)
|
||||
throw new Exception("Attempt to set parent to self");
|
||||
|
||||
if (_parent != null)
|
||||
_parent._children.Remove(this);
|
||||
|
||||
value._children.Add(this);
|
||||
_parent = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<RobloxInstance> Children
|
||||
{
|
||||
get { return _children.AsReadOnly(); }
|
||||
}
|
||||
|
||||
public object ReadProperty(string propertyName)
|
||||
{
|
||||
RobloxProperty property = Properties
|
||||
.Where((prop) => prop.Name == propertyName)
|
||||
.First();
|
||||
|
||||
return property.Value;
|
||||
}
|
||||
|
||||
public bool TryReadProperty<T>(string propertyName, out T value)
|
||||
{
|
||||
try
|
||||
{
|
||||
object result = ReadProperty(propertyName);
|
||||
value = (T)result;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
value = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var name = "";
|
||||
TryReadProperty("Name", out name);
|
||||
|
||||
return '[' + ClassName + ']' + name;
|
||||
}
|
||||
}
|
||||
}
|
62
Core/Property.cs
Normal file
62
Core/Property.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roblox
|
||||
{
|
||||
public enum PropertyType
|
||||
{
|
||||
Unknown,
|
||||
String,
|
||||
Bool,
|
||||
Int,
|
||||
Float,
|
||||
Double,
|
||||
UDim,
|
||||
UDim2,
|
||||
Ray,
|
||||
Faces,
|
||||
Axes,
|
||||
BrickColor,
|
||||
Color3,
|
||||
Vector2,
|
||||
Vector3,
|
||||
Vector2int16,
|
||||
CFrame,
|
||||
Quaternion,
|
||||
Enum,
|
||||
Ref,
|
||||
Vector3int16,
|
||||
NumberSequence,
|
||||
ColorSequence,
|
||||
NumberRange,
|
||||
Rect,
|
||||
PhysicalProperties,
|
||||
Color3uint8,
|
||||
Int64
|
||||
}
|
||||
|
||||
public class RobloxProperty
|
||||
{
|
||||
public string Name;
|
||||
public PropertyType Type;
|
||||
public object Value;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
Type PropertyType = typeof(PropertyType);
|
||||
|
||||
string typeName = Enum.GetName(PropertyType, Type);
|
||||
string valueLabel;
|
||||
|
||||
if (Value != null)
|
||||
valueLabel = Value.ToString();
|
||||
else
|
||||
valueLabel = "?";
|
||||
|
||||
return string.Join(" ", typeName, Name, '=', valueLabel);
|
||||
}
|
||||
}
|
||||
}
|
13
Core/RobloxFile.cs
Normal file
13
Core/RobloxFile.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roblox
|
||||
{
|
||||
public class RobloxFile
|
||||
{
|
||||
public List<RobloxInstance> Trunk { get; private set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user