Compare commits
71 Commits
c5571e7d17
...
0.5.2
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 | |||
e8f8593555 | |||
2b5bc5dd08 | |||
cf6186aa16 | |||
4d7773a2ac | |||
e8f74399f2 | |||
ca72f7adb5 | |||
5e19a8b886 | |||
a416f772d4 | |||
989a6b5554 | |||
732af15d9b | |||
8cdab36cd6 | |||
44180c7e0f | |||
e589e37640 | |||
94107de97d | |||
13c55dc23e | |||
617eddc030 | |||
7475b19547 | |||
0049ace91a | |||
356f4df9a9 | |||
ff5928b556 | |||
1f0ac2a2e9 | |||
95628f07d1 | |||
3bead4f1b3 | |||
ec9b23f797 | |||
8175ca7e82 | |||
451ebbe91a | |||
da2313ab57 |
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Cryville.Common.Pdt {
|
||||
/// <summary>
|
||||
@@ -104,7 +105,7 @@ namespace Cryville.Common.Pdt {
|
||||
else if (i is PdtInstruction.PushVariable) {
|
||||
i.Execute(this);
|
||||
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));
|
||||
il.Remove(_rip.Previous);
|
||||
}
|
||||
@@ -147,10 +148,10 @@ namespace Cryville.Common.Pdt {
|
||||
_goffset += value.Length;
|
||||
}
|
||||
}
|
||||
internal unsafe void PushVariable(int name) {
|
||||
internal unsafe void PushVariable(int name, bool forced) {
|
||||
fixed (StackFrame* frame = &_stack[_framecount++]) {
|
||||
byte[] value;
|
||||
GetVariable(name, out frame->Type, out value);
|
||||
GetVariable(name, forced, out frame->Type, out value);
|
||||
frame->Offset = _goffset;
|
||||
frame->Length = 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.
|
||||
/// </summary>
|
||||
/// <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="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) {
|
||||
PdtOperator op;
|
||||
try { op = GetOperator(sig); }
|
||||
catch (Exception) {
|
||||
catch (Exception ex) {
|
||||
for (int i = 0; i < sig.ParamCount; i++)
|
||||
DiscardStack();
|
||||
throw;
|
||||
throw new EvaluationFailureException(string.Format("Failed to get operator {0}", sig), ex);
|
||||
}
|
||||
Operate(op, sig.ParamCount);
|
||||
}
|
||||
@@ -222,4 +224,18 @@ namespace Cryville.Common.Pdt {
|
||||
_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 int Name { get; private set; }
|
||||
public PushVariable(int name) { Name = name; }
|
||||
public PushVariable(string name) : this(IdentifierManager.SharedInstance.Request(name)) { }
|
||||
public bool Forced { get; private set; }
|
||||
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) {
|
||||
etor.PushVariable(Name);
|
||||
etor.PushVariable(Name, Forced);
|
||||
}
|
||||
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 {
|
||||
@@ -239,7 +240,11 @@ namespace Cryville.Common.Pdt {
|
||||
if (defs.TryGetValue(buf.Value.Value, out def)) {
|
||||
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;
|
||||
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, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
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,
|
||||
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,
|
||||
|
@@ -19,7 +19,8 @@ namespace Cryville.Common.Pdt {
|
||||
/// <returns>The operand at the specified index.</returns>
|
||||
/// <exception cref="IndexOutOfRangeException"><paramref name="index" /> is not less than <see cref="LoadedOperandCount" /> or less than 0.</exception>
|
||||
protected PdtVariableMemory GetOperand(int index) {
|
||||
if (index >= LoadedOperandCount || index < 0) throw new IndexOutOfRangeException();
|
||||
if (index >= LoadedOperandCount || index < 0)
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
int i = index + _loadindex;
|
||||
return _operands[i];
|
||||
}
|
||||
@@ -33,11 +34,9 @@ namespace Cryville.Common.Pdt {
|
||||
_operands = new PdtVariableMemory[pc];
|
||||
}
|
||||
PdtEvaluatorBase _etor;
|
||||
bool _failure = false;
|
||||
bool _rfreq = true;
|
||||
internal void Begin(PdtEvaluatorBase etor) {
|
||||
_etor = etor;
|
||||
_failure = false;
|
||||
_loadindex = ParamCount;
|
||||
}
|
||||
internal void LoadOperand(PdtVariableMemory mem) {
|
||||
@@ -49,13 +48,9 @@ namespace Cryville.Common.Pdt {
|
||||
_rfreq = false;
|
||||
try { Execute(); } catch (Exception ex) {
|
||||
if (_rfreq) _etor.DiscardStack();
|
||||
throw new InvalidOperationException("Evaluation failed", ex);
|
||||
throw new EvaluationFailureException("Evaluation failed", ex);
|
||||
}
|
||||
if (_failure) {
|
||||
if (_rfreq) _etor.DiscardStack();
|
||||
throw new InvalidOperationException("Evaluation failed");
|
||||
}
|
||||
if (!_rfreq && !noset) throw new InvalidOperationException("Return frame not set");
|
||||
if (!_rfreq && !noset) throw new EvaluationFailureException("Return frame not set");
|
||||
}
|
||||
/// <summary>
|
||||
/// Executes the operator.
|
||||
@@ -69,10 +64,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <returns>The return frame.</returns>
|
||||
/// <exception cref="InvalidOperationException">The return frame has already been requested.</exception>
|
||||
protected PdtVariableMemory GetReturnFrame(int type, int len) {
|
||||
if (_rfreq) {
|
||||
_failure = true;
|
||||
throw new InvalidOperationException("Return frame already requested");
|
||||
}
|
||||
if (_rfreq) throw new InvalidOperationException("Return frame requested twice");
|
||||
_rfreq = true;
|
||||
return _etor.StackAlloc(type, _prmem, len);
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// <summary>
|
||||
/// Span on the memory of a <see cref="PdtEvaluatorBase" />.
|
||||
/// </summary>
|
||||
public unsafe struct PdtVariableMemory {
|
||||
public unsafe struct PdtVariableMemory : IEquatable<PdtVariableMemory> {
|
||||
readonly byte* _ptr;
|
||||
/// <summary>
|
||||
/// The length of the span.
|
||||
@@ -46,6 +46,14 @@ namespace Cryville.Common.Pdt {
|
||||
for (int i = 0; i < length; 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>
|
||||
/// Gets the memory of the span as a number.
|
||||
/// </summary>
|
||||
|
@@ -145,7 +145,7 @@ namespace Cryville.Common {
|
||||
/// <returns>An array containing all the subclasses of the type in the current app domain.</returns>
|
||||
public static Type[] GetSubclassesOf<T>() where T : class {
|
||||
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
IEnumerable<Type> r = new List<Type>();
|
||||
IEnumerable<Type> r = Enumerable.Empty<Type>();
|
||||
foreach (var a in assemblies)
|
||||
r = r.Concat(a.GetTypes().Where(
|
||||
t => t.IsClass
|
||||
|
@@ -98,7 +98,7 @@ namespace Cryville.Common.Unity {
|
||||
#elif UNITY_ANDROID
|
||||
GameObject sbtn = GameObject.Instantiate<GameObject>(prefabButton);
|
||||
sbtn.GetComponentInChildren<Text>().text = "Storage";
|
||||
sbtn.GetComponentInChildren<Button>().onClick.AddListener(() => OnDriveChanged(new DirectoryInfo(androidStorage)));
|
||||
sbtn.GetComponentInChildren<Button>().onClick.AddListener(() => ChangeDirectory(new DirectoryInfo(androidStorage)));
|
||||
sbtn.transform.SetParent(drives, false);
|
||||
#else
|
||||
#error No update GUI logic
|
||||
|
@@ -4,7 +4,19 @@ using UnityEngine;
|
||||
namespace Cryville.Common.Unity.Input {
|
||||
public delegate void InputEventDelegate(InputIdentifier id, InputVector vec);
|
||||
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() {
|
||||
Dispose(false);
|
||||
@@ -14,26 +26,15 @@ namespace Cryville.Common.Unity.Input {
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public bool Activated { get; private set; }
|
||||
public void Activate() {
|
||||
if (Activated) return;
|
||||
Activated = true;
|
||||
ActivateImpl();
|
||||
}
|
||||
protected abstract void ActivateImpl();
|
||||
public void Deactivate() {
|
||||
if (!Activated) return;
|
||||
Activated = false;
|
||||
DeactivateImpl();
|
||||
}
|
||||
protected abstract void DeactivateImpl();
|
||||
protected abstract void Activate();
|
||||
protected abstract void Deactivate();
|
||||
public abstract void Dispose(bool disposing);
|
||||
public abstract bool IsNullable(int type);
|
||||
public abstract byte GetDimension(int type);
|
||||
public abstract string GetTypeName(int type);
|
||||
public abstract double GetCurrentTimestamp();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -4,28 +4,22 @@ using System.Reflection;
|
||||
|
||||
namespace Cryville.Common.Unity.Input {
|
||||
public class InputManager {
|
||||
static readonly List<Type> HandlerRegistries = new List<Type> {
|
||||
static readonly HashSet<Type> HandlerRegistries = new HashSet<Type> {
|
||||
typeof(WindowsPointerHandler),
|
||||
typeof(UnityKeyHandler<UnityKeyboardReceiver>),
|
||||
typeof(UnityKeyHandler<UnityMouseButtonReceiver>),
|
||||
typeof(UnityMouseHandler),
|
||||
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<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() {
|
||||
foreach (var t in HandlerRegistries) {
|
||||
try {
|
||||
if (!typeof(InputHandler).IsAssignableFrom(t)) continue;
|
||||
var h = (InputHandler)ReflectionHelper.InvokeEmptyConstructor(t);
|
||||
_typemap.Add(t, h);
|
||||
h.OnInput += OnInput;
|
||||
_handlers.Add(h);
|
||||
_timeOrigins.Add(h, 0);
|
||||
Logger.Log("main", 1, "Input", "Initialized {0}", ReflectionHelper.GetSimpleName(t));
|
||||
}
|
||||
catch (TargetInvocationException ex) {
|
||||
@@ -36,49 +30,8 @@ namespace Cryville.Common.Unity.Input {
|
||||
public InputHandler GetHandler(string name) {
|
||||
return _typemap[Type.GetType(name)];
|
||||
}
|
||||
public void Activate() {
|
||||
lock (_lock) {
|
||||
_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();
|
||||
}
|
||||
public void EnumerateHandlers(Action<InputHandler> cb) {
|
||||
foreach (var h in _handlers) cb(h);
|
||||
}
|
||||
}
|
||||
|
||||
|
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() { }
|
||||
|
||||
protected override void ActivateImpl() {
|
||||
protected override void Activate() {
|
||||
receiver = new GameObject("__keyrecv__");
|
||||
recvcomp = receiver.AddComponent<T>();
|
||||
recvcomp.SetCallback(Feed);
|
||||
}
|
||||
|
||||
protected override void DeactivateImpl() {
|
||||
protected override void Deactivate() {
|
||||
if (receiver) GameObject.Destroy(receiver);
|
||||
}
|
||||
|
||||
public override void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
DeactivateImpl();
|
||||
Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Cryville.Common.Unity.Input {
|
||||
|
||||
public abstract class UnityKeyReceiver<T> : MonoBehaviour where T : UnityKeyReceiver<T> {
|
||||
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) {
|
||||
Callback = h;
|
||||
}
|
||||
|
@@ -12,35 +12,35 @@ namespace Cryville.Common.Unity.Input {
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ActivateImpl() {
|
||||
protected override void Activate() {
|
||||
receiver = new GameObject("__mouserecv__");
|
||||
receiver.AddComponent<UnityMouseReceiver>().SetHandler(this);
|
||||
}
|
||||
|
||||
protected override void DeactivateImpl() {
|
||||
protected override void Deactivate() {
|
||||
if (receiver) GameObject.Destroy(receiver);
|
||||
}
|
||||
|
||||
public override void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
DeactivateImpl();
|
||||
Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsNullable(int type) {
|
||||
if (type != 0) throw new ArgumentOutOfRangeException(nameof(type));
|
||||
if (type != 0) throw new ArgumentOutOfRangeException("type");
|
||||
return false;
|
||||
}
|
||||
|
||||
public override byte GetDimension(int type) {
|
||||
if (type != 0) throw new ArgumentOutOfRangeException(nameof(type));
|
||||
if (type != 0) throw new ArgumentOutOfRangeException("type");
|
||||
return 2;
|
||||
}
|
||||
|
||||
public override string GetTypeName(int type) {
|
||||
switch (type) {
|
||||
case 0: return "Mouse Position";
|
||||
default: throw new ArgumentOutOfRangeException(nameof(type));
|
||||
default: throw new ArgumentOutOfRangeException("type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,35 +12,35 @@ namespace Cryville.Common.Unity.Input {
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ActivateImpl() {
|
||||
protected override void Activate() {
|
||||
receiver = new GameObject("__touchrecv__");
|
||||
receiver.AddComponent<UnityPointerReceiver>().SetHandler(this);
|
||||
}
|
||||
|
||||
protected override void DeactivateImpl() {
|
||||
protected override void Deactivate() {
|
||||
if (receiver) GameObject.Destroy(receiver);
|
||||
}
|
||||
|
||||
public override void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
DeactivateImpl();
|
||||
Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsNullable(int type) {
|
||||
if (type != 0) throw new ArgumentOutOfRangeException(nameof(type));
|
||||
if (type != 0) throw new ArgumentOutOfRangeException("type");
|
||||
return true;
|
||||
}
|
||||
|
||||
public override byte GetDimension(int type) {
|
||||
if (type != 0) throw new ArgumentOutOfRangeException(nameof(type));
|
||||
if (type != 0) throw new ArgumentOutOfRangeException("type");
|
||||
return 2;
|
||||
}
|
||||
|
||||
public override string GetTypeName(int type) {
|
||||
switch (type) {
|
||||
case 0: return "Touch";
|
||||
default: throw new ArgumentOutOfRangeException(nameof(type));
|
||||
default: throw new ArgumentOutOfRangeException("type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -61,7 +61,7 @@ namespace Cryville.Common.Unity.Input {
|
||||
public const int TABLET_DISABLE_PENBARRELFEEDBACK = 0x00000010;
|
||||
public const int TABLET_DISABLE_FLICKS = 0x00010000;
|
||||
|
||||
protected override void ActivateImpl() {
|
||||
protected override void Activate() {
|
||||
newWndProc = WndProc;
|
||||
newWndProcPtr = Marshal.GetFunctionPointerForDelegate(newWndProc);
|
||||
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) {
|
||||
NativeMethods.RemoveProp(hMainWindow, PRESS_AND_HOLD_ATOM);
|
||||
NativeMethods.GlobalDeleteAtom(pressAndHoldAtomID);
|
||||
@@ -142,7 +142,7 @@ namespace Cryville.Common.Unity.Input {
|
||||
}
|
||||
|
||||
public override void Dispose(bool disposing) {
|
||||
DeactivateImpl();
|
||||
Deactivate();
|
||||
if (usePointerMessage)
|
||||
NativeMethods.EnableMouseInPointer(false);
|
||||
Instance = null;
|
||||
|
@@ -1,15 +1,17 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class Anchor {
|
||||
bool _opened;
|
||||
public bool Opened { get { return _opened; } }
|
||||
public Transform Transform { get; set; }
|
||||
public void Open() {
|
||||
_opened = true;
|
||||
}
|
||||
public void Close() {
|
||||
_opened = false;
|
||||
public int Name { get; private set; }
|
||||
public Transform Transform { get; private set; }
|
||||
public SkinContext SkinContext { get; private set; }
|
||||
public Dictionary<int, PropSrc> PropSrcs { get; private set; }
|
||||
public Anchor(int name, Transform transform, bool hasProps = false) {
|
||||
Name = name;
|
||||
Transform = transform;
|
||||
if (hasProps) PropSrcs = new Dictionary<int, PropSrc>();
|
||||
SkinContext = new SkinContext(transform, PropSrcs);
|
||||
}
|
||||
}
|
||||
}
|
@@ -73,6 +73,9 @@ namespace Cryville.Crtr.Browsing {
|
||||
Application.LoadLevelAdditive("Play");
|
||||
#endif
|
||||
GameObject.Find("/Master").GetComponent<Master>().HideMenu();
|
||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||
DiscordController.Instance.SetPlaying(string.Format("{0} - {1}", detail.Meta.song.name, detail.Meta.name), detail.Meta.length);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OpenConfig(int id, ChartDetail detail) {
|
||||
|
@@ -130,15 +130,6 @@ namespace Cryville.Crtr {
|
||||
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;
|
||||
[JsonIgnore]
|
||||
public InstantEvent ReleaseEvent {
|
||||
@@ -203,7 +194,7 @@ namespace Cryville.Crtr {
|
||||
public virtual EventList GetEventsOfType(string type) {
|
||||
switch (type) {
|
||||
case "motions": return new EventList<Chart.Motion>(motions);
|
||||
default: throw new ArgumentException("Unknown type");
|
||||
default: throw new ArgumentException(string.Format("Unknown event type {0}", type));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,6 +301,8 @@ namespace Cryville.Crtr {
|
||||
#pragma warning restore IDE1006
|
||||
|
||||
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+))?(@(.+?))?(\^(.+?))?(\*(.+?))?(:(.+))?$");
|
||||
if (!m.Success) throw new ArgumentException("Invalid motion string format");
|
||||
name = new Identifier(m.Groups[1].Value);
|
||||
@@ -331,6 +324,10 @@ namespace Cryville.Crtr {
|
||||
else {
|
||||
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() {
|
||||
@@ -382,10 +379,6 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
public Motion() {
|
||||
SubmitPropSrc("value", new VectorSrc(() => {
|
||||
if (RelativeNode != null) return RelativeNode.Value;
|
||||
else return AbsoluteValue;
|
||||
}));
|
||||
SubmitPropOp("motion", new PropOp.String(v => motion = v));
|
||||
SubmitPropOp("name", new PropOp.Identifier(v => {
|
||||
var n = new Identifier(v);
|
||||
|
@@ -54,8 +54,8 @@ namespace Cryville.Crtr {
|
||||
static bool disableGC = true;
|
||||
static float clippingDist = 1f;
|
||||
static float renderDist = 6f;
|
||||
static float renderStep = 0.05f;
|
||||
public static float actualRenderStep = 0f;
|
||||
static double renderStep = 0.05;
|
||||
public static double actualRenderStep = 0;
|
||||
static bool autoRenderStep = false;
|
||||
public static float soundOffset = 0;
|
||||
static float startOffset = 0;
|
||||
@@ -111,7 +111,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
bool texloaddone;
|
||||
diag::Stopwatch texloadtimer = new diag::Stopwatch();
|
||||
bool firstFrame;
|
||||
int forceSyncFrames;
|
||||
double atime0;
|
||||
void Update() {
|
||||
if (started) GameUpdate();
|
||||
@@ -123,10 +123,18 @@ namespace Cryville.Crtr {
|
||||
try {
|
||||
if (Screen.width != screenSize.x || Screen.height != screenSize.y)
|
||||
throw new InvalidOperationException("Window resized while playing");
|
||||
float dt = firstFrame
|
||||
? 1f / Application.targetFrameRate
|
||||
: Time.deltaTime;
|
||||
firstFrame = false;
|
||||
double dt, step;
|
||||
if (forceSyncFrames != 0) {
|
||||
forceSyncFrames--;
|
||||
double target = Game.AudioClient.Position - atime0;
|
||||
dt = target - cbus.Time;
|
||||
step = autoRenderStep ? 1f / Application.targetFrameRate : renderStep;
|
||||
inputProxy.SyncTime(target);
|
||||
}
|
||||
else {
|
||||
dt = Time.deltaTime;
|
||||
step = autoRenderStep ? Time.smoothDeltaTime : renderStep;
|
||||
}
|
||||
inputProxy.ForceTick();
|
||||
cbus.ForwardByTime(dt);
|
||||
bbus.ForwardByTime(dt);
|
||||
@@ -135,16 +143,13 @@ namespace Cryville.Crtr {
|
||||
bbus.CopyTo(2, tbus);
|
||||
bbus.CopyTo(3, nbus);
|
||||
UnityEngine.Profiling.Profiler.EndSample();
|
||||
float step = autoRenderStep ? ( firstFrame
|
||||
? 1f / Application.targetFrameRate
|
||||
: Time.smoothDeltaTime
|
||||
) : renderStep;
|
||||
actualRenderStep = step;
|
||||
|
||||
nbus.ForwardStepByTime(clippingDist, step);
|
||||
nbus.BroadcastEndUpdate();
|
||||
nbus.Anchor();
|
||||
|
||||
tbus.StripTempEvents();
|
||||
tbus.ForwardStepByTime(clippingDist, step);
|
||||
tbus.ForwardStepByTime(renderDist, step);
|
||||
tbus.BroadcastEndUpdate();
|
||||
@@ -250,14 +255,15 @@ namespace Cryville.Crtr {
|
||||
status.text = sttext;
|
||||
}
|
||||
void OnCameraPostRender(Camera cam) {
|
||||
if (!started) return;
|
||||
if (!logEnabled) return;
|
||||
if (started) timetext = string.Format(
|
||||
"\nSTime: {0:R}\nATime: {1:R}\nITime: {2:R}",
|
||||
timetext = string.Format(
|
||||
"\nSTime: {0:R}s {3}\ndATime: {1:+0.0ms;-0.0ms;0} {3}\ndITime: {2:+0.0ms;-0.0ms;0} {3}",
|
||||
cbus.Time,
|
||||
Game.AudioClient.Position - atime0,
|
||||
inputProxy.GetTimestampAverage()
|
||||
(Game.AudioClient.Position - atime0 - cbus.Time) * 1e3,
|
||||
(inputProxy.GetTimestampAverage() - cbus.Time) * 1e3,
|
||||
forceSyncFrames != 0 ? "(force sync)" : ""
|
||||
);
|
||||
else timetext = string.Empty;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -278,6 +284,9 @@ namespace Cryville.Crtr {
|
||||
SceneManager.UnloadSceneAsync("Play");
|
||||
#elif UNITY_5_3_OR_NEWER
|
||||
SceneManager.UnloadScene("Play");
|
||||
#endif
|
||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||
DiscordController.Instance.SetIdle();
|
||||
#endif
|
||||
}
|
||||
#pragma warning restore IDE1006
|
||||
@@ -308,7 +317,7 @@ namespace Cryville.Crtr {
|
||||
autoRenderStep = renderStep == 0;
|
||||
soundOffset = Settings.Default.SoundOffset;
|
||||
startOffset = Settings.Default.StartOffset;
|
||||
firstFrame = true;
|
||||
forceSyncFrames= Settings.Default.ForceSyncFrames;
|
||||
texloaddone = false;
|
||||
Game.NetworkTaskWorker.SuspendBackgroundTasks();
|
||||
Game.AudioSession = Game.AudioSequencer.NewSession();
|
||||
@@ -476,6 +485,7 @@ namespace Cryville.Crtr {
|
||||
workerTimer = new diag::Stopwatch();
|
||||
workerTimer.Start();
|
||||
RMVPool.Prepare();
|
||||
MotionCachePool.Prepare();
|
||||
LoadChart(info);
|
||||
workerTimer.Stop();
|
||||
Logger.Log("main", 1, "Load/WorkerThread", "Worker thread done ({0}ms)", workerTimer.Elapsed.TotalMilliseconds);
|
||||
@@ -507,10 +517,10 @@ namespace Cryville.Crtr {
|
||||
var batcher = new EventBatcher(chart);
|
||||
batcher.Forward();
|
||||
cbus = batcher.Batch();
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Batched {0} event batches", cbus.events.Count);
|
||||
|
||||
LoadSkin(info.skinFile);
|
||||
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Initializing judge and input");
|
||||
judge = new Judge(pruleset);
|
||||
etor.ContextJudge = judge;
|
||||
|
||||
@@ -529,10 +539,10 @@ namespace Cryville.Crtr {
|
||||
foreach (var ts in gs.Value.Children) {
|
||||
ContainerHandler th;
|
||||
if (ts.Key is Chart.Note) {
|
||||
th = new NoteHandler(gh, (Chart.Note)ts.Key, pruleset, judge);
|
||||
th = new NoteHandler((Chart.Note)ts.Key, gh);
|
||||
}
|
||||
else {
|
||||
th = new TrackHandler(gh, (Chart.Track)ts.Key);
|
||||
th = new TrackHandler((Chart.Track)ts.Key, gh);
|
||||
}
|
||||
ts.Value.AttachHandler(th);
|
||||
}
|
||||
@@ -542,8 +552,6 @@ namespace Cryville.Crtr {
|
||||
using (var pbus = cbus.Clone(16)) {
|
||||
pbus.Forward();
|
||||
}
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Patching events");
|
||||
cbus.DoPatch();
|
||||
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Cloning states (type 1)");
|
||||
bbus = cbus.Clone(1, -clippingDist);
|
||||
|
@@ -9,6 +9,18 @@ namespace Cryville.Crtr.Components {
|
||||
protected Vector3? prevpt;
|
||||
protected Quaternion? prevrot;
|
||||
protected int vertCount = 0;
|
||||
Part part = Part.whole;
|
||||
enum Part {
|
||||
whole = 0,
|
||||
idle = 1,
|
||||
start = 2,
|
||||
end = 3,
|
||||
}
|
||||
|
||||
public SectionalGameObject() {
|
||||
SubmitProperty("partial", new PropOp.Boolean(v => part = Part.idle));
|
||||
SubmitProperty("part", new PropOp.Enum<Part>(v => part = v, v => (Part)v), 2);
|
||||
}
|
||||
|
||||
protected override void OnDestroy() {
|
||||
mesh.Destroy();
|
||||
@@ -23,7 +35,7 @@ namespace Cryville.Crtr.Components {
|
||||
}
|
||||
|
||||
public void AppendPoint(Vector3 p, Quaternion r) {
|
||||
if (prevpt == p && prevrot == r) return;
|
||||
if (prevpt == p && prevrot == r || ((int)part & 1) == 1) return;
|
||||
AppendPointInternal(p, r);
|
||||
// if (!headGenerated) Logger.Log("main", 0, "Skin/Polysec", "{0}", r);
|
||||
prevpt = p;
|
||||
@@ -52,9 +64,9 @@ namespace Cryville.Crtr.Components {
|
||||
static readonly ArrayPool<Vector2> _shapePool = new ArrayPool<Vector2>(0x100, 0x10000);
|
||||
|
||||
public PolygonSGO() {
|
||||
SubmitProperty("head", new PropOp.String(v => head.FrameName = v), 2);
|
||||
SubmitProperty("body", new PropOp.String(v => body.FrameName = v), 2);
|
||||
SubmitProperty("tail", new PropOp.String(v => tail.FrameName = v), 2);
|
||||
SubmitProperty("head", new PropOp.String(v => head.FrameName = v));
|
||||
SubmitProperty("body", new PropOp.String(v => body.FrameName = v));
|
||||
SubmitProperty("tail", new PropOp.String(v => tail.FrameName = v));
|
||||
SubmitProperty("shape", new op_set_shape(this), 2);
|
||||
}
|
||||
|
||||
@@ -108,12 +120,6 @@ namespace Cryville.Crtr.Components {
|
||||
UpdateZIndex();
|
||||
}
|
||||
|
||||
void AddMat(List<Material> list, string frame) {
|
||||
var mat = mesh.NewMaterial;
|
||||
mat.mainTexture = ChartPlayer.frames[frame].Texture;
|
||||
list.Add(mat);
|
||||
}
|
||||
|
||||
protected override void OnDestroy() {
|
||||
base.OnDestroy();
|
||||
Reset();
|
||||
@@ -146,6 +152,7 @@ namespace Cryville.Crtr.Components {
|
||||
List<Vector3> verts;
|
||||
List<Vector2> uvs;
|
||||
List<int> trih = null, trib = null, trit = null;
|
||||
static List<int> _emptyTris = new List<int>();
|
||||
|
||||
public override void Seal() {
|
||||
if (vertCount <= 1 || sumLength == 0) return;
|
||||
@@ -186,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 (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;
|
||||
mesh.Mesh.SetVertices(verts);
|
||||
mesh.Mesh.SetUVs(0, uvs);
|
||||
if (head.Frame != null) mesh.Mesh.SetTriangles(trih, m++);
|
||||
if (body.Frame != null) mesh.Mesh.SetTriangles(trib, m++);
|
||||
if (tail.Frame != null) mesh.Mesh.SetTriangles(trit, m++);
|
||||
mesh.Mesh.SetTriangles(head.Frame == null ? _emptyTris : trih, m++);
|
||||
mesh.Mesh.SetTriangles(body.Frame == null ? _emptyTris : trib, m++);
|
||||
mesh.Mesh.SetTriangles(tail.Frame == null ? _emptyTris : trit, m++);
|
||||
mesh.Mesh.RecalculateNormals();
|
||||
|
||||
_vertPool.Return(verts); verts = null;
|
||||
|
@@ -19,7 +19,7 @@ namespace Cryville.Crtr.Components {
|
||||
private set;
|
||||
}
|
||||
public Rect Rect {
|
||||
get { return Frame.frame; }
|
||||
get { return Frame.Frame; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The ratio of width divided by height.
|
||||
@@ -60,8 +60,8 @@ namespace Cryville.Crtr.Components {
|
||||
|
||||
public class SpritePlane : SpriteBase {
|
||||
public SpritePlane() {
|
||||
SubmitProperty("frame", new PropOp.String(v => Frame = v), 2);
|
||||
SubmitProperty("fit", new PropOp.Enum<FitMode>(v => Fit = v));
|
||||
SubmitProperty("frame", new PropOp.String(v => Frame = v));
|
||||
SubmitProperty("fit", new PropOp.Enum<FitMode>(v => Fit = v, v => (FitMode)v));
|
||||
SubmitProperty("opacity", new PropOp.Float(v => Opacity = v));
|
||||
}
|
||||
|
||||
|
@@ -63,13 +63,13 @@ namespace Cryville.Crtr.Components {
|
||||
case 1: x = _border.x; bx = b.x; break;
|
||||
case 2: x = _border.y; bx = b.y; break;
|
||||
case 3: x = 1; bx = 1; break;
|
||||
default: throw new Exception();
|
||||
default: throw new NotSupportedException("Built-in resource corrupted");
|
||||
}
|
||||
float y;
|
||||
switch ((int)muv[i].y) {
|
||||
case 0: y = 0; break;
|
||||
case 3: y = 1; break;
|
||||
default: throw new Exception();
|
||||
default: throw new NotSupportedException("Built-in resource corrupted");
|
||||
}
|
||||
uv[i] = frameInfo.Frame.GetUV(x, y);
|
||||
bx -= 0.5f; y -= 0.5f;
|
||||
|
@@ -79,7 +79,7 @@ namespace Cryville.Crtr.Components {
|
||||
foreach (var f in m_frames) {
|
||||
f.Value.Load();
|
||||
if (frameHeight == 0) frameHeight = f.Value.Rect.height;
|
||||
else if (frameHeight != f.Value.Rect.height) throw new Exception("Inconsistent frame height");
|
||||
else if (frameHeight != f.Value.Rect.height) throw new Exception("Inconsistent frame height for text component");
|
||||
var tex = f.Value.Frame.Texture;
|
||||
if (!meshes.ContainsKey(tex)) {
|
||||
var m = new MeshWrapper();
|
||||
|
@@ -19,7 +19,7 @@ namespace Cryville.Crtr.Config {
|
||||
public Ruleset ruleset;
|
||||
RulesetConfig _rscfg;
|
||||
|
||||
void Awake() {
|
||||
void Start() {
|
||||
ChartPlayer.etor = new PdtEvaluator();
|
||||
FileInfo file = new FileInfo(
|
||||
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
||||
@@ -57,7 +57,6 @@ namespace Cryville.Crtr.Config {
|
||||
var proxy = new InputProxy(ruleset.Root, null);
|
||||
proxy.LoadFrom(_rscfg.inputs);
|
||||
m_inputConfigPanel.proxy = proxy;
|
||||
Game.InputManager.Activate();
|
||||
}
|
||||
|
||||
public void SwitchCategory(GameObject cat) {
|
||||
@@ -68,7 +67,6 @@ namespace Cryville.Crtr.Config {
|
||||
}
|
||||
|
||||
public void SaveAndReturnToMenu() {
|
||||
Game.InputManager.Deactivate();
|
||||
m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
|
||||
m_inputConfigPanel.proxy.Dispose();
|
||||
FileInfo cfgfile = new FileInfo(
|
||||
|
@@ -24,6 +24,7 @@ namespace Cryville.Crtr.Config {
|
||||
[SerializeField]
|
||||
GameObject m_prefabInputConfigEntry;
|
||||
|
||||
readonly SimpleInputConsumer _consumer = new SimpleInputConsumer(Game.InputManager);
|
||||
public InputProxy proxy;
|
||||
readonly Dictionary<string, InputConfigPanelEntry> _entries = new Dictionary<string, InputConfigPanelEntry>();
|
||||
|
||||
@@ -32,7 +33,7 @@ namespace Cryville.Crtr.Config {
|
||||
_sel = entry;
|
||||
m_inputDialog.SetActive(true);
|
||||
CallHelper.Purge(m_deviceList);
|
||||
Game.InputManager.EnumerateEvents(ev => { });
|
||||
_consumer.EnumerateEvents(ev => { });
|
||||
_recvsrcs.Clear();
|
||||
AddSourceItem(null);
|
||||
}
|
||||
@@ -46,10 +47,11 @@ namespace Cryville.Crtr.Config {
|
||||
Target = _sel,
|
||||
Source = src,
|
||||
});
|
||||
m_inputDialog.SetActive(false);
|
||||
CloseDialog();
|
||||
}
|
||||
|
||||
void Start() {
|
||||
_consumer.Activate();
|
||||
foreach (var i in m_configScene.ruleset.Root.inputs) {
|
||||
var e = GameObject.Instantiate(m_prefabInputConfigEntry, m_entryList.transform).GetComponent<InputConfigPanelEntry>();
|
||||
_entries.Add(i.Key, e);
|
||||
@@ -59,6 +61,10 @@ namespace Cryville.Crtr.Config {
|
||||
proxy.ProxyChanged += OnProxyChanged;
|
||||
}
|
||||
|
||||
void OnDestroy() {
|
||||
_consumer.Deactivate();
|
||||
}
|
||||
|
||||
void OnProxyChanged(object sender, ProxyChangedEventArgs e) {
|
||||
_entries[e.Name].SetEnabled(!e.Used);
|
||||
_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?>();
|
||||
void Update() {
|
||||
if (m_inputDialog.activeSelf) {
|
||||
Game.InputManager.EnumerateEvents(ev => {
|
||||
_consumer.EnumerateEvents(ev => {
|
||||
AddSourceItem(ev.Id.Source);
|
||||
});
|
||||
}
|
||||
|
78
Assets/Cryville/Crtr/DiscordController.cs
Normal file
78
Assets/Cryville/Crtr/DiscordController.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using Discord;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logger;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
internal class DiscordController : MonoBehaviour {
|
||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||
public static DiscordController Instance;
|
||||
|
||||
const long CLIENT_ID = 1059021675578007622L;
|
||||
|
||||
Discord.Discord dc;
|
||||
ActivityManager am;
|
||||
long launchTime;
|
||||
|
||||
void Start() {
|
||||
Instance = this;
|
||||
launchTime = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
||||
try {
|
||||
dc = new Discord.Discord(CLIENT_ID, (UInt64)CreateFlags.NoRequireDiscord);
|
||||
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() {
|
||||
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() {
|
||||
if (dc == null) return;
|
||||
dc.Dispose();
|
||||
}
|
||||
|
||||
void Callback(Result result) { }
|
||||
|
||||
public void SetIdle() {
|
||||
if (dc == null) return;
|
||||
am.UpdateActivity(new Activity {
|
||||
State = "Idle",
|
||||
Instance = false,
|
||||
Timestamps = { Start = launchTime },
|
||||
}, Callback);
|
||||
}
|
||||
|
||||
public void SetPlaying(string detail, double? duration) {
|
||||
if (dc == null) return;
|
||||
long now = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
||||
am.UpdateActivity(new Activity {
|
||||
State = "Playing a chart",
|
||||
Details = detail,
|
||||
Instance = true,
|
||||
Timestamps = {
|
||||
Start = now,
|
||||
End = duration == null ? 0 : now + (long)duration,
|
||||
},
|
||||
}, Callback);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/DiscordController.cs.meta
Normal file
11
Assets/Cryville/Crtr/DiscordController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f7c5da9a520bef4e832e2f89f7b737f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,3 +1,5 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Buffers;
|
||||
using Cryville.Crtr.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -34,38 +36,21 @@ namespace Cryville.Crtr.Event {
|
||||
/// <summary>
|
||||
/// <see cref="GameObject"/> group, the <see cref="Transform"/> containing all the generated elements in the <see cref="ContainerHandler"/>.
|
||||
/// </summary>
|
||||
public Transform gogroup;
|
||||
protected Transform gogroup;
|
||||
public SkinContext SkinContext;
|
||||
|
||||
public readonly Dictionary<string, Anchor> Anchors = new Dictionary<string, Anchor>();
|
||||
public Transform a_head;
|
||||
public Transform a_tail;
|
||||
public Vector3 Position {
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
public Quaternion Rotation {
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
public bool Alive {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public bool Awoken {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public bool Disposed {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public Vector3 Position { get; protected set; }
|
||||
public Quaternion Rotation { get; protected set; }
|
||||
public bool Alive { get; private set; }
|
||||
public bool Awoken { get; private set; }
|
||||
public bool Disposed { get; private set; }
|
||||
|
||||
public EventContainer Container {
|
||||
get { return cs.Container; }
|
||||
}
|
||||
|
||||
public SkinContainer skinContainer;
|
||||
public Judge judge;
|
||||
SkinContainer skinContainer;
|
||||
protected Judge judge;
|
||||
public void AttachSystems(PdtSkin skin, Judge judge) {
|
||||
skinContainer = new SkinContainer(skin);
|
||||
this.judge = judge;
|
||||
@@ -75,17 +60,34 @@ namespace Cryville.Crtr.Event {
|
||||
public abstract string TypeName {
|
||||
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_head = IdentifierManager.SharedInstance.Request("head");
|
||||
protected readonly static int _a_tail = IdentifierManager.SharedInstance.Request("tail");
|
||||
public virtual void PreInit() {
|
||||
gogroup = new GameObject(TypeName + ":" + Container.GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
|
||||
SkinContext = new SkinContext(gogroup);
|
||||
if (cs.Parent != null)
|
||||
gogroup.SetParent(cs.Parent.Handler.gogroup, false);
|
||||
a_head = new GameObject("::head").transform;
|
||||
a_head.SetParent(gogroup, false);
|
||||
Anchors.Add("head", new Anchor() { Transform = a_head });
|
||||
a_tail = new GameObject("::tail").transform;
|
||||
a_tail.SetParent(gogroup, false);
|
||||
Anchors.Add("tail", new Anchor() { Transform = a_tail });
|
||||
a_cur = RegisterAnchor(_a_cur);
|
||||
a_head = RegisterAnchor(_a_head);
|
||||
a_tail = RegisterAnchor(_a_tail);
|
||||
}
|
||||
protected Anchor RegisterAnchor(int name, bool hasPropSrcs = false) {
|
||||
var go = new GameObject("." + IdentifierManager.SharedInstance.Retrieve(name)).transform;
|
||||
go.SetParent(gogroup, false);
|
||||
var result = new Anchor(name, go, hasPropSrcs);
|
||||
List<Anchor> list;
|
||||
if (!Anchors.TryGetValue(name, out list))
|
||||
Anchors.Add(name, list = new List<Anchor>());
|
||||
list.Add(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called upon StartUpdate of ps 17.
|
||||
/// </summary>
|
||||
@@ -106,12 +108,14 @@ namespace Cryville.Crtr.Event {
|
||||
Alive = false;
|
||||
}
|
||||
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;
|
||||
OpenAnchor("head");
|
||||
}
|
||||
protected virtual void Awake(ContainerState s) {
|
||||
CloseAnchor("head");
|
||||
if (gogroup) CloseAnchor();
|
||||
}
|
||||
protected virtual void GetPosition(ContainerState s) { }
|
||||
public virtual void StartUpdate(ContainerState s) {
|
||||
@@ -123,26 +127,64 @@ namespace Cryville.Crtr.Event {
|
||||
Init();
|
||||
}
|
||||
}
|
||||
static readonly SimpleObjectPool<StampedEvent.Anchor> anchorEvPool
|
||||
= new SimpleObjectPool<StampedEvent.Anchor>(1024);
|
||||
protected void PushAnchorEvent(double time, Anchor anchor) {
|
||||
var tev = anchorEvPool.Rent();
|
||||
tev.Time = time;
|
||||
tev.Container = Container;
|
||||
tev.Target = anchor;
|
||||
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) {
|
||||
bool flag = !Awoken && s.CloneType >= 2 && s.CloneType < 16;
|
||||
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);
|
||||
}
|
||||
public virtual void ExUpdate(ContainerState s, StampedEvent ev) { }
|
||||
public virtual void ExUpdate(ContainerState s, StampedEvent ev) {
|
||||
if (ev is StampedEvent.Anchor) {
|
||||
var tev = (StampedEvent.Anchor)ev;
|
||||
if (gogroup) {
|
||||
OpenAnchor(tev.Target);
|
||||
#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);
|
||||
CloseAnchor();
|
||||
}
|
||||
anchorEvPool.Return(tev);
|
||||
}
|
||||
}
|
||||
public virtual void MotionUpdate(byte ct, Chart.Motion ev) { }
|
||||
public virtual void EndUpdate(ContainerState s) {
|
||||
if (s.CloneType < 16) {
|
||||
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() { }
|
||||
protected void OpenAnchor(string name) {
|
||||
if (Anchors.ContainsKey(name)) Anchors[name].Open();
|
||||
public virtual void Anchor() {
|
||||
skinContainer.MatchDynamic(cs);
|
||||
if (cs.Working) PushAnchorEvent(cs.Time, a_cur);
|
||||
}
|
||||
protected void CloseAnchor(string name) {
|
||||
if (Anchors.ContainsKey(name)) Anchors[name].Close();
|
||||
protected void OpenAnchor(Anchor anchor) {
|
||||
if (OpenedAnchor != null) throw new InvalidOperationException("An anchor has been opened");
|
||||
OpenedAnchor = anchor;
|
||||
}
|
||||
protected void CloseAnchor() {
|
||||
OpenedAnchor = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ namespace Cryville.Crtr.Event {
|
||||
public class ContainerState {
|
||||
public EventBus Bus;
|
||||
public EventContainer Container;
|
||||
public StampedEvent StampedContainer;
|
||||
public ContainerState Parent = null;
|
||||
public ushort Depth;
|
||||
|
||||
@@ -38,6 +39,7 @@ namespace Cryville.Crtr.Event {
|
||||
InvalidatedChildren.Clear();
|
||||
}
|
||||
|
||||
public bool Active { get; set; }
|
||||
private bool m_Working;
|
||||
public bool Working {
|
||||
get { return m_Working; }
|
||||
@@ -63,16 +65,10 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
|
||||
readonly RMVPool RMVPool = new RMVPool();
|
||||
protected Dictionary<StampedEvent, RealtimeMotionValue> PlayingMotions = new Dictionary<StampedEvent, RealtimeMotionValue>();
|
||||
protected Dictionary<Identifier, RealtimeMotionValue> Values;
|
||||
protected Dictionary<Identifier, CacheEntry> CachedValues;
|
||||
protected class CacheEntry {
|
||||
public bool Valid { get; set; }
|
||||
public Vector Value { get; set; }
|
||||
public CacheEntry Clone() {
|
||||
return new CacheEntry { Valid = Valid, Value = Value == null ? null : Value.Clone() };
|
||||
}
|
||||
}
|
||||
readonly MotionCachePool MCPool = new MotionCachePool();
|
||||
Dictionary<StampedEvent, RealtimeMotionValue> PlayingMotions = new Dictionary<StampedEvent, RealtimeMotionValue>(4);
|
||||
Dictionary<Identifier, RealtimeMotionValue> Values;
|
||||
Dictionary<Identifier, MotionCache> CachedValues;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a motion value.
|
||||
@@ -81,25 +77,19 @@ namespace Cryville.Crtr.Event {
|
||||
/// <param name="clone">Returns a cloned motion value instead.</param>
|
||||
/// <returns>A motion value.</returns>
|
||||
RealtimeMotionValue GetMotionValue(Identifier name, bool clone = false) {
|
||||
RealtimeMotionValue value;
|
||||
if (!Values.TryGetValue(name, out value)) {
|
||||
value = new RealtimeMotionValue().Init(Parent == null
|
||||
? ChartPlayer.motionRegistry[name].GlobalInitValue
|
||||
: ChartPlayer.motionRegistry[name].InitValue
|
||||
);
|
||||
Values.Add(name, value);
|
||||
}
|
||||
RealtimeMotionValue value = Values[name];
|
||||
if (clone) return value.Clone();
|
||||
return value;
|
||||
}
|
||||
|
||||
void InvalidateMotion(Identifier name) {
|
||||
CacheEntry cache;
|
||||
MotionCache cache;
|
||||
if (!CachedValues.TryGetValue(name, out cache))
|
||||
CachedValues.Add(name, cache = new CacheEntry());
|
||||
CachedValues.Add(name, cache = MCPool.Rent(name));
|
||||
cache.Valid = false;
|
||||
foreach (var c in Children)
|
||||
c.Value.InvalidateMotion(name);
|
||||
ValidateChildren();
|
||||
foreach (var c in WorkingChildren)
|
||||
Children[c].InvalidateMotion(name);
|
||||
}
|
||||
|
||||
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);
|
||||
CachedValues = new Dictionary<Identifier, CacheEntry>(ChartPlayer.motionRegistry.Count);
|
||||
CachedValues = new Dictionary<Identifier, MotionCache>(ChartPlayer.motionRegistry.Count);
|
||||
foreach (var m in ChartPlayer.motionRegistry)
|
||||
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;
|
||||
|
||||
var cvs = new Dictionary<Identifier, CacheEntry>(ChartPlayer.motionRegistry.Count);
|
||||
var cvs = new Dictionary<Identifier, MotionCache>(ChartPlayer.motionRegistry.Count);
|
||||
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;
|
||||
|
||||
@@ -145,7 +137,7 @@ namespace Cryville.Crtr.Event {
|
||||
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)
|
||||
pms.Add(m.Key, m.Value);
|
||||
r.PlayingMotions = pms;
|
||||
@@ -171,20 +163,20 @@ namespace Cryville.Crtr.Event {
|
||||
else dest.Values.Add(mv.Key, mv.Value.Clone());
|
||||
}
|
||||
|
||||
foreach (var cv in dest.CachedValues) cv.Value.Valid = false;
|
||||
foreach (var cv in CachedValues) {
|
||||
CacheEntry dv;
|
||||
if (dest.CachedValues.TryGetValue(cv.Key, out dv)) {
|
||||
dv.Valid = cv.Value.Valid;
|
||||
if (cv.Value.Value != null) cv.Value.Value.CopyTo(dv.Value);
|
||||
MotionCache dv;
|
||||
if (!dest.CachedValues.TryGetValue(cv.Key, out dv)) {
|
||||
dest.CachedValues.Add(cv.Key, dv = dest.MCPool.Rent(cv.Key));
|
||||
}
|
||||
else dest.CachedValues.Add(cv.Key, cv.Value.Clone());
|
||||
cv.Value.CopyTo(dv);
|
||||
}
|
||||
|
||||
if (ct != 1) foreach (var cev in WorkingChildren)
|
||||
Children[cev].CopyTo(ct, dest.Children[cev]);
|
||||
else foreach (var child in Children)
|
||||
child.Value.CopyTo(ct, dest.Children[child.Key]);
|
||||
ValidateChildren();
|
||||
dest.ValidateChildren();
|
||||
|
||||
dest.PlayingMotions.Clear();
|
||||
foreach (var m in PlayingMotions) dest.PlayingMotions.Add(m.Key, m.Value);
|
||||
@@ -201,11 +193,12 @@ namespace Cryville.Crtr.Event {
|
||||
foreach (var s in Children)
|
||||
s.Value.Dispose();
|
||||
RMVPool.ReturnAll();
|
||||
MCPool.ReturnAll();
|
||||
}
|
||||
|
||||
public void AttachHandler(ContainerHandler h) {
|
||||
if (Handler != null)
|
||||
throw new InvalidOperationException();
|
||||
throw new InvalidOperationException("Handler attached twice");
|
||||
Handler = h;
|
||||
h.cs = this;
|
||||
}
|
||||
@@ -215,11 +208,9 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
|
||||
public Vector GetRawValue(Identifier key) {
|
||||
CacheEntry tr;
|
||||
MotionCache tr;
|
||||
if (!CachedValues.TryGetValue(key, out tr))
|
||||
CachedValues.Add(key, tr = new CacheEntry { Valid = false });
|
||||
if (tr.Value == null)
|
||||
tr.Value = (Vector)ReflectionHelper.InvokeEmptyConstructor(ChartPlayer.motionRegistry[key].Type);
|
||||
CachedValues.Add(key, tr = MCPool.Rent(key));
|
||||
Vector r = tr.Value;
|
||||
#if !DISABLE_CACHE
|
||||
if (tr.Valid) return r;
|
||||
@@ -317,7 +308,11 @@ namespace Cryville.Crtr.Event {
|
||||
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 (ev != null) {
|
||||
if (ev.Unstamped is Chart.Motion) {
|
||||
@@ -326,7 +321,7 @@ namespace Cryville.Crtr.Event {
|
||||
mv.CloneTypeFlag = CloneType;
|
||||
GetMotionValue(tev.Name).CopyTo(mv);
|
||||
PlayingMotions.Add(ev, mv);
|
||||
Callback(ev, callback);
|
||||
Update(ev);
|
||||
if (!ev.Unstamped.IsLong) {
|
||||
PlayingMotions.Remove(ev);
|
||||
RMVPool.Return(mv);
|
||||
@@ -338,7 +333,7 @@ namespace Cryville.Crtr.Event {
|
||||
ccs.Working = true;
|
||||
ccs.StartUpdate();
|
||||
UpdateMotions();
|
||||
if (!ev.Unstamped.IsLong) {
|
||||
if (!cev.IsLong) {
|
||||
ccs.Working = false;
|
||||
ccs.BroadcastEndUpdate();
|
||||
if (CloneType == 1) ccs.Dispose();
|
||||
@@ -349,7 +344,7 @@ namespace Cryville.Crtr.Event {
|
||||
if (tev.IsRelease) {
|
||||
var nev = tev.Original;
|
||||
if (nev is Chart.Motion) {
|
||||
Callback(ev, callback);
|
||||
Update(ev);
|
||||
var mv = PlayingMotions[ev.Origin];
|
||||
if (mv.CloneTypeFlag == CloneType) RMVPool.Return(mv);
|
||||
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();
|
||||
if (callback != null)
|
||||
callback(ev);
|
||||
if (ev == null || ev.Unstamped != null) Handler.Update(this, ev);
|
||||
else Handler.ExUpdate(this, ev);
|
||||
foreach (var m in PlayingMotions)
|
||||
|
@@ -9,124 +9,127 @@ namespace Cryville.Crtr.Event {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
ContainerState RootState;
|
||||
/// <summary>
|
||||
/// event => the container state that handles the event
|
||||
/// </summary>
|
||||
readonly Dictionary<ChartEvent, ContainerState> table
|
||||
readonly Chart chart;
|
||||
ContainerState rootState;
|
||||
readonly Dictionary<ChartEvent, ContainerState> containerMap
|
||||
= 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>();
|
||||
|
||||
double beat;
|
||||
float tempo;
|
||||
|
||||
public EventBatcher(Chart c) : base(c, new List<ChartEvent>()) {
|
||||
public EventBatcher(Chart c) : base(new List<ChartEvent>()) {
|
||||
chart = c;
|
||||
beat = chart.BeatPosition;
|
||||
tempo = (float)c.sigs[0].tempo;
|
||||
events.Add(c);
|
||||
events.Add(c.ReleaseEvent);
|
||||
Events.Add(c);
|
||||
Events.Add(c.ReleaseEvent);
|
||||
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) {
|
||||
var cs = new ContainerState(chart, c, parent);
|
||||
stateMap.Add(c, cs);
|
||||
if (parent == null) {
|
||||
cs.Depth = 0;
|
||||
RootState = cs;
|
||||
rootState = cs;
|
||||
}
|
||||
else {
|
||||
cs.Depth = (ushort)(parent.Depth + 1);
|
||||
}
|
||||
foreach (var ev in c.Events) {
|
||||
if (ev.time == null) {
|
||||
coevents.Add(ev);
|
||||
ev.time = c.time;
|
||||
if (ev is EventContainer)
|
||||
ev.endtime = c.endtime;
|
||||
}
|
||||
if (ev.IsLong) {
|
||||
events.Add(ev.ReleaseEvent);
|
||||
table.Add(ev.ReleaseEvent, cs);
|
||||
Events.Add(ev.ReleaseEvent);
|
||||
containerMap.Add(ev.ReleaseEvent, cs);
|
||||
}
|
||||
events.Add(ev);
|
||||
table.Add(ev, cs);
|
||||
Events.Add(ev);
|
||||
containerMap.Add(ev, cs);
|
||||
if (ev is EventContainer)
|
||||
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);
|
||||
if (EventId >= events.Count)
|
||||
if (EventId >= Events.Count)
|
||||
goto return_ahead;
|
||||
double ebeat = events[EventId].BeatPosition;
|
||||
double ebeat = Events[EventId].BeatPosition;
|
||||
double etime = Math.Round((ebeat - beat) / tempo * 60f + Time, 6);
|
||||
if (etime > toTime)
|
||||
goto return_ahead;
|
||||
var batch = GetEventBatch();
|
||||
Time = etime;
|
||||
beat = ebeat;
|
||||
bool flag = false;
|
||||
foreach (var ev in batch) {
|
||||
EventContainer con = null;
|
||||
if (table.ContainsKey(ev)) con = table[ev].Container;
|
||||
if (containerMap.ContainsKey(ev)) con = containerMap[ev].Container;
|
||||
var sev = new StampedEvent() {
|
||||
Time = etime,
|
||||
Unstamped = ev,
|
||||
Container = con
|
||||
};
|
||||
if (ev is EventContainer) {
|
||||
stateMap[(EventContainer)ev].StampedContainer = sev;
|
||||
}
|
||||
if (ev is InstantEvent) {
|
||||
var tev = (InstantEvent)ev;
|
||||
var pev = stampedEvents.First(tpev => tpev.Unstamped == tev.Original);
|
||||
var pev = map[tev.Original];
|
||||
pev.Subevents.Add(sev);
|
||||
sev.Origin = pev;
|
||||
}
|
||||
stampedEvents.Add(sev);
|
||||
if (ev.Priority >= 0) {
|
||||
if (callback != null) callback(ev);
|
||||
flag = true;
|
||||
if (con != null && coevents.Contains(ev)) {
|
||||
List<StampedEvent> cevs;
|
||||
if (!coeventMap.TryGetValue(con, out cevs)) {
|
||||
coeventMap.Add(con, cevs = new List<StampedEvent>());
|
||||
}
|
||||
cevs.Add(sev);
|
||||
}
|
||||
else stampedEvents.Add(sev);
|
||||
map.Add(ev, sev);
|
||||
if (ev is Chart.Signature) {
|
||||
var tev = (Chart.Signature)ev;
|
||||
if (tev.tempo != null) tempo = (float)tev.tempo;
|
||||
}
|
||||
EventId++;
|
||||
}
|
||||
if (callback != null && !flag) callback(batch.First());
|
||||
return;
|
||||
return_ahead:
|
||||
Time = toTime;
|
||||
beat = toBeat;
|
||||
if (callback != null) callback(null);
|
||||
}
|
||||
|
||||
IOrderedEnumerable<ChartEvent> GetEventBatch() {
|
||||
float cbeat = events[EventId].BeatPosition;
|
||||
float cbeat = Events[EventId].BeatPosition;
|
||||
int b = EventId;
|
||||
while (Mathf.Approximately(events[b].BeatPosition, cbeat)) {
|
||||
while (Mathf.Approximately(Events[b].BeatPosition, cbeat)) {
|
||||
b--;
|
||||
if (b == -1) break;
|
||||
}
|
||||
int a = EventId;
|
||||
while (Mathf.Approximately(events[a].BeatPosition, cbeat)) {
|
||||
while (Mathf.Approximately(Events[a].BeatPosition, cbeat)) {
|
||||
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() {
|
||||
stampedEvents.Sort((a, b) => {
|
||||
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());
|
||||
});
|
||||
stampedEvents.Sort(CompareStampedEvents);
|
||||
var cb = new EventBatch(stampedEvents[0].Time);
|
||||
foreach (var ev in stampedEvents) {
|
||||
if (ev.Time != cb.Time) {
|
||||
@@ -134,10 +137,36 @@ namespace Cryville.Crtr.Event {
|
||||
cb = new EventBatch(ev.Time);
|
||||
}
|
||||
cb.Enqueue(ev);
|
||||
BatchCoevents(ev);
|
||||
}
|
||||
batches.Add(cb);
|
||||
Bus = new EventBus(chart, RootState, batches);
|
||||
Bus = new EventBus(rootState, batches);
|
||||
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
|
||||
= new Dictionary<EventContainer, ContainerState>();
|
||||
List<EventContainer> activeContainers
|
||||
= new List<EventContainer>();
|
||||
HashSet<EventContainer> activeContainers
|
||||
= new HashSet<EventContainer>();
|
||||
HashSet<ContainerState> workingStates
|
||||
= new HashSet<ContainerState>();
|
||||
HashSet<ContainerState> invalidatedStates
|
||||
= new HashSet<ContainerState>();
|
||||
|
||||
public EventBus(Chart c, ContainerState root, List<EventBatch> b)
|
||||
: base(c, b) {
|
||||
public EventBus(ContainerState root, List<EventBatch> b) : base(b) {
|
||||
RootState = root;
|
||||
Expand();
|
||||
AttachBus();
|
||||
@@ -30,9 +29,10 @@ namespace Cryville.Crtr.Event {
|
||||
var r = (EventBus)MemberwiseClone();
|
||||
r.prototype = this;
|
||||
r.states = new Dictionary<EventContainer, ContainerState>();
|
||||
r.activeContainers = new List<EventContainer>();
|
||||
r.activeContainers = new HashSet<EventContainer>();
|
||||
r.workingStates = new HashSet<ContainerState>();
|
||||
r.invalidatedStates = new HashSet<ContainerState>();
|
||||
r.tempEvents = new List<StampedEvent>();
|
||||
r.Time += offsetTime;
|
||||
r.RootState = RootState.Clone(ct);
|
||||
r.RootState.StartUpdate();
|
||||
@@ -85,8 +85,18 @@ namespace Cryville.Crtr.Event {
|
||||
|
||||
void EnsureActivity(EventContainer c) {
|
||||
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);
|
||||
|
||||
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() {
|
||||
@@ -99,39 +109,60 @@ namespace Cryville.Crtr.Event {
|
||||
s.AttachSystems(skin, judge);
|
||||
}
|
||||
|
||||
readonly List<StampedEvent> patch = new List<StampedEvent>();
|
||||
public void IssuePatch(IEnumerable<StampedEvent> l) {
|
||||
patch.AddRange(l);
|
||||
}
|
||||
public void DoPatch() {
|
||||
foreach (var ev in patch) {
|
||||
var batch = new EventBatch(ev.Time);
|
||||
var batchIndex = events.BinarySearch(batch);
|
||||
if (batchIndex >= 0) batch = events[batchIndex];
|
||||
else events.Insert(~batchIndex, batch);
|
||||
batch.Add(ev);
|
||||
}
|
||||
patch.Clear();
|
||||
List<StampedEvent> tempEvents = new List<StampedEvent>();
|
||||
public void PushTempEvent(StampedEvent ev) {
|
||||
var index = tempEvents.BinarySearch(ev);
|
||||
if (index < 0) index = ~index;
|
||||
tempEvents.Insert(index, ev);
|
||||
}
|
||||
|
||||
public override void ForwardOnceToTime(double toTime, Action<EventBatch> callback = null) {
|
||||
if (EventId < events.Count && events[EventId].Time <= toTime) {
|
||||
Time = events[EventId].Time;
|
||||
var batch = events[EventId];
|
||||
readonly StampedEvent _dummyEvent = new StampedEvent();
|
||||
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 time0 = Math.Min(time1, time2);
|
||||
if (time0 <= toTime && time0 != double.PositiveInfinity) {
|
||||
Time = time0;
|
||||
foreach (var s in workingStates) s.Handle(null);
|
||||
ValidateStates();
|
||||
for (var i = 0; i < batch.Count; i++) {
|
||||
var ev = batch[i];
|
||||
if (ev.Container != null) {
|
||||
EnsureActivity(ev.Container);
|
||||
states[ev.Container].Handle(ev);
|
||||
if (time1 == time0) {
|
||||
var batch = Events[EventId];
|
||||
for (var i = 0; i < batch.Count; i++) {
|
||||
var ev = batch[i];
|
||||
if (ev.Container != null) {
|
||||
if (ev.Unstamped is EventContainer) EnsureActivity((EventContainer)ev.Unstamped);
|
||||
else EnsureActivity(ev.Container);
|
||||
states[ev.Container].Handle(ev);
|
||||
}
|
||||
else if (ev.Coevents != null) EnsureActivity((EventContainer)ev.Unstamped);
|
||||
}
|
||||
if (ev.Unstamped is EventContainer) {
|
||||
if (ev.Container != null) EnsureActivity((EventContainer)ev.Unstamped);
|
||||
EventId++;
|
||||
}
|
||||
if (time2 == time0) {
|
||||
while (tempEvents.Count > 0) {
|
||||
var ev = tempEvents[0];
|
||||
if (ev.Time != time0) break;
|
||||
if (ev.Container != null) {
|
||||
EnsureActivity(ev.Container);
|
||||
states[ev.Container].Handle(ev);
|
||||
}
|
||||
tempEvents.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
ValidateStates();
|
||||
EventId++;
|
||||
}
|
||||
else {
|
||||
Time = toTime;
|
||||
@@ -156,6 +187,7 @@ namespace Cryville.Crtr.Event {
|
||||
|
||||
public void BroadcastEndUpdate() {
|
||||
RootState.BroadcastEndUpdate();
|
||||
tempEvents.Clear();
|
||||
}
|
||||
|
||||
public void Anchor() {
|
||||
|
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:
|
@@ -20,11 +20,13 @@ namespace Cryville.Crtr.Event {
|
||||
_buckets.Add(reg.Key, new Bucket(reg.Key, 4096));
|
||||
}
|
||||
|
||||
readonly Dictionary<RealtimeMotionValue, Identifier> _rented = new Dictionary<RealtimeMotionValue, Identifier>();
|
||||
static readonly SimpleObjectPool<Dictionary<RealtimeMotionValue, Identifier>> _dictPool
|
||||
= new SimpleObjectPool<Dictionary<RealtimeMotionValue, Identifier>>(1024);
|
||||
Dictionary<RealtimeMotionValue, Identifier> _rented;
|
||||
public RealtimeMotionValue Rent(Identifier name) {
|
||||
var n = name;
|
||||
var obj = _buckets[n].Rent();
|
||||
_rented.Add(obj, n);
|
||||
var obj = _buckets[name].Rent();
|
||||
if (_rented == null) _rented = _dictPool.Rent();
|
||||
_rented.Add(obj, name);
|
||||
return obj;
|
||||
}
|
||||
public void Return(RealtimeMotionValue obj) {
|
||||
@@ -32,9 +34,11 @@ namespace Cryville.Crtr.Event {
|
||||
_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -73,16 +73,19 @@ namespace Cryville.Crtr.Extensions.Bestdori {
|
||||
};
|
||||
for (int i = 0; i < tev.connections.Count; i++) {
|
||||
BestdoriChartEvent.Connection c = tev.connections[i];
|
||||
var motion = new Chart.Motion { motion = "track:" + c.lane.ToString(CultureInfo.InvariantCulture) };
|
||||
if (i == 0) {
|
||||
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 {
|
||||
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)
|
||||
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)
|
||||
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;
|
||||
|
@@ -18,11 +18,11 @@ namespace Cryville.Crtr.Extensions.Malody {
|
||||
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||
List<Resource> result = new List<Resource>();
|
||||
MalodyChart src;
|
||||
if (file.Extension != ".mc") throw new NotImplementedException("mcz file is not supported");
|
||||
if (file.Extension != ".mc") throw new NotImplementedException("mcz file is not supported yet");
|
||||
using (var reader = new StreamReader(file.FullName)) {
|
||||
src = JsonConvert.DeserializeObject<MalodyChart>(reader.ReadToEnd());
|
||||
}
|
||||
if (src.meta.mode != 0) throw new NotImplementedException("The chart mode is not supported");
|
||||
if (src.meta.mode != 0) throw new NotImplementedException(string.Format("{0} mode is not supported yet", MODES[src.meta.mode]));
|
||||
|
||||
var ruleset = "malody!" + MODES[src.meta.mode];
|
||||
if (src.meta.mode == 0) {
|
||||
@@ -110,7 +110,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
||||
offset = -tev.offset / 1000f,
|
||||
});
|
||||
}
|
||||
else throw new NotImplementedException();
|
||||
else throw new NotImplementedException("Key sounds are not supported yet");
|
||||
}
|
||||
else {
|
||||
var rn = new Chart.Note() {
|
||||
@@ -135,9 +135,9 @@ namespace Cryville.Crtr.Extensions.Malody {
|
||||
var sev = tev.StartEvent;
|
||||
longEvents.Remove(sev);
|
||||
}
|
||||
else throw new NotSupportedException();
|
||||
else throw new NotSupportedException("Unrecognized long event");
|
||||
}
|
||||
else throw new NotSupportedException();
|
||||
else throw new NotSupportedException("Unrecognized event");
|
||||
}
|
||||
var endbeat = tm.FractionalBeatTime;
|
||||
endbeat.b += 4;
|
||||
|
@@ -35,6 +35,7 @@ namespace Cryville.Crtr.Extensions.osu {
|
||||
var diff = new DifficultyInfo();
|
||||
var evs = new List<osuEvent>();
|
||||
|
||||
bool ftc = false;
|
||||
using (var reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||
Section section = Section.General;
|
||||
int version;
|
||||
@@ -45,7 +46,7 @@ namespace Cryville.Crtr.Extensions.osu {
|
||||
if (line.StartsWith("osu file format v")) {
|
||||
version = int.Parse(line.Substring(17), CultureInfo.InvariantCulture);
|
||||
if (version > 14) throw new NotSupportedException("osu! chart format version too high");
|
||||
else if (version < 5) throw new NotSupportedException("osu! chart format version too low"); // TODO apply offset
|
||||
else if (version < 5) throw new NotImplementedException("osu! chart format version too low"); // TODO apply offset
|
||||
}
|
||||
else throw new NotSupportedException("Unrecognized osu! chart format");
|
||||
flag = true;
|
||||
@@ -57,10 +58,14 @@ namespace Cryville.Crtr.Extensions.osu {
|
||||
Enum.TryParse(line.Substring(1, line.Length - 2), out section);
|
||||
continue;
|
||||
}
|
||||
ParseLine(meta, chart, diff, evs, section, line);
|
||||
ParseLine(meta, chart, diff, evs, ref ftc, section, line);
|
||||
}
|
||||
}
|
||||
if (meta.ruleset == "osu!mania") {
|
||||
chart.ruleset = meta.ruleset += "." + diff.CircleSize.ToString(CultureInfo.InvariantCulture) + "k";
|
||||
}
|
||||
|
||||
if (!ftc) throw new InvalidOperationException("Unconvertible chart: no timing point is present in this beatmap");
|
||||
result.Add(new RawChartResource(string.Format("{0} - {1}", meta.song.name, meta.name), chart, meta));
|
||||
var evc = evs.Count;
|
||||
for (int i = 0; i < evc; i++) if (evs[i].IsLong) evs.Add(new osuEvent.EndEvent(evs[i]));
|
||||
@@ -81,7 +86,7 @@ namespace Cryville.Crtr.Extensions.osu {
|
||||
}
|
||||
else if (ev is osuEvent.EffectPoint) {
|
||||
var tev = (osuEvent.EffectPoint)ev;
|
||||
group.motions.Add(new Chart.Motion { motion = string.Format(CultureInfo.InvariantCulture, "svm:{0}", tev.ScrollSpeed) });
|
||||
group.motions.Add(new Chart.Motion { time = tm.FractionalBeatTime, motion = string.Format(CultureInfo.InvariantCulture, "svm:{0}", tev.ScrollSpeed) });
|
||||
}
|
||||
else if (ev is osuEvent.EndEvent) {
|
||||
if (tm == null) throw new InvalidOperationException("Unconvertible chart: timed event before first timing point");
|
||||
@@ -122,13 +127,13 @@ namespace Cryville.Crtr.Extensions.osu {
|
||||
return result;
|
||||
}
|
||||
|
||||
void ParseLine(ChartMeta meta, Chart chart, DifficultyInfo diff, List<osuEvent> evs, Section section, string line) {
|
||||
void ParseLine(ChartMeta meta, Chart chart, DifficultyInfo diff, List<osuEvent> evs, ref bool ftc, Section section, string line) {
|
||||
switch (section) {
|
||||
case Section.General: HandleGeneral(meta, chart, evs, line); return;
|
||||
case Section.Metadata: HandleMetadata(meta, line); return;
|
||||
case Section.Difficulty: HandleDifficulty(diff, line); return;
|
||||
case Section.Events: HandleEvent(evs, line); return;
|
||||
case Section.TimingPoints: HandleTimingPoint(chart, evs, line); return;
|
||||
case Section.TimingPoints: HandleTimingPoint(chart, evs, ref ftc, line); return;
|
||||
case Section.HitObjects: HandleHitObject(evs, line); return;
|
||||
}
|
||||
}
|
||||
@@ -143,9 +148,9 @@ namespace Cryville.Crtr.Extensions.osu {
|
||||
int rulesetID = int.Parse(pair.Value, CultureInfo.InvariantCulture);
|
||||
var ruleset = "osu!";
|
||||
switch (rulesetID) {
|
||||
case 0: /*ruleset += "standard";*/ throw new NotSupportedException("osu!standard mode is not supported yet");
|
||||
case 1: /*ruleset += "taiko";*/ throw new NotSupportedException("osu!taiko mode is not supported yet");
|
||||
case 2: /*ruleset += "catch";*/ throw new NotSupportedException("osu!catch mode is not supported yet");
|
||||
case 0: /*ruleset += "standard";*/ throw new NotImplementedException("osu!standard mode is not supported yet");
|
||||
case 1: /*ruleset += "taiko";*/ throw new NotImplementedException("osu!taiko mode is not supported yet");
|
||||
case 2: /*ruleset += "catch";*/ throw new NotImplementedException("osu!catch mode is not supported yet");
|
||||
case 3: ruleset += "mania"; break;
|
||||
}
|
||||
meta.ruleset = chart.ruleset = ruleset;
|
||||
@@ -201,7 +206,7 @@ namespace Cryville.Crtr.Extensions.osu {
|
||||
Animation = 6
|
||||
}
|
||||
|
||||
void HandleTimingPoint(Chart chart, List<osuEvent> evs, string line) {
|
||||
void HandleTimingPoint(Chart chart, List<osuEvent> evs, ref bool ftc, string line) {
|
||||
string[] split = line.Split(',');
|
||||
|
||||
double time = double.Parse(split[0].Trim(), CultureInfo.InvariantCulture)/* + offset*/;
|
||||
@@ -230,7 +235,12 @@ namespace Cryville.Crtr.Extensions.osu {
|
||||
if (timingChange) {
|
||||
if (double.IsNaN(beatLength))
|
||||
throw new InvalidDataException("Beat length cannot be NaN in a timing control point");
|
||||
evs.Add(new osuEvent.TimingChange { StartTime = time, BeatLength = beatLength, TimeSignature = timeSignature });
|
||||
var ev = new osuEvent.TimingChange { StartTime = time, BeatLength = beatLength, TimeSignature = timeSignature };
|
||||
if (!ftc) {
|
||||
ftc = true;
|
||||
ev.StartTime = time % beatLength - beatLength;
|
||||
}
|
||||
evs.Add(ev);
|
||||
}
|
||||
|
||||
// osu!taiko and osu!mania use effect points rather than difficulty points for scroll speed adjustments.
|
||||
|
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
class GroupHandler : ContainerHandler {
|
||||
public class GroupHandler : ContainerHandler {
|
||||
public ChartHandler ch;
|
||||
|
||||
SquareMatrix matFrame;
|
||||
|
@@ -65,10 +65,6 @@ namespace Cryville.Crtr {
|
||||
if (_use[target] > 0)
|
||||
throw new InvalidOperationException("Input already assigned");
|
||||
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);
|
||||
_sproxies.Add(proxy.Source.Value, proxy);
|
||||
IncrementUseRecursive(target);
|
||||
@@ -77,7 +73,6 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
void Remove(InputProxyEntry proxy) {
|
||||
var target = proxy.Target;
|
||||
if (_judge != null) _tproxies[target].Source.Value.Handler.OnInput -= OnInput;
|
||||
_sproxies.Remove(_tproxies[target].Source.Value);
|
||||
_tproxies.Remove(target);
|
||||
DecrementUseRecursive(target);
|
||||
@@ -142,12 +137,22 @@ namespace Cryville.Crtr {
|
||||
public void Activate() {
|
||||
_activeCounts.Clear();
|
||||
_vect.Clear(); _vecs.Clear();
|
||||
foreach (var src in _sproxies.Keys) {
|
||||
_activeCounts.Add(src, 0);
|
||||
src.Handler.Activate();
|
||||
foreach (var src in _sproxies) {
|
||||
_activeCounts.Add(src.Key, 0);
|
||||
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() {
|
||||
Dispose(false);
|
||||
@@ -173,7 +178,7 @@ namespace Cryville.Crtr {
|
||||
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
|
||||
readonly Dictionary<InputSource, int> _activeCounts = new Dictionary<InputSource, int>();
|
||||
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]);
|
||||
unsafe void OnInput(InputIdentifier id, InputVector vec) {
|
||||
lock (_lock) {
|
||||
@@ -214,7 +219,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
else {
|
||||
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 (fv.Type != PdtInternalType.Null || tv.Type != PdtInternalType.Null) {
|
||||
if (fv.Type == PdtInternalType.Null) _activeCounts[id.Source]++;
|
||||
@@ -232,8 +237,7 @@ namespace Cryville.Crtr {
|
||||
public void SyncTime(double time) {
|
||||
foreach (var s in _sproxies.Keys) {
|
||||
var h = s.Handler;
|
||||
if (!_timeOrigins.ContainsKey(h))
|
||||
_timeOrigins.Add(h, h.GetCurrentTimestamp() - time);
|
||||
_timeOrigins[h] = h.GetCurrentTimestamp() - time;
|
||||
}
|
||||
}
|
||||
public void ForceTick() {
|
||||
|
@@ -1,13 +1,13 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Buffers;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Crtr.Event;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class Judge {
|
||||
#region Data
|
||||
readonly PdtEvaluator _etor;
|
||||
readonly PdtRuleset _rs;
|
||||
readonly Dictionary<Identifier, float> ct
|
||||
@@ -16,13 +16,14 @@ namespace Cryville.Crtr {
|
||||
= new Dictionary<Identifier, List<JudgeEvent>>();
|
||||
readonly Dictionary<Identifier, List<JudgeEvent>> activeEvs
|
||||
= new Dictionary<Identifier, List<JudgeEvent>>();
|
||||
struct JudgeEvent {
|
||||
public struct JudgeEvent {
|
||||
public double StartTime { get; set; }
|
||||
public double EndTime { get; set; }
|
||||
public double StartClip { get; set; }
|
||||
public double EndClip { get; set; }
|
||||
public Chart.Judge BaseEvent { get; set; }
|
||||
public JudgeDefinition Definition { get; set; }
|
||||
public ContainerState State { get; set; }
|
||||
public NoteHandler Handler { get; set; }
|
||||
}
|
||||
static readonly IComparer<JudgeEvent> _stcmp = new JudgeEventStartTimeComparer();
|
||||
class JudgeEventStartTimeComparer : IComparer<JudgeEvent> {
|
||||
@@ -33,27 +34,46 @@ namespace Cryville.Crtr {
|
||||
public Judge(PdtRuleset rs) {
|
||||
_etor = ChartPlayer.etor;
|
||||
_rs = rs;
|
||||
InitJudges();
|
||||
InitScores();
|
||||
}
|
||||
public void Prepare(double st, double et, Identifier input, JudgeDefinition def, ContainerState container) {
|
||||
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;
|
||||
if (!evs.TryGetValue(input, out list)) {
|
||||
ct.Add(input, 0);
|
||||
evs.Add(input, list = new List<JudgeEvent>());
|
||||
activeEvs.Add(input, new List<JudgeEvent>());
|
||||
}
|
||||
var def = _rs.judges[tev.Id];
|
||||
var ev = new JudgeEvent {
|
||||
StartTime = st,
|
||||
EndTime = et,
|
||||
StartClip = st + def.clip[0],
|
||||
EndClip = et + def.clip[1],
|
||||
BaseEvent = tev,
|
||||
Definition = def,
|
||||
State = container,
|
||||
Handler = handler,
|
||||
};
|
||||
var index = list.BinarySearch(ev, _stcmp);
|
||||
if (index < 0) index = ~index;
|
||||
list.Insert(index, ev);
|
||||
}
|
||||
#endregion
|
||||
#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> jtrelMap = new Dictionary<int, int>();
|
||||
void InitJudges() {
|
||||
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));
|
||||
jtrelMap.Add(i.Key, IdentifierManager.SharedInstance.Request("jtrel_" + i.Name));
|
||||
}
|
||||
}
|
||||
static bool _flag;
|
||||
static readonly PropOp.Boolean _flagop = new PropOp.Boolean(v => _flag = v);
|
||||
static readonly int _var_fn = IdentifierManager.SharedInstance.Request("fn");
|
||||
@@ -112,7 +132,7 @@ namespace Cryville.Crtr {
|
||||
else _flag = true;
|
||||
if (_flag) {
|
||||
if (def.scores != null) UpdateScore(def.scores);
|
||||
if (def.pass != null) Pass(def.pass);
|
||||
if (def.pass != null) Pass(ev, (ft + tt) / 2, def.pass);
|
||||
actlist.RemoveAt(index);
|
||||
if (def.prop != 0 && actlist.Count > 0) {
|
||||
index = BinarySearchFirst(actlist, (float)ev.StartClip, def.stack - def.prop);
|
||||
@@ -124,14 +144,15 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
bool Pass(Identifier[] ids) {
|
||||
bool Pass(JudgeEvent ev, float time, Identifier[] ids) {
|
||||
foreach (var i in ids) {
|
||||
var def = _rs.judges[i];
|
||||
if (def.hit != null) _etor.Evaluate(_flagop, def.hit);
|
||||
else _flag = true;
|
||||
if (_flag) {
|
||||
if (def.scores != null) UpdateScore(def.scores);
|
||||
if (def.pass != null) Pass(def.pass);
|
||||
if (def.pass != null) Pass(ev, time, def.pass);
|
||||
ev.Handler.ReportJudge(ev, time, i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -144,7 +165,7 @@ namespace Cryville.Crtr {
|
||||
JudgeEvent ev = actlist[i];
|
||||
if (tt > ev.EndClip) {
|
||||
actlist.RemoveAt(i);
|
||||
if (ev.Definition.miss != null) Pass(ev.Definition.miss);
|
||||
if (ev.Definition.miss != null) Pass(ev, tt, ev.Definition.miss);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,6 +195,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Score
|
||||
readonly Dictionary<int, int> scoreStringKeys = new Dictionary<int, int>();
|
||||
readonly Dictionary<int, int> scoreStringKeysRev = new Dictionary<int, int>();
|
||||
readonly Dictionary<int, PropSrc> scoreSrcs = new Dictionary<int, PropSrc>();
|
||||
@@ -229,7 +252,8 @@ namespace Cryville.Crtr {
|
||||
readonly Func<string> _cb;
|
||||
readonly ArrayPool<byte> _pool;
|
||||
byte[] _buf;
|
||||
public ScoreStringSrc(ArrayPool<byte> pool, Func<string> cb) {
|
||||
public ScoreStringSrc(ArrayPool<byte> pool, Func<string> cb)
|
||||
: base(PdtInternalType.String) {
|
||||
_pool = pool;
|
||||
_cb = cb;
|
||||
}
|
||||
@@ -240,12 +264,11 @@ namespace Cryville.Crtr {
|
||||
_buf = null;
|
||||
}
|
||||
}
|
||||
protected override unsafe void InternalGet(out int type, out byte[] value) {
|
||||
protected override unsafe void InternalGet() {
|
||||
var src = _cb();
|
||||
int strlen = src.Length;
|
||||
type = PdtInternalType.String;
|
||||
value = _pool.Rent(sizeof(int) + strlen * sizeof(char));
|
||||
fixed (byte* _ptr = value) {
|
||||
buf = _pool.Rent(sizeof(int) + strlen * sizeof(char));
|
||||
fixed (byte* _ptr = buf) {
|
||||
char* ptr = (char*)(_ptr + sizeof(int));
|
||||
*(int*)_ptr = strlen;
|
||||
int i = 0;
|
||||
@@ -253,7 +276,9 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#region Definitions
|
||||
public class InputDefinition {
|
||||
public int dim;
|
||||
public bool notnull;
|
||||
@@ -282,4 +307,5 @@ namespace Cryville.Crtr {
|
||||
public float init = 0;
|
||||
public string format = "";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@@ -351,6 +351,8 @@ namespace Cryville.Crtr {
|
||||
public abstract class Vector : IComparable<Vector> {
|
||||
public Vector() { }
|
||||
|
||||
public abstract byte Dimension { get; }
|
||||
|
||||
public abstract int CompareTo(Vector other);
|
||||
|
||||
public abstract void ApplyFrom(Vector parent);
|
||||
@@ -392,6 +394,8 @@ namespace Cryville.Crtr {
|
||||
Value = i;
|
||||
}
|
||||
|
||||
public override byte Dimension { get { return 1; } }
|
||||
|
||||
public override int CompareTo(Vector other) {
|
||||
return CompareTo((Vec1)other);
|
||||
}
|
||||
@@ -457,6 +461,8 @@ namespace Cryville.Crtr {
|
||||
Value = i;
|
||||
}
|
||||
|
||||
public override byte Dimension { get { return 1; } }
|
||||
|
||||
public override int CompareTo(Vector other) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -517,6 +523,8 @@ namespace Cryville.Crtr {
|
||||
Value = i;
|
||||
}
|
||||
|
||||
public override byte Dimension { get { return 1; } }
|
||||
|
||||
public override int CompareTo(Vector other) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -578,6 +586,8 @@ namespace Cryville.Crtr {
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
public override byte Dimension { get { return 2; } }
|
||||
|
||||
public static void Parse(string s, out float? w, out float? h) {
|
||||
string[] c = s.Split('+');
|
||||
float rw = 0, rh = 0;
|
||||
@@ -697,6 +707,8 @@ namespace Cryville.Crtr {
|
||||
this.x = x; this.y = y; this.z = z;
|
||||
}
|
||||
|
||||
public override byte Dimension { get { return 3; } }
|
||||
|
||||
public override int CompareTo(Vector other) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -773,6 +785,8 @@ namespace Cryville.Crtr {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
public override byte Dimension { get { return 5; } }
|
||||
|
||||
public override int CompareTo(Vector other) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -925,22 +941,29 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
public class VectorSrc : PropSrc {
|
||||
readonly Func<Vector> _cb;
|
||||
public VectorSrc(Func<Vector> cb) { _cb = cb; }
|
||||
protected override unsafe void InternalGet(out int type, out byte[] value) {
|
||||
var arr = _cb().ToArray();
|
||||
if (arr.Length == 1) {
|
||||
type = PdtInternalType.Number;
|
||||
value = new byte[sizeof(float)];
|
||||
fixed (byte* ptr = value) {
|
||||
public abstract class VectorSrc : PropSrc {
|
||||
protected readonly Func<Vector> _cb;
|
||||
public VectorSrc(Func<Vector> cb, int type) : base(type) { _cb = cb; }
|
||||
public static VectorSrc Construct(Func<Vector> cb) {
|
||||
if (cb().Dimension == 1) return new INumber(cb);
|
||||
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)];
|
||||
fixed (byte* ptr = buf) {
|
||||
*(float*)ptr = arr[0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
type = PdtInternalType.Vector;
|
||||
value = new byte[sizeof(float) * arr.Length + sizeof(int)];
|
||||
fixed (byte* rptr = value) {
|
||||
}
|
||||
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)];
|
||||
fixed (byte* rptr = buf) {
|
||||
var ptr = (float*)rptr;
|
||||
for (int i = 0; i < arr.Length; i++, ptr++) {
|
||||
*ptr = arr[i];
|
||||
|
@@ -7,15 +7,12 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
class NoteHandler : ContainerHandler {
|
||||
public class NoteHandler : ContainerHandler {
|
||||
readonly GroupHandler gh;
|
||||
public readonly Chart.Note Event;
|
||||
readonly PdtRuleset ruleset;
|
||||
public NoteHandler(GroupHandler gh, Chart.Note ev, PdtRuleset rs, Judge j) : base() {
|
||||
this.gh = gh;
|
||||
public NoteHandler(Chart.Note ev, GroupHandler gh) : base() {
|
||||
Event = ev;
|
||||
ruleset = rs;
|
||||
judge = j;
|
||||
this.gh = gh;
|
||||
}
|
||||
|
||||
public override string TypeName {
|
||||
@@ -25,26 +22,76 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
SectionalGameObject[] sgos;
|
||||
readonly Dictionary<Chart.Judge, JudgeState> judges = new Dictionary<Chart.Judge, JudgeState>();
|
||||
readonly Dictionary<int, DynamicJudgeAnchorPair> dynJudgeAnchors = new Dictionary<int, DynamicJudgeAnchorPair>();
|
||||
class JudgeState {
|
||||
static readonly int _var_judge_result = IdentifierManager.SharedInstance.Request("judge_result");
|
||||
public Anchor StaticAnchor { get; private set; }
|
||||
public DynamicJudgeAnchorPair DynamicAnchors { get; private set; }
|
||||
public bool Judged { get; private set; }
|
||||
public float AbsoluteTime { get; private set; }
|
||||
public float RelativeTime { get; private set; }
|
||||
int _result = 0;
|
||||
PropSrc _resultPropSrc;
|
||||
public JudgeState(NoteHandler handler, int name) {
|
||||
StaticAnchor = handler.RegisterAnchor(handler.judge.judgeMap[name], true);
|
||||
DynamicAnchors = handler.GetDynamicJudgeAnchorPair(name);
|
||||
}
|
||||
public void MarkJudged(float abs, float rel, int result) {
|
||||
Judged = true;
|
||||
AbsoluteTime = abs;
|
||||
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() {
|
||||
base.PreInit();
|
||||
foreach (var j in Event.judges) {
|
||||
judges.Add(j, new JudgeState(this, j.Id.Key));
|
||||
}
|
||||
}
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
sgos = gogroup.GetComponentsInChildren<SectionalGameObject>();
|
||||
foreach (var judge in judges.Values) judge.InitPropSrcs();
|
||||
}
|
||||
protected override void PreAwake(ContainerState s) {
|
||||
base.PreAwake(s);
|
||||
#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
|
||||
a_head.position = Position = GetFramePoint(s.Parent, s.Track);
|
||||
a_head.rotation = Rotation = GetFrameRotation(s.Parent, s.Track);
|
||||
a_head.Transform.position = Position = GetFramePoint(s.Parent, s.Track);
|
||||
a_head.Transform.rotation = Rotation = GetFrameRotation(s.Parent, s.Track);
|
||||
#endif
|
||||
}
|
||||
protected override void Awake(ContainerState s) {
|
||||
base.Awake(s);
|
||||
if (s.CloneType == 2) {
|
||||
if (!gogroup) return;
|
||||
Chart.Note tev = Event;
|
||||
if (tev.IsLong) {
|
||||
if (Event.IsLong) {
|
||||
foreach (var i in sgos) {
|
||||
i.Reset();
|
||||
i.AppendPoint(Position, Rotation);
|
||||
@@ -54,8 +101,8 @@ namespace Cryville.Crtr {
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
gogroup.SetPositionAndRotation(Position, Rotation);
|
||||
#else
|
||||
gogroup.position = Position;
|
||||
gogroup.rotation = Rotation;
|
||||
gogroup.position = Position;
|
||||
gogroup.rotation = Rotation;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -63,13 +110,11 @@ namespace Cryville.Crtr {
|
||||
|
||||
public override void Update(ContainerState s, StampedEvent ev) {
|
||||
base.Update(s, ev);
|
||||
if (s.CloneType == 1) {
|
||||
Position = GetFramePoint(bs.Parent, bs.Track);
|
||||
Rotation = GetFrameRotation(bs.Parent, bs.Track);
|
||||
if (s.CloneType <= 2) {
|
||||
Position = GetFramePoint(s.Parent, s.Track);
|
||||
Rotation = GetFrameRotation(s.Parent, s.Track);
|
||||
}
|
||||
else if (s.CloneType == 2) {
|
||||
Position = GetFramePoint(ts.Parent, ts.Track);
|
||||
Rotation = GetFrameRotation(ts.Parent, ts.Track);
|
||||
if (s.CloneType == 2) {
|
||||
if (!gogroup) return;
|
||||
Chart.Note tev = Event;
|
||||
if (tev.IsLong) {
|
||||
@@ -81,31 +126,35 @@ namespace Cryville.Crtr {
|
||||
if (ev == null) { }
|
||||
else if (ev.Unstamped == null) { }
|
||||
else if (ev.Unstamped is Chart.Judge) {
|
||||
var tev = (Chart.Judge)ev.Unstamped;
|
||||
Identifier name = default(Identifier);
|
||||
ChartPlayer.etor.ContextEvent = tev;
|
||||
ChartPlayer.etor.ContextEvent = ev.Unstamped;
|
||||
ChartPlayer.etor.ContextState = s;
|
||||
ChartPlayer.etor.Evaluate(new PropOp.Identifier(v => name = new Identifier(v)), ruleset.judges[tev.Id].input);
|
||||
judge.Prepare(ev.Time, ev.Time + ev.Duration, name, ruleset.judges[tev.Id], cs);
|
||||
judge.Prepare(ev, this);
|
||||
ChartPlayer.etor.ContextState = null;
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Anchor() {
|
||||
base.Anchor();
|
||||
foreach (var j in judges.Values) {
|
||||
if (!j.Judged) continue;
|
||||
PushAnchorEvent(j.AbsoluteTime, j.DynamicAnchors.Absolute);
|
||||
PushAnchorEvent(j.RelativeTime + cs.Time, j.DynamicAnchors.Relative);
|
||||
}
|
||||
}
|
||||
|
||||
public override void EndUpdate(ContainerState s) {
|
||||
if (s.CloneType == 2 && gogroup) {
|
||||
foreach (var i in sgos) i.Seal();
|
||||
#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
|
||||
a_tail.position = GetFramePoint(ts.Parent, ts.Track);
|
||||
a_tail.rotation = Quaternion.Euler(ts.Direction);
|
||||
a_tail.Transform.position = GetFramePoint(ts.Parent, ts.Track);
|
||||
a_tail.Transform.rotation = Quaternion.Euler(ts.Direction);
|
||||
#endif
|
||||
}
|
||||
OpenAnchor("tail");
|
||||
base.EndUpdate(s);
|
||||
CloseAnchor("tail");
|
||||
}
|
||||
|
||||
Vector3 GetFramePoint(ContainerState state, float track) {
|
||||
@@ -117,7 +166,7 @@ namespace Cryville.Crtr {
|
||||
return Quaternion.LookRotation(r, state.Normal);
|
||||
}
|
||||
|
||||
List<Vector3> ctrl = new List<Vector3>(2);
|
||||
readonly List<Vector3> ctrl = new List<Vector3>(2);
|
||||
Vector3 GetFrame(ContainerState state, float track, Func<ContainerState, Vector3> func) {
|
||||
// TODO
|
||||
int id = Mathf.FloorToInt(track);
|
||||
@@ -162,5 +211,11 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ReportJudge(Judge.JudgeEvent ev, float time, Identifier result) {
|
||||
JudgeState state;
|
||||
if (!judges.TryGetValue(ev.BaseEvent, out state)) return;
|
||||
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>();
|
||||
readonly Dictionary<int, PdtOperator> _ctxops = new Dictionary<int, PdtOperator>();
|
||||
|
||||
static readonly byte[] _nullbuf = new byte[0];
|
||||
readonly byte[] _numbuf = new byte[4];
|
||||
static readonly int _var_w = IdentifierManager.SharedInstance.Request("w");
|
||||
static readonly int _var_h = IdentifierManager.SharedInstance.Request("h");
|
||||
static readonly int _var_true = IdentifierManager.SharedInstance.Request("true");
|
||||
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; }
|
||||
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_false) { LoadNum(0); type = PdtInternalType.Number; value = _numbuf; }
|
||||
else if (name == _var_null) { LoadIdent(0); type = PdtInternalType.Undefined; value = _numbuf; }
|
||||
else {
|
||||
var id = new Identifier(name);
|
||||
PropSrc prop;
|
||||
@@ -29,7 +32,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
else if (ContextState != null && ChartPlayer.motionRegistry.ContainsKey(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)) {
|
||||
prop.Get(out type, out value);
|
||||
@@ -40,10 +43,14 @@ namespace Cryville.Crtr {
|
||||
RevokePotentialConstant();
|
||||
}
|
||||
else {
|
||||
PropSrc.Arbitrary result = ContextCascadeLookup(name);
|
||||
PropSrc result = ContextCascadeLookup(name);
|
||||
if (result != null) {
|
||||
result.Get(out type, out value);
|
||||
}
|
||||
else if (forced) {
|
||||
type = PdtInternalType.Error;
|
||||
value = _nullbuf;
|
||||
}
|
||||
else {
|
||||
type = PdtInternalType.Undefined;
|
||||
LoadIdent(name);
|
||||
@@ -84,9 +91,10 @@ namespace Cryville.Crtr {
|
||||
static readonly int _colop_and = IdentifierManager.SharedInstance.Request("&");
|
||||
static readonly int _colop_or = IdentifierManager.SharedInstance.Request("|");
|
||||
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;
|
||||
else if (name == _colop_or) return param.Type != PdtInternalType.Number || param.AsNumber() > 0;
|
||||
else throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", name));
|
||||
else throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", IdentifierManager.SharedInstance.Retrieve(name)));
|
||||
}
|
||||
|
||||
public ChartEvent ContextEvent { private get; set; }
|
||||
@@ -95,18 +103,22 @@ namespace Cryville.Crtr {
|
||||
public Judge ContextJudge { 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;
|
||||
public void ContextCascadeInsert() {
|
||||
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;
|
||||
}
|
||||
public PropSrc.Arbitrary ContextCascadeLookup(int name) {
|
||||
PropSrc.Arbitrary result;
|
||||
public PropSrc ContextCascadeLookup(int name) {
|
||||
PropSrc result;
|
||||
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)) {
|
||||
return result;
|
||||
}
|
||||
@@ -118,7 +130,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
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("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("in_area", 1), new func_in_area());
|
||||
_shortops.Add(new PdtOperatorSignature("is", 2), new func_is());
|
||||
}
|
||||
#region Operators
|
||||
#pragma warning disable IDE1006
|
||||
@@ -336,6 +349,17 @@ namespace Cryville.Crtr {
|
||||
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
|
||||
#region Contextual Functions
|
||||
class func_screen_edge : PdtOperator {
|
||||
|
@@ -72,19 +72,21 @@ namespace Cryville.Crtr {
|
||||
public class Enum<T> : PropOp {
|
||||
readonly static Dictionary<int, int> _cache = new Dictionary<int, int>();
|
||||
readonly Action<T> _cb;
|
||||
public Enum(Action<T> cb) {
|
||||
readonly Func<int, T> _caster;
|
||||
public Enum(Action<T> cb, Func<int, T> caster) {
|
||||
if (!typeof(T).IsEnum)
|
||||
throw new ArgumentException("Type is not enum");
|
||||
var names = typeof(T).GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
_cache[IdentifierManager.SharedInstance.Request(names[i].Name)] = Convert.ToInt32(names[i].GetValue(null));
|
||||
_cb = cb;
|
||||
_caster = caster;
|
||||
}
|
||||
protected override void Execute() {
|
||||
int result = 0;
|
||||
for (int i = 0; i < LoadedOperandCount; i++)
|
||||
result |= _cache[GetOperand(0).AsIdentifier()];
|
||||
_cb((T)(object)result);
|
||||
_cb(_caster(result));
|
||||
}
|
||||
}
|
||||
public class BeatTime : PropOp {
|
||||
|
@@ -4,52 +4,60 @@ using RBeatTime = Cryville.Crtr.BeatTime;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public abstract class PropSrc {
|
||||
int _type;
|
||||
byte[] _buf = null;
|
||||
public virtual void Invalidate() { _buf = null; }
|
||||
public void Get(out int type, out byte[] value) {
|
||||
if (_buf == null) InternalGet(out _type, out _buf);
|
||||
type = _type;
|
||||
value = _buf;
|
||||
public int Type { get; private set; }
|
||||
public PropSrc(int type) {
|
||||
Type = type;
|
||||
}
|
||||
protected abstract void InternalGet(out int type, out byte[] value);
|
||||
protected byte[] buf = null;
|
||||
protected virtual bool Invalidated { get { return buf == null; } }
|
||||
public virtual void Invalidate() { buf = null; }
|
||||
public void Get(out int type, out byte[] value) {
|
||||
if (Invalidated) InternalGet();
|
||||
type = Type;
|
||||
value = buf;
|
||||
}
|
||||
protected abstract void InternalGet();
|
||||
public class Arbitrary : PropSrc {
|
||||
public int Type { get; private set; }
|
||||
readonly byte[] _value;
|
||||
public Arbitrary(int type, byte[] value) {
|
||||
Type = type;
|
||||
public Arbitrary(int type, byte[] value) : base(type) {
|
||||
_value = value;
|
||||
}
|
||||
protected override void InternalGet(out int type, out byte[] value) {
|
||||
type = Type;
|
||||
value = _value;
|
||||
protected override void InternalGet() {
|
||||
buf = _value;
|
||||
}
|
||||
}
|
||||
public class Boolean : PropSrc {
|
||||
readonly Func<bool> _cb;
|
||||
public Boolean(Func<bool> cb) { _cb = cb; }
|
||||
protected override void InternalGet(out int type, out byte[] value) {
|
||||
type = PdtInternalType.Number;
|
||||
value = new byte[] { _cb() ? (byte)1 : (byte)0, 0, 0, 0 };
|
||||
bool m_invalidated = true;
|
||||
protected override bool Invalidated { get { return m_invalidated; } }
|
||||
public override void Invalidate() { m_invalidated = true; }
|
||||
public Boolean(Func<bool> cb) : base(PdtInternalType.Number) { _cb = cb; buf = new byte[4]; }
|
||||
protected override void InternalGet() {
|
||||
m_invalidated = false;
|
||||
buf[0] = _cb() ? (byte)1 : (byte)0;
|
||||
}
|
||||
}
|
||||
public class Float : PropSrc {
|
||||
readonly Func<float> _cb;
|
||||
public Float(Func<float> cb) { _cb = cb; }
|
||||
protected override void InternalGet(out int type, out byte[] value) {
|
||||
type = PdtInternalType.Number;
|
||||
value = BitConverter.GetBytes(_cb());
|
||||
bool m_invalidated = true;
|
||||
protected override bool Invalidated { get { return m_invalidated; } }
|
||||
public override void Invalidate() { m_invalidated = true; }
|
||||
public Float(Func<float> cb) : base(PdtInternalType.Number) { _cb = cb; buf = new byte[4]; }
|
||||
protected override unsafe void InternalGet() {
|
||||
m_invalidated = false;
|
||||
fixed (byte* _ptr = buf) {
|
||||
*(float*)_ptr = _cb();
|
||||
}
|
||||
}
|
||||
}
|
||||
public class String : PropSrc {
|
||||
readonly Func<string> _cb;
|
||||
public String(Func<string> cb) { _cb = cb; }
|
||||
protected override unsafe void InternalGet(out int type, out byte[] value) {
|
||||
type = PdtInternalType.String;
|
||||
public String(Func<string> cb) : base(PdtInternalType.String) { _cb = cb; }
|
||||
protected override unsafe void InternalGet() {
|
||||
var v = _cb();
|
||||
int strlen = v.Length;
|
||||
value = new byte[strlen * sizeof(char) + sizeof(int)];
|
||||
fixed (byte* _ptr = value) {
|
||||
buf = new byte[strlen * sizeof(char) + sizeof(int)];
|
||||
fixed (byte* _ptr = buf) {
|
||||
char* ptr = (char*)(_ptr + sizeof(int));
|
||||
*(int*)_ptr = strlen;
|
||||
int i = 0;
|
||||
@@ -59,20 +67,18 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public class Identifier : PropSrc {
|
||||
readonly Func<int> _cb;
|
||||
public Identifier(Func<int> cb) { _cb = cb; }
|
||||
protected override void InternalGet(out int type, out byte[] value) {
|
||||
type = PdtInternalType.Undefined;
|
||||
value = BitConverter.GetBytes(_cb());
|
||||
public Identifier(Func<int> cb) : base(PdtInternalType.Undefined) { _cb = cb; }
|
||||
protected override void InternalGet() {
|
||||
buf = BitConverter.GetBytes(_cb());
|
||||
}
|
||||
}
|
||||
public class BeatTime : PropSrc {
|
||||
readonly Func<RBeatTime> _cb;
|
||||
public BeatTime(Func<RBeatTime> cb) { _cb = cb; }
|
||||
protected override unsafe void InternalGet(out int type, out byte[] value) {
|
||||
public BeatTime(Func<RBeatTime> cb) : base(PdtInternalType.Vector) { _cb = cb; }
|
||||
protected override unsafe void InternalGet() {
|
||||
var bt = _cb();
|
||||
type = PdtInternalType.Vector;
|
||||
value = new byte[4 * sizeof(int)];
|
||||
fixed (byte* _ptr = value) {
|
||||
buf = new byte[4 * sizeof(int)];
|
||||
fixed (byte* _ptr = buf) {
|
||||
int* ptr = (int*)_ptr;
|
||||
*ptr++ = bt.b;
|
||||
*ptr++ = bt.n;
|
||||
|
@@ -34,6 +34,17 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
[Category("gameplay")]
|
||||
[Range(-1, 5)]
|
||||
public int ForceSyncFrames {
|
||||
get {
|
||||
return PlayerPrefs.GetInt("ForceSyncFrames", 5);
|
||||
}
|
||||
set {
|
||||
PlayerPrefs.SetInt("ForceSyncFrames", value);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[Category("data")]
|
||||
[Description("The directory where the game files are stored.")]
|
||||
|
@@ -1,3 +1,4 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Crtr.Components;
|
||||
using Cryville.Crtr.Event;
|
||||
@@ -11,100 +12,157 @@ namespace Cryville.Crtr {
|
||||
readonly PdtSkin skin;
|
||||
readonly List<DynamicProperty> dynprops = new List<DynamicProperty>();
|
||||
struct DynamicProperty {
|
||||
public Transform Anchor { get; set; }
|
||||
public RuntimeSkinContext Context { get; set; }
|
||||
public SkinPropertyKey Key { get; set; }
|
||||
public PdtExpression Value { get; set; }
|
||||
}
|
||||
readonly List<DynamicElement> dynelems = new List<DynamicElement>();
|
||||
struct DynamicElement {
|
||||
public Transform Anchor { get; set; }
|
||||
public RuntimeSkinContext Context { get; set; }
|
||||
public SkinSelectors Selectors { get; set; }
|
||||
public SkinElement Element { get; set; }
|
||||
}
|
||||
public SkinContainer(PdtSkin _skin) {
|
||||
skin = _skin;
|
||||
}
|
||||
public void MatchStatic(ContainerState context) {
|
||||
public void MatchStatic(ContainerState state) {
|
||||
dynprops.Clear(); dynelems.Clear();
|
||||
ChartPlayer.etor.ContextState = context;
|
||||
ChartPlayer.etor.ContextEvent = context.Container;
|
||||
MatchStatic(skin, context, context.Handler.gogroup);
|
||||
ChartPlayer.etor.ContextState = state;
|
||||
ChartPlayer.etor.ContextEvent = state.Container;
|
||||
MatchStatic(skin, state, new RuntimeSkinContext(state.Handler.SkinContext));
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
ChartPlayer.etor.ContextState = null;
|
||||
}
|
||||
void MatchStatic(SkinElement rel, ContainerState context, Transform anchor = null) {
|
||||
ChartPlayer.etor.ContextTransform = anchor;
|
||||
void MatchStatic(SkinElement rel, ContainerState state, RuntimeSkinContext ctx) {
|
||||
var rc = ctx.ReadContext;
|
||||
ChartPlayer.etor.ContextTransform = rc.Transform;
|
||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeInsert(rc.PropSrcs);
|
||||
foreach (var p in rel.properties) {
|
||||
if (p.Key.Name == 0)
|
||||
anchor.gameObject.AddComponent(p.Key.Component);
|
||||
rc.Transform.gameObject.AddComponent(p.Key.Component);
|
||||
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(
|
||||
new DynamicProperty { Anchor = anchor, Key = p.Key, Value = p.Value }
|
||||
new DynamicProperty { Context = ctx, Key = p.Key, Value = p.Value }
|
||||
);
|
||||
}
|
||||
}
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
foreach (var r in rel.elements) {
|
||||
try {
|
||||
var new_anchor = r.Key.MatchStatic(context, anchor);
|
||||
if (new_anchor != null) {
|
||||
MatchStatic(r.Value, context, new_anchor);
|
||||
var nctxs = r.Key.MatchStatic(state, rc);
|
||||
var roflag = r.Key.annotations.Contains("if");
|
||||
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(
|
||||
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;
|
||||
Profiler.BeginSample("SkinContainer.MatchDynamic");
|
||||
ChartPlayer.etor.ContextState = context;
|
||||
ChartPlayer.etor.ContextEvent = context.Container;
|
||||
ChartPlayer.etor.ContextState = state;
|
||||
ChartPlayer.etor.ContextEvent = state.Container;
|
||||
for (int i = 0; i < dynprops.Count; i++) {
|
||||
DynamicProperty p = dynprops[i];
|
||||
var prop = GetPropOp(p.Anchor, p.Key);
|
||||
if (context.CloneType > prop.UpdateCloneType) continue;
|
||||
var psrcs = p.Context.ReadContext.PropSrcs;
|
||||
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);
|
||||
if (psrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||
}
|
||||
for (int i = 0; i < dynelems.Count; i++) {
|
||||
DynamicElement e = dynelems[i];
|
||||
var anchor = e.Selectors.MatchDynamic(context, e.Anchor);
|
||||
if (anchor != null) MatchDynamic(e.Element, context, anchor);
|
||||
var psrcs = e.Context.ReadContext.PropSrcs;
|
||||
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.ContextState = null;
|
||||
Profiler.EndSample();
|
||||
}
|
||||
void MatchDynamic(SkinElement rel, ContainerState context, Transform anchor = null) {
|
||||
ChartPlayer.etor.ContextTransform = anchor;
|
||||
void MatchDynamic(SkinElement rel, ContainerState state, RuntimeSkinContext ctx) {
|
||||
var rc = ctx.ReadContext;
|
||||
ChartPlayer.etor.ContextTransform = rc.Transform;
|
||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeInsert(rc.PropSrcs);
|
||||
foreach (var p in rel.properties) {
|
||||
if (p.Key.Name == 0)
|
||||
throw new InvalidOperationException("Component creation in dynamic context is not allowed");
|
||||
var prop = GetPropOp(anchor, p.Key);
|
||||
if (context.CloneType > prop.UpdateCloneType) continue;
|
||||
var prop = GetPropOp(ctx.WriteTransform, p.Key);
|
||||
if (state.CloneType > prop.UpdateCloneType) continue;
|
||||
ChartPlayer.etor.Evaluate(prop.Operator, p.Value);
|
||||
}
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
foreach (var r in rel.elements) {
|
||||
if (!r.Key.IsUpdatable(context)) continue;
|
||||
var new_anchor = r.Key.MatchDynamic(context, anchor);
|
||||
if (new_anchor != null) {
|
||||
MatchDynamic(r.Value, context, new_anchor);
|
||||
}
|
||||
if (!r.Key.IsUpdatable(state)) continue;
|
||||
var nctx = r.Key.MatchDynamic(state, rc);
|
||||
if (nctx != null) MatchDynamic(r.Value, state, new RuntimeSkinContext(
|
||||
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) {
|
||||
var ctype = key.Component;
|
||||
var comp = (SkinComponent)obj.GetComponent(ctype);
|
||||
if (comp == null) throw new InvalidOperationException("Component instance not found");
|
||||
if (comp == null) throw new InvalidOperationException(string.Format(
|
||||
"Trying to set property {0} but the component is not found",
|
||||
IdentifierManager.SharedInstance.Retrieve(key.Name)
|
||||
));
|
||||
SkinProperty result;
|
||||
if (!comp.Properties.TryGetValue(key.Name, out result))
|
||||
throw new ArgumentException(string.Format("Property {0} not found on component", key.Name));
|
||||
throw new ArgumentException(string.Format(
|
||||
"Property {0} not found on component",
|
||||
IdentifierManager.SharedInstance.Retrieve(key.Name)
|
||||
));
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ namespace Cryville.Crtr {
|
||||
GetChar();
|
||||
if (cc == '.') {
|
||||
GetChar();
|
||||
s.Add(new SkinSelector.State(GetIdentifier()));
|
||||
s.Add(new SkinSelector.AtAnchor(GetIdentifier()));
|
||||
key = null;
|
||||
}
|
||||
else {
|
||||
|
@@ -1,3 +1,4 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Crtr.Components;
|
||||
using Cryville.Crtr.Event;
|
||||
@@ -6,15 +7,16 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using UnityEngine;
|
||||
using CAnchor = Cryville.Crtr.Anchor;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class SkinSelectors {
|
||||
readonly SkinSelector[] selectors;
|
||||
readonly string[] annotations;
|
||||
public readonly HashSet<string> annotations;
|
||||
|
||||
public SkinSelectors(IEnumerable<SkinSelector> s, IEnumerable<string> a) {
|
||||
selectors = s.ToArray();
|
||||
annotations = a.ToArray();
|
||||
annotations = a.ToHashSet();
|
||||
}
|
||||
public override string ToString() {
|
||||
if (selectors.Length == 0) return "";
|
||||
@@ -35,72 +37,71 @@ namespace Cryville.Crtr {
|
||||
selectors[i].Optimize(etor);
|
||||
}
|
||||
}
|
||||
public bool IsStatic {
|
||||
get {
|
||||
foreach (var s in selectors) {
|
||||
if (!s.IsStatic) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public Transform MatchStatic(ContainerState h, Transform anchor) {
|
||||
public IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext ctx) {
|
||||
IEnumerable<SkinContext> result = new SkinContext[] { ctx };
|
||||
foreach (var s in selectors) {
|
||||
anchor = s.Match(h, anchor);
|
||||
if (anchor == null) return null;
|
||||
result = result.SelectMany(l => s.MatchStatic(h, l));
|
||||
}
|
||||
return anchor;
|
||||
return result;
|
||||
}
|
||||
public bool IsUpdatable(ContainerState h) {
|
||||
foreach (var s in selectors)
|
||||
if (!s.IsUpdatable(h)) return false;
|
||||
return true;
|
||||
}
|
||||
public Transform MatchDynamic(ContainerState h, Transform anchor) {
|
||||
public SkinContext MatchDynamic(ContainerState h, SkinContext ctx) {
|
||||
foreach (var s in selectors) {
|
||||
anchor = s.Match(h, anchor, true);
|
||||
if (anchor == null) return null;
|
||||
ctx = s.MatchDynamic(h, ctx);
|
||||
if (ctx == null) return null;
|
||||
}
|
||||
return anchor;
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class SkinSelector {
|
||||
protected SkinSelector() { }
|
||||
public abstract bool IsStatic {
|
||||
get;
|
||||
}
|
||||
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) {
|
||||
return true;
|
||||
}
|
||||
public class CreateObject : SkinSelector {
|
||||
public CreateObject() { }
|
||||
public override bool IsStatic {
|
||||
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");
|
||||
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||
var obj = new GameObject("__obj__");
|
||||
obj.transform.SetParent(a, false);
|
||||
obj.transform.SetParent(c.Transform, false);
|
||||
obj.AddComponent<TransformInterface>();
|
||||
return obj.transform;
|
||||
return new SkinContext[] { new SkinContext(obj.transform) };
|
||||
}
|
||||
}
|
||||
public class Anchor : SkinSelector {
|
||||
public string Name { get; private set; }
|
||||
public int Name { get; private set; }
|
||||
public Anchor(string name) {
|
||||
Name = name;
|
||||
}
|
||||
public override bool IsStatic {
|
||||
get { return true; }
|
||||
Name = IdentifierManager.SharedInstance.Request(name);
|
||||
}
|
||||
|
||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
||||
return h.Handler.Anchors[Name].Transform;
|
||||
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||
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) {
|
||||
return h.Handler.Anchors[Name].Opened;
|
||||
return h.Handler.OpenedAnchor != null && h.Handler.OpenedAnchor.Name == Name;
|
||||
}
|
||||
}
|
||||
public class AtAnchor : SkinSelector {
|
||||
public int Name { get; private set; }
|
||||
public AtAnchor(string name) {
|
||||
Name = IdentifierManager.SharedInstance.Request(name);
|
||||
}
|
||||
public override SkinContext MatchDynamic(ContainerState h, SkinContext c) {
|
||||
return IsUpdatable(h) ? c : null;
|
||||
}
|
||||
public override bool IsUpdatable(ContainerState h) {
|
||||
return h.Handler.OpenedAnchor != null && h.Handler.OpenedAnchor.Name == Name;
|
||||
}
|
||||
}
|
||||
public class Property : SkinSelector {
|
||||
@@ -114,17 +115,22 @@ namespace Cryville.Crtr {
|
||||
public override void Optimize(PdtEvaluatorBase etor) {
|
||||
etor.Optimize(_exp);
|
||||
}
|
||||
public override bool IsStatic {
|
||||
get { return _exp.IsConstant; }
|
||||
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||
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) {
|
||||
ChartPlayer.etor.ContextTransform = a;
|
||||
public override SkinContext MatchDynamic(ContainerState h, SkinContext c) {
|
||||
return Match(c);
|
||||
}
|
||||
public SkinContext Match(SkinContext a) {
|
||||
ChartPlayer.etor.ContextTransform = a.Transform;
|
||||
try {
|
||||
ChartPlayer.etor.Evaluate(_op, _exp);
|
||||
return _flag ? a : null;
|
||||
}
|
||||
catch (Exception) {
|
||||
throw new SelectorNotStaticException();
|
||||
catch (Exception ex) {
|
||||
throw new SelectorNotAvailableException("The expression is not evaluatable under the current context", ex);
|
||||
}
|
||||
finally {
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
@@ -133,28 +139,22 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public class State : SkinSelector {
|
||||
public State(string state) { }
|
||||
public override bool IsStatic {
|
||||
get { return false; }
|
||||
}
|
||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
||||
return null; // TODO
|
||||
public override SkinContext MatchDynamic(ContainerState h, SkinContext c) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public class ElementType : SkinSelector {
|
||||
readonly string _type;
|
||||
public ElementType(string type) { _type = type; }
|
||||
public override bool IsStatic {
|
||||
get { return true; }
|
||||
}
|
||||
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
|
||||
return h.Handler.TypeName == _type ? a : null;
|
||||
public override IEnumerable<SkinContext> MatchStatic(ContainerState h, SkinContext c) {
|
||||
return h.Handler.TypeName == _type ? new SkinContext[] { c } : Enumerable.Empty<SkinContext>();
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SelectorNotStaticException : Exception {
|
||||
public SelectorNotStaticException() : base("The selector is not static") { }
|
||||
public SelectorNotStaticException(string message) : base(message) { }
|
||||
public SelectorNotStaticException(string message, Exception innerException) : base(message, innerException) { }
|
||||
protected SelectorNotStaticException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
public class SelectorNotAvailableException : Exception {
|
||||
public SelectorNotAvailableException() : base("The selector is not available under the current context") { }
|
||||
public SelectorNotAvailableException(string message) : base(message) { }
|
||||
public SelectorNotAvailableException(string message, Exception innerException) : base(message, innerException) { }
|
||||
protected SelectorNotAvailableException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
|
@@ -3,32 +3,18 @@ using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class SpriteFrame {
|
||||
#pragma warning disable IDE1006
|
||||
Rect _frame;
|
||||
public Rect frame {
|
||||
get { return _frame; }
|
||||
set { _frame = value; }
|
||||
}
|
||||
public Rect textureRect {
|
||||
get { return _frame; }
|
||||
set { _frame = value; }
|
||||
Rect m_frame;
|
||||
public Rect Frame {
|
||||
get { return m_frame; }
|
||||
set { m_frame = value; }
|
||||
}
|
||||
|
||||
bool _rotated = false;
|
||||
public bool rotated {
|
||||
get { return _rotated; }
|
||||
set { _rotated = value; }
|
||||
bool m_rotated = false;
|
||||
public bool Rotated {
|
||||
get { return m_rotated; }
|
||||
set { m_rotated = value; }
|
||||
}
|
||||
public bool textureRotated {
|
||||
get { return _rotated; }
|
||||
set { _rotated = value; }
|
||||
}
|
||||
#pragma warning restore IDE1006
|
||||
|
||||
public Vector2 offset;
|
||||
|
||||
public Rect sourceColorRect;
|
||||
public Vector2 sourceSize;
|
||||
private Rect _uv;
|
||||
private Vector2[] cuv;
|
||||
public Rect UV {
|
||||
@@ -41,7 +27,7 @@ namespace Cryville.Crtr {
|
||||
float x1 = Mathf.Max(_uv.xMin, _uv.xMax);
|
||||
float y0 = Mathf.Min(_uv.yMin, _uv.yMax);
|
||||
float y1 = Mathf.Max(_uv.yMin, _uv.yMax);
|
||||
if (_rotated) cuv = new Vector2[]{
|
||||
if (m_rotated) cuv = new Vector2[]{
|
||||
new Vector2(x0, y1),
|
||||
new Vector2(x1, y0),
|
||||
new Vector2(x0, y0),
|
||||
@@ -79,28 +65,17 @@ namespace Cryville.Crtr {
|
||||
public void Init() {
|
||||
if (Texture == null)
|
||||
throw new InvalidOperationException("Missing texture");
|
||||
_frame = new Rect(Vector2.zero, Size);
|
||||
var w = _frame.width;
|
||||
var h = _frame.height;
|
||||
float x = _frame.x / w;
|
||||
float y = 1 - _frame.y / h;
|
||||
float tw = (_rotated ? _frame.height : _frame.width) / w;
|
||||
float th = (_rotated ? _frame.width : _frame.height) / h;
|
||||
if (_rotated) UV = new Rect(x, y, tw, -th);
|
||||
m_frame = new Rect(Vector2.zero, Size);
|
||||
var w = m_frame.width;
|
||||
var h = m_frame.height;
|
||||
float x = m_frame.x / w;
|
||||
float y = 1 - m_frame.y / h;
|
||||
float tw = (m_rotated ? m_frame.height : m_frame.width) / w;
|
||||
float th = (m_rotated ? m_frame.width : m_frame.height) / h;
|
||||
if (m_rotated) UV = new Rect(x, y, tw, -th);
|
||||
else UV = new Rect(x, y, tw, -th);
|
||||
}
|
||||
|
||||
public void Init(int w, int h, Texture2D _base) {
|
||||
if (Texture != null)
|
||||
throw new InvalidOperationException("Missing texture");
|
||||
Texture = _base;
|
||||
float x = _frame.x / w;
|
||||
float y = 1 - _frame.y / h;
|
||||
float tw = (_rotated ? _frame.height : _frame.width) / w;
|
||||
float th = (_rotated ? _frame.width : _frame.height) / h;
|
||||
if (_rotated) UV = new Rect(x, y, tw, -th);
|
||||
else UV = new Rect(x, y, tw, -th);
|
||||
}
|
||||
public SpriteFrame() { }
|
||||
public SpriteFrame(Texture2D tex) {
|
||||
Texture = tex;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CAnchor = Cryville.Crtr.Anchor;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class StampedEvent : IComparable<StampedEvent> {
|
||||
@@ -9,7 +10,7 @@ namespace Cryville.Crtr {
|
||||
public EventContainer Container;
|
||||
public StampedEvent Origin;
|
||||
public List<StampedEvent> Subevents = new List<StampedEvent>();
|
||||
private StampedEvent attev = null;
|
||||
public List<StampedEvent> Coevents;
|
||||
private StampedEvent relev = null;
|
||||
|
||||
public double Duration {
|
||||
@@ -28,33 +29,13 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
public class PlaySound : StampedEvent {
|
||||
public new Chart.Sound Unstamped;
|
||||
public class Anchor : StampedEvent {
|
||||
public CAnchor Target;
|
||||
public override int Priority {
|
||||
get { return 0; }
|
||||
}
|
||||
}
|
||||
|
||||
public class Judge : StampedEvent {
|
||||
public float NoteTime;
|
||||
public JudgeDefinition TargetJudge;
|
||||
public Judge StartEvent;
|
||||
public bool IsEndJudge;
|
||||
public override int Priority {
|
||||
get { return StartEvent == null ? 4 : 6; }
|
||||
}
|
||||
protected override int CompareExtra(StampedEvent other) {
|
||||
return Equals(StartEvent, other) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public StampedEvent AttackEvent {
|
||||
get {
|
||||
if (attev == null) attev = Subevents.FirstOrDefault(ev => ev.Time == this.Time);
|
||||
return attev;
|
||||
}
|
||||
}
|
||||
|
||||
public StampedEvent ReleaseEvent {
|
||||
get {
|
||||
if (relev == null) relev = Subevents.FirstOrDefault(ev => ((InstantEvent)ev.Unstamped).IsRelease);
|
||||
|
@@ -1,71 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
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 int EventId;
|
||||
public double Time;
|
||||
public Chart chart;
|
||||
public List<T> events;
|
||||
/// <summary>
|
||||
/// The current time of the state in seconds.
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
public StateBase(Chart c, List<T> evs) {
|
||||
chart = c;
|
||||
events = evs;
|
||||
/// <summary>
|
||||
/// Creates an instance of the <see cref="StateBase{T}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="evs">The event list.</param>
|
||||
public StateBase(List<T> evs) {
|
||||
Events = evs;
|
||||
EventId = 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() {
|
||||
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) {
|
||||
dest.EventId = EventId;
|
||||
dest.Time = Time;
|
||||
dest.EventId = EventId;
|
||||
dest.breakflag = breakflag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interrupts the forward process.
|
||||
/// </summary>
|
||||
public virtual void Break() {
|
||||
breakflag = true;
|
||||
}
|
||||
|
||||
public void Forward(Action<T> callback = null) {
|
||||
ForwardToTime(double.PositiveInfinity, callback);
|
||||
/// <summary>
|
||||
/// Walks through all the remaining events.
|
||||
/// </summary>
|
||||
public void Forward() {
|
||||
ForwardToTime(double.PositiveInfinity);
|
||||
}
|
||||
|
||||
public void ForwardByTime(double time, Action<T> callback = null) {
|
||||
ForwardToTime(Time + time, callback);
|
||||
/// <summary>
|
||||
/// 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) {
|
||||
ForwardOnceToTime(Time + time, callback);
|
||||
/// <summary>
|
||||
/// 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;
|
||||
ForwardOnceToTime(Time, callback);
|
||||
ForwardOnceToTime(Time);
|
||||
while (Time < toTime) {
|
||||
ForwardOnceToTime(toTime, callback);
|
||||
ForwardOnceToTime(toTime);
|
||||
if (breakflag) break;
|
||||
}
|
||||
}
|
||||
|
||||
public void ForwardStepByTime(double time, double step, Action<T> callback = null) {
|
||||
ForwardStepToTime(Time + time, step, callback);
|
||||
/// <summary>
|
||||
/// 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;
|
||||
ForwardOnceToTime(Time, callback);
|
||||
ForwardOnceToTime(Time);
|
||||
while (Time < toTime) {
|
||||
double next = Time + step;
|
||||
ForwardOnceToTime(next < toTime ? next : toTime, callback);
|
||||
ForwardOnceToTime(next < toTime ? next : toTime);
|
||||
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 Chart.Track track;
|
||||
|
||||
public TrackHandler(GroupHandler gh, Chart.Track _track) : base() {
|
||||
track = _track;
|
||||
public TrackHandler(Chart.Track ev, GroupHandler gh) : base() {
|
||||
track = ev;
|
||||
this.gh = gh;
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ namespace Cryville.Crtr {
|
||||
ptime = s.Time;
|
||||
if (s.CloneType == 2) {
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
a_head.SetPositionAndRotation(GetCurrentWorldPoint(), Quaternion.Euler(s.Direction));
|
||||
a_head.Transform.SetPositionAndRotation(GetCurrentWorldPoint(), Quaternion.Euler(s.Direction));
|
||||
#else
|
||||
a_head.position = GetCurrentWorldPoint();
|
||||
a_head.rotation = Quaternion.Euler(s.Direction);
|
||||
a_head.Transform.position = GetCurrentWorldPoint();
|
||||
a_head.Transform.rotation = Quaternion.Euler(s.Direction);
|
||||
#endif
|
||||
}
|
||||
else if (s.CloneType == 3) {
|
||||
@@ -107,9 +107,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
public override void EndUpdate(ContainerState s) {
|
||||
OpenAnchor("tail");
|
||||
base.EndUpdate(s);
|
||||
CloseAnchor("tail");
|
||||
if (s.CloneType == 0 || s.CloneType == 2) {
|
||||
EndUpdatePosition(ts);
|
||||
var p = GetCurrentWorldPoint();
|
||||
@@ -118,10 +116,10 @@ namespace Cryville.Crtr {
|
||||
i.Seal();
|
||||
}
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
a_tail.SetPositionAndRotation(GetCurrentWorldPoint(), Quaternion.Euler(ts.Direction));
|
||||
a_tail.Transform.SetPositionAndRotation(GetCurrentWorldPoint(), Quaternion.Euler(ts.Direction));
|
||||
#else
|
||||
a_tail.position = GetCurrentWorldPoint();
|
||||
a_tail.rotation = Quaternion.Euler(ts.Direction);
|
||||
a_tail.Transform.position = GetCurrentWorldPoint();
|
||||
a_tail.Transform.rotation = Quaternion.Euler(ts.Direction);
|
||||
#endif
|
||||
}
|
||||
else if (s.CloneType == 3) EndUpdatePosition(ns);
|
||||
|
@@ -2,7 +2,8 @@
|
||||
"name": "Cryville.Crtr",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:d8ea0e0da3ad53a45b65c912ffcacab0"
|
||||
"GUID:d8ea0e0da3ad53a45b65c912ffcacab0",
|
||||
"GUID:5686e5ee69d0e084c843d61c240d7fdb"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -27,6 +27,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
[assembly: SuppressMessage("Style", "IDE0034")]
|
||||
|
||||
// Simplified new not supported
|
||||
[assembly: SuppressMessage("Style", "IDE0017")]
|
||||
[assembly: SuppressMessage("Style", "IDE0090")]
|
||||
|
||||
// Pattern matching not supported
|
||||
|
Binary file not shown.
8
Assets/Plugins/DiscordGameSDK.meta
Normal file
8
Assets/Plugins/DiscordGameSDK.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 431a8644546221a40a73de6618f11332
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
12
Assets/Plugins/DiscordGameSDK/ActivityManager.cs
Normal file
12
Assets/Plugins/DiscordGameSDK/ActivityManager.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
public partial class ActivityManager
|
||||
{
|
||||
public void RegisterCommand()
|
||||
{
|
||||
RegisterCommand(null);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Plugins/DiscordGameSDK/ActivityManager.cs.meta
Normal file
11
Assets/Plugins/DiscordGameSDK/ActivityManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bce5beb292181a43b6427b71e8a7e93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Plugins/DiscordGameSDK/Constants.cs
Normal file
9
Assets/Plugins/DiscordGameSDK/Constants.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
static class Constants
|
||||
{
|
||||
public const string DllName = "discord_game_sdk";
|
||||
}
|
||||
}
|
11
Assets/Plugins/DiscordGameSDK/Constants.cs.meta
Normal file
11
Assets/Plugins/DiscordGameSDK/Constants.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62db490eb0dffd64785623624a77cfd4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
4421
Assets/Plugins/DiscordGameSDK/Core.cs
Normal file
4421
Assets/Plugins/DiscordGameSDK/Core.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/Plugins/DiscordGameSDK/Core.cs.meta
Normal file
11
Assets/Plugins/DiscordGameSDK/Core.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 492875a0b937d86409c5dddd1d597026
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3
Assets/Plugins/DiscordGameSDK/DiscordGameSDK.asmdef
Normal file
3
Assets/Plugins/DiscordGameSDK/DiscordGameSDK.asmdef
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "DiscordGameSDK"
|
||||
}
|
7
Assets/Plugins/DiscordGameSDK/DiscordGameSDK.asmdef.meta
Normal file
7
Assets/Plugins/DiscordGameSDK/DiscordGameSDK.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5686e5ee69d0e084c843d61c240d7fdb
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
53
Assets/Plugins/DiscordGameSDK/ImageManager.cs
Normal file
53
Assets/Plugins/DiscordGameSDK/ImageManager.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
#if UNITY_EDITOR || UNITY_STANDALONE
|
||||
using UnityEngine;
|
||||
#endif
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
public partial struct ImageHandle
|
||||
{
|
||||
static public ImageHandle User(Int64 id)
|
||||
{
|
||||
return User(id, 128);
|
||||
}
|
||||
|
||||
static public ImageHandle User(Int64 id, UInt32 size)
|
||||
{
|
||||
return new ImageHandle
|
||||
{
|
||||
Type = ImageType.User,
|
||||
Id = id,
|
||||
Size = size,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ImageManager
|
||||
{
|
||||
public void Fetch(ImageHandle handle, FetchHandler callback)
|
||||
{
|
||||
Fetch(handle, false, callback);
|
||||
}
|
||||
|
||||
public byte[] GetData(ImageHandle handle)
|
||||
{
|
||||
var dimensions = GetDimensions(handle);
|
||||
var data = new byte[dimensions.Width * dimensions.Height * 4];
|
||||
GetData(handle, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR || UNITY_STANDALONE
|
||||
public Texture2D GetTexture(ImageHandle handle)
|
||||
{
|
||||
var dimensions = GetDimensions(handle);
|
||||
var texture = new Texture2D((int)dimensions.Width, (int)dimensions.Height, TextureFormat.RGBA32, false, true);
|
||||
texture.LoadRawTextureData(GetData(handle));
|
||||
texture.Apply();
|
||||
return texture;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
11
Assets/Plugins/DiscordGameSDK/ImageManager.cs.meta
Normal file
11
Assets/Plugins/DiscordGameSDK/ImageManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3cfde4503bedc444807a916e1ad2960
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
Assets/Plugins/DiscordGameSDK/LobbyManager.cs
Normal file
26
Assets/Plugins/DiscordGameSDK/LobbyManager.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
public partial class LobbyManager
|
||||
{
|
||||
public IEnumerable<User> GetMemberUsers(Int64 lobbyID)
|
||||
{
|
||||
var memberCount = MemberCount(lobbyID);
|
||||
var members = new List<User>();
|
||||
for (var i = 0; i < memberCount; i++)
|
||||
{
|
||||
members.Add(GetMemberUser(lobbyID, GetMemberUserId(lobbyID, i)));
|
||||
}
|
||||
return members;
|
||||
}
|
||||
|
||||
public void SendLobbyMessage(Int64 lobbyID, string data, SendLobbyMessageHandler handler)
|
||||
{
|
||||
SendLobbyMessage(lobbyID, Encoding.UTF8.GetBytes(data), handler);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Plugins/DiscordGameSDK/LobbyManager.cs.meta
Normal file
11
Assets/Plugins/DiscordGameSDK/LobbyManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d49d4d1d5cee72b40a22bf6f6bdd0309
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
Assets/Plugins/DiscordGameSDK/StorageManager.cs
Normal file
20
Assets/Plugins/DiscordGameSDK/StorageManager.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
public partial class StorageManager
|
||||
{
|
||||
public IEnumerable<FileStat> Files()
|
||||
{
|
||||
var fileCount = Count();
|
||||
var files = new List<FileStat>();
|
||||
for (var i = 0; i < fileCount; i++)
|
||||
{
|
||||
files.Add(StatAt(i));
|
||||
}
|
||||
return files;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Plugins/DiscordGameSDK/StorageManager.cs.meta
Normal file
11
Assets/Plugins/DiscordGameSDK/StorageManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75e55be5cce5be14ca292ed00ff90a43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Assets/Plugins/DiscordGameSDK/StoreManager.cs
Normal file
32
Assets/Plugins/DiscordGameSDK/StoreManager.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
public partial class StoreManager
|
||||
{
|
||||
public IEnumerable<Entitlement> GetEntitlements()
|
||||
{
|
||||
var count = CountEntitlements();
|
||||
var entitlements = new List<Entitlement>();
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
entitlements.Add(GetEntitlementAt(i));
|
||||
}
|
||||
return entitlements;
|
||||
}
|
||||
|
||||
public IEnumerable<Sku> GetSkus()
|
||||
{
|
||||
var count = CountSkus();
|
||||
var skus = new List<Sku>();
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
skus.Add(GetSkuAt(i));
|
||||
}
|
||||
return skus;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Plugins/DiscordGameSDK/StoreManager.cs.meta
Normal file
11
Assets/Plugins/DiscordGameSDK/StoreManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f28abb9e0c9477541bba93c5c21a7111
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Windows/x86.meta
Normal file
8
Assets/Plugins/Windows/x86.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 460f7228edb725a48a1fb6b5f4617ee9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Windows/x86/discord_game_sdk.dll
Normal file
BIN
Assets/Plugins/Windows/x86/discord_game_sdk.dll
Normal file
Binary file not shown.
BIN
Assets/Plugins/Windows/x86/discord_game_sdk.dll.lib
Normal file
BIN
Assets/Plugins/Windows/x86/discord_game_sdk.dll.lib
Normal file
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5b20befc03909345bd7d08158c02462
|
||||
guid: 751d95431111781498a1a512ad9edd8c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
70
Assets/Plugins/Windows/x86/discord_game_sdk.dll.meta
Normal file
70
Assets/Plugins/Windows/x86/discord_game_sdk.dll.meta
Normal file
@@ -0,0 +1,70 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bbe28aa384b7cf47bae3469ee3357a2
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 0
|
||||
Exclude OSXUniversal: 0
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: None
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/Windows/x86_64.meta
Normal file
8
Assets/Plugins/Windows/x86_64.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45f45105fdfb4d348baf39f50ea65c68
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Plugins/Windows/x86_64/discord_game_sdk.dll
Normal file
BIN
Assets/Plugins/Windows/x86_64/discord_game_sdk.dll
Normal file
Binary file not shown.
BIN
Assets/Plugins/Windows/x86_64/discord_game_sdk.dll.lib
Normal file
BIN
Assets/Plugins/Windows/x86_64/discord_game_sdk.dll.lib
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0215748675da6b43a2f70236d99e492
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
70
Assets/Plugins/Windows/x86_64/discord_game_sdk.dll.meta
Normal file
70
Assets/Plugins/Windows/x86_64/discord_game_sdk.dll.meta
Normal file
@@ -0,0 +1,70 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 212370df4e6cbbb4eb87395114fb6885
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux64: 0
|
||||
Exclude OSXUniversal: 0
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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}
|
Binary file not shown.
Reference in New Issue
Block a user