void transaction_OnTransactionCompleted(BotEngine sender, EventTransactionCompletedArgs e) { ConsoleHelpers.WriteLine(string.Format("Transaction {0} committed {1} objects, and completed in {2} ms.", e.Transaction.TransactionId, e.Transaction.Commits, e.Transaction.elapsedMs)); foreach (var model in sender.SceneNodes.Models.FindAll(p => p.Action.Contains("@key=unittest"))) { sender.DeleteObject(model); } // create a second transaction var transaction = new SimpleTransaction <Model>(sender); transaction.OnTransactionCompleted += transaction_OnTransactionCompleted2; for (int h = 0; h < 1; h++) { for (int j = 0; j < 15; j++) { for (int i = 0; i < 15; i++) { transaction.Add(new Model() { ModelName = "bzmb0.rwx", Action = "@key=unittest", Description = "Bot created object teet", Position = new Vector3((i * 120) + (-h * 1600), j * 120, 2000) }); } } } sender.AddObjects(transaction); }
/// <summary> /// Handles the object event scan completed. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="AwManaged.EventHandling.BotEngine.EventObjectScanCompletedEventArgs"/> instance containing the event data.</param> void HandleObjectEventScanCompleted(BotEngine sender, EventObjectScanCompletedEventArgs e) { _sw1.Stop(); ConsoleHelpers.WriteLine(string.Format("Found {0} objects in {1} ms.", e.SceneNodes.Models.Count, _sw1.ElapsedMilliseconds)); _sw1.Reset(); // start receiving object events. sender.ObjectEventAdd += HandleObjectEventAdd; sender.ObjectEventRemove += HandleObjectEventRemove; sender.ObjectEventClick += HandleObjectEventClick; sender.ObjectEventChange += HandleObjectEventChange; // check how many zone's there are in the world ConsoleHelpers.WriteLine(string.Format("Found {0} zones.", e.SceneNodes.Zones.Count)); ConsoleHelpers.WriteLine(string.Format("Found {0} cameras.", e.SceneNodes.Cameras.Count)); ConsoleHelpers.WriteLine(string.Format("Found {0} movers.", e.SceneNodes.Movers.Count)); ConsoleHelpers.WriteLine(string.Format("Found {0} particle emitters.", e.SceneNodes.Particles.Count)); //string actionContains = "light"; //ConsoleHelpers.WriteLine(string.Format("object query test, testing object actions which contain {0}",actionContains)); //var b = from Model p in e.SceneNodes.Models where p.Action.Contains(actionContains) select p; //ConsoleHelpers.WriteLine(string.Format("found {0} objects which contain action {1}",b.Count(), actionContains)); //sender.AddObject(new Model(){ModelName="bzmb0.rwx",Position=new Vector3(0,0,10000)}); #if OBJECT_ADD // remove all objects which are part of the unit test. foreach (var model in e.SceneNodes.Models.FindAll(p => p.Action.Contains("@key=unittest"))) { sender.DeleteObject(model); } var transaction = new SimpleTransaction <Model>(sender); transaction.OnTransactionCompleted += transaction_OnTransactionCompleted; for (int h = 0; h < 1; h++) { for (int j = 0; j < 15; j++) { for (int i = 0; i < 15; i++) { transaction.Add(new Model() { ModelName = "bzmb0.rwx", Action = "@key=unittest", Description = "Bot created object teet", Position = new Vector3((i * 120) + (-h * 1600), j * 120, 1000) }); } } } sender.AddObjects(transaction); #endif #if BACKUP ConsoleHelpers.Write("Performing main backup..."); _sw1.Start(); var db = sender.Storage.Db; //var main_backup = from SceneNodes.SceneNodes p in db select p; //if (main_backup.Count() == 1) // db.Delete(main_backup.Single()); sender.Storage.Db.Store(e.SceneNodes); db.Commit(); ConsoleHelpers.WriteLine("Done!" + _sw1.ElapsedMilliseconds + " ms."); #endif #if ACTION_INTERPRETER List <IEnumerable <IActionTrigger> > triggers = new List <IEnumerable <IActionTrigger> >(); _sw1.Reset(); _sw1.Start(); foreach (var model in e.SceneNodes.Models) { var m = Interpret(model.Action); if (m != null) { triggers.Add(Interpret(model.Action)); } } ConsoleHelpers.WriteLine(string.Format("Interpreted {0} object actions in {1} ms.", triggers.Count, _sw1.ElapsedMilliseconds)); #endif }