Exemple #1
0
        static DC6 Load(Stream stream, BinaryReader reader, byte[] bytes, int textureSize = -1, bool loadAllDirections = false)
        {
            var dc6 = new DC6();

            reader.ReadInt32();
            dc6.directionCount     = reader.ReadInt32();
            dc6.framesPerDirection = reader.ReadInt32();
            dc6.directions         = new Direction[dc6.directionCount];
            dc6.offsets            = new int[dc6.directionCount * dc6.framesPerDirection];
            dc6.bytes       = bytes;
            dc6.textureSize = textureSize;
            for (int i = 0; i < dc6.offsets.Length; ++i)
            {
                dc6.offsets[i] = reader.ReadInt32();
            }

            if (loadAllDirections)
            {
                for (int i = 0; i < dc6.directionCount; ++i)
                {
                    dc6.LoadDirection(stream, reader, i);
                }
            }

            return(dc6);
        }
Exemple #2
0
        public static DC6 Load(string filename, bool mpq = true, int textureSize = -1, bool loadAllDirections = false)
        {
            UnityEngine.Profiling.Profiler.BeginSample("DC6.DecodeDirection");
            try
            {
                Palette.LoadPalette(0);
                var bytes = mpq ? Mpq.ReadAllBytes(filename) : File.ReadAllBytes(filename);

                using (var stream = new MemoryStream(bytes))
                    using (var reader = new BinaryReader(stream))
                    {
                        int version1 = reader.ReadInt32();
                        var version2 = reader.ReadInt32();
                        var version3 = reader.ReadInt32();
                        if (version1 != 6 || version2 != 1 || version3 != 0)
                        {
                            Debug.LogWarning("Unknown dc6 version " + version1 + " " + version2 + " " + version3);
                            return(null);
                        }

                        DC6 dc6 = Load(stream, reader, bytes, textureSize, loadAllDirections);
                        return(dc6);
                    }
            }
            finally
            {
                UnityEngine.Profiling.Profiler.EndSample();
            }
        }