public static void RebuildArticleActions(MoveDefNode RootNode, MoveDefDataNode node, ref VoidPtr dataAddress, VoidPtr baseAddress, bool subactions, int index)
        {
            if (node.staticArticles != null && node.staticArticles.Children.Count > 0)
                foreach (MoveDefArticleNode d in node.staticArticles.Children)
                    if (!subactions)
                    {
                        if (d.actions != null)
                            foreach (MoveDefActionNode a in d.actions.Children)
                                if (a.Children.Count > 0)
                                    Rebuild(RootNode, a, ref dataAddress, baseAddress);
                    }
                    else
                    {
                        if (d.subActions != null)
                            foreach (MoveDefSubActionGroupNode grp in d.subActions.Children)
                                if (grp.Children[index].Children.Count > 0 || (grp.Children[index] as MoveDefActionNode)._actionRefs.Count > 0 || (grp.Children[index] as MoveDefActionNode)._build)
                                    Rebuild(RootNode, (grp.Children[index] as MoveDefActionNode), ref dataAddress, baseAddress);
                    }

            if (node.entryArticle != null)
                if (!subactions)
                {
                    if (node.entryArticle.actions != null)
                        foreach (MoveDefActionNode a in node.entryArticle.actions.Children)
                            if (a.Children.Count > 0)
                                Rebuild(RootNode, a, ref dataAddress, baseAddress);
                }
                else
                {
                    if (node.entryArticle.subActions != null)
                        foreach (MoveDefSubActionGroupNode grp in node.entryArticle.subActions.Children)
                            if (grp.Children[index].Children.Count > 0 || (grp.Children[index] as MoveDefActionNode)._actionRefs.Count > 0 || (grp.Children[index] as MoveDefActionNode)._build)
                                Rebuild(RootNode, (grp.Children[index] as MoveDefActionNode), ref dataAddress, baseAddress);
                }

            foreach (MoveDefArticleNode d in node._articles.Values)
                if (!subactions)
                {
                    if (d.actions != null)
                    {
                        if (d.pikmin)
                        {
                            foreach (MoveDefActionGroupNode grp in d.actions.Children)
                                foreach (MoveDefActionNode a in grp.Children)
                                    if (a.Children.Count > 0)
                                        Rebuild(RootNode, a, ref dataAddress, baseAddress);
                        }
                        else
                            foreach (MoveDefActionNode a in d.actions.Children)
                                if (a.Children.Count > 0)
                                    Rebuild(RootNode, a, ref dataAddress, baseAddress);
                    }
                }
                else
                {
                    if (d.subActions != null)
                    {
                        MoveDefEntryNode e = d.subActions;
                        int populateCount = 1;
                        bool children = false;
                        if (d.subActions.Children[0] is MoveDefActionListNode)
                        {
                            populateCount = d.subActions.Children.Count;
                            children = true;
                        }
                        for (int i = 0; i < populateCount; i++)
                        {
                            if (children)
                                e = d.subActions.Children[i] as MoveDefEntryNode;

                            foreach (MoveDefSubActionGroupNode grp in e.Children)
                                if (grp.Children[index].Children.Count > 0 || (grp.Children[index] as MoveDefActionNode)._actionRefs.Count > 0 || (grp.Children[index] as MoveDefActionNode)._build)
                                    Rebuild(RootNode, (grp.Children[index] as MoveDefActionNode), ref dataAddress, baseAddress);
                        }
                    }
                }
        }
        public static int Rebuild(MoveDefNode root, MoveDefEntryNode node, ref VoidPtr dataAddress, VoidPtr baseAddress)
        {
            if (node != null)
            {
                if (!(node.External && !(node._extNode is MoveDefReferenceEntryNode)))
                {
                    node.Rebuild(dataAddress, node._calcSize, true);
                    dataAddress += node._calcSize;

                    if (node._lookupOffsets.Count != node._lookupCount && !(node is MoveDefActionNode))
                        Console.WriteLine(node.TreePath + (node._lookupCount - node._lookupOffsets.Count));

                    MoveDefNode._lookupOffsets.AddRange(node._lookupOffsets.ToArray());
                }
                MoveDefEntryNode next = node;
            Top:
                //Check for random params around the file
                if (next.Parent is MoveDefDataNode)
                    if (next.Parent.Children.Count > next.Index + 1)
                        if ((next = next.Parent.Children[next.Index + 1] as MoveDefEntryNode) is MoveDefCharSpecificNode || (next is MoveDefRawDataNode && next.Children.Count > 0 && next.Children[0] is MoveDefSectionParamNode))
                        {
                            if (!(next is MoveDefRawDataNode))
                            {
                                next.Rebuild(dataAddress, next._calcSize, true);
                                MoveDefNode._lookupOffsets.AddRange(next._lookupOffsets.ToArray());
                                dataAddress += next._calcSize;

                                if (next._lookupCount != next._lookupOffsets.Count)
                                    Console.WriteLine();
                            }
                            else
                            {
                                next._entryOffset = dataAddress;
                                foreach (MoveDefSectionParamNode p in next.Children)
                                {
                                    p.Rebuild(dataAddress, p.AttributeBuffer.Length, true);
                                    dataAddress += p.AttributeBuffer.Length;
                                }
                            }
                            goto Top;
                        }
                return node._rebuildOffset;
            }
            else return 0;
        }