public void onFrame() { if (isPlaying) { try { while (recordedActions.Count > 0 && sw.ElapsedMilliseconds > recordedActions.Peek().time) { AAREvent e = recordedActions.Dequeue(); processedActions.Enqueue(e); dispatchEvent(e); } return; } catch (Exception e) { /*string msg = "Error processing: "; * if(recordedActions == null) * { * msg += "recordedActions is null - "; * } * else if(recordedActions.Peek() == null) * { * msg += "recordedActions.Peek() is null - "; * } * else * { * msg += string.Format("recordedActions.Count: {0}", recordedActions.Count); * } * if(sw == null) * { * msg += "stopwatch is null - "; * } * else * { * msg += string.Format("Stopwatch elapsed millisecionds: {0}", sw.ElapsedMilliseconds); * }*/ isPlaying = false; log(e.Message + ": " + e.StackTrace); //log(msg + e.StackTrace); } } }
private void dispatchEvent(AAREvent e) { if (e is EventStart) { log("AAR Event Playback Start"); } else if (e is EventEnd) { log("AAR Event Playback Completed"); pausePlayback(); } else if (e is ObjectAddedEvent) { ObjectAddedEvent oe = (ObjectAddedEvent)e; createObjectPart(oe.uuid, oe.name); } else if (e is ObjectMovedEvent) { ObjectMovedEvent oe = (ObjectMovedEvent)e; moveObjectPart(oe.uuid, oe.position, oe.rotation, oe.velocity, oe.angularVelocity); } else if (e is ObjectRemovedEvent) { ObjectRemovedEvent oe = (ObjectRemovedEvent)e; deleteObject(oe.uuid); } else if (e is ActorAddedEvent) { ActorAddedEvent ae = (ActorAddedEvent)e; createActor(ae.uuid, ae.firstName, ae.lastName, ae.notecard); } else if (e is ActorRemovedEvent) { ActorRemovedEvent ae = (ActorRemovedEvent)e; deleteActor(ae.uuid); } else if (e is ActorAppearanceEvent) { ActorAppearanceEvent ae = (ActorAppearanceEvent)e; changeAppearance(ae.uuid, ae.notecard); } else if (e is ActorAnimationEvent) { ActorAnimationEvent ae = (ActorAnimationEvent)e; animateActor(ae.uuid, ae.animations); } else if (e is ActorMovedEvent) { ActorMovedEvent ae = (ActorMovedEvent)e; moveActor(ae.uuid, ae.position, ae.rotation, ae.velocity, ae.isFlying, ae.controlFlags); } else if (e is ChatEvent) { ChatEvent ce = (ChatEvent)e; chat(ce.sender, ce.message, ce.msgType, ce.channel); } else { log(string.Format("Invalid event {0}", e.GetType().Name)); } }