Compare commits
71 Commits
0.6.0
...
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 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -68,3 +68,4 @@ crashlytics-build.properties
|
||||
/UserSettings
|
||||
/*.zip
|
||||
*.lnk
|
||||
/HybridCLRData
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5335612e48e4c3947808c99fb99411d5
|
||||
guid: c4ef48e4a4983de4e9c31483df2a918e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6823ead66b33bc048bbad48719feb25d
|
||||
guid: 9ec674235c0dd6744af2dab2b58dd53c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
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
|
||||
guid: f5b3f3294f679f14f8ec1195b0def630
|
||||
guid: 73fb17b484b343242bcce27c15ed7d44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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
|
||||
guid: 23377bf2926d93a4b8e3f3ab6040c7f2
|
||||
guid: 2517e8f040bd36f46948e5fafaf5335c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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
|
||||
guid: 4ffe72fef6ebb9e4da3571b4117f0d6d
|
||||
guid: d9ed5ea8b7b1a934287e7ec5971166c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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
|
||||
guid: e3c5a8bf05d5e284ba498e91cb0dd35e
|
||||
guid: 046617672d437de4ab7e644a55defd3b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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;
|
||||
}
|
||||
public override TableDirectory GetSubTable(UInt32 item) {
|
||||
var i = (UInt32)item;
|
||||
var i = item;
|
||||
return new TableDirectory(Reader, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Cryville.Common {
|
||||
public struct Identifier : IEquatable<Identifier> {
|
||||
public static Identifier Empty = new Identifier(0);
|
||||
public int Key { get; private set; }
|
||||
public object Name { get { return IdentifierManager.SharedInstance.Retrieve(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="n">The numerator.</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) {
|
||||
if (value < 0.0)
|
||||
throw new ArgumentOutOfRangeException("value", "Must be >= 0.");
|
||||
if (error <= 0.0 || error >= 1.0)
|
||||
throw new ArgumentOutOfRangeException("accuracy", "Must be > 0 and < 1.");
|
||||
if (error <= 0.0 || error > 1.0)
|
||||
throw new ArgumentOutOfRangeException("error", "Must be > 0 and <= 1.");
|
||||
|
||||
int num = (int)System.Math.Floor(value);
|
||||
value -= num;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// Indicates that the attributed member is an element list.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class ElementListAttribute : Attribute { }
|
||||
@@ -14,7 +14,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// Indicates that the attributed member is a property list.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class PropertyListAttribute : Attribute { }
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Cryville.Common.Pdt {
|
||||
}
|
||||
}
|
||||
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 },
|
||||
{ '*', 6 }, { '/', 6 }, { '%', 6 },
|
||||
{ '+', 5 }, { '-', 5 },
|
||||
@@ -103,7 +103,7 @@ namespace Cryville.Common.Pdt {
|
||||
{ ',', 0 },
|
||||
{ '$', -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 },
|
||||
@@ -115,7 +115,7 @@ namespace Cryville.Common.Pdt {
|
||||
{ '$', -1 },
|
||||
};
|
||||
|
||||
readonly static PdtExpression _emptyexp;
|
||||
static readonly PdtExpression _emptyexp;
|
||||
static PdtInterpreter() {
|
||||
var ins = new LinkedList<PdtInstruction>();
|
||||
ins.AddLast(new PdtInstruction.PushConstant(
|
||||
@@ -143,7 +143,7 @@ namespace Cryville.Common.Pdt {
|
||||
public override string ToString() {
|
||||
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,
|
||||
Value = "$",
|
||||
};
|
||||
|
||||
@@ -6,30 +6,30 @@
|
||||
/// <summary>
|
||||
/// Error type.
|
||||
/// </summary>
|
||||
public readonly static int Error = 0x00525245;
|
||||
public const int Error = 0x00525245;
|
||||
/// <summary>
|
||||
/// Array of a same variable-length type, with a suffix indicating the element count and the element type.
|
||||
/// </summary>
|
||||
public readonly static int Array = 0x00525241;
|
||||
public const int Array = 0x00525241;
|
||||
/// <summary>
|
||||
/// Null type.
|
||||
/// </summary>
|
||||
public readonly static int Null = 0x4c4c554e;
|
||||
public const int Null = 0x4c4c554e;
|
||||
/// <summary>
|
||||
/// IEEE 754 32-bit floating-point number.
|
||||
/// </summary>
|
||||
public readonly static int Number = 0x004d554e;
|
||||
public const int Number = 0x004d554e;
|
||||
/// <summary>
|
||||
/// A sequence of UTF-16 code units, with a prefix indicating the number of the code units.
|
||||
/// </summary>
|
||||
public readonly static int String = 0x00525453;
|
||||
public const int String = 0x00525453;
|
||||
/// <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.
|
||||
/// </summary>
|
||||
public readonly static int Undefined = 0x00444e55;
|
||||
public const int Undefined = 0x00444e55;
|
||||
/// <summary>
|
||||
/// Vector of a same constant-length type, with a suffix indicating the element type.
|
||||
/// </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.Generic;
|
||||
using System.Linq;
|
||||
@@ -27,7 +28,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <item><term><c>0x1000</c></term><description>End of Key</description></item>
|
||||
/// </list>
|
||||
/// </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
|
||||
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,
|
||||
@@ -255,13 +256,13 @@ namespace Cryville.Common.Pdt {
|
||||
if (prop == null) throw new MissingMemberException(string.Format("The property \"{0}\" is not found", pkey));
|
||||
Type ptype = ReflectionHelper.GetMemberType(prop);
|
||||
if (flag) {
|
||||
if (!typeof(IDictionary).IsAssignableFrom(ptype))
|
||||
throw new InvalidOperationException("Internal error: Element list is not a dictionary");
|
||||
var ktype = ptype.GetGenericArguments()[0];
|
||||
var vtype = ptype.GetGenericArguments()[1];
|
||||
object key = _binder.ChangeType(pkey, ktype, null);
|
||||
object value = InterpretObject(vtype);
|
||||
((IDictionary)ReflectionHelper.GetValue(prop, result)).Add(key, value);
|
||||
using (var collection = new PairCollection(ReflectionHelper.GetValue(prop, result))) {
|
||||
var ktype = ptype.GetGenericArguments()[0];
|
||||
var vtype = ptype.GetGenericArguments()[1];
|
||||
object key = _binder.ChangeType(pkey, ktype, null);
|
||||
object value = InterpretObject(vtype);
|
||||
collection.Add(key, value);
|
||||
}
|
||||
}
|
||||
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));
|
||||
var ptype = ReflectionHelper.GetMemberType(prop);
|
||||
if (flag) {
|
||||
if (!typeof(IDictionary).IsAssignableFrom(ptype))
|
||||
throw new InvalidOperationException("Internal error: Property list is not a dictionary");
|
||||
var ktype = ptype.GetGenericArguments()[0];
|
||||
var vtype = ptype.GetGenericArguments()[1];
|
||||
object key = _binder.ChangeType(pkey, ktype, null);
|
||||
object value = _binder.ChangeType(exp, vtype, null);
|
||||
((IDictionary)ReflectionHelper.GetValue(prop, result)).Add(key, value);
|
||||
using (var collection = new PairCollection(ReflectionHelper.GetValue(prop, result))) {
|
||||
var ktype = ptype.GetGenericArguments()[0];
|
||||
var vtype = ptype.GetGenericArguments()[1];
|
||||
object key = _binder.ChangeType(pkey, ktype, null);
|
||||
object value = _binder.ChangeType(exp, vtype, null);
|
||||
collection.Add(key, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
object value = _binder.ChangeType(exp, ptype, null);
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <summary>
|
||||
/// PDT operator.
|
||||
/// </summary>
|
||||
public unsafe abstract class PdtOperator {
|
||||
public abstract unsafe class PdtOperator {
|
||||
byte* _prmem;
|
||||
int _loadindex;
|
||||
readonly PdtVariableMemory[] _operands;
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace Cryville.Common.Unity {
|
||||
set { m_filter = value; }
|
||||
}
|
||||
|
||||
public Dictionary<string, string> m_presetPaths = new Dictionary<string, string>();
|
||||
public Dictionary<string, string> PresetPaths {
|
||||
public IReadOnlyDictionary<string, string> m_presetPaths = new Dictionary<string, string>();
|
||||
public IReadOnlyDictionary<string, string> PresetPaths {
|
||||
get { return m_presetPaths; }
|
||||
set { m_presetPaths = value; }
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ using UnityEngine;
|
||||
namespace Cryville.Common.Unity.UI {
|
||||
public abstract class SetParameterBehaviour : StateMachineBehaviour {
|
||||
[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:
|
||||
@@ -12,6 +12,6 @@ namespace Cryville.Crtr.Browsing {
|
||||
|
||||
bool ImportItemFrom(string path);
|
||||
string[] GetSupportedFormats();
|
||||
Dictionary<string, string> GetPresetPaths();
|
||||
IReadOnlyDictionary<string, string> GetPresetPaths();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Unity;
|
||||
using Cryville.Crtr.Extension;
|
||||
using Cryville.Crtr.Extensions.Umg;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,49 +17,13 @@ namespace Cryville.Crtr.Browsing {
|
||||
private DirectoryInfo[] items = new DirectoryInfo[0];
|
||||
public string[] CurrentDirectory { get; private set; }
|
||||
|
||||
static readonly Dictionary<string, List<ResourceConverter>> converters
|
||||
= new Dictionary<string, List<ResourceConverter>>();
|
||||
static readonly Dictionary<string, string> localRes
|
||||
= new Dictionary<string, string>();
|
||||
static bool _init;
|
||||
|
||||
public LegacyResourceManager(string rootPath) {
|
||||
_rootPath = rootPath;
|
||||
}
|
||||
|
||||
static LegacyResourceManager() {
|
||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) {
|
||||
foreach (var type in asm.GetTypes()) {
|
||||
if (!type.IsSubclassOf(typeof(ExtensionInterface))) continue;
|
||||
var ext = (ExtensionInterface)Activator.CreateInstance(type);
|
||||
try {
|
||||
var cs = ext.GetResourceConverters();
|
||||
if (cs != null) {
|
||||
foreach (var c in cs) {
|
||||
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 fs2 = ext.GetResourceFinders();
|
||||
if (fs2 != null) {
|
||||
foreach (var f in fs2) {
|
||||
var name = f.Name;
|
||||
var path = f.GetRootPath();
|
||||
if (name != null && path != null)
|
||||
localRes.Add(name, path);
|
||||
}
|
||||
}
|
||||
Logger.Log("main", 1, "Resource", "Loaded extension {0}", ReflectionHelper.GetNamespaceQualifiedName(type));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Log("main", 4, "Resource", "Failed to initialize extension {0}: {1}", ReflectionHelper.GetNamespaceQualifiedName(type), ex);
|
||||
}
|
||||
}
|
||||
if (!_init) {
|
||||
_init = true;
|
||||
ExtensionManager.Init(rootPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,14 +115,15 @@ namespace Cryville.Crtr.Browsing {
|
||||
|
||||
public bool ImportItemFrom(string path) {
|
||||
var file = new FileInfo(path);
|
||||
if (!converters.ContainsKey(file.Extension)) return false;
|
||||
foreach (var converter in converters[file.Extension]) {
|
||||
IEnumerable<ResourceConverter> converters;
|
||||
if (!ExtensionManager.TryGetConverters(file.Extension, out converters)) return false;
|
||||
foreach (var converter in converters) {
|
||||
IEnumerable<Resource> resources = null;
|
||||
try {
|
||||
resources = converter.ConvertFrom(file);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LogAndPopup(4, ex.Message);
|
||||
LogAndPopupExtra(4, ex, "Failed to import resource: {0}", ex.Message);
|
||||
return false;
|
||||
}
|
||||
foreach (var res in resources) {
|
||||
@@ -168,7 +135,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
var dir = new DirectoryInfo(_rootPath + "/charts/" + res.Name);
|
||||
if (!dir.Exists) dir.Create();
|
||||
using (var writer = new StreamWriter(dir.FullName + "/.json")) {
|
||||
writer.Write(JsonConvert.SerializeObject(tres.Main, Game.GlobalJsonSerializerSettings));
|
||||
writer.Write(JsonConvert.SerializeObject(ConvertChartData(tres.Main), Game.GlobalJsonSerializerSettings));
|
||||
}
|
||||
using (var writer = new StreamWriter(dir.FullName + "/.umgc")) {
|
||||
tres.Meta.data = "";
|
||||
@@ -219,12 +186,89 @@ namespace Cryville.Crtr.Browsing {
|
||||
Popup.Create(msg);
|
||||
}
|
||||
|
||||
public string[] GetSupportedFormats() {
|
||||
return converters.Keys.ToArray();
|
||||
void LogAndPopupExtra(int level, object extraLog, string format, params object[] args) {
|
||||
var msg = string.Format(format, args);
|
||||
Logger.Log("main", level, "Resource", "{0}\n{1}", msg, extraLog);
|
||||
Popup.Create(msg);
|
||||
}
|
||||
|
||||
public Dictionary<string, string> GetPresetPaths() {
|
||||
return localRes;
|
||||
public string[] GetSupportedFormats() {
|
||||
return ExtensionManager.GetSupportedFormats().ToArray();
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<string, string> GetPresetPaths() {
|
||||
return ExtensionManager.GetLocalResourcePaths();
|
||||
}
|
||||
|
||||
static Chart ConvertChartData(ChartData i) {
|
||||
return new Chart {
|
||||
endtime = ConvertBeatTime(i.endtime),
|
||||
format = i.format,
|
||||
groups = ConvertGroups(i.groups),
|
||||
motions = ConvertMotions(i.motions),
|
||||
ruleset = i.ruleset,
|
||||
sigs = ConvertSignatures(i.sigs),
|
||||
sounds = ConvertSounds(i.sounds),
|
||||
time = ConvertBeatTime(i.time),
|
||||
};
|
||||
}
|
||||
static BeatTime? ConvertBeatTime(Extension.BeatTime? value) {
|
||||
if (value == null) return null;
|
||||
return new BeatTime(value.Value.b, value.Value.n, value.Value.d);
|
||||
}
|
||||
static List<Chart.Group> ConvertGroups(List<ChartData.Group> l) {
|
||||
return l.Select(i => new Chart.Group {
|
||||
endtime = ConvertBeatTime(i.endtime),
|
||||
motions = ConvertMotions(i.motions),
|
||||
notes = ConvertNotes(i.notes),
|
||||
time = ConvertBeatTime(i.time),
|
||||
tracks = ConvertTracks(i.tracks),
|
||||
}).ToList();
|
||||
}
|
||||
static List<Chart.Judge> ConvertJudges(List<ChartData.Judge> l) {
|
||||
return l.Select(i => new Chart.Judge {
|
||||
endtime = ConvertBeatTime(i.endtime),
|
||||
name = i.name,
|
||||
time = ConvertBeatTime(i.time),
|
||||
}).ToList();
|
||||
}
|
||||
static List<Chart.Motion> ConvertMotions(List<ChartData.Motion> l) {
|
||||
return l.Select(i => new Chart.Motion {
|
||||
endtime = ConvertBeatTime(i.endtime),
|
||||
motion = i.motion,
|
||||
sumfix = i.sumfix,
|
||||
time = ConvertBeatTime(i.time),
|
||||
}).ToList();
|
||||
}
|
||||
static List<Chart.Note> ConvertNotes(List<ChartData.Note> l) {
|
||||
return l.Select(i => new Chart.Note {
|
||||
endtime = ConvertBeatTime(i.endtime),
|
||||
judges = ConvertJudges(i.judges),
|
||||
motions = ConvertMotions(i.motions),
|
||||
time = ConvertBeatTime(i.time),
|
||||
}).ToList();
|
||||
}
|
||||
static List<Chart.Signature> ConvertSignatures(List<ChartData.Signature> l) {
|
||||
return l.Select(i => new Chart.Signature {
|
||||
endtime = ConvertBeatTime(i.endtime),
|
||||
tempo = i.tempo,
|
||||
time = ConvertBeatTime(i.time),
|
||||
}).ToList();
|
||||
}
|
||||
static List<Chart.Sound> ConvertSounds(List<ChartData.Sound> l) {
|
||||
return l.Select(i => new Chart.Sound {
|
||||
endtime = ConvertBeatTime(i.endtime),
|
||||
id = i.id,
|
||||
offset = i.offset,
|
||||
time = ConvertBeatTime(i.time),
|
||||
}).ToList();
|
||||
}
|
||||
static List<Chart.Track> ConvertTracks(List<ChartData.Track> l) {
|
||||
return l.Select(i => new Chart.Track {
|
||||
endtime = ConvertBeatTime(i.endtime),
|
||||
motions = ConvertMotions(i.motions),
|
||||
time = ConvertBeatTime(i.time),
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public abstract class LocalResourceFinder {
|
||||
public abstract string Name { get; }
|
||||
public abstract string GetRootPath();
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,11 @@ namespace Cryville.Crtr.Browsing {
|
||||
public override object Value {
|
||||
get {
|
||||
float s_value = GetDisplayValue();
|
||||
return IntegerMode ? (object)(int)s_value : (object)s_value;
|
||||
return IntegerMode ? (int)s_value : (object)s_value;
|
||||
}
|
||||
set {
|
||||
if (value is double) m_value = (double)value;
|
||||
else m_value = IntegerMode ? (double)(int)value : (double)(float)value;
|
||||
else m_value = IntegerMode ? (int)value : (double)(float)value;
|
||||
float s_value = GetDisplayValue();
|
||||
m_text.text = s_value.ToString();
|
||||
if (Range != null && MaxStep == 0) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Unity.UI;
|
||||
using Cryville.Crtr.Config;
|
||||
using Newtonsoft.Json;
|
||||
using Cryville.Crtr.Extension;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -94,24 +94,4 @@ namespace Cryville.Crtr.Browsing {
|
||||
public AsyncDelivery<Texture2D> Cover { get; set; }
|
||||
public ChartMeta Meta { get; set; }
|
||||
}
|
||||
|
||||
#pragma warning disable IDE1006
|
||||
public class MetaInfo {
|
||||
public string name { get; set; }
|
||||
public string author { get; set; }
|
||||
[JsonRequired]
|
||||
public string data { get; set; }
|
||||
}
|
||||
public class SongMetaInfo {
|
||||
public string name { get; set; }
|
||||
public string author { get; set; }
|
||||
}
|
||||
public class ChartMeta : MetaInfo {
|
||||
public SongMetaInfo song { get; set; }
|
||||
public float length { get; set; }
|
||||
public string ruleset { get; set; }
|
||||
public int note_count { get; set; }
|
||||
public string cover { get; set; }
|
||||
}
|
||||
#pragma warning restore IDE1006
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
using Cryville.Common;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public abstract class ResourceConverter {
|
||||
public abstract string[] GetSupportedFormats();
|
||||
public abstract IEnumerable<Resource> ConvertFrom(FileInfo file);
|
||||
}
|
||||
public abstract class Resource {
|
||||
protected Resource(string name) {
|
||||
Name = StringUtils.EscapeFileName(name);
|
||||
}
|
||||
public string Name { get; private set; }
|
||||
public abstract bool Valid { get; }
|
||||
public override string ToString() {
|
||||
return string.Format("{0} ({1})", Name, ReflectionHelper.GetSimpleName(GetType()));
|
||||
}
|
||||
}
|
||||
public class RawChartResource : Resource {
|
||||
public RawChartResource(string name, Chart main, ChartMeta meta) : base(name) {
|
||||
Main = main; Meta = meta;
|
||||
}
|
||||
public Chart Main { get; private set; }
|
||||
public ChartMeta Meta { get; private set; }
|
||||
public override bool Valid { get { return true; } }
|
||||
}
|
||||
public abstract class FileResource : Resource {
|
||||
public FileResource(string name, FileInfo master) : base(name) {
|
||||
Master = master;
|
||||
Attachments = new List<FileInfo>();
|
||||
}
|
||||
public FileInfo Master { get; private set; }
|
||||
public List<FileInfo> Attachments { get; private set; }
|
||||
public override bool Valid {
|
||||
get {
|
||||
if (!Master.Exists) return false;
|
||||
foreach (var file in Attachments) {
|
||||
if (!file.Exists) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class ChartResource : FileResource {
|
||||
public ChartResource(string name, FileInfo master) : base(name, master) {
|
||||
using (var reader = new StreamReader(master.FullName)) {
|
||||
var meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
||||
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".json")));
|
||||
if (meta.cover != null) Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.cover)));
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SongResource : FileResource {
|
||||
public SongResource(string name, FileInfo master) : base(name, master) { }
|
||||
}
|
||||
public class RulesetResource : FileResource {
|
||||
public RulesetResource(string name, FileInfo master) : base(name, master) {
|
||||
using (var reader = new StreamReader(master.FullName)) {
|
||||
var meta = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd());
|
||||
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".pdt")));
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SkinResource : FileResource {
|
||||
public string RulesetName { get; private set; }
|
||||
public SkinResource(string name, FileInfo master) : base(name, master) {
|
||||
using (var reader = new StreamReader(master.FullName)) {
|
||||
var meta = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd());
|
||||
RulesetName = meta.ruleset;
|
||||
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".pdt")));
|
||||
foreach (var frame in meta.frames) {
|
||||
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, frame)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2546fb1d514348842a14a03531be192d
|
||||
timeCreated: 1637982768
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,20 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public class SkinResourceImporter : ResourceConverter {
|
||||
static readonly string[] SUPPORTED_FORMATS = { ".umgs" };
|
||||
public override string[] GetSupportedFormats() {
|
||||
return SUPPORTED_FORMATS;
|
||||
}
|
||||
|
||||
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||
var data = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd());
|
||||
return new Resource[] { new SkinResource(data.name, file) };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace Cryville.Crtr {
|
||||
#region Fields
|
||||
Chart chart;
|
||||
Skin skin;
|
||||
PdtSkin pskin;
|
||||
public static PdtSkin pskin;
|
||||
Ruleset ruleset;
|
||||
PdtRuleset pruleset;
|
||||
Dictionary<string, Texture2D> texs;
|
||||
@@ -485,7 +485,6 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
Game.AudioSequencer.Playing = true;
|
||||
atime0 = Game.AudioClient.BufferPosition;
|
||||
Thread.Sleep((int)((atime0 - Game.AudioClient.Position) * 1000));
|
||||
inputProxy.SyncTime(cbus.Time);
|
||||
started = true;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Components {
|
||||
[DisallowMultipleComponent]
|
||||
public abstract class MeshBase : SkinComponent {
|
||||
public MeshBase() {
|
||||
SubmitProperty("color", new PropOp.Color(v => Color = v));
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Cryville.Crtr.Components {
|
||||
public op_set_shape(PolygonSGO self) : base(1) {
|
||||
_self = self;
|
||||
}
|
||||
protected unsafe override void Execute() {
|
||||
protected override unsafe void Execute() {
|
||||
var o = GetOperand(0);
|
||||
if (o.Type != PdtInternalType.Vector) throw new ArgumentException("Not a vector");
|
||||
_self._shapeLength = (o.Length - sizeof(int)) / sizeof(Vector2);
|
||||
|
||||
@@ -1,5 +1,89 @@
|
||||
namespace Cryville.Crtr.Components {
|
||||
using Cryville.Common;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logger;
|
||||
|
||||
namespace Cryville.Crtr.Components {
|
||||
public class SkinAnimation : SkinComponent {
|
||||
public SkinAnimation() {
|
||||
SubmitProperty("name", new PropOp.Identifier(v => Name = v));
|
||||
SubmitProperty("duration", new PropOp.Float(v => Duration = v));
|
||||
SubmitProperty("iteration", new PropOp.Float(v => Iteration = v));
|
||||
SubmitProperty("direction", new PropOp.Enum<AnimationDirection>(v => Direction = v, v => (AnimationDirection)v));
|
||||
SubmitProperty("delay", new PropOp.Float(v => Delay = v));
|
||||
Iteration = 1;
|
||||
}
|
||||
|
||||
SkinContext _skinContext;
|
||||
Transform _writeTransform;
|
||||
|
||||
AnimationSpan _anim;
|
||||
int _name;
|
||||
public int Name {
|
||||
set {
|
||||
if (_name == value) return;
|
||||
_name = value;
|
||||
if (value == 0) {
|
||||
_anim = null;
|
||||
}
|
||||
else {
|
||||
var id = new Identifier(value);
|
||||
AnimationSpan anim;
|
||||
if (!ChartPlayer.pskin.animations.TryGetValue(id, out anim)) {
|
||||
Logger.Log("main", 4, "Skin", "Animation {0} not found", id.Name);
|
||||
_anim = null;
|
||||
return;
|
||||
}
|
||||
_anim = anim;
|
||||
}
|
||||
}
|
||||
}
|
||||
public float Duration { get; private set; }
|
||||
public float Iteration { get; private set; }
|
||||
public AnimationDirection Direction { get; private set; }
|
||||
public float Delay { get; private set; }
|
||||
|
||||
double _startTime;
|
||||
|
||||
public override void Init() {
|
||||
_skinContext = new SkinContext(transform);
|
||||
}
|
||||
public override void Rewind(double time, Transform target) {
|
||||
_startTime = time;
|
||||
if (target == null) target = transform;
|
||||
_writeTransform = target;
|
||||
}
|
||||
public override void Tick(SkinContainer c, double time) {
|
||||
float _rtime = (float)(time - _startTime - Delay) / Duration;
|
||||
if (_rtime < 0) _rtime = 0;
|
||||
else if (_rtime > Iteration) {
|
||||
if (Direction.HasFlag(AnimationDirection.alternate)) {
|
||||
_rtime = Iteration % 2;
|
||||
if (_rtime > 1) _rtime = 2 - _rtime;
|
||||
}
|
||||
else {
|
||||
_rtime = Iteration % 1;
|
||||
if (_rtime == 0) _rtime = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (Direction.HasFlag(AnimationDirection.alternate)) {
|
||||
_rtime %= 2;
|
||||
if (_rtime > 1) _rtime = 2 - _rtime;
|
||||
}
|
||||
else {
|
||||
_rtime %= 1;
|
||||
}
|
||||
}
|
||||
if (Direction.HasFlag(AnimationDirection.reverse)) _rtime = 1 - _rtime;
|
||||
if (_anim != null) c.MatchAnimation(_anim, _rtime, new RuntimeSkinContext(_skinContext, _writeTransform));
|
||||
}
|
||||
protected override void OnDestroy() { }
|
||||
}
|
||||
[Flags]
|
||||
public enum AnimationDirection {
|
||||
normal = 0,
|
||||
reverse = 1,
|
||||
alternate = 2,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace Cryville.Crtr.Components {
|
||||
}
|
||||
|
||||
public virtual void Init() { }
|
||||
public virtual void Rewind(double time, Transform target) { }
|
||||
public virtual void Tick(SkinContainer c, double time) { }
|
||||
protected abstract void OnDestroy();
|
||||
}
|
||||
public struct SkinProperty {
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace Cryville.Crtr.Components {
|
||||
SubmitProperty("border", new PropOp.Vector2(v => Border = v));
|
||||
}
|
||||
|
||||
readonly static Dictionary<float, int> uvrefl
|
||||
static readonly Dictionary<float, int> uvrefl
|
||||
= new Dictionary<float, int>() {
|
||||
{-0.5f, 0}, {-0.4f, 1}, {0.4f, 2}, {0.5f, 3},
|
||||
};
|
||||
static Vector2[] _origuv;
|
||||
protected new static Vector2[] OriginalUV {
|
||||
protected static new Vector2[] OriginalUV {
|
||||
get {
|
||||
if (_origuv == null) {
|
||||
var m = GenericResources.Meshes["quad_scale3h"];
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Cryville.Crtr.Components {
|
||||
public op_set_frames(SpriteText self) : base(2) {
|
||||
_self = self;
|
||||
}
|
||||
protected unsafe override void Execute() {
|
||||
protected override unsafe void Execute() {
|
||||
var keys = GetOperand(0).AsString();
|
||||
var values = GetOperand(1);
|
||||
int arrtype; int len;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Cryville.Common.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class EffectGroup {
|
||||
@@ -35,28 +36,37 @@ namespace Cryville.Crtr {
|
||||
while (_endQueue.Count > 0) {
|
||||
var item = _endQueue[0];
|
||||
if (item.EndTime > _time) break;
|
||||
item.OnDone();
|
||||
_instances.Remove(item.Index);
|
||||
_pool.Return(item);
|
||||
_endQueue.RemoveAt(0);
|
||||
if (item.OnStateDone()) {
|
||||
QueueInstance(item);
|
||||
}
|
||||
else {
|
||||
item.Tick(time);
|
||||
_instances.Remove(item.Index);
|
||||
_pool.Return(item);
|
||||
}
|
||||
}
|
||||
foreach (var instance in _instances) {
|
||||
instance.Value.Tick();
|
||||
instance.Value.Tick(time);
|
||||
}
|
||||
}
|
||||
public void Emit(float index) {
|
||||
public void Emit(float index, Transform target = null) {
|
||||
EffectInstance instance;
|
||||
if (_instances.TryGetValue(index, out instance)) {
|
||||
var i = _endQueue.BinarySearch(instance);
|
||||
_endQueue.RemoveAt(i);
|
||||
}
|
||||
else {
|
||||
_instances.Add(index, instance = _pool.Rent());
|
||||
}
|
||||
bool flag = _instances.TryGetValue(index, out instance);
|
||||
if (!flag) _instances.Add(index, instance = _pool.Rent());
|
||||
instance.Index = index;
|
||||
instance.OnEmit(_time);
|
||||
var i2 = ~_endQueue.BinarySearch(instance);
|
||||
_endQueue.Insert(i2, instance);
|
||||
if (instance.CanEmit()) {
|
||||
if (flag) {
|
||||
var i = _endQueue.BinarySearch(instance);
|
||||
_endQueue.RemoveAt(i);
|
||||
}
|
||||
instance.OnEmit(_time, target);
|
||||
QueueInstance(instance);
|
||||
}
|
||||
}
|
||||
void QueueInstance(EffectInstance i) {
|
||||
var index = ~_endQueue.BinarySearch(i);
|
||||
_endQueue.Insert(index, i);
|
||||
}
|
||||
public void Dispose() {
|
||||
_pool.DisposeAll();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Crtr.Components;
|
||||
using Cryville.Crtr.Event;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -10,19 +11,24 @@ namespace Cryville.Crtr {
|
||||
readonly EffectDefinition _def;
|
||||
readonly SkinContainer _skinContainer;
|
||||
public Transform RootTransform { get; private set; }
|
||||
readonly SkinComponent[] _comps;
|
||||
public EffectInstance(EffectDefinition def) {
|
||||
_def = def;
|
||||
_skinContainer = new SkinContainer(_def.elements);
|
||||
_skinContainer = new SkinContainer(this, _def.elements);
|
||||
RootTransform = new GameObject("effect:" + GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
|
||||
SkinContext = new SkinContext(RootTransform);
|
||||
ChartPlayer.etor.ContextCascadeInsertBlock();
|
||||
_skinContainer.MatchStatic(this);
|
||||
_skinContainer.MatchStatic();
|
||||
ChartPlayer.etor.ContextCascadeDiscardBlock();
|
||||
foreach (var i in RootTransform.GetComponentsInChildren<SkinComponent>())
|
||||
i.Init();
|
||||
_comps = RootTransform.GetComponentsInChildren<SkinComponent>();
|
||||
foreach (var i in _comps) i.Init();
|
||||
_indexSrc = new PropSrc.Float(() => Index);
|
||||
_durationOp = new PropOp.Float(v => _duration = v);
|
||||
}
|
||||
public void Rewind(double time, Transform target) {
|
||||
_startTime = time;
|
||||
foreach (var i in _comps) i.Rewind(time, target);
|
||||
}
|
||||
private float m_index;
|
||||
public float Index {
|
||||
get { return m_index; }
|
||||
@@ -32,26 +38,62 @@ namespace Cryville.Crtr {
|
||||
_indexSrc.Invalidate();
|
||||
}
|
||||
}
|
||||
Transform _currentTarget;
|
||||
Identifier _currentStateName = Identifier.Empty;
|
||||
EffectState _currentState;
|
||||
ChartEvent _ctxev;
|
||||
ContainerState _ctxstate;
|
||||
internal static readonly int _VAR_EFFECT_INDEX = IdentifierManager.SharedInstance.Request("effect_index");
|
||||
readonly PropSrc _indexSrc;
|
||||
double _startTime;
|
||||
float _duration;
|
||||
readonly PropOp _durationOp;
|
||||
public double EndTime { get { return _startTime + _duration; } }
|
||||
public void Tick() {
|
||||
_skinContainer.MatchDynamic(this, 1);
|
||||
public void Tick(double time) {
|
||||
foreach (var i in _comps) i.Tick(_skinContainer, time);
|
||||
}
|
||||
public void OnEmit(double time) {
|
||||
_startTime = time;
|
||||
public bool CanEmit() {
|
||||
return _currentStateName.Key == 0 || _currentState.rewind.Key != 0;
|
||||
}
|
||||
public void OnEmit(double time, Transform target) {
|
||||
_currentTarget = target;
|
||||
_ctxev = ChartPlayer.etor.ContextEvent;
|
||||
_ctxstate = ChartPlayer.etor.ContextState;
|
||||
if (_currentStateName.Key == 0) {
|
||||
EnterState(_def.init, time, _currentTarget, true);
|
||||
}
|
||||
else {
|
||||
if (_currentState.rewind.Key == 0) throw new InvalidOperationException("Cannot rewind");
|
||||
EnterState(_currentState.rewind, time, _currentTarget, true);
|
||||
}
|
||||
}
|
||||
void EnterState(Identifier name, double time, Transform target, bool emitting) {
|
||||
_currentStateName = name;
|
||||
_currentState = _def.states[name];
|
||||
Rewind(time, target);
|
||||
RootTransform.gameObject.SetActive(true);
|
||||
ChartPlayer.etor.ContextCascadeInsert();
|
||||
ChartPlayer.etor.ContextCascadeUpdate(_VAR_EFFECT_INDEX, _indexSrc);
|
||||
ChartPlayer.etor.Evaluate(_durationOp, _def.duration);
|
||||
_skinContainer.MatchDynamic(this, 0);
|
||||
ChartPlayer.etor.Evaluate(_durationOp, _currentState.duration);
|
||||
if (emitting) _skinContainer.MatchDynamic(0, true);
|
||||
_skinContainer.MatchDynamic(1, emitting);
|
||||
ChartPlayer.etor.ContextCascadeDiscard();
|
||||
}
|
||||
public void OnDone() {
|
||||
RootTransform.gameObject.SetActive(false);
|
||||
public bool OnStateDone() {
|
||||
if (_currentState.next.Key == 0) {
|
||||
RootTransform.gameObject.SetActive(false);
|
||||
_currentStateName = Identifier.Empty;
|
||||
_currentState = null;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
ChartPlayer.etor.ContextEvent = _ctxev;
|
||||
ChartPlayer.etor.ContextState = _ctxstate;
|
||||
EnterState(_currentState.next, EndTime, _currentTarget, false);
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
ChartPlayer.etor.ContextState = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public void Dispose() {
|
||||
GameObject.Destroy(RootTransform.gameObject);
|
||||
@@ -59,7 +101,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
public string TypeName { get { throw new InvalidOperationException("Type name undefined"); } }
|
||||
public SkinContext SkinContext { get; private set; }
|
||||
public Anchor OpenedAnchor { get { throw new InvalidOperationException("Anchor not supported"); } }
|
||||
public int OpenedAnchorName { get { return _currentStateName.Key; } }
|
||||
public void PushAnchorEvent(double time, int name) {
|
||||
throw new InvalidOperationException("Anchor not supported");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class EffectManager {
|
||||
@@ -15,6 +16,9 @@ namespace Cryville.Crtr {
|
||||
public void Emit(int id, float index) {
|
||||
_groups[id].Emit(index);
|
||||
}
|
||||
public void EmitSelf(int id, float index, Transform target) {
|
||||
_groups[id].Emit(index, target);
|
||||
}
|
||||
public void Dispose() {
|
||||
foreach (var g in _groups) g.Value.Dispose();
|
||||
}
|
||||
|
||||
@@ -37,10 +37,9 @@ namespace Cryville.Crtr.Event {
|
||||
/// </summary>
|
||||
public ContainerState ts;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="GameObject"/> group, the <see cref="Transform"/> containing all the generated elements in the <see cref="ContainerHandler"/>.
|
||||
/// </summary>
|
||||
protected Transform gogroup;
|
||||
protected Transform RootTransform;
|
||||
|
||||
SkinComponent[] _comps;
|
||||
|
||||
public Vector3 Position { get; protected set; }
|
||||
public Quaternion Rotation { get; protected set; }
|
||||
@@ -70,7 +69,7 @@ namespace Cryville.Crtr.Event {
|
||||
SkinContainer skinContainer;
|
||||
protected Judge judge;
|
||||
public void AttachSystems(PdtSkin skin, Judge judge) {
|
||||
skinContainer = new SkinContainer(skin.elements);
|
||||
skinContainer = new SkinContainer(this, skin.elements);
|
||||
this.judge = judge;
|
||||
}
|
||||
|
||||
@@ -80,15 +79,15 @@ namespace Cryville.Crtr.Event {
|
||||
Anchor a_cur;
|
||||
Anchor a_head;
|
||||
Anchor a_tail;
|
||||
readonly static int _a_cur = IdentifierManager.SharedInstance.Request("cur");
|
||||
readonly static int _a_head = IdentifierManager.SharedInstance.Request("head");
|
||||
readonly static int _a_tail = IdentifierManager.SharedInstance.Request("tail");
|
||||
static readonly int _a_cur = IdentifierManager.SharedInstance.Request("cur");
|
||||
static readonly int _a_head = IdentifierManager.SharedInstance.Request("head");
|
||||
static readonly int _a_tail = IdentifierManager.SharedInstance.Request("tail");
|
||||
double atime_head;
|
||||
double atime_tail;
|
||||
public Anchor RegisterAnchor(int name, bool dyn = false, int propSrcCount = 0) {
|
||||
var strname = IdentifierManager.SharedInstance.Retrieve(name);
|
||||
var go = new GameObject("." + strname).transform;
|
||||
go.SetParent(gogroup, false);
|
||||
go.SetParent(RootTransform, false);
|
||||
var result = new Anchor(name, go, propSrcCount);
|
||||
if (dyn) {
|
||||
if (DynamicAnchors.ContainsKey(name))
|
||||
@@ -103,22 +102,22 @@ namespace Cryville.Crtr.Event {
|
||||
return result;
|
||||
}
|
||||
protected void OpenAnchor(Anchor anchor) {
|
||||
if (OpenedAnchor != null) throw new InvalidOperationException("An anchor has been opened");
|
||||
if (_openedAnchor != null) throw new InvalidOperationException("An anchor has been opened");
|
||||
anchor.Transform.gameObject.SetActive(true);
|
||||
OpenedAnchor = anchor;
|
||||
_openedAnchor = anchor;
|
||||
}
|
||||
protected void CloseAnchor() {
|
||||
OpenedAnchor = null;
|
||||
_openedAnchor = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Logic
|
||||
#region Init methods: Called on prehandle
|
||||
public virtual void PreInit() {
|
||||
gogroup = new GameObject(TypeName + ":" + Container.GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
|
||||
SkinContext = new SkinContext(gogroup);
|
||||
RootTransform = new GameObject(TypeName + ":" + Container.GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
|
||||
SkinContext = new SkinContext(RootTransform);
|
||||
if (cs.Parent != null)
|
||||
gogroup.SetParent(cs.Parent.Handler.gogroup, false);
|
||||
RootTransform.SetParent(cs.Parent.Handler.RootTransform, false);
|
||||
a_cur = RegisterAnchor(_a_cur);
|
||||
a_head = RegisterAnchor(_a_head, true);
|
||||
a_tail = RegisterAnchor(_a_tail, true);
|
||||
@@ -126,16 +125,16 @@ namespace Cryville.Crtr.Event {
|
||||
public virtual void Init() {
|
||||
ChartPlayer.etor.ContextState = ps;
|
||||
ChartPlayer.etor.ContextEvent = Container;
|
||||
skinContainer.MatchStatic(this);
|
||||
skinContainer.MatchStatic();
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
ChartPlayer.etor.ContextState = null;
|
||||
foreach (var i in gogroup.GetComponentsInChildren<SkinComponent>())
|
||||
i.Init();
|
||||
_comps = RootTransform.GetComponentsInChildren<SkinComponent>();
|
||||
foreach (var i in _comps) i.Init();
|
||||
}
|
||||
public virtual void PostInit() {
|
||||
PropSrcs.Add(_var_current_time, new PropSrc.Float(() => (float)cs.rootPrototype.Time));
|
||||
PropSrcs.Add(_var_invisible_bounds, new PropSrc.Boolean(() => atime_head > atime_tail));
|
||||
gogroup.gameObject.SetActive(false);
|
||||
RootTransform.gameObject.SetActive(false);
|
||||
}
|
||||
#endregion
|
||||
#region Start methods
|
||||
@@ -146,14 +145,14 @@ namespace Cryville.Crtr.Event {
|
||||
public virtual void StartLogicalUpdate(ContainerState s) { }
|
||||
protected virtual void StartPreGraphicalUpdate(ContainerState s) { }
|
||||
protected virtual void StartGraphicalUpdate(ContainerState s) {
|
||||
if (gogroup) gogroup.gameObject.SetActive(true);
|
||||
if (RootTransform) RootTransform.gameObject.SetActive(true);
|
||||
}
|
||||
#endregion
|
||||
public virtual void Update(ContainerState s, StampedEvent ev) {
|
||||
if (s.CloneType == 3) SetPreGraphicalActive(true, s);
|
||||
else if (ev is StampedEvent.Anchor) {
|
||||
var tev = (StampedEvent.Anchor)ev;
|
||||
if (gogroup) {
|
||||
if (RootTransform) {
|
||||
OpenAnchor(tev.Target);
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
tev.Target.Transform.SetPositionAndRotation(Position, Rotation);
|
||||
@@ -172,7 +171,7 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
anchorEvPool.Return(tev);
|
||||
}
|
||||
else if (gogroup && s.CloneType == 2) MatchDynamic(s, 1);
|
||||
else if (RootTransform && s.CloneType == 2) MatchDynamic(s, 1);
|
||||
}
|
||||
#region End methods
|
||||
protected virtual void EndGraphicalUpdate(ContainerState s) { }
|
||||
@@ -180,8 +179,8 @@ namespace Cryville.Crtr.Event {
|
||||
public virtual void EndLogicalUpdate(ContainerState s) { }
|
||||
public virtual void EndPhysicalUpdate(ContainerState s) { }
|
||||
public virtual void Dispose() {
|
||||
if (gogroup)
|
||||
GameObject.Destroy(gogroup.gameObject);
|
||||
if (RootTransform)
|
||||
GameObject.Destroy(RootTransform.gameObject);
|
||||
Alive = false;
|
||||
}
|
||||
public virtual void DisposeAll() { }
|
||||
@@ -193,7 +192,7 @@ namespace Cryville.Crtr.Event {
|
||||
void MatchDynamic(ContainerState s, int dl) {
|
||||
ChartPlayer.etor.ContextState = s;
|
||||
ChartPlayer.etor.ContextEvent = Container;
|
||||
skinContainer.MatchDynamic(this, dl);
|
||||
skinContainer.MatchDynamic(dl);
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
ChartPlayer.etor.ContextState = null;
|
||||
}
|
||||
@@ -205,6 +204,7 @@ namespace Cryville.Crtr.Event {
|
||||
atime_head = cs.StampedContainer.Time;
|
||||
atime_tail = atime_head + cs.StampedContainer.Duration;
|
||||
MatchDynamic(cs, 0);
|
||||
foreach (var i in _comps) i.Tick(skinContainer, cs.Time);
|
||||
if (cs.Active) PushAnchorEvent(cs.Time, a_cur);
|
||||
if (double.IsNaN(DynamicAnchorSetTime[_a_head])) DynamicAnchorSetTime[_a_head] = atime_head;
|
||||
if (double.IsNaN(DynamicAnchorSetTime[_a_tail])) DynamicAnchorSetTime[_a_tail] = atime_tail;
|
||||
@@ -241,7 +241,8 @@ namespace Cryville.Crtr.Event {
|
||||
#region ISkinnableGroup
|
||||
public abstract string TypeName { get; }
|
||||
public SkinContext SkinContext { get; private set; }
|
||||
public Anchor OpenedAnchor { get; private set; }
|
||||
Anchor _openedAnchor;
|
||||
public int OpenedAnchorName { get { return _openedAnchor == null ? 0 : _openedAnchor.Name; } }
|
||||
public bool TryGetAnchorsByName(int name, out IReadOnlyCollection<Anchor> result) {
|
||||
List<Anchor> anchors;
|
||||
var ret = Anchors.TryGetValue(name, out anchors);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbc046e7cabacbb4fbf74520399a7340
|
||||
guid: b35ffffce02252548a66e18cf98050e2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user