Tokenize ruleset keys. Remove MotionName.
This commit is contained in:
@@ -66,9 +66,9 @@ namespace Cryville.Crtr.Event {
|
||||
|
||||
readonly RMVPool RMVPool = new RMVPool();
|
||||
protected Dictionary<StampedEvent, RealtimeMotionValue> PlayingMotions = new Dictionary<StampedEvent, RealtimeMotionValue>();
|
||||
protected Dictionary<MotionName, RealtimeMotionValue> Values = new Dictionary<MotionName, RealtimeMotionValue>();
|
||||
protected Dictionary<MotionName, Vector> CachedValues = new Dictionary<MotionName, Vector>();
|
||||
protected Dictionary<MotionName, bool> CachedValueStates = new Dictionary<MotionName, bool>();
|
||||
protected Dictionary<Identifier, RealtimeMotionValue> Values;
|
||||
protected Dictionary<Identifier, Vector> CachedValues;
|
||||
protected Dictionary<Identifier, bool> CachedValueStates;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a motion value.
|
||||
@@ -76,12 +76,12 @@ namespace Cryville.Crtr.Event {
|
||||
/// <param name="name">The motion name.</param>
|
||||
/// <param name="clone">Returns a cloned motion value instead.</param>
|
||||
/// <returns>A motion value.</returns>
|
||||
RealtimeMotionValue GetMotionValue(MotionName name, bool clone = false) {
|
||||
RealtimeMotionValue GetMotionValue(Identifier name, bool clone = false) {
|
||||
RealtimeMotionValue value;
|
||||
if (!Values.TryGetValue(name, out value)) {
|
||||
value = new RealtimeMotionValue().Init(Parent == null
|
||||
? ChartPlayer.motionRegistry[name.MainName].GlobalInitValue
|
||||
: ChartPlayer.motionRegistry[name.MainName].InitValue
|
||||
? ChartPlayer.motionRegistry[name].GlobalInitValue
|
||||
: ChartPlayer.motionRegistry[name].InitValue
|
||||
);
|
||||
Values.Add(name, value);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ namespace Cryville.Crtr.Event {
|
||||
return value;
|
||||
}
|
||||
|
||||
void InvalidateMotion(MotionName name) {
|
||||
void InvalidateMotion(Identifier name) {
|
||||
CachedValueStates[name] = false;
|
||||
foreach (var c in Children)
|
||||
c.Value.InvalidateMotion(name);
|
||||
@@ -103,8 +103,11 @@ namespace Cryville.Crtr.Event {
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
Values = new Dictionary<Identifier, RealtimeMotionValue>(ChartPlayer.motionRegistry.Count);
|
||||
CachedValues = new Dictionary<Identifier, Vector>(ChartPlayer.motionRegistry.Count);
|
||||
CachedValueStates = new Dictionary<Identifier, bool>(ChartPlayer.motionRegistry.Count);
|
||||
foreach (var m in ChartPlayer.motionRegistry)
|
||||
Values.Add(new MotionName(m.Key), new RealtimeMotionValue().Init(Parent == null ? m.Value.GlobalInitValue : m.Value.InitValue));
|
||||
Values.Add(m.Key, new RealtimeMotionValue().Init(Parent == null ? m.Value.GlobalInitValue : m.Value.InitValue));
|
||||
}
|
||||
|
||||
static void AddChild(EventContainer c, ContainerState s, ContainerState target) {
|
||||
@@ -117,19 +120,19 @@ namespace Cryville.Crtr.Event {
|
||||
public ContainerState Clone(byte ct) {
|
||||
var r = (ContainerState)MemberwiseClone();
|
||||
|
||||
var mvs = new Dictionary<MotionName, RealtimeMotionValue>(Values.Count);
|
||||
var mvs = new Dictionary<Identifier, RealtimeMotionValue>(ChartPlayer.motionRegistry.Count);
|
||||
foreach (var mv in Values) {
|
||||
mvs.Add(mv.Key, mv.Value.Clone());
|
||||
}
|
||||
r.Values = mvs;
|
||||
|
||||
var cvs = new Dictionary<MotionName, Vector>(CachedValues.Count);
|
||||
var cvs = new Dictionary<Identifier, Vector>(ChartPlayer.motionRegistry.Count);
|
||||
foreach (var cv in CachedValues) {
|
||||
cvs.Add(cv.Key, cv.Value.Clone());
|
||||
}
|
||||
r.CachedValues = cvs;
|
||||
|
||||
var cvss = new Dictionary<MotionName, bool>(CachedValueStates.Count);
|
||||
var cvss = new Dictionary<Identifier, bool>(ChartPlayer.motionRegistry.Count);
|
||||
foreach (var cv in CachedValueStates) {
|
||||
cvss.Add(cv.Key, cv.Value);
|
||||
}
|
||||
@@ -211,7 +214,7 @@ namespace Cryville.Crtr.Event {
|
||||
this.judge = judge;
|
||||
}
|
||||
|
||||
public T GetRawValue<T>(MotionName key) where T : Vector {
|
||||
public T GetRawValue<T>(Identifier key) where T : Vector {
|
||||
Vector tr;
|
||||
if (!CachedValues.TryGetValue(key, out tr)) {
|
||||
tr = (Vector)ReflectionHelper.InvokeEmptyConstructor(typeof(T));
|
||||
@@ -232,7 +235,15 @@ namespace Cryville.Crtr.Event {
|
||||
return r;
|
||||
}
|
||||
|
||||
static readonly MotionName n_dir = new MotionName("dir");
|
||||
static readonly Identifier n_pt = new Identifier("pt");
|
||||
public Vector2 ScreenPoint {
|
||||
get {
|
||||
var mv = GetRawValue<VecPt>(n_pt);
|
||||
return mv.ToVector2(ChartPlayer.hitRect);
|
||||
}
|
||||
}
|
||||
|
||||
static readonly Identifier n_dir = new Identifier("dir");
|
||||
public Vector3 Direction {
|
||||
get {
|
||||
Vec3 r = GetRawValue<Vec3>(n_dir);
|
||||
@@ -240,7 +251,7 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
}
|
||||
|
||||
static readonly MotionName n_normal = new MotionName("normal");
|
||||
static readonly Identifier n_normal = new Identifier("normal");
|
||||
public Vector3 Normal {
|
||||
get {
|
||||
Vec3 r = GetRawValue<Vec3>(n_normal);
|
||||
@@ -254,16 +265,8 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
}
|
||||
|
||||
static readonly MotionName n_pt = new MotionName("pt");
|
||||
public Vector2 ScreenPoint {
|
||||
get {
|
||||
var mv = GetRawValue<VecPt>(n_pt);
|
||||
return mv.ToVector2(ChartPlayer.hitRect);
|
||||
}
|
||||
}
|
||||
|
||||
static readonly MotionName n_sv = new MotionName("sv");
|
||||
static readonly MotionName n_svm = new MotionName("svm");
|
||||
static readonly Identifier n_sv = new Identifier("sv");
|
||||
static readonly Identifier n_svm = new Identifier("svm");
|
||||
public float ScrollVelocity {
|
||||
get {
|
||||
return GetRawValue<VecPtComp>(n_sv).ToFloat(ChartPlayer.hitRect)
|
||||
@@ -271,7 +274,7 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
}
|
||||
|
||||
static readonly MotionName n_dist = new MotionName("dist");
|
||||
static readonly Identifier n_dist = new Identifier("dist");
|
||||
public float Distance {
|
||||
get {
|
||||
var mv = GetRawValue<VecPtComp>(n_dist);
|
||||
@@ -279,15 +282,15 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
}
|
||||
|
||||
static readonly MotionName n_corner = new MotionName("corner");
|
||||
static readonly Identifier n_corner = new Identifier("corner");
|
||||
public bool Corner {
|
||||
get {
|
||||
return GetRawValue<VecI1>(n_corner).Value % 2 >= 1;
|
||||
}
|
||||
}
|
||||
|
||||
static readonly MotionName n_ctrl0 = new MotionName("ctrl0");
|
||||
static readonly MotionName n_ctrl1 = new MotionName("ctrl1");
|
||||
static readonly Identifier n_ctrl0 = new Identifier("ctrl0");
|
||||
static readonly Identifier n_ctrl1 = new Identifier("ctrl1");
|
||||
public Vector3 GetControlPoint(bool alt1, float deltaz) {
|
||||
var mv = GetRawValue<VecCtrl>(alt1 ? n_ctrl1 : n_ctrl0);
|
||||
if (alt1 && mv.IsZero()) {
|
||||
@@ -296,7 +299,7 @@ namespace Cryville.Crtr.Event {
|
||||
return mv.ToVector3(ChartPlayer.hitRect, deltaz);
|
||||
}
|
||||
|
||||
static readonly MotionName n_track = new MotionName("track");
|
||||
static readonly Identifier n_track = new Identifier("track");
|
||||
public float Track {
|
||||
get {
|
||||
return GetRawValue<Vec1>(n_track).Value;
|
||||
|
Reference in New Issue
Block a user