Пример #1
0
        static void AttachPhysObjectFullPath(MyEntity physObject, string fullPath)
        {
            MyMwcLog.WriteLine("MyTrailedLoad.AttachPhysObject - START", LoggingOptions.TRAILERS);
            MyMwcLog.IncreaseIndent(LoggingOptions.TRAILERS);

            Dictionary <int, MyPhysObjectTrackedTickData> ticks = new Dictionary <int, MyPhysObjectTrackedTickData>(MyTrailerConstants.MAX_TRACKED_TICKS);

            MyMwcLog.WriteLine("File: " + fullPath, LoggingOptions.TRAILERS);

            //  Open file, BinaryReader must use ASCII encoding, otherwise PeekChar will have problems when trying to convert some values to chars
            using (FileStream fs = File.OpenRead(fullPath))
            {
                using (BinaryReader br = new BinaryReader(fs, Encoding.ASCII))
                {
                    int tickIndex = 0;
                    while (br.PeekChar() != -1)
                    {
                        MyPhysObjectTrackedTickData tickData = new MyPhysObjectTrackedTickData();

                        MyUtils.BinaryRead(br, ref tickData.Position);
                        MyUtils.BinaryRead(br, ref tickData.Orientation);
                        tickData.ReflectorLevel = br.ReadSingle();
                        tickData.EngineLevel    = br.ReadSingle();

                        int gunShot = br.ReadInt32();
                        if (gunShot == -1)
                        {
                            tickData.GunShot = null;
                        }
                        else
                        {
                            tickData.GunShot = (MyTrailerGunsShotTypeEnum)gunShot;
                        }

                        ticks.Add(tickIndex, tickData);
                        tickIndex++;
                    }

                    MyMwcLog.WriteLine("Ticks: " + ticks.Count, LoggingOptions.TRAILERS);
                    MyMwcLog.WriteLine("Milliseconds: " + TicksToMilliseconds(ticks.Count), LoggingOptions.TRAILERS);
                }
            }

            m_attachedPhysObjects.Add(physObject, ticks);

            MyMwcLog.DecreaseIndent(LoggingOptions.TRAILERS);
            MyMwcLog.WriteLine("MyTrailedLoad.AttachPhysObject - END", LoggingOptions.TRAILERS);
        }