GetTurnTable() public method

public GetTurnTable ( Compact cpt, ushort dir ) : UShortAccess
cpt Compact
dir ushort
return UShortAccess
Example #1
0
        private void MainAnim()
        {
            // Extension of arAnim()
            _compact.Core.waitingFor = 0; // clear possible zero-zero skip

            var sequence = _skyCompact.GetGrafixPtr(_compact);

            if (sequence[0] == 0)
            {
                // ok, move to new anim segment
                sequence.Offset             += 4;
                _compact.Core.grafixProgPos += 2;
                if (sequence[0] == 0)
                { // end of route?
                  // ok, sequence has finished

                    // will start afresh if new sequence continues in last direction
                    _compact.Core.arAnimIndex = 0;

                    _compact.Core.downFlag = 0; // pass back ok to script
                    _compact.Core.logic    = L_SCRIPT;
                    LogicScript();
                    return;
                }

                _compact.Core.arAnimIndex = 0; // reset position
            }

            ushort dir;

            while ((dir = _compact.Core.dir) != sequence[1])
            {
                // ok, setup turning
                _compact.Core.dir = sequence[1];

                var tt = _skyCompact.GetTurnTable(_compact, dir);
                if (tt[_compact.Core.dir] != 0)
                {
                    _compact.Core.turnProgId  = tt[_compact.Core.dir];
                    _compact.Core.turnProgPos = 0;
                    _compact.Core.logic       = L_AR_TURNING;
                    ArTurn();
                    return;
                }
            }

            var animId   = _skyCompact.GetCompactElem(_compact, (ushort)(C_ANIM_UP + _compact.Core.megaSet + dir * 4)).Field;
            var animList = new UShortAccess(_skyCompact.FetchCptRaw(animId), 0);

            ushort arAnimIndex = _compact.Core.arAnimIndex;

            if (animList[arAnimIndex / 2] == 0)
            {
                arAnimIndex = 0;
                _compact.Core.arAnimIndex = 0; // reset
            }

            _compact.Core.arAnimIndex += S_LENGTH;

            sequence[0]         -= animList[(S_COUNT + arAnimIndex) / 2]; // reduce the distance to travel
            _compact.Core.frame  = animList[(S_FRAME + arAnimIndex) / 2]; // new graphic frame
            _compact.Core.xcood += animList[(S_AR_X + arAnimIndex) / 2];  // update x coordinate
            _compact.Core.ycood += animList[(S_AR_Y + arAnimIndex) / 2];  // update y coordinate
        }