Add animation stub and effect stub for skin.

This commit is contained in:
2023-02-15 18:12:41 +08:00
parent b6e238780e
commit eb6dafbd60
6 changed files with 118 additions and 6 deletions

View File

@@ -32,8 +32,28 @@ namespace Cryville.Crtr {
}
[Binder(typeof(PdtBinder))]
public class PdtSkin : SkinElement {
public Dictionary<Identifier, EffectDefinition> effects = new Dictionary<Identifier, EffectDefinition>();
public class PdtSkin {
public Dictionary<Identifier, AnimationSpan> animations
= new Dictionary<Identifier, AnimationSpan>();
public Dictionary<Identifier, EffectDefinition> effects
= new Dictionary<Identifier, EffectDefinition>();
public SkinElement elements;
public void Optimize(PdtEvaluator etor) {
foreach (var animation in animations.Values) {
animation.Optimize(etor);
}
foreach (var effect in effects.Values) {
etor.ContextCascadeInsert();
if (effect.args != null) foreach (var i in effect.args) {
etor.ContextCascadeUpdate(i.Key, PropSrc.Error);
}
etor.Optimize(effect.duration);
effect.elements.Optimize(etor);
etor.ContextCascadeDiscard();
}
elements.Optimize(etor);
}
}
public class SkinElement {
@@ -69,9 +89,25 @@ namespace Cryville.Crtr {
public class EffectDefinition {
public Identifier[] args;
public PdtExpression duration;
public SkinElement elements;
}
public class AnimationSpan {
[ElementList]
public Dictionary<SkinSelectors, SkinElement> elements
= new Dictionary<SkinSelectors, SkinElement>();
public Dictionary<Clip, AnimationSpan> spans
= new Dictionary<Clip, AnimationSpan>();
[PropertyList]
public Dictionary<SkinPropertyKey, PdtExpression> properties
= new Dictionary<SkinPropertyKey, PdtExpression>();
public void Optimize(PdtEvaluator etor) {
foreach (var p in properties.Values) {
etor.Optimize(p);
}
foreach (var e in spans.Values) {
e.Optimize(etor);
}
}
}
}