44 Commits
0.5.1 ... 0.5.2

Author SHA1 Message Date
9f73c8ffad Code cleanup. 2023-01-21 20:14:41 +08:00
c1c354959d Add MotionCache. 2023-01-21 20:13:40 +08:00
94428d9e18 Append IDE warning suppression. 2023-01-21 20:12:03 +08:00
5198ecec1f Optimize code structure for input module. 2023-01-21 17:04:29 +08:00
6779b88055 Code cleanup. 2023-01-21 16:59:19 +08:00
c5dab3a232 Refactor SelectorNotAvailableException. 2023-01-20 22:50:31 +08:00
a7608bcd7e Matches dynamic on anchoring. 2023-01-20 22:50:05 +08:00
be64bc76b5 Revert "Revise update clone type to update depth."
This reverts commit 4185303bd2.
2023-01-20 22:26:56 +08:00
39bc34fd42 Fix dynamic judge anchors not updated if note is not working. 2023-01-17 22:16:40 +08:00
4185303bd2 Revise update clone type to update depth. 2023-01-17 22:16:09 +08:00
3280693e8f Update project version. 2023-01-16 22:11:19 +08:00
29432feabc Fix error on "(at) anchor" selector when no anchor is opened. 2023-01-16 20:57:19 +08:00
86559c681e Fix relative time calculation in judge report. 2023-01-16 20:55:32 +08:00
79f11b9c33 Implement judge_result contextual variable. 2023-01-16 20:54:53 +08:00
5b9149cb34 Make the output type of a property source read-only. 2023-01-16 20:53:45 +08:00
9d6bdd968f Implement write-only context. 2023-01-16 20:50:14 +08:00
bc4fec33ef Add null constant. 2023-01-16 20:47:54 +08:00
09e917dbe8 Add is function. 2023-01-16 20:46:57 +08:00
1003a0e199 Add forced variable syntax in PDT. 2023-01-16 20:45:06 +08:00
e3a805b855 Implement skin context property source injection. 2023-01-16 15:23:57 +08:00
4222176979 Add temporary event discard handling. 2023-01-16 15:09:34 +08:00
43c87fba70 Wrap Transform into SkinContext. Implement r/w context separation for skins. 2023-01-16 15:08:25 +08:00
d0a23aaf30 Add static judge anchor. Change dynamic anchors to single only. 2023-01-16 13:35:51 +08:00
a09a5686d7 Change anchor opening to single only. 2023-01-16 13:33:25 +08:00
609bb317d0 Code cleanup. 2023-01-15 11:54:11 +08:00
898fb7d557 Pull down chart field from StateBase. 2023-01-15 11:52:28 +08:00
c39f258a19 Code cleanup. 2023-01-14 22:03:08 +08:00
4fdd4e1935 Implement multiple static matching. 2023-01-14 22:01:29 +08:00
7662011d60 Pull down some judge preparation logic. 2023-01-14 21:39:10 +08:00
c24372b308 Pull up tail anchoring. 2023-01-14 21:35:15 +08:00
5e4c53113a Revise anchor data structure. 2023-01-14 21:34:13 +08:00
4f93995bbd Pull down EvaluationFailureException. 2023-01-13 22:18:13 +08:00
5b14466059 Add error handling for Discord callback. 2023-01-13 22:16:16 +08:00
1d3aa85446 Fix polysec.part. Enable judge anchor. 2023-01-13 16:46:29 +08:00
6efe70d751 Implement coevent. (2) 2023-01-13 16:37:31 +08:00
555c88855c Adapt Bestdori chart converter to coevents. 2023-01-12 18:05:20 +08:00
105aacc133 Fix config scene not unloaded if the ruleset is not present. 2023-01-10 21:41:48 +08:00
ea9000f2b0 Cleanup. 2023-01-09 22:17:42 +08:00
4e851d9b73 Implement coevent. 2023-01-09 16:28:36 +08:00
0a1e512f41 Code cleanup. 2023-01-08 16:27:02 +08:00
a7baef2c9d Add NoRequireDiscord flag when initializing Discord GameSDK. 2023-01-08 13:00:35 +08:00
723ec937ad Remove callback parameters on states. 2023-01-03 12:09:16 +08:00
7c77ba83f8 Fix polysec not mapping textures correctly if texture set partly. 2023-01-03 11:58:39 +08:00
6da4b96b24 Optimize motion invalidation performance. 2023-01-02 20:05:14 +08:00
44 changed files with 860 additions and 916 deletions

