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


C# ObjectLocation.Handler方法代码示例

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


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

示例1: Load

        public static WLD Load(Stream stream,string name="default.wld")
        {
            WLD wld = new WLD();
            wld.Name = name;
            int size = Marshal.SizeOf(typeof(WLDHeader));
            var barray = new byte[size];
            stream.Read(barray, 0, size);

            var header = Functions.ByteArrayToStructure<WLDHeader>(barray);

            if (header.Magic != 0x54503d02)
            {
                throw new Exception("Invalid file format");
            }

            if (header.Version == 0x00015500)
            {
                wld._format = Format.Old;
            }
            else if (header.Version == 0x1000C800)
            {
                wld._format = Format.New;
            }
            else
            {
                throw new Exception("Unknown file version");
            }

            //var shash = stream.Position;
            barray = new byte[header.StringHashSize];
            stream.Read(barray, 0, (int)header.StringHashSize);
            wld._sHash = WLD.DecodeFileName(barray);
            wld._strings = wld._sHash.Split('\0');

            var fragCount = header.FragmentCount;

            stream.Seek(size + header.StringHashSize, SeekOrigin.Begin);

            int fragSize = Marshal.SizeOf(typeof(BasicWLDFragment));

            for (int i = 0; i < header.FragmentCount; i++)
            {
                barray = new byte[fragSize];
                stream.Read(barray, 0, fragSize);
                var fragment = Functions.ByteArrayToStructure<BasicWLDFragment>(barray);
                int nameRef = (int)fragment.NameRef;

                var position = stream.Position;

                switch (fragment.Id)
                {
                    case 0x03:
                        var bmpname = new BitmapName(i, nameRef);
                        bmpname.Handler(stream);
                        wld._fragments.Add(bmpname);
                        break;
                    case 0x04:
                        var binfo = new BitmapInfo(i, nameRef);
                        binfo.Handler(stream);
                        wld._fragments.Add(binfo);
                        break;
                    case 0x05:
                        var bitmapInfoRef = new BitmapInfoReference(i, nameRef);
                        bitmapInfoRef.Handler(stream);
                        wld._fragments.Add(bitmapInfoRef);
                        break;
                    case 0x09:
                        break;
                    case 0x10:
                        var skelset = new SkeletonTrackSet(i, nameRef);
                        skelset.Handler(stream);
                        skelset.FragmentName = wld.GetStringAtHashIndex(0-skelset.FragmentNameRef);
                        wld._fragments.Add(skelset);
                        break;
                    case 0x11:
                        var skeltrackRef = new SkeletonTrackReference(i, nameRef);
                        skeltrackRef.Handler(stream);
                        wld._fragments.Add(skeltrackRef);
                        break;
                    case 0x12:
                        var skelpiece = new SkeletonPieceTrack(i, nameRef);
                        skelpiece.Handler(stream);
                        wld._fragments.Add(skelpiece);
                        break;
                    case 0x13:
                        var skelpref = new SkeletonPieceTrackReference(i, nameRef);
                        skelpref.Handler(stream);
                        //skelpref.FragmentName = wld.GetStringAtHashIndex(0 - skelpref.FragmentNameRef);
                        wld._fragments.Add(skelpref);
                        break;
                    case 0x14:
                        var modelref = new ModelReference(i, nameRef);
                        modelref.Handler(stream);
                        modelref.FragmentName = wld.GetStringAtHashIndex(0 - modelref.FragmentNameRef);
                        wld._fragments.Add(modelref);
                        modelref.MagicString = wld.GetStringAtHashIndex(modelref.MagicStringRef);
                        break;
                    case 0x15:
                        var objlocation = new ObjectLocation(i, nameRef);
                        objlocation.Handler(stream);
//.........这里部分代码省略.........
开发者ID:Unchated,项目名称:pogee-3d-editor,代码行数:101,代码来源:WLD.cs


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