Esempio n. 1
0
        protected override void OnPopulate()
        {
            VoidPtr entries  = BaseAddress + EntryOffset;
            VoidPtr defaults = BaseAddress + DefaultsOffset;

            for (int i = 0; i < (EntryOffset == 0 ? 0 : ((DefaultsOffset == 0 ? _offset : DefaultsOffset) - EntryOffset) / 4); i++)
            {
                MoveDefModelVisRefNode offset;
                (offset = new MoveDefModelVisRefNode()
                {
                    _name = "Reference" + (i + 1)
                }).Initialize(this, entries + i * 4, 4);

                if (offset.DataOffset == 0)
                {
                    continue;
                }

                VoidPtr offAddr = BaseAddress + offset.DataOffset;
                for (int c = 0; c < EntryCount; c++)
                {
                    MoveDefBoneSwitchNode Switch;
                    (Switch = new MoveDefBoneSwitchNode()
                    {
                        _name = "BoneSwitch" + c
                    }).Initialize(offset, offAddr + c * 8, 8);
                    int     sCount = Switch.Count;
                    VoidPtr gAddr  = BaseAddress + Switch.DataOffset;
                    for (int s = 0; s < sCount; s++)
                    {
                        MoveDefModelVisGroupNode Group;
                        (Group = new MoveDefModelVisGroupNode()
                        {
                            _name = "BoneGroup" + s
                        }).Initialize(Switch, gAddr + s * 8, 8);
                        int     gCount = Group.Count;
                        VoidPtr bAddr  = BaseAddress + Group.DataOffset;
                        for (int g = 0; g < gCount; g++)
                        {
                            new MoveDefBoneIndexNode().Initialize(Group, bAddr + g * 4, 4);
                        }
                    }
                }
            }
            if (Children.Count > 0)
            {
                for (int i = 0; i < DefaultsCount; i++)
                {
                    FDefModelDisplayDefaults *def = (FDefModelDisplayDefaults *)(defaults + i * 8);
                    for (int x = 0; x < ((DefaultsOffset == 0 ? _offset : DefaultsOffset) - EntryOffset) / 4; x++)
                    {
                        if (Children[x].Children.Count > 0)
                        {
                            (Children[x].Children[def->_switchIndex] as MoveDefBoneSwitchNode).defaultGroup = def->_defaultGroup;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public void Advance(int eventid, ModelEditControl _mainWindow)
        {
            if (eventid >= Children.Count)
            {
                return;
            }

            int list, index, type;
            MoveDefEventNode e = Children[eventid] as MoveDefEventNode;

            if (!_runEvents &&
                e._event != 0x00050000 &&
                e._event != 0x00110100 &&
                e._event != 0x00120000 &&
                e._event != 0x00130000)
            {
                return;
            }

            //Code what to do for each event here.
            switch (e._event)
            {
            case 0x00010100:     //Synchronous Timer
                _waitFrames = (int)((float)e.EventData.parameters[0]._data / 60000f);
                break;

            case 0x00020000:     //No Operation
                break;

            case 0x00020100:     //Asynchronous Timer
                _waitFrames = Math.Max((int)((float)e.EventData.parameters[0]._data / 60000f) - _totalFrames, 0);
                break;

            case 0x00040100:     //Set loop data
                _loopCount      = (int)e.EventData.parameters[0]._data;
                _loopStartIndex = e.Index + 1;
                _runEvents      = false;
                break;

            case 0x00050000:     //Start looping
                _looping      = true;
                _loopEndIndex = e.Index;
                _eventIndex   = _loopStartIndex;
                _runEvents    = true;
                break;

            case 0x01010000:     //Loop Rest
                _waitFrames = 1;
                break;

            case 0x06000D00:     //Offensive Collison
            case 0x062B0D00:     //Thrown Collision
                e.HitboxID   = (int)(e.EventData.parameters[0]._data & 0xFFFF);
                e.HitboxSize = (int)(e.EventData.parameters[5]._data);
                offensiveCollisions.Add(e);
                break;

            case 0x06050100:     //Body Collision
                _mainWindow.hurtBoxType = (int)(e.EventData.parameters[0]._data);
                break;

            case 0x06080200:     //Bone Collision
                int id = (int)(e.EventData.parameters[0]._data);
                if (Root.Model != null && Root.Model._linker.BoneCache.Length > id && id > 0)
                {
                    MDL0BoneNode bone = Root.Model._linker.BoneCache[id] as MDL0BoneNode;
                    switch ((int)(e.EventData.parameters[1]._data))
                    {
                    case 0:
                        bone._nodeColor = Color.Transparent;
                        bone._boneColor = Color.Transparent;
                        break;

                    case 1:
                        bone._nodeColor = bone._boneColor = Color.FromArgb(255, 255, 0);
                        break;

                    default:
                        bone._nodeColor = bone._boneColor = Color.FromArgb(0, 0, 255);
                        break;
                    }
                    _mainWindow.boneCollisions.Add(bone);
                }
                break;

            case 0x06060100:     //Undo Bone Collision
                foreach (MDL0BoneNode bone in _mainWindow.boneCollisions)
                {
                    bone._nodeColor = bone._boneColor = Color.Transparent;
                }
                _mainWindow.boneCollisions = new List <MDL0BoneNode>();
                break;

            case 0x060A0800:     //Catch Collision 1
            case 0x060A0900:     //Catch Collision 2
            case 0x060A0A00:     //Catch Collision 3
                e.HitboxID   = (int)(e.EventData.parameters[0]._data);
                e.HitboxSize = (int)(e.EventData.parameters[2]._data);
                catchCollisions.Add(e);
                break;

            case 0x060D0000:     //Terminate Catch Collisions
                catchCollisions = new List <MoveDefEventNode>();
                break;

            case 0x00060000:     //Loop break?
                _looping    = false;
                _eventIndex = _loopEndIndex + 1;
                _loopTime   = 0;
                break;

            case 0x06150F00:     //Special Offensive Collison
                e.HitboxID   = (int)(e.EventData.parameters[0]._data & 0xFFFF);
                e.HitboxSize = (int)(e.EventData.parameters[5]._data);
                specialOffensiveCollisions.Add(e);
                break;

            case 0x06040000:     //Terminate Collisions
                offensiveCollisions        = new List <MoveDefEventNode>();
                specialOffensiveCollisions = new List <MoveDefEventNode>();
                break;

            case 0x06030100:     //Delete hitbox
                foreach (MoveDefEventNode ev in offensiveCollisions)
                {
                    if (ev.HitboxID == (int)(ev.EventData.parameters[0]._data))
                    {
                        offensiveCollisions.Remove(ev);
                        break;
                    }
                }
                foreach (MoveDefEventNode ev in specialOffensiveCollisions)
                {
                    if (ev.HitboxID == (int)(ev.EventData.parameters[0]._data))
                    {
                        specialOffensiveCollisions.Remove(ev);
                        break;
                    }
                }
                break;

            case 0x04060100:     //Set anim frame - subaction timer unaffected
                _mainWindow.SetFrame((int)((float)e.EventData.parameters[0]._data / 60000f));
                break;

            case 0x00070100:     //Go to subroutine and return
                Root.GetLocation((int)e.EventData.parameters[0]._data, out list, out type, out index);
                subRoutine = Root.GetAction(list, type, index);
                if (subRoutine != null)
                {
                    subRoutineSetAt = _totalFrames;
                    subRoutine.actionReferencedBy = this;
                    subRoutine._subRoutine        = true;
                }
                break;

            case 0x00080000:     //Return
                _return     = true;
                _eventIndex = Children.Count;
                _idling     = true;
                break;

            case 0x00090100:     //Go to and do not return unless called
                Root.GetLocation((int)e.EventData.parameters[0]._data, out list, out type, out index);
                MoveDefActionNode a = Root.GetAction(list, type, index);
                if (a != null)
                {
                    subRoutineSetAt      = _totalFrames;
                    a.actionReferencedBy = this;
                    a._delete            = true;
                    _mainWindow.pnlMoveset.selectedActionNodes.Add(a);
                    //if (_eventIndex == Children.Count)
                    _mainWindow.pnlMoveset.selectedActionNodes.Remove(this);
                }
                break;

            case 0x0B000200:     //Model Changer 1
            case 0x0B010200:     //Model Changer 2
                if (Root.Model._polyList == null)
                {
                    break;
                }
                if (Root.data.mdlVisibility.Children.Count == 0)
                {
                    break;
                }
                MoveDefModelVisRefNode entry = Root.data.mdlVisibility.Children[(e._event >> 16 & 1)] as MoveDefModelVisRefNode;
                if (entry.Children.Count == 0)
                {
                    break;
                }
                MoveDefBoneSwitchNode list1 = entry.Children[(int)e.EventData.parameters[0]._data] as MoveDefBoneSwitchNode;
                if (list1.Children.Count == 0)
                {
                    break;
                }
                if ((int)e.EventData.parameters[1]._data > list1.Children.Count)
                {
                    foreach (MDL0PolygonNode p in Root.Model._polyList)
                    {
                        p._render = false;
                    }
                    break;
                }
                else if ((int)e.EventData.parameters[1]._data < 0)
                {
                    foreach (MoveDefModelVisGroupNode l in list1.Children)
                    {
                        foreach (MoveDefBoneIndexNode b in l.Children)
                        {
                            if (b.BoneNode == null)
                            {
                                continue;
                            }

                            foreach (MDL0PolygonNode p in b.BoneNode._manPolys)
                            {
                                p._render = false;
                            }
                        }
                    }
                    break;
                }
                MoveDefModelVisGroupNode list2 = list1.Children[(int)e.EventData.parameters[1]._data] as MoveDefModelVisGroupNode;
                if (list2.Children.Count == 0)
                {
                    break;
                }
                foreach (MoveDefModelVisGroupNode l in list1.Children)
                {
                    if (l.Index != (int)e.EventData.parameters[1]._data)
                    {
                        foreach (MoveDefBoneIndexNode b in l.Children)
                        {
                            if (b.BoneNode == null)
                            {
                                continue;
                            }

                            foreach (MDL0PolygonNode p in b.BoneNode._manPolys)
                            {
                                p._render = false;
                            }
                        }
                    }
                }
                foreach (MoveDefBoneIndexNode b in list2.Children)
                {
                    if (b.BoneNode == null)
                    {
                        continue;
                    }

                    foreach (MDL0PolygonNode p in b.BoneNode._manPolys)
                    {
                        p._render = true;
                    }
                }
                break;

            case 0x0B020100:
                if (Root.Model._polyList != null)
                {
                    bool val = e.EventData.parameters[0]._data != 0;
                    foreach (MDL0PolygonNode p in Root.Model._polyList)
                    {
                        p._render = val;
                    }
                    if (val)
                    {
                        _mainWindow.pnlMoveset.ResetModelVis();
                    }
                }
                break;

            case 0x00100200:     //Switch
                _cases          = new List <MoveDefEventParameterNode>();
                _caseIndices    = new List <int>();
                _runEvents      = false;
                _loopStartIndex = e.Index;
                break;

            case 0x00110100:     //Case
                if (!_runEvents)
                {
                    if (_cases != null && _caseIndices != null)
                    {
                        _cases.Add(e.Children[0] as MoveDefEventParameterNode);
                        _caseIndices.Add(e.Index);
                    }
                }
                else
                {
                    _eventIndex   = _loopEndIndex + 1;
                    _loopEndIndex = -1;
                }
                break;

            case 0x00120000:     //Default Case
                _defaultCaseIndex = e.Index;
                break;

            case 0x00130000:     //End Switch
                _runEvents    = true;
                _loopEndIndex = e.Index;
                //Apply cases
                int i = 0;
                MoveDefEventParameterNode Switch = Children[_loopStartIndex].Children[1] as MoveDefEventParameterNode;
                foreach (MoveDefEventParameterNode p in _cases)
                {
                    if (Switch.Compare(p, 2))
                    {
                        _eventIndex = _caseIndices[i] + 1;
                        break;
                    }
                    i++;
                }
                if (i == _cases.Count && _defaultCaseIndex != -1)
                {
                    _eventIndex = _defaultCaseIndex + 1;
                }
                _cases            = null;
                _defaultCaseIndex = -1;
                _loopStartIndex   = -1;
                break;

            case 0x00180000:     //Break
                _eventIndex   = _loopEndIndex + 1;
                _loopEndIndex = -1;
                break;
            }
        }