Beispiel #1
0
        private void OnMake(EntityUid uid, string name, string description, string rules, bool makeSentient)
        {
            var player = _playerManager.LocalPlayer;

            if (player == null)
            {
                return;
            }

            var makeGhostRoleCommand =
                $"makeghostrole " +
                $"\"{CommandParsing.Escape(uid.ToString())}\" " +
                $"\"{CommandParsing.Escape(name)}\" " +
                $"\"{CommandParsing.Escape(description)}\" " +
                $"\"{CommandParsing.Escape(rules)}\"";

            _consoleHost.ExecuteCommand(player.Session, makeGhostRoleCommand);

            if (makeSentient)
            {
                var makeSentientCommand = $"makesentient \"{CommandParsing.Escape(uid.ToString())}\"";
                _consoleHost.ExecuteCommand(player.Session, makeSentientCommand);
            }

            _window.Close();
        }
 public ObjectsTabEntry(string name, EntityUid euid)
 {
     RobustXamlLoader.Load(this);
     AssocEntity    = euid;
     EIDLabel.Text  = euid.ToString();
     NameLabel.Text = name;
 }
        public static string SubstituteEntityDetails(IConsoleShell shell, EntityUid ent, string ruleString)
        {
            var entMan    = IoCManager.Resolve <IEntityManager>();
            var transform = entMan.GetComponent <TransformComponent>(ent);

            // gross, is there a better way to do this?
            ruleString = ruleString.Replace("$ID", ent.ToString());
            ruleString = ruleString.Replace("$WX",
                                            transform.WorldPosition.X.ToString(CultureInfo.InvariantCulture));
            ruleString = ruleString.Replace("$WY",
                                            transform.WorldPosition.Y.ToString(CultureInfo.InvariantCulture));
            ruleString = ruleString.Replace("$LX",
                                            transform.LocalPosition.X.ToString(CultureInfo.InvariantCulture));
            ruleString = ruleString.Replace("$LY",
                                            transform.LocalPosition.Y.ToString(CultureInfo.InvariantCulture));
            ruleString = ruleString.Replace("$NAME", entMan.GetComponent <MetaDataComponent>(ent).EntityName);

            if (shell.Player is IPlayerSession player)
            {
                if (player.AttachedEntity is { Valid : true } p)
                {
                    var pTransform = entMan.GetComponent <TransformComponent>(p);

                    ruleString = ruleString.Replace("$PID", ent.ToString());
                    ruleString = ruleString.Replace("$PWX",
                                                    pTransform.WorldPosition.X.ToString(CultureInfo.InvariantCulture));
                    ruleString = ruleString.Replace("$PWY",
                                                    pTransform.WorldPosition.Y.ToString(CultureInfo.InvariantCulture));
                    ruleString = ruleString.Replace("$PLX",
                                                    pTransform.LocalPosition.X.ToString(CultureInfo.InvariantCulture));
                    ruleString = ruleString.Replace("$PLY",
                                                    pTransform.LocalPosition.Y.ToString(CultureInfo.InvariantCulture));
                }
            }
            return(ruleString);
        }