Compare commits
44 Commits
Author | SHA1 | Date | |
---|---|---|---|
9f73c8ffad | |||
c1c354959d | |||
94428d9e18 | |||
5198ecec1f | |||
6779b88055 | |||
c5dab3a232 | |||
a7608bcd7e | |||
be64bc76b5 | |||
39bc34fd42 | |||
4185303bd2 | |||
3280693e8f | |||
29432feabc | |||
86559c681e | |||
79f11b9c33 | |||
5b9149cb34 | |||
9d6bdd968f | |||
bc4fec33ef | |||
09e917dbe8 | |||
1003a0e199 | |||
e3a805b855 | |||
4222176979 | |||
43c87fba70 | |||
d0a23aaf30 | |||
a09a5686d7 | |||
609bb317d0 | |||
898fb7d557 | |||
c39f258a19 | |||
4fdd4e1935 | |||
7662011d60 | |||
c24372b308 | |||
5e4c53113a | |||
4f93995bbd | |||
5b14466059 | |||
1d3aa85446 | |||
6efe70d751 | |||
555c88855c | |||
105aacc133 | |||
ea9000f2b0 | |||
4e851d9b73 | |||
0a1e512f41 | |||
a7baef2c9d | |||
723ec937ad | |||
7c77ba83f8 | |||
6da4b96b24 |
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace Cryville.Common.Pdt {
|
namespace Cryville.Common.Pdt {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -104,7 +105,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
else if (i is PdtInstruction.PushVariable) {
|
else if (i is PdtInstruction.PushVariable) {
|
||||||
i.Execute(this);
|
i.Execute(this);
|
||||||
var frame = _stack[_framecount - 1];
|
var frame = _stack[_framecount - 1];
|
||||||
if (frame.Type != PdtInternalType.Undefined) {
|
if (frame.Type != PdtInternalType.Undefined && frame.Type != PdtInternalType.Error) {
|
||||||
_rip = il.AddAfter(_rip, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length));
|
_rip = il.AddAfter(_rip, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length));
|
||||||
il.Remove(_rip.Previous);
|
il.Remove(_rip.Previous);
|
||||||
}
|
}
|
||||||
@@ -147,10 +148,10 @@ namespace Cryville.Common.Pdt {
|
|||||||
_goffset += value.Length;
|
_goffset += value.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal unsafe void PushVariable(int name) {
|
internal unsafe void PushVariable(int name, bool forced) {
|
||||||
fixed (StackFrame* frame = &_stack[_framecount++]) {
|
fixed (StackFrame* frame = &_stack[_framecount++]) {
|
||||||
byte[] value;
|
byte[] value;
|
||||||
GetVariable(name, out frame->Type, out value);
|
GetVariable(name, forced, out frame->Type, out value);
|
||||||
frame->Offset = _goffset;
|
frame->Offset = _goffset;
|
||||||
frame->Length = value.Length;
|
frame->Length = value.Length;
|
||||||
Array.Copy(value, 0, _mem, _goffset, value.Length);
|
Array.Copy(value, 0, _mem, _goffset, value.Length);
|
||||||
@@ -161,16 +162,17 @@ namespace Cryville.Common.Pdt {
|
|||||||
/// Gets a variable of the specified name.
|
/// Gets a variable of the specified name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of the variable.</param>
|
/// <param name="name">The name of the variable.</param>
|
||||||
|
/// <param name="forced">Whether to produce an error stack instead of an identifier stack if the variable is not found.</param>
|
||||||
/// <param name="type">The type of the variable.</param>
|
/// <param name="type">The type of the variable.</param>
|
||||||
/// <param name="value">The value of the variable.</param>
|
/// <param name="value">The value of the variable.</param>
|
||||||
protected abstract void GetVariable(int name, out int type, out byte[] value);
|
protected abstract void GetVariable(int name, bool forced, out int type, out byte[] value);
|
||||||
internal void Operate(PdtOperatorSignature sig) {
|
internal void Operate(PdtOperatorSignature sig) {
|
||||||
PdtOperator op;
|
PdtOperator op;
|
||||||
try { op = GetOperator(sig); }
|
try { op = GetOperator(sig); }
|
||||||
catch (Exception) {
|
catch (Exception ex) {
|
||||||
for (int i = 0; i < sig.ParamCount; i++)
|
for (int i = 0; i < sig.ParamCount; i++)
|
||||||
DiscardStack();
|
DiscardStack();
|
||||||
throw;
|
throw new EvaluationFailureException(string.Format("Failed to get operator {0}", sig), ex);
|
||||||
}
|
}
|
||||||
Operate(op, sig.ParamCount);
|
Operate(op, sig.ParamCount);
|
||||||
}
|
}
|
||||||
@@ -222,4 +224,18 @@ namespace Cryville.Common.Pdt {
|
|||||||
_goffset -= _stack[--_framecount].Length;
|
_goffset -= _stack[--_framecount].Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The exception that is thrown when the evalution of a <see cref="PdtExpression" /> fails.
|
||||||
|
/// </summary>
|
||||||
|
public class EvaluationFailureException : Exception {
|
||||||
|
/// <inheritdoc />
|
||||||
|
public EvaluationFailureException() : base("Evaluation failed") { }
|
||||||
|
/// <inheritdoc />
|
||||||
|
public EvaluationFailureException(string message) : base(message) { }
|
||||||
|
/// <inheritdoc />
|
||||||
|
public EvaluationFailureException(string message, Exception innerException) : base(message, innerException) { }
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected EvaluationFailureException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,13 +51,14 @@ namespace Cryville.Common.Pdt {
|
|||||||
}
|
}
|
||||||
public class PushVariable : PdtInstruction {
|
public class PushVariable : PdtInstruction {
|
||||||
public int Name { get; private set; }
|
public int Name { get; private set; }
|
||||||
public PushVariable(int name) { Name = name; }
|
public bool Forced { get; private set; }
|
||||||
public PushVariable(string name) : this(IdentifierManager.SharedInstance.Request(name)) { }
|
public PushVariable(int name, bool forced = false) { Name = name; Forced = forced; }
|
||||||
|
public PushVariable(string name, bool forced = false) : this(IdentifierManager.SharedInstance.Request(name)) { Forced = forced; }
|
||||||
internal override void Execute(PdtEvaluatorBase etor) {
|
internal override void Execute(PdtEvaluatorBase etor) {
|
||||||
etor.PushVariable(Name);
|
etor.PushVariable(Name, Forced);
|
||||||
}
|
}
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return string.Format("pushv {0}", IdentifierManager.SharedInstance.Retrieve(Name));
|
return string.Format(Forced ? "pushv ?{0}" : "pushv {0}", IdentifierManager.SharedInstance.Retrieve(Name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Operate : PdtInstruction {
|
public class Operate : PdtInstruction {
|
||||||
@@ -239,7 +240,11 @@ namespace Cryville.Common.Pdt {
|
|||||||
if (defs.TryGetValue(buf.Value.Value, out def)) {
|
if (defs.TryGetValue(buf.Value.Value, out def)) {
|
||||||
foreach (var i in def.Instructions) ins.AddLast(i);
|
foreach (var i in def.Instructions) ins.AddLast(i);
|
||||||
}
|
}
|
||||||
else ins.AddLast(new PdtInstruction.PushVariable(buf.Value.Value));
|
else {
|
||||||
|
var name = buf.Value.Value;
|
||||||
|
if (name[0] == '?') ins.AddLast(new PdtInstruction.PushVariable(name.Substring(1), true));
|
||||||
|
else ins.AddLast(new PdtInstruction.PushVariable(name));
|
||||||
|
}
|
||||||
buf = null;
|
buf = null;
|
||||||
TryPushAdjMul(ins, ref flag);
|
TryPushAdjMul(ins, ref flag);
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
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,
|
||||||
0x0001, 0x0080, 0x0100, 0x0000, 0x0030, 0x0080, 0x0080, 0x0000, 0x0200, 0x0400, 0x0080, 0x0080, 0x0080, 0x0080, 0x0040, 0x0080,
|
0x0001, 0x0080, 0x0100, 0x0000, 0x0030, 0x0080, 0x0080, 0x0000, 0x0200, 0x0400, 0x0080, 0x0080, 0x0080, 0x0080, 0x0040, 0x0080,
|
||||||
0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x1000, 0x1800, 0x0080, 0x0080, 0x0080, 0x0000,
|
0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x1000, 0x1800, 0x0080, 0x0080, 0x0080, 0x0030,
|
||||||
0x0080, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030,
|
0x0080, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030,
|
||||||
0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0030,
|
0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0030,
|
||||||
0x0000, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030,
|
0x0000, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030,
|
||||||
|
@@ -48,9 +48,9 @@ namespace Cryville.Common.Pdt {
|
|||||||
_rfreq = false;
|
_rfreq = false;
|
||||||
try { Execute(); } catch (Exception ex) {
|
try { Execute(); } catch (Exception ex) {
|
||||||
if (_rfreq) _etor.DiscardStack();
|
if (_rfreq) _etor.DiscardStack();
|
||||||
throw new InvalidOperationException("Evaluation failed", ex);
|
throw new EvaluationFailureException("Evaluation failed", ex);
|
||||||
}
|
}
|
||||||
if (!_rfreq && !noset) throw new InvalidOperationException("Return frame not set");
|
if (!_rfreq && !noset) throw new EvaluationFailureException("Return frame not set");
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes the operator.
|
/// Executes the operator.
|
||||||
|
@@ -4,7 +4,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Span on the memory of a <see cref="PdtEvaluatorBase" />.
|
/// Span on the memory of a <see cref="PdtEvaluatorBase" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public unsafe struct PdtVariableMemory {
|
public unsafe struct PdtVariableMemory : IEquatable<PdtVariableMemory> {
|
||||||
readonly byte* _ptr;
|
readonly byte* _ptr;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The length of the span.
|
/// The length of the span.
|
||||||
@@ -46,6 +46,14 @@ namespace Cryville.Common.Pdt {
|
|||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++)
|
||||||
dest[destOffset + i] = _ptr[i];
|
dest[destOffset + i] = _ptr[i];
|
||||||
}
|
}
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool Equals(PdtVariableMemory obj) {
|
||||||
|
if (Type != obj.Type || Length != obj.Length) return false;
|
||||||
|
for (int i = 0; i < Length; i++) {
|
||||||
|
if (*(_ptr + i) != *(obj._ptr + i)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the memory of the span as a number.
|
/// Gets the memory of the span as a number.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -145,7 +145,7 @@ namespace Cryville.Common {
|
|||||||
/// <returns>An array containing all the subclasses of the type in the current app domain.</returns>
|
/// <returns>An array containing all the subclasses of the type in the current app domain.</returns>
|
||||||
public static Type[] GetSubclassesOf<T>() where T : class {
|
public static Type[] GetSubclassesOf<T>() where T : class {
|
||||||
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||||
IEnumerable<Type> r = new List<Type>();
|
IEnumerable<Type> r = Enumerable.Empty<Type>();
|
||||||
foreach (var a in assemblies)
|
foreach (var a in assemblies)
|
||||||
r = r.Concat(a.GetTypes().Where(
|
r = r.Concat(a.GetTypes().Where(
|
||||||
t => t.IsClass
|
t => t.IsClass
|
||||||
|
@@ -4,7 +4,19 @@ using UnityEngine;
|
|||||||
namespace Cryville.Common.Unity.Input {
|
namespace Cryville.Common.Unity.Input {
|
||||||
public delegate void InputEventDelegate(InputIdentifier id, InputVector vec);
|
public delegate void InputEventDelegate(InputIdentifier id, InputVector vec);
|
||||||
public abstract class InputHandler : IDisposable {
|
public abstract class InputHandler : IDisposable {
|
||||||
public event InputEventDelegate OnInput;
|
InputEventDelegate m_onInput;
|
||||||
|
public event InputEventDelegate OnInput {
|
||||||
|
add {
|
||||||
|
if (m_onInput == null) Activate();
|
||||||
|
m_onInput -= value;
|
||||||
|
m_onInput += value;
|
||||||
|
}
|
||||||
|
remove {
|
||||||
|
if (m_onInput == null) return;
|
||||||
|
m_onInput -= value;
|
||||||
|
if (m_onInput == null) Deactivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
~InputHandler() {
|
~InputHandler() {
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
@@ -14,26 +26,15 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Activated { get; private set; }
|
protected abstract void Activate();
|
||||||
public void Activate() {
|
protected abstract void Deactivate();
|
||||||
if (Activated) return;
|
|
||||||
Activated = true;
|
|
||||||
ActivateImpl();
|
|
||||||
}
|
|
||||||
protected abstract void ActivateImpl();
|
|
||||||
public void Deactivate() {
|
|
||||||
if (!Activated) return;
|
|
||||||
Activated = false;
|
|
||||||
DeactivateImpl();
|
|
||||||
}
|
|
||||||
protected abstract void DeactivateImpl();
|
|
||||||
public abstract void Dispose(bool disposing);
|
public abstract void Dispose(bool disposing);
|
||||||
public abstract bool IsNullable(int type);
|
public abstract bool IsNullable(int type);
|
||||||
public abstract byte GetDimension(int type);
|
public abstract byte GetDimension(int type);
|
||||||
public abstract string GetTypeName(int type);
|
public abstract string GetTypeName(int type);
|
||||||
public abstract double GetCurrentTimestamp();
|
public abstract double GetCurrentTimestamp();
|
||||||
protected void Feed(int type, int id, InputVector vec) {
|
protected void Feed(int type, int id, InputVector vec) {
|
||||||
var del = OnInput;
|
var del = m_onInput;
|
||||||
if (del != null) del(new InputIdentifier { Source = new InputSource { Handler = this, Type = type }, Id = id }, vec);
|
if (del != null) del(new InputIdentifier { Source = new InputSource { Handler = this, Type = type }, Id = id }, vec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,28 +4,22 @@ using System.Reflection;
|
|||||||
|
|
||||||
namespace Cryville.Common.Unity.Input {
|
namespace Cryville.Common.Unity.Input {
|
||||||
public class InputManager {
|
public class InputManager {
|
||||||
static readonly List<Type> HandlerRegistries = new List<Type> {
|
static readonly HashSet<Type> HandlerRegistries = new HashSet<Type> {
|
||||||
typeof(WindowsPointerHandler),
|
typeof(WindowsPointerHandler),
|
||||||
typeof(UnityKeyHandler<UnityKeyboardReceiver>),
|
typeof(UnityKeyHandler<UnityKeyboardReceiver>),
|
||||||
typeof(UnityKeyHandler<UnityMouseButtonReceiver>),
|
typeof(UnityKeyHandler<UnityMouseButtonReceiver>),
|
||||||
typeof(UnityMouseHandler),
|
typeof(UnityMouseHandler),
|
||||||
typeof(UnityTouchHandler),
|
typeof(UnityTouchHandler),
|
||||||
};
|
};
|
||||||
readonly List<InputHandler> _handlers = new List<InputHandler>();
|
readonly HashSet<InputHandler> _handlers = new HashSet<InputHandler>();
|
||||||
readonly Dictionary<Type, InputHandler> _typemap = new Dictionary<Type, InputHandler>();
|
readonly Dictionary<Type, InputHandler> _typemap = new Dictionary<Type, InputHandler>();
|
||||||
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
|
|
||||||
readonly object _lock = new object();
|
|
||||||
readonly Dictionary<InputIdentifier, InputVector> _vectors = new Dictionary<InputIdentifier, InputVector>();
|
|
||||||
readonly List<InputEvent> _events = new List<InputEvent>();
|
|
||||||
public InputManager() {
|
public InputManager() {
|
||||||
foreach (var t in HandlerRegistries) {
|
foreach (var t in HandlerRegistries) {
|
||||||
try {
|
try {
|
||||||
if (!typeof(InputHandler).IsAssignableFrom(t)) continue;
|
if (!typeof(InputHandler).IsAssignableFrom(t)) continue;
|
||||||
var h = (InputHandler)ReflectionHelper.InvokeEmptyConstructor(t);
|
var h = (InputHandler)ReflectionHelper.InvokeEmptyConstructor(t);
|
||||||
_typemap.Add(t, h);
|
_typemap.Add(t, h);
|
||||||
h.OnInput += OnInput;
|
|
||||||
_handlers.Add(h);
|
_handlers.Add(h);
|
||||||
_timeOrigins.Add(h, 0);
|
|
||||||
Logger.Log("main", 1, "Input", "Initialized {0}", ReflectionHelper.GetSimpleName(t));
|
Logger.Log("main", 1, "Input", "Initialized {0}", ReflectionHelper.GetSimpleName(t));
|
||||||
}
|
}
|
||||||
catch (TargetInvocationException ex) {
|
catch (TargetInvocationException ex) {
|
||||||
@@ -36,49 +30,8 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
public InputHandler GetHandler(string name) {
|
public InputHandler GetHandler(string name) {
|
||||||
return _typemap[Type.GetType(name)];
|
return _typemap[Type.GetType(name)];
|
||||||
}
|
}
|
||||||
public void Activate() {
|
public void EnumerateHandlers(Action<InputHandler> cb) {
|
||||||
lock (_lock) {
|
foreach (var h in _handlers) cb(h);
|
||||||
_events.Clear();
|
|
||||||
}
|
|
||||||
foreach (var h in _handlers) h.Activate();
|
|
||||||
}
|
|
||||||
public void SyncTime(double time) {
|
|
||||||
foreach (var h in _handlers) {
|
|
||||||
_timeOrigins[h] = time - h.GetCurrentTimestamp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void Deactivate() {
|
|
||||||
foreach (var h in _handlers) h.Deactivate();
|
|
||||||
}
|
|
||||||
void OnInput(InputIdentifier id, InputVector vec) {
|
|
||||||
lock (_lock) {
|
|
||||||
double timeOrigin = _timeOrigins[id.Source.Handler];
|
|
||||||
vec.Time += timeOrigin;
|
|
||||||
InputVector vec0;
|
|
||||||
if (_vectors.TryGetValue(id, out vec0)) {
|
|
||||||
_events.Add(new InputEvent {
|
|
||||||
Id = id,
|
|
||||||
From = vec0,
|
|
||||||
To = vec,
|
|
||||||
});
|
|
||||||
if (vec.IsNull) _vectors.Remove(id);
|
|
||||||
else _vectors[id] = vec;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_events.Add(new InputEvent {
|
|
||||||
Id = id,
|
|
||||||
From = new InputVector(vec.Time),
|
|
||||||
To = vec,
|
|
||||||
});
|
|
||||||
_vectors.Add(id, vec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void EnumerateEvents(Action<InputEvent> cb) {
|
|
||||||
lock (_lock) {
|
|
||||||
foreach (var ev in _events) cb(ev);
|
|
||||||
_events.Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
49
Assets/Cryville/Common/Unity/Input/SimpleInputConsumer.cs
Normal file
49
Assets/Cryville/Common/Unity/Input/SimpleInputConsumer.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Unity.Input {
|
||||||
|
public class SimpleInputConsumer {
|
||||||
|
readonly InputManager _manager;
|
||||||
|
readonly object _lock = new object();
|
||||||
|
readonly Dictionary<InputIdentifier, InputVector> _vectors = new Dictionary<InputIdentifier, InputVector>();
|
||||||
|
readonly List<InputEvent> _events = new List<InputEvent>();
|
||||||
|
public SimpleInputConsumer(InputManager manager) { _manager = manager; }
|
||||||
|
public void Activate() {
|
||||||
|
lock (_lock) {
|
||||||
|
_events.Clear();
|
||||||
|
}
|
||||||
|
_manager.EnumerateHandlers(h => h.OnInput += OnInput);
|
||||||
|
}
|
||||||
|
public void Deactivate() {
|
||||||
|
_manager.EnumerateHandlers(h => h.OnInput -= OnInput);
|
||||||
|
}
|
||||||
|
protected void OnInput(InputIdentifier id, InputVector vec) {
|
||||||
|
lock (_lock) {
|
||||||
|
InputVector vec0;
|
||||||
|
if (_vectors.TryGetValue(id, out vec0)) {
|
||||||
|
_events.Add(new InputEvent {
|
||||||
|
Id = id,
|
||||||
|
From = vec0,
|
||||||
|
To = vec,
|
||||||
|
});
|
||||||
|
if (vec.IsNull) _vectors.Remove(id);
|
||||||
|
else _vectors[id] = vec;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_events.Add(new InputEvent {
|
||||||
|
Id = id,
|
||||||
|
From = new InputVector(vec.Time),
|
||||||
|
To = vec,
|
||||||
|
});
|
||||||
|
_vectors.Add(id, vec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void EnumerateEvents(Action<InputEvent> cb) {
|
||||||
|
lock (_lock) {
|
||||||
|
foreach (var ev in _events) cb(ev);
|
||||||
|
_events.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8fd2d5f1c7ba0c74c9ce8775075750db
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@@ -9,19 +9,19 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
|
|
||||||
public UnityKeyHandler() { }
|
public UnityKeyHandler() { }
|
||||||
|
|
||||||
protected override void ActivateImpl() {
|
protected override void Activate() {
|
||||||
receiver = new GameObject("__keyrecv__");
|
receiver = new GameObject("__keyrecv__");
|
||||||
recvcomp = receiver.AddComponent<T>();
|
recvcomp = receiver.AddComponent<T>();
|
||||||
recvcomp.SetCallback(Feed);
|
recvcomp.SetCallback(Feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DeactivateImpl() {
|
protected override void Deactivate() {
|
||||||
if (receiver) GameObject.Destroy(receiver);
|
if (receiver) GameObject.Destroy(receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose(bool disposing) {
|
public override void Dispose(bool disposing) {
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
DeactivateImpl();
|
Deactivate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
|
|
||||||
public abstract class UnityKeyReceiver<T> : MonoBehaviour where T : UnityKeyReceiver<T> {
|
public abstract class UnityKeyReceiver<T> : MonoBehaviour where T : UnityKeyReceiver<T> {
|
||||||
protected Action<int, int, InputVector> Callback;
|
protected Action<int, int, InputVector> Callback;
|
||||||
protected readonly List<int> Keys = new List<int>();
|
protected readonly HashSet<int> Keys = new HashSet<int>();
|
||||||
public void SetCallback(Action<int, int, InputVector> h) {
|
public void SetCallback(Action<int, int, InputVector> h) {
|
||||||
Callback = h;
|
Callback = h;
|
||||||
}
|
}
|
||||||
|
@@ -12,18 +12,18 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ActivateImpl() {
|
protected override void Activate() {
|
||||||
receiver = new GameObject("__mouserecv__");
|
receiver = new GameObject("__mouserecv__");
|
||||||
receiver.AddComponent<UnityMouseReceiver>().SetHandler(this);
|
receiver.AddComponent<UnityMouseReceiver>().SetHandler(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DeactivateImpl() {
|
protected override void Deactivate() {
|
||||||
if (receiver) GameObject.Destroy(receiver);
|
if (receiver) GameObject.Destroy(receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose(bool disposing) {
|
public override void Dispose(bool disposing) {
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
DeactivateImpl();
|
Deactivate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,18 +12,18 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ActivateImpl() {
|
protected override void Activate() {
|
||||||
receiver = new GameObject("__touchrecv__");
|
receiver = new GameObject("__touchrecv__");
|
||||||
receiver.AddComponent<UnityPointerReceiver>().SetHandler(this);
|
receiver.AddComponent<UnityPointerReceiver>().SetHandler(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DeactivateImpl() {
|
protected override void Deactivate() {
|
||||||
if (receiver) GameObject.Destroy(receiver);
|
if (receiver) GameObject.Destroy(receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose(bool disposing) {
|
public override void Dispose(bool disposing) {
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
DeactivateImpl();
|
Deactivate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
public const int TABLET_DISABLE_PENBARRELFEEDBACK = 0x00000010;
|
public const int TABLET_DISABLE_PENBARRELFEEDBACK = 0x00000010;
|
||||||
public const int TABLET_DISABLE_FLICKS = 0x00010000;
|
public const int TABLET_DISABLE_FLICKS = 0x00010000;
|
||||||
|
|
||||||
protected override void ActivateImpl() {
|
protected override void Activate() {
|
||||||
newWndProc = WndProc;
|
newWndProc = WndProc;
|
||||||
newWndProcPtr = Marshal.GetFunctionPointerForDelegate(newWndProc);
|
newWndProcPtr = Marshal.GetFunctionPointerForDelegate(newWndProc);
|
||||||
oldWndProcPtr = SetWindowLongPtr(hMainWindow, -4, newWndProcPtr);
|
oldWndProcPtr = SetWindowLongPtr(hMainWindow, -4, newWndProcPtr);
|
||||||
@@ -77,7 +77,7 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DeactivateImpl() {
|
protected override void Deactivate() {
|
||||||
if (pressAndHoldAtomID != 0) {
|
if (pressAndHoldAtomID != 0) {
|
||||||
NativeMethods.RemoveProp(hMainWindow, PRESS_AND_HOLD_ATOM);
|
NativeMethods.RemoveProp(hMainWindow, PRESS_AND_HOLD_ATOM);
|
||||||
NativeMethods.GlobalDeleteAtom(pressAndHoldAtomID);
|
NativeMethods.GlobalDeleteAtom(pressAndHoldAtomID);
|
||||||
@@ -142,7 +142,7 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose(bool disposing) {
|
public override void Dispose(bool disposing) {
|
||||||
DeactivateImpl();
|
Deactivate();
|
||||||
if (usePointerMessage)
|
if (usePointerMessage)
|
||||||
NativeMethods.EnableMouseInPointer(false);
|
NativeMethods.EnableMouseInPointer(false);
|
||||||
Instance = null;
|
Instance = null;
|
||||||
|
@@ -1,15 +1,17 @@
|
|||||||
using UnityEngine;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
public class Anchor {
|
public class Anchor {
|
||||||
bool _opened;
|
public int Name { get; private set; }
|
||||||
public bool Opened { get { return _opened; } }
|
public Transform Transform { get; private set; }
|
||||||
public Transform Transform { get; set; }
|
public SkinContext SkinContext { get; private set; }
|
||||||
public void Open() {
|
public Dictionary<int, PropSrc> PropSrcs { get; private set; }
|
||||||
_opened = true;
|
public Anchor(int name, Transform transform, bool hasProps = false) {
|
||||||
}
|
Name = name;
|
||||||
public void Close() {
|
Transform = transform;
|
||||||
_opened = false;
|
if (hasProps) PropSrcs = new Dictionary<int, PropSrc>();
|
||||||
|
SkinContext = new SkinContext(transform, PropSrcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -130,15 +130,6 @@ namespace Cryville.Crtr {
|
|||||||
get { return Duration > 0; }
|
get { return Duration > 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private InstantEvent attev = null;
|
|
||||||
[JsonIgnore]
|
|
||||||
public InstantEvent AttackEvent {
|
|
||||||
get {
|
|
||||||
if (attev == null) attev = new InstantEvent(this);
|
|
||||||
return attev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private InstantEvent relev = null;
|
private InstantEvent relev = null;
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public InstantEvent ReleaseEvent {
|
public InstantEvent ReleaseEvent {
|
||||||
@@ -310,6 +301,8 @@ namespace Cryville.Crtr {
|
|||||||
#pragma warning restore IDE1006
|
#pragma warning restore IDE1006
|
||||||
|
|
||||||
private void LoadFromString(string s) {
|
private void LoadFromString(string s) {
|
||||||
|
if (RelativeNode != null || AbsoluteValue != null)
|
||||||
|
throw new InvalidOperationException("The motion property can only be set at initialization");
|
||||||
Match m = Regex.Match(s, @"^(.+?)(#(\d+))?(@(.+?))?(\^(.+?))?(\*(.+?))?(:(.+))?$");
|
Match m = Regex.Match(s, @"^(.+?)(#(\d+))?(@(.+?))?(\^(.+?))?(\*(.+?))?(:(.+))?$");
|
||||||
if (!m.Success) throw new ArgumentException("Invalid motion string format");
|
if (!m.Success) throw new ArgumentException("Invalid motion string format");
|
||||||
name = new Identifier(m.Groups[1].Value);
|
name = new Identifier(m.Groups[1].Value);
|
||||||
@@ -331,6 +324,10 @@ namespace Cryville.Crtr {
|
|||||||
else {
|
else {
|
||||||
AbsoluteValue = Vector.Construct(registry.Type, m.Groups[11].Value);
|
AbsoluteValue = Vector.Construct(registry.Type, m.Groups[11].Value);
|
||||||
}
|
}
|
||||||
|
SubmitPropSrc("value", VectorSrc.Construct(() => {
|
||||||
|
if (RelativeNode != null) return RelativeNode.Value;
|
||||||
|
else return AbsoluteValue;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
@@ -382,10 +379,6 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Motion() {
|
public Motion() {
|
||||||
SubmitPropSrc("value", new VectorSrc(() => {
|
|
||||||
if (RelativeNode != null) return RelativeNode.Value;
|
|
||||||
else return AbsoluteValue;
|
|
||||||
}));
|
|
||||||
SubmitPropOp("motion", new PropOp.String(v => motion = v));
|
SubmitPropOp("motion", new PropOp.String(v => motion = v));
|
||||||
SubmitPropOp("name", new PropOp.Identifier(v => {
|
SubmitPropOp("name", new PropOp.Identifier(v => {
|
||||||
var n = new Identifier(v);
|
var n = new Identifier(v);
|
||||||
|
@@ -149,6 +149,7 @@ namespace Cryville.Crtr {
|
|||||||
nbus.BroadcastEndUpdate();
|
nbus.BroadcastEndUpdate();
|
||||||
nbus.Anchor();
|
nbus.Anchor();
|
||||||
|
|
||||||
|
tbus.StripTempEvents();
|
||||||
tbus.ForwardStepByTime(clippingDist, step);
|
tbus.ForwardStepByTime(clippingDist, step);
|
||||||
tbus.ForwardStepByTime(renderDist, step);
|
tbus.ForwardStepByTime(renderDist, step);
|
||||||
tbus.BroadcastEndUpdate();
|
tbus.BroadcastEndUpdate();
|
||||||
@@ -484,6 +485,7 @@ namespace Cryville.Crtr {
|
|||||||
workerTimer = new diag::Stopwatch();
|
workerTimer = new diag::Stopwatch();
|
||||||
workerTimer.Start();
|
workerTimer.Start();
|
||||||
RMVPool.Prepare();
|
RMVPool.Prepare();
|
||||||
|
MotionCachePool.Prepare();
|
||||||
LoadChart(info);
|
LoadChart(info);
|
||||||
workerTimer.Stop();
|
workerTimer.Stop();
|
||||||
Logger.Log("main", 1, "Load/WorkerThread", "Worker thread done ({0}ms)", workerTimer.Elapsed.TotalMilliseconds);
|
Logger.Log("main", 1, "Load/WorkerThread", "Worker thread done ({0}ms)", workerTimer.Elapsed.TotalMilliseconds);
|
||||||
@@ -515,10 +517,10 @@ namespace Cryville.Crtr {
|
|||||||
var batcher = new EventBatcher(chart);
|
var batcher = new EventBatcher(chart);
|
||||||
batcher.Forward();
|
batcher.Forward();
|
||||||
cbus = batcher.Batch();
|
cbus = batcher.Batch();
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Batched {0} event batches", cbus.events.Count);
|
|
||||||
|
|
||||||
LoadSkin(info.skinFile);
|
LoadSkin(info.skinFile);
|
||||||
|
|
||||||
|
Logger.Log("main", 0, "Load/WorkerThread", "Initializing judge and input");
|
||||||
judge = new Judge(pruleset);
|
judge = new Judge(pruleset);
|
||||||
etor.ContextJudge = judge;
|
etor.ContextJudge = judge;
|
||||||
|
|
||||||
@@ -537,10 +539,10 @@ namespace Cryville.Crtr {
|
|||||||
foreach (var ts in gs.Value.Children) {
|
foreach (var ts in gs.Value.Children) {
|
||||||
ContainerHandler th;
|
ContainerHandler th;
|
||||||
if (ts.Key is Chart.Note) {
|
if (ts.Key is Chart.Note) {
|
||||||
th = new NoteHandler(gh, (Chart.Note)ts.Key, pruleset);
|
th = new NoteHandler((Chart.Note)ts.Key, gh);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
th = new TrackHandler(gh, (Chart.Track)ts.Key);
|
th = new TrackHandler((Chart.Track)ts.Key, gh);
|
||||||
}
|
}
|
||||||
ts.Value.AttachHandler(th);
|
ts.Value.AttachHandler(th);
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
|
|
||||||
public SectionalGameObject() {
|
public SectionalGameObject() {
|
||||||
SubmitProperty("partial", new PropOp.Boolean(v => part = Part.idle));
|
SubmitProperty("partial", new PropOp.Boolean(v => part = Part.idle));
|
||||||
SubmitProperty("part", new PropOp.Enum<Part>(v => part = v, v => (Part)v));
|
SubmitProperty("part", new PropOp.Enum<Part>(v => part = v, v => (Part)v), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDestroy() {
|
protected override void OnDestroy() {
|
||||||
@@ -152,6 +152,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
List<Vector3> verts;
|
List<Vector3> verts;
|
||||||
List<Vector2> uvs;
|
List<Vector2> uvs;
|
||||||
List<int> trih = null, trib = null, trit = null;
|
List<int> trih = null, trib = null, trit = null;
|
||||||
|
static List<int> _emptyTris = new List<int>();
|
||||||
|
|
||||||
public override void Seal() {
|
public override void Seal() {
|
||||||
if (vertCount <= 1 || sumLength == 0) return;
|
if (vertCount <= 1 || sumLength == 0) return;
|
||||||
@@ -192,13 +193,13 @@ namespace Cryville.Crtr.Components {
|
|||||||
if (body.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trib, body, ref i, ref t, ref l, headLength, sumLength - tailLength, vcpsec, hvc + bvc); }
|
if (body.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trib, body, ref i, ref t, ref l, headLength, sumLength - tailLength, vcpsec, hvc + bvc); }
|
||||||
if (tail.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trit, tail, ref i, ref t, ref l, sumLength - tailLength, sumLength, vcpsec, vc); }
|
if (tail.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trit, tail, ref i, ref t, ref l, sumLength - tailLength, sumLength, vcpsec, vc); }
|
||||||
|
|
||||||
mesh.Mesh.subMeshCount = m;
|
mesh.Mesh.subMeshCount = 3;
|
||||||
m = 0;
|
m = 0;
|
||||||
mesh.Mesh.SetVertices(verts);
|
mesh.Mesh.SetVertices(verts);
|
||||||
mesh.Mesh.SetUVs(0, uvs);
|
mesh.Mesh.SetUVs(0, uvs);
|
||||||
if (head.Frame != null) mesh.Mesh.SetTriangles(trih, m++);
|
mesh.Mesh.SetTriangles(head.Frame == null ? _emptyTris : trih, m++);
|
||||||
if (body.Frame != null) mesh.Mesh.SetTriangles(trib, m++);
|
mesh.Mesh.SetTriangles(body.Frame == null ? _emptyTris : trib, m++);
|
||||||
if (tail.Frame != null) mesh.Mesh.SetTriangles(trit, m++);
|
mesh.Mesh.SetTriangles(tail.Frame == null ? _emptyTris : trit, m++);
|
||||||
mesh.Mesh.RecalculateNormals();
|
mesh.Mesh.RecalculateNormals();
|
||||||
|
|
||||||
_vertPool.Return(verts); verts = null;
|
_vertPool.Return(verts); verts = null;
|
||||||
|
@@ -19,7 +19,7 @@ namespace Cryville.Crtr.Config {
|
|||||||
public Ruleset ruleset;
|
public Ruleset ruleset;
|
||||||
RulesetConfig _rscfg;
|
RulesetConfig _rscfg;
|
||||||
|
|
||||||
void Awake() {
|
void Start() {
|
||||||
ChartPlayer.etor = new PdtEvaluator();
|
ChartPlayer.etor = new PdtEvaluator();
|
||||||
FileInfo file = new FileInfo(
|
FileInfo file = new FileInfo(
|
||||||
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
||||||
@@ -57,7 +57,6 @@ namespace Cryville.Crtr.Config {
|
|||||||
var proxy = new InputProxy(ruleset.Root, null);
|
var proxy = new InputProxy(ruleset.Root, null);
|
||||||
proxy.LoadFrom(_rscfg.inputs);
|
proxy.LoadFrom(_rscfg.inputs);
|
||||||
m_inputConfigPanel.proxy = proxy;
|
m_inputConfigPanel.proxy = proxy;
|
||||||
Game.InputManager.Activate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SwitchCategory(GameObject cat) {
|
public void SwitchCategory(GameObject cat) {
|
||||||
@@ -68,7 +67,6 @@ namespace Cryville.Crtr.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void SaveAndReturnToMenu() {
|
public void SaveAndReturnToMenu() {
|
||||||
Game.InputManager.Deactivate();
|
|
||||||
m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
|
m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
|
||||||
m_inputConfigPanel.proxy.Dispose();
|
m_inputConfigPanel.proxy.Dispose();
|
||||||
FileInfo cfgfile = new FileInfo(
|
FileInfo cfgfile = new FileInfo(
|
||||||
|
@@ -24,6 +24,7 @@ namespace Cryville.Crtr.Config {
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
GameObject m_prefabInputConfigEntry;
|
GameObject m_prefabInputConfigEntry;
|
||||||
|
|
||||||
|
readonly SimpleInputConsumer _consumer = new SimpleInputConsumer(Game.InputManager);
|
||||||
public InputProxy proxy;
|
public InputProxy proxy;
|
||||||
readonly Dictionary<string, InputConfigPanelEntry> _entries = new Dictionary<string, InputConfigPanelEntry>();
|
readonly Dictionary<string, InputConfigPanelEntry> _entries = new Dictionary<string, InputConfigPanelEntry>();
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ namespace Cryville.Crtr.Config {
|
|||||||
_sel = entry;
|
_sel = entry;
|
||||||
m_inputDialog.SetActive(true);
|
m_inputDialog.SetActive(true);
|
||||||
CallHelper.Purge(m_deviceList);
|
CallHelper.Purge(m_deviceList);
|
||||||
Game.InputManager.EnumerateEvents(ev => { });
|
_consumer.EnumerateEvents(ev => { });
|
||||||
_recvsrcs.Clear();
|
_recvsrcs.Clear();
|
||||||
AddSourceItem(null);
|
AddSourceItem(null);
|
||||||
}
|
}
|
||||||
@@ -46,10 +47,11 @@ namespace Cryville.Crtr.Config {
|
|||||||
Target = _sel,
|
Target = _sel,
|
||||||
Source = src,
|
Source = src,
|
||||||
});
|
});
|
||||||
m_inputDialog.SetActive(false);
|
CloseDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
|
_consumer.Activate();
|
||||||
foreach (var i in m_configScene.ruleset.Root.inputs) {
|
foreach (var i in m_configScene.ruleset.Root.inputs) {
|
||||||
var e = GameObject.Instantiate(m_prefabInputConfigEntry, m_entryList.transform).GetComponent<InputConfigPanelEntry>();
|
var e = GameObject.Instantiate(m_prefabInputConfigEntry, m_entryList.transform).GetComponent<InputConfigPanelEntry>();
|
||||||
_entries.Add(i.Key, e);
|
_entries.Add(i.Key, e);
|
||||||
@@ -59,6 +61,10 @@ namespace Cryville.Crtr.Config {
|
|||||||
proxy.ProxyChanged += OnProxyChanged;
|
proxy.ProxyChanged += OnProxyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnDestroy() {
|
||||||
|
_consumer.Deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
void OnProxyChanged(object sender, ProxyChangedEventArgs e) {
|
void OnProxyChanged(object sender, ProxyChangedEventArgs e) {
|
||||||
_entries[e.Name].SetEnabled(!e.Used);
|
_entries[e.Name].SetEnabled(!e.Used);
|
||||||
_entries[e.Name].SetValue(e.Proxy == null ? "None" : e.Proxy.Value.Handler.GetTypeName(e.Proxy.Value.Type));
|
_entries[e.Name].SetValue(e.Proxy == null ? "None" : e.Proxy.Value.Handler.GetTypeName(e.Proxy.Value.Type));
|
||||||
@@ -67,7 +73,7 @@ namespace Cryville.Crtr.Config {
|
|||||||
readonly List<InputSource?> _recvsrcs = new List<InputSource?>();
|
readonly List<InputSource?> _recvsrcs = new List<InputSource?>();
|
||||||
void Update() {
|
void Update() {
|
||||||
if (m_inputDialog.activeSelf) {
|
if (m_inputDialog.activeSelf) {
|
||||||
Game.InputManager.EnumerateEvents(ev => {
|
_consumer.EnumerateEvents(ev => {
|
||||||
AddSourceItem(ev.Id.Source);
|
AddSourceItem(ev.Id.Source);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Logger = Cryville.Common.Logger;
|
||||||
|
|
||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
internal class DiscordController : MonoBehaviour {
|
internal class DiscordController : MonoBehaviour {
|
||||||
@@ -16,22 +17,42 @@ namespace Cryville.Crtr {
|
|||||||
void Start() {
|
void Start() {
|
||||||
Instance = this;
|
Instance = this;
|
||||||
launchTime = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
launchTime = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
||||||
dc = new Discord.Discord(CLIENT_ID, (UInt64)CreateFlags.Default);
|
try {
|
||||||
am = dc.GetActivityManager();
|
dc = new Discord.Discord(CLIENT_ID, (UInt64)CreateFlags.NoRequireDiscord);
|
||||||
SetIdle();
|
Logger.Log("main", 1, "Discord", "Connected to Discord");
|
||||||
|
am = dc.GetActivityManager();
|
||||||
|
SetIdle();
|
||||||
|
}
|
||||||
|
catch (ResultException) {
|
||||||
|
if (dc != null) {
|
||||||
|
dc.Dispose();
|
||||||
|
dc = null;
|
||||||
|
}
|
||||||
|
Logger.Log("main", 3, "Discord", "Cannot connect to Discord");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
dc.RunCallbacks();
|
if (dc == null) return;
|
||||||
|
try {
|
||||||
|
dc.RunCallbacks();
|
||||||
|
}
|
||||||
|
catch (ResultException ex) {
|
||||||
|
dc.Dispose();
|
||||||
|
dc = null;
|
||||||
|
Logger.Log("main", 4, "Discord", "An error occured while running callbacks: {0}", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnApplicationQuit() {
|
void OnApplicationQuit() {
|
||||||
|
if (dc == null) return;
|
||||||
dc.Dispose();
|
dc.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Callback(Result result) { }
|
void Callback(Result result) { }
|
||||||
|
|
||||||
public void SetIdle() {
|
public void SetIdle() {
|
||||||
|
if (dc == null) return;
|
||||||
am.UpdateActivity(new Activity {
|
am.UpdateActivity(new Activity {
|
||||||
State = "Idle",
|
State = "Idle",
|
||||||
Instance = false,
|
Instance = false,
|
||||||
@@ -40,6 +61,7 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void SetPlaying(string detail, double? duration) {
|
public void SetPlaying(string detail, double? duration) {
|
||||||
|
if (dc == null) return;
|
||||||
long now = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
long now = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
||||||
am.UpdateActivity(new Activity {
|
am.UpdateActivity(new Activity {
|
||||||
State = "Playing a chart",
|
State = "Playing a chart",
|
||||||
|
@@ -36,12 +36,9 @@ namespace Cryville.Crtr.Event {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="GameObject"/> group, the <see cref="Transform"/> containing all the generated elements in the <see cref="ContainerHandler"/>.
|
/// <see cref="GameObject"/> group, the <see cref="Transform"/> containing all the generated elements in the <see cref="ContainerHandler"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Transform gogroup;
|
protected Transform gogroup;
|
||||||
|
public SkinContext SkinContext;
|
||||||
|
|
||||||
public readonly Dictionary<int, Anchor> Anchors = new Dictionary<int, Anchor>();
|
|
||||||
protected Transform a_cur;
|
|
||||||
protected Transform a_head;
|
|
||||||
protected Transform a_tail;
|
|
||||||
public Vector3 Position { get; protected set; }
|
public Vector3 Position { get; protected set; }
|
||||||
public Quaternion Rotation { get; protected set; }
|
public Quaternion Rotation { get; protected set; }
|
||||||
public bool Alive { get; private set; }
|
public bool Alive { get; private set; }
|
||||||
@@ -63,22 +60,31 @@ namespace Cryville.Crtr.Event {
|
|||||||
public abstract string TypeName {
|
public abstract string TypeName {
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
public readonly Dictionary<int, List<Anchor>> Anchors = new Dictionary<int, List<Anchor>>();
|
||||||
|
public Anchor OpenedAnchor;
|
||||||
|
protected Anchor a_cur;
|
||||||
|
protected Anchor a_head;
|
||||||
|
protected Anchor a_tail;
|
||||||
protected readonly static int _a_cur = IdentifierManager.SharedInstance.Request("cur");
|
protected readonly static int _a_cur = IdentifierManager.SharedInstance.Request("cur");
|
||||||
protected readonly static int _a_head = IdentifierManager.SharedInstance.Request("head");
|
protected readonly static int _a_head = IdentifierManager.SharedInstance.Request("head");
|
||||||
protected readonly static int _a_tail = IdentifierManager.SharedInstance.Request("tail");
|
protected readonly static int _a_tail = IdentifierManager.SharedInstance.Request("tail");
|
||||||
public virtual void PreInit() {
|
public virtual void PreInit() {
|
||||||
gogroup = new GameObject(TypeName + ":" + Container.GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
|
gogroup = new GameObject(TypeName + ":" + Container.GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
|
||||||
|
SkinContext = new SkinContext(gogroup);
|
||||||
if (cs.Parent != null)
|
if (cs.Parent != null)
|
||||||
gogroup.SetParent(cs.Parent.Handler.gogroup, false);
|
gogroup.SetParent(cs.Parent.Handler.gogroup, false);
|
||||||
a_cur = RegisterAnchor(_a_cur).Transform;
|
a_cur = RegisterAnchor(_a_cur);
|
||||||
a_head = RegisterAnchor(_a_head).Transform;
|
a_head = RegisterAnchor(_a_head);
|
||||||
a_tail = RegisterAnchor(_a_tail).Transform;
|
a_tail = RegisterAnchor(_a_tail);
|
||||||
}
|
}
|
||||||
protected Anchor RegisterAnchor(int name) {
|
protected Anchor RegisterAnchor(int name, bool hasPropSrcs = false) {
|
||||||
var go = new GameObject("." + IdentifierManager.SharedInstance.Retrieve(name)).transform;
|
var go = new GameObject("." + IdentifierManager.SharedInstance.Retrieve(name)).transform;
|
||||||
go.SetParent(gogroup, false);
|
go.SetParent(gogroup, false);
|
||||||
var result = new Anchor() { Transform = go };
|
var result = new Anchor(name, go, hasPropSrcs);
|
||||||
Anchors.Add(name, result);
|
List<Anchor> list;
|
||||||
|
if (!Anchors.TryGetValue(name, out list))
|
||||||
|
Anchors.Add(name, list = new List<Anchor>());
|
||||||
|
list.Add(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,12 +108,14 @@ namespace Cryville.Crtr.Event {
|
|||||||
Alive = false;
|
Alive = false;
|
||||||
}
|
}
|
||||||
protected virtual void PreAwake(ContainerState s) {
|
protected virtual void PreAwake(ContainerState s) {
|
||||||
if (gogroup) gogroup.gameObject.SetActive(true);
|
if (gogroup) {
|
||||||
|
gogroup.gameObject.SetActive(true);
|
||||||
|
OpenAnchor(a_head);
|
||||||
|
}
|
||||||
Awoken = true; Alive = true;
|
Awoken = true; Alive = true;
|
||||||
OpenAnchor(_a_head);
|
|
||||||
}
|
}
|
||||||
protected virtual void Awake(ContainerState s) {
|
protected virtual void Awake(ContainerState s) {
|
||||||
CloseAnchor(_a_head);
|
if (gogroup) CloseAnchor();
|
||||||
}
|
}
|
||||||
protected virtual void GetPosition(ContainerState s) { }
|
protected virtual void GetPosition(ContainerState s) { }
|
||||||
public virtual void StartUpdate(ContainerState s) {
|
public virtual void StartUpdate(ContainerState s) {
|
||||||
@@ -121,27 +129,37 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
static readonly SimpleObjectPool<StampedEvent.Anchor> anchorEvPool
|
static readonly SimpleObjectPool<StampedEvent.Anchor> anchorEvPool
|
||||||
= new SimpleObjectPool<StampedEvent.Anchor>(1024);
|
= new SimpleObjectPool<StampedEvent.Anchor>(1024);
|
||||||
protected void PushAnchorEvent(int name, double time) {
|
protected void PushAnchorEvent(double time, Anchor anchor) {
|
||||||
var tev = anchorEvPool.Rent();
|
var tev = anchorEvPool.Rent();
|
||||||
tev.Time = time;
|
tev.Time = time;
|
||||||
tev.Container = Container;
|
tev.Container = Container;
|
||||||
tev.Name = name;
|
tev.Target = anchor;
|
||||||
ts.Bus.PushTempEvent(tev);
|
ts.Bus.PushTempEvent(tev);
|
||||||
}
|
}
|
||||||
|
public virtual void Discard(ContainerState s, StampedEvent ev) {
|
||||||
|
if (ev is StampedEvent.Anchor) {
|
||||||
|
anchorEvPool.Return((StampedEvent.Anchor)ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
public virtual void Update(ContainerState s, StampedEvent ev) {
|
public virtual void Update(ContainerState s, StampedEvent ev) {
|
||||||
bool flag = !Awoken && s.CloneType >= 2 && s.CloneType < 16;
|
bool flag = !Awoken && s.CloneType >= 2 && s.CloneType < 16;
|
||||||
if (flag) PreAwake(s);
|
if (flag) PreAwake(s);
|
||||||
if (s.CloneType <= 2) if (gogroup) skinContainer.MatchDynamic(s);
|
if (gogroup && s.CloneType <= 2) skinContainer.MatchDynamic(s);
|
||||||
if (flag) Awake(s);
|
if (flag) Awake(s);
|
||||||
}
|
}
|
||||||
public virtual void ExUpdate(ContainerState s, StampedEvent ev) {
|
public virtual void ExUpdate(ContainerState s, StampedEvent ev) {
|
||||||
if (ev is StampedEvent.Anchor) {
|
if (ev is StampedEvent.Anchor) {
|
||||||
var tev = (StampedEvent.Anchor)ev;
|
var tev = (StampedEvent.Anchor)ev;
|
||||||
if (gogroup) {
|
if (gogroup) {
|
||||||
OpenAnchor(tev.Name);
|
OpenAnchor(tev.Target);
|
||||||
Anchors[tev.Name].Transform.SetPositionAndRotation(Position, Rotation);
|
#if UNITY_5_6_OR_NEWER
|
||||||
|
tev.Target.Transform.SetPositionAndRotation(Position, Rotation);
|
||||||
|
#else
|
||||||
|
tev.Target.Transform.position = GetCurrentWorldPoint();
|
||||||
|
tev.Target.Transform.rotation = Quaternion.Euler(s.Direction);
|
||||||
|
#endif
|
||||||
skinContainer.MatchDynamic(s);
|
skinContainer.MatchDynamic(s);
|
||||||
CloseAnchor(tev.Name);
|
CloseAnchor();
|
||||||
}
|
}
|
||||||
anchorEvPool.Return(tev);
|
anchorEvPool.Return(tev);
|
||||||
}
|
}
|
||||||
@@ -150,17 +168,23 @@ namespace Cryville.Crtr.Event {
|
|||||||
public virtual void EndUpdate(ContainerState s) {
|
public virtual void EndUpdate(ContainerState s) {
|
||||||
if (s.CloneType < 16) {
|
if (s.CloneType < 16) {
|
||||||
Awoken = false;
|
Awoken = false;
|
||||||
if (gogroup && s.CloneType <= 2) skinContainer.MatchDynamic(s);
|
if (gogroup && s.CloneType <= 2) {
|
||||||
|
OpenAnchor(a_tail);
|
||||||
|
skinContainer.MatchDynamic(s);
|
||||||
|
CloseAnchor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual void Anchor() {
|
public virtual void Anchor() {
|
||||||
if (cs.Working) PushAnchorEvent(_a_cur, cs.Time);
|
skinContainer.MatchDynamic(cs);
|
||||||
|
if (cs.Working) PushAnchorEvent(cs.Time, a_cur);
|
||||||
}
|
}
|
||||||
protected void OpenAnchor(int name) {
|
protected void OpenAnchor(Anchor anchor) {
|
||||||
if (Anchors.ContainsKey(name)) Anchors[name].Open();
|
if (OpenedAnchor != null) throw new InvalidOperationException("An anchor has been opened");
|
||||||
|
OpenedAnchor = anchor;
|
||||||
}
|
}
|
||||||
protected void CloseAnchor(int name) {
|
protected void CloseAnchor() {
|
||||||
if (Anchors.ContainsKey(name)) Anchors[name].Close();
|
OpenedAnchor = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
public class ContainerState {
|
public class ContainerState {
|
||||||
public EventBus Bus;
|
public EventBus Bus;
|
||||||
public EventContainer Container;
|
public EventContainer Container;
|
||||||
|
public StampedEvent StampedContainer;
|
||||||
public ContainerState Parent = null;
|
public ContainerState Parent = null;
|
||||||
public ushort Depth;
|
public ushort Depth;
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
InvalidatedChildren.Clear();
|
InvalidatedChildren.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Active { get; set; }
|
||||||
private bool m_Working;
|
private bool m_Working;
|
||||||
public bool Working {
|
public bool Working {
|
||||||
get { return m_Working; }
|
get { return m_Working; }
|
||||||
@@ -63,16 +65,10 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
readonly RMVPool RMVPool = new RMVPool();
|
readonly RMVPool RMVPool = new RMVPool();
|
||||||
protected Dictionary<StampedEvent, RealtimeMotionValue> PlayingMotions = new Dictionary<StampedEvent, RealtimeMotionValue>();
|
readonly MotionCachePool MCPool = new MotionCachePool();
|
||||||
protected Dictionary<Identifier, RealtimeMotionValue> Values;
|
Dictionary<StampedEvent, RealtimeMotionValue> PlayingMotions = new Dictionary<StampedEvent, RealtimeMotionValue>(4);
|
||||||
protected Dictionary<Identifier, CacheEntry> CachedValues;
|
Dictionary<Identifier, RealtimeMotionValue> Values;
|
||||||
protected class CacheEntry {
|
Dictionary<Identifier, MotionCache> CachedValues;
|
||||||
public bool Valid { get; set; }
|
|
||||||
public Vector Value { get; set; }
|
|
||||||
public CacheEntry Clone() {
|
|
||||||
return new CacheEntry { Valid = Valid, Value = Value == null ? null : Value.Clone() };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a motion value.
|
/// Gets a motion value.
|
||||||
@@ -81,25 +77,19 @@ namespace Cryville.Crtr.Event {
|
|||||||
/// <param name="clone">Returns a cloned motion value instead.</param>
|
/// <param name="clone">Returns a cloned motion value instead.</param>
|
||||||
/// <returns>A motion value.</returns>
|
/// <returns>A motion value.</returns>
|
||||||
RealtimeMotionValue GetMotionValue(Identifier name, bool clone = false) {
|
RealtimeMotionValue GetMotionValue(Identifier name, bool clone = false) {
|
||||||
RealtimeMotionValue value;
|
RealtimeMotionValue value = Values[name];
|
||||||
if (!Values.TryGetValue(name, out value)) {
|
|
||||||
value = new RealtimeMotionValue().Init(Parent == null
|
|
||||||
? ChartPlayer.motionRegistry[name].GlobalInitValue
|
|
||||||
: ChartPlayer.motionRegistry[name].InitValue
|
|
||||||
);
|
|
||||||
Values.Add(name, value);
|
|
||||||
}
|
|
||||||
if (clone) return value.Clone();
|
if (clone) return value.Clone();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InvalidateMotion(Identifier name) {
|
void InvalidateMotion(Identifier name) {
|
||||||
CacheEntry cache;
|
MotionCache cache;
|
||||||
if (!CachedValues.TryGetValue(name, out cache))
|
if (!CachedValues.TryGetValue(name, out cache))
|
||||||
CachedValues.Add(name, cache = new CacheEntry());
|
CachedValues.Add(name, cache = MCPool.Rent(name));
|
||||||
cache.Valid = false;
|
cache.Valid = false;
|
||||||
foreach (var c in Children)
|
ValidateChildren();
|
||||||
c.Value.InvalidateMotion(name);
|
foreach (var c in WorkingChildren)
|
||||||
|
Children[c].InvalidateMotion(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerState(Chart c, EventContainer _ev, ContainerState parent = null) {
|
public ContainerState(Chart c, EventContainer _ev, ContainerState parent = null) {
|
||||||
@@ -111,7 +101,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Values = new Dictionary<Identifier, RealtimeMotionValue>(ChartPlayer.motionRegistry.Count);
|
Values = new Dictionary<Identifier, RealtimeMotionValue>(ChartPlayer.motionRegistry.Count);
|
||||||
CachedValues = new Dictionary<Identifier, CacheEntry>(ChartPlayer.motionRegistry.Count);
|
CachedValues = new Dictionary<Identifier, MotionCache>(ChartPlayer.motionRegistry.Count);
|
||||||
foreach (var m in ChartPlayer.motionRegistry)
|
foreach (var m in ChartPlayer.motionRegistry)
|
||||||
Values.Add(m.Key, new RealtimeMotionValue().Init(Parent == null ? m.Value.GlobalInitValue : m.Value.InitValue));
|
Values.Add(m.Key, new RealtimeMotionValue().Init(Parent == null ? m.Value.GlobalInitValue : m.Value.InitValue));
|
||||||
}
|
}
|
||||||
@@ -132,9 +122,11 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
r.Values = mvs;
|
r.Values = mvs;
|
||||||
|
|
||||||
var cvs = new Dictionary<Identifier, CacheEntry>(ChartPlayer.motionRegistry.Count);
|
var cvs = new Dictionary<Identifier, MotionCache>(ChartPlayer.motionRegistry.Count);
|
||||||
foreach (var cv in CachedValues) {
|
foreach (var cv in CachedValues) {
|
||||||
cvs.Add(cv.Key, cv.Value.Clone());
|
var dv = r.MCPool.Rent(cv.Key);
|
||||||
|
cv.Value.CopyTo(dv);
|
||||||
|
cvs.Add(cv.Key, dv);
|
||||||
}
|
}
|
||||||
r.CachedValues = cvs;
|
r.CachedValues = cvs;
|
||||||
|
|
||||||
@@ -145,7 +137,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
AddChild(child.Key, cc, r);
|
AddChild(child.Key, cc, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pms = new Dictionary<StampedEvent, RealtimeMotionValue>(PlayingMotions.Count);
|
var pms = new Dictionary<StampedEvent, RealtimeMotionValue>(Math.Max(4, PlayingMotions.Count));
|
||||||
foreach (var m in PlayingMotions)
|
foreach (var m in PlayingMotions)
|
||||||
pms.Add(m.Key, m.Value);
|
pms.Add(m.Key, m.Value);
|
||||||
r.PlayingMotions = pms;
|
r.PlayingMotions = pms;
|
||||||
@@ -171,20 +163,20 @@ namespace Cryville.Crtr.Event {
|
|||||||
else dest.Values.Add(mv.Key, mv.Value.Clone());
|
else dest.Values.Add(mv.Key, mv.Value.Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var cv in dest.CachedValues) cv.Value.Valid = false;
|
||||||
foreach (var cv in CachedValues) {
|
foreach (var cv in CachedValues) {
|
||||||
CacheEntry dv;
|
MotionCache dv;
|
||||||
if (dest.CachedValues.TryGetValue(cv.Key, out dv)) {
|
if (!dest.CachedValues.TryGetValue(cv.Key, out dv)) {
|
||||||
dv.Valid = cv.Value.Valid;
|
dest.CachedValues.Add(cv.Key, dv = dest.MCPool.Rent(cv.Key));
|
||||||
if (cv.Value.Value != null) cv.Value.Value.CopyTo(dv.Value);
|
|
||||||
}
|
}
|
||||||
else dest.CachedValues.Add(cv.Key, cv.Value.Clone());
|
cv.Value.CopyTo(dv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ct != 1) foreach (var cev in WorkingChildren)
|
if (ct != 1) foreach (var cev in WorkingChildren)
|
||||||
Children[cev].CopyTo(ct, dest.Children[cev]);
|
Children[cev].CopyTo(ct, dest.Children[cev]);
|
||||||
else foreach (var child in Children)
|
else foreach (var child in Children)
|
||||||
child.Value.CopyTo(ct, dest.Children[child.Key]);
|
child.Value.CopyTo(ct, dest.Children[child.Key]);
|
||||||
ValidateChildren();
|
dest.ValidateChildren();
|
||||||
|
|
||||||
dest.PlayingMotions.Clear();
|
dest.PlayingMotions.Clear();
|
||||||
foreach (var m in PlayingMotions) dest.PlayingMotions.Add(m.Key, m.Value);
|
foreach (var m in PlayingMotions) dest.PlayingMotions.Add(m.Key, m.Value);
|
||||||
@@ -201,6 +193,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
foreach (var s in Children)
|
foreach (var s in Children)
|
||||||
s.Value.Dispose();
|
s.Value.Dispose();
|
||||||
RMVPool.ReturnAll();
|
RMVPool.ReturnAll();
|
||||||
|
MCPool.ReturnAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AttachHandler(ContainerHandler h) {
|
public void AttachHandler(ContainerHandler h) {
|
||||||
@@ -215,11 +208,9 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Vector GetRawValue(Identifier key) {
|
public Vector GetRawValue(Identifier key) {
|
||||||
CacheEntry tr;
|
MotionCache tr;
|
||||||
if (!CachedValues.TryGetValue(key, out tr))
|
if (!CachedValues.TryGetValue(key, out tr))
|
||||||
CachedValues.Add(key, tr = new CacheEntry { Valid = false });
|
CachedValues.Add(key, tr = MCPool.Rent(key));
|
||||||
if (tr.Value == null)
|
|
||||||
tr.Value = RMVPool.Rent(key).AbsoluteValue;
|
|
||||||
Vector r = tr.Value;
|
Vector r = tr.Value;
|
||||||
#if !DISABLE_CACHE
|
#if !DISABLE_CACHE
|
||||||
if (tr.Valid) return r;
|
if (tr.Valid) return r;
|
||||||
@@ -317,7 +308,11 @@ namespace Cryville.Crtr.Event {
|
|||||||
Working = false;
|
Working = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(StampedEvent ev, Action<StampedEvent> callback = null) {
|
public void Discard(StampedEvent ev) {
|
||||||
|
Handler.Discard(this, ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Handle(StampedEvent ev) {
|
||||||
if (breakflag) return;
|
if (breakflag) return;
|
||||||
if (ev != null) {
|
if (ev != null) {
|
||||||
if (ev.Unstamped is Chart.Motion) {
|
if (ev.Unstamped is Chart.Motion) {
|
||||||
@@ -326,7 +321,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
mv.CloneTypeFlag = CloneType;
|
mv.CloneTypeFlag = CloneType;
|
||||||
GetMotionValue(tev.Name).CopyTo(mv);
|
GetMotionValue(tev.Name).CopyTo(mv);
|
||||||
PlayingMotions.Add(ev, mv);
|
PlayingMotions.Add(ev, mv);
|
||||||
Callback(ev, callback);
|
Update(ev);
|
||||||
if (!ev.Unstamped.IsLong) {
|
if (!ev.Unstamped.IsLong) {
|
||||||
PlayingMotions.Remove(ev);
|
PlayingMotions.Remove(ev);
|
||||||
RMVPool.Return(mv);
|
RMVPool.Return(mv);
|
||||||
@@ -338,7 +333,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
ccs.Working = true;
|
ccs.Working = true;
|
||||||
ccs.StartUpdate();
|
ccs.StartUpdate();
|
||||||
UpdateMotions();
|
UpdateMotions();
|
||||||
if (!ev.Unstamped.IsLong) {
|
if (!cev.IsLong) {
|
||||||
ccs.Working = false;
|
ccs.Working = false;
|
||||||
ccs.BroadcastEndUpdate();
|
ccs.BroadcastEndUpdate();
|
||||||
if (CloneType == 1) ccs.Dispose();
|
if (CloneType == 1) ccs.Dispose();
|
||||||
@@ -349,7 +344,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
if (tev.IsRelease) {
|
if (tev.IsRelease) {
|
||||||
var nev = tev.Original;
|
var nev = tev.Original;
|
||||||
if (nev is Chart.Motion) {
|
if (nev is Chart.Motion) {
|
||||||
Callback(ev, callback);
|
Update(ev);
|
||||||
var mv = PlayingMotions[ev.Origin];
|
var mv = PlayingMotions[ev.Origin];
|
||||||
if (mv.CloneTypeFlag == CloneType) RMVPool.Return(mv);
|
if (mv.CloneTypeFlag == CloneType) RMVPool.Return(mv);
|
||||||
PlayingMotions.Remove(ev.Origin);
|
PlayingMotions.Remove(ev.Origin);
|
||||||
@@ -364,15 +359,13 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Callback(ev.Unstamped == null || ev.Unstamped.Priority >= 0 ? ev : null, callback);
|
Update(ev.Unstamped == null || ev.Unstamped.Priority >= 0 ? ev : null);
|
||||||
}
|
}
|
||||||
else Callback(null, callback);
|
else Update(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Callback(StampedEvent ev, Action<StampedEvent> callback) {
|
void Update(StampedEvent ev) {
|
||||||
UpdateMotions();
|
UpdateMotions();
|
||||||
if (callback != null)
|
|
||||||
callback(ev);
|
|
||||||
if (ev == null || ev.Unstamped != null) Handler.Update(this, ev);
|
if (ev == null || ev.Unstamped != null) Handler.Update(this, ev);
|
||||||
else Handler.ExUpdate(this, ev);
|
else Handler.ExUpdate(this, ev);
|
||||||
foreach (var m in PlayingMotions)
|
foreach (var m in PlayingMotions)
|
||||||
|
@@ -9,124 +9,127 @@ namespace Cryville.Crtr.Event {
|
|||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
ContainerState RootState;
|
readonly Chart chart;
|
||||||
/// <summary>
|
ContainerState rootState;
|
||||||
/// event => the container state that handles the event
|
readonly Dictionary<ChartEvent, ContainerState> containerMap
|
||||||
/// </summary>
|
|
||||||
readonly Dictionary<ChartEvent, ContainerState> table
|
|
||||||
= new Dictionary<ChartEvent, ContainerState>();
|
= new Dictionary<ChartEvent, ContainerState>();
|
||||||
public List<StampedEvent> stampedEvents = new List<StampedEvent>();
|
readonly Dictionary<EventContainer, ContainerState> stateMap
|
||||||
|
= new Dictionary<EventContainer, ContainerState>();
|
||||||
|
readonly Dictionary<ChartEvent, StampedEvent> map
|
||||||
|
= new Dictionary<ChartEvent, StampedEvent>();
|
||||||
|
readonly Dictionary<EventContainer, List<StampedEvent>> coeventMap
|
||||||
|
= new Dictionary<EventContainer, List<StampedEvent>>();
|
||||||
|
readonly HashSet<ChartEvent> coevents = new HashSet<ChartEvent>();
|
||||||
|
readonly List<StampedEvent> stampedEvents = new List<StampedEvent>();
|
||||||
readonly List<EventBatch> batches = new List<EventBatch>();
|
readonly List<EventBatch> batches = new List<EventBatch>();
|
||||||
|
|
||||||
double beat;
|
double beat;
|
||||||
float tempo;
|
float tempo;
|
||||||
|
|
||||||
public EventBatcher(Chart c) : base(c, new List<ChartEvent>()) {
|
public EventBatcher(Chart c) : base(new List<ChartEvent>()) {
|
||||||
|
chart = c;
|
||||||
beat = chart.BeatPosition;
|
beat = chart.BeatPosition;
|
||||||
tempo = (float)c.sigs[0].tempo;
|
tempo = (float)c.sigs[0].tempo;
|
||||||
events.Add(c);
|
Events.Add(c);
|
||||||
events.Add(c.ReleaseEvent);
|
Events.Add(c.ReleaseEvent);
|
||||||
AddEventContainer(c);
|
AddEventContainer(c);
|
||||||
events.Sort((a, b) => a.BeatPosition.CompareTo(b.BeatPosition));
|
Events.Sort((a, b) => a.BeatPosition.CompareTo(b.BeatPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddEventContainer(EventContainer c, ContainerState parent = null) {
|
void AddEventContainer(EventContainer c, ContainerState parent = null) {
|
||||||
var cs = new ContainerState(chart, c, parent);
|
var cs = new ContainerState(chart, c, parent);
|
||||||
|
stateMap.Add(c, cs);
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
cs.Depth = 0;
|
cs.Depth = 0;
|
||||||
RootState = cs;
|
rootState = cs;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cs.Depth = (ushort)(parent.Depth + 1);
|
cs.Depth = (ushort)(parent.Depth + 1);
|
||||||
}
|
}
|
||||||
foreach (var ev in c.Events) {
|
foreach (var ev in c.Events) {
|
||||||
if (ev.time == null) {
|
if (ev.time == null) {
|
||||||
|
coevents.Add(ev);
|
||||||
ev.time = c.time;
|
ev.time = c.time;
|
||||||
if (ev is EventContainer)
|
if (ev is EventContainer)
|
||||||
ev.endtime = c.endtime;
|
ev.endtime = c.endtime;
|
||||||
}
|
}
|
||||||
if (ev.IsLong) {
|
if (ev.IsLong) {
|
||||||
events.Add(ev.ReleaseEvent);
|
Events.Add(ev.ReleaseEvent);
|
||||||
table.Add(ev.ReleaseEvent, cs);
|
containerMap.Add(ev.ReleaseEvent, cs);
|
||||||
}
|
}
|
||||||
events.Add(ev);
|
Events.Add(ev);
|
||||||
table.Add(ev, cs);
|
containerMap.Add(ev, cs);
|
||||||
if (ev is EventContainer)
|
if (ev is EventContainer)
|
||||||
AddEventContainer((EventContainer)ev, cs);
|
AddEventContainer((EventContainer)ev, cs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ForwardOnceToTime(double toTime, Action<ChartEvent> callback) {
|
public override void ForwardOnceToTime(double toTime) {
|
||||||
double toBeat = Math.Round(beat + (toTime - Time) * tempo / 60f, 6);
|
double toBeat = Math.Round(beat + (toTime - Time) * tempo / 60f, 6);
|
||||||
if (EventId >= events.Count)
|
if (EventId >= Events.Count)
|
||||||
goto return_ahead;
|
goto return_ahead;
|
||||||
double ebeat = events[EventId].BeatPosition;
|
double ebeat = Events[EventId].BeatPosition;
|
||||||
double etime = Math.Round((ebeat - beat) / tempo * 60f + Time, 6);
|
double etime = Math.Round((ebeat - beat) / tempo * 60f + Time, 6);
|
||||||
if (etime > toTime)
|
if (etime > toTime)
|
||||||
goto return_ahead;
|
goto return_ahead;
|
||||||
var batch = GetEventBatch();
|
var batch = GetEventBatch();
|
||||||
Time = etime;
|
Time = etime;
|
||||||
beat = ebeat;
|
beat = ebeat;
|
||||||
bool flag = false;
|
|
||||||
foreach (var ev in batch) {
|
foreach (var ev in batch) {
|
||||||
EventContainer con = null;
|
EventContainer con = null;
|
||||||
if (table.ContainsKey(ev)) con = table[ev].Container;
|
if (containerMap.ContainsKey(ev)) con = containerMap[ev].Container;
|
||||||
var sev = new StampedEvent() {
|
var sev = new StampedEvent() {
|
||||||
Time = etime,
|
Time = etime,
|
||||||
Unstamped = ev,
|
Unstamped = ev,
|
||||||
Container = con
|
Container = con
|
||||||
};
|
};
|
||||||
|
if (ev is EventContainer) {
|
||||||
|
stateMap[(EventContainer)ev].StampedContainer = sev;
|
||||||
|
}
|
||||||
if (ev is InstantEvent) {
|
if (ev is InstantEvent) {
|
||||||
var tev = (InstantEvent)ev;
|
var tev = (InstantEvent)ev;
|
||||||
var pev = stampedEvents.First(tpev => tpev.Unstamped == tev.Original);
|
var pev = map[tev.Original];
|
||||||
pev.Subevents.Add(sev);
|
pev.Subevents.Add(sev);
|
||||||
sev.Origin = pev;
|
sev.Origin = pev;
|
||||||
}
|
}
|
||||||
stampedEvents.Add(sev);
|
if (con != null && coevents.Contains(ev)) {
|
||||||
if (ev.Priority >= 0) {
|
List<StampedEvent> cevs;
|
||||||
if (callback != null) callback(ev);
|
if (!coeventMap.TryGetValue(con, out cevs)) {
|
||||||
flag = true;
|
coeventMap.Add(con, cevs = new List<StampedEvent>());
|
||||||
|
}
|
||||||
|
cevs.Add(sev);
|
||||||
}
|
}
|
||||||
|
else stampedEvents.Add(sev);
|
||||||
|
map.Add(ev, sev);
|
||||||
if (ev is Chart.Signature) {
|
if (ev is Chart.Signature) {
|
||||||
var tev = (Chart.Signature)ev;
|
var tev = (Chart.Signature)ev;
|
||||||
if (tev.tempo != null) tempo = (float)tev.tempo;
|
if (tev.tempo != null) tempo = (float)tev.tempo;
|
||||||
}
|
}
|
||||||
EventId++;
|
EventId++;
|
||||||
}
|
}
|
||||||
if (callback != null && !flag) callback(batch.First());
|
|
||||||
return;
|
return;
|
||||||
return_ahead:
|
return_ahead:
|
||||||
Time = toTime;
|
Time = toTime;
|
||||||
beat = toBeat;
|
beat = toBeat;
|
||||||
if (callback != null) callback(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IOrderedEnumerable<ChartEvent> GetEventBatch() {
|
IOrderedEnumerable<ChartEvent> GetEventBatch() {
|
||||||
float cbeat = events[EventId].BeatPosition;
|
float cbeat = Events[EventId].BeatPosition;
|
||||||
int b = EventId;
|
int b = EventId;
|
||||||
while (Mathf.Approximately(events[b].BeatPosition, cbeat)) {
|
while (Mathf.Approximately(Events[b].BeatPosition, cbeat)) {
|
||||||
b--;
|
b--;
|
||||||
if (b == -1) break;
|
if (b == -1) break;
|
||||||
}
|
}
|
||||||
int a = EventId;
|
int a = EventId;
|
||||||
while (Mathf.Approximately(events[a].BeatPosition, cbeat)) {
|
while (Mathf.Approximately(Events[a].BeatPosition, cbeat)) {
|
||||||
a++;
|
a++;
|
||||||
if (a == events.Count) break;
|
if (a == Events.Count) break;
|
||||||
}
|
}
|
||||||
return from ev in events.GetRange(b + 1, a - b - 1) orderby ev.Priority select ev;
|
return from ev in Events.GetRange(b + 1, a - b - 1) orderby ev.Priority select ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventBus Batch() {
|
public EventBus Batch() {
|
||||||
stampedEvents.Sort((a, b) => {
|
stampedEvents.Sort(CompareStampedEvents);
|
||||||
int u = a.CompareTo(b);
|
|
||||||
if (u != 0) return u;
|
|
||||||
if (a.Unstamped != null && b.Unstamped != null)
|
|
||||||
if (table.ContainsKey(a.Unstamped) && table.ContainsKey(b.Unstamped)) {
|
|
||||||
u = table[a.Unstamped].Depth.CompareTo(table[b.Unstamped].Depth);
|
|
||||||
if (u != 0) return u;
|
|
||||||
}
|
|
||||||
return a.GetHashCode().CompareTo(b.GetHashCode());
|
|
||||||
});
|
|
||||||
var cb = new EventBatch(stampedEvents[0].Time);
|
var cb = new EventBatch(stampedEvents[0].Time);
|
||||||
foreach (var ev in stampedEvents) {
|
foreach (var ev in stampedEvents) {
|
||||||
if (ev.Time != cb.Time) {
|
if (ev.Time != cb.Time) {
|
||||||
@@ -134,10 +137,36 @@ namespace Cryville.Crtr.Event {
|
|||||||
cb = new EventBatch(ev.Time);
|
cb = new EventBatch(ev.Time);
|
||||||
}
|
}
|
||||||
cb.Enqueue(ev);
|
cb.Enqueue(ev);
|
||||||
|
BatchCoevents(ev);
|
||||||
}
|
}
|
||||||
batches.Add(cb);
|
batches.Add(cb);
|
||||||
Bus = new EventBus(chart, RootState, batches);
|
Bus = new EventBus(rootState, batches);
|
||||||
return Bus;
|
return Bus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BatchCoevents(StampedEvent ev, List<StampedEvent> ocevs = null) {
|
||||||
|
if (!(ev.Unstamped is EventContainer)) return;
|
||||||
|
List<StampedEvent> cevs;
|
||||||
|
if (coeventMap.TryGetValue((EventContainer)ev.Unstamped, out cevs)) {
|
||||||
|
var rootFlag = ocevs == null;
|
||||||
|
if (rootFlag) ev.Coevents = ocevs = new List<StampedEvent>();
|
||||||
|
foreach (var cev in cevs) {
|
||||||
|
ocevs.Add(cev);
|
||||||
|
BatchCoevents(cev, ocevs);
|
||||||
|
}
|
||||||
|
if (rootFlag) ocevs.Sort(CompareStampedEvents);
|
||||||
|
else ocevs.Add(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int CompareStampedEvents(StampedEvent a, StampedEvent b) {
|
||||||
|
int u = a.CompareTo(b);
|
||||||
|
if (u != 0) return u;
|
||||||
|
if (a.Unstamped != null && b.Unstamped != null && containerMap.ContainsKey(a.Unstamped) && containerMap.ContainsKey(b.Unstamped)) {
|
||||||
|
u = containerMap[a.Unstamped].Depth.CompareTo(containerMap[b.Unstamped].Depth);
|
||||||
|
if (u != 0) return u;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,15 +11,14 @@ namespace Cryville.Crtr.Event {
|
|||||||
|
|
||||||
Dictionary<EventContainer, ContainerState> states
|
Dictionary<EventContainer, ContainerState> states
|
||||||
= new Dictionary<EventContainer, ContainerState>();
|
= new Dictionary<EventContainer, ContainerState>();
|
||||||
List<EventContainer> activeContainers
|
HashSet<EventContainer> activeContainers
|
||||||
= new List<EventContainer>();
|
= new HashSet<EventContainer>();
|
||||||
HashSet<ContainerState> workingStates
|
HashSet<ContainerState> workingStates
|
||||||
= new HashSet<ContainerState>();
|
= new HashSet<ContainerState>();
|
||||||
HashSet<ContainerState> invalidatedStates
|
HashSet<ContainerState> invalidatedStates
|
||||||
= new HashSet<ContainerState>();
|
= new HashSet<ContainerState>();
|
||||||
|
|
||||||
public EventBus(Chart c, ContainerState root, List<EventBatch> b)
|
public EventBus(ContainerState root, List<EventBatch> b) : base(b) {
|
||||||
: base(c, b) {
|
|
||||||
RootState = root;
|
RootState = root;
|
||||||
Expand();
|
Expand();
|
||||||
AttachBus();
|
AttachBus();
|
||||||
@@ -30,7 +29,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
var r = (EventBus)MemberwiseClone();
|
var r = (EventBus)MemberwiseClone();
|
||||||
r.prototype = this;
|
r.prototype = this;
|
||||||
r.states = new Dictionary<EventContainer, ContainerState>();
|
r.states = new Dictionary<EventContainer, ContainerState>();
|
||||||
r.activeContainers = new List<EventContainer>();
|
r.activeContainers = new HashSet<EventContainer>();
|
||||||
r.workingStates = new HashSet<ContainerState>();
|
r.workingStates = new HashSet<ContainerState>();
|
||||||
r.invalidatedStates = new HashSet<ContainerState>();
|
r.invalidatedStates = new HashSet<ContainerState>();
|
||||||
r.tempEvents = new List<StampedEvent>();
|
r.tempEvents = new List<StampedEvent>();
|
||||||
@@ -86,8 +85,18 @@ namespace Cryville.Crtr.Event {
|
|||||||
|
|
||||||
void EnsureActivity(EventContainer c) {
|
void EnsureActivity(EventContainer c) {
|
||||||
if (activeContainers.Contains(c)) return;
|
if (activeContainers.Contains(c)) return;
|
||||||
if (RootState.CloneType >= 2) prototype.states[c].CopyTo(RootState.CloneType, states[c]);
|
var state = states[c];
|
||||||
|
if (state.Parent != null) EnsureActivity(state.Parent.Container);
|
||||||
|
if (RootState.CloneType >= 2) prototype.states[c].CopyTo(RootState.CloneType, state);
|
||||||
|
state.Active = true;
|
||||||
activeContainers.Add(c);
|
activeContainers.Add(c);
|
||||||
|
|
||||||
|
if (state.StampedContainer.Coevents == null) return;
|
||||||
|
foreach (var cev in state.StampedContainer.Coevents) {
|
||||||
|
if (cev.Container == null) continue;
|
||||||
|
EnsureActivity(cev.Container);
|
||||||
|
states[cev.Container].Handle(cev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachBus() {
|
void AttachBus() {
|
||||||
@@ -107,8 +116,22 @@ namespace Cryville.Crtr.Event {
|
|||||||
tempEvents.Insert(index, ev);
|
tempEvents.Insert(index, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ForwardOnceToTime(double toTime, Action<EventBatch> callback = null) {
|
readonly StampedEvent _dummyEvent = new StampedEvent();
|
||||||
double time1 = EventId < events.Count ? events[EventId].Time : double.PositiveInfinity;
|
public void StripTempEvents() {
|
||||||
|
_dummyEvent.Time = Time;
|
||||||
|
var index = tempEvents.BinarySearch(_dummyEvent);
|
||||||
|
if (index < 0) index = ~index;
|
||||||
|
for (var i = 0; i < index; i++) {
|
||||||
|
var ev = tempEvents[i];
|
||||||
|
if (ev.Container != null) {
|
||||||
|
states[ev.Container].Discard(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tempEvents.RemoveRange(0, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ForwardOnceToTime(double toTime) {
|
||||||
|
double time1 = EventId < Events.Count ? Events[EventId].Time : double.PositiveInfinity;
|
||||||
double time2 = tempEvents.Count > 0 ? tempEvents[0].Time : double.PositiveInfinity;
|
double time2 = tempEvents.Count > 0 ? tempEvents[0].Time : double.PositiveInfinity;
|
||||||
double time0 = Math.Min(time1, time2);
|
double time0 = Math.Min(time1, time2);
|
||||||
if (time0 <= toTime && time0 != double.PositiveInfinity) {
|
if (time0 <= toTime && time0 != double.PositiveInfinity) {
|
||||||
@@ -116,22 +139,22 @@ namespace Cryville.Crtr.Event {
|
|||||||
foreach (var s in workingStates) s.Handle(null);
|
foreach (var s in workingStates) s.Handle(null);
|
||||||
ValidateStates();
|
ValidateStates();
|
||||||
if (time1 == time0) {
|
if (time1 == time0) {
|
||||||
var batch = events[EventId];
|
var batch = Events[EventId];
|
||||||
for (var i = 0; i < batch.Count; i++) {
|
for (var i = 0; i < batch.Count; i++) {
|
||||||
var ev = batch[i];
|
var ev = batch[i];
|
||||||
if (ev.Container != null) {
|
if (ev.Container != null) {
|
||||||
EnsureActivity(ev.Container);
|
if (ev.Unstamped is EventContainer) EnsureActivity((EventContainer)ev.Unstamped);
|
||||||
|
else EnsureActivity(ev.Container);
|
||||||
states[ev.Container].Handle(ev);
|
states[ev.Container].Handle(ev);
|
||||||
}
|
}
|
||||||
if (ev.Unstamped is EventContainer) {
|
else if (ev.Coevents != null) EnsureActivity((EventContainer)ev.Unstamped);
|
||||||
if (ev.Container != null) EnsureActivity((EventContainer)ev.Unstamped);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EventId++;
|
EventId++;
|
||||||
}
|
}
|
||||||
if (time2 == time0) {
|
if (time2 == time0) {
|
||||||
while (tempEvents.Count > 0) {
|
while (tempEvents.Count > 0) {
|
||||||
var ev = tempEvents[0];
|
var ev = tempEvents[0];
|
||||||
|
if (ev.Time != time0) break;
|
||||||
if (ev.Container != null) {
|
if (ev.Container != null) {
|
||||||
EnsureActivity(ev.Container);
|
EnsureActivity(ev.Container);
|
||||||
states[ev.Container].Handle(ev);
|
states[ev.Container].Handle(ev);
|
||||||
|
55
Assets/Cryville/Crtr/Event/MotionCache.cs
Normal file
55
Assets/Cryville/Crtr/Event/MotionCache.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using Cryville.Common;
|
||||||
|
using Cryville.Common.Buffers;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Cryville.Crtr.Event {
|
||||||
|
internal class MotionCache {
|
||||||
|
public bool Valid { get; set; }
|
||||||
|
public Vector Value { get; set; }
|
||||||
|
public void CopyTo(MotionCache dest) {
|
||||||
|
dest.Valid = Valid;
|
||||||
|
Value.CopyTo(dest.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal class MotionCachePool {
|
||||||
|
private class Bucket : ObjectPool<MotionCache> {
|
||||||
|
readonly MotionRegistry _reg;
|
||||||
|
public Bucket(string name, int capacity) : base(capacity) {
|
||||||
|
_reg = ChartPlayer.motionRegistry[name];
|
||||||
|
}
|
||||||
|
protected override MotionCache Construct() {
|
||||||
|
var result = new MotionCache();
|
||||||
|
result.Value = (Vector)ReflectionHelper.InvokeEmptyConstructor(_reg.Type);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static Dictionary<Identifier, Bucket> _buckets;
|
||||||
|
public static void Prepare() {
|
||||||
|
_buckets = new Dictionary<Identifier, Bucket>(ChartPlayer.motionRegistry.Count);
|
||||||
|
foreach (var reg in ChartPlayer.motionRegistry)
|
||||||
|
_buckets.Add(reg.Key, new Bucket(reg.Key, 4096));
|
||||||
|
}
|
||||||
|
|
||||||
|
static readonly SimpleObjectPool<Dictionary<MotionCache, Identifier>> _dictPool
|
||||||
|
= new SimpleObjectPool<Dictionary<MotionCache, Identifier>>(1024);
|
||||||
|
Dictionary<MotionCache, Identifier> _rented;
|
||||||
|
public MotionCache Rent(Identifier name) {
|
||||||
|
var obj = _buckets[name].Rent();
|
||||||
|
obj.Valid = false;
|
||||||
|
if (_rented == null) _rented = _dictPool.Rent();
|
||||||
|
_rented.Add(obj, name);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
public void Return(MotionCache obj) {
|
||||||
|
_buckets[_rented[obj]].Return(obj);
|
||||||
|
_rented.Remove(obj);
|
||||||
|
}
|
||||||
|
public void ReturnAll() {
|
||||||
|
if (_rented == null) return;
|
||||||
|
foreach (var obj in _rented)
|
||||||
|
_buckets[obj.Value].Return(obj.Key);
|
||||||
|
_rented.Clear();
|
||||||
|
_dictPool.Return(_rented);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Cryville/Crtr/Event/MotionCache.cs.meta
Normal file
11
Assets/Cryville/Crtr/Event/MotionCache.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5d11b50a98974254f87273c94ed20de7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@@ -24,10 +24,9 @@ namespace Cryville.Crtr.Event {
|
|||||||
= new SimpleObjectPool<Dictionary<RealtimeMotionValue, Identifier>>(1024);
|
= new SimpleObjectPool<Dictionary<RealtimeMotionValue, Identifier>>(1024);
|
||||||
Dictionary<RealtimeMotionValue, Identifier> _rented;
|
Dictionary<RealtimeMotionValue, Identifier> _rented;
|
||||||
public RealtimeMotionValue Rent(Identifier name) {
|
public RealtimeMotionValue Rent(Identifier name) {
|
||||||
var n = name;
|
var obj = _buckets[name].Rent();
|
||||||
var obj = _buckets[n].Rent();
|
|
||||||
if (_rented == null) _rented = _dictPool.Rent();
|
if (_rented == null) _rented = _dictPool.Rent();
|
||||||
_rented.Add(obj, n);
|
_rented.Add(obj, name);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
public void Return(RealtimeMotionValue obj) {
|
public void Return(RealtimeMotionValue obj) {
|
||||||
@@ -35,6 +34,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
_rented.Remove(obj);
|
_rented.Remove(obj);
|
||||||
}
|
}
|
||||||
public void ReturnAll() {
|
public void ReturnAll() {
|
||||||
|
if (_rented == null) return;
|
||||||
foreach (var obj in _rented)
|
foreach (var obj in _rented)
|
||||||
_buckets[obj.Value].Return(obj.Key);
|
_buckets[obj.Value].Return(obj.Key);
|
||||||
_rented.Clear();
|
_rented.Clear();
|
||||||
|
@@ -73,16 +73,19 @@ namespace Cryville.Crtr.Extensions.Bestdori {
|
|||||||
};
|
};
|
||||||
for (int i = 0; i < tev.connections.Count; i++) {
|
for (int i = 0; i < tev.connections.Count; i++) {
|
||||||
BestdoriChartEvent.Connection c = tev.connections[i];
|
BestdoriChartEvent.Connection c = tev.connections[i];
|
||||||
|
var motion = new Chart.Motion { motion = "track:" + c.lane.ToString(CultureInfo.InvariantCulture) };
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
note.judges.Add(new Chart.Judge { name = "single" });
|
note.judges.Add(new Chart.Judge { name = "single" });
|
||||||
note.motions.Add(new Chart.Motion { motion = "track:" + c.lane.ToString(CultureInfo.InvariantCulture) });
|
note.motions.Add(motion);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
note.motions.Add(new Chart.Motion { time = ToBeatTime(tev.connections[i - 1].beat), endtime = ToBeatTime(c.beat), motion = "track:" + c.lane.ToString(CultureInfo.InvariantCulture) });
|
var cbeat = motion.endtime = ToBeatTime(c.beat);
|
||||||
|
if (i > 1) motion.time = ToBeatTime(tev.connections[i - 1].beat);
|
||||||
|
note.motions.Add(motion);
|
||||||
if (i == tev.connections.Count - 1)
|
if (i == tev.connections.Count - 1)
|
||||||
note.judges.Add(new Chart.Judge { time = ToBeatTime(c.beat), name = c.flick ? "longend_flick" : "longend" });
|
note.judges.Add(new Chart.Judge { time = cbeat, name = c.flick ? "longend_flick" : "longend" });
|
||||||
else if (!c.hidden)
|
else if (!c.hidden)
|
||||||
note.judges.Add(new Chart.Judge { time = ToBeatTime(c.beat), name = "longnode" });
|
note.judges.Add(new Chart.Judge { time = cbeat, name = "longnode" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c1.beat > endbeat) endbeat = c1.beat;
|
if (c1.beat > endbeat) endbeat = c1.beat;
|
||||||
|
@@ -65,10 +65,6 @@ namespace Cryville.Crtr {
|
|||||||
if (_use[target] > 0)
|
if (_use[target] > 0)
|
||||||
throw new InvalidOperationException("Input already assigned");
|
throw new InvalidOperationException("Input already assigned");
|
||||||
if (proxy.Source != null) {
|
if (proxy.Source != null) {
|
||||||
if (_judge != null) {
|
|
||||||
proxy.Source.Value.Handler.OnInput -= OnInput; // Prevent duplicated hooks, no exception will be thrown
|
|
||||||
proxy.Source.Value.Handler.OnInput += OnInput;
|
|
||||||
}
|
|
||||||
_tproxies.Add(target, proxy);
|
_tproxies.Add(target, proxy);
|
||||||
_sproxies.Add(proxy.Source.Value, proxy);
|
_sproxies.Add(proxy.Source.Value, proxy);
|
||||||
IncrementUseRecursive(target);
|
IncrementUseRecursive(target);
|
||||||
@@ -77,7 +73,6 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
void Remove(InputProxyEntry proxy) {
|
void Remove(InputProxyEntry proxy) {
|
||||||
var target = proxy.Target;
|
var target = proxy.Target;
|
||||||
if (_judge != null) _tproxies[target].Source.Value.Handler.OnInput -= OnInput;
|
|
||||||
_sproxies.Remove(_tproxies[target].Source.Value);
|
_sproxies.Remove(_tproxies[target].Source.Value);
|
||||||
_tproxies.Remove(target);
|
_tproxies.Remove(target);
|
||||||
DecrementUseRecursive(target);
|
DecrementUseRecursive(target);
|
||||||
@@ -142,12 +137,22 @@ namespace Cryville.Crtr {
|
|||||||
public void Activate() {
|
public void Activate() {
|
||||||
_activeCounts.Clear();
|
_activeCounts.Clear();
|
||||||
_vect.Clear(); _vecs.Clear();
|
_vect.Clear(); _vecs.Clear();
|
||||||
foreach (var src in _sproxies.Keys) {
|
foreach (var src in _sproxies) {
|
||||||
_activeCounts.Add(src, 0);
|
_activeCounts.Add(src.Key, 0);
|
||||||
src.Handler.Activate();
|
var isrc = src.Value.Source;
|
||||||
|
if (isrc != null) {
|
||||||
|
isrc.Value.Handler.OnInput += OnInput;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Deactivate() {
|
||||||
|
foreach (var src in _sproxies) {
|
||||||
|
var isrc = src.Value.Source;
|
||||||
|
if (isrc != null) {
|
||||||
|
isrc.Value.Handler.OnInput -= OnInput;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Deactivate() { foreach (var src in _sproxies.Keys) src.Handler.Deactivate(); }
|
|
||||||
|
|
||||||
~InputProxy() {
|
~InputProxy() {
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
@@ -173,7 +178,7 @@ namespace Cryville.Crtr {
|
|||||||
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
|
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
|
||||||
readonly Dictionary<InputSource, int> _activeCounts = new Dictionary<InputSource, int>();
|
readonly Dictionary<InputSource, int> _activeCounts = new Dictionary<InputSource, int>();
|
||||||
readonly Dictionary<InputIdentifier, float> _vect = new Dictionary<InputIdentifier, float>();
|
readonly Dictionary<InputIdentifier, float> _vect = new Dictionary<InputIdentifier, float>();
|
||||||
readonly Dictionary<ProxiedInputIdentifier, PropSrc.Arbitrary> _vecs = new Dictionary<ProxiedInputIdentifier, PropSrc.Arbitrary>();
|
readonly Dictionary<ProxiedInputIdentifier, PropSrc> _vecs = new Dictionary<ProxiedInputIdentifier, PropSrc>();
|
||||||
static readonly PropSrc.Arbitrary _nullsrc = new PropSrc.Arbitrary(PdtInternalType.Null, new byte[0]);
|
static readonly PropSrc.Arbitrary _nullsrc = new PropSrc.Arbitrary(PdtInternalType.Null, new byte[0]);
|
||||||
unsafe void OnInput(InputIdentifier id, InputVector vec) {
|
unsafe void OnInput(InputIdentifier id, InputVector vec) {
|
||||||
lock (_lock) {
|
lock (_lock) {
|
||||||
@@ -214,7 +219,7 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var pid = new ProxiedInputIdentifier { Source = id, Target = target };
|
var pid = new ProxiedInputIdentifier { Source = id, Target = target };
|
||||||
PropSrc.Arbitrary fv, tv = _etor.ContextCascadeLookup(_var_value);
|
PropSrc fv, tv = _etor.ContextCascadeLookup(_var_value);
|
||||||
if (!_vecs.TryGetValue(pid, out fv)) fv = _nullsrc;
|
if (!_vecs.TryGetValue(pid, out fv)) fv = _nullsrc;
|
||||||
if (fv.Type != PdtInternalType.Null || tv.Type != PdtInternalType.Null) {
|
if (fv.Type != PdtInternalType.Null || tv.Type != PdtInternalType.Null) {
|
||||||
if (fv.Type == PdtInternalType.Null) _activeCounts[id.Source]++;
|
if (fv.Type == PdtInternalType.Null) _activeCounts[id.Source]++;
|
||||||
|
@@ -21,7 +21,7 @@ namespace Cryville.Crtr {
|
|||||||
public double EndTime { get; set; }
|
public double EndTime { get; set; }
|
||||||
public double StartClip { get; set; }
|
public double StartClip { get; set; }
|
||||||
public double EndClip { get; set; }
|
public double EndClip { get; set; }
|
||||||
public Identifier JudgeId { get; set; }
|
public Chart.Judge BaseEvent { get; set; }
|
||||||
public JudgeDefinition Definition { get; set; }
|
public JudgeDefinition Definition { get; set; }
|
||||||
public NoteHandler Handler { get; set; }
|
public NoteHandler Handler { get; set; }
|
||||||
}
|
}
|
||||||
@@ -37,20 +37,24 @@ namespace Cryville.Crtr {
|
|||||||
InitJudges();
|
InitJudges();
|
||||||
InitScores();
|
InitScores();
|
||||||
}
|
}
|
||||||
public void Prepare(double st, double et, Identifier input, Identifier judge, NoteHandler handler) {
|
public void Prepare(StampedEvent sev, NoteHandler handler) {
|
||||||
|
var tev = (Chart.Judge)sev.Unstamped;
|
||||||
|
Identifier input = default(Identifier);
|
||||||
|
ChartPlayer.etor.Evaluate(new PropOp.Identifier(v => input = new Identifier(v)), _rs.judges[tev.Id].input);
|
||||||
|
double st = sev.Time, et = st + sev.Duration;
|
||||||
List<JudgeEvent> list;
|
List<JudgeEvent> list;
|
||||||
if (!evs.TryGetValue(input, out list)) {
|
if (!evs.TryGetValue(input, out list)) {
|
||||||
ct.Add(input, 0);
|
ct.Add(input, 0);
|
||||||
evs.Add(input, list = new List<JudgeEvent>());
|
evs.Add(input, list = new List<JudgeEvent>());
|
||||||
activeEvs.Add(input, new List<JudgeEvent>());
|
activeEvs.Add(input, new List<JudgeEvent>());
|
||||||
}
|
}
|
||||||
var def = _rs.judges[judge];
|
var def = _rs.judges[tev.Id];
|
||||||
var ev = new JudgeEvent {
|
var ev = new JudgeEvent {
|
||||||
StartTime = st,
|
StartTime = st,
|
||||||
EndTime = et,
|
EndTime = et,
|
||||||
StartClip = st + def.clip[0],
|
StartClip = st + def.clip[0],
|
||||||
EndClip = et + def.clip[1],
|
EndClip = et + def.clip[1],
|
||||||
JudgeId = judge,
|
BaseEvent = tev,
|
||||||
Definition = def,
|
Definition = def,
|
||||||
Handler = handler,
|
Handler = handler,
|
||||||
};
|
};
|
||||||
@@ -60,10 +64,12 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Judge
|
#region Judge
|
||||||
|
internal readonly Dictionary<int, int> judgeMap = new Dictionary<int, int>();
|
||||||
internal readonly Dictionary<int, int> jtabsMap = new Dictionary<int, int>();
|
internal readonly Dictionary<int, int> jtabsMap = new Dictionary<int, int>();
|
||||||
internal readonly Dictionary<int, int> jtrelMap = new Dictionary<int, int>();
|
internal readonly Dictionary<int, int> jtrelMap = new Dictionary<int, int>();
|
||||||
void InitJudges() {
|
void InitJudges() {
|
||||||
foreach (var i in _rs.judges.Keys) {
|
foreach (var i in _rs.judges.Keys) {
|
||||||
|
judgeMap.Add(i.Key, IdentifierManager.SharedInstance.Request("judge_" + i.Name));
|
||||||
jtabsMap.Add(i.Key, IdentifierManager.SharedInstance.Request("jtabs_" + i.Name));
|
jtabsMap.Add(i.Key, IdentifierManager.SharedInstance.Request("jtabs_" + i.Name));
|
||||||
jtrelMap.Add(i.Key, IdentifierManager.SharedInstance.Request("jtrel_" + i.Name));
|
jtrelMap.Add(i.Key, IdentifierManager.SharedInstance.Request("jtrel_" + i.Name));
|
||||||
}
|
}
|
||||||
@@ -246,7 +252,8 @@ namespace Cryville.Crtr {
|
|||||||
readonly Func<string> _cb;
|
readonly Func<string> _cb;
|
||||||
readonly ArrayPool<byte> _pool;
|
readonly ArrayPool<byte> _pool;
|
||||||
byte[] _buf;
|
byte[] _buf;
|
||||||
public ScoreStringSrc(ArrayPool<byte> pool, Func<string> cb) {
|
public ScoreStringSrc(ArrayPool<byte> pool, Func<string> cb)
|
||||||
|
: base(PdtInternalType.String) {
|
||||||
_pool = pool;
|
_pool = pool;
|
||||||
_cb = cb;
|
_cb = cb;
|
||||||
}
|
}
|
||||||
@@ -257,7 +264,7 @@ namespace Cryville.Crtr {
|
|||||||
_buf = null;
|
_buf = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override unsafe int InternalGet() {
|
protected override unsafe void InternalGet() {
|
||||||
var src = _cb();
|
var src = _cb();
|
||||||
int strlen = src.Length;
|
int strlen = src.Length;
|
||||||
buf = _pool.Rent(sizeof(int) + strlen * sizeof(char));
|
buf = _pool.Rent(sizeof(int) + strlen * sizeof(char));
|
||||||
@@ -267,7 +274,6 @@ namespace Cryville.Crtr {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var c in src) ptr[i++] = c;
|
foreach (var c in src) ptr[i++] = c;
|
||||||
}
|
}
|
||||||
return PdtInternalType.String;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@@ -351,6 +351,8 @@ namespace Cryville.Crtr {
|
|||||||
public abstract class Vector : IComparable<Vector> {
|
public abstract class Vector : IComparable<Vector> {
|
||||||
public Vector() { }
|
public Vector() { }
|
||||||
|
|
||||||
|
public abstract byte Dimension { get; }
|
||||||
|
|
||||||
public abstract int CompareTo(Vector other);
|
public abstract int CompareTo(Vector other);
|
||||||
|
|
||||||
public abstract void ApplyFrom(Vector parent);
|
public abstract void ApplyFrom(Vector parent);
|
||||||
@@ -392,6 +394,8 @@ namespace Cryville.Crtr {
|
|||||||
Value = i;
|
Value = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override byte Dimension { get { return 1; } }
|
||||||
|
|
||||||
public override int CompareTo(Vector other) {
|
public override int CompareTo(Vector other) {
|
||||||
return CompareTo((Vec1)other);
|
return CompareTo((Vec1)other);
|
||||||
}
|
}
|
||||||
@@ -457,6 +461,8 @@ namespace Cryville.Crtr {
|
|||||||
Value = i;
|
Value = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override byte Dimension { get { return 1; } }
|
||||||
|
|
||||||
public override int CompareTo(Vector other) {
|
public override int CompareTo(Vector other) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -517,6 +523,8 @@ namespace Cryville.Crtr {
|
|||||||
Value = i;
|
Value = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override byte Dimension { get { return 1; } }
|
||||||
|
|
||||||
public override int CompareTo(Vector other) {
|
public override int CompareTo(Vector other) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -578,6 +586,8 @@ namespace Cryville.Crtr {
|
|||||||
this.h = h;
|
this.h = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override byte Dimension { get { return 2; } }
|
||||||
|
|
||||||
public static void Parse(string s, out float? w, out float? h) {
|
public static void Parse(string s, out float? w, out float? h) {
|
||||||
string[] c = s.Split('+');
|
string[] c = s.Split('+');
|
||||||
float rw = 0, rh = 0;
|
float rw = 0, rh = 0;
|
||||||
@@ -697,6 +707,8 @@ namespace Cryville.Crtr {
|
|||||||
this.x = x; this.y = y; this.z = z;
|
this.x = x; this.y = y; this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override byte Dimension { get { return 3; } }
|
||||||
|
|
||||||
public override int CompareTo(Vector other) {
|
public override int CompareTo(Vector other) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -773,6 +785,8 @@ namespace Cryville.Crtr {
|
|||||||
this.xw = xw; this.xh = xh; this.yw = yw; this.yh = yh;
|
this.xw = xw; this.xh = xh; this.yw = yw; this.yh = yh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override byte Dimension { get { return 4; } }
|
||||||
|
|
||||||
public override int CompareTo(Vector other) {
|
public override int CompareTo(Vector other) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -852,6 +866,8 @@ namespace Cryville.Crtr {
|
|||||||
this.xw = xw; this.xh = xh; this.yw = yw; this.yh = yh; this.z = z;
|
this.xw = xw; this.xh = xh; this.yw = yw; this.yh = yh; this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override byte Dimension { get { return 5; } }
|
||||||
|
|
||||||
public override int CompareTo(Vector other) {
|
public override int CompareTo(Vector other) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -925,19 +941,27 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VectorSrc : PropSrc {
|
public abstract class VectorSrc : PropSrc {
|
||||||
readonly Func<Vector> _cb;
|
protected readonly Func<Vector> _cb;
|
||||||
public VectorSrc(Func<Vector> cb) { _cb = cb; }
|
public VectorSrc(Func<Vector> cb, int type) : base(type) { _cb = cb; }
|
||||||
protected override unsafe int InternalGet() {
|
public static VectorSrc Construct(Func<Vector> cb) {
|
||||||
var arr = _cb().ToArray();
|
if (cb().Dimension == 1) return new INumber(cb);
|
||||||
if (arr.Length == 1) {
|
else return new IVector(cb);
|
||||||
|
}
|
||||||
|
class INumber : VectorSrc {
|
||||||
|
public INumber(Func<Vector> cb) : base(cb, PdtInternalType.Number) { }
|
||||||
|
protected override unsafe void InternalGet() {
|
||||||
|
var arr = _cb().ToArray();
|
||||||
buf = new byte[sizeof(float)];
|
buf = new byte[sizeof(float)];
|
||||||
fixed (byte* ptr = buf) {
|
fixed (byte* ptr = buf) {
|
||||||
*(float*)ptr = arr[0];
|
*(float*)ptr = arr[0];
|
||||||
}
|
}
|
||||||
return PdtInternalType.Number;
|
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
|
class IVector : VectorSrc {
|
||||||
|
public IVector(Func<Vector> cb) : base(cb, PdtInternalType.Vector) { }
|
||||||
|
protected override unsafe void InternalGet() {
|
||||||
|
var arr = _cb().ToArray();
|
||||||
buf = new byte[sizeof(float) * arr.Length + sizeof(int)];
|
buf = new byte[sizeof(float) * arr.Length + sizeof(int)];
|
||||||
fixed (byte* rptr = buf) {
|
fixed (byte* rptr = buf) {
|
||||||
var ptr = (float*)rptr;
|
var ptr = (float*)rptr;
|
||||||
@@ -946,7 +970,6 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
*(int*)ptr = PdtInternalType.Number;
|
*(int*)ptr = PdtInternalType.Number;
|
||||||
}
|
}
|
||||||
return PdtInternalType.Vector;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,11 +10,9 @@ namespace Cryville.Crtr {
|
|||||||
public class NoteHandler : ContainerHandler {
|
public class NoteHandler : ContainerHandler {
|
||||||
readonly GroupHandler gh;
|
readonly GroupHandler gh;
|
||||||
public readonly Chart.Note Event;
|
public readonly Chart.Note Event;
|
||||||
readonly PdtRuleset ruleset;
|
public NoteHandler(Chart.Note ev, GroupHandler gh) : base() {
|
||||||
public NoteHandler(GroupHandler gh, Chart.Note ev, PdtRuleset rs) : base() {
|
|
||||||
this.gh = gh;
|
|
||||||
Event = ev;
|
Event = ev;
|
||||||
ruleset = rs;
|
this.gh = gh;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string TypeName {
|
public override string TypeName {
|
||||||
@@ -24,43 +22,69 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SectionalGameObject[] sgos;
|
SectionalGameObject[] sgos;
|
||||||
readonly Dictionary<Identifier, JudgeState> judges = new Dictionary<Identifier, JudgeState>();
|
readonly Dictionary<Chart.Judge, JudgeState> judges = new Dictionary<Chart.Judge, JudgeState>();
|
||||||
|
readonly Dictionary<int, DynamicJudgeAnchorPair> dynJudgeAnchors = new Dictionary<int, DynamicJudgeAnchorPair>();
|
||||||
class JudgeState {
|
class JudgeState {
|
||||||
public int AbsoluteAnchorName { get; set; }
|
static readonly int _var_judge_result = IdentifierManager.SharedInstance.Request("judge_result");
|
||||||
public int RelativeAnchorName { get; set; }
|
public Anchor StaticAnchor { get; private set; }
|
||||||
|
public DynamicJudgeAnchorPair DynamicAnchors { get; private set; }
|
||||||
public bool Judged { get; private set; }
|
public bool Judged { get; private set; }
|
||||||
public float AbsoluteTime { get; private set; }
|
public float AbsoluteTime { get; private set; }
|
||||||
public float RelativeTime { get; private set; }
|
public float RelativeTime { get; private set; }
|
||||||
|
int _result = 0;
|
||||||
|
PropSrc _resultPropSrc;
|
||||||
public JudgeState(NoteHandler handler, int name) {
|
public JudgeState(NoteHandler handler, int name) {
|
||||||
handler.RegisterAnchor(AbsoluteAnchorName = handler.judge.jtabsMap[name]);
|
StaticAnchor = handler.RegisterAnchor(handler.judge.judgeMap[name], true);
|
||||||
handler.RegisterAnchor(RelativeAnchorName = handler.judge.jtrelMap[name]);
|
DynamicAnchors = handler.GetDynamicJudgeAnchorPair(name);
|
||||||
}
|
}
|
||||||
public void MarkJudged(float abs, float rel) {
|
public void MarkJudged(float abs, float rel, int result) {
|
||||||
Judged = true;
|
Judged = true;
|
||||||
AbsoluteTime = abs;
|
AbsoluteTime = abs;
|
||||||
RelativeTime = rel;
|
RelativeTime = rel;
|
||||||
|
_result = result;
|
||||||
|
_resultPropSrc.Invalidate();
|
||||||
}
|
}
|
||||||
|
public void InitPropSrcs() {
|
||||||
|
StaticAnchor.PropSrcs.Add(_var_judge_result, _resultPropSrc = new PropSrc.Identifier(() => _result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class DynamicJudgeAnchorPair {
|
||||||
|
public Anchor Absolute { get; private set; }
|
||||||
|
public Anchor Relative { get; private set; }
|
||||||
|
public DynamicJudgeAnchorPair(Anchor absolute, Anchor relative) {
|
||||||
|
Absolute = absolute;
|
||||||
|
Relative = relative;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DynamicJudgeAnchorPair GetDynamicJudgeAnchorPair(int name) {
|
||||||
|
DynamicJudgeAnchorPair result;
|
||||||
|
if (!dynJudgeAnchors.TryGetValue(name, out result)) {
|
||||||
|
dynJudgeAnchors.Add(name, result = new DynamicJudgeAnchorPair(
|
||||||
|
RegisterAnchor(judge.jtabsMap[name]),
|
||||||
|
RegisterAnchor(judge.jtrelMap[name])
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PreInit() {
|
public override void PreInit() {
|
||||||
base.PreInit();
|
base.PreInit();
|
||||||
foreach (var j in Event.judges) {
|
foreach (var j in Event.judges) {
|
||||||
if (!judges.ContainsKey(j.Id)) {
|
judges.Add(j, new JudgeState(this, j.Id.Key));
|
||||||
judges.Add(j.Id, new JudgeState(this, j.Id.Key));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
base.Init();
|
base.Init();
|
||||||
sgos = gogroup.GetComponentsInChildren<SectionalGameObject>();
|
sgos = gogroup.GetComponentsInChildren<SectionalGameObject>();
|
||||||
|
foreach (var judge in judges.Values) judge.InitPropSrcs();
|
||||||
}
|
}
|
||||||
protected override void PreAwake(ContainerState s) {
|
protected override void PreAwake(ContainerState s) {
|
||||||
base.PreAwake(s);
|
base.PreAwake(s);
|
||||||
#if UNITY_5_6_OR_NEWER
|
#if UNITY_5_6_OR_NEWER
|
||||||
a_head.SetPositionAndRotation(Position = GetFramePoint(s.Parent, s.Track), Rotation = GetFrameRotation(s.Parent, s.Track));
|
a_head.Transform.SetPositionAndRotation(Position = GetFramePoint(s.Parent, s.Track), Rotation = GetFrameRotation(s.Parent, s.Track));
|
||||||
#else
|
#else
|
||||||
a_head.position = Position = GetFramePoint(s.Parent, s.Track);
|
a_head.Transform.position = Position = GetFramePoint(s.Parent, s.Track);
|
||||||
a_head.rotation = Rotation = GetFrameRotation(s.Parent, s.Track);
|
a_head.Transform.rotation = Rotation = GetFrameRotation(s.Parent, s.Track);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
protected override void Awake(ContainerState s) {
|
protected override void Awake(ContainerState s) {
|
||||||
@@ -102,12 +126,9 @@ namespace Cryville.Crtr {
|
|||||||
if (ev == null) { }
|
if (ev == null) { }
|
||||||
else if (ev.Unstamped == null) { }
|
else if (ev.Unstamped == null) { }
|
||||||
else if (ev.Unstamped is Chart.Judge) {
|
else if (ev.Unstamped is Chart.Judge) {
|
||||||
var tev = (Chart.Judge)ev.Unstamped;
|
ChartPlayer.etor.ContextEvent = ev.Unstamped;
|
||||||
Identifier name = default(Identifier);
|
|
||||||
ChartPlayer.etor.ContextEvent = tev;
|
|
||||||
ChartPlayer.etor.ContextState = s;
|
ChartPlayer.etor.ContextState = s;
|
||||||
ChartPlayer.etor.Evaluate(new PropOp.Identifier(v => name = new Identifier(v)), ruleset.judges[tev.Id].input);
|
judge.Prepare(ev, this);
|
||||||
judge.Prepare(ev.Time, ev.Time + ev.Duration, name, tev.Id, this);
|
|
||||||
ChartPlayer.etor.ContextState = null;
|
ChartPlayer.etor.ContextState = null;
|
||||||
ChartPlayer.etor.ContextEvent = null;
|
ChartPlayer.etor.ContextEvent = null;
|
||||||
}
|
}
|
||||||
@@ -116,12 +137,10 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
public override void Anchor() {
|
public override void Anchor() {
|
||||||
base.Anchor();
|
base.Anchor();
|
||||||
if (cs.Working) {
|
foreach (var j in judges.Values) {
|
||||||
foreach (var j in judges.Values) {
|
if (!j.Judged) continue;
|
||||||
if (!j.Judged) continue;
|
PushAnchorEvent(j.AbsoluteTime, j.DynamicAnchors.Absolute);
|
||||||
// PushAnchorEvent(j.AbsoluteAnchorName, j.AbsoluteTime);
|
PushAnchorEvent(j.RelativeTime + cs.Time, j.DynamicAnchors.Relative);
|
||||||
// PushAnchorEvent(j.RelativeAnchorName, j.RelativeTime + cs.Time);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,15 +148,13 @@ namespace Cryville.Crtr {
|
|||||||
if (s.CloneType == 2 && gogroup) {
|
if (s.CloneType == 2 && gogroup) {
|
||||||
foreach (var i in sgos) i.Seal();
|
foreach (var i in sgos) i.Seal();
|
||||||
#if UNITY_5_6_OR_NEWER
|
#if UNITY_5_6_OR_NEWER
|
||||||
a_tail.SetPositionAndRotation(GetFramePoint(ts.Parent, ts.Track), Quaternion.Euler(ts.Direction));
|
a_tail.Transform.SetPositionAndRotation(GetFramePoint(ts.Parent, ts.Track), Quaternion.Euler(ts.Direction));
|
||||||
#else
|
#else
|
||||||
a_tail.position = GetFramePoint(ts.Parent, ts.Track);
|
a_tail.Transform.position = GetFramePoint(ts.Parent, ts.Track);
|
||||||
a_tail.rotation = Quaternion.Euler(ts.Direction);
|
a_tail.Transform.rotation = Quaternion.Euler(ts.Direction);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
OpenAnchor(_a_tail);
|
|
||||||
base.EndUpdate(s);
|
base.EndUpdate(s);
|
||||||
CloseAnchor(_a_tail);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 GetFramePoint(ContainerState state, float track) {
|
Vector3 GetFramePoint(ContainerState state, float track) {
|
||||||
@@ -197,8 +214,8 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
public void ReportJudge(Judge.JudgeEvent ev, float time, Identifier result) {
|
public void ReportJudge(Judge.JudgeEvent ev, float time, Identifier result) {
|
||||||
JudgeState state;
|
JudgeState state;
|
||||||
if (!judges.TryGetValue(ev.JudgeId, out state)) return;
|
if (!judges.TryGetValue(ev.BaseEvent, out state)) return;
|
||||||
state.MarkJudged(time, (float)(time - cs.Time));
|
state.MarkJudged(time, (float)(ev.StartTime - time), result.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,16 +11,19 @@ namespace Cryville.Crtr {
|
|||||||
static readonly Dictionary<PdtOperatorSignature, PdtOperator> _shortops = new Dictionary<PdtOperatorSignature, PdtOperator>();
|
static readonly Dictionary<PdtOperatorSignature, PdtOperator> _shortops = new Dictionary<PdtOperatorSignature, PdtOperator>();
|
||||||
readonly Dictionary<int, PdtOperator> _ctxops = new Dictionary<int, PdtOperator>();
|
readonly Dictionary<int, PdtOperator> _ctxops = new Dictionary<int, PdtOperator>();
|
||||||
|
|
||||||
|
static readonly byte[] _nullbuf = new byte[0];
|
||||||
readonly byte[] _numbuf = new byte[4];
|
readonly byte[] _numbuf = new byte[4];
|
||||||
static readonly int _var_w = IdentifierManager.SharedInstance.Request("w");
|
static readonly int _var_w = IdentifierManager.SharedInstance.Request("w");
|
||||||
static readonly int _var_h = IdentifierManager.SharedInstance.Request("h");
|
static readonly int _var_h = IdentifierManager.SharedInstance.Request("h");
|
||||||
static readonly int _var_true = IdentifierManager.SharedInstance.Request("true");
|
static readonly int _var_true = IdentifierManager.SharedInstance.Request("true");
|
||||||
static readonly int _var_false = IdentifierManager.SharedInstance.Request("false");
|
static readonly int _var_false = IdentifierManager.SharedInstance.Request("false");
|
||||||
protected override void GetVariable(int name, out int type, out byte[] value) {
|
static readonly int _var_null = IdentifierManager.SharedInstance.Request("null");
|
||||||
|
protected override void GetVariable(int name, bool forced, out int type, out byte[] value) {
|
||||||
if (name == _var_w) { LoadNum(ChartPlayer.hitRect.width); type = PdtInternalType.Number; value = _numbuf; }
|
if (name == _var_w) { LoadNum(ChartPlayer.hitRect.width); type = PdtInternalType.Number; value = _numbuf; }
|
||||||
else if (name == _var_h) { LoadNum(ChartPlayer.hitRect.height); type = PdtInternalType.Number; value = _numbuf; }
|
else if (name == _var_h) { LoadNum(ChartPlayer.hitRect.height); type = PdtInternalType.Number; value = _numbuf; }
|
||||||
else if (name == _var_true) { LoadNum(1); type = PdtInternalType.Number; value = _numbuf; }
|
else if (name == _var_true) { LoadNum(1); type = PdtInternalType.Number; value = _numbuf; }
|
||||||
else if (name == _var_false) { LoadNum(0); type = PdtInternalType.Number; value = _numbuf; }
|
else if (name == _var_false) { LoadNum(0); type = PdtInternalType.Number; value = _numbuf; }
|
||||||
|
else if (name == _var_null) { LoadIdent(0); type = PdtInternalType.Undefined; value = _numbuf; }
|
||||||
else {
|
else {
|
||||||
var id = new Identifier(name);
|
var id = new Identifier(name);
|
||||||
PropSrc prop;
|
PropSrc prop;
|
||||||
@@ -29,7 +32,7 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
else if (ContextState != null && ChartPlayer.motionRegistry.ContainsKey(id)) {
|
else if (ContextState != null && ChartPlayer.motionRegistry.ContainsKey(id)) {
|
||||||
var vec = ContextState.GetRawValue(id);
|
var vec = ContextState.GetRawValue(id);
|
||||||
new VectorSrc(() => vec).Get(out type, out value);
|
VectorSrc.Construct(() => vec).Get(out type, out value);
|
||||||
}
|
}
|
||||||
else if (ContextJudge != null && ContextJudge.TryGetScoreSrc(name, out prop)) {
|
else if (ContextJudge != null && ContextJudge.TryGetScoreSrc(name, out prop)) {
|
||||||
prop.Get(out type, out value);
|
prop.Get(out type, out value);
|
||||||
@@ -40,10 +43,14 @@ namespace Cryville.Crtr {
|
|||||||
RevokePotentialConstant();
|
RevokePotentialConstant();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PropSrc.Arbitrary result = ContextCascadeLookup(name);
|
PropSrc result = ContextCascadeLookup(name);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
result.Get(out type, out value);
|
result.Get(out type, out value);
|
||||||
}
|
}
|
||||||
|
else if (forced) {
|
||||||
|
type = PdtInternalType.Error;
|
||||||
|
value = _nullbuf;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
type = PdtInternalType.Undefined;
|
type = PdtInternalType.Undefined;
|
||||||
LoadIdent(name);
|
LoadIdent(name);
|
||||||
@@ -84,6 +91,7 @@ namespace Cryville.Crtr {
|
|||||||
static readonly int _colop_and = IdentifierManager.SharedInstance.Request("&");
|
static readonly int _colop_and = IdentifierManager.SharedInstance.Request("&");
|
||||||
static readonly int _colop_or = IdentifierManager.SharedInstance.Request("|");
|
static readonly int _colop_or = IdentifierManager.SharedInstance.Request("|");
|
||||||
protected override bool Collapse(int name, PdtVariableMemory param) {
|
protected override bool Collapse(int name, PdtVariableMemory param) {
|
||||||
|
if (param.Type == PdtInternalType.Error) throw new ArgumentException("Error");
|
||||||
if (name == _colop_and) return param.Type == PdtInternalType.Number && param.AsNumber() <= 0;
|
if (name == _colop_and) return param.Type == PdtInternalType.Number && param.AsNumber() <= 0;
|
||||||
else if (name == _colop_or) return param.Type != PdtInternalType.Number || param.AsNumber() > 0;
|
else if (name == _colop_or) return param.Type != PdtInternalType.Number || param.AsNumber() > 0;
|
||||||
else throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", IdentifierManager.SharedInstance.Retrieve(name)));
|
else throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", IdentifierManager.SharedInstance.Retrieve(name)));
|
||||||
@@ -95,18 +103,22 @@ namespace Cryville.Crtr {
|
|||||||
public Judge ContextJudge { private get; set; }
|
public Judge ContextJudge { private get; set; }
|
||||||
public PropSrc ContextSelfValue { private get; set; }
|
public PropSrc ContextSelfValue { private get; set; }
|
||||||
|
|
||||||
readonly Dictionary<int, PropSrc.Arbitrary>[] ContextCascade = new Dictionary<int, PropSrc.Arbitrary>[256];
|
readonly Dictionary<int, PropSrc>[] ContextCascade = new Dictionary<int, PropSrc>[256];
|
||||||
int _cascadeHeight;
|
int _cascadeHeight;
|
||||||
public void ContextCascadeInsert() {
|
public void ContextCascadeInsert() {
|
||||||
ContextCascade[_cascadeHeight++].Clear();
|
ContextCascade[_cascadeHeight++].Clear();
|
||||||
}
|
}
|
||||||
public void ContextCascadeUpdate(int key, PropSrc.Arbitrary value) {
|
public void ContextCascadeInsert(Dictionary<int, PropSrc> srcs) {
|
||||||
|
ContextCascadeInsert();
|
||||||
|
foreach (var src in srcs) ContextCascadeUpdate(src.Key, src.Value);
|
||||||
|
}
|
||||||
|
public void ContextCascadeUpdate(int key, PropSrc value) {
|
||||||
ContextCascade[_cascadeHeight - 1][key] = value;
|
ContextCascade[_cascadeHeight - 1][key] = value;
|
||||||
}
|
}
|
||||||
public PropSrc.Arbitrary ContextCascadeLookup(int name) {
|
public PropSrc ContextCascadeLookup(int name) {
|
||||||
PropSrc.Arbitrary result;
|
PropSrc result;
|
||||||
for (int i = _cascadeHeight - 1; i >= 0; i--) {
|
for (int i = _cascadeHeight - 1; i >= 0; i--) {
|
||||||
Dictionary<int, PropSrc.Arbitrary> cas = ContextCascade[i];
|
Dictionary<int, PropSrc> cas = ContextCascade[i];
|
||||||
if (cas.TryGetValue(name, out result)) {
|
if (cas.TryGetValue(name, out result)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -118,7 +130,7 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PdtEvaluator() {
|
public PdtEvaluator() {
|
||||||
for (int i = 0; i < ContextCascade.Length; i++) ContextCascade[i] = new Dictionary<int, PropSrc.Arbitrary>();
|
for (int i = 0; i < ContextCascade.Length; i++) ContextCascade[i] = new Dictionary<int, PropSrc>();
|
||||||
|
|
||||||
_ctxops.Add(IdentifierManager.SharedInstance.Request("screen_edge"), new func_screen_edge(() => ContextTransform));
|
_ctxops.Add(IdentifierManager.SharedInstance.Request("screen_edge"), new func_screen_edge(() => ContextTransform));
|
||||||
_ctxops.Add(IdentifierManager.SharedInstance.Request("int"), new func_int(() => ContextSelfValue));
|
_ctxops.Add(IdentifierManager.SharedInstance.Request("int"), new func_int(() => ContextSelfValue));
|
||||||
@@ -154,6 +166,7 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
_shortops.Add(new PdtOperatorSignature("frame_seq", 3), new func_frame_seq());
|
_shortops.Add(new PdtOperatorSignature("frame_seq", 3), new func_frame_seq());
|
||||||
_shortops.Add(new PdtOperatorSignature("in_area", 1), new func_in_area());
|
_shortops.Add(new PdtOperatorSignature("in_area", 1), new func_in_area());
|
||||||
|
_shortops.Add(new PdtOperatorSignature("is", 2), new func_is());
|
||||||
}
|
}
|
||||||
#region Operators
|
#region Operators
|
||||||
#pragma warning disable IDE1006
|
#pragma warning disable IDE1006
|
||||||
@@ -336,6 +349,17 @@ namespace Cryville.Crtr {
|
|||||||
hit.CopyTo(ret);
|
hit.CopyTo(ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class func_is : PdtOperator {
|
||||||
|
public func_is() : base(2) { }
|
||||||
|
protected override unsafe void Execute() {
|
||||||
|
var op0 = GetOperand(0);
|
||||||
|
if (op0.Type == PdtInternalType.Error) throw new ArgumentException("Error");
|
||||||
|
var op1 = GetOperand(1);
|
||||||
|
if (op1.Type == PdtInternalType.Error) throw new ArgumentException("Error");
|
||||||
|
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
|
||||||
|
ret.SetNumber(op0.Equals(op1) ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Contextual Functions
|
#region Contextual Functions
|
||||||
class func_screen_edge : PdtOperator {
|
class func_screen_edge : PdtOperator {
|
||||||
|
@@ -4,26 +4,26 @@ using RBeatTime = Cryville.Crtr.BeatTime;
|
|||||||
|
|
||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
public abstract class PropSrc {
|
public abstract class PropSrc {
|
||||||
int _type;
|
public int Type { get; private set; }
|
||||||
|
public PropSrc(int type) {
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
protected byte[] buf = null;
|
protected byte[] buf = null;
|
||||||
protected virtual bool Invalidated { get { return buf == null; } }
|
protected virtual bool Invalidated { get { return buf == null; } }
|
||||||
public virtual void Invalidate() { buf = null; }
|
public virtual void Invalidate() { buf = null; }
|
||||||
public void Get(out int type, out byte[] value) {
|
public void Get(out int type, out byte[] value) {
|
||||||
if (Invalidated) _type = InternalGet();
|
if (Invalidated) InternalGet();
|
||||||
type = _type;
|
type = Type;
|
||||||
value = buf;
|
value = buf;
|
||||||
}
|
}
|
||||||
protected abstract int InternalGet();
|
protected abstract void InternalGet();
|
||||||
public class Arbitrary : PropSrc {
|
public class Arbitrary : PropSrc {
|
||||||
public int Type { get; private set; }
|
|
||||||
readonly byte[] _value;
|
readonly byte[] _value;
|
||||||
public Arbitrary(int type, byte[] value) {
|
public Arbitrary(int type, byte[] value) : base(type) {
|
||||||
Type = type;
|
|
||||||
_value = value;
|
_value = value;
|
||||||
}
|
}
|
||||||
protected override int InternalGet() {
|
protected override void InternalGet() {
|
||||||
buf = _value;
|
buf = _value;
|
||||||
return Type;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Boolean : PropSrc {
|
public class Boolean : PropSrc {
|
||||||
@@ -31,11 +31,10 @@ namespace Cryville.Crtr {
|
|||||||
bool m_invalidated = true;
|
bool m_invalidated = true;
|
||||||
protected override bool Invalidated { get { return m_invalidated; } }
|
protected override bool Invalidated { get { return m_invalidated; } }
|
||||||
public override void Invalidate() { m_invalidated = true; }
|
public override void Invalidate() { m_invalidated = true; }
|
||||||
public Boolean(Func<bool> cb) { _cb = cb; buf = new byte[4]; }
|
public Boolean(Func<bool> cb) : base(PdtInternalType.Number) { _cb = cb; buf = new byte[4]; }
|
||||||
protected override int InternalGet() {
|
protected override void InternalGet() {
|
||||||
m_invalidated = false;
|
m_invalidated = false;
|
||||||
buf[0] = _cb() ? (byte)1 : (byte)0;
|
buf[0] = _cb() ? (byte)1 : (byte)0;
|
||||||
return PdtInternalType.Number;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Float : PropSrc {
|
public class Float : PropSrc {
|
||||||
@@ -43,19 +42,18 @@ namespace Cryville.Crtr {
|
|||||||
bool m_invalidated = true;
|
bool m_invalidated = true;
|
||||||
protected override bool Invalidated { get { return m_invalidated; } }
|
protected override bool Invalidated { get { return m_invalidated; } }
|
||||||
public override void Invalidate() { m_invalidated = true; }
|
public override void Invalidate() { m_invalidated = true; }
|
||||||
public Float(Func<float> cb) { _cb = cb; buf = new byte[4]; }
|
public Float(Func<float> cb) : base(PdtInternalType.Number) { _cb = cb; buf = new byte[4]; }
|
||||||
protected override unsafe int InternalGet() {
|
protected override unsafe void InternalGet() {
|
||||||
m_invalidated = false;
|
m_invalidated = false;
|
||||||
fixed (byte* _ptr = buf) {
|
fixed (byte* _ptr = buf) {
|
||||||
*(float*)_ptr = _cb();
|
*(float*)_ptr = _cb();
|
||||||
}
|
}
|
||||||
return PdtInternalType.Number;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class String : PropSrc {
|
public class String : PropSrc {
|
||||||
readonly Func<string> _cb;
|
readonly Func<string> _cb;
|
||||||
public String(Func<string> cb) { _cb = cb; }
|
public String(Func<string> cb) : base(PdtInternalType.String) { _cb = cb; }
|
||||||
protected override unsafe int InternalGet() {
|
protected override unsafe void InternalGet() {
|
||||||
var v = _cb();
|
var v = _cb();
|
||||||
int strlen = v.Length;
|
int strlen = v.Length;
|
||||||
buf = new byte[strlen * sizeof(char) + sizeof(int)];
|
buf = new byte[strlen * sizeof(char) + sizeof(int)];
|
||||||
@@ -65,21 +63,19 @@ namespace Cryville.Crtr {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var c in v) ptr[i++] = c;
|
foreach (var c in v) ptr[i++] = c;
|
||||||
}
|
}
|
||||||
return PdtInternalType.String;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Identifier : PropSrc {
|
public class Identifier : PropSrc {
|
||||||
readonly Func<int> _cb;
|
readonly Func<int> _cb;
|
||||||
public Identifier(Func<int> cb) { _cb = cb; }
|
public Identifier(Func<int> cb) : base(PdtInternalType.Undefined) { _cb = cb; }
|
||||||
protected override int InternalGet() {
|
protected override void InternalGet() {
|
||||||
buf = BitConverter.GetBytes(_cb());
|
buf = BitConverter.GetBytes(_cb());
|
||||||
return PdtInternalType.Undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class BeatTime : PropSrc {
|
public class BeatTime : PropSrc {
|
||||||
readonly Func<RBeatTime> _cb;
|
readonly Func<RBeatTime> _cb;
|
||||||
public BeatTime(Func<RBeatTime> cb) { _cb = cb; }
|
public BeatTime(Func<RBeatTime> cb) : base(PdtInternalType.Vector) { _cb = cb; }
|
||||||
protected override unsafe int InternalGet() {
|
protected override unsafe void InternalGet() {
|
||||||
var bt = _cb();
|
var bt = _cb();
|
||||||
buf = new byte[4 * sizeof(int)];
|
buf = new byte[4 * sizeof(int)];
|
||||||
fixed (byte* _ptr = buf) {
|
fixed (byte* _ptr = buf) {
|
||||||
@@ -89,7 +85,6 @@ namespace Cryville.Crtr {
|
|||||||
*ptr++ = bt.d;
|
*ptr++ = bt.d;
|
||||||
*ptr++ = PdtInternalType.Number;
|
*ptr++ = PdtInternalType.Number;
|
||||||
}
|
}
|
||||||
return PdtInternalType.Vector;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,91 +12,108 @@ namespace Cryville.Crtr {
|
|||||||
readonly PdtSkin skin;
|
readonly PdtSkin skin;
|
||||||
readonly List<DynamicProperty> dynprops = new List<DynamicProperty>();
|
readonly List<DynamicProperty> dynprops = new List<DynamicProperty>();
|
||||||
struct DynamicProperty {
|
struct DynamicProperty {
|
||||||
public Transform Anchor { get; set; }
|
public RuntimeSkinContext Context { get; set; }
|
||||||
public SkinPropertyKey Key { get; set; }
|
public SkinPropertyKey Key { get; set; }
|
||||||
public PdtExpression Value { get; set; }
|
public PdtExpression Value { get; set; }
|
||||||
}
|
}
|
||||||
readonly List<DynamicElement> dynelems = new List<DynamicElement>();
|
readonly List<DynamicElement> dynelems = new List<DynamicElement>();
|
||||||
struct DynamicElement {
|
struct DynamicElement {
|
||||||
public Transform Anchor { get; set; }
|
public RuntimeSkinContext Context { get; set; }
|
||||||
public SkinSelectors Selectors { get; set; }
|
public SkinSelectors Selectors { get; set; }
|
||||||
public SkinElement Element { get; set; }
|
public SkinElement Element { get; set; }
|
||||||
}
|
}
|
||||||
public SkinContainer(PdtSkin _skin) {
|
public SkinContainer(PdtSkin _skin) {
|
||||||
skin = _skin;
|
skin = _skin;
|
||||||
}
|
}
|
||||||
public void MatchStatic(ContainerState context) {
|
public void MatchStatic(ContainerState state) {
|
||||||
dynprops.Clear(); dynelems.Clear();
|
dynprops.Clear(); dynelems.Clear();
|
||||||
ChartPlayer.etor.ContextState = context;
|
ChartPlayer.etor.ContextState = state;
|
||||||
ChartPlayer.etor.ContextEvent = context.Container;
|
ChartPlayer.etor.ContextEvent = state.Container;
|
||||||
MatchStatic(skin, context, context.Handler.gogroup);
|
MatchStatic(skin, state, new RuntimeSkinContext(state.Handler.SkinContext));
|
||||||
ChartPlayer.etor.ContextEvent = null;
|
ChartPlayer.etor.ContextEvent = null;
|
||||||
ChartPlayer.etor.ContextState = null;
|
ChartPlayer.etor.ContextState = null;
|
||||||
}
|
}
|
||||||
void MatchStatic(SkinElement rel, ContainerState context, Transform anchor = null) {
|
void MatchStatic(SkinElement rel, ContainerState state, RuntimeSkinContext ctx) {
|
||||||
ChartPlayer.etor.ContextTransform = anchor;
|
var rc = ctx.ReadContext;
|
||||||
|
ChartPlayer.etor.ContextTransform = rc.Transform;
|
||||||
|
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeInsert(rc.PropSrcs);
|
||||||
foreach (var p in rel.properties) {
|
foreach (var p in rel.properties) {
|
||||||
if (p.Key.Name == 0)
|
if (p.Key.Name == 0)
|
||||||
anchor.gameObject.AddComponent(p.Key.Component);
|
rc.Transform.gameObject.AddComponent(p.Key.Component);
|
||||||
else {
|
else {
|
||||||
ChartPlayer.etor.Evaluate(GetPropOp(anchor, p.Key).Operator, p.Value);
|
ChartPlayer.etor.Evaluate(GetPropOp(ctx.WriteTransform, p.Key).Operator, p.Value);
|
||||||
if (!p.Value.IsConstant) dynprops.Add(
|
if (!p.Value.IsConstant) dynprops.Add(
|
||||||
new DynamicProperty { Anchor = anchor, Key = p.Key, Value = p.Value }
|
new DynamicProperty { Context = ctx, Key = p.Key, Value = p.Value }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChartPlayer.etor.ContextTransform = null;
|
ChartPlayer.etor.ContextTransform = null;
|
||||||
foreach (var r in rel.elements) {
|
foreach (var r in rel.elements) {
|
||||||
try {
|
try {
|
||||||
var new_anchor = r.Key.MatchStatic(context, anchor);
|
var nctxs = r.Key.MatchStatic(state, rc);
|
||||||
if (new_anchor != null) {
|
var roflag = r.Key.annotations.Contains("if");
|
||||||
MatchStatic(r.Value, context, new_anchor);
|
var woflag = r.Key.annotations.Contains("then");
|
||||||
|
foreach (var nctx in nctxs) {
|
||||||
|
var nrctx = new RuntimeSkinContext(nctx, ctx, roflag, woflag);
|
||||||
|
MatchStatic(r.Value, state, nrctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SelectorNotStaticException) {
|
catch (SelectorNotAvailableException) {
|
||||||
dynelems.Add(
|
dynelems.Add(
|
||||||
new DynamicElement { Anchor = anchor, Selectors = r.Key, Element = r.Value }
|
new DynamicElement { Context = ctx, Selectors = r.Key, Element = r.Value }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||||
}
|
}
|
||||||
public void MatchDynamic(ContainerState context) {
|
public void MatchDynamic(ContainerState state) {
|
||||||
if (dynprops.Count == 0 && dynelems.Count == 0) return;
|
if (dynprops.Count == 0 && dynelems.Count == 0) return;
|
||||||
Profiler.BeginSample("SkinContainer.MatchDynamic");
|
Profiler.BeginSample("SkinContainer.MatchDynamic");
|
||||||
ChartPlayer.etor.ContextState = context;
|
ChartPlayer.etor.ContextState = state;
|
||||||
ChartPlayer.etor.ContextEvent = context.Container;
|
ChartPlayer.etor.ContextEvent = state.Container;
|
||||||
for (int i = 0; i < dynprops.Count; i++) {
|
for (int i = 0; i < dynprops.Count; i++) {
|
||||||
DynamicProperty p = dynprops[i];
|
DynamicProperty p = dynprops[i];
|
||||||
var prop = GetPropOp(p.Anchor, p.Key);
|
var psrcs = p.Context.ReadContext.PropSrcs;
|
||||||
if (context.CloneType > prop.UpdateCloneType) continue;
|
if (psrcs != null) ChartPlayer.etor.ContextCascadeInsert(psrcs);
|
||||||
|
var prop = GetPropOp(p.Context.WriteTransform, p.Key);
|
||||||
|
if (state.CloneType > prop.UpdateCloneType) continue;
|
||||||
ChartPlayer.etor.Evaluate(prop.Operator, p.Value);
|
ChartPlayer.etor.Evaluate(prop.Operator, p.Value);
|
||||||
|
if (psrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < dynelems.Count; i++) {
|
for (int i = 0; i < dynelems.Count; i++) {
|
||||||
DynamicElement e = dynelems[i];
|
DynamicElement e = dynelems[i];
|
||||||
var anchor = e.Selectors.MatchDynamic(context, e.Anchor);
|
var psrcs = e.Context.ReadContext.PropSrcs;
|
||||||
if (anchor != null) MatchDynamic(e.Element, context, anchor);
|
if (psrcs != null) ChartPlayer.etor.ContextCascadeInsert(psrcs);
|
||||||
|
var nctx = e.Selectors.MatchDynamic(state, e.Context.ReadContext);
|
||||||
|
if (nctx != null) MatchDynamic(e.Element, state, new RuntimeSkinContext(
|
||||||
|
nctx, e.Context, e.Selectors.annotations.Contains("if"), e.Selectors.annotations.Contains("then")
|
||||||
|
));
|
||||||
|
if (psrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||||
}
|
}
|
||||||
ChartPlayer.etor.ContextEvent = null;
|
ChartPlayer.etor.ContextEvent = null;
|
||||||
ChartPlayer.etor.ContextState = null;
|
ChartPlayer.etor.ContextState = null;
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
}
|
}
|
||||||
void MatchDynamic(SkinElement rel, ContainerState context, Transform anchor = null) {
|
void MatchDynamic(SkinElement rel, ContainerState state, RuntimeSkinContext ctx) {
|
||||||
ChartPlayer.etor.ContextTransform = anchor;
|
var rc = ctx.ReadContext;
|
||||||
|
ChartPlayer.etor.ContextTransform = rc.Transform;
|
||||||
|
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeInsert(rc.PropSrcs);
|
||||||
foreach (var p in rel.properties) {
|
foreach (var p in rel.properties) {
|
||||||
if (p.Key.Name == 0)
|
if (p.Key.Name == 0)
|
||||||
throw new InvalidOperationException("Component creation in dynamic context is not allowed");
|
throw new InvalidOperationException("Component creation in dynamic context is not allowed");
|
||||||
var prop = GetPropOp(anchor, p.Key);
|
var prop = GetPropOp(ctx.WriteTransform, p.Key);
|
||||||
if (context.CloneType > prop.UpdateCloneType) continue;
|
if (state.CloneType > prop.UpdateCloneType) continue;
|
||||||
ChartPlayer.etor.Evaluate(prop.Operator, p.Value);
|
ChartPlayer.etor.Evaluate(prop.Operator, p.Value);
|
||||||
}
|
}
|
||||||
ChartPlayer.etor.ContextTransform = null;
|
ChartPlayer.etor.ContextTransform = null;
|
||||||
foreach (var r in rel.elements) {
|
foreach (var r in rel.elements) {
|
||||||
if (!r.Key.IsUpdatable(context)) continue;
|
if (!r.Key.IsUpdatable(state)) continue;
|
||||||
var new_anchor = r.Key.MatchDynamic(context, anchor);
|
var nctx = r.Key.MatchDynamic(state, rc);
|
||||||
if (new_anchor != null) {
|
if (nctx != null) MatchDynamic(r.Value, state, new RuntimeSkinContext(
|
||||||
MatchDynamic(r.Value, context, new_anchor);
|
nctx, ctx, r.Key.annotations.Contains("if"), r.Key.annotations.Contains("then")
|
||||||
}
|
));
|
||||||
}
|
}
|
||||||
|
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||||
}
|
}
|
||||||
SkinProperty GetPropOp(Transform obj, SkinPropertyKey key) {
|
SkinProperty GetPropOp(Transform obj, SkinPropertyKey key) {
|
||||||
var ctype = key.Component;
|
var ctype = key.Component;
|
||||||
@@ -114,4 +131,38 @@ namespace Cryville.Crtr {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class SkinContext {
|
||||||
|
public Transform Transform { get; private set; }
|
||||||
|
public Dictionary<int, PropSrc> PropSrcs { get; private set; }
|
||||||
|
public SkinContext(Transform transform, Dictionary<int, PropSrc> propSrcs = null) {
|
||||||
|
Transform = transform;
|
||||||
|
PropSrcs = propSrcs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public struct RuntimeSkinContext {
|
||||||
|
public SkinContext ReadContext { get; private set; }
|
||||||
|
public Transform WriteTransform { get; private set; }
|
||||||
|
public RuntimeSkinContext(SkinContext rw) {
|
||||||
|
ReadContext = rw;
|
||||||
|
WriteTransform = rw.Transform;
|
||||||
|
}
|
||||||
|
public RuntimeSkinContext(SkinContext r, Transform w) {
|
||||||
|
ReadContext = r;
|
||||||
|
WriteTransform = w;
|
||||||
|
}
|
||||||
|
public RuntimeSkinContext(SkinContext newctx, RuntimeSkinContext oldctx, bool roflag, bool woflag) {
|
||||||
|
if (roflag) {
|
||||||
|
ReadContext = newctx;
|
||||||
|
WriteTransform = oldctx.WriteTransform;
|
||||||
|
}
|
||||||
|
else if (woflag) {
|
||||||
|
ReadContext = oldctx.ReadContext;
|
||||||
|
WriteTransform = newctx.Transform;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ReadContext = newctx;
|
||||||
|
WriteTransform = newctx.Transform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,15 +7,16 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using CAnchor = Cryville.Crtr.Anchor;
|
||||||
|
|
||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
public class SkinSelectors {
|
public class SkinSelectors {
|
||||||
readonly SkinSelector[] selectors;
|
readonly SkinSelector[] selectors;
|
||||||
readonly string[] annotations;
|
public readonly HashSet<string> annotations;
|
||||||
|
|
||||||
public SkinSelectors(IEnumerable<SkinSelector> s, IEnumerable<string> a) {
|
public SkinSelectors(IEnumerable<SkinSelector> s, IEnumerable<string> a) {
|
||||||
selectors = s.ToArray();
|
selectors = s.ToArray();
|
||||||
annotations = a.ToArray();
|
annotations = a.ToHashSet();
|
||||||
}
|
}
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
if (selectors.Length == 0) return "";
|
if (selectors.Length == 0) return "";
|
||||||
@@ -36,56 +37,42 @@ namespace Cryville.Crtr {
|
|||||||
selectors[i].Optimize(etor);
|
selectors[i].Optimize(etor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public bool IsStatic {
|
public IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext ctx) {
|
||||||
get {
|
IEnumerable<SkinContext> result = new SkinContext[] { ctx };
|
||||||
foreach (var s in selectors) {
|
|
||||||
if (!s.IsStatic) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public Transform MatchStatic(ContainerState h, Transform anchor) {
|
|
||||||
foreach (var s in selectors) {
|
foreach (var s in selectors) {
|
||||||
anchor = s.Match(h, anchor);
|
result = result.SelectMany(l => s.MatchStatic(h, l));
|
||||||
if (anchor == null) return null;
|
|
||||||
}
|
}
|
||||||
return anchor;
|
return result;
|
||||||
}
|
}
|
||||||
public bool IsUpdatable(ContainerState h) {
|
public bool IsUpdatable(ContainerState h) {
|
||||||
foreach (var s in selectors)
|
foreach (var s in selectors)
|
||||||
if (!s.IsUpdatable(h)) return false;
|
if (!s.IsUpdatable(h)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public Transform MatchDynamic(ContainerState h, Transform anchor) {
|
public SkinContext MatchDynamic(ContainerState h, SkinContext ctx) {
|
||||||
foreach (var s in selectors) {
|
foreach (var s in selectors) {
|
||||||
anchor = s.Match(h, anchor, true);
|
ctx = s.MatchDynamic(h, ctx);
|
||||||
if (anchor == null) return null;
|
if (ctx == null) return null;
|
||||||
}
|
}
|
||||||
return anchor;
|
return ctx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class SkinSelector {
|
public abstract class SkinSelector {
|
||||||
protected SkinSelector() { }
|
protected SkinSelector() { }
|
||||||
public abstract bool IsStatic {
|
|
||||||
get;
|
|
||||||
}
|
|
||||||
public virtual void Optimize(PdtEvaluatorBase etor) { }
|
public virtual void Optimize(PdtEvaluatorBase etor) { }
|
||||||
public abstract Transform Match(ContainerState h, Transform a, bool dyn = false);
|
public virtual IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) { throw new SelectorNotAvailableException(); }
|
||||||
|
public virtual SkinContext MatchDynamic(ContainerState h, SkinContext c) { throw new SelectorNotAvailableException(); }
|
||||||
public virtual bool IsUpdatable(ContainerState h) {
|
public virtual bool IsUpdatable(ContainerState h) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public class CreateObject : SkinSelector {
|
public class CreateObject : SkinSelector {
|
||||||
public CreateObject() { }
|
public CreateObject() { }
|
||||||
public override bool IsStatic {
|
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||||
get { return true; }
|
|
||||||
}
|
|
||||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
|
||||||
if (dyn) throw new InvalidOperationException("Object creation in dynamic context is not allowed");
|
|
||||||
var obj = new GameObject("__obj__");
|
var obj = new GameObject("__obj__");
|
||||||
obj.transform.SetParent(a, false);
|
obj.transform.SetParent(c.Transform, false);
|
||||||
obj.AddComponent<TransformInterface>();
|
obj.AddComponent<TransformInterface>();
|
||||||
return obj.transform;
|
return new SkinContext[] { new SkinContext(obj.transform) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Anchor : SkinSelector {
|
public class Anchor : SkinSelector {
|
||||||
@@ -93,15 +80,16 @@ namespace Cryville.Crtr {
|
|||||||
public Anchor(string name) {
|
public Anchor(string name) {
|
||||||
Name = IdentifierManager.SharedInstance.Request(name);
|
Name = IdentifierManager.SharedInstance.Request(name);
|
||||||
}
|
}
|
||||||
public override bool IsStatic {
|
|
||||||
get { return true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||||
return h.Handler.Anchors[Name].Transform;
|
List<CAnchor> anchors;
|
||||||
|
if (h.Handler.Anchors.TryGetValue(Name, out anchors)) {
|
||||||
|
return anchors.Select(a => a.SkinContext);
|
||||||
|
}
|
||||||
|
else return Enumerable.Empty<SkinContext>();
|
||||||
}
|
}
|
||||||
public override bool IsUpdatable(ContainerState h) {
|
public override bool IsUpdatable(ContainerState h) {
|
||||||
return h.Handler.Anchors[Name].Opened;
|
return h.Handler.OpenedAnchor != null && h.Handler.OpenedAnchor.Name == Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class AtAnchor : SkinSelector {
|
public class AtAnchor : SkinSelector {
|
||||||
@@ -109,16 +97,11 @@ namespace Cryville.Crtr {
|
|||||||
public AtAnchor(string name) {
|
public AtAnchor(string name) {
|
||||||
Name = IdentifierManager.SharedInstance.Request(name);
|
Name = IdentifierManager.SharedInstance.Request(name);
|
||||||
}
|
}
|
||||||
public override bool IsStatic {
|
public override SkinContext MatchDynamic(ContainerState h, SkinContext c) {
|
||||||
get { return false; }
|
return IsUpdatable(h) ? c : null;
|
||||||
}
|
|
||||||
|
|
||||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
|
||||||
if (!dyn) throw new SelectorNotStaticException();
|
|
||||||
return IsUpdatable(h) ? a : null;
|
|
||||||
}
|
}
|
||||||
public override bool IsUpdatable(ContainerState h) {
|
public override bool IsUpdatable(ContainerState h) {
|
||||||
return h.Handler.Anchors[Name].Opened;
|
return h.Handler.OpenedAnchor != null && h.Handler.OpenedAnchor.Name == Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Property : SkinSelector {
|
public class Property : SkinSelector {
|
||||||
@@ -132,17 +115,22 @@ namespace Cryville.Crtr {
|
|||||||
public override void Optimize(PdtEvaluatorBase etor) {
|
public override void Optimize(PdtEvaluatorBase etor) {
|
||||||
etor.Optimize(_exp);
|
etor.Optimize(_exp);
|
||||||
}
|
}
|
||||||
public override bool IsStatic {
|
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||||
get { return _exp.IsConstant; }
|
var result = Match(c);
|
||||||
|
if (result != null) return new SkinContext[] { result };
|
||||||
|
else return Enumerable.Empty<SkinContext>();
|
||||||
}
|
}
|
||||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
public override SkinContext MatchDynamic(ContainerState h, SkinContext c) {
|
||||||
ChartPlayer.etor.ContextTransform = a;
|
return Match(c);
|
||||||
|
}
|
||||||
|
public SkinContext Match(SkinContext a) {
|
||||||
|
ChartPlayer.etor.ContextTransform = a.Transform;
|
||||||
try {
|
try {
|
||||||
ChartPlayer.etor.Evaluate(_op, _exp);
|
ChartPlayer.etor.Evaluate(_op, _exp);
|
||||||
return _flag ? a : null;
|
return _flag ? a : null;
|
||||||
}
|
}
|
||||||
catch (Exception) {
|
catch (Exception ex) {
|
||||||
throw new SelectorNotStaticException();
|
throw new SelectorNotAvailableException("The expression is not evaluatable under the current context", ex);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
ChartPlayer.etor.ContextTransform = null;
|
ChartPlayer.etor.ContextTransform = null;
|
||||||
@@ -151,29 +139,22 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
public class State : SkinSelector {
|
public class State : SkinSelector {
|
||||||
public State(string state) { }
|
public State(string state) { }
|
||||||
public override bool IsStatic {
|
public override SkinContext MatchDynamic(ContainerState h, SkinContext c) {
|
||||||
get { return false; }
|
|
||||||
}
|
|
||||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
|
||||||
if (!dyn) throw new SelectorNotStaticException();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class ElementType : SkinSelector {
|
public class ElementType : SkinSelector {
|
||||||
readonly string _type;
|
readonly string _type;
|
||||||
public ElementType(string type) { _type = type; }
|
public ElementType(string type) { _type = type; }
|
||||||
public override bool IsStatic {
|
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||||
get { return true; }
|
return h.Handler.TypeName == _type ? new SkinContext[] { c } : Enumerable.Empty<SkinContext>();
|
||||||
}
|
|
||||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
|
||||||
return h.Handler.TypeName == _type ? a : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class SelectorNotStaticException : Exception {
|
public class SelectorNotAvailableException : Exception {
|
||||||
public SelectorNotStaticException() : base("The selector is not static") { }
|
public SelectorNotAvailableException() : base("The selector is not available under the current context") { }
|
||||||
public SelectorNotStaticException(string message) : base(message) { }
|
public SelectorNotAvailableException(string message) : base(message) { }
|
||||||
public SelectorNotStaticException(string message, Exception innerException) : base(message, innerException) { }
|
public SelectorNotAvailableException(string message, Exception innerException) : base(message, innerException) { }
|
||||||
protected SelectorNotStaticException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
protected SelectorNotAvailableException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using CAnchor = Cryville.Crtr.Anchor;
|
||||||
|
|
||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
public class StampedEvent : IComparable<StampedEvent> {
|
public class StampedEvent : IComparable<StampedEvent> {
|
||||||
@@ -9,7 +10,7 @@ namespace Cryville.Crtr {
|
|||||||
public EventContainer Container;
|
public EventContainer Container;
|
||||||
public StampedEvent Origin;
|
public StampedEvent Origin;
|
||||||
public List<StampedEvent> Subevents = new List<StampedEvent>();
|
public List<StampedEvent> Subevents = new List<StampedEvent>();
|
||||||
private StampedEvent attev = null;
|
public List<StampedEvent> Coevents;
|
||||||
private StampedEvent relev = null;
|
private StampedEvent relev = null;
|
||||||
|
|
||||||
public double Duration {
|
public double Duration {
|
||||||
@@ -29,19 +30,12 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class Anchor : StampedEvent {
|
public class Anchor : StampedEvent {
|
||||||
public int Name;
|
public CAnchor Target;
|
||||||
public override int Priority {
|
public override int Priority {
|
||||||
get { return 0; }
|
get { return 0; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StampedEvent AttackEvent {
|
|
||||||
get {
|
|
||||||
if (attev == null) attev = Subevents.FirstOrDefault(ev => ev.Time == this.Time);
|
|
||||||
return attev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public StampedEvent ReleaseEvent {
|
public StampedEvent ReleaseEvent {
|
||||||
get {
|
get {
|
||||||
if (relev == null) relev = Subevents.FirstOrDefault(ev => ((InstantEvent)ev.Unstamped).IsRelease);
|
if (relev == null) relev = Subevents.FirstOrDefault(ev => ((InstantEvent)ev.Unstamped).IsRelease);
|
||||||
|
@@ -1,71 +1,128 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
|
/// <summary>
|
||||||
|
/// A time-forward handler of a sequence of events.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The event type.</typeparam>
|
||||||
public abstract class StateBase<T> {
|
public abstract class StateBase<T> {
|
||||||
public int EventId;
|
/// <summary>
|
||||||
public double Time;
|
/// The current time of the state in seconds.
|
||||||
public Chart chart;
|
/// </summary>
|
||||||
public List<T> events;
|
public double Time { get; protected set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The index of the event to be handled next.
|
||||||
|
/// </summary>
|
||||||
|
protected int EventId;
|
||||||
|
/// <summary>
|
||||||
|
/// The event list.
|
||||||
|
/// </summary>
|
||||||
|
protected readonly List<T> Events;
|
||||||
|
|
||||||
bool breakflag = false;
|
bool breakflag = false;
|
||||||
|
|
||||||
public StateBase(Chart c, List<T> evs) {
|
/// <summary>
|
||||||
chart = c;
|
/// Creates an instance of the <see cref="StateBase{T}" /> class.
|
||||||
events = evs;
|
/// </summary>
|
||||||
|
/// <param name="evs">The event list.</param>
|
||||||
|
public StateBase(List<T> evs) {
|
||||||
|
Events = evs;
|
||||||
EventId = 0;
|
EventId = 0;
|
||||||
Time = 0;
|
Time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a copy of the current state.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A copy of the current state.</returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para><see cref="Events" /> is shared across copies.</para>
|
||||||
|
/// </remarks>
|
||||||
public virtual StateBase<T> Clone() {
|
public virtual StateBase<T> Clone() {
|
||||||
return (StateBase<T>)MemberwiseClone();
|
return (StateBase<T>)MemberwiseClone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copies the state to another existing state.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dest">The state to be overridden.</param>
|
||||||
public virtual void CopyTo(StateBase<T> dest) {
|
public virtual void CopyTo(StateBase<T> dest) {
|
||||||
dest.EventId = EventId;
|
|
||||||
dest.Time = Time;
|
dest.Time = Time;
|
||||||
|
dest.EventId = EventId;
|
||||||
dest.breakflag = breakflag;
|
dest.breakflag = breakflag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interrupts the forward process.
|
||||||
|
/// </summary>
|
||||||
public virtual void Break() {
|
public virtual void Break() {
|
||||||
breakflag = true;
|
breakflag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Forward(Action<T> callback = null) {
|
/// <summary>
|
||||||
ForwardToTime(double.PositiveInfinity, callback);
|
/// Walks through all the remaining events.
|
||||||
|
/// </summary>
|
||||||
|
public void Forward() {
|
||||||
|
ForwardToTime(double.PositiveInfinity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForwardByTime(double time, Action<T> callback = null) {
|
/// <summary>
|
||||||
ForwardToTime(Time + time, callback);
|
/// Forwards the time by the specified span and walks through all the encountered events.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">The span in seconds.</param>
|
||||||
|
public void ForwardByTime(double time) {
|
||||||
|
ForwardToTime(Time + time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForwardOnceByTime(double time, Action<T> callback = null) {
|
/// <summary>
|
||||||
ForwardOnceToTime(Time + time, callback);
|
/// Forwards the time by the specified span but walks through at most one event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">The span in seconds.</param>
|
||||||
|
public void ForwardOnceByTime(double time) {
|
||||||
|
ForwardOnceToTime(Time + time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForwardToTime(double toTime, Action<T> callback = null) {
|
/// <summary>
|
||||||
|
/// Forwards the time to the specified time and walks through all the encountered events.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="toTime">The time in seconds.</param>
|
||||||
|
public void ForwardToTime(double toTime) {
|
||||||
breakflag = false;
|
breakflag = false;
|
||||||
ForwardOnceToTime(Time, callback);
|
ForwardOnceToTime(Time);
|
||||||
while (Time < toTime) {
|
while (Time < toTime) {
|
||||||
ForwardOnceToTime(toTime, callback);
|
ForwardOnceToTime(toTime);
|
||||||
if (breakflag) break;
|
if (breakflag) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForwardStepByTime(double time, double step, Action<T> callback = null) {
|
/// <summary>
|
||||||
ForwardStepToTime(Time + time, step, callback);
|
/// Forwards the time by the specified span and walks through all the encountered events, with a specified step.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">The span in seconds.</param>
|
||||||
|
/// <param name="step">The step in seconds.</param>
|
||||||
|
public void ForwardStepByTime(double time, double step) {
|
||||||
|
ForwardStepToTime(Time + time, step);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForwardStepToTime(double toTime, double step, Action<T> callback = null) {
|
/// <summary>
|
||||||
|
/// Forwards the time to the specified time and walks through all the encountered events, with a specified step.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="toTime">The time in seconds.</param>
|
||||||
|
/// <param name="step">The step in seconds.</param>
|
||||||
|
public void ForwardStepToTime(double toTime, double step) {
|
||||||
breakflag = false;
|
breakflag = false;
|
||||||
ForwardOnceToTime(Time, callback);
|
ForwardOnceToTime(Time);
|
||||||
while (Time < toTime) {
|
while (Time < toTime) {
|
||||||
double next = Time + step;
|
double next = Time + step;
|
||||||
ForwardOnceToTime(next < toTime ? next : toTime, callback);
|
ForwardOnceToTime(next < toTime ? next : toTime);
|
||||||
if (breakflag) break;
|
if (breakflag) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void ForwardOnceToTime(double toTime, Action<T> callback = null);
|
/// <summary>
|
||||||
|
/// Forwards the time to the specified time but walks through at most one event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="toTime">The time in seconds.</param>
|
||||||
|
public abstract void ForwardOnceToTime(double toTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,8 +7,8 @@ namespace Cryville.Crtr {
|
|||||||
readonly GroupHandler gh;
|
readonly GroupHandler gh;
|
||||||
readonly Chart.Track track;
|
readonly Chart.Track track;
|
||||||
|
|
||||||
public TrackHandler(GroupHandler gh, Chart.Track _track) : base() {
|
public TrackHandler(Chart.Track ev, GroupHandler gh) : base() {
|
||||||
track = _track;
|
track = ev;
|
||||||
this.gh = gh;
|
this.gh = gh;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,10 +32,10 @@ namespace Cryville.Crtr {
|
|||||||
ptime = s.Time;
|
ptime = s.Time;
|
||||||
if (s.CloneType == 2) {
|
if (s.CloneType == 2) {
|
||||||
#if UNITY_5_6_OR_NEWER
|
#if UNITY_5_6_OR_NEWER
|
||||||
a_head.SetPositionAndRotation(GetCurrentWorldPoint(), Quaternion.Euler(s.Direction));
|
a_head.Transform.SetPositionAndRotation(GetCurrentWorldPoint(), Quaternion.Euler(s.Direction));
|
||||||
#else
|
#else
|
||||||
a_head.position = GetCurrentWorldPoint();
|
a_head.Transform.position = GetCurrentWorldPoint();
|
||||||
a_head.rotation = Quaternion.Euler(s.Direction);
|
a_head.Transform.rotation = Quaternion.Euler(s.Direction);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (s.CloneType == 3) {
|
else if (s.CloneType == 3) {
|
||||||
@@ -107,9 +107,7 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void EndUpdate(ContainerState s) {
|
public override void EndUpdate(ContainerState s) {
|
||||||
OpenAnchor(_a_tail);
|
|
||||||
base.EndUpdate(s);
|
base.EndUpdate(s);
|
||||||
CloseAnchor(_a_tail);
|
|
||||||
if (s.CloneType == 0 || s.CloneType == 2) {
|
if (s.CloneType == 0 || s.CloneType == 2) {
|
||||||
EndUpdatePosition(ts);
|
EndUpdatePosition(ts);
|
||||||
var p = GetCurrentWorldPoint();
|
var p = GetCurrentWorldPoint();
|
||||||
@@ -118,10 +116,10 @@ namespace Cryville.Crtr {
|
|||||||
i.Seal();
|
i.Seal();
|
||||||
}
|
}
|
||||||
#if UNITY_5_6_OR_NEWER
|
#if UNITY_5_6_OR_NEWER
|
||||||
a_tail.SetPositionAndRotation(GetCurrentWorldPoint(), Quaternion.Euler(ts.Direction));
|
a_tail.Transform.SetPositionAndRotation(GetCurrentWorldPoint(), Quaternion.Euler(ts.Direction));
|
||||||
#else
|
#else
|
||||||
a_tail.position = GetCurrentWorldPoint();
|
a_tail.Transform.position = GetCurrentWorldPoint();
|
||||||
a_tail.rotation = Quaternion.Euler(ts.Direction);
|
a_tail.Transform.rotation = Quaternion.Euler(ts.Direction);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (s.CloneType == 3) EndUpdatePosition(ns);
|
else if (s.CloneType == 3) EndUpdatePosition(ns);
|
||||||
|
@@ -27,6 +27,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
[assembly: SuppressMessage("Style", "IDE0034")]
|
[assembly: SuppressMessage("Style", "IDE0034")]
|
||||||
|
|
||||||
// Simplified new not supported
|
// Simplified new not supported
|
||||||
|
[assembly: SuppressMessage("Style", "IDE0017")]
|
||||||
[assembly: SuppressMessage("Style", "IDE0090")]
|
[assembly: SuppressMessage("Style", "IDE0090")]
|
||||||
|
|
||||||
// Pattern matching not supported
|
// Pattern matching not supported
|
||||||
|
@@ -1,406 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!29 &1
|
|
||||||
OcclusionCullingSettings:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
serializedVersion: 2
|
|
||||||
m_OcclusionBakeSettings:
|
|
||||||
smallestOccluder: 5
|
|
||||||
smallestHole: 0.25
|
|
||||||
backfaceThreshold: 100
|
|
||||||
m_SceneGUID: 00000000000000000000000000000000
|
|
||||||
m_OcclusionCullingData: {fileID: 0}
|
|
||||||
--- !u!104 &2
|
|
||||||
RenderSettings:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
serializedVersion: 9
|
|
||||||
m_Fog: 0
|
|
||||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
|
||||||
m_FogMode: 3
|
|
||||||
m_FogDensity: 0.01
|
|
||||||
m_LinearFogStart: 0
|
|
||||||
m_LinearFogEnd: 300
|
|
||||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
|
||||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
|
||||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
|
||||||
m_AmbientIntensity: 1
|
|
||||||
m_AmbientMode: 0
|
|
||||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
|
||||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
|
||||||
m_HaloStrength: 0.5
|
|
||||||
m_FlareStrength: 1
|
|
||||||
m_FlareFadeSpeed: 3
|
|
||||||
m_HaloTexture: {fileID: 0}
|
|
||||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
m_DefaultReflectionMode: 0
|
|
||||||
m_DefaultReflectionResolution: 128
|
|
||||||
m_ReflectionBounces: 1
|
|
||||||
m_ReflectionIntensity: 1
|
|
||||||
m_CustomReflection: {fileID: 0}
|
|
||||||
m_Sun: {fileID: 0}
|
|
||||||
m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1}
|
|
||||||
m_UseRadianceAmbientProbe: 0
|
|
||||||
--- !u!157 &4
|
|
||||||
LightmapSettings:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
serializedVersion: 12
|
|
||||||
m_GIWorkflowMode: 0
|
|
||||||
m_GISettings:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_BounceScale: 1
|
|
||||||
m_IndirectOutputScale: 1
|
|
||||||
m_AlbedoBoost: 1
|
|
||||||
m_EnvironmentLightingMode: 0
|
|
||||||
m_EnableBakedLightmaps: 1
|
|
||||||
m_EnableRealtimeLightmaps: 1
|
|
||||||
m_LightmapEditorSettings:
|
|
||||||
serializedVersion: 12
|
|
||||||
m_Resolution: 2
|
|
||||||
m_BakeResolution: 40
|
|
||||||
m_AtlasSize: 1024
|
|
||||||
m_AO: 0
|
|
||||||
m_AOMaxDistance: 1
|
|
||||||
m_CompAOExponent: 0
|
|
||||||
m_CompAOExponentDirect: 0
|
|
||||||
m_ExtractAmbientOcclusion: 0
|
|
||||||
m_Padding: 2
|
|
||||||
m_LightmapParameters: {fileID: 0}
|
|
||||||
m_LightmapsBakeMode: 1
|
|
||||||
m_TextureCompression: 1
|
|
||||||
m_FinalGather: 0
|
|
||||||
m_FinalGatherFiltering: 1
|
|
||||||
m_FinalGatherRayCount: 1024
|
|
||||||
m_ReflectionCompression: 2
|
|
||||||
m_MixedBakeMode: 1
|
|
||||||
m_BakeBackend: 0
|
|
||||||
m_PVRSampling: 1
|
|
||||||
m_PVRDirectSampleCount: 32
|
|
||||||
m_PVRSampleCount: 512
|
|
||||||
m_PVRBounces: 2
|
|
||||||
m_PVREnvironmentSampleCount: 512
|
|
||||||
m_PVREnvironmentReferencePointCount: 2048
|
|
||||||
m_PVRFilteringMode: 0
|
|
||||||
m_PVRDenoiserTypeDirect: 0
|
|
||||||
m_PVRDenoiserTypeIndirect: 0
|
|
||||||
m_PVRDenoiserTypeAO: 0
|
|
||||||
m_PVRFilterTypeDirect: 0
|
|
||||||
m_PVRFilterTypeIndirect: 0
|
|
||||||
m_PVRFilterTypeAO: 0
|
|
||||||
m_PVREnvironmentMIS: 0
|
|
||||||
m_PVRCulling: 1
|
|
||||||
m_PVRFilteringGaussRadiusDirect: 1
|
|
||||||
m_PVRFilteringGaussRadiusIndirect: 5
|
|
||||||
m_PVRFilteringGaussRadiusAO: 2
|
|
||||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
|
||||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
|
||||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
|
||||||
m_ExportTrainingData: 0
|
|
||||||
m_TrainingDataDestination: TrainingData
|
|
||||||
m_LightProbeSampleCountMultiplier: 4
|
|
||||||
m_LightingDataAsset: {fileID: 0}
|
|
||||||
m_LightingSettings: {fileID: 97992989}
|
|
||||||
--- !u!196 &5
|
|
||||||
NavMeshSettings:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_BuildSettings:
|
|
||||||
serializedVersion: 2
|
|
||||||
agentTypeID: 0
|
|
||||||
agentRadius: 0.5
|
|
||||||
agentHeight: 2
|
|
||||||
agentSlope: 45
|
|
||||||
agentClimb: 0.4
|
|
||||||
ledgeDropHeight: 0
|
|
||||||
maxJumpAcrossDistance: 0
|
|
||||||
minRegionArea: 2
|
|
||||||
manualCellSize: 0
|
|
||||||
cellSize: 0.16666667
|
|
||||||
manualTileSize: 0
|
|
||||||
tileSize: 256
|
|
||||||
accuratePlacement: 0
|
|
||||||
maxJobWorkers: 0
|
|
||||||
preserveTilesOutsideBounds: 0
|
|
||||||
debug:
|
|
||||||
m_Flags: 0
|
|
||||||
m_NavMeshData: {fileID: 0}
|
|
||||||
--- !u!850595691 &97992989
|
|
||||||
LightingSettings:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_Name: Settings.lighting
|
|
||||||
serializedVersion: 3
|
|
||||||
m_GIWorkflowMode: 0
|
|
||||||
m_EnableBakedLightmaps: 1
|
|
||||||
m_EnableRealtimeLightmaps: 1
|
|
||||||
m_RealtimeEnvironmentLighting: 1
|
|
||||||
m_BounceScale: 1
|
|
||||||
m_AlbedoBoost: 1
|
|
||||||
m_IndirectOutputScale: 1
|
|
||||||
m_UsingShadowmask: 0
|
|
||||||
m_BakeBackend: 0
|
|
||||||
m_LightmapMaxSize: 1024
|
|
||||||
m_BakeResolution: 40
|
|
||||||
m_Padding: 2
|
|
||||||
m_TextureCompression: 1
|
|
||||||
m_AO: 0
|
|
||||||
m_AOMaxDistance: 1
|
|
||||||
m_CompAOExponent: 0
|
|
||||||
m_CompAOExponentDirect: 0
|
|
||||||
m_ExtractAO: 0
|
|
||||||
m_MixedBakeMode: 1
|
|
||||||
m_LightmapsBakeMode: 1
|
|
||||||
m_FilterMode: 1
|
|
||||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
|
||||||
m_ExportTrainingData: 0
|
|
||||||
m_TrainingDataDestination: TrainingData
|
|
||||||
m_RealtimeResolution: 2
|
|
||||||
m_ForceWhiteAlbedo: 0
|
|
||||||
m_ForceUpdates: 0
|
|
||||||
m_FinalGather: 0
|
|
||||||
m_FinalGatherRayCount: 1024
|
|
||||||
m_FinalGatherFiltering: 1
|
|
||||||
m_PVRCulling: 1
|
|
||||||
m_PVRSampling: 1
|
|
||||||
m_PVRDirectSampleCount: 32
|
|
||||||
m_PVRSampleCount: 512
|
|
||||||
m_PVREnvironmentSampleCount: 512
|
|
||||||
m_PVREnvironmentReferencePointCount: 2048
|
|
||||||
m_LightProbeSampleCountMultiplier: 4
|
|
||||||
m_PVRBounces: 2
|
|
||||||
m_PVRMinBounces: 2
|
|
||||||
m_PVREnvironmentMIS: 0
|
|
||||||
m_PVRFilteringMode: 0
|
|
||||||
m_PVRDenoiserTypeDirect: 0
|
|
||||||
m_PVRDenoiserTypeIndirect: 0
|
|
||||||
m_PVRDenoiserTypeAO: 0
|
|
||||||
m_PVRFilterTypeDirect: 0
|
|
||||||
m_PVRFilterTypeIndirect: 0
|
|
||||||
m_PVRFilterTypeAO: 0
|
|
||||||
m_PVRFilteringGaussRadiusDirect: 1
|
|
||||||
m_PVRFilteringGaussRadiusIndirect: 5
|
|
||||||
m_PVRFilteringGaussRadiusAO: 2
|
|
||||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
|
||||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
|
||||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
|
||||||
--- !u!1 &194276658
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 194276661}
|
|
||||||
- component: {fileID: 194276660}
|
|
||||||
- component: {fileID: 194276659}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Main Camera
|
|
||||||
m_TagString: MainCamera
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!81 &194276659
|
|
||||||
AudioListener:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 194276658}
|
|
||||||
m_Enabled: 1
|
|
||||||
--- !u!20 &194276660
|
|
||||||
Camera:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 194276658}
|
|
||||||
m_Enabled: 1
|
|
||||||
serializedVersion: 2
|
|
||||||
m_ClearFlags: 1
|
|
||||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
|
||||||
m_projectionMatrixMode: 1
|
|
||||||
m_GateFitMode: 2
|
|
||||||
m_FOVAxisMode: 0
|
|
||||||
m_SensorSize: {x: 36, y: 24}
|
|
||||||
m_LensShift: {x: 0, y: 0}
|
|
||||||
m_FocalLength: 50
|
|
||||||
m_NormalizedViewPortRect:
|
|
||||||
serializedVersion: 2
|
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
width: 1
|
|
||||||
height: 1
|
|
||||||
near clip plane: 0.3
|
|
||||||
far clip plane: 1000
|
|
||||||
field of view: 60
|
|
||||||
orthographic: 0
|
|
||||||
orthographic size: 5
|
|
||||||
m_Depth: -1
|
|
||||||
m_CullingMask:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 4294967295
|
|
||||||
m_RenderingPath: -1
|
|
||||||
m_TargetTexture: {fileID: 0}
|
|
||||||
m_TargetDisplay: 0
|
|
||||||
m_TargetEye: 3
|
|
||||||
m_HDR: 1
|
|
||||||
m_AllowMSAA: 1
|
|
||||||
m_AllowDynamicResolution: 0
|
|
||||||
m_ForceIntoRT: 0
|
|
||||||
m_OcclusionCulling: 1
|
|
||||||
m_StereoConvergence: 10
|
|
||||||
m_StereoSeparation: 0.022
|
|
||||||
--- !u!4 &194276661
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 194276658}
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1 &234401415
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 234401416}
|
|
||||||
- component: {fileID: 234401417}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Play to run tests
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &234401416
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 234401415}
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_RootOrder: 2
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!114 &234401417
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 234401415}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: c7b67eba0ebbcd6418a881e3028c9901, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
disabledTests: []
|
|
||||||
--- !u!1 &2047485421
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 2047485423}
|
|
||||||
- component: {fileID: 2047485422}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Directional Light
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!108 &2047485422
|
|
||||||
Light:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 2047485421}
|
|
||||||
m_Enabled: 1
|
|
||||||
serializedVersion: 10
|
|
||||||
m_Type: 1
|
|
||||||
m_Shape: 0
|
|
||||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
|
||||||
m_Intensity: 1
|
|
||||||
m_Range: 10
|
|
||||||
m_SpotAngle: 30
|
|
||||||
m_InnerSpotAngle: 21.80208
|
|
||||||
m_CookieSize: 10
|
|
||||||
m_Shadows:
|
|
||||||
m_Type: 2
|
|
||||||
m_Resolution: -1
|
|
||||||
m_CustomResolution: -1
|
|
||||||
m_Strength: 1
|
|
||||||
m_Bias: 0.05
|
|
||||||
m_NormalBias: 0.4
|
|
||||||
m_NearPlane: 0.2
|
|
||||||
m_CullingMatrixOverride:
|
|
||||||
e00: 1
|
|
||||||
e01: 0
|
|
||||||
e02: 0
|
|
||||||
e03: 0
|
|
||||||
e10: 0
|
|
||||||
e11: 1
|
|
||||||
e12: 0
|
|
||||||
e13: 0
|
|
||||||
e20: 0
|
|
||||||
e21: 0
|
|
||||||
e22: 1
|
|
||||||
e23: 0
|
|
||||||
e30: 0
|
|
||||||
e31: 0
|
|
||||||
e32: 0
|
|
||||||
e33: 1
|
|
||||||
m_UseCullingMatrixOverride: 0
|
|
||||||
m_Cookie: {fileID: 0}
|
|
||||||
m_DrawHalo: 0
|
|
||||||
m_Flare: {fileID: 0}
|
|
||||||
m_RenderMode: 0
|
|
||||||
m_CullingMask:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 4294967295
|
|
||||||
m_RenderingLayerMask: 1
|
|
||||||
m_Lightmapping: 4
|
|
||||||
m_LightShadowCasterMode: 0
|
|
||||||
m_AreaSize: {x: 1, y: 1}
|
|
||||||
m_BounceIntensity: 1
|
|
||||||
m_ColorTemperature: 6570
|
|
||||||
m_UseColorTemperature: 0
|
|
||||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
m_UseBoundingSphereOverride: 0
|
|
||||||
m_UseViewFrustumForShadowCasterCull: 1
|
|
||||||
m_ShadowRadius: 0
|
|
||||||
m_ShadowAngle: 0
|
|
||||||
--- !u!4 &2047485423
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 2047485421}
|
|
||||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
|
||||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_RootOrder: 1
|
|
||||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
|
@@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a5b20befc03909345bd7d08158c02462
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
Binary file not shown.
Reference in New Issue
Block a user