public void RegionLoaded(Scene scene) { if (enabled) { aar = new AAR(m_scene, this, delegate(string s){ m_log.DebugFormat("[AAR]: {0}", s); }); } }
public void loadSession(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } if (args.Length <= 2) { log("Error loading session, Usage: aar load <id>"); return; } string sessionId = args[2]; Dictionary <string, int> sessions = getSessions(); if (!sessions.ContainsKey(sessionId)) { log("Error loading session: session does not exist"); return; } dialog.SendGeneralAlert("AAR Module: Halting scripts in preparation for Playback"); haltScripts(); dialog.SendGeneralAlert("AAR Module: Initializing scene"); loadSession(sessionId, sessions[sessionId]); dialog.SendGeneralAlert("AAR Module: Scene ready for playback"); }
public void saveSession(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } if (isRecording) { log("Error saving session, module is still recording"); return; } if (!hasRecording) { log("Error saving session, there is no recorded session"); return; } //persist the session string session = ""; using (MemoryStream msCompressed = new MemoryStream()) using (GZipStream gZipStream = new GZipStream(msCompressed, CompressionMode.Compress)) using (MemoryStream msDecompressed = new MemoryStream()) { new BinaryFormatter().Serialize(msDecompressed, recordedActions); byte[] byteArray = msDecompressed.ToArray(); gZipStream.Write(byteArray, 0, byteArray.Length); gZipStream.Close(); session = Convert.ToBase64String(msCompressed.ToArray()); } //the recorded session events are all compressed and encoded into the string in session OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(xEngine, aarBox.RootPart, null, null); for (int i = 0, n = 0; i < session.Length; i += CHUNKSIZE, n++) { string sessionChunk; if (i + CHUNKSIZE > session.Length) { sessionChunk = session.Substring(i, session.Length - i); } else { sessionChunk = session.Substring(i, CHUNKSIZE); } OpenSim.Region.ScriptEngine.Shared.LSL_Types.list l = new OpenSim.Region.ScriptEngine.Shared.LSL_Types.list(); l.Add(sessionChunk); string notecardName = string.Format("session-{0}-{1}", sessionId, n); osslApi.osMakeNotecard(notecardName, l); } log(string.Format("{0} bytes", System.Text.ASCIIEncoding.ASCII.GetByteCount(session))); foreach (AvatarActor a in avatars.Values) { a.appearances.Clear(); a.appearanceCount = 0; } hasRecording = false; }
public void pausePlayback(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } pausePlayback(); }
public void beginPlayback(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } sw.Restart(); isPlaying = true; }
public void purgeBox(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } foreach (UUID id in aarBox.RootPart.Inventory.GetInventoryList()) { aarBox.RootPart.Inventory.RemoveInventoryItem(id); } }
public void listSessions(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } Dictionary <string, int> sessions = getSessions(); foreach (string id in sessions.Keys) { log(string.Format("session: {0}", id)); } }
public void unloadSession(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } isPlaying = false; recordedActions = null; dialog.SendGeneralAlert("AAR Module: Clearing Scene"); //TODO delete managed objects and NPC characters deleteAllActors(); dialog.SendGeneralAlert("AAR Module: Resuming normal region script operation"); resumeScripts(); dialog.SendGeneralAlert("AAR Module: Unload complete"); }
public void stopRecording(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } if (!isRecording) { log("Error stopping: AAR is not recording"); return; } recordedActions.Enqueue(new EventEnd(sw.ElapsedMilliseconds)); isRecording = false; sw.Stop(); }
public void startRecording(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } if (isRecording) { log("Error starting: AAR is already recording"); return; } if (hasRecording) { log("Overwriting recorded session"); } isRecording = true; hasRecording = true; sw.Restart(); sessionId = DateTime.Now.ToString("MM/dd/yyyy_h:mm"); recordedActions.Clear(); foreach (AvatarActor a in avatars.Values) { a.appearanceCount = 0; a.appearances.Clear(); string appearanceName = persistAppearance(a.uuid, a.appearanceCount); a.appearances.Add(appearanceName); recordedActions.Enqueue(new ActorAddedEvent(a.firstName, a.lastName, a.uuid, appearanceName, sw.ElapsedMilliseconds)); recordedActions.Enqueue(new ActorMovedEvent(a, sw.ElapsedMilliseconds)); recordedActions.Enqueue(new ActorAnimationEvent(a.uuid, a.animations, sw.ElapsedMilliseconds)); } //We assume the region is populated, but lets record their initial positions foreach (ObjectActor oa in objects.Values) { recordedActions.Enqueue(new ObjectMovedEvent(oa.uuid, oa.position, oa.rotation, oa.velocity, oa.angularVelocity, sw.ElapsedMilliseconds)); } recordedActions.Enqueue(new EventStart(sw.ElapsedMilliseconds)); log("Record Start"); }