public void AttachmentInfo(ConsoleWriteLine WriteLine) { Client.Self.GetAttachmentResources((bool success, AttachmentResourcesMessage info) => { if (!success || info == null) { WriteLine("Failed to get the script info."); return; } StringBuilder sb = new StringBuilder(); sb.AppendLine("Summary:"); sb.AppendFormat("Memory used {0} KB out of {1} KB available.", info.SummaryUsed["memory"] / 1024, info.SummaryAvailable["memory"] / 1024); sb.AppendLine(); sb.AppendFormat("URLs used {0} out of {1} available.", info.SummaryUsed["urls"], info.SummaryAvailable["urls"]); sb.AppendLine(); sb.AppendLine(); sb.AppendLine("Details:"); foreach (KeyValuePair<AttachmentPoint, ObjectResourcesDetail[]> kvp in info.Attachments) { sb.AppendLine(); sb.AppendLine(string.Format("Attached to {0} ", Utils.EnumToText(kvp.Key)) + ":"); for (int i = 0; i < kvp.Value.Length; i++) { ObjectResourcesDetail obj = kvp.Value[i]; sb.AppendLine(obj.Name + " using " + obj.Resources["memory"] / 1024 + " KB"); } } WriteLine(sb.ToString()); } ); }
public void AttachmentInfo(ConsoleWriteLine WriteLine) { Client.Self.GetAttachmentResources((bool success, AttachmentResourcesMessage info) => { if (!success || info == null) { WriteLine("Failed to get the script info."); return; } StringBuilder sb = new StringBuilder(); sb.AppendLine("Summary:"); sb.AppendFormat("Memory used {0} KB out of {1} KB available.", info.SummaryUsed["memory"] / 1024, info.SummaryAvailable["memory"] / 1024); sb.AppendLine(); sb.AppendFormat("URLs used {0} out of {1} available.", info.SummaryUsed["urls"], info.SummaryAvailable["urls"]); sb.AppendLine(); sb.AppendLine(); sb.AppendLine("Details:"); foreach (KeyValuePair <AttachmentPoint, ObjectResourcesDetail[]> kvp in info.Attachments) { sb.AppendLine(); sb.AppendLine(string.Format("Attached to {0} ", Utils.EnumToText(kvp.Key)) + ":"); for (int i = 0; i < kvp.Value.Length; i++) { ObjectResourcesDetail obj = kvp.Value[i]; sb.AppendLine(obj.Name + " using " + obj.Resources["memory"] / 1024 + " KB"); } } WriteLine(sb.ToString()); } ); }
static void Main(string[] args) { //Helper.CheckDirectories(); var CurrentDomain = AppDomain.CurrentDomain.BaseDirectory; var GetDirectoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Console.WriteLine("AppDomain.CurrentDomain.BaseDirectory: {0}", CurrentDomain); Console.WriteLine("Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location): {0}", GetDirectoryName); ManualResetEvent manualResetEvent = new ManualResetEvent(true); manualResetEvent.WaitOne(); ConsoleWriteLine.WriteInConsole(null, null, null, "Project started", ConsoleColor.White); Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; Process.GetCurrentProcess().PriorityBoostEnabled = true; Helper_WINWORD.Clear(); Helper_EXCEL.Clear(); ClearNormal(); ProgressOfUpdateAtStructAttribute Standart = (ProgressOfUpdateAtStructAttribute)ParentMethods.GetStandart().Clone_Full(); ValueForClient.DeserializeConfig(new TimeSpan(0, 5, 0)); // Deserialization data'es if (ValueForClient.ReadyStructure.ProgressOfUpdate is null ? true : ValueForClient.ReadyStructure.ProgressOfUpdate.List_ProgressOfUpdateAtStructAttribute.Count != 1) { Progress = Standart; ValueForClient.ReadyStructure.ProgressOfUpdate = new ProgressOfUpdate() { List_ProgressOfUpdateAtStructAttribute = new List <ProgressOfUpdateAtStructAttribute>() { Progress } }; }
public void ParcelInfo(ConsoleWriteLine WriteLine) { WriteLine("Requesting script resources information..."); UUID currectParcel = Client.Parcels.RequestRemoteParcelID(Client.Self.SimPosition, Client.Network.CurrentSim.Handle, Client.Network.CurrentSim.ID); Client.Parcels.GetParcelResouces(currectParcel, true, (bool success, LandResourcesInfo info) => { if (!success || info == null) { return; } StringBuilder sb = new StringBuilder(); sb.AppendLine("Summary:"); sb.AppendFormat("Memory used {0} KB out of {1} KB available.", info.SummaryUsed["memory"] / 1024, info.SummaryAvailable["memory"] / 1024); sb.AppendLine(); sb.AppendFormat("URLs used {0} out of {1} available.", info.SummaryUsed["urls"], info.SummaryAvailable["urls"]); sb.AppendLine(); if (info.Parcels != null) { for (int i = 0; i < info.Parcels.Length; i++) { sb.AppendLine(); sb.AppendLine("Detailed usage for parcel " + info.Parcels[i].Name); for (int j = 0; j < info.Parcels[i].Objects.Length; j++) { sb.AppendFormat("{0} KB - {1}", info.Parcels[i].Objects[j].Resources["memory"] / 1024, info.Parcels[i].Objects[j].Name); sb.AppendLine(); } } } WriteLine(sb.ToString()); }); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (Chat.InvokeRequired) { if (!Instance.MonoRuntime || Chat.IsHandleCreated) { Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine))); } return; } wl = WriteLine; if (cmdArgs.Length == 0) { PrintUsage(); return; } string cmd = string.Join(" ", cmdArgs); if (cmd == "ground") { Client.Self.SitOnGround(); wl("Sat on the ground"); return; } if (!TC.TabExists("objects")) { RadegastTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance)); tab.AllowClose = true; tab.AllowDetach = true; tab.Visible = true; tab.AllowHide = false; ((ObjectsConsole)tab.Control).RefreshObjectList(); TC.Tabs["chat"].Select(); WriteLine("Objects list was not active. Started getting object names, please try again in a minute."); return; } Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List <Primitive> prims = Objects.GetObjectList(); Primitive target = prims.Find((Primitive prim) => { return(prim.Properties != null && prim.Properties.Name.ToLower().Contains(cmd.ToLower())); }); if (target == null) { WriteLine("Could not find '{0}' nearby", cmd); return; } WriteLine("Requesting to sit on object '{0}'", target.Properties.Name); Instance.State.SetSitting(true, target.ID); }
public static void RegisterApplication(EntityViewModel viewModel, StreamReader stdOut, StreamReader errOut) { new Thread(() => { while (!stdOut.EndOfStream) { string line = stdOut.ReadLine(); if (line != null) { ConsoleWriteLine?.Invoke(line, viewModel); if (viewModel is ServerViewModel serverViewModel) { if (line.Contains("For help, type \"help\"")) { serverViewModel.CurrentStatus = ServerStatus.RUNNING; } serverViewModel.RoleInputHandler(line); } if (viewModel is NetworkViewModel networkViewModel) { if (waterfallStarted.Match(line).Success) { networkViewModel.CurrentStatus = ServerStatus.RUNNING; } } viewModel.ConsoleOutList.Add(line); } } }).Start(); new Thread(() => { while (!errOut.EndOfStream) { string line = errOut.ReadLine(); if (line != null) { // For early minecraft versions if (line.Contains("For help, type \"help\"")) { viewModel.CurrentStatus = ServerStatus.RUNNING; } if (viewModel is ServerViewModel serverViewModel) { serverViewModel.RoleInputHandler(line); } ConsoleWriteLine?.Invoke(line, viewModel); viewModel.ConsoleOutList.Add(line); } } }).Start(); }
public virtual void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (_execute == null) { WriteLine("Someone did not implement {0}!", name); } else { _execute(name, cmdArgs, WriteLine); } }
public void Watcher_Turn(bool Turn) { if (PathFolder != null) { PathFolder.EnableRaisingEvents = Turn; ConsoleWriteLine.WriteInConsole(null, null, null, string.Format("\nClassName: {0}\nPathFolder: {1}\nTurn: {2}\nTimes: {3}\n", ClassName, PathFolder.Path, Turn, Times), ConsoleColor.White); } else { ConsoleWriteLine.WriteInConsole(null, null, null, string.Format("\nClassName: {0}\nPathFolder: {1}\nTurn: {2}\nTimes: {3}\n", ClassName, "NULL", Turn, Times), ConsoleColor.White); } }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { float time; if (cmdArgs.Length == 0 || !float.TryParse(cmdArgs[0], out time)) WriteLine(Usage); else { WriteLine("pausing for " + time); Thread.Sleep((int)(time * 1000)); WriteLine("paused for " + time); } }
public void Execute(string n, string[] cmdArgs, ConsoleWriteLine WriteLine) { string loadfilename = String.Join(" ", cmdArgs); try { Assembly assembly = Assembly.LoadFile(loadfilename); instance.PluginManager.LoadAssembly(loadfilename, assembly, true); } catch (Exception ex) { WriteLine("ERROR in Radegast Plugin: {0} because {1} {2}", loadfilename, ex.Message, ex.StackTrace); } }
public void Execute(string n, string[] cmdArgs, ConsoleWriteLine WriteLine) { string loadfilename = String.Join(" ", cmdArgs); try { instance.PluginManager.LoadPlugin(loadfilename); } catch (Exception ex) { WriteLine("ERROR in Radegast Plugin: {0} because {1} {2}", loadfilename, ex.Message, ex.StackTrace); } }
public void ExecuteCommandForeground(ConsoleWriteLine WriteLine, string cmdline) { if (cmdline == null) { return; } cmdline = cmdline.Trim(); List <ICommandInterpreter> interpretersLoadedLocal = new List <ICommandInterpreter>(); lock (InterpretersLoaded) interpretersLoadedLocal.AddRange(InterpretersLoaded); foreach (ICommandInterpreter manager in interpretersLoadedLocal) { if (!manager.IsValidCommand(cmdline)) { continue; } // the command is queued from outside manager.ExecuteCommand(WriteLine, cmdline); return; } // our local impl while (cmdline.StartsWith(CmdPrefix)) { cmdline = cmdline.Substring(CmdPrefix.Length); cmdline = cmdline.Trim(); } if (cmdline == "") { return; } string[] parsd = ParseArguments(cmdline); string cmd = parsd[0]; IRadegastCommand cmdimpl; if (CommandsByName.TryGetValue(cmd.ToLower(), out cmdimpl)) { try { cmdimpl.Execute(cmd, SplitOff(parsd, 1), WriteLine); } catch (Exception ex) { WriteLine("Command error: {0} \n{1} {2} ", cmdline, ex.Message, ex.StackTrace); } return; } WriteLine("Command not found {0}", cmd); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { float time; if (cmdArgs.Length == 0 || !float.TryParse(cmdArgs[0], out time)) { WriteLine(Usage); } else { WriteLine("pausing for " + time); Thread.Sleep((int)(time * 1000)); WriteLine("paused for " + time); } }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (cmdArgs.Length == 0) { AttachmentInfo(WriteLine); } else if (cmdArgs[0] == "avatar") { AttachmentInfo(WriteLine); } else if (cmdArgs[0] == "parcel") { ParcelInfo(WriteLine); } }
/// <summary> /// Получить параметры, основываясь на их типе данных, записанного в string-формате /// </summary> /// <param name="ParametersSet"></param> /// <param name="dataSet"></param> /// <param name="NumbOfStartTable"></param> /// <returns></returns> private static Tuple <List <dynamic>, int> GetParametersByNameOfParameters(List <dynamic> ParametersSet, DataSet dataSet, int NumbOfStartTable) { List <dynamic> typeParameterReturns = new List <dynamic>(); List <dynamic> listDynamic = new List <dynamic>(); string ExceptionMessage = ""; foreach (dynamic parameter in ParametersSet) { if ((parameter).GetType() == (new List <string>().GetType())) { foreach (string s in parameter) { Tuple <dynamic, string> Item = GetInstenceFromThisNamespace(s); var someItem = Item.Item1; DataTable dt = dataSet.Tables[NumbOfStartTable]; var r = ConvertFrom(someItem, dt); listDynamic.Add(r); NumbOfStartTable++; } typeParameterReturns.Add(listDynamic); listDynamic = new List <dynamic>(); } else { var someItem = default(dynamic); Tuple <dynamic, string> Item = GetInstenceFromThisNamespace(parameter); someItem = Item.Item1; var r = default(dynamic); DataTable dt = dataSet.Tables[NumbOfStartTable]; r = ConvertFrom(someItem, dt); typeParameterReturns.Add(r); // Преобразованный экземпляр из dataSet NumbOfStartTable++; } } if (ExceptionMessage != "") { ConsoleWriteLine.WriteInConsole(nameof(GetParametersByNameOfParameters), "", "Failed", string.Format("{0}: {1}", MethodBase.GetCurrentMethod().Name, ExceptionMessage), default); } return(new Tuple <List <dynamic>, int>(typeParameterReturns, NumbOfStartTable)); }
private static readonly object lockObject = new object(); // очередь public void Watch(string MethodName, string ClassName, string dir, Tuple <bool, bool, bool, bool> Changed_Created_Deleted_Renamed, List <dynamic> Config) { if (!string.IsNullOrEmpty(dir)) { Times = 0; this.Config = Config; this.MethodName = MethodName; this.ClassName = ClassName; time = 5000; this.PathFolder = RunForFolders(dir, Changed_Created_Deleted_Renamed.Item1, Changed_Created_Deleted_Renamed.Item2, Changed_Created_Deleted_Renamed.Item3, Changed_Created_Deleted_Renamed.Item4); ConsoleWriteLine.WriteInConsole(this.MethodName, "Watch", "Start", "", ConsoleColor.White); } }
public static void RegisterApplication(EntityViewModel viewModel, StreamReader stdOut, StreamReader errOut) { new Thread(() => { while (!stdOut.EndOfStream) { string line = stdOut.ReadLine(); if (line != null) { ConsoleWriteLine?.Invoke(line, viewModel); if (line.Contains(@"WARN Advanced terminal features are not available in this environment")) { continue; } //bool used to generate green success message in console bool isSuccess = false; if (viewModel is ServerViewModel serverViewModel) { if (line.Contains("For help, type \"help\"")) { serverViewModel.CurrentStatus = ServerStatus.RUNNING; isSuccess = true; } serverViewModel.RoleInputHandler(line); } if (viewModel is NetworkViewModel networkViewModel) { if (waterfallStarted.Match(line).Success) { networkViewModel.CurrentStatus = ServerStatus.RUNNING; isSuccess = true; } } viewModel.AddToConsole(isSuccess ? new ConsoleMessage(line, ConsoleMessage.MessageLevel.SUCCESS) : new ConsoleMessage(line)); } } }) { IsBackground = true }.Start();
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { StringBuilder sb = new StringBuilder(); string result; EventHandler <SimParcelsDownloadedEventArgs> del = delegate(object sender, SimParcelsDownloadedEventArgs e) { ParcelsDownloaded.Set(); }; instance.MainForm.PreventParcelUpdate = true; ParcelsDownloaded.Reset(); Client.Parcels.SimParcelsDownloaded += del; Client.Parcels.RequestAllSimParcels(Client.Network.CurrentSim, true, 750); if (Client.Network.CurrentSim.IsParcelMapFull()) { ParcelsDownloaded.Set(); } if (ParcelsDownloaded.WaitOne(30000, false) && Client.Network.Connected) { sb.AppendFormat("Downloaded {0} Parcels in {1} " + System.Environment.NewLine, Client.Network.CurrentSim.Parcels.Count, Client.Network.CurrentSim.Name); Client.Network.CurrentSim.Parcels.ForEach(delegate(Parcel parcel) { sb.AppendFormat("Parcel[{0}]: Name: \"{1}\", Description: \"{2}\" ACLBlacklist Count: {3}, ACLWhiteList Count: {5} Traffic: {4}" + System.Environment.NewLine, parcel.LocalID, parcel.Name, parcel.Desc, parcel.AccessBlackList.Count, parcel.Dwell, parcel.AccessWhiteList.Count); }); result = sb.ToString(); } else { result = "Failed to retrieve information on all the simulator parcels"; } Client.Parcels.SimParcelsDownloaded -= del; Thread.Sleep(2000); instance.MainForm.PreventParcelUpdate = false; WriteLine("Parcel Infro results:\n{0}", result); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (Chat.InvokeRequired) { if (!Instance.MonoRuntime || Chat.IsHandleCreated) { Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine))); } return; } if (cmdArgs.Length == 0) { if (Instance.State.FollowName == string.Empty) { WriteLine("Follow inactive, type {0}follow person name, to start following them", CommandsManager.CmdPrefix); } else { WriteLine("Following {0}", Instance.State.FollowName); } return; } string cmd = string.Join(" ", cmdArgs); if (cmd == "stop") { Instance.State.StopFollowing(); WriteLine("Following stopped"); return; } List <UUID> people = Chat.GetAvatarList(); UUID person = people.Find((UUID id) => { return(Instance.Names.Get(id).ToLower().StartsWith(cmd.ToLower())); }); if (person == UUID.Zero) { WriteLine("Could not find {0}", cmd); return; } Instance.State.Follow(Instance.Names.Get(person), person); WriteLine("Following {0}", Instance.State.FollowName); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { StringBuilder sb = new StringBuilder(); Simulator sim = Client.Network.CurrentSim; sb.AppendLine(); sb.AppendFormat("Information on region {0}:{1}", sim.Name, Environment.NewLine); sb.AppendFormat("Product name: {0}{1}", sim.ProductName, Environment.NewLine); sb.AppendFormat("Product SKU: {0}{1}", sim.ProductSku, Environment.NewLine); sb.AppendFormat("Regions per CPU: {0}{1}", sim.CPURatio, Environment.NewLine); sb.AppendFormat("CPU class: {0}{1}", sim.CPUClass, Environment.NewLine); sb.AppendFormat("Datacenter: {0}{1}", sim.ColoLocation, Environment.NewLine); sb.AppendFormat("Agents: {0}{1}", sim.Stats.Agents, Environment.NewLine); sb.AppendFormat("Active scripts: {0}{1}", sim.Stats.ActiveScripts, Environment.NewLine); sb.AppendFormat("Time dilation: {0}{1}", sim.Stats.Dilation, Environment.NewLine); WriteLine(sb.ToString()); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { StringBuilder sb = new StringBuilder(); Simulator sim = Client.Network.CurrentSim; sb.AppendLine(); sb.AppendFormat("Information on region {0}:{1}", sim.Name, Environment.NewLine); sb.AppendFormat("Product name: {0}{1}", sim.ProductName, Environment.NewLine); sb.AppendFormat("Product SKU: {0}{1}", sim.ProductSku, Environment.NewLine); sb.AppendFormat("Regions per CPU: {0}{1}", sim.CPURatio, Environment.NewLine); sb.AppendFormat("CPU class: {0}{1}", sim.CPUClass, Environment.NewLine); sb.AppendFormat("Datacenter: {0}{1}", sim.ColoLocation, Environment.NewLine); sb.AppendFormat("Agents: {0}{1}", sim.Stats.Agents, Environment.NewLine); sb.AppendFormat("Active scripts: {0}{1}", sim.Stats.ActiveScripts, Environment.NewLine); sb.AppendFormat("Time dilation: {0}{1}", sim.Stats.Dilation, Environment.NewLine); WriteLine(sb.ToString()); }
private FileSystemWatcher RunForFolders(string Path, bool Changed, bool Created, bool Deleted, bool Renamed) { // Create a new FileSystemWatcher and set its properties. FileSystemWatcher watcher = new FileSystemWatcher(); try { watcher.Path = Path; } catch (Exception ex) { ConsoleWriteLine.WriteInConsole(null, null, "Failed", ex.Message.ToString(), ConsoleColor.Red); return(null); } /* Watch for changes in LastAccess and LastWrite times, and * the renaming of files or directories. */ watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.Size | NotifyFilters.Attributes; // Add event handlers. if (Changed) { watcher.Changed += new FileSystemEventHandler(Watcher_Process); } if (Created) { watcher.Created += new FileSystemEventHandler(Watcher_Process); } if (Deleted) { watcher.Deleted += new FileSystemEventHandler(Watcher_Process); } if (Renamed) { watcher.Renamed += new RenamedEventHandler(Watcher_Process); } return(watcher); }
private static List <T> ToListof <T>(this DataTable dt) { try { const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance; var columnNames = dt.Columns.Cast <DataColumn>() .Select(c => c.ColumnName) ; var objectProperties = typeof(T).GetProperties(flags); var targetList = dt.AsEnumerable().Select(dataRow => { T instanceOfT; if (typeof(T) == typeof(string)) { instanceOfT = (T)Activator.CreateInstance("".GetType(), "".ToCharArray()); } else { instanceOfT = (T)Activator.CreateInstance <T>(); } try { foreach (var properties in objectProperties.Where(properties => columnNames.Contains(properties.Name) && dataRow[properties.Name] != DBNull.Value)) { properties.SetValue(instanceOfT, dataRow[properties.Name], null); } } catch (Exception ex) { ConsoleWriteLine.WriteInConsole(nameof(ToListof), "", "Failed", ex.ToString(), default); } return(instanceOfT); }).ToList(); return(targetList); } catch { return(dt.ToListof <T>()); } }
private static void StartListening() { Priority = Thread.CurrentThread.Priority; try { if (!Helper.IsLocked(StartListening_LockObject)) { lock (StartListening_LockObject) using (listener = new Socket(localEndPoint.AddressFamily, // Bind the socket to the local endpoint and listen for incoming connections. SocketType.Stream, ProtocolType.Tcp) { ReceiveTimeout = (int)Math.Round(TimeSpan.FromMinutes(2).TotalMilliseconds), SendTimeout = (int)Math.Round(TimeSpan.FromMinutes(2).TotalMilliseconds), }) // Create a TCP/IP socket. { listener.Bind(localEndPoint); listener.Listen(5); while (true) { AllDone.Reset(); // Set the event to nonsignaled state. ConsoleWriteLine.WriteInConsole(null, null, null, "\nWaiting for a new connection...", ConsoleColor.White); // Start an asynchronous socket to listen for connections. listener.BeginAccept(new AsyncCallback(AcceptCallback), listener); AllDone.WaitOne(); // Wait until a connection is made before continuing. } } } } catch (ThreadAbortException ex) { StartListening(); } catch (SocketException ex) { StartListening(); } catch (Exception ex) { StartListening(); } }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { StringBuilder sb = new StringBuilder(); string result; EventHandler<SimParcelsDownloadedEventArgs> del = delegate(object sender, SimParcelsDownloadedEventArgs e) { ParcelsDownloaded.Set(); }; instance.MainForm.PreventParcelUpdate = true; ParcelsDownloaded.Reset(); Client.Parcels.SimParcelsDownloaded += del; Client.Parcels.RequestAllSimParcels(Client.Network.CurrentSim, true, 750); if (Client.Network.CurrentSim.IsParcelMapFull()) ParcelsDownloaded.Set(); if (ParcelsDownloaded.WaitOne(30000, false) && Client.Network.Connected) { sb.AppendFormat("Downloaded {0} Parcels in {1} " + System.Environment.NewLine, Client.Network.CurrentSim.Parcels.Count, Client.Network.CurrentSim.Name); Client.Network.CurrentSim.Parcels.ForEach(delegate(Parcel parcel) { sb.AppendFormat("Parcel[{0}]: Name: \"{1}\", Description: \"{2}\" ACLBlacklist Count: {3}, ACLWhiteList Count: {5} Traffic: {4}" + System.Environment.NewLine, parcel.LocalID, parcel.Name, parcel.Desc, parcel.AccessBlackList.Count, parcel.Dwell, parcel.AccessWhiteList.Count); }); result = sb.ToString(); } else result = "Failed to retrieve information on all the simulator parcels"; Client.Parcels.SimParcelsDownloaded -= del; Thread.Sleep(2000); instance.MainForm.PreventParcelUpdate = false; WriteLine("Parcel Infro results:\n{0}", result); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (cmdArgs.Length == 0) { AttachmentInfo(WriteLine); } else { switch (cmdArgs[0]) { case "avatar": AttachmentInfo(WriteLine); break; case "parcel": ParcelInfo(WriteLine); break; } } }
public void ExecuteCommand(ConsoleWriteLine WriteLine, object session, string cmdline) { while (cmdline.StartsWith("/")) { cmdline = cmdline.Substring(1); } OutputDelegate newOutputDelegate = new OutputDelegate(WriteLine); CmdResult result; var botClient = BotClient; CMDFLAGS needResult = CMDFLAGS.Inherit | CMDFLAGS.IsConsole; try { if (botClient == null) { result = clientManager.ExecuteCommand(cmdline, session, newOutputDelegate, needResult); } else { result = botClient.ExecuteCommand(cmdline, session, newOutputDelegate, needResult); } if (result != null) { WriteLine(result.ToString()); } else { WriteLine("No result returned: {0}", cmdline); } } catch (NoSuchCommand nsc) { WriteLine("NoSuchCommand: {0} => {1}", cmdline, nsc); } catch (Exception nsc) { WriteLine("Exception: {0} => {1}", cmdline, nsc); } }
/// <summary> /// Запуск прослушки сокета /// </summary> /// <param name="ClassName">Класс для взаимодействия запросов клиента</param> /// <param name="Port"></param> /// <param name="Parent"></param> public static void StartListening(string ClassName, int Port) { var Priority = Thread.CurrentThread.Priority; foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces()) { ConsoleWriteLine.WriteInConsole(null, null, null, "Name: " + netInterface.Name, ConsoleColor.White); ConsoleWriteLine.WriteInConsole(null, null, null, "Description: " + netInterface.Description, ConsoleColor.White); ConsoleWriteLine.WriteInConsole(null, null, null, "Addresses: ", ConsoleColor.White); IPInterfaceProperties ipProps = netInterface.GetIPProperties(); foreach (UnicastIPAddressInformation addr in ipProps.UnicastAddresses) { ConsoleWriteLine.WriteInConsole(null, null, null, " " + addr.Address.ToString(), ConsoleColor.White); } } ConnectFromServer.ClassName = ClassName; localEndPoint = new IPEndPoint(IPAddress.Any, Port); ConsoleWriteLine.WriteInConsole(null, null, null, string.Format("Local IP: {0}", Helper.GetLocalIPv4(NetworkInterfaceType.Ethernet)), ConsoleColor.White); StartListening(); }
public void ExecuteCommand(ConsoleWriteLine WriteLine, object session, string cmdline) { while (cmdline.StartsWith("/")) { cmdline = cmdline.Substring(1); } OutputDelegate newOutputDelegate = new OutputDelegate(WriteLine); CmdResult result; var botClient = BotClient; CMDFLAGS needResult = CMDFLAGS.Inherit | CMDFLAGS.IsConsole; try { if (botClient == null) { result = clientManager.ExecuteCommand(cmdline, session, newOutputDelegate, needResult); } else { result = botClient.ExecuteCommand(cmdline, session, newOutputDelegate, needResult); } if (result != null) { WriteLine(result.ToString()); } else { WriteLine("No result returned: {0}", cmdline); } } catch (NoSuchCommand nsc) { WriteLine("NoSuchCommand: {0} => {1}", cmdline, nsc); } catch (Exception nsc) { WriteLine("Exception: {0} => {1}", cmdline, nsc); } }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (Chat.InvokeRequired) { if (!Instance.MonoRuntime || Chat.IsHandleCreated) Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine))); return; } if (cmdArgs.Length == 0) { if (Instance.State.FollowName == string.Empty) WriteLine("Follow inactive, type {0}follow person name, to start following them", CommandsManager.CmdPrefix); else WriteLine("Following {0}", Instance.State.FollowName); return; } string cmd = string.Join(" ", cmdArgs); if (cmd == "stop") { Instance.State.StopFollowing(); WriteLine("Following stopped"); return; } List<UUID> people = Chat.GetAvatarList(); UUID person = people.Find((UUID id) => { return Instance.Names.Get(id).ToLower().StartsWith(cmd.ToLower()); }); if (person == UUID.Zero) { WriteLine("Could not find {0}", cmd); return; } Instance.State.Follow(Instance.Names.Get(person), person); WriteLine("Following {0}", Instance.State.FollowName); }
public void Help(string args, ConsoleWriteLine WriteLine) { int found = 0; WriteLine("Result of Help : {0}", args); foreach (var cmd in instance.CommandsManager.GetCommands()) { if (args != "" && !args.Contains(cmd.Name) && !cmd.Name.Contains(args)) { continue; } WriteLine(" {0}: {1} Usage: {2}{3}", cmd.Name, cmd.Description, CmdPrefix, cmd.Usage); found++; } if (found == 0) { WriteLine("no help."); } else { WriteLine("Listed {0} command{1}.", found, found == 1 ? "" : "s"); } }
public static byte[] SerializeState_ToNetWork <T>(T obj, out string Exception, out TimeSpan TimeSpend) // Сериализация { DateTime Start = DateTime.Now; Exception = ""; byte[] bytes = default; try { using (MemoryStream stream = new MemoryStream()) { using (var deflateStream = new DeflateStream(stream, CompressionMode.Compress, true)) try { new BinaryFormatter().Serialize(deflateStream, obj); } catch (Exception ex) { ConsoleWriteLine.WriteInConsole(nameof(SerializeState_ToNetWork), "", "Failed", ex.Message.ToString(), default); Exception = ex.Message.ToString(); } stream.Position = 0; bytes = stream.GetBuffer(); } } catch (Exception ex) { ConsoleWriteLine.WriteInConsole(nameof(SerializeState_ToNetWork), "", "Failed", ex.Message.ToString(), default); Exception = ex.Message.ToString(); } TimeSpend = DateTime.Now - Start; return(bytes); }
public static T DeserializeState_ToNetWork <T>(byte[] bytes, out string Exception, out TimeSpan TimeSpend) // Десериализация { DateTime Start = DateTime.Now; Exception = ""; T Returned = default; using (var ms = new MemoryStream(bytes)) using (var deflateStream = new DeflateStream(ms, CompressionMode.Decompress, true)) try { Returned = (T) new BinaryFormatter().Deserialize(deflateStream); } catch (Exception ex) { ConsoleWriteLine.WriteInConsole(nameof(DeserializeState_ToNetWork), "", "Failed", ex.Message.ToString(), default); Exception = ex.Message.ToString(); } bytes = null; TimeSpend = DateTime.Now - Start; return(Returned); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (Chat.InvokeRequired) { if (!Instance.MonoRuntime || Chat.IsHandleCreated) { Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine))); } return; } wl = WriteLine; string cmd = string.Join(" ", cmdArgs); List <string> args = new List <string>(Regex.Split(cmd, @"\s", regexOptions)); if (args.Count == 0) { PrintUsage(); return; } bool useTP = false; if (args[0] == "tp") { useTP = true; args.RemoveAt(0); } if (args.Count == 0) { PrintUsage(); return; } string subcmd = args[0]; args.RemoveAt(0); string subarg = string.Empty; // Move certain distance int distance = 0; if (int.TryParse(subcmd, out distance)) { if (distance < 1) { return; } Quaternion heading = Client.Self.Movement.BodyRotation; KnownHeading kh = null; if (args.Count > 0) { kh = StateManager.KnownHeadings.Find((KnownHeading h) => { return(h.ID == args[0].ToUpper()); }); if (kh != null) { heading = kh.Heading; } } targetPos = Client.Self.SimPosition + new Vector3((float)distance, 0f, 0f) * heading; Client.Self.Movement.BodyRotation = Client.Self.Movement.HeadRotation = heading; Client.Self.Movement.Camera.LookAt(Client.Self.SimPosition, targetPos); Client.Self.Movement.SendUpdate(true); WriteLine("Going {0} to {1:0},{2:0},{3:0}", kh == null ? string.Empty : kh.Name, targetPos.X, targetPos.Y, targetPos.Z); Instance.State.MoveTo(targetPos, useTP); return; } if (subcmd == "help") { PrintFullUsage(); return; } if (args.Count == 0) { PrintUsage(); return; } subarg = string.Join(" ", args.ToArray()); // Move towards switch (subcmd) { case "xyz": string[] coords = Regex.Split(subarg, @"\D+"); if (coords.Length < 2) { PrintUsage(); return; } int x = int.Parse(coords[0]); int y = int.Parse(coords[1]); int z = coords.Length > 2 ? int.Parse(coords[2]) : (int)Client.Self.SimPosition.Z; targetPos = new Vector3(x, y, z); WriteLine("Going to {0:0},{1:0},{2:0}", targetPos.X, targetPos.Y, targetPos.Z); Instance.State.MoveTo(targetPos, useTP); return; case "person": List <UUID> people = Chat.GetAvatarList(); UUID person = people.Find((UUID id) => { return(Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower())); }); if (person == UUID.Zero) { WriteLine("Could not find {0}", subarg); return; } string pname = Instance.Names.Get(person); targetPos = Vector3.Zero; if (!Instance.State.TryFindAvatar(person, out targetPos)) { WriteLine("Could not locate {0}", pname); return; } WriteLine("Going to {3} at {0:0},{1:0},{2:0}", targetPos.X, targetPos.Y, targetPos.Z, pname); Instance.State.MoveTo(targetPos, useTP); return; case "object": if (!TC.TabExists("objects")) { METAboltTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance)); tab.AllowClose = true; tab.AllowDetach = true; tab.Visible = true; tab.AllowHide = false; ((ObjectsConsole)tab.Control).RefreshObjectList(); WriteLine("Objects list was not active. Started getting object names, please try again in a minute."); TC.Tabs["chat"].Select(); return; } Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List <Primitive> prims = Objects.GetObjectList(); Primitive target = prims.Find((Primitive prim) => { return(prim.Properties != null && prim.Properties.Name.ToLower().Contains(subarg.ToLower())); }); if (target == null) { WriteLine("Could not find '{0}' nearby", subarg); return; } targetPos = target.Position; WriteLine("Going to object '{0}' at {1:0},{2:0},{3:0}", target.Properties.Name, targetPos.X, targetPos.Y, targetPos.Z); Instance.State.MoveTo(targetPos, useTP); return; default: WriteLine("Unrecognized go command {0}", subcmd); return; } }
public void Help(string args, ConsoleWriteLine WriteLine) { int found = 0; WriteLine("Result of Help : {0}", args); foreach (var cmd in instance.CommandsManager.GetCommands()) { if (args != "" && !args.Contains(cmd.Name) && !cmd.Name.Contains(args)) continue; WriteLine(" {0}: {1} Usage: {2}{3}", cmd.Name, cmd.Description, CmdPrefix, cmd.Usage); found++; } if (found == 0) WriteLine("no help."); else WriteLine("Listed {0} command{1}.", found, found == 1 ? "" : "s"); }
public void ExecuteCommandForeground(ConsoleWriteLine WriteLine, string cmdline) { if (cmdline == null) return; cmdline = cmdline.Trim(); List<ICommandInterpreter> interpretersLoadedLocal = new List<ICommandInterpreter>(); lock (InterpretersLoaded) interpretersLoadedLocal.AddRange(InterpretersLoaded); foreach (ICommandInterpreter manager in interpretersLoadedLocal) { if (!manager.IsValidCommand(cmdline)) continue; // the command is queued from outside manager.ExecuteCommand(WriteLine, cmdline); return; } // our local impl while (cmdline.StartsWith(CmdPrefix)) { cmdline = cmdline.Substring(CmdPrefix.Length); cmdline = cmdline.Trim(); } if (cmdline == "") return; string[] parsd = ParseArguments(cmdline); string cmd = parsd[0]; IRadegastCommand cmdimpl; if (CommandsByName.TryGetValue(cmd.ToLower(), out cmdimpl)) { try { cmdimpl.Execute(cmd, SplitOff(parsd, 1), WriteLine); } catch (Exception ex) { WriteLine("Command error: {0} \n{1} {2} ", cmdline, ex.Message, ex.StackTrace); } return; } WriteLine("Command not found {0}", cmd); }
/// <summary> /// Queues command for execution /// </summary> /// <param name="WriteLine"></param> /// <param name="cmdline"></param> public void ExecuteCommand(ConsoleWriteLine WriteLine, string cmdline) { EnqueueCommand(cmdline, () => ExecuteCommandForeground(WriteLine, cmdline)); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { wl = WriteLine; if (cmdArgs.Length == 0) { PrintUsage(); return; } if (cmdArgs[0] == "help") { PrintFullUsage(); return; } InventoryFolder folder = (InventoryFolder)Inv.GetContents(Inv.RootFolder).Find(b => b.Name == FolderName && b is InventoryFolder); if (folder == null) { Client.Inventory.CreateFolder(Inv.RootFolder.UUID, FolderName); WriteLine(@"Could not find ""{0}"" folder in the inventory, creating one.", FolderName); return; } List <InventoryLandmark> landmarks = new List <InventoryLandmark>(); Inv.GetContents(folder) .FindAll(b => b is InventoryLandmark) .ForEach(l => { landmarks.Add((InventoryLandmark)l); }); if (landmarks.Count == 0) { WriteLine(@"""{0}"" folder is empty, nothing to do.", FolderName); return; } string cmd = string.Join(" ", cmdArgs); landmarks.Sort(new LMSorter()); if (cmd == "list") { StringBuilder sb = new StringBuilder(); sb.AppendLine("Landmarks:"); for (int i = 0; i < landmarks.Count; i++) { sb.AppendLine(string.Format("{0}. {1}", i + 1, landmarks[i].Name)); } WriteLine(sb.ToString()); return; } int lmnr; if (int.TryParse(cmd, out lmnr)) { if (lmnr >= 1 && lmnr <= landmarks.Count) { WriteLine("Teleporting to {0}", landmarks[lmnr - 1].Name); Client.Self.RequestTeleport(landmarks[lmnr - 1].AssetUUID); } else { WriteLine("Valid landmark number is between 1 and {0}", landmarks.Count); } return; } InventoryLandmark lm = landmarks.Find(l => l.Name.ToLower().StartsWith(cmd.ToLower())); if (lm == null) { WriteLine("Could not find landmark {0}, try {1}tp list", cmd, CommandsManager.CmdPrefix); } else { WriteLine("Teleporting to {0}", lm.Name); Client.Self.RequestTeleport(lm.AssetUUID); } }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (cmdArgs.Length == 0) { AttachmentInfo(WriteLine); } else if (cmdArgs[0] == "avatar") { AttachmentInfo(WriteLine); } else if (cmdArgs[0] == "parcel") { ParcelInfo(WriteLine); } }
public void Execute(string threadCmd, string[] cmdArgs, ConsoleWriteLine WriteLine) { string args = String.Join(" ", cmdArgs); if (threadCmd == "kill") { if (_listed == null) { WriteLine("Must load the threadlist Using: thread"); return; } lock (_listed) { if (_listed.Count == 0) { WriteLine("No threaded commands to kill."); } else { WriteLine("Killing all threaded commands"); int found = 0; foreach (var cmd in _listed) { try { if (cmd.IsAlive) { found++; cmd.Abort(); } } catch (Exception) { } } WriteLine("Killed {0} thread{1}.", found, found == 1 ? "" : "s"); _listed = null; } } lock (_commandQueue) { int commandQueueCount = _commandQueue.Count; if (commandQueueCount == 0) { WriteLine("No queued commands."); } else { _commandQueue.Clear(); WriteLine("Clear queued commands: " + commandQueueCount); } } return; } //cleared each time becasue the list will change _listed = null; if (args == string.Empty) { lock (_commandThreads) _listed = new List<Thread>(_commandThreads); if (_listed.Count == 0) { WriteLine("No threaded commands."); } else { int found = _listed.Count; WriteLine("Listing {0} thread{1}.", found, found == 1 ? "" : "s"); for (int i = 0; i < _listed.Count; i++) { WriteLine(" * {0}: {1}", i, _listed[i].Name); } } lock (_commandQueue) { if (_commandQueue.Count == 0) { WriteLine("No queued commands."); } else { WriteLine("Queued commands: {0}", _commandQueue.Count); foreach (var c in _commandQueue) { WriteLine(" Q: {0}", c.Key); } } } return; } string name = string.Format("ThreadCommand {0}: {1}", DateTime.Now, args); Thread thread = new Thread(() => { try { WriteLine("Started command: {0}", args); instance.CommandsManager.ExecuteCommandForeground(WriteLine, args); } catch (Exception e) { WriteLine("Exception: " + name + "\n" + e); } finally { WriteLine("Done with {0}", args); _commandThreads.Remove(Thread.CurrentThread); } }) {Name = name}; lock (_commandThreads) _commandThreads.Add(thread); thread.Start(); }
public void Help(string helpArgs, ConsoleWriteLine WriteLine) { clientManager.ExecuteCommand("help " + helpArgs, null, new OutputDelegate(WriteLine), CMDFLAGS.Inherit); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { Instance.State.SetSitting(false, UUID.Zero); WriteLine("Stood up"); }
public virtual void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (_execute == null) WriteLine("Someone did not implement {0}!", name); else _execute(name, cmdArgs, WriteLine); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { args.Clear(); args.AddRange(cmdArgs); StringBuilder sb = new StringBuilder(); if (arg("doing")) { if (Client.Self.SittingOn != 0) { sb.Append("Sitting"); Primitive seat; if (Client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(Client.Self.SittingOn, out seat)) { if (seat.Properties != null) { sb.AppendFormat(" on object {0}", seat.Properties.Name); } else { ManualResetEvent gotName = new ManualResetEvent(false); EventHandler<ObjectPropertiesFamilyEventArgs> handler = (object sender, ObjectPropertiesFamilyEventArgs e) => { if (e.Properties.ObjectID == seat.ID) gotName.Set(); }; Client.Objects.ObjectPropertiesFamily += handler; Client.Objects.RequestObjectPropertiesFamily(Client.Network.CurrentSim, seat.ID); if (gotName.WaitOne(3000, false)) { sb.Append(sb.AppendFormat(" on object {0}", seat.Properties.Name)); } Client.Objects.ObjectPropertiesFamily -= handler; } } } else { if (Client.Self.Movement.SitOnGround) sb.Append("Sitting on the ground"); else if (Client.Self.Movement.Fly) sb.Append("Flying"); else sb.Append("Standing"); if (Client.Self.Movement.AlwaysRun) sb.Append(", always running when moving"); } if (Instance.State.FollowName != string.Empty) sb.AppendFormat(", following {0}", Instance.State.FollowName); sb.AppendLine(); } if (arg("region")) { sb.AppendLine(string.Format("Region: {0} ({1})", Client.Network.CurrentSim.Name, Utils.EnumToText(Client.Network.CurrentSim.Access))); } if (arg("parcel") && Instance.State.Parcel != null) { Parcel parcel = Instance.State.Parcel; sb.AppendFormat(@"Parcel: {0}", parcel.Name); List<string> mods = new List<string>(); if ((parcel.Flags & ParcelFlags.AllowFly) != ParcelFlags.AllowFly) mods.Add("no fly"); if ((parcel.Flags & ParcelFlags.CreateObjects) != ParcelFlags.CreateObjects) mods.Add("no build"); if ((parcel.Flags & ParcelFlags.AllowOtherScripts) != ParcelFlags.AllowOtherScripts) mods.Add("no scripts"); if ((parcel.Flags & ParcelFlags.RestrictPushObject) == ParcelFlags.RestrictPushObject) mods.Add("no push"); if ((parcel.Flags & ParcelFlags.AllowDamage) == ParcelFlags.AllowDamage) mods.Add("damage allowed"); if ((parcel.Flags & ParcelFlags.AllowVoiceChat) != ParcelFlags.AllowVoiceChat) mods.Add("no voice"); if (mods.Count > 0) sb.AppendFormat(" ({0})", string.Join(", ", mods.ToArray())); sb.AppendLine(); } if (arg("location")) { Primitive seat = null; if (Client.Self.SittingOn != 0) Client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(Client.Self.SittingOn, out seat); Vector3 pos = Client.Self.RelativePosition; if (seat != null) pos = seat.Position + pos; sb.AppendFormat("Position <{0:0}, {1:0}, {2:0}>", pos.X, pos.Y, pos.Z); Quaternion rot; if (seat == null) rot = Client.Self.Movement.BodyRotation; else rot = seat.Rotation + Client.Self.RelativeRotation; Vector3 heading = StateManager.RotToEuler(rot); int facing = (int)(57.2957795d * heading.Z); if (facing < 0) facing = 360 + facing; sb.AppendFormat(" heading {0:0} degrees, ", facing); sb.AppendFormat(" facing {0}", StateManager.ClosestKnownHeading(facing).Name); sb.AppendLine(); } if (arg("money")) { sb.AppendFormat("Account balance: ${0}", Client.Self.Balance); sb.AppendLine(); } if (arg("time")) { try { TimeZoneInfo SLTime = null; foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones()) { if (tz.Id == "Pacific Standard Time" || tz.Id == "America/Los_Angeles") { SLTime = tz; break; } } DateTime now; if (SLTime != null) now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, SLTime); else now = DateTime.UtcNow.AddHours(-7); sb.AppendLine(string.Format("Current time is " + now.ToString("h:mm tt", System.Globalization.CultureInfo.InvariantCulture))); } catch { } } WriteLine(sb.ToString()); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (Chat.InvokeRequired) { if (!Instance.MonoRuntime || Chat.IsHandleCreated) Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine))); return; } wl = WriteLine; if (cmdArgs.Length == 0) { PrintUsage(); return; } string cmd = string.Join(" ", cmdArgs); List<string> args = new List<string>(Regex.Split(cmd, @"\s")); string subcmd = args[0]; args.RemoveAt(0); if (args.Count == 0) { PrintUsage(); return; } string subarg = string.Join(" ", args.ToArray()); Primitive seat = null; if (Client.Self.SittingOn != 0) Client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(Client.Self.SittingOn, out seat); Vector3 mypos = Client.Self.RelativePosition; if (seat != null) mypos = seat.Position + mypos; StringBuilder sb = new StringBuilder(); if (subcmd == "object") { if (!TC.TabExists("objects")) { RadegastTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance)); tab.AllowClose = true; tab.AllowDetach = true; tab.Visible = true; tab.AllowHide = false; ((ObjectsConsole)tab.Control).RefreshObjectList(); TC.Tabs["chat"].Select(); WriteLine("Objects list was not active. Started getting object names, please try again in a minute."); return; } Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List<Primitive> prims = Objects.GetObjectList(); List<Primitive> targets = prims.FindAll((Primitive prim) => { return prim.Properties != null && prim.Properties.Name.ToLower().Contains(subarg.ToLower()); }); if (targets == null || targets.Count == 0) { WriteLine("Could not find '{0}' nearby", subarg); return; } foreach (Primitive target in targets) { Vector3 heading = StateManager.RotToEuler(Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(target.Position - mypos))); int facing = (int)(57.2957795d * heading.Z); if (facing < 0) facing = 360 + facing; sb.AppendFormat("{0} is {1:0} meters away to the {2}", target.Properties.Name, Vector3.Distance(mypos, target.Position), StateManager.ClosestKnownHeading(facing) ); float elev = target.Position.Z - mypos.Z; if (Math.Abs(elev) < 2f) sb.Append(" at our level"); else if (elev > 0) sb.AppendFormat(", {0:0} meters above our level", elev); else sb.AppendFormat(", {0:0} meters below our level", -elev); sb.AppendLine(); } wl(sb.ToString()); return; } if (subcmd == "person") { List<UUID> people = Chat.GetAvatarList(); people = people.FindAll((UUID id) => { return id != Client.Self.AgentID && Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower()); }); if (people == null || people.Count == 0) { WriteLine("Could not find {0}", subarg); return; } foreach (UUID person in people) { string pname = Instance.Names.Get(person); Vector3 targetPos = Vector3.Zero; // try to find where they are Avatar avi = Client.Network.CurrentSim.ObjectsAvatars.Find((Avatar av) => { return av.ID == person; }); if (avi != null) { if (avi.ParentID == 0) { targetPos = avi.Position; } else { Primitive theirSeat; if (Client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(avi.ParentID, out theirSeat)) { targetPos = theirSeat.Position + avi.Position; } } } else { if (Client.Network.CurrentSim.AvatarPositions.ContainsKey(person)) targetPos = Client.Network.CurrentSim.AvatarPositions[person]; } if (targetPos.Z < 0.01f) { WriteLine("Could not locate {0}", pname); return; } Vector3 heading = StateManager.RotToEuler(Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(targetPos - mypos))); int facing = (int)(57.2957795d * heading.Z); if (facing < 0) facing = 360 + facing; sb.AppendFormat("{0} is {1:0} meters away to the {2}", pname, Vector3.Distance(mypos, targetPos), StateManager.ClosestKnownHeading(facing) ); float elev = targetPos.Z - mypos.Z; if (Math.Abs(elev) < 2f) sb.Append(" at our level"); else if (elev > 0) sb.AppendFormat(", {0:0} meters above our level", elev); else sb.AppendFormat(", {0:0} meters below our level", -elev); sb.AppendLine(); } wl(sb.ToString()); return; } }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (Chat.InvokeRequired) { if (!Instance.MonoRuntime || Chat.IsHandleCreated) Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine))); return; } wl = WriteLine; if (cmdArgs.Length == 0) { PrintUsage(); return; } string cmd = string.Join(" ", cmdArgs); if (cmd == "ground") { Client.Self.SitOnGround(); wl("Sat on the ground"); return; } if (!TC.TabExists("objects")) { RadegastTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance)); tab.AllowClose = true; tab.AllowDetach = true; tab.Visible = true; tab.AllowHide = false; ((ObjectsConsole)tab.Control).RefreshObjectList(); TC.Tabs["chat"].Select(); WriteLine("Objects list was not active. Started getting object names, please try again in a minute."); return; } Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List<Primitive> prims = Objects.GetObjectList(); Primitive target = prims.Find((Primitive prim) => { return prim.Properties != null && prim.Properties.Name.ToLower().Contains(cmd.ToLower()); }); if (target == null) { WriteLine("Could not find '{0}' nearby", cmd); return; } WriteLine("Requesting to sit on object '{0}'", target.Properties.Name); Instance.State.SetSitting(true, target.ID); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (Chat.InvokeRequired) { if (!Instance.MonoRuntime || Chat.IsHandleCreated) { Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine))); } return; } wl = WriteLine; if (cmdArgs.Length == 0) { PrintUsage(); return; } string cmd = string.Join(" ", cmdArgs); List <string> args = new List <string>(Regex.Split(cmd, @"\s")); string subcmd = args[0]; args.RemoveAt(0); if (args.Count == 0) { PrintUsage(); return; } string subarg = string.Join(" ", args.ToArray()); Primitive seat = null; if (Client.Self.SittingOn != 0) { Client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(Client.Self.SittingOn, out seat); } Vector3 mypos = Client.Self.RelativePosition; if (seat != null) { mypos = seat.Position + mypos; } StringBuilder sb = new StringBuilder(); if (subcmd == "object") { if (!TC.TabExists("objects")) { RadegastTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance)); tab.AllowClose = true; tab.AllowDetach = true; tab.Visible = true; tab.AllowHide = false; ((ObjectsConsole)tab.Control).RefreshObjectList(); TC.Tabs["chat"].Select(); WriteLine("Objects list was not active. Started getting object names, please try again in a minute."); return; } Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List <Primitive> prims = Objects.GetObjectList(); List <Primitive> targets = prims.FindAll(prim => prim.Properties != null && prim.Properties.Name.ToLower().Contains(subarg.ToLower())); if (targets.Count == 0) { WriteLine("Could not find '{0}' nearby", subarg); return; } foreach (Primitive target in targets) { Vector3 heading = StateManager.RotToEuler(Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(target.Position - mypos))); int facing = (int)(57.2957795d * heading.Z); if (facing < 0) { facing = 360 + facing; } sb.AppendFormat("{0} is {1:0} meters away to the {2}", target.Properties.Name, Vector3.Distance(mypos, target.Position), StateManager.ClosestKnownHeading(facing) ); float elev = target.Position.Z - mypos.Z; if (Math.Abs(elev) < 2f) { sb.Append(" at our level"); } else if (elev > 0) { sb.AppendFormat(", {0:0} meters above our level", elev); } else { sb.AppendFormat(", {0:0} meters below our level", -elev); } sb.AppendLine(); } wl(sb.ToString()); return; } if (subcmd == "person") { List <UUID> people = Chat.GetAvatarList(); people = people.FindAll(id => id != Client.Self.AgentID && Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower())); if (people.Count == 0) { WriteLine("Could not find {0}", subarg); return; } foreach (UUID person in people) { string pname = Instance.Names.Get(person); Vector3 targetPos = Vector3.Zero; // try to find where they are Avatar avi = Client.Network.CurrentSim.ObjectsAvatars.Find(av => av.ID == person); if (avi != null) { if (avi.ParentID == 0) { targetPos = avi.Position; } else { Primitive theirSeat; if (Client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(avi.ParentID, out theirSeat)) { targetPos = theirSeat.Position + avi.Position; } } } else { if (Client.Network.CurrentSim.AvatarPositions.ContainsKey(person)) { targetPos = Client.Network.CurrentSim.AvatarPositions[person]; } } if (targetPos.Z < 0.01f) { WriteLine("Could not locate {0}", pname); return; } Vector3 heading = StateManager.RotToEuler(Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(targetPos - mypos))); int facing = (int)(57.2957795d * heading.Z); if (facing < 0) { facing = 360 + facing; } sb.AppendFormat("{0} is {1:0} meters away to the {2}", pname, Vector3.Distance(mypos, targetPos), StateManager.ClosestKnownHeading(facing) ); float elev = targetPos.Z - mypos.Z; if (Math.Abs(elev) < 2f) { sb.Append(" at our level"); } else if (elev > 0) { sb.AppendFormat(", {0:0} meters above our level", elev); } else { sb.AppendFormat(", {0:0} meters below our level", -elev); } sb.AppendLine(); } wl(sb.ToString()); } }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (Chat.InvokeRequired) { if (!Instance.MonoRuntime || Chat.IsHandleCreated) Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine))); return; } wl = WriteLine; string cmd = string.Join(" ", cmdArgs); List<string> args = new List<string>(Regex.Split(cmd, @"\s", regexOptions)); if (args.Count == 0) { PrintUsage(); return; } bool useTP = false; if (args[0] == "tp") { useTP = true; args.RemoveAt(0); } if (args.Count == 0) { PrintUsage(); return; } string subcmd = args[0]; args.RemoveAt(0); string subarg = string.Empty; // Move certain distance int distance = 0; if (int.TryParse(subcmd, out distance)) { if (distance < 1) return; Quaternion heading = Client.Self.Movement.BodyRotation; KnownHeading kh = null; if (args.Count > 0) { kh = StateManager.KnownHeadings.Find((KnownHeading h) => { return h.ID == args[0].ToUpper(); }); if (kh != null) heading = kh.Heading; } targetPos = Client.Self.SimPosition + new Vector3((float)distance, 0f, 0f) * heading; Client.Self.Movement.BodyRotation = Client.Self.Movement.HeadRotation = heading; Client.Self.Movement.Camera.LookAt(Client.Self.SimPosition, targetPos); Client.Self.Movement.SendUpdate(true); WriteLine("Going {0} to {1:0},{2:0},{3:0}", kh == null ? string.Empty : kh.Name, targetPos.X, targetPos.Y, targetPos.Z); Instance.State.MoveTo(targetPos, useTP); return; } if (subcmd == "help") { PrintFullUsage(); return; } if (args.Count == 0) { PrintUsage(); return; } subarg = string.Join(" ", args.ToArray()); // Move towards switch (subcmd) { case "xyz": string[] coords = Regex.Split(subarg, @"\D+"); if (coords.Length < 2) { PrintUsage(); return; } int x = int.Parse(coords[0]); int y = int.Parse(coords[1]); int z = coords.Length > 2 ? int.Parse(coords[2]) : (int)Client.Self.SimPosition.Z; targetPos = new Vector3(x, y, z); WriteLine("Going to {0:0},{1:0},{2:0}", targetPos.X, targetPos.Y, targetPos.Z); Instance.State.MoveTo(targetPos, useTP); return; case "person": List<UUID> people = Chat.GetAvatarList(); UUID person = people.Find((UUID id) => { return Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower()); }); if (person == UUID.Zero) { WriteLine("Could not find {0}", subarg); return; } string pname = Instance.Names.Get(person); targetPos = Vector3.Zero; if (!Instance.State.TryFindAvatar(person, out targetPos)) { WriteLine("Could not locate {0}", pname); return; } WriteLine("Going to {3} at {0:0},{1:0},{2:0}", targetPos.X, targetPos.Y, targetPos.Z, pname); Instance.State.MoveTo(targetPos, useTP); return; case "object": if (!TC.TabExists("objects")) { RadegastTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance)); tab.AllowClose = true; tab.AllowDetach = true; tab.Visible = true; tab.AllowHide = false; ((ObjectsConsole)tab.Control).RefreshObjectList(); WriteLine("Objects list was not active. Started getting object names, please try again in a minute."); TC.Tabs["chat"].Select(); return; } Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List<Primitive> prims = Objects.GetObjectList(); Primitive target = prims.Find((Primitive prim) => { return prim.Properties != null && prim.Properties.Name.ToLower().Contains(subarg.ToLower()); }); if (target == null) { WriteLine("Could not find '{0}' nearby", subarg); return; } targetPos = target.Position; WriteLine("Going to object '{0}' at {1:0},{2:0},{3:0}", target.Properties.Name, targetPos.X, targetPos.Y, targetPos.Z); Instance.State.MoveTo(targetPos, useTP); return; default: WriteLine("Unrecognized go command {0}", subcmd); return; } }
public void ParcelInfo(ConsoleWriteLine WriteLine) { WriteLine("Requesting script resources information..."); UUID currectParcel = Client.Parcels.RequestRemoteParcelID(Client.Self.SimPosition, Client.Network.CurrentSim.Handle, Client.Network.CurrentSim.ID); Client.Parcels.GetParcelResouces(currectParcel, true, (bool success, LandResourcesInfo info) => { if (!success || info == null) return; StringBuilder sb = new StringBuilder(); sb.AppendLine("Summary:"); sb.AppendFormat("Memory used {0} KB out of {1} KB available.", info.SummaryUsed["memory"] / 1024, info.SummaryAvailable["memory"] / 1024); sb.AppendLine(); sb.AppendFormat("URLs used {0} out of {1} available.", info.SummaryUsed["urls"], info.SummaryAvailable["urls"]); sb.AppendLine(); if (info.Parcels != null) { for (int i = 0; i < info.Parcels.Length; i++) { sb.AppendLine(); sb.AppendLine("Detailed usage for parcel " + info.Parcels[i].Name); for (int j = 0; j < info.Parcels[i].Objects.Length; j++) { sb.AppendFormat("{0} KB - {1}", info.Parcels[i].Objects[j].Resources["memory"] / 1024, info.Parcels[i].Objects[j].Name); sb.AppendLine(); } } } WriteLine(sb.ToString()); }); }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (Chat.InvokeRequired) { if (!Instance.MonoRuntime || Chat.IsHandleCreated) Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine))); return; } wl = WriteLine; string cmd = string.Join(" ", cmdArgs); List<string> args = new List<string>(Regex.Split(cmd, @"\s", regexOptions)); if (args.Count == 0) { PrintUsage(); return; } string subcmd = args[0]; args.RemoveAt(0); string subarg = string.Empty; // Face certain direction int heading = 0; if (int.TryParse(subcmd, out heading)) { double rad = 0.0174532925d * heading; Client.Self.Movement.UpdateFromHeading(rad, true); WriteLine("Facing {0} degrees", heading % 360); return; } if (subcmd == "help") { PrintFullUsage(); return; } KnownHeading kh = null; kh = StateManager.KnownHeadings.Find((KnownHeading h) => { return h.ID == subcmd.ToUpper(); }); if (kh != null) { Client.Self.Movement.BodyRotation = Client.Self.Movement.HeadRotation = kh.Heading; WriteLine("Facing {0}", kh.Name); return; } if (args.Count == 0) { PrintUsage(); return; } subarg = string.Join(" ", args.ToArray()); // Move towards switch (subcmd) { case "person": List<UUID> people = Chat.GetAvatarList(); UUID person = people.Find((UUID id) => { return Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower()); }); if (person == UUID.Zero) { WriteLine("Could not find {0}", subarg); return; } string pname = Instance.Names.Get(person); if (!Instance.State.TryFindAvatar(person, out targetPos)) { WriteLine("Could not locate {0}", pname); return; } WriteLine("Facing {0}", pname); Client.Self.Movement.TurnToward(targetPos); return; case "object": if (!TC.TabExists("objects")) { RadegastTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance)); tab.AllowClose = true; tab.AllowDetach = true; tab.Visible = true; tab.AllowHide = false; ((ObjectsConsole)tab.Control).RefreshObjectList(); TC.Tabs["chat"].Select(); WriteLine("Objects list was not active. Started getting object names, please try again in a minute."); return; } Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List<Primitive> prims = Objects.GetObjectList(); Primitive target = prims.Find((Primitive prim) => { return prim.Properties != null && prim.Properties.Name.ToLower().Contains(subarg.ToLower()); }); if (target == null) { WriteLine("Could not find '{0}' nearby", subarg); return; } targetPos = target.Position; WriteLine("Facing object '{0}'", target.Properties.Name); Client.Self.Movement.TurnToward(targetPos); return; default: WriteLine("Unrecognized face command {0}", subcmd); return; } }
public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine) { if (Chat.InvokeRequired) { if (!Instance.MonoRuntime || Chat.IsHandleCreated) { Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine))); } return; } wl = WriteLine; string cmd = string.Join(" ", cmdArgs); List <string> args = new List <string>(Regex.Split(cmd, @"\s", regexOptions)); if (args.Count == 0) { PrintUsage(); return; } string subcmd = args[0]; args.RemoveAt(0); string subarg = string.Empty; // Face certain direction int heading = 0; if (int.TryParse(subcmd, out heading)) { double rad = 0.0174532925d * heading; Client.Self.Movement.UpdateFromHeading(rad, true); WriteLine("Facing {0} degrees", heading % 360); return; } if (subcmd == "help") { PrintFullUsage(); return; } KnownHeading kh = null; kh = StateManager.KnownHeadings.Find(h => { return(h.ID == subcmd.ToUpper()); }); if (kh != null) { Client.Self.Movement.BodyRotation = Client.Self.Movement.HeadRotation = kh.Heading; WriteLine("Facing {0}", kh.Name); return; } if (args.Count == 0) { PrintUsage(); return; } subarg = string.Join(" ", args.ToArray()); // Move towards switch (subcmd) { case "person": List <UUID> people = Chat.GetAvatarList(); UUID person = people.Find(id => { return(Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower())); }); if (person == UUID.Zero) { WriteLine("Could not find {0}", subarg); return; } string pname = Instance.Names.Get(person); if (!Instance.State.TryFindAvatar(person, out targetPos)) { WriteLine("Could not locate {0}", pname); return; } WriteLine("Facing {0}", pname); Client.Self.Movement.TurnToward(targetPos); return; case "object": if (!TC.TabExists("objects")) { RadegastTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance)); tab.AllowClose = true; tab.AllowDetach = true; tab.Visible = true; tab.AllowHide = false; ((ObjectsConsole)tab.Control).RefreshObjectList(); TC.Tabs["chat"].Select(); WriteLine("Objects list was not active. Started getting object names, please try again in a minute."); return; } Objects = (ObjectsConsole)TC.Tabs["objects"].Control; List <Primitive> prims = Objects.GetObjectList(); Primitive target = prims.Find(prim => { return(prim.Properties != null && prim.Properties.Name.ToLower().Contains(subarg.ToLower())); }); if (target == null) { WriteLine("Could not find '{0}' nearby", subarg); return; } targetPos = target.Position; WriteLine("Facing object '{0}'", target.Properties.Name); Client.Self.Movement.TurnToward(targetPos); return; default: WriteLine("Unrecognized face command {0}", subcmd); return; } }
public void ExecuteCommand(ConsoleWriteLine WriteLine, string cmdline) { ExecuteCommand(WriteLine, this, cmdline); }