Make animation time of subspan relative.
This commit is contained in:
@@ -9,7 +9,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
SubmitProperty("iteration", new PropOp.Float(v => Iteration = v));
|
SubmitProperty("iteration", new PropOp.Float(v => Iteration = v));
|
||||||
SubmitProperty("direction", new PropOp.Enum<AnimationDirection>(v => Direction = v, v => (AnimationDirection)v));
|
SubmitProperty("direction", new PropOp.Enum<AnimationDirection>(v => Direction = v, v => (AnimationDirection)v));
|
||||||
SubmitProperty("delay", new PropOp.Float(v => Delay = v));
|
SubmitProperty("delay", new PropOp.Float(v => Delay = v));
|
||||||
_rtimeSrc = new PropSrc.Float(() => _rtime);
|
|
||||||
Iteration = 1;
|
Iteration = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,8 +41,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
public float Delay { get; private set; }
|
public float Delay { get; private set; }
|
||||||
|
|
||||||
double _startTime;
|
double _startTime;
|
||||||
float _rtime;
|
|
||||||
readonly PropSrc _rtimeSrc;
|
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
_skinContext = new SkinContext(transform);
|
_skinContext = new SkinContext(transform);
|
||||||
@@ -52,7 +49,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
_startTime = time;
|
_startTime = time;
|
||||||
}
|
}
|
||||||
public override void Tick(SkinContainer c, double time) {
|
public override void Tick(SkinContainer c, double time) {
|
||||||
_rtime = (float)(time - _startTime - Delay) / Duration;
|
float _rtime = (float)(time - _startTime - Delay) / Duration;
|
||||||
if (_rtime < 0) _rtime = 0;
|
if (_rtime < 0) _rtime = 0;
|
||||||
else if (_rtime > Iteration) {
|
else if (_rtime > Iteration) {
|
||||||
if (Direction.HasFlag(AnimationDirection.alternate)) {
|
if (Direction.HasFlag(AnimationDirection.alternate)) {
|
||||||
@@ -74,10 +71,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Direction.HasFlag(AnimationDirection.reverse)) _rtime = 1 - _rtime;
|
if (Direction.HasFlag(AnimationDirection.reverse)) _rtime = 1 - _rtime;
|
||||||
_rtimeSrc.Invalidate();
|
|
||||||
ChartPlayer.etor.ContextSelfValue = _rtimeSrc;
|
|
||||||
if (_anim != null) c.MatchAnimation(_anim, _rtime, new RuntimeSkinContext(_skinContext));
|
if (_anim != null) c.MatchAnimation(_anim, _rtime, new RuntimeSkinContext(_skinContext));
|
||||||
ChartPlayer.etor.ContextSelfValue = null;
|
|
||||||
}
|
}
|
||||||
protected override void OnDestroy() { }
|
protected override void OnDestroy() { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace Cryville.Crtr {
|
|||||||
_group = group;
|
_group = group;
|
||||||
_rootElement = rootElement;
|
_rootElement = rootElement;
|
||||||
for (int i = 0; i < _stacks.Length; i++) _stacks[i] = new DynamicStack();
|
for (int i = 0; i < _stacks.Length; i++) _stacks[i] = new DynamicStack();
|
||||||
|
_rtimeSrc = new PropSrc.Float(() => _rtime);
|
||||||
}
|
}
|
||||||
public void MatchStatic() {
|
public void MatchStatic() {
|
||||||
var stack = _stacks[0];
|
var stack = _stacks[0];
|
||||||
@@ -140,13 +141,22 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||||
}
|
}
|
||||||
|
float _rtime;
|
||||||
|
readonly PropSrc _rtimeSrc;
|
||||||
public void MatchAnimation(AnimationSpan span, float rtime, RuntimeSkinContext ctx) {
|
public void MatchAnimation(AnimationSpan span, float rtime, RuntimeSkinContext ctx) {
|
||||||
|
ChartPlayer.etor.ContextSelfValue = _rtimeSrc;
|
||||||
|
MatchAnimationInternal(span, rtime, ctx);
|
||||||
|
ChartPlayer.etor.ContextSelfValue = null;
|
||||||
|
}
|
||||||
|
void MatchAnimationInternal(AnimationSpan span, float rtime, RuntimeSkinContext ctx) {
|
||||||
|
_rtime = rtime;
|
||||||
|
_rtimeSrc.Invalidate();
|
||||||
foreach (var p in span.properties) {
|
foreach (var p in span.properties) {
|
||||||
p.Key.ExecuteDynamic(_group, ctx, p.Value, 0);
|
p.Key.ExecuteDynamic(_group, ctx, p.Value, 0);
|
||||||
}
|
}
|
||||||
foreach (var s in span.spans) {
|
foreach (var s in span.spans) {
|
||||||
if (rtime < s.Key.Behind || rtime >= s.Key.Ahead) continue;
|
if (rtime < s.Key.Behind || rtime >= s.Key.Ahead) continue;
|
||||||
MatchAnimation(s.Value, rtime, ctx);
|
MatchAnimationInternal(s.Value, (rtime - s.Key.Behind) / (s.Key.Ahead - s.Key.Behind), ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user