public DConstraintsBlock(ShaderDataReader datareader, int blockIndex) : base(datareader)
 {
     this.blockIndex = blockIndex;
     relRule         = datareader.ReadInt32();
     arg0            = datareader.ReadInt32();
     if (arg0 != 3)
     {
         throw new ShaderParserException("unexpected value!");
     }
     // flags at (8)
     flags = ReadByteFlags();
     // range0 at (24)
     range0 = ReadIntRange();
     datareader.BaseStream.Position += 64 - range0.Length * 4;
     // integer at (88)
     arg1 = datareader.ReadInt32();
     // range1 at (92)
     range1 = ReadIntRange();
     datareader.BaseStream.Position += 60 - range1.Length * 4;
     // range1 at (152)
     range2 = ReadIntRange();
     datareader.BaseStream.Position += 64 - range2.Length * 4;
     // there is a provision here for a description, but for the dota2 archive this is always null
     description = datareader.ReadNullTermStringAtPosition();
     datareader.BaseStream.Position += 256;
 }
        public VsPsHeaderBlock(ShaderDataReader datareader) : base(datareader)
        {
            int vcsMagicId = datareader.ReadInt32();

            if (vcsMagicId != ShaderFile.MAGIC)
            {
                throw new UnexpectedMagicException($"Wrong magic ID, VCS expects 0x{ShaderFile.MAGIC:x}",
                                                   vcsMagicId, nameof(vcsMagicId));
            }
            vcsFileVersion = datareader.ReadInt32();
            if (vcsFileVersion != 65 && vcsFileVersion != 64 && vcsFileVersion != 62)
            {
                throw new UnexpectedMagicException($"Unsupported version {vcsFileVersion}, versions 65, 64 and 62 are supported",
                                                   vcsFileVersion, nameof(vcsFileVersion));
            }
            int psrs_arg = 0;

            if (vcsFileVersion >= 64)
            {
                psrs_arg = datareader.ReadInt32();
                if (psrs_arg != 0 && psrs_arg != 1)
                {
                    throw new ShaderParserException($"Unexpected value psrs_arg = {psrs_arg}");
                }
            }
            hasPsrsFile = psrs_arg > 0;
            fileID0     = datareader.ReadBytesAsString(16);
            fileID1     = datareader.ReadBytesAsString(16);
        }
 public MipmapBlock(ShaderDataReader datareader, int blockIndex) : base(datareader)
 {
     this.blockIndex = blockIndex;
     arg0            = datareader.ReadBytes(4);
     arg1            = datareader.ReadInt32();
     arg2            = datareader.ReadInt32();
     arg3            = datareader.ReadInt32();
     arg4            = datareader.ReadInt32();
     arg5            = datareader.ReadInt32();
     name            = datareader.ReadNullTermStringAtPosition();
     datareader.BaseStream.Position += 256;
 }
        public SfConstraintsBlock(ShaderDataReader datareader, int blockIndex) : base(datareader)
        {
            this.blockIndex = blockIndex;
            relRule         = datareader.ReadInt32();
            arg0            = datareader.ReadInt32();
            // flags are at (8)
            flags = ReadByteFlags();
            // range 0 at (24)
            range0 = ReadIntRange();
            datareader.BaseStream.Position += 68 - range0.Length * 4;
            // range 1 at (92)
            range1 = ReadIntRange();

            datareader.BaseStream.Position += 60 - range1.Length * 4;
            // range 2 at (152)
            range2 = ReadIntRange();
            datareader.BaseStream.Position += 64 - range2.Length * 4;
            description = datareader.ReadNullTermStringAtPosition();
            datareader.BaseStream.Position += 256;
        }
 public DBlock(ShaderDataReader datareader, int blockIndex) : base(datareader)
 {
     this.blockIndex = blockIndex;
     name0           = datareader.ReadNullTermStringAtPosition();
     datareader.BaseStream.Position += 64;
     name1 = datareader.ReadNullTermStringAtPosition();
     datareader.BaseStream.Position += 64;
     arg0 = datareader.ReadInt32();
     arg1 = datareader.ReadInt32();
     arg2 = datareader.ReadInt32();
     arg3 = datareader.ReadInt32();
     arg4 = datareader.ReadInt32();
     arg5 = datareader.ReadInt32();
 }
        public ParamBlock(ShaderDataReader datareader, int blockIndex, int vcsVersion) : base(datareader)
        {
            this.blockIndex = blockIndex;
            name0           = datareader.ReadNullTermStringAtPosition();
            datareader.BaseStream.Position += 64;
            name1 = datareader.ReadNullTermStringAtPosition();
            datareader.BaseStream.Position += 64;
            type  = datareader.ReadInt32();
            res0  = datareader.ReadSingle();
            name2 = datareader.ReadNullTermStringAtPosition();
            datareader.BaseStream.Position += 64;
            lead0 = datareader.ReadInt32();
            if (lead0 == 6 || lead0 == 7)
            {
                int dynExpLen = datareader.ReadInt32();
                dynExp = datareader.ReadBytes(dynExpLen);
            }

            // check to see if this reads 'SBMS' (unknown what this is, instance found in v65 hero_pc_40_features.vcs file)
            byte[] checkSBMS = datareader.ReadBytesAtPosition(0, 4);
            if (checkSBMS[0] == 0x53 && checkSBMS[1] == 0x42 && checkSBMS[2] == 0x4D && checkSBMS[3] == 0x53)
            {
                // note - bytes are ignored
                datareader.ReadBytes(4);
                int dynExpLength = datareader.ReadInt32();
                datareader.ReadBytes(dynExpLength);
            }

            arg0 = datareader.ReadInt32();
            arg1 = datareader.ReadInt32();
            arg2 = datareader.ReadInt32();
            arg3 = datareader.ReadInt32();
            arg4 = datareader.ReadInt32();
            if (vcsVersion > 62)
            {
                arg5 = datareader.ReadInt32();
            }

            fileref = datareader.ReadNullTermStringAtPosition();
            datareader.BaseStream.Position += 64;
            for (int i = 0; i < 4; i++)
            {
                ranges0[i] = datareader.ReadInt32();
            }
            for (int i = 0; i < 4; i++)
            {
                ranges1[i] = datareader.ReadInt32();
            }
            for (int i = 0; i < 4; i++)
            {
                ranges2[i] = datareader.ReadInt32();
            }
            for (int i = 0; i < 4; i++)
            {
                ranges3[i] = datareader.ReadSingle();
            }
            for (int i = 0; i < 4; i++)
            {
                ranges4[i] = datareader.ReadSingle();
            }
            for (int i = 0; i < 4; i++)
            {
                ranges5[i] = datareader.ReadSingle();
            }
            for (int i = 0; i < 4; i++)
            {
                ranges6[i] = datareader.ReadInt32();
            }
            for (int i = 0; i < 4; i++)
            {
                ranges7[i] = datareader.ReadInt32();
            }
            command0 = datareader.ReadNullTermStringAtPosition();
            datareader.BaseStream.Position += 32;
            command1 = datareader.ReadNullTermStringAtPosition();
            datareader.BaseStream.Position += 32;

            if (vcsVersion == 65)
            {
                v65Data = datareader.ReadBytes(6);
            }
        }