Example #1
0
        public Zone(string filePath)
        {
            this.sceneInfos = new List <SceneInfo>();

            ReadOnlyBitStream reader = new ReadOnlyBitStream(File.ReadAllBytes(filePath));

            this.Version = reader.ReadUInt32();

            if (this.Version >= 0x24)
            {
                reader.SkipBytes(4);
            }

            this.WorldId = reader.ReadUInt32();

            if (this.Version >= 0x26)
            {
                float spawnPosX = reader.ReadSingle();
                float spawnPosY = reader.ReadSingle();
                float spawnPosZ = reader.ReadSingle();

                this.SpawnPosition = new JVector(spawnPosX, spawnPosY, spawnPosZ);

                float spawnRotX = reader.ReadSingle();
                float spawnRotY = reader.ReadSingle();
                float spawnRotZ = reader.ReadSingle();
                float spawnRotW = reader.ReadSingle();

                this.SpawnRotation = new JQuaternion(spawnRotX, spawnRotY, spawnRotZ, spawnRotW);
            }
            else
            {
                this.SpawnPosition = JVector.Zero;
                this.SpawnRotation = new JQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
            }

            uint sceneCount;

            if (this.Version >= 0x25)
            {
                sceneCount = reader.ReadUInt32();
            }
            else
            {
                sceneCount = reader.ReadByte();
            }

            for (uint i = 0; i < sceneCount; i++)
            {
                byte   sceneFileNameLength = reader.ReadByte();
                string sceneFileName       = String.Empty;

                for (byte b = 0; b < sceneFileNameLength; b++)
                {
                    byte c = reader.ReadByte();

                    sceneFileName += (char)c;
                }

                reader.SkipBytes(1);
                reader.SkipBytes(3);
                reader.SkipBytes(1);
                reader.SkipBytes(3);

                byte   sceneNameLength = reader.ReadByte();
                string sceneName       = String.Empty;

                for (byte b = 0; b < sceneNameLength; b++)
                {
                    byte c = reader.ReadByte();

                    sceneName += (char)c;
                }

                sceneInfos.Add(new SceneInfo(sceneName, sceneFileName));
            }

            reader.SkipBytes(1);

            byte length = reader.ReadByte();

            for (byte b = 0; b < length; b++)
            {
                reader.SkipBytes(1);
            }

            length = reader.ReadByte();

            for (byte b = 0; b < length; b++)
            {
                reader.SkipBytes(1);
            }

            length = reader.ReadByte();

            for (byte b = 0; b < length; b++)
            {
                reader.SkipBytes(1);
            }

            // SCENE TRANSITIONS
        }
        public void FromBitStream(ReadOnlyBitStream packetStream)
        {
            float positionX = packetStream.ReadSingle();
            float positionY = packetStream.ReadSingle();
            float positionZ = packetStream.ReadSingle();

            Position = new JVector(positionX, positionY, positionZ);

            float rotationX = packetStream.ReadSingle();
            float rotationY = packetStream.ReadSingle();
            float rotationZ = packetStream.ReadSingle();
            float rotationW = packetStream.ReadSingle();

            Rotation = new JQuaternion(rotationX, rotationY, rotationZ, rotationW);

            IsSupported = packetStream.ReadBit();
            IsOnRail    = packetStream.ReadBit();

            bool flag = packetStream.ReadBit();

            if (flag)
            {
                float linearVelocityX = packetStream.ReadSingle();
                float linearVelocityY = packetStream.ReadSingle();
                float linearVelocityZ = packetStream.ReadSingle();

                LinearVelocity = new JVector(linearVelocityX, linearVelocityY, linearVelocityZ);
            }

            flag = packetStream.ReadBit();

            if (flag)
            {
                float angularVelocityX = packetStream.ReadSingle();
                float angularVelocityY = packetStream.ReadSingle();
                float angularVelocityZ = packetStream.ReadSingle();

                AngularVelocity = new JVector(angularVelocityX, angularVelocityY, angularVelocityZ);
            }

            flag = packetStream.ReadBit();

            if (flag)
            {
                LocalSpaceObjectId = packetStream.ReadInt64();

                float localPositionX = packetStream.ReadSingle();
                float localPositionY = packetStream.ReadSingle();
                float localPositionZ = packetStream.ReadSingle();

                LocalPosition = new JVector(localPositionX, localPositionY, localPositionZ);

                flag = packetStream.ReadBit();

                if (flag)
                {
                    float localLinearVelocityX = packetStream.ReadSingle();
                    float localLinearVelocityY = packetStream.ReadSingle();
                    float localLinearVelocityZ = packetStream.ReadSingle();

                    LocalLinearVelocity = new JVector(localLinearVelocityX, localLinearVelocityY, localLinearVelocityZ);
                }
            }
        }