/* Copyright 2003-2007 ROBLOX Corporation, All Rights Reserved */ #pragma once #include "V8Tree/Instance.h" #include "Util/SteppedInstance.h" #include "V8DataModel/KeyframeSequence.h" //for Animation::Priority, CachedPose namespace RBX { class AnimatableRootJoint; class AnimationTrackState; class PartInstance; class AnimationTrack; extern const char *const sAnimator; class Animator : public DescribedCreatable , public IStepped { private: typedef DescribedCreatable Super; RBX::Time serverLockTimer; Instance* getRootInstance(); void setupClumpChangedListener(Instance* rootInstance); protected: std::map > animationTrackMap; std::string activeAnimation; typedef std::vector AnimatableJointSet; AnimatableJointSet animatableJoints; void calcAnimatableJoints(Instance* rootInstance, shared_ptr descendant = shared_ptr()); void appendAnimatableJointsRec(shared_ptr instance, shared_ptr exclude); scoped_ptr animatableRootJoint; rbx::signals::scoped_connection descentdantAdded; rbx::signals::scoped_connection descentdantRemoved; rbx::signals::scoped_connection ancestorChanged; rbx::signals::scoped_connection clumpChangedConnection; void onEvent_DescendantAdded(shared_ptr descendant); void onEvent_DescendantRemoving(shared_ptr descendant); void onEvent_AncestorModified(); void onEvent_ClumpChanged(shared_ptr instance); std::list > activeAnimations; public: Animator(); Animator(Instance* replicatingContainer); // use this to add Animator behavor to another Instance in the tree, like Humanoid. virtual ~Animator(); float getGameTime() const; shared_ptr loadAnimation(shared_ptr animation); void reloadAnimation(shared_ptr animationTrackState); shared_ptr testForServerLockPart; /*implement*/ void onStepped(const Stepped& event); /*override*/ void onServiceProvider(ServiceProvider* oldProvider, ServiceProvider* newProvider); /*override*/ void verifySetParent(const Instance* instance) const; /*override*/ bool askSetParent(const Instance* instance) const { return true; } /*override*/ bool askAddChild(const Instance* instance) const; /*override*/ void onAncestorChanged(const AncestorChanged& event); rbx::remote_signal onPlaySignal; rbx::remote_signal onStopSignal; rbx::remote_signal onAdjustSpeedSignal; rbx::remote_signal onSetTimePositionSignal; void onPlay(ContentId animation, float fadeTime, float weight, float speed); void onStop(ContentId animation, float fadeTime); void onAdjustSpeed(ContentId animation, float speed); void onSetTimePosition(ContentId animation, float timePosition); void passiveLoadAnimation(ContentId animation); void replicateAnimationPlay(ContentId animation, float fadeTime, float weight, float speed, shared_ptr track); void replicateAnimationStop(ContentId animation, float fadeTime); void replicateAnimationSpeed(ContentId animation, float speed); void replicateAnimationTimePosition(ContentId animation, float timePosition); std::string getActiveAnimation() const {return activeAnimation;} void tellParentAnimationPlayed(shared_ptr animationTrack); shared_ptr getPlayingAnimationTracks(); private: void onTrackStepped(shared_ptr trackinst, double time, KeyframeSequence::Priority priority, std::vector* poses ); }; } // namespace