diff --git a/Assets/Cryville/Crtr/ChartHandler.cs b/Assets/Cryville/Crtr/ChartHandler.cs index 6813738..40ed5c0 100644 --- a/Assets/Cryville/Crtr/ChartHandler.cs +++ b/Assets/Cryville/Crtr/ChartHandler.cs @@ -14,11 +14,7 @@ namespace Cryville.Crtr { chart = _chart; } - public override string TypeName { - get { - return "chart"; - } - } + public override string TypeName { get { return "chart"; } } public override void PreInit() { base.PreInit(); diff --git a/Assets/Cryville/Crtr/ChartPlayer.cs b/Assets/Cryville/Crtr/ChartPlayer.cs index 543a274..5741587 100644 --- a/Assets/Cryville/Crtr/ChartPlayer.cs +++ b/Assets/Cryville/Crtr/ChartPlayer.cs @@ -19,6 +19,7 @@ using Logger = Cryville.Common.Logger; namespace Cryville.Crtr { public class ChartPlayer : MonoBehaviour { + #region Fields Chart chart; Skin skin; PdtSkin pskin; @@ -66,6 +67,7 @@ namespace Cryville.Crtr { public static PdtEvaluator etor; InputProxy inputProxy; + #endregion #region MonoBehaviour void Start() { @@ -437,10 +439,10 @@ namespace Cryville.Crtr { Logger.Log("main", 1, "Game", "Stopping"); Game.AudioSession = Game.AudioSequencer.NewSession(); inputProxy.Deactivate(); - if (cbus != null) { cbus.Dispose(); cbus = null; } - if (bbus != null) { bbus.Dispose(); bbus = null; } - if (tbus != null) { tbus.Dispose(); tbus = null; } if (nbus != null) { nbus.Dispose(); nbus = null; } + if (tbus != null) { tbus.Dispose(); tbus = null; } + if (bbus != null) { bbus.Dispose(); bbus = null; } + if (cbus != null) { cbus.Dispose(); cbus = null; } Logger.Log("main", 1, "Game", "Stopped"); } catch (Exception ex) { diff --git a/Assets/Cryville/Crtr/Event/ContainerHandler.cs b/Assets/Cryville/Crtr/Event/ContainerHandler.cs index 87aea8b..edb8282 100644 --- a/Assets/Cryville/Crtr/Event/ContainerHandler.cs +++ b/Assets/Cryville/Crtr/Event/ContainerHandler.cs @@ -7,7 +7,10 @@ using System.Globalization; using UnityEngine; namespace Cryville.Crtr.Event { - public abstract class ContainerHandler : IDisposable { + public abstract class ContainerHandler { + public ContainerHandler() { } + public abstract string TypeName { get; } + /// /// Prehandling , prehandling the events. /// @@ -56,10 +59,6 @@ namespace Cryville.Crtr.Event { this.judge = judge; } - public ContainerHandler() { } - public abstract string TypeName { - get; - } public readonly Dictionary> Anchors = new Dictionary>(); public Anchor OpenedAnchor; protected Anchor a_cur; diff --git a/Assets/Cryville/Crtr/Event/ContainerState.cs b/Assets/Cryville/Crtr/Event/ContainerState.cs index c2c8d7b..950a3f4 100644 --- a/Assets/Cryville/Crtr/Event/ContainerState.cs +++ b/Assets/Cryville/Crtr/Event/ContainerState.cs @@ -64,35 +64,7 @@ namespace Cryville.Crtr.Event { } } - readonly RMVPool RMVPool = new RMVPool(); - readonly MotionCachePool MCPool = new MotionCachePool(); - Dictionary PlayingMotions = new Dictionary(4); - Dictionary Values; - Dictionary CachedValues; - - /// - /// Gets a motion value. - /// - /// The motion name. - /// Returns a cloned motion value instead. - /// A motion value. - RealtimeMotionValue GetMotionValue(Identifier name, bool clone = false) { - RealtimeMotionValue value = Values[name]; - if (clone) return value.Clone(); - return value; - } - - void InvalidateMotion(Identifier name) { - MotionCache cache; - if (!CachedValues.TryGetValue(name, out cache)) - CachedValues.Add(name, cache = MCPool.Rent(name)); - cache.Valid = false; - ValidateChildren(); - foreach (var c in WorkingChildren) - Children[c].InvalidateMotion(name); - } - - public ContainerState(Chart c, EventContainer _ev, ContainerState parent = null) { + public ContainerState(EventContainer _ev, ContainerState parent = null) { Container = _ev; if (parent != null) { @@ -189,7 +161,7 @@ namespace Cryville.Crtr.Event { public void Dispose() { if (Disposed) return; Disposed = true; - if (CloneType < 16 && Handler != null) Handler.Dispose(); + if (CloneType == 1) Handler.Dispose(); foreach (var s in Children) s.Value.Dispose(); RMVPool.ReturnAll(); @@ -206,6 +178,35 @@ namespace Cryville.Crtr.Event { public void AttachSystems(PdtSkin skin, Judge judge) { Handler.AttachSystems(skin, judge); } + #endregion + + #region Motion + readonly RMVPool RMVPool = new RMVPool(); + readonly MotionCachePool MCPool = new MotionCachePool(); + Dictionary PlayingMotions = new Dictionary(4); + Dictionary Values; + Dictionary CachedValues; + + /// + /// Gets a motion value. + /// + /// The motion name. + /// Returns a cloned motion value instead. + /// A motion value. + RealtimeMotionValue GetMotionValue(Identifier name, bool clone = false) { + RealtimeMotionValue value = Values[name]; + if (clone) return value.Clone(); + return value; + } + + void InvalidateMotion(Identifier name) { + MotionCache cache; + if (!CachedValues.TryGetValue(name, out cache)) + CachedValues.Add(name, cache = MCPool.Rent(name)); + cache.Valid = false; + foreach (var c in ActiveChildren) + Children[c].InvalidateMotion(name); + } public Vector GetRawValue(Identifier key) { MotionCache tr; @@ -299,7 +300,9 @@ namespace Cryville.Crtr.Event { return GetRawValue(n_track).Value; } } + #endregion + #region Update bool breakflag = false; public void Break() { @@ -431,5 +434,6 @@ namespace Cryville.Crtr.Event { if (ls.Handler.Alive) ls.Anchor(); } } + #endregion } } diff --git a/Assets/Cryville/Crtr/Event/EventBatcher.cs b/Assets/Cryville/Crtr/Event/EventBatcher.cs index 6061eb7..1e61c3d 100644 --- a/Assets/Cryville/Crtr/Event/EventBatcher.cs +++ b/Assets/Cryville/Crtr/Event/EventBatcher.cs @@ -37,7 +37,7 @@ namespace Cryville.Crtr.Event { } void AddEventContainer(EventContainer c, ContainerState parent = null) { - var cs = new ContainerState(chart, c, parent); + var cs = new ContainerState(c, parent); stateMap.Add(c, cs); if (parent == null) { cs.Depth = 0; diff --git a/Assets/Cryville/Crtr/Event/EventBus.cs b/Assets/Cryville/Crtr/Event/EventBus.cs index da2e60d..a630832 100644 --- a/Assets/Cryville/Crtr/Event/EventBus.cs +++ b/Assets/Cryville/Crtr/Event/EventBus.cs @@ -191,7 +191,7 @@ namespace Cryville.Crtr.Event { } public void Anchor() { - RootState.Anchor(); + if (RootState.Handler.Alive) RootState.Anchor(); } } } diff --git a/Assets/Cryville/Crtr/GroupHandler.cs b/Assets/Cryville/Crtr/GroupHandler.cs index 68f4c4e..792a359 100644 --- a/Assets/Cryville/Crtr/GroupHandler.cs +++ b/Assets/Cryville/Crtr/GroupHandler.cs @@ -15,11 +15,7 @@ namespace Cryville.Crtr { this.ch = ch; } - public override string TypeName { - get { - return "group"; - } - } + public override string TypeName { get { return "group"; } } public override void PreInit() { base.PreInit(); diff --git a/Assets/Cryville/Crtr/NoteHandler.cs b/Assets/Cryville/Crtr/NoteHandler.cs index acafbd1..4f1bffd 100644 --- a/Assets/Cryville/Crtr/NoteHandler.cs +++ b/Assets/Cryville/Crtr/NoteHandler.cs @@ -15,11 +15,7 @@ namespace Cryville.Crtr { this.gh = gh; } - public override string TypeName { - get { - return "note"; - } - } + public override string TypeName { get { return "note"; } } SectionalGameObject[] sgos; readonly Dictionary judges = new Dictionary(); diff --git a/Assets/Cryville/Crtr/TrackHandler.cs b/Assets/Cryville/Crtr/TrackHandler.cs index b4ebc21..c6db0fb 100644 --- a/Assets/Cryville/Crtr/TrackHandler.cs +++ b/Assets/Cryville/Crtr/TrackHandler.cs @@ -12,11 +12,7 @@ namespace Cryville.Crtr { this.gh = gh; } - public override string TypeName { - get { - return "track"; - } - } + public override string TypeName { get { return "track"; } } public override void Init() { base.Init();