Esempio n. 1
0
        /// <summary>
        /// Dumps all configuration options to a text file in Markdown format
        /// </summary>
        public static void DumpDescriptions()
        {
            var sb = new StringBuilder();
            var defaults = new ServerSideConfig();

            foreach (var field in defaults.GetType().GetFields().OrderBy(f => f.Name))
            {
                if (field.IsStatic)
                    continue;

                var name = field.Name;
                var type = field.FieldType.Name;

                var descattr =
                    field.GetCustomAttributes(false).FirstOrDefault(o => o is DescriptionAttribute) as DescriptionAttribute;
                var desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : "None";

                var def = field.GetValue(defaults);

                sb.AppendLine("{0}  ".SFormat(name));
                sb.AppendLine("Type: {0}  ".SFormat(type));
                sb.AppendLine("Description: {0}  ".SFormat(desc));
                sb.AppendLine("Default: \"{0}\"  ".SFormat(def));
                sb.AppendLine();
            }

            File.WriteAllText("ServerSideConfigDescriptions.txt", sb.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Dumps all configuration options to a text file in Markdown format
        /// </summary>
        public static void DumpDescriptions()
        {
            var sb       = new StringBuilder();
            var defaults = new ServerSideConfig();

            foreach (var field in defaults.GetType().GetFields().OrderBy(f => f.Name))
            {
                if (field.IsStatic)
                {
                    continue;
                }

                var nameattr =
                    field.GetCustomAttributes(false).FirstOrDefault(o => o is JsonPropertyAttribute) as JsonPropertyAttribute;
                var name = nameattr != null && !string.IsNullOrWhiteSpace(nameattr.PropertyName) ? nameattr.PropertyName : field.Name;
                var type = field.FieldType.Name;

                var descattr =
                    field.GetCustomAttributes(false).FirstOrDefault(o => o is DescriptionAttribute) as DescriptionAttribute;
                var desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : "无";

                var def = field.GetValue(defaults);

                sb.AppendLine("{0}  ".SFormat(name));
                sb.AppendLine("字段种类: {0}  ".SFormat(type));
                sb.AppendLine("说明: {0}  ".SFormat(desc));
                sb.AppendLine("默认值: \"{0}\"  ".SFormat(def));
                sb.AppendLine();
            }

            File.WriteAllText("云存档配置说明.txt", sb.ToString());
        }
Esempio n. 3
0
 /// <summary>TShock - The constructor for the TShock plugin.</summary>
 /// <param name="game">game - The Terraria main game.</param>
 public TShock(Main game)
     : base(game)
 {
     Config = new ConfigFile();
     ServerSideCharacterConfig = new ServerSideConfig();
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem(-15, 1, 0));
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem(-13, 1, 0));
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem(-16, 1, 0));
     Order = 0;
     instance = this;
 }
Esempio n. 4
0
 public TShock(Main game)
     : base(game)
 {
     Config = new ConfigFile();
     ServerSideCharacterConfig = new ServerSideConfig();
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem { netID = -15, prefix = 0, stack = 1 });
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem { netID = -13, prefix = 0, stack = 1 });
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem { netID = -16, prefix = 0, stack = 1 });
     Order = 0;
     instance = this;
 }