Beispiel #1
0
        /// <summary>
        /// Creates a new option object.
        /// </summary>
        /// <param name="mc">The <see cref="ModCompiler" /> that is compiling the <see cref="Option" />.</param>
        /// <param name="json">The JSON useto create the objects. (ModOptions.json)</param>
        /// <returns>A tuple containing the option, and a collection of errors.</returns>
        public static Tuple<Option, IEnumerable<CompilerError>> NewOption(ModCompiler mc, JsonFile json)
        {
            Dictionary<string, Func<Option>> Options = new Dictionary<string, Func<Option>>();

            // only lower-case
            Options.Add("string",     () => new StringOption    (mc));
            Options.Add("integer",    () => new IntegerOption   (mc));
            Options.Add("float",      () => new FloatOption     (mc));
            Options.Add("keybinding", () => new KeybindingOption(mc));
            Options.Add("list",       () => new ListOption      (mc));
            Options.Add("boolean",    () => new BoolOption      (mc));
            Options.Add("dynamic",    () => new DynamicOption   (mc));

            Option ret = null;
            List<CompilerError> errors = new List<CompilerError>();

            if (!json.Json.Has("type"))
                errors.Add(new CompilerError(mc.building)
                {
                    Cause = new KeyNotFoundException(),
                    FilePath = json.Path,
                    IsWarning = false,
                    Message = "Key 'type' not found."
                });
            else
            {
                string type = ((string)json.Json["type"]).ToLowerInvariant();

                if (!Options.ContainsKey(type))
                    errors.Add(new CompilerError(mc.building)
                    {
                        Cause = new KeyNotFoundException(),
                        FilePath = json.Path,
                        IsWarning = false,
                        Message = "Did nout found the '" + type + "' option."
                    });
                else
                {
                    Option o = Options[type]();
                    o.type = type;

                    errors.AddRange(o.CreateAndValidate(json));
                }
            }

            return new Tuple<Option, IEnumerable<CompilerError>>(ret, errors);
        }
Beispiel #2
0
        static ModCompiler CreateMod()
        {
            ModCompiler mc = new ModCompiler();

            ModData md = new ModData(mc);

            md.Assembly = Assembly.GetExecutingAssembly();
            md.Info = new ModInfo(mc);
            md.Info.author = "PoroCYon";
            md.Info.displayName = "Test Mod";
            md.Info.includePDB = true;
            md.Info.internalName = "TestMod";
            md.Info.info = "Mod meant to test the MCT Tools";
            md.OriginName = "TestMod";
            md.OriginPath = Directory.GetCurrentDirectory() + "\\TestMod";

            md.items.Add(new Item(mc)
            {
                internalName = "TestMod:TestItem",
                displayName = "Test Item",
                maxStack = 999,
                rare = 2,
                recipes = new List<Recipe>()
                {
                    new Recipe(mc)
                    {
                        creates = 3,
                        items = new Dictionary<string, int>()
                        {
                            { "g:Wood"          , 5 },
                            { "TestMod:TestItem", 1 }
                        },
                        tiles = new List<string>()
                        {
                            "Work Bench"
                        }
                    }
                },
                value = 50
            });

            return mc;
        }
Beispiel #3
0
        public Writer(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #4
0
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="Fish" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public Fish(ModCompiler mc)
            : base(mc)
        {

        }
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="EntityValidator" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        protected EntityValidator(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #6
0
        /// <summary>
        /// Creates a new instance of the <see cref="Choice" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public Choice(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #7
0
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="Option" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        protected Option(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #8
0
        public Extractor(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #9
0
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="Projectile" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public Projectile(ModCompiler mc)
            : base(mc)
        {

        }
        public CSharpCompiler(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #11
0
        public Validator(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #12
0
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="IntegerOption" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public IntegerOption(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #13
0
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="Recipe" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public Recipe(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #14
0
        /// <summary>
        /// Creates a new instance of the <see cref="ModOptions" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public ModOptions(ModCompiler mc)
            : base(mc)
        {

        }
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="ItemCraftGroup" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public ItemCraftGroup(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #16
0
        /// <summary>
        /// Creates a new instance of the <see cref="ModInfo" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public ModInfo(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #17
0
#pragma warning restore 1591
        #endregion

        /// <summary>
        /// Creates a new instance of the <see cref="NPC" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public NPC(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #18
0
        readonly static IEnumerable<CompilerError> errors = new List<CompilerError>(); // only alloc once

        /// <summary>
        /// Creates a new instance of the <see cref="DynamicOption" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public DynamicOption(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #19
0
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="StringOption" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public StringOption(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #20
0
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="ListOption" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public ListOption(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #21
0
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="Buff" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public Buff(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #22
0
 /// <summary>
 /// Creates a new instance of the <see cref="CompilerPhase" /> class.
 /// </summary>
 /// <param name="mc"><see cref="Compiler" /></param>
 protected CompilerPhase(ModCompiler mc)
 {
     compiler_wr = new WeakReference<ModCompiler>(mc);
 }
Beispiel #23
0
 /// <summary>
 /// Creates a new instance of the <see cref="ModData" /> class.
 /// </summary>
 /// <param name="mc">The <see cref="ModCompiler" /> that is compiling the mod.</param>
 public ModData(ModCompiler mc)
 {
     Info = new ModInfo(mc);
     Options = new ModOptions(mc);
     CraftGroups = new CraftGroups(mc);
 }
Beispiel #24
0
        public Checker(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #25
0
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="Drop" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public Drop(ModCompiler mc)
            : base(mc)
        {

        }
        public JScriptCompiler(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #27
0
#pragma warning restore 1591
        #endregion

        /// <summary>
        /// Creates a new instance of the <see cref="Item" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public Item(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #28
0
#pragma warning restore 1591

        /// <summary>
        /// Creates a new instance of the <see cref="Prefix" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public Prefix(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #29
0
        public Builder(ModCompiler mc)
            : base(mc)
        {

        }
Beispiel #30
0
        /// <summary>
        /// Creates a new instance of the <see cref="BoolOption" /> class.
        /// </summary>
        /// <param name="mc"><see cref="CompilerPhase.Compiler" /></param>
        public BoolOption(ModCompiler mc)
            : base(mc)
        {

        }