using System.Collections.Generic;
public interface IAnimation {
public interface ISeekable {
public interface IAnimationCollection : IAnimation {
public IAnimationCollection AddChildAnimation<U>(U child) where U: IAnimation;
public class DeterministicAnimation : IAnimation, ISeekable {
public void Seek(int t) { }
public class PhysicsAnimation : IAnimation {
public class AnimationSequence : IAnimationCollection, ISeekable {
internal List<IAnimation> _children = new();
public void Seek(int t) { }
public IAnimationCollection AddChildAnimation<U>(U child) where U:IAnimation {
if(child is ISeekable) return this;
else return this.AsNonSeekableSequence();
private NonSeekAnimationSequence AsNonSeekableSequence() {
var n = new NonSeekAnimationSequence();
public class NonSeekAnimationSequence : IAnimationCollection {
internal List<IAnimation> _children = new();
public IAnimationCollection AddChildAnimation<U>(U child) where U:IAnimation {
public static void Main()
var makeEndGameSequence = IAnimation () => new AnimationSequence();
var someCutscene = new AnimationSequence()
.AddChildAnimation(new DeterministicAnimation())
.AddChildAnimation(new PhysicsAnimation())
.AddChildAnimation(new DeterministicAnimation())
.AddChildAnimation(makeEndGameSequence());
Console.WriteLine(someCutscene.GetType());