示例#1
0
        public static void outputRecipes()
        {
            Pipliz.JSON.JSONNode node = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Array);

            foreach (Recipe recipe in Managers.RecipeManager.recipeList)
            {
                Pipliz.JSON.JSONNode recipenode = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Object);

                recipenode.SetAs("fuelCost", recipe.FuelCost);
                recipenode.SetAs("playerCraftable", recipe.PlayerCraftable);
                recipenode.SetAs("type", recipe.Type);

                List <string> resultingTypes = new List <string>();

                Pipliz.JSON.JSONNode requirementArr = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Array);
                Pipliz.JSON.JSONNode resultArr      = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Array);


                foreach (InventoryItem i in recipe.Requirements)
                {
                    Pipliz.JSON.JSONNode reqItem = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Object);

                    reqItem.SetAs("type", ItemTypes.IndexLookup.GetName(i.Type));
                    reqItem.SetAs("amount", i.Amount);

                    requirementArr.AddToArray(reqItem);
                }

                foreach (InventoryItem i in recipe.Results)
                {
                    Pipliz.JSON.JSONNode resItem = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Object);

                    string typename = ItemTypes.IndexLookup.GetName(i.Type);
                    resItem.SetAs("type", typename);
                    resItem.SetAs("amount", i.Amount);

                    resultArr.AddToArray(resItem);

                    resultingTypes.Add(typename);
                }

                recipenode.SetAs("requirements", requirementArr);
                recipenode.SetAs("results", resultArr);
                recipenode.SetAs("mainresulttype", resultingTypes[0]);

                node.AddToArray(recipenode);
            }

            Pipliz.JSON.JSON.Serialize(Utilities.GetDebugJSONPath("recipes"), node);
        }
示例#2
0
        public Furnace(string name) : base(name)
        {
            this.OnPlaceAudio    = "stonePlace";
            this.OnRemoveAudio   = "stoneDelete";
            this.IsAutoRotatable = true;
            this.IsPlaceable     = true;
            this.SideAll         = "furnaceside";
            this.SideYPlus       = "furnacelittop";
            this.SideXPlus       = "furnacelitfront";
            this.DestructionTime = 800;
            this.NPCLimit        = 0;
            this.RotatableXPlus  = "furnacex+";
            this.RotatableXMinus = "furnacex-";
            this.RotatableZPlus  = "furnacez+";
            this.RotatableZMinus = "furnacez-";

            CustomDataItem[] customDataUp =
            {
                new CustomDataItem("volume",      0.3f),
                new CustomDataItem("intensity",   2.5f),
                new CustomDataItem("range",       8.0f),
                new CustomDataItem("red",       195.0f),
                new CustomDataItem("green",     135.0f),
                new CustomDataItem("blue",       46.0f),
            };
            CustomDataItem[] customDataSide =
            {
                new CustomDataItem("volume",      0.2f),
                new CustomDataItem("intensity",   1.0f),
                new CustomDataItem("range",       8.0f),
                new CustomDataItem("red",       195.0f),
                new CustomDataItem("green",     135.0f),
                new CustomDataItem("blue",       46.0f),
            };
            Pipliz.JSON.JSONNode tempCustomDataNode = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Object);
            CustomDataHelper     cu = new CustomDataHelper(customDataUp);

            tempCustomDataNode.SetAs("up", cu.customDataNode);

            CustomDataHelper cs = new CustomDataHelper("side", customDataSide, cu.customDataNode);

            tempCustomDataNode.SetAs("side", cs.customDataNode);
            this.CustomData = tempCustomDataNode;

            this.Register();
        }
示例#3
0
        // NOT YET IMPLEMENTED
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ColonyPlusPlus.classes.CustomDataHelper"/> class with child nodes
        /// </summary>
        /// <param name="name">The name to give the node</param>
        /// <param name="childnodes">Childnodes.</param>
        /// <param name="node">The referenced parent node</param>
        public CustomDataNode(string name, CustomDataItem[] childnodes, Pipliz.JSON.JSONNode node)
        {
            Pipliz.JSON.JSONNode customChildNode = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Object);
            foreach (CustomDataItem c in childnodes)
            {
                customChildNode = c.getCustomData(customChildNode);
            }

            node.SetAs(name, customChildNode);
            customDataNode = node;
        }
示例#4
0
        public Pipliz.JSON.JSONNode ToJSON()
        {
            Pipliz.JSON.JSONNode node = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Object);

            if (XPAmounts.Count > 0)
            {
                foreach (string jobname in XPAmounts.Keys)
                {
                    node.SetAs(jobname, XPAmounts[jobname]);
                }
            }

            return(node);
        }
        /// <summary>
        /// Gets the custom data.
        /// </summary>
        /// <returns>The custom data.</returns>
        public Pipliz.JSON.JSONNode getCustomData(Pipliz.JSON.JSONNode customDataNode)
        {
            switch (DataType)
            {
            case dataType.typeBool:
                customDataNode.SetAs(this.DataName, this.DataValueB);
                break;

            case dataType.typeFloat:
                customDataNode.SetAs(this.DataName, this.DataValueF);
                break;

            case dataType.typeInt:
                customDataNode.SetAs(this.DataName, this.DataValueI);
                break;

            case dataType.typeString:
                customDataNode.SetAs(this.DataName, this.DataValueS);
                break;
            }

            return(customDataNode);
        }
示例#6
0
        public static void outputTypes()
        {
            Pipliz.JSON.JSONNode node = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Array);

            foreach (string typename in Managers.TypeManager.AddedTypes)
            {
                Pipliz.JSON.JSONNode outputtype = new Pipliz.JSON.JSONNode(Pipliz.JSON.NodeType.Object);

                Pipliz.JSON.JSONNode itemJson = ItemTypes.GetTypesJSON.GetAs <Pipliz.JSON.JSONNode>(typename);

                //Utilities.WriteLog("Outputting JSON: " + typename);

                string icon = "";
                itemJson.TryGetAs <string>("icon", out icon);

                outputtype.SetAs("icon", icon);

                int maxstack = 0;
                itemJson.TryGetAs <int>("maxStackSize", out maxstack);

                outputtype.SetAs("maxstack", maxstack);
                outputtype.SetAs("name", typename);

                bool newtype = false;
                itemJson.TryGetAs <bool>("newtype", out newtype);

                outputtype.SetAs("newtype", newtype);

                bool isPlaceable = false;
                itemJson.TryGetAs <bool>("isPlaceable", out isPlaceable);

                outputtype.SetAs("isplaceable", isPlaceable);

                bool isBaseBlock = false;
                itemJson.TryGetAs <bool>("isBaseBlock", out isBaseBlock);

                outputtype.SetAs("isbaseblock", isBaseBlock);

                node.AddToArray(outputtype);
            }

            Pipliz.JSON.JSON.Serialize(Utilities.GetDebugJSONPath("types"), node);
        }
示例#7
0
 /// <summary>
 /// Constructor for string nodes ("name":"value")
 /// </summary>
 /// <param name="name">Node Name</param>
 /// <param name="value">Node Value (string)</param>
 public CustomDataNode(string name, string value)
 {
     customDataNode.SetAs(name, value);
 }