//increments one frame, and handles animation ending signals. Note that all animations loop by default.
        public AnimationState Tick(AnimationState currentState)
        {
            currentState.CurrentFrame++;
            if (!Frames.ContainsKey (currentState.AnimationName)) { //Shouldn't happen, let's fail gracefully.
                //TODO: Log this?
                return currentState;
            }

            if (currentState.CurrentFrame == Frames[currentState.AnimationName].Length) { //The current animation just ended and looped!
                currentState.CurrentFrame = 0;
                currentState = Update (currentState, "anim_end"); //Could probably be optimized. Perhaps the current animation stores a next_anim? If none, stop. If it has one, switch. Looping would switching to self.
            }
            return currentState;
        }
        public AnimationState Update(AnimationState currentState, String signal)
        {
            AnimationTransitionSignal specificTransition = new AnimationTransitionSignal (currentState.AnimationName, signal);
            AnimationTransitionSignal generalTransition = new AnimationTransitionSignal ("", signal);

            if (StateChanges.ContainsKey (specificTransition)) {
                AnimationTransitionResponse response = StateChanges [specificTransition];
                currentState.AnimationName = response.DestAnim;
                if (response.ResetFrameNumber) {
                    currentState.CurrentFrame = 0;
                }
            } else if (StateChanges.ContainsKey (generalTransition)) {
                AnimationTransitionResponse response = StateChanges [generalTransition];
                currentState.AnimationName = response.DestAnim;
                if (response.ResetFrameNumber) {
                    currentState.CurrentFrame = 0;
                }
            }

            return currentState;
        }
 public Rectangle GetRectangle(AnimationState state)
 {
     Rectangle[] rects = Frames [state.AnimationName];
     int frameNum = state.CurrentFrame % rects.Length;
     return rects [frameNum];
 }