private static void BenchmarkHooks_OnCommand(CommandEventArgs e) { if (e.Arguments.Length != 1) { return; } var iterations = e.GetUInt32(0); var tableId = e.GetString(1); var itemLevel = e.GetInt32(2); var itemChance = e.GetDouble(3); var backpack = new BackpackOfHolding(); e.Mobile.AddToBackpack(backpack); ZhConfig.Loot.Tables.TryGetValue(tableId, out var table); var watch = new Stopwatch(); watch.Start(); var items = 0; for (var i = 0; i < iterations; i++) { items += LootGenerator.MakeLoot(e.Mobile, backpack, table, itemLevel, itemChance); } watch.Stop(); Console.WriteLine($"Ran {iterations} iterations generating {items} which took {watch.Elapsed.TotalSeconds:F2} seconds."); }
public override void Execute(CommandEventArgs e) { if (e.Length >= 2) { Serial serial = e.GetUInt32(0); object obj = null; if (serial.IsItem) { obj = World.FindItem(serial); } else if (serial.IsMobile) { obj = World.FindMobile(serial); } if (obj == null) { e.Mobile.SendMessage("That is not a valid serial."); } else { Commands.TryGetValue(e.GetString(1), out var command); if (command == null) { e.Mobile.SendMessage( "That is either an invalid command name or one that does not support this modifier." ); } else if (e.Mobile.AccessLevel < command.AccessLevel) { e.Mobile.SendMessage("You do not have access to that command."); } else { switch (command.ObjectTypes) { case ObjectTypes.Items: { if (!(obj is Item)) { e.Mobile.SendMessage("This command only works on items."); return; } break; } case ObjectTypes.Mobiles: { if (!(obj is Mobile)) { e.Mobile.SendMessage("This command only works on mobiles."); return; } break; } } var oldArgs = e.Arguments; var args = new string[oldArgs.Length - 2]; for (var i = 0; i < args.Length; ++i) { args[i] = oldArgs[i + 2]; } RunCommand(e.Mobile, obj, command, args); } } } else { e.Mobile.SendMessage("You must supply an object serial and a command name."); } }