Code cleanup with the implementation of property store.

This commit is contained in:
2023-08-02 17:20:45 +08:00
parent e34a9cc868
commit 5393ff1451
9 changed files with 122 additions and 99 deletions

View File

@@ -22,29 +22,23 @@ namespace Cryville.Crtr {
PdtEvaluator.Instance.ContextCascadeDiscardBlock();
_comps = RootTransform.GetComponentsInChildren<SkinComponent>();
foreach (var i in _comps) i.Init();
_indexSrc = new PropSrc.Float(() => Index);
_durationOp = new PropOp.Float(v => _duration = v);
}
public void Rewind(double time, Transform target) {
_startTime = time;
foreach (var i in _comps) i.Rewind(time, target);
}
private float m_index;
public float Index {
get { return m_index; }
set {
if (m_index == value) return;
m_index = value;
_indexSrc.Invalidate();
}
}
Transform _currentTarget;
Identifier _currentStateName = Identifier.Empty;
EffectState _currentState;
ChartEvent _ctxev;
ContainerState _ctxstate;
internal static readonly int _VAR_EFFECT_INDEX = IdentifierManager.Shared.Request("effect_index");
readonly PropSrc _indexSrc;
readonly PropStores.Float _indexst = new PropStores.Float();
public float Index {
get { return _indexst.Value; }
set { _indexst.Value = value; }
}
double _startTime;
float _duration;
readonly PropOp _durationOp;
@@ -74,7 +68,7 @@ namespace Cryville.Crtr {
Rewind(time, target);
RootTransform.gameObject.SetActive(true);
PdtEvaluator.Instance.ContextCascadeInsert();
PdtEvaluator.Instance.ContextCascadeUpdate(_VAR_EFFECT_INDEX, _indexSrc);
PdtEvaluator.Instance.ContextCascadeUpdate(_VAR_EFFECT_INDEX, _indexst.Source);
PdtEvaluator.Instance.Evaluate(_durationOp, _currentState.duration);
_skinContainer.MatchDynamic(1, emitting);
PdtEvaluator.Instance.ContextCascadeDiscard();