Code cleanup with the implementation of property store.
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Cryville.Crtr {
|
||||
readonly SkinElement _rootElement;
|
||||
readonly DynamicStack[] _stacks = new DynamicStack[3];
|
||||
readonly HashSet<SkinPropertyKey> _once = new HashSet<SkinPropertyKey>();
|
||||
public readonly IntKeyedDictionary<SkinVariable> Variables = new IntKeyedDictionary<SkinVariable>();
|
||||
public readonly IntKeyedDictionary<PropStores.Float> Variables = new IntKeyedDictionary<PropStores.Float>();
|
||||
|
||||
class DynamicStack {
|
||||
public readonly List<DynamicProperty> Properties = new List<DynamicProperty>();
|
||||
@@ -34,7 +34,6 @@ namespace Cryville.Crtr {
|
||||
_group = group;
|
||||
_rootElement = rootElement;
|
||||
for (int i = 0; i < _stacks.Length; i++) _stacks[i] = new DynamicStack();
|
||||
_rtimeSrc = new PropSrc.Float(() => _rtime);
|
||||
}
|
||||
public void MatchStatic() {
|
||||
var stack = _stacks[0];
|
||||
@@ -151,18 +150,16 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
if (rc.PropSrcs != null) PdtEvaluator.Instance.ContextCascadeDiscard();
|
||||
}
|
||||
float _rtime;
|
||||
readonly PropSrc _rtimeSrc;
|
||||
readonly PropStores.Float _rtimest = new PropStores.Float();
|
||||
public void MatchAnimation(AnimationSpan span, float rtime, RuntimeSkinContext ctx) {
|
||||
PdtEvaluator.Instance.ContextSkinContainer = this;
|
||||
PdtEvaluator.Instance.ContextSelfValue = _rtimeSrc;
|
||||
PdtEvaluator.Instance.ContextSelfValue = _rtimest.Source;
|
||||
MatchAnimationInternal(span, rtime, ctx);
|
||||
PdtEvaluator.Instance.ContextSelfValue = null;
|
||||
PdtEvaluator.Instance.ContextSkinContainer = null;
|
||||
}
|
||||
void MatchAnimationInternal(AnimationSpan span, float rtime, RuntimeSkinContext ctx) {
|
||||
_rtime = rtime;
|
||||
_rtimeSrc.Invalidate();
|
||||
_rtimest.Value = rtime;
|
||||
foreach (var p in span.properties) {
|
||||
p.Key.ExecuteDynamic(_group, ctx, p.Value, Variables, 0);
|
||||
}
|
||||
@@ -215,17 +212,4 @@ namespace Cryville.Crtr {
|
||||
void RegisterAnchor(int name);
|
||||
void PushAnchorEvent(double time, int name);
|
||||
}
|
||||
public class SkinVariable {
|
||||
float _value;
|
||||
public PropOp Op { get; private set; }
|
||||
public PropSrc Src { get; private set; }
|
||||
public SkinVariable() {
|
||||
Op = new PropOp.Float(Set);
|
||||
Src = new PropSrc.Float(() => _value);
|
||||
}
|
||||
void Set(float value) {
|
||||
_value = value;
|
||||
Src.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user