Fix index invalidation for effects.

This commit is contained in:
2023-02-19 22:13:57 +08:00
parent 887837bb3d
commit 3728360dd2
2 changed files with 15 additions and 4 deletions

View File

@@ -23,8 +23,16 @@ namespace Cryville.Crtr {
_indexSrc = new PropSrc.Float(() => Index); _indexSrc = new PropSrc.Float(() => Index);
_durationOp = new PropOp.Float(v => _duration = v); _durationOp = new PropOp.Float(v => _duration = v);
} }
public float Index { get; set; } private float m_index;
static readonly int _var_index = IdentifierManager.SharedInstance.Request("index"); public float Index {
get { return m_index; }
set {
if (m_index == value) return;
m_index = value;
_indexSrc.Invalidate();
}
}
internal static readonly int _VAR_INDEX = IdentifierManager.SharedInstance.Request("index");
readonly PropSrc _indexSrc; readonly PropSrc _indexSrc;
double _startTime; double _startTime;
float _duration; float _duration;
@@ -34,7 +42,7 @@ namespace Cryville.Crtr {
_startTime = time; _startTime = time;
RootTransform.gameObject.SetActive(true); RootTransform.gameObject.SetActive(true);
ChartPlayer.etor.ContextCascadeInsert(); ChartPlayer.etor.ContextCascadeInsert();
ChartPlayer.etor.ContextCascadeUpdate(_var_index, _indexSrc); ChartPlayer.etor.ContextCascadeUpdate(_VAR_INDEX, _indexSrc);
ChartPlayer.etor.Evaluate(_durationOp, _def.duration); ChartPlayer.etor.Evaluate(_durationOp, _def.duration);
_skinContainer.MatchDynamic(this, 0); _skinContainer.MatchDynamic(this, 0);
ChartPlayer.etor.ContextCascadeDiscard(); ChartPlayer.etor.ContextCascadeDiscard();
@@ -60,7 +68,9 @@ namespace Cryville.Crtr {
} }
public int CompareTo(EffectInstance other) { public int CompareTo(EffectInstance other) {
return EndTime.CompareTo(other.EndTime); int r = EndTime.CompareTo(other.EndTime);
if (r != 0) return r;
return GetHashCode().CompareTo(other.GetHashCode());
} }
} }
} }

View File

@@ -59,6 +59,7 @@ namespace Cryville.Crtr {
foreach (var e in effects) { foreach (var e in effects) {
var effect = e.Value; var effect = e.Value;
etor.ContextCascadeInsert(); etor.ContextCascadeInsert();
etor.ContextCascadeUpdate(EffectInstance._VAR_INDEX, PropSrc.Error);
etor.Optimize(effect.duration); etor.Optimize(effect.duration);
effect.elements.Optimize(etor); effect.elements.Optimize(etor);
etor.ContextCascadeDiscard(); etor.ContextCascadeDiscard();