示例#1
0
 public ActionEntry(sActionFlags flags, int i, int id)
 {
     _flags1 = flags._flags1;
     _flags2 = flags._flags2;
     _flags3 = flags._flags3;
     _flags4 = flags._flags4;
     _index  = i;
     _id     = id;
 }
        private void ParseScripts(bint *hdr, int[] sizes)
        {
            Script             s = null;
            int                size, count;
            bint *             actionOffset;
            List <List <int> > list;

            MovesetNode node = _root as MovesetNode;

            sSubActionFlags *sflags = (sSubActionFlags *)Address(hdr[0]);
            sActionFlags *   aflags = (sActionFlags *)Address(hdr[6]);

            //Collect offsets first
            size = sizes[9];
            for (int i = 9; i < 11; i++)
            {
                if (hdr[i] < 0)
                {
                    continue;
                }
                actionOffset = (bint *)Address(hdr[i]);
                for (int x = 0; x < size / 4; x++)
                {
                    node._scriptOffsets[0][i - 9].Add(actionOffset[x]);
                }
            }
            size = sizes[12];
            for (int i = 12; i < 16; i++)
            {
                if (hdr[i] < 0)
                {
                    continue;
                }
                actionOffset = (bint *)Address(hdr[i]);
                for (int x = 0; x < size / 4; x++)
                {
                    node._scriptOffsets[1][i - 12].Add(actionOffset[x]);
                }
            }

            //Now parse scripts using collected offsets
            //The offsets are stored in the root in order to find scripts later

            //Actions first
            ActionEntry ag;

            list          = node._scriptOffsets[0];
            count         = list[0].Count;
            node._actions = new BindingList <ActionEntry>();
            for (int i = 0; i < count; i++)
            {
                sActionFlags flag = aflags[i];
                node.Actions.Add(ag = new ActionEntry(flag, i, i + 274));
                for (int x = 0; x < 2; x++)
                {
                    if (i < list[x].Count && list[x][i] > 0)
                    {
                        s = Parse <Script>(list[x][i]);
                    }
                    else
                    {
                        s = new Script();
                    }
                    ag.SetWithType(x, s);
                }
            }

            //Now subactions
            SubActionEntry sg;

            list        = node._scriptOffsets[1];
            count       = list[0].Count;
            _subActions = new BindingList <SubActionEntry>();
            for (int i = 0; i < count; i++)
            {
                sSubActionFlags flag = sflags[i];
                _subActions.Add(sg = new SubActionEntry(flag, flag._stringOffset > 0 ? new String((sbyte *)Address(flag._stringOffset)) : "<null>", i));
                for (int x = 0; x < 4; x++)
                {
                    if (i < list[x].Count && list[x][i] > 0)
                    {
                        s = Parse <Script>(list[x][i]);
                    }
                    else
                    {
                        s = new Script();
                    }
                    sg.SetWithType(x, s);
                }
            }
        }