public bool Execute(IDebugConsole console, params string[] args) { if (args.Length != 1) { console.AddLine(Help); return(false); } if ((!new Regex(@"^c?[0-9]+$").IsMatch(args[0]))) { console.AddLine("Malformed UID", Color.Red); return(false); } var uid = EntityUid.Parse(args[0]); var entmgr = IoCManager.Resolve <IEntityManager>(); if (!entmgr.TryGetEntity(uid, out var entity)) { console.AddLine("That entity does not exist. Sorry lad.", Color.Red); return(false); } console.AddLine($"{entity.Uid}: {entity.Prototype?.ID}/{entity.Name}"); console.AddLine($"init/del/lmt: {entity.Initialized}/{entity.Deleted}/{entity.LastModifiedTick}"); foreach (var component in entity.GetAllComponents()) { console.AddLine(component.ToString() ?? ""); if (component is IComponentDebug debug) { foreach (var line in debug.GetDebugString().Split('\n')) { if (string.IsNullOrWhiteSpace(line)) { continue; } console.AddLine("\t" + line); } } } return(false); }
public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length != 1) { shell.WriteLine(Help); return; } if ((!new Regex(@"^c?[0-9]+$").IsMatch(args[0]))) { shell.WriteError("Malformed UID"); return; } var uid = EntityUid.Parse(args[0]); var entmgr = IoCManager.Resolve <IEntityManager>(); if (!entmgr.EntityExists(uid)) { shell.WriteError("That entity does not exist. Sorry lad."); return; } var meta = entmgr.GetComponent <MetaDataComponent>(uid); shell.WriteLine($"{uid}: {meta.EntityPrototype?.ID}/{meta.EntityName}"); shell.WriteLine($"init/del/lmt: {meta.EntityInitialized}/{meta.EntityDeleted}/{meta.EntityLastModifiedTick}"); foreach (var component in entmgr.GetComponents(uid)) { shell.WriteLine(component.ToString() ?? ""); if (component is IComponentDebug debug) { foreach (var line in debug.GetDebugString().Split('\n')) { if (string.IsNullOrWhiteSpace(line)) { continue; } shell.WriteLine("\t" + line); } } } }
public bool Execute(IDebugConsole console, params string[] args) { var vvm = IoCManager.Resolve <IViewVariablesManager>(); // If you don't provide an entity ID, it opens the test class. // Spooky huh. if (args.Length == 0) { vvm.OpenVV(new VVTest()); } else { var valArg = args[0]; if (valArg.StartsWith("SI")) { var selector = new ViewVariablesIoCSelector(valArg.Substring(1)); vvm.OpenVV(selector); return(false); } if (valArg.StartsWith("I")) { // IoC name. var type = IoCManager.Resolve <IReflectionManager>().LooseGetType(valArg); var obj = IoCManager.ResolveType(type); vvm.OpenVV(obj); return(false); } if (valArg.StartsWith("gui/")) { var obj = IoCManager.Resolve <IUserInterfaceManager>().RootControl; vvm.OpenVV(obj.GetChild(valArg.Substring(4))); return(false); } var entityManager = IoCManager.Resolve <IEntityManager>(); var uid = EntityUid.Parse(args[0]); vvm.OpenVV(entityManager.GetEntity(uid)); } return(false); }
public bool Execute(IDebugConsole shell, string[] args) { if (args.Length != 2) { shell.AddLine("Wrong number of arguments"); return(false); } var entityUid = EntityUid.Parse(args[0]); var componentName = args[1]; var compManager = IoCManager.Resolve <IComponentManager>(); var compFactory = IoCManager.Resolve <IComponentFactory>(); var registration = compFactory.GetRegistration(componentName); compManager.RemoveComponent(entityUid, registration.Type); return(false); }
public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length != 2) { shell.WriteLine("Wrong number of arguments"); return; } var entity = EntityUid.Parse(args[0]); var componentName = args[1]; var compFactory = IoCManager.Resolve <IComponentFactory>(); var entityManager = IoCManager.Resolve <IEntityManager>(); var component = (Component)compFactory.GetComponent(componentName); component.Owner = entity; entityManager.AddComponent(entity, component); }
public void Execute(IConsoleShell shell, IPlayerSession?player, string[] args) { if (args.Length != 2) { shell.SendText(player, "Wrong number of arguments"); return; } var entityUid = EntityUid.Parse(args[0]); var componentName = args[1]; var compManager = IoCManager.Resolve <IComponentManager>(); var compFactory = IoCManager.Resolve <IComponentFactory>(); var entityManager = IoCManager.Resolve <IEntityManager>(); var entity = entityManager.GetEntity(entityUid); var component = (Component)compFactory.GetComponent(componentName); component.Owner = entity; compManager.AddComponent(entity, component); }
protected override Control MakeUI(object?value) { var hBox = new BoxContainer { Orientation = LayoutOrientation.Horizontal, MinSize = new Vector2(200, 0) }; var uid = (EntityUid)value !; var lineEdit = new LineEdit { Text = uid.ToString(), Editable = !ReadOnly, HorizontalExpand = true, }; if (!ReadOnly) { lineEdit.OnTextEntered += e => ValueChanged(EntityUid.Parse(e.Text)); } var vvButton = new Button() { Text = "View", }; vvButton.OnPressed += e => { IoCManager.Resolve <IConsoleHost>().ExecuteCommand($"vv {uid}"); }; hBox.AddChild(lineEdit); hBox.AddChild(vvButton); return(hBox); }
protected override Control MakeUI(object?value) { var hBox = new HBoxContainer { CustomMinimumSize = new Vector2(200, 0) }; var uid = (EntityUid)value !; var lineEdit = new LineEdit { Text = uid.ToString(), Editable = !ReadOnly, SizeFlagsHorizontal = Control.SizeFlags.FillExpand }; if (!ReadOnly) { lineEdit.OnTextEntered += e => ValueChanged(EntityUid.Parse(e.Text)); } hBox.AddChild(lineEdit); return(hBox); }
public bool Execute(IDebugConsole shell, params string[] args) { if (args.Length != 2) { shell.AddLine("Wrong number of arguments"); return(false); } var entityUid = EntityUid.Parse(args[0]); var componentName = args[1]; var compManager = IoCManager.Resolve <IComponentManager>(); var compFactory = IoCManager.Resolve <IComponentFactory>(); var entityManager = IoCManager.Resolve <IEntityManager>(); var entity = entityManager.GetEntity(entityUid); var component = (Component)compFactory.GetComponent(componentName); component.Owner = entity; compManager.AddComponent(entity, component); return(false); }