Code cleanup.
This commit is contained in:
@@ -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();
|
||||
|
@@ -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) {
|
||||
|
@@ -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; }
|
||||
|
||||
/// <summary>
|
||||
/// Prehandling <see cref="ContainerState"/>, prehandling the events.
|
||||
/// </summary>
|
||||
@@ -56,10 +59,6 @@ namespace Cryville.Crtr.Event {
|
||||
this.judge = judge;
|
||||
}
|
||||
|
||||
public ContainerHandler() { }
|
||||
public abstract string TypeName {
|
||||
get;
|
||||
}
|
||||
public readonly Dictionary<int, List<Anchor>> Anchors = new Dictionary<int, List<Anchor>>();
|
||||
public Anchor OpenedAnchor;
|
||||
protected Anchor a_cur;
|
||||
|
@@ -64,35 +64,7 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
}
|
||||
|
||||
readonly RMVPool RMVPool = new RMVPool();
|
||||
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.
|
||||
/// </summary>
|
||||
/// <param name="name">The motion name.</param>
|
||||
/// <param name="clone">Returns a cloned motion value instead.</param>
|
||||
/// <returns>A motion value.</returns>
|
||||
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<StampedEvent, RealtimeMotionValue> PlayingMotions = new Dictionary<StampedEvent, RealtimeMotionValue>(4);
|
||||
Dictionary<Identifier, RealtimeMotionValue> Values;
|
||||
Dictionary<Identifier, MotionCache> CachedValues;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a motion value.
|
||||
/// </summary>
|
||||
/// <param name="name">The motion name.</param>
|
||||
/// <param name="clone">Returns a cloned motion value instead.</param>
|
||||
/// <returns>A motion value.</returns>
|
||||
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<Vec1>(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
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -191,7 +191,7 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
|
||||
public void Anchor() {
|
||||
RootState.Anchor();
|
||||
if (RootState.Handler.Alive) RootState.Anchor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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<Chart.Judge, JudgeState> judges = new Dictionary<Chart.Judge, JudgeState>();
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user