Example #1
0
        protected override PreparedResult Prepare(Dictionary <string, object> conVars,
                                                  ref Dictionary <string, string> packetContents)
        {
            foreach (Command cmd in SandboxMain.CmdHandler.GetCommands())
            {
                SandboxMain.ToHud(" -- " + cmd.Key());
            }

            return(PreparedResult.Stop);
        }
Example #2
0
        protected override PreparedResult Prepare(Dictionary <string, object> conVars,
                                                  ref Dictionary <string, string> packetContents)
        {
            if (!UnityUtils.RayTrace(out RaycastHit hit))
            {
                return(PreparedResult.Stop);
            }

            string id = conVars["Id"].ToString();

            string[] nearbyNames = DataUtils.SelectEnum(id, out T idx, 3, false, GetDefault());

            if (AreEqual(idx, GetDefault()))
            {
                SandboxMain.ToHud("Unable to find  ID: " + id);

                // ReSharper disable once InvertIf
                if (nearbyNames.Length > 0)
                {
                    SandboxMain.ToHud("Did you mean:");
                    foreach (string t in nearbyNames)
                    {
                        SandboxMain.ToHud("    " + t);
                    }
                }

                return(PreparedResult.Stop);
            }

            string amtStr = conVars["Amount"].ToString();

            if (!int.TryParse(amtStr, out int amt))
            {
                amt = 1;
            }

            packetContents.Add("Id", ToInteger(idx).ToString());
            packetContents.Add("Amount", amt.ToString());
            DataUtils.WriteVector3ToDictionary("Location", hit.point, ref packetContents);

            return(PreparedResult.Replicate);
        }