当前位置: 首页>>代码示例>>C#>>正文


C# AssetLoader.Expect方法代码示例

本文整理汇总了C#中Glare.Assets.AssetLoader.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# AssetLoader.Expect方法的具体用法?C# AssetLoader.Expect怎么用?C# AssetLoader.Expect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Glare.Assets.AssetLoader的用法示例。


在下文中一共展示了AssetLoader.Expect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Effect

        internal Effect(AssetLoader loader)
            : base(loader)
        {
            var reader = loader.Reader;

            loader.ExpectMagic(Magic);
            loader.Expect(0x10000);
            loader.Expect(ContentStart);

            int offsetOffset = reader.ReadInt32();
            int pointerCount = reader.ReadInt32();
            HashSet<int> pointers = new HashSet<int>();
            int functionCount = reader.ReadInt32();
            HashSet<int> functions = new HashSet<int>();

            loader.Position = offsetOffset;
            for (int index = 0; index < pointerCount; index++)
                pointers.Add(reader.ReadInt32());
            for (int index = 0; index < functionCount; index++)
                functions.Add(reader.ReadInt32());

            loader.Position = ContentStart;
            int tokenCount = (offsetOffset - ContentStart) / 4;
            Tokens = new Codex<EffectToken>(tokenCount);
            for (int index = 0; index < tokenCount; index++)
                Tokens.Add(new EffectToken(reader, pointers, functions));
            for (int index = 0; index < tokenCount; index++)
                Tokens[index].Link(Tokens);

            Instructions = new Codex<EffectInstruction>();
            for (int index = 0; index < tokenCount; )
                Instructions.Add(new EffectInstruction(Tokens, ref index));
        }
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:33,代码来源:Effect.cs

示例2: ParameterDefinition

        internal ParameterDefinition(AssetLoader loader)
            : base(loader)
        {
            var reader = loader.Reader;

            loader.Expect(loader.CheckedShortLength);
            loader.Expect((ushort)0x30); // Offset of rows
            Unknowns.ReadInt16s(reader, 1); // 1-4
            int rowCount = reader.ReadUInt16();
            loader.Expect((ushort)0xB0); // Size in bytes of a row
            Name = reader.ReadStringz(32, EncodingShiftJis);
            loader.Expect((ushort)0);
            loader.Expect((ushort)0x68);

            for (int index = 0; index < rowCount; index++)
                new ParameterDefinitionRow(this, index, loader);
        }
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:17,代码来源:ParameterDefinition.cs

示例3: Object

            internal Object(Script script, ScriptBlock block, AssetLoader loader)
                : base(script, block)
            {
                var reader = loader.Reader;

                loader.Expect((ushort)0x1234);
                LocalVariableOffset = reader.ReadUInt16();
                int functionSelectorListOffset = reader.ReadUInt16();

                int variableSelectorCount = reader.ReadUInt16();
                Codex<VariableSelector> variableSelectors = new Codex<VariableSelector>(variableSelectorCount);
                Variables = variableSelectors;
                for (int index = 0; index < variableSelectorCount; index++)
                    variableSelectors.Add(new VariableSelector(this, loader));

                int functionSelectorCount = reader.ReadUInt16();
                Codex<FunctionSelector> functionSelectors = new Codex<FunctionSelector>(functionSelectorCount);
                Functions = functionSelectors;
                for (int index = 0; index < functionSelectorCount; index++)
                    functionSelectors.Add(new FunctionSelector(this, loader));

                loader.Expect((ushort)0);
                for (int index = 0; index < functionSelectorCount; index++)
                    functionSelectors[index].ReadCodeOffset(loader);

                loader.ExpectPosition(block.EndOffset);
            }
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:27,代码来源:Script.cs

示例4: Rom

        internal Rom(AssetLoader loader)
            : base(loader)
        {
            BinaryReader reader = Reader = loader.Reader;

            Codex<RomFile> files = new Codex<RomFile>();
            Codex<RomFolder> folders = new Codex<RomFolder>();
            Files = files;
            Folders = folders;

            GameTitle = Reader.ReadStringz(12, Encoding.ASCII);
            GameCode = Reader.ReadStringz(4, Encoding.ASCII);

            // Offset 0x10
            MakerCode = Reader.ReadStringz(2, Encoding.ASCII);
            UnitCode = reader.ReadByte();
            DeviceCode = reader.ReadByte();
            CardSizeBase = reader.ReadByte();
            loader.ExpectZeroes(1, 7);
            Unknowns.ReadInt32s(reader, 1); // Usually 0, Alice in Wonderland: 3

            // Offset 0x20
            PageSize = reader.ReadInt32(); // Usually (always?) 0x4000
            Unknowns.ReadInt16s(reader, 2); // The Dark Spire: 0x800; Trauma Center: 0xF780 (-2176)
            loader.Expect(0x2000000);
            Unknowns.ReadInt32s(reader, 1); // The Dark Spire: 0x9BEF8; Trauma Center: 0x1DC518

            // Offset 0x30
            Unknowns.ReadInt32s(reader, 1); // Entry points? The Dark Spire: 0x152200; Trauma Center: 0x1E0600
            loader.Expect(0x2380000);
            loader.Expect(0x2380000);
            Unknowns.ReadInt16s(reader, 1); // The Dark Spire: 0x6F28; Trauma Center: 0x6F24
            loader.Expect((short)0x2);

            // Offset 0x40
            int fileNameTableOffset = reader.ReadInt32();
            int fileNameTableSize = reader.ReadInt32();
            int fileSizeTableOffset = reader.ReadInt32();
            int fileSizeTableSize = reader.ReadInt32();

            // Offset 0x50
            Unknowns.ReadInt32s(reader, 2, "Offset and size"); // Used in The Dark Spire, zeroes in Trauma Center.
            loader.ExpectZeroes(4, 2);

            // Offset 0x60
            Unknowns.ReadInt32s(reader, 2);
            int iconAndTitleOffset = reader.ReadInt32();
            Unknowns.ReadInt32s(reader, 1);

            // Offset 0x70
            Unknowns.ReadInt32s(reader, 2);
            loader.ExpectZeroes(4, 2);

            // Offset 0x80
            DataLength = reader.ReadInt32();
            loader.Expect(PageSize);
            Unknowns.ReadInt32s(reader, 2); // The Dark Spire: 0x4B68; 0 in Trauma Center.

            ReadIconAndTitle(iconAndTitleOffset);

            if (fileNameTableOffset > 0) {
                int folderNamesOffset = reader.ReadInt32At(fileNameTableOffset);
                reader.BaseStream.Position = fileNameTableOffset;
                int folderCount = folderNamesOffset / 8;
                for (int index = 0; index < folderCount; index++)
                    folders.Add(new RomFolder(this, index, reader));
                byte[] folderNames = reader.ReadBytes(fileNameTableSize - folderNamesOffset);

                reader.BaseStream.Position = fileSizeTableOffset;
                int fileCount = fileSizeTableSize / 8;
                for (int index = 0; index < fileCount; index++)
                    files.Add(new RomFile(this, index, reader));

                folders[0].Sort(this, "Root", folderNamesOffset, folderNames);

                FolderAsset orphanedFolders = null, orphanedFiles = null;

                foreach (RomFolder folder in folders) {
                    if (folder.Used)
                        continue;
                    if (orphanedFolders == null)
                        orphanedFolders = new FolderAsset(this, "Orphaned folder[s]");
                    folder.Sort(this, folder.Name, folderNamesOffset, folderNames);
                }

                foreach (RomFile file in files) {
                    if (file.Used)
                        continue;
                    if (orphanedFiles == null)
                        orphanedFiles = new FolderAsset(this, "Orphaned file[s]");
                    file.Sort(orphanedFiles, file.Name);
                }
            }
        }
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:94,代码来源:Rom.cs

示例5: Model

        internal Model(AssetLoader loader)
            : base(loader)
        {
            Asset context = loader.Context;
            string name = loader.Name;
            BinaryReader reader = loader.Reader;

            FolderAsset textureArchive = null;

            FolderAsset bonesFolder = new FolderAsset(this, "Bones");
            FolderAsset materialsFolder = new FolderAsset(this, "Materials");
            FolderAsset meshesFolder = new FolderAsset(this, "Meshes");
            FolderAsset vertexDeclarationsFolder = new FolderAsset(this, "Vertex declarations");

            ArrayBackedList<byte> bufferData = new ArrayBackedList<byte>();

            if (context != null && context.Parent is FolderAsset) {
                // @"/map/m##_##_##_##/m*.flver.dcx" for DS1; textures are in the @"/map/m##/" folder.
                if (name.StartsWith(@"map/m")) {
                    string folderName = name.Substring(4, 3);
                    FolderAsset maps = (FolderAsset)context.Parent.Parent;
                    foreach (FolderAsset child in maps.Children) {
                        if (child.Name == folderName) {
                            textureArchive = child;
                            break;
                        }
                    }
                } else
                    textureArchive = (FolderAsset)context.Parent;
            }

            #if Marking
            MarkingStream markingStream = loader.StartMarking(out reader);
            #endif

            loader.ExpectMagic(Magic);
            char endian = (char)reader.ReadByte();

            switch (endian) {
                case 'L':
                    ByteOrder = ByteOrder.LittleEndian;
                    break;

                case 'B':
                    reader = loader.MakeBigEndian();
                    ByteOrder = ByteOrder.BigEndian;
                    break;

                default:
                    throw new Exception();
            }

            using (reader) {
                // Read header.
                loader.Expect((byte)0);
                Version = (ModelVersion)reader.ReadInt32();
                if (Version != ModelVersion.DarkSouls && Version != ModelVersion.DarkSouls2)
                    loader.AddError(loader.Position - 4, "Unknown model version " + VersionString + "; will try to load it anyway.");
                int dataOffset = reader.ReadInt32();
                int dataSize = reader.ReadInt32();
                if (((dataOffset + dataSize + 31) & ~31) != reader.BaseStream.Length)
                    loader.AddError(loader.Position - 4, "Data size and offset aren't correct.");

                int boneUnknownCount = reader.ReadInt32();
                int materialCount = reader.ReadInt32();
                int boneCount = reader.ReadInt32();

                int meshCount = reader.ReadInt32();
                int meshCount2 = reader.ReadInt32();
                if (meshCount != meshCount2)
                    loader.AddError(loader.Position - 4, "Mesh count 1 and 2 aren't the same.");

                Bounds = new Box3f(reader.ReadVector3f(), reader.ReadVector3f());
                Unknowns.ReadInt32s(reader, 1); // Possible the non-degenerate triangle count. Seems related.
                int triangleCount = reader.ReadInt32();

                loader.Expect(IsDS1 ? 272 : 0x10010100);
                loader.Expect(IsDS1 ? 0 : 0xFFFF);

                int partCount = reader.ReadInt32();
                int vertexDeclarationCount = reader.ReadInt32();
                int materialParameterCount = reader.ReadInt32();
                loader.Expect(IsDS1 ? 0 : 0x1000000);
                loader.ExpectZeroes(4, 8);

                // Calculate offsets.
                long boneUnknownsOffset = HeaderSize;
                long materialsOffset = boneUnknownsOffset + boneUnknownCount * ModelBoneUnknown.DataSize;
                long bonesOffset = materialsOffset + materialCount * ModelMaterial.DataSize;
                long meshesOffset = bonesOffset + boneCount * ModelBone.DataSize;
                long detailLevelsOffset = meshesOffset + meshCount * ModelMesh.DataSize;
                long meshVerticesOffset = detailLevelsOffset + partCount * ModelDetailLevel.DataSize;
                long vertexDeclarationsOffset = meshVerticesOffset + meshCount * ModelMesh.DataSizeVertexHeader;
                long materialParametersOffset = vertexDeclarationsOffset + vertexDeclarationCount * ModelVertexDeclaration.DataSize;
                long postHeaderOffset = materialParametersOffset + materialParameterCount * ModelMaterialParameter.DataSize;

                // BoneUnknowns
                ExpectedOffset(loader, boneUnknownsOffset, typeof(ModelBoneUnknown).Name);
                for (int index = 0; index < boneUnknownCount; index++)
                    boneUnknowns.Add(new ModelBoneUnknown(bonesFolder, index, loader));
//.........这里部分代码省略.........
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:101,代码来源:Model.cs


注:本文中的Glare.Assets.AssetLoader.Expect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。