public AnimationStateManager( AnimationPlayer player, AnimationTree animationTree, Option <IAnimationGraphFactory> graphFactory, Option <IAnimationControlFactory> controlFactory, ProcessMode processMode, ITimeSource timeSource, bool active, ILoggerFactory loggerFactory) : base(player, processMode, timeSource, active, loggerFactory) { Ensure.That(animationTree, nameof(animationTree)).IsNotNull(); AnimationTree = animationTree; GraphFactory = graphFactory.IfNone(() => new AnimationGraphFactory()); ControlFactory = controlFactory.IfNone(() => new AnimationControlFactory()); Context = new AnimationGraphContext( Player, AnimationTree, OnAdvance, GraphFactory, ControlFactory, loggerFactory); _graph = GraphFactory.TryCreate((AnimationRootNode)AnimationTree.TreeRoot, Context).IfNone(() => throw new ArgumentException( "Failed to create animation graph from the specified animation tree.", nameof(animationTree))); AnimationTree.ProcessMode = AnimationTree.AnimationProcessMode.Manual; this.LogDebug("Using graph factory: {}.", GraphFactory); this.LogDebug("Using control factory: {}.", ControlFactory); }
public AnimationGraphContext( AnimationPlayer player, AnimationTree animationTree, IObservable <float> onAdvance, IAnimationGraphFactory graphFactory, IAnimationControlFactory controlFactory, ILoggerFactory loggerFactory) { Ensure.That(player, nameof(player)).IsNotNull(); Ensure.That(animationTree, nameof(animationTree)).IsNotNull(); Ensure.That(onAdvance, nameof(onAdvance)).IsNotNull(); Ensure.That(graphFactory, nameof(graphFactory)).IsNotNull(); Ensure.That(controlFactory, nameof(controlFactory)).IsNotNull(); Ensure.That(loggerFactory, nameof(loggerFactory)).IsNotNull(); Player = player; AnimationTree = animationTree; OnAdvance = onAdvance; GraphFactory = graphFactory; ControlFactory = controlFactory; LoggerFactory = loggerFactory; }