Example #1
0
        public static void SetWorldFuncTool(WEFuncTool tool)
        {
            WETools.WEFuncTool = tool;
            WETools.WETileTool = null;
            WETools.WETempTool = null;

            // Update Helper Text (if applicable)
            WETools.UpdateHelperText();
        }
Example #2
0
        public static WEFuncTool WETempTool;                    // The highest priority tool; runs because the user is forcing a temporary tool to activate.

        public static void SetWorldTileTool(WETileTool tool, byte index = 0)
        {
            WETools.WETileTool = tool;
            WETools.WEFuncTool = null;
            WETools.WETempTool = null;

            WE_UI.curWESlotGroup = WETools.WETileTool.slotGroup;

            // Assign Index and SubIndex to WorldTileTool (if applicable)
            WETools.WETileTool.SetIndex(index);

            // Update Helper Text (if applicable)
            WETools.UpdateHelperText();
        }
Example #3
0
        public static void SetWorldTileToolBySlotGroup(byte slotGroup, byte index = 0)
        {
            // If the current slot group is being changed:
            if (WETools.WETileTool == null || WETools.WETileTool.slotGroup != slotGroup)
            {
                if (WETileTool.WorldTileToolMap.ContainsKey(slotGroup))
                {
                    WETileTool tool = WETileTool.WorldTileToolMap[slotGroup];
                    if (tool == null)
                    {
                        return;
                    }
                    WETools.SetWorldTileTool(tool, tool.index);
                }
            }

            // If the current slot group is the same, need to change the index only.
            else
            {
                WETileTool tool = WETools.WETileTool;
                WETools.SetWorldTileTool(tool, index);
            }
        }
Example #4
0
        public static WETileTool GetWorldTileToolFromTileData(byte[] tileData)
        {
            Dictionary <byte, WETileTool> toolMap = WETileTool.WorldTileToolMap;

            // Standard
            byte tBase    = tileData[0];
            byte top      = tileData[1];
            byte topLay   = tileData[2];
            byte cover    = tileData[3];
            byte coverLay = tileData[4];
            byte obj      = tileData[5];

            // Scan each entry in WorldTileToolMap.
            for (byte slotGroupNum = 0; slotGroupNum < 8; slotGroupNum++)
            {
                if (!toolMap.ContainsKey(slotGroupNum))
                {
                    continue;
                }
                List <WEPlaceholder[]> placeholders = toolMap[slotGroupNum].placeholders;

                // Loop through each placeholder to see if a tileData match is found.
                byte phLen = (byte)placeholders.Count;

                for (byte i = 0; i < phLen; i++)
                {
                    WEPlaceholder[] pData = placeholders[i];

                    byte phSubLen = (byte)pData.Length;
                    for (byte s = 0; s < phSubLen; s++)
                    {
                        WEPlaceholder ph = pData[s];

                        // If the tile is an Object:
                        if (obj > 0)
                        {
                            if (ph.obj != obj)
                            {
                                continue;
                            }
                        }

                        // If the tile is Terrain Cover:
                        else if (cover > 0)
                        {
                            if (ph.cover != cover)
                            {
                                continue;
                            }
                            if (ph.auto == false)
                            {
                                continue;
                            }
                        }

                        // If the tile is Top Layer:
                        else if (top > 0)
                        {
                            if (ph.top != top)
                            {
                                continue;
                            }
                            if (ph.topLay != topLay)
                            {
                                continue;
                            }
                        }

                        // If the tile is Base Layer only:
                        else if (tBase > 0)
                        {
                            if (ph.tBase != tBase)
                            {
                                continue;
                            }
                            if (!ph.auto)
                            {
                                continue;
                            }
                        }

                        // Any other results caught:
                        else
                        {
                            throw new System.Exception("Unable to locate a potential match in WorldTileTool.");
                        }

                        // If the tileData[0] ID & SubType matches with the WorldTileTool placeholder, we've found a match.
                        WETileTool clonedTool = toolMap[(byte)slotGroupNum];

                        // Set the default values for the tool.
                        clonedTool.index            = i;
                        clonedTool.subIndex         = s;
                        clonedTool.subIndexSaves[i] = s;

                        return(clonedTool);
                    }
                }
            }

            return(null);
        }