View File

@@ -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) { }
}
}

View File

@@ -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);
}

View File

@@ -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,

View File

@@ -48,9 +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 (!_rfreq && !noset) throw new InvalidOperationException("Return frame not set");
if (!_rfreq && !noset) throw new EvaluationFailureException("Return frame not set");
}
/// <summary>
/// Executes the operator.

View File

@@ -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>

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View 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();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8fd2d5f1c7ba0c74c9ce8775075750db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}

View File

@@ -12,18 +12,18 @@ 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();
}
}

View File

@@ -12,18 +12,18 @@ 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();
}
}

View File

@@ -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;

View File

@@ -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);
}
}
}

View File

@@ -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 {
@@ -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);

View File

@@ -149,6 +149,7 @@ namespace Cryville.Crtr {
nbus.BroadcastEndUpdate();
nbus.Anchor();
tbus.StripTempEvents();
tbus.ForwardStepByTime(clippingDist, step);
tbus.ForwardStepByTime(renderDist, step);
tbus.BroadcastEndUpdate();
@@ -484,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);
@@ -515,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;
@@ -537,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);
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);
}

View File

@@ -19,7 +19,7 @@ namespace Cryville.Crtr.Components {
public SectionalGameObject() {
SubmitProperty("partial", new PropOp.Boolean(v => part = Part.idle));
SubmitProperty("part", new PropOp.Enum<Part>(v => part = v, v => (Part)v));
SubmitProperty("part", new PropOp.Enum<Part>(v => part = v, v => (Part)v), 2);
}
protected override void OnDestroy() {
@@ -152,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;
@@ -192,13 +193,13 @@ namespace Cryville.Crtr.Components {
if (body.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trib, body, ref i, ref t, ref l, headLength, sumLength - tailLength, vcpsec, hvc + bvc); }
if (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;

View File

@@ -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(

View File

@@ -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);
});
}

View File

@@ -1,6 +1,7 @@
using Discord;
using System;
using UnityEngine;
using Logger = Cryville.Common.Logger;
namespace Cryville.Crtr {
internal class DiscordController : MonoBehaviour {
@@ -16,22 +17,42 @@ namespace Cryville.Crtr {
void Start() {
Instance = this;
launchTime = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
dc = new Discord.Discord(CLIENT_ID, (UInt64)CreateFlags.Default);
am = dc.GetActivityManager();
SetIdle();
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() {
dc.RunCallbacks();
if (dc == null) return;
try {
dc.RunCallbacks();
}
catch (ResultException ex) {
dc.Dispose();
dc = null;
Logger.Log("main", 4, "Discord", "An error occured while running callbacks: {0}", ex);
}
}
void OnApplicationQuit() {
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,
@@ -40,6 +61,7 @@ namespace Cryville.Crtr {
}
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",

View File

@@ -36,12 +36,9 @@ 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<int, Anchor> Anchors = new Dictionary<int, Anchor>();
protected Transform a_cur;
protected Transform a_head;
protected Transform a_tail;
public Vector3 Position { get; protected set; }
public Quaternion Rotation { get; protected set; }
public bool Alive { get; private set; }
@@ -63,22 +60,31 @@ 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_cur = RegisterAnchor(_a_cur).Transform;
a_head = RegisterAnchor(_a_head).Transform;
a_tail = RegisterAnchor(_a_tail).Transform;
a_cur = RegisterAnchor(_a_cur);
a_head = RegisterAnchor(_a_head);
a_tail = RegisterAnchor(_a_tail);
}
protected Anchor RegisterAnchor(int name) {
protected Anchor RegisterAnchor(int name, bool hasPropSrcs = false) {
var go = new GameObject("." + IdentifierManager.SharedInstance.Retrieve(name)).transform;
go.SetParent(gogroup, false);
var result = new Anchor() { Transform = go };
Anchors.Add(name, result);
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;
}
@@ -102,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(_a_head);
}
protected virtual void Awake(ContainerState s) {
CloseAnchor(_a_head);
if (gogroup) CloseAnchor();
}
protected virtual void GetPosition(ContainerState s) { }
public virtual void StartUpdate(ContainerState s) {
@@ -121,27 +129,37 @@ namespace Cryville.Crtr.Event {
}
static readonly SimpleObjectPool<StampedEvent.Anchor> anchorEvPool
= new SimpleObjectPool<StampedEvent.Anchor>(1024);
protected void PushAnchorEvent(int name, double time) {
protected void PushAnchorEvent(double time, Anchor anchor) {
var tev = anchorEvPool.Rent();
tev.Time = time;
tev.Container = Container;
tev.Name = name;
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) {
if (ev is StampedEvent.Anchor) {
var tev = (StampedEvent.Anchor)ev;
if (gogroup) {
OpenAnchor(tev.Name);
Anchors[tev.Name].Transform.SetPositionAndRotation(Position, Rotation);
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(tev.Name);
CloseAnchor();
}
anchorEvPool.Return(tev);
}
@@ -150,17 +168,23 @@ namespace Cryville.Crtr.Event {
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() {
if (cs.Working) PushAnchorEvent(_a_cur, cs.Time);
skinContainer.MatchDynamic(cs);
if (cs.Working) PushAnchorEvent(cs.Time, a_cur);
}
protected void OpenAnchor(int name) {
if (Anchors.ContainsKey(name)) Anchors[name].Open();
protected void OpenAnchor(Anchor anchor) {
if (OpenedAnchor != null) throw new InvalidOperationException("An anchor has been opened");
OpenedAnchor = anchor;
}
protected void CloseAnchor(int name) {
if (Anchors.ContainsKey(name)) Anchors[name].Close();
protected void CloseAnchor() {
OpenedAnchor = null;
}
}
}

View File

@@ -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,6 +193,7 @@ namespace Cryville.Crtr.Event {
foreach (var s in Children)
s.Value.Dispose();
RMVPool.ReturnAll();
MCPool.ReturnAll();
}
public void AttachHandler(ContainerHandler h) {
@@ -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 = RMVPool.Rent(key).AbsoluteValue;
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)

View File

@@ -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;
}
}
}

View File

@@ -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,7 +29,7 @@ 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>();
@@ -86,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() {
@@ -107,8 +116,22 @@ namespace Cryville.Crtr.Event {
tempEvents.Insert(index, ev);
}
public override void ForwardOnceToTime(double toTime, Action<EventBatch> callback = null) {
double time1 = EventId < events.Count ? events[EventId].Time : double.PositiveInfinity;
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) {
@@ -116,22 +139,22 @@ namespace Cryville.Crtr.Event {
foreach (var s in workingStates) s.Handle(null);
ValidateStates();
if (time1 == time0) {
var batch = events[EventId];
var batch = Events[EventId];
for (var i = 0; i < batch.Count; i++) {
var ev = batch[i];
if (ev.Container != null) {
EnsureActivity(ev.Container);
if (ev.Unstamped is EventContainer) EnsureActivity((EventContainer)ev.Unstamped);
else EnsureActivity(ev.Container);
states[ev.Container].Handle(ev);
}
if (ev.Unstamped is EventContainer) {
if (ev.Container != null) EnsureActivity((EventContainer)ev.Unstamped);
}
else if (ev.Coevents != 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);

View 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);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5d11b50a98974254f87273c94ed20de7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -24,10 +24,9 @@ namespace Cryville.Crtr.Event {
= new SimpleObjectPool<Dictionary<RealtimeMotionValue, Identifier>>(1024);
Dictionary<RealtimeMotionValue, Identifier> _rented;
public RealtimeMotionValue Rent(Identifier name) {
var n = name;
var obj = _buckets[n].Rent();
var obj = _buckets[name].Rent();
if (_rented == null) _rented = _dictPool.Rent();
_rented.Add(obj, n);
_rented.Add(obj, name);
return obj;
}
public void Return(RealtimeMotionValue obj) {
@@ -35,6 +34,7 @@ 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();

View File

@@ -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;

View File

@@ -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]++;

View File

@@ -21,7 +21,7 @@ namespace Cryville.Crtr {
public double EndTime { get; set; }
public double StartClip { get; set; }
public double EndClip { get; set; }
public Identifier JudgeId { get; set; }
public Chart.Judge BaseEvent { get; set; }
public JudgeDefinition Definition { get; set; }
public NoteHandler Handler { get; set; }
}
@@ -37,20 +37,24 @@ namespace Cryville.Crtr {
InitJudges();
InitScores();
}
public void Prepare(double st, double et, Identifier input, Identifier judge, NoteHandler handler) {
public void Prepare(StampedEvent sev, NoteHandler handler) {
var tev = (Chart.Judge)sev.Unstamped;
Identifier input = default(Identifier);
ChartPlayer.etor.Evaluate(new PropOp.Identifier(v => input = new Identifier(v)), _rs.judges[tev.Id].input);
double st = sev.Time, et = st + sev.Duration;
List<JudgeEvent> list;
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[judge];
var def = _rs.judges[tev.Id];
var ev = new JudgeEvent {
StartTime = st,
EndTime = et,
StartClip = st + def.clip[0],
EndClip = et + def.clip[1],
JudgeId = judge,
BaseEvent = tev,
Definition = def,
Handler = handler,
};
@@ -60,10 +64,12 @@ namespace Cryville.Crtr {
}
#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));
}
@@ -246,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;
}
@@ -257,7 +264,7 @@ namespace Cryville.Crtr {
_buf = null;
}
}
protected override unsafe int InternalGet() {
protected override unsafe void InternalGet() {
var src = _cb();
int strlen = src.Length;
buf = _pool.Rent(sizeof(int) + strlen * sizeof(char));
@@ -267,7 +274,6 @@ namespace Cryville.Crtr {
int i = 0;
foreach (var c in src) ptr[i++] = c;
}
return PdtInternalType.String;
}
}
#endregion

View File

@@ -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,19 +941,27 @@ namespace Cryville.Crtr {
}
}
public class VectorSrc : PropSrc {
readonly Func<Vector> _cb;
public VectorSrc(Func<Vector> cb) { _cb = cb; }
protected override unsafe int InternalGet() {
var arr = _cb().ToArray();
if (arr.Length == 1) {
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];
}
return PdtInternalType.Number;
}
else {
}
class IVector : VectorSrc {
public IVector(Func<Vector> cb) : base(cb, PdtInternalType.Vector) { }
protected override unsafe void InternalGet() {
var arr = _cb().ToArray();
buf = new byte[sizeof(float) * arr.Length + sizeof(int)];
fixed (byte* rptr = buf) {
var ptr = (float*)rptr;
@@ -946,7 +970,6 @@ namespace Cryville.Crtr {
}
*(int*)ptr = PdtInternalType.Number;
}
return PdtInternalType.Vector;
}
}
}

View File

@@ -10,11 +10,9 @@ namespace Cryville.Crtr {
public class NoteHandler : ContainerHandler {
readonly GroupHandler gh;
public readonly Chart.Note Event;
readonly PdtRuleset ruleset;
public NoteHandler(GroupHandler gh, Chart.Note ev, PdtRuleset rs) : base() {
this.gh = gh;
public NoteHandler(Chart.Note ev, GroupHandler gh) : base() {
Event = ev;
ruleset = rs;
this.gh = gh;
}
public override string TypeName {
@@ -24,43 +22,69 @@ namespace Cryville.Crtr {
}
SectionalGameObject[] sgos;
readonly Dictionary<Identifier, JudgeState> judges = new Dictionary<Identifier, JudgeState>();
readonly Dictionary<Chart.Judge, JudgeState> judges = new Dictionary<Chart.Judge, JudgeState>();
readonly Dictionary<int, DynamicJudgeAnchorPair> dynJudgeAnchors = new Dictionary<int, DynamicJudgeAnchorPair>();
class JudgeState {
public int AbsoluteAnchorName { get; set; }
public int RelativeAnchorName { get; set; }
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) {
handler.RegisterAnchor(AbsoluteAnchorName = handler.judge.jtabsMap[name]);
handler.RegisterAnchor(RelativeAnchorName = handler.judge.jtrelMap[name]);
StaticAnchor = handler.RegisterAnchor(handler.judge.judgeMap[name], true);
DynamicAnchors = handler.GetDynamicJudgeAnchorPair(name);
}
public void MarkJudged(float abs, float rel) {
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) {
if (!judges.ContainsKey(j.Id)) {
judges.Add(j.Id, new JudgeState(this, j.Id.Key));
}
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) {
@@ -102,12 +126,9 @@ 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, tev.Id, this);
judge.Prepare(ev, this);
ChartPlayer.etor.ContextState = null;
ChartPlayer.etor.ContextEvent = null;
}
@@ -116,12 +137,10 @@ namespace Cryville.Crtr {
public override void Anchor() {
base.Anchor();
if (cs.Working) {
foreach (var j in judges.Values) {
if (!j.Judged) continue;
// PushAnchorEvent(j.AbsoluteAnchorName, j.AbsoluteTime);
// PushAnchorEvent(j.RelativeAnchorName, j.RelativeTime + cs.Time);
}
foreach (var j in judges.Values) {
if (!j.Judged) continue;
PushAnchorEvent(j.AbsoluteTime, j.DynamicAnchors.Absolute);
PushAnchorEvent(j.RelativeTime + cs.Time, j.DynamicAnchors.Relative);
}
}
@@ -129,15 +148,13 @@ namespace Cryville.Crtr {
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(_a_tail);
base.EndUpdate(s);
CloseAnchor(_a_tail);
}
Vector3 GetFramePoint(ContainerState state, float track) {
@@ -197,8 +214,8 @@ namespace Cryville.Crtr {
public void ReportJudge(Judge.JudgeEvent ev, float time, Identifier result) {
JudgeState state;
if (!judges.TryGetValue(ev.JudgeId, out state)) return;
state.MarkJudged(time, (float)(time - cs.Time));
if (!judges.TryGetValue(ev.BaseEvent, out state)) return;
state.MarkJudged(time, (float)(ev.StartTime - time), result.Key);
}
}
}

View File

@@ -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,6 +91,7 @@ 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}", IdentifierManager.SharedInstance.Retrieve(name)));
@@ -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 {

View File

@@ -4,26 +4,26 @@ using RBeatTime = Cryville.Crtr.BeatTime;
namespace Cryville.Crtr {
public abstract class PropSrc {
int _type;
public int Type { get; private set; }
public PropSrc(int type) {
Type = type;
}
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) _type = InternalGet();
type = _type;
if (Invalidated) InternalGet();
type = Type;
value = buf;
}
protected abstract int InternalGet();
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 int InternalGet() {
protected override void InternalGet() {
buf = _value;
return Type;
}
}
public class Boolean : PropSrc {
@@ -31,11 +31,10 @@ namespace Cryville.Crtr {
bool m_invalidated = true;
protected override bool Invalidated { get { return m_invalidated; } }
public override void Invalidate() { m_invalidated = true; }
public Boolean(Func<bool> cb) { _cb = cb; buf = new byte[4]; }
protected override int InternalGet() {
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;
return PdtInternalType.Number;
}
}
public class Float : PropSrc {
@@ -43,19 +42,18 @@ namespace Cryville.Crtr {
bool m_invalidated = true;
protected override bool Invalidated { get { return m_invalidated; } }
public override void Invalidate() { m_invalidated = true; }
public Float(Func<float> cb) { _cb = cb; buf = new byte[4]; }
protected override unsafe int InternalGet() {
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();
}
return PdtInternalType.Number;
}
}
public class String : PropSrc {
readonly Func<string> _cb;
public String(Func<string> cb) { _cb = cb; }
protected override unsafe int InternalGet() {
public String(Func<string> cb) : base(PdtInternalType.String) { _cb = cb; }
protected override unsafe void InternalGet() {
var v = _cb();
int strlen = v.Length;
buf = new byte[strlen * sizeof(char) + sizeof(int)];
@@ -65,21 +63,19 @@ namespace Cryville.Crtr {
int i = 0;
foreach (var c in v) ptr[i++] = c;
}
return PdtInternalType.String;
}
}
public class Identifier : PropSrc {
readonly Func<int> _cb;
public Identifier(Func<int> cb) { _cb = cb; }
protected override int InternalGet() {
public Identifier(Func<int> cb) : base(PdtInternalType.Undefined) { _cb = cb; }
protected override void InternalGet() {
buf = BitConverter.GetBytes(_cb());
return PdtInternalType.Undefined;
}
}
public class BeatTime : PropSrc {
readonly Func<RBeatTime> _cb;
public BeatTime(Func<RBeatTime> cb) { _cb = cb; }
protected override unsafe int InternalGet() {
public BeatTime(Func<RBeatTime> cb) : base(PdtInternalType.Vector) { _cb = cb; }
protected override unsafe void InternalGet() {
var bt = _cb();
buf = new byte[4 * sizeof(int)];
fixed (byte* _ptr = buf) {
@@ -89,7 +85,6 @@ namespace Cryville.Crtr {
*ptr++ = bt.d;
*ptr++ = PdtInternalType.Number;
}
return PdtInternalType.Vector;
}
}
}

View File

@@ -12,91 +12,108 @@ 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;
@@ -114,4 +131,38 @@ namespace Cryville.Crtr {
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;
}
}
}
}

View File

@@ -7,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 "";
@@ -36,56 +37,42 @@ 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 {
@@ -93,15 +80,16 @@ namespace Cryville.Crtr {
public Anchor(string name) {
Name = IdentifierManager.SharedInstance.Request(name);
}
public override bool IsStatic {
get { return true; }
}
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 {
@@ -109,16 +97,11 @@ namespace Cryville.Crtr {
public AtAnchor(string name) {
Name = IdentifierManager.SharedInstance.Request(name);
}
public override bool IsStatic {
get { return false; }
}
public override Transform Match(ContainerState h, Transform a, bool dyn = false) {
if (!dyn) throw new SelectorNotStaticException();
return IsUpdatable(h) ? a : null;
public override SkinContext MatchDynamic(ContainerState h, SkinContext c) {
return IsUpdatable(h) ? c : null;
}
public override bool IsUpdatable(ContainerState h) {
return h.Handler.Anchors[Name].Opened;
return h.Handler.OpenedAnchor != null && h.Handler.OpenedAnchor.Name == Name;
}
}
public class Property : SkinSelector {
@@ -132,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;
@@ -151,29 +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) {
if (!dyn) throw new SelectorNotStaticException();
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) { }
}
}

View File

@@ -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 {
@@ -29,19 +30,12 @@ namespace Cryville.Crtr {
}
public class Anchor : StampedEvent {
public int Name;
public CAnchor Target;
public override int Priority {
get { return 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);

View File

@@ -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);
}
}

View File

@@ -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(_a_tail);
base.EndUpdate(s);
CloseAnchor(_a_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);

View File

@@ -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

View File

@@ -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}

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: a5b20befc03909345bd7d08158c02462
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: