Compare commits
93 Commits
0.6.0-rc2
...
dev-extens
| Author | SHA1 | Date | |
|---|---|---|---|
| 054b17811d | |||
| 94d5f7f82e | |||
| 0e4445e52b | |||
| ed2c216cf4 | |||
| 609645c108 | |||
| d280d27a0a | |||
| 5b727065f3 | |||
| 7aa2577059 | |||
| c1b7e9ab55 | |||
| 99384397ed | |||
| a2391aeb22 | |||
| 2207c80951 | |||
| bf578d7cb9 | |||
| 0bc57c368f | |||
| b64f85aaa2 | |||
| 93fa2f2d7e | |||
| d72216de8b | |||
| df5133a91a | |||
| 88b959a118 | |||
| 310bf91fbd | |||
| 699f47f98d | |||
| 24e881b138 | |||
| 2eef1b5c4e | |||
| c18ceb50d4 | |||
| 27ca1a7292 | |||
| dc59176eac | |||
| aec7470ff8 | |||
| 983cba6843 | |||
| 871782e73f | |||
| 9aaa96fe10 | |||
| 22190a29c1 | |||
| 613ca467d0 | |||
| 536a3066b2 | |||
| 43488cd002 | |||
| a11ccbd39c | |||
| 76df4929a7 | |||
| 505b826627 | |||
| 26a8675922 | |||
| b89e1f983e | |||
| 717e77b47e | |||
| 2f10c79dee | |||
| 55f7790f89 | |||
| ae5f4a8c16 | |||
| 1851bd3c54 | |||
| 6d74685cb7 | |||
| 03fd7f6d01 | |||
| 28c878f3e5 | |||
| 7736eba14d | |||
| 2e54b38d2b | |||
| da60dc0903 | |||
| 215f72b3b5 | |||
| a93c081dd8 | |||
| 456782930a | |||
| ba3cbbd64c | |||
| dfc3e9ca06 | |||
| f567a2b78e | |||
| c7e7bd8a77 | |||
| 67720fd0e1 | |||
| 1a30149942 | |||
| a755cc13bd | |||
| 9a51cf1b56 | |||
| 256c656e9c | |||
| 2ac7f05316 | |||
| 28d46dbabe | |||
| 18b3e0bc84 | |||
| 23f2e7c1f2 | |||
| 998713b41f | |||
| 3561354231 | |||
| 0cccb170c1 | |||
| d2480b8a6f | |||
| 6837d3f7ee | |||
| 3ecf3b4bfc | |||
| 1da8647ff1 | |||
| 2f19e8daad | |||
| 07f62c7aeb | |||
| 39db8dfa45 | |||
| f04cd370f1 | |||
| 5c4acd54ce | |||
| 82dbc5c479 | |||
| 1f1663d714 | |||
| a3c5392caa | |||
| 6c983cc2cb | |||
| 3bf3fdac3d | |||
| f2f3dba098 | |||
| 3728360dd2 | |||
| 887837bb3d | |||
| 99b4c2dfc1 | |||
| e59769158a | |||
| ba3238614b | |||
| a115999aab | |||
| 393947db9f | |||
| e9b2a7f894 | |||
| 9c73455761 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -68,3 +68,4 @@ crashlytics-build.properties
|
|||||||
/UserSettings
|
/UserSettings
|
||||||
/*.zip
|
/*.zip
|
||||||
*.lnk
|
*.lnk
|
||||||
|
/HybridCLRData
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 5335612e48e4c3947808c99fb99411d5
|
guid: c4ef48e4a4983de4e9c31483df2a918e
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 6823ead66b33bc048bbad48719feb25d
|
guid: 9ec674235c0dd6744af2dab2b58dd53c
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
8
Assets/Cryville/Common/Collections/Generic/IPairList.cs
Normal file
8
Assets/Cryville/Common/Collections/Generic/IPairList.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Collections.Generic {
|
||||||
|
public interface IPairList<TKey, TValue> : IList<KeyValuePair<TKey, TValue>> {
|
||||||
|
void Add(TKey key, TValue value);
|
||||||
|
void Insert(int index, TKey key, TValue value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: f5b3f3294f679f14f8ec1195b0def630
|
guid: 73fb17b484b343242bcce27c15ed7d44
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
46
Assets/Cryville/Common/Collections/Generic/PairCollection.cs
Normal file
46
Assets/Cryville/Common/Collections/Generic/PairCollection.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Collections.Generic {
|
||||||
|
[DebuggerDisplay("Count = {Count}"), DebuggerTypeProxy(typeof(PairCollectionDebugView<,>))]
|
||||||
|
public struct PairCollection<TKey, TValue> : IDisposable {
|
||||||
|
public void Dispose() { }
|
||||||
|
readonly IPairList<TKey, TValue> _pairList;
|
||||||
|
readonly IDictionary<TKey, TValue> _dictionary;
|
||||||
|
public PairCollection(object collection) : this() {
|
||||||
|
var type = collection.GetType();
|
||||||
|
if (typeof(IPairList<TKey, TValue>).IsAssignableFrom(type)) _pairList = (IPairList<TKey, TValue>)collection;
|
||||||
|
else if (typeof(IDictionary<TKey, TValue>).IsAssignableFrom(type)) _dictionary = (IDictionary<TKey, TValue>)collection;
|
||||||
|
else throw new ArgumentException("Parameter is not a pair collection");
|
||||||
|
}
|
||||||
|
public int Count {
|
||||||
|
get {
|
||||||
|
if (_pairList != null) return _pairList.Count;
|
||||||
|
else return _dictionary.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Add(TKey key, TValue value) {
|
||||||
|
if (_pairList != null) _pairList.Add(key, value);
|
||||||
|
else _dictionary.Add(key, value);
|
||||||
|
}
|
||||||
|
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int index) {
|
||||||
|
if (_pairList != null) _pairList.CopyTo(array, index);
|
||||||
|
else _dictionary.CopyTo(array, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal class PairCollectionDebugView<TKey, TValue> {
|
||||||
|
readonly PairCollection<TKey, TValue> _self;
|
||||||
|
public PairCollectionDebugView(PairCollection<TKey, TValue> self) {
|
||||||
|
_self = self;
|
||||||
|
}
|
||||||
|
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
|
||||||
|
public KeyValuePair<TKey, TValue>[] Items {
|
||||||
|
get {
|
||||||
|
KeyValuePair<TKey, TValue>[] array = new KeyValuePair<TKey, TValue>[_self.Count];
|
||||||
|
_self.CopyTo(array, 0);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 23377bf2926d93a4b8e3f3ab6040c7f2
|
guid: 2517e8f040bd36f46948e5fafaf5335c
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
48
Assets/Cryville/Common/Collections/Generic/PairList.cs
Normal file
48
Assets/Cryville/Common/Collections/Generic/PairList.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Collections.Generic {
|
||||||
|
[DebuggerDisplay("Count = {Count}"), DebuggerTypeProxy(typeof(PairListDebugView<,>))]
|
||||||
|
public class PairList<TKey, TValue> : List<KeyValuePair<TKey, TValue>>, IPairList<TKey, TValue>, IPairList {
|
||||||
|
public void Add(TKey key, TValue value) {
|
||||||
|
Add(new KeyValuePair<TKey, TValue>(key, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(object key, object value) {
|
||||||
|
try {
|
||||||
|
Add((TKey)key, (TValue)value);
|
||||||
|
}
|
||||||
|
catch (InvalidCastException) {
|
||||||
|
throw new ArgumentException("Wrong key type or value type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(int index, TKey key, TValue value) {
|
||||||
|
Insert(index, new KeyValuePair<TKey, TValue>(key, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(int index, object key, object value) {
|
||||||
|
try {
|
||||||
|
Insert(index, (TKey)key, (TValue)value);
|
||||||
|
}
|
||||||
|
catch (InvalidCastException) {
|
||||||
|
throw new ArgumentException("Wrong key type or value type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal class PairListDebugView<TKey, TValue> {
|
||||||
|
readonly PairList<TKey, TValue> _self;
|
||||||
|
public PairListDebugView(PairList<TKey, TValue> self) {
|
||||||
|
_self = self;
|
||||||
|
}
|
||||||
|
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
|
||||||
|
public KeyValuePair<TKey, TValue>[] Items {
|
||||||
|
get {
|
||||||
|
KeyValuePair<TKey, TValue>[] array = new KeyValuePair<TKey, TValue>[_self.Count];
|
||||||
|
_self.CopyTo(array, 0);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 4ffe72fef6ebb9e4da3571b4117f0d6d
|
guid: d9ed5ea8b7b1a934287e7ec5971166c0
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
8
Assets/Cryville/Common/Collections/IPairList.cs
Normal file
8
Assets/Cryville/Common/Collections/IPairList.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Collections {
|
||||||
|
public interface IPairList : IList {
|
||||||
|
void Add(object key, object value);
|
||||||
|
void Insert(int index, object key, object value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: e3c5a8bf05d5e284ba498e91cb0dd35e
|
guid: 046617672d437de4ab7e644a55defd3b
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
47
Assets/Cryville/Common/Collections/PairCollection.cs
Normal file
47
Assets/Cryville/Common/Collections/PairCollection.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Collections {
|
||||||
|
[DebuggerDisplay("Count = {Count}"), DebuggerTypeProxy(typeof(PairCollectionDebugView))]
|
||||||
|
public struct PairCollection : IDisposable {
|
||||||
|
public void Dispose() { }
|
||||||
|
readonly IPairList _pairList;
|
||||||
|
readonly IDictionary _dictionary;
|
||||||
|
public PairCollection(object collection) : this() {
|
||||||
|
var type = collection.GetType();
|
||||||
|
if (typeof(IPairList).IsAssignableFrom(type)) _pairList = (IPairList)collection;
|
||||||
|
else if (typeof(IDictionary).IsAssignableFrom(type)) _dictionary = (IDictionary)collection;
|
||||||
|
else throw new ArgumentException("Parameter is not a pair collection");
|
||||||
|
}
|
||||||
|
public int Count {
|
||||||
|
get {
|
||||||
|
if (_pairList != null) return _pairList.Count;
|
||||||
|
else return _dictionary.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Add(object key, object value) {
|
||||||
|
if (_pairList != null) _pairList.Add(key, value);
|
||||||
|
else _dictionary.Add(key, value);
|
||||||
|
}
|
||||||
|
public void CopyTo(KeyValuePair<object, object>[] array, int index) {
|
||||||
|
if (_pairList != null) _pairList.CopyTo(array, index);
|
||||||
|
else _dictionary.CopyTo(array, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal class PairCollectionDebugView {
|
||||||
|
readonly PairCollection _self;
|
||||||
|
public PairCollectionDebugView(PairCollection self) {
|
||||||
|
_self = self;
|
||||||
|
}
|
||||||
|
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
|
||||||
|
public KeyValuePair<object, object>[] Items {
|
||||||
|
get {
|
||||||
|
KeyValuePair<object, object>[] array = new KeyValuePair<object, object>[_self.Count];
|
||||||
|
_self.CopyTo(array, 0);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Common/Collections/PairCollection.cs.meta
Normal file
11
Assets/Cryville/Common/Collections/PairCollection.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1f87dfb8f6a1f5640b6deae741cd715c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
29
Assets/Cryville/Common/Collections/PairList.cs
Normal file
29
Assets/Cryville/Common/Collections/PairList.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Collections {
|
||||||
|
[DebuggerDisplay("Count = {Count}"), DebuggerTypeProxy(typeof(PairListDebugView))]
|
||||||
|
public class PairList : List<KeyValuePair<object, object>>, IPairList {
|
||||||
|
public void Add(object key, object value) {
|
||||||
|
Add(new KeyValuePair<object, object>(key, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(int index, object key, object value) {
|
||||||
|
Insert(index, new KeyValuePair<object, object>(key, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal class PairListDebugView {
|
||||||
|
readonly PairList _self;
|
||||||
|
public PairListDebugView(PairList self) {
|
||||||
|
_self = self;
|
||||||
|
}
|
||||||
|
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
|
||||||
|
public KeyValuePair<object, object>[] Items {
|
||||||
|
get {
|
||||||
|
KeyValuePair<object, object>[] array = new KeyValuePair<object, object>[_self.Count];
|
||||||
|
_self.CopyTo(array, 0);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Common/Collections/PairList.cs.meta
Normal file
11
Assets/Cryville/Common/Collections/PairList.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 57fc9f037c1fda5449e2a365a835c82c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -45,7 +45,7 @@ namespace Cryville.Common.Font {
|
|||||||
return tableDirectoryOffsets;
|
return tableDirectoryOffsets;
|
||||||
}
|
}
|
||||||
public override TableDirectory GetSubTable(UInt32 item) {
|
public override TableDirectory GetSubTable(UInt32 item) {
|
||||||
var i = (UInt32)item;
|
var i = item;
|
||||||
return new TableDirectory(Reader, i);
|
return new TableDirectory(Reader, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Cryville.Common {
|
namespace Cryville.Common {
|
||||||
public struct Identifier : IEquatable<Identifier> {
|
public struct Identifier : IEquatable<Identifier> {
|
||||||
|
public static Identifier Empty = new Identifier(0);
|
||||||
public int Key { get; private set; }
|
public int Key { get; private set; }
|
||||||
public object Name { get { return IdentifierManager.SharedInstance.Retrieve(Key); } }
|
public object Name { get { return IdentifierManager.SharedInstance.Retrieve(Key); } }
|
||||||
public Identifier(int key) {
|
public Identifier(int key) {
|
||||||
|
|||||||
44
Assets/Cryville/Common/Math/CubicBezier.cs
Normal file
44
Assets/Cryville/Common/Math/CubicBezier.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using SMath = System.Math;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Math {
|
||||||
|
// Ported from https://github.com/arian/cubic-bezier/blob/master/index.js
|
||||||
|
public static class CubicBezier {
|
||||||
|
public static float Evaluate(float t, float x1, float y1, float x2, float y2, float epsilon) {
|
||||||
|
float x = t, t0, t1, t2, tx, d2, i;
|
||||||
|
for (t2 = x, i = 0; i < 8; i++) {
|
||||||
|
tx = CurveX(t2, x1, x2) - x;
|
||||||
|
if (SMath.Abs(tx) < epsilon) return CurveY(t2, y1, y2);
|
||||||
|
d2 = DerivativeCurveX(t2, x1, x2);
|
||||||
|
if (SMath.Abs(d2) < 1e-6) break;
|
||||||
|
t2 -= tx / d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
t0 = 0; t1 = 1; t2 = x;
|
||||||
|
|
||||||
|
if (t2 < t0) return CurveY(t0, y1, y2);
|
||||||
|
if (t2 > t1) return CurveY(t1, y1, y2);
|
||||||
|
|
||||||
|
while (t0 < t1) {
|
||||||
|
tx = CurveX(t2, x1, x2);
|
||||||
|
if (SMath.Abs(tx - x) < epsilon) return CurveY(t2, y1, y2);
|
||||||
|
if (x > tx) t0 = t2;
|
||||||
|
else t1 = t2;
|
||||||
|
t2 = (t1 - t0) * .5f + t0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CurveY(t2, y1, y2);
|
||||||
|
}
|
||||||
|
static float CurveX(float t, float x1, float x2) {
|
||||||
|
float v = 1 - t;
|
||||||
|
return 3 * v * v * t * x1 + 3 * v * t * t * x2 + t * t * t;
|
||||||
|
}
|
||||||
|
static float CurveY(float t, float y1, float y2) {
|
||||||
|
float v = 1 - t;
|
||||||
|
return 3 * v * v * t * y1 + 3 * v * t * t * y2 + t * t * t;
|
||||||
|
}
|
||||||
|
static float DerivativeCurveX(float t, float x1, float x2) {
|
||||||
|
float v = 1 - t;
|
||||||
|
return 3 * (2 * (t - 1) * t + v * v) * x1 + 3 * (-t * t * t + 2 * v * t) * x2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Common/Math/CubicBezier.cs.meta
Normal file
11
Assets/Cryville/Common/Math/CubicBezier.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 17dd6f775fc965f43960da7166b55b87
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -12,12 +12,12 @@ namespace Cryville.Common.Math {
|
|||||||
/// <param name="error">The error.</param>
|
/// <param name="error">The error.</param>
|
||||||
/// <param name="n">The numerator.</param>
|
/// <param name="n">The numerator.</param>
|
||||||
/// <param name="d">The denominator.</param>
|
/// <param name="d">The denominator.</param>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is less than 0 or <paramref name="error" /> is not greater than 0 or not less than 1.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is less than 0 or <paramref name="error" /> is not greater than 0 or greater than 1.</exception>
|
||||||
public static void ToFraction(double value, double error, out int n, out int d) {
|
public static void ToFraction(double value, double error, out int n, out int d) {
|
||||||
if (value < 0.0)
|
if (value < 0.0)
|
||||||
throw new ArgumentOutOfRangeException("value", "Must be >= 0.");
|
throw new ArgumentOutOfRangeException("value", "Must be >= 0.");
|
||||||
if (error <= 0.0 || error >= 1.0)
|
if (error <= 0.0 || error > 1.0)
|
||||||
throw new ArgumentOutOfRangeException("accuracy", "Must be > 0 and < 1.");
|
throw new ArgumentOutOfRangeException("error", "Must be > 0 and <= 1.");
|
||||||
|
|
||||||
int num = (int)System.Math.Floor(value);
|
int num = (int)System.Math.Floor(value);
|
||||||
value -= num;
|
value -= num;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
/// Indicates that the attributed member is an element list.
|
/// Indicates that the attributed member is an element list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>An element list is a <see cref="System.Collections.IDictionary" /> that represents a collection of PDT elements. There must be at most one element list in a class.</para>
|
/// <para>An element list is a <see cref="System.Collections.IDictionary" /> or <see cref="Cryville.Common.Collections.Generic.IPairList" /> that represents a collection of PDT elements. There must be at most one element list in a class.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||||
public class ElementListAttribute : Attribute { }
|
public class ElementListAttribute : Attribute { }
|
||||||
@@ -14,7 +14,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
/// Indicates that the attributed member is a property list.
|
/// Indicates that the attributed member is a property list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>A property list is a <see cref="System.Collections.IDictionary" /> that represents a collection of PDT properties. There must be at most one property list in a class.</para>
|
/// <para>A property list is a <see cref="System.Collections.IDictionary" /> or <see cref="Cryville.Common.Collections.Generic.IPairList" /> that represents a collection of PDT properties. There must be at most one property list in a class.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||||
public class PropertyListAttribute : Attribute { }
|
public class PropertyListAttribute : Attribute { }
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public partial class PdtInterpreter {
|
public partial class PdtInterpreter {
|
||||||
readonly static Dictionary<char, int> OP_PRIORITY = new Dictionary<char, int> {
|
static readonly Dictionary<char, int> OP_PRIORITY = new Dictionary<char, int> {
|
||||||
{ '@', 7 },
|
{ '@', 7 },
|
||||||
{ '*', 6 }, { '/', 6 }, { '%', 6 },
|
{ '*', 6 }, { '/', 6 }, { '%', 6 },
|
||||||
{ '+', 5 }, { '-', 5 },
|
{ '+', 5 }, { '-', 5 },
|
||||||
@@ -103,7 +103,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
{ ',', 0 },
|
{ ',', 0 },
|
||||||
{ '$', -1 },
|
{ '$', -1 },
|
||||||
};
|
};
|
||||||
readonly static Dictionary<char, int> OP_TYPE = new Dictionary<char, int> {
|
static readonly Dictionary<char, int> OP_TYPE = new Dictionary<char, int> {
|
||||||
{ '@', 0 },
|
{ '@', 0 },
|
||||||
{ '*', 0 }, { '/', 0 }, { '%', 0 },
|
{ '*', 0 }, { '/', 0 }, { '%', 0 },
|
||||||
{ '+', 0 }, { '-', 0 },
|
{ '+', 0 }, { '-', 0 },
|
||||||
@@ -115,7 +115,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
{ '$', -1 },
|
{ '$', -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
readonly static PdtExpression _emptyexp;
|
static readonly PdtExpression _emptyexp;
|
||||||
static PdtInterpreter() {
|
static PdtInterpreter() {
|
||||||
var ins = new LinkedList<PdtInstruction>();
|
var ins = new LinkedList<PdtInstruction>();
|
||||||
ins.AddLast(new PdtInstruction.PushConstant(
|
ins.AddLast(new PdtInstruction.PushConstant(
|
||||||
@@ -143,7 +143,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return string.Format("0x{0:x4}: {1}", Type, Value);
|
return string.Format("0x{0:x4}: {1}", Type, Value);
|
||||||
}
|
}
|
||||||
public readonly static PdtExpToken EmptyOperator = new PdtExpToken {
|
public static readonly PdtExpToken EmptyOperator = new PdtExpToken {
|
||||||
Type = 0x0080,
|
Type = 0x0080,
|
||||||
Value = "$",
|
Value = "$",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,30 +6,30 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Error type.
|
/// Error type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly static int Error = 0x00525245;
|
public const int Error = 0x00525245;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Array of a same variable-length type, with a suffix indicating the element count and the element type.
|
/// Array of a same variable-length type, with a suffix indicating the element count and the element type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly static int Array = 0x00525241;
|
public const int Array = 0x00525241;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Null type.
|
/// Null type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly static int Null = 0x4c4c554e;
|
public const int Null = 0x4c4c554e;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IEEE 754 32-bit floating-point number.
|
/// IEEE 754 32-bit floating-point number.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly static int Number = 0x004d554e;
|
public const int Number = 0x004d554e;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A sequence of UTF-16 code units, with a prefix indicating the number of the code units.
|
/// A sequence of UTF-16 code units, with a prefix indicating the number of the code units.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly static int String = 0x00525453;
|
public const int String = 0x00525453;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A sequence of UTF-16 code units, with a prefix indicating the number of the code units, representing the name of an undefined variable.
|
/// A sequence of UTF-16 code units, with a prefix indicating the number of the code units, representing the name of an undefined variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly static int Undefined = 0x00444e55;
|
public const int Undefined = 0x00444e55;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Vector of a same constant-length type, with a suffix indicating the element type.
|
/// Vector of a same constant-length type, with a suffix indicating the element type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly static int Vector = 0x00434556;
|
public const int Vector = 0x00434556;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Cryville.Common.Collections;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -27,7 +28,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
/// <item><term><c>0x1000</c></term><description>End of Key</description></item>
|
/// <item><term><c>0x1000</c></term><description>End of Key</description></item>
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
readonly static int[] cm = new int[] {
|
static readonly int[] cm = new int[] {
|
||||||
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
@@ -255,13 +256,13 @@ namespace Cryville.Common.Pdt {
|
|||||||
if (prop == null) throw new MissingMemberException(string.Format("The property \"{0}\" is not found", pkey));
|
if (prop == null) throw new MissingMemberException(string.Format("The property \"{0}\" is not found", pkey));
|
||||||
Type ptype = ReflectionHelper.GetMemberType(prop);
|
Type ptype = ReflectionHelper.GetMemberType(prop);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
if (!typeof(IDictionary).IsAssignableFrom(ptype))
|
using (var collection = new PairCollection(ReflectionHelper.GetValue(prop, result))) {
|
||||||
throw new InvalidOperationException("Internal error: Element list is not a dictionary");
|
|
||||||
var ktype = ptype.GetGenericArguments()[0];
|
var ktype = ptype.GetGenericArguments()[0];
|
||||||
var vtype = ptype.GetGenericArguments()[1];
|
var vtype = ptype.GetGenericArguments()[1];
|
||||||
object key = _binder.ChangeType(pkey, ktype, null);
|
object key = _binder.ChangeType(pkey, ktype, null);
|
||||||
object value = InterpretObject(vtype);
|
object value = InterpretObject(vtype);
|
||||||
((IDictionary)ReflectionHelper.GetValue(prop, result)).Add(key, value);
|
collection.Add(key, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else ReflectionHelper.SetValue(prop, result, InterpretObject(ptype));
|
else ReflectionHelper.SetValue(prop, result, InterpretObject(ptype));
|
||||||
}
|
}
|
||||||
@@ -284,13 +285,13 @@ namespace Cryville.Common.Pdt {
|
|||||||
if (prop == null) throw new MissingMemberException(string.Format("The property \"{0}\" is not found", pkey));
|
if (prop == null) throw new MissingMemberException(string.Format("The property \"{0}\" is not found", pkey));
|
||||||
var ptype = ReflectionHelper.GetMemberType(prop);
|
var ptype = ReflectionHelper.GetMemberType(prop);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
if (!typeof(IDictionary).IsAssignableFrom(ptype))
|
using (var collection = new PairCollection(ReflectionHelper.GetValue(prop, result))) {
|
||||||
throw new InvalidOperationException("Internal error: Property list is not a dictionary");
|
|
||||||
var ktype = ptype.GetGenericArguments()[0];
|
var ktype = ptype.GetGenericArguments()[0];
|
||||||
var vtype = ptype.GetGenericArguments()[1];
|
var vtype = ptype.GetGenericArguments()[1];
|
||||||
object key = _binder.ChangeType(pkey, ktype, null);
|
object key = _binder.ChangeType(pkey, ktype, null);
|
||||||
object value = _binder.ChangeType(exp, vtype, null);
|
object value = _binder.ChangeType(exp, vtype, null);
|
||||||
((IDictionary)ReflectionHelper.GetValue(prop, result)).Add(key, value);
|
collection.Add(key, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
object value = _binder.ChangeType(exp, ptype, null);
|
object value = _binder.ChangeType(exp, ptype, null);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// PDT operator.
|
/// PDT operator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public unsafe abstract class PdtOperator {
|
public abstract unsafe class PdtOperator {
|
||||||
byte* _prmem;
|
byte* _prmem;
|
||||||
int _loadindex;
|
int _loadindex;
|
||||||
readonly PdtVariableMemory[] _operands;
|
readonly PdtVariableMemory[] _operands;
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ namespace Cryville.Common.Unity {
|
|||||||
set { m_filter = value; }
|
set { m_filter = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, string> m_presetPaths = new Dictionary<string, string>();
|
public IReadOnlyDictionary<string, string> m_presetPaths = new Dictionary<string, string>();
|
||||||
public Dictionary<string, string> PresetPaths {
|
public IReadOnlyDictionary<string, string> PresetPaths {
|
||||||
get { return m_presetPaths; }
|
get { return m_presetPaths; }
|
||||||
set { m_presetPaths = value; }
|
set { m_presetPaths = value; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ using UnityEngine;
|
|||||||
namespace Cryville.Common.Unity.UI {
|
namespace Cryville.Common.Unity.UI {
|
||||||
public abstract class SetParameterBehaviour : StateMachineBehaviour {
|
public abstract class SetParameterBehaviour : StateMachineBehaviour {
|
||||||
[SerializeField] protected string m_name;
|
[SerializeField] protected string m_name;
|
||||||
public override abstract void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex);
|
public abstract override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Cryville.Crtr.Browsing {
|
|
||||||
public abstract class ExtensionInterface {
|
|
||||||
public abstract IEnumerable<ResourceConverter> GetResourceConverters();
|
|
||||||
public abstract IEnumerable<LocalResourceFinder> GetResourceFinders();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
138
Assets/Cryville/Crtr/Browsing/ExtensionManager.cs
Normal file
138
Assets/Cryville/Crtr/Browsing/ExtensionManager.cs
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
using Cryville.Common;
|
||||||
|
using Cryville.Crtr.Extension;
|
||||||
|
using Mono.Cecil;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Cryville.Crtr.Browsing {
|
||||||
|
internal static class ExtensionManager {
|
||||||
|
static readonly Dictionary<string, List<ResourceConverter>> _converters
|
||||||
|
= new Dictionary<string, List<ResourceConverter>>();
|
||||||
|
public static IEnumerable<string> GetSupportedFormats() {
|
||||||
|
return _converters.Keys;
|
||||||
|
}
|
||||||
|
public static bool TryGetConverters(string extension, out IEnumerable<ResourceConverter> converters) {
|
||||||
|
List<ResourceConverter> outResult;
|
||||||
|
bool result = _converters.TryGetValue(extension, out outResult);
|
||||||
|
converters = outResult;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
static readonly Dictionary<string, string> _localRes
|
||||||
|
= new Dictionary<string, string>();
|
||||||
|
public static IReadOnlyDictionary<string, string> GetLocalResourcePaths() {
|
||||||
|
return _localRes;
|
||||||
|
}
|
||||||
|
public static void Init(string rootPath) {
|
||||||
|
LoadExtension(typeof(Extensions.Umg.Extension));
|
||||||
|
var asms = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name).ToHashSet();
|
||||||
|
var modules = new Queue<ModuleItem>();
|
||||||
|
var extensionDir = new DirectoryInfo(Path.Combine(rootPath, "extensions"));
|
||||||
|
if (extensionDir.Exists) {
|
||||||
|
foreach (var extension in extensionDir.EnumerateFiles("*.dll")) {
|
||||||
|
try {
|
||||||
|
modules.Enqueue(new ModuleItem(extension.OpenRead()));
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Log("main", 4, "Extension", "Failed to load DLL {0}: {1}", extension, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int refCounter = 0;
|
||||||
|
while (modules.Count > 0 && refCounter < modules.Count) {
|
||||||
|
var module = modules.Dequeue();
|
||||||
|
bool flag = false;
|
||||||
|
foreach (var reference in module.Definition.AssemblyReferences) {
|
||||||
|
if (!asms.Contains(reference.Name)) {
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
modules.Enqueue(module);
|
||||||
|
refCounter++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
var stream = module.Stream;
|
||||||
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
var buf = new byte[stream.Length];
|
||||||
|
stream.Read(buf, 0, buf.Length);
|
||||||
|
var asm = Assembly.Load(buf);
|
||||||
|
if (asm == null) throw new TypeLoadException("Failed to load the module");
|
||||||
|
asms.Add(asm.GetName().Name);
|
||||||
|
foreach (var type in asm.GetTypes()) {
|
||||||
|
if (typeof(ExtensionInterface).IsAssignableFrom(type)) {
|
||||||
|
LoadExtension(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Logger.Log("main", 1, "Extension", "Loaded module {0}", module.Definition.Name);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Log("main", 4, "Extension", "An error occured while trying to load module {0}: {1}", module.Definition.Name, ex);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
module.Definition.Dispose();
|
||||||
|
module.Stream.Dispose();
|
||||||
|
refCounter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var missingList = new List<string>();
|
||||||
|
while (modules.Count > 0) {
|
||||||
|
missingList.Clear();
|
||||||
|
var module = modules.Dequeue();
|
||||||
|
foreach (var reference in module.Definition.AssemblyReferences) {
|
||||||
|
if (!asms.Contains(reference.Name)) {
|
||||||
|
missingList.Add(reference.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Logger.Log("main", 4, "Extension", "Could not load the module {0} because the following dependencies were missing: {1}", module.Definition.Name, missingList.Aggregate((current, next) => current + ", " + next));
|
||||||
|
module.Definition.Dispose();
|
||||||
|
module.Stream.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ModuleItem {
|
||||||
|
public ModuleDefinition Definition { get; set; }
|
||||||
|
public FileStream Stream { get; set; }
|
||||||
|
public ModuleItem(FileStream stream) {
|
||||||
|
Stream = stream;
|
||||||
|
Definition = ModuleDefinition.ReadModule(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void LoadExtension(Type type) {
|
||||||
|
try {
|
||||||
|
var extension = (ExtensionInterface)Activator.CreateInstance(type);
|
||||||
|
var l1 = extension.GetResourceConverters();
|
||||||
|
if (l1 != null) {
|
||||||
|
foreach (var c in l1) {
|
||||||
|
var fs = c.GetSupportedFormats();
|
||||||
|
if (fs == null) continue;
|
||||||
|
foreach (var f in fs) {
|
||||||
|
if (f == null) continue;
|
||||||
|
if (!_converters.ContainsKey(f))
|
||||||
|
_converters.Add(f, new List<ResourceConverter> { c });
|
||||||
|
else _converters[f].Add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var l2 = extension.GetResourceFinders();
|
||||||
|
if (l2 != null) {
|
||||||
|
foreach (var f in l2) {
|
||||||
|
var name = f.Name;
|
||||||
|
var path = f.GetRootPath();
|
||||||
|
if (name != null && path != null) _localRes.Add(name, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Logger.Log("main", 1, "Extension", "Loaded extension {0}", type);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Log("main", 4, "Extension", "Failed to load extension {0}: {1}", type, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Crtr/Browsing/ExtensionManager.cs.meta
Normal file
11
Assets/Cryville/Crtr/Browsing/ExtensionManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a9ea11165e6269b488f916982507a2af
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user