예제 #1
0
        public static MovementEvent read(BinaryReader binaryReader)
        {
            MovementEvent newObj = new MovementEvent();

            newObj.object_id                = binaryReader.ReadUInt32();
            newObj.instance_timestamp       = binaryReader.ReadUInt16();
            newObj.server_control_timestamp = binaryReader.ReadUInt16();
            newObj.movement_timestamp       = binaryReader.ReadUInt16();
            newObj.autonomous               = binaryReader.ReadByte();

            Util.readToAlign(binaryReader);

            newObj.movementType__guessedname = (MovementTypes.Type)binaryReader.ReadUInt16();
            newObj.style = (MotionStyle)command_ids[binaryReader.ReadUInt16()];

            switch (newObj.movementType__guessedname)
            {
            // TODO: This now needs to mimic the rest of MovementManager::unpack_movement here
            case MovementTypes.Type.Invalid: {
                newObj.motionState__guessedname = InterpretedMotionState.read(binaryReader);
                if (((ushort)newObj.movementType__guessedname & 0x100) != 0)           // TODO: Double check that this is the correct mask here
                {
                    newObj.stickToObject = binaryReader.ReadUInt32();
                }
                break;
            }

            case MovementTypes.Type.MoveToObject: {
                newObj.moveToObject = binaryReader.ReadUInt32();
                newObj.moveToPos    = Position.readOrigin(binaryReader);
                newObj.movementParams__guessedname = MovementParameters.read(newObj.movementType__guessedname, binaryReader);
                newObj.my_run_rate = binaryReader.ReadSingle();
                break;
            }

            case MovementTypes.Type.MoveToPosition: {
                newObj.moveToPos = Position.readOrigin(binaryReader);
                newObj.movementParams__guessedname = MovementParameters.read(newObj.movementType__guessedname, binaryReader);
                newObj.my_run_rate = binaryReader.ReadSingle();
                break;
            }

            case MovementTypes.Type.TurnToObject: {
                newObj.turnToObject  = binaryReader.ReadUInt32();
                newObj.turnToHeading = binaryReader.ReadSingle();
                newObj.movementParams__guessedname = MovementParameters.read(newObj.movementType__guessedname, binaryReader);
                break;
            }

            case MovementTypes.Type.TurnToHeading: {
                newObj.movementParams__guessedname = MovementParameters.read(newObj.movementType__guessedname, binaryReader);
                break;
            }

            default: {
                break;
            }
            }

            return(newObj);
        }
예제 #2
0
        public static MovementDataUnpack read(BinaryReader binaryReader)
        {
            MovementDataUnpack newObj    = new MovementDataUnpack();
            ushort             pack_word = binaryReader.ReadUInt16();

            newObj.movement_options = (ushort)(pack_word & 0xFF00);
            newObj.movement_type    = (uint)((ushort)(pack_word & 0x00FF));
            newObj.style            = (uint)command_ids[binaryReader.ReadUInt16()];
            switch (newObj.movement_type)
            {
            case 0:
            {
                newObj.interpretedMotionState = InterpretedMotionState.read(binaryReader);
                if ((newObj.movement_options & 0x100) != 0)
                {
                    newObj.stickToObject = binaryReader.ReadUInt32();
                }
                if ((newObj.movement_options & 0x200) != 0)
                {
                    newObj.standing_longjump = true;
                }
                break;
            }

            case 6:
            {
                newObj.moveToObject    = binaryReader.ReadUInt32();
                newObj.moveToPos       = Position.readOrigin(binaryReader);
                newObj.movement_params = MovementParameters.read(newObj.movement_type, binaryReader);
                newObj.my_run_rate     = binaryReader.ReadSingle();
                break;
            }

            case 7:
            {
                newObj.moveToPos       = Position.readOrigin(binaryReader);
                newObj.movement_params = MovementParameters.read(newObj.movement_type, binaryReader);
                newObj.my_run_rate     = binaryReader.ReadSingle();
                break;
            }

            case 8:
            {
                newObj.turnToObject    = binaryReader.ReadUInt32();
                newObj.desiredHeading  = binaryReader.ReadSingle();
                newObj.movement_params = MovementParameters.read(newObj.movement_type, binaryReader);
                break;
            }

            case 9:
            {
                newObj.movement_params = MovementParameters.read(newObj.movement_type, binaryReader);
                break;
            }

            default:
            {
                break;
            }
            }

            return(newObj);
        }