public void advance_to_next_animation_inner(float timeElapsed, AnimSequenceNode currAnim, double frameNum, AFrame frame, bool checkFrame, bool firstCheck) { if (frame != null && checkFrame) { if (currAnim.Anim.PosFrames.Count > 0) { if (firstCheck) { frame.Subtract(currAnim.get_pos_frame((int)Math.Floor(frameNum))); } else { frame = AFrame.Combine(frame, currAnim.get_pos_frame((int)Math.Floor(frameNum))); } } if (Math.Abs(currAnim.Framerate) > PhysicsGlobals.EPSILON) { apply_physics(frame, 1.0f / currAnim.Framerate, timeElapsed); } } }
public void update_internal(float timeElapsed, AnimSequenceNode currAnim, float frameNum, AFrame frame) { var framerate = currAnim.Framerate; var frametime = framerate * timeElapsed; var lastFrame = (int)Math.Floor(frameNum); // ref? frameNum += frametime; var frameTimeElapsed = 0.0f; var animDone = false; if (frametime > 0.0f) { if (currAnim.get_high_frame() < Math.Floor(frameNum)) { var frameOffset = frameNum - currAnim.get_high_frame() - 1.0f; if (frameOffset < 0.0f) { frameOffset = 0.0f; } if (Math.Abs(framerate) > PhysicsGlobals.EPSILON) { frameTimeElapsed = frameOffset / framerate; } frameNum = currAnim.get_high_frame(); animDone = true; } while (Math.Floor(frameNum) > lastFrame) { if (frame != null) { if (currAnim.Anim.PosFrames != null) { frame = AFrame.Combine(frame, currAnim.get_pos_frame(lastFrame)); } if (Math.Abs(framerate) > PhysicsGlobals.EPSILON) { apply_physics(frame, 1.0f / framerate, timeElapsed); } } execute_hooks(currAnim.get_part_frame(lastFrame), AnimationHookDir.Forward); lastFrame++; } } else if (frametime < 0.0f) { if (currAnim.get_low_frame() > Math.Floor(frameNum)) { var frameOffset = frameNum - currAnim.get_low_frame(); if (frameOffset > 0.0f) { frameOffset = 0.0f; } if (Math.Abs(framerate) > PhysicsGlobals.EPSILON) { frameTimeElapsed = frameOffset / framerate; } frameNum = currAnim.get_low_frame(); animDone = true; } while (Math.Floor(frameNum) < lastFrame) { if (frame != null) { if (currAnim.Anim.PosFrames != null) { frame = AFrame.Combine(frame, currAnim.get_pos_frame(lastFrame)); } if (Math.Abs(framerate) > PhysicsGlobals.EPSILON) { apply_physics(frame, 1.0f / framerate, timeElapsed); } } execute_hooks(currAnim.get_part_frame(lastFrame), AnimationHookDir.Backward); lastFrame--; } } else { if (frame != null && Math.Abs(timeElapsed) > PhysicsGlobals.EPSILON) { apply_physics(frame, timeElapsed, timeElapsed); } } if (!animDone) { return; } if (HookObj != null) { var node = AnimList.First; if (!node.Equals(FirstCyclic)) { var animHook = new AnimationHook(); HookObj.add_anim_hook(animHook); } } advance_to_next_animation(timeElapsed, currAnim, frameNum, frame); timeElapsed = frameTimeElapsed; // loop to next anim update_internal(timeElapsed, currAnim, frameNum, frame); }