public override void Write(CGameCtnMediaBlockCameraCustom n, GameBoxWriter w, GameBoxReader unknownR)
            {
                w.Write(Version);

                w.Write(n.Keys?.ToArray(), x =>
                {
                    w.Write(x.Time);
                    w.Write((int)x.Unknown.ElementAtOrDefault(0));
                    w.Write(x.AnchorRot);
                    w.Write(x.Anchor);
                    w.Write(x.AnchorVis);
                    w.Write(x.Target);
                    w.Write(x.Position);
                    w.Write(x.PitchYawRoll);
                    w.Write(x.FOV);
                    w.Write((int)x.Unknown.ElementAtOrDefault(1));
                    w.Write((int)x.Unknown.ElementAtOrDefault(2));
                    w.Write((int)x.Unknown.ElementAtOrDefault(3));
                    w.Write(x.ZIndex.GetValueOrDefault());
                    w.Write(x.LeftTangent);
                    w.Write((float[])x.Unknown.ElementAtOrDefault(4));
                    w.Write(x.RightTangent);
                    w.Write((float[])x.Unknown.ElementAtOrDefault(5));
                });
            }
Example #2
0
 public override void Read(CGameCtnMediaBlockFxColors n, GameBoxReader r, GameBoxWriter unknownW)
 {
     n.Keys = r.ReadArray(i => new Key()
     {
         Time          = r.ReadSingle(),
         Intensity     = r.ReadSingle(),
         BlendZ        = r.ReadSingle(),
         Distance      = r.ReadSingle(),
         FarDistance   = r.ReadSingle(),
         Inverse       = r.ReadSingle(),
         Hue           = r.ReadSingle(),
         Saturation    = r.ReadSingle(), // from center
         Brightness    = r.ReadSingle(), // from center
         Contrast      = r.ReadSingle(), // from center
         RGB           = r.ReadVec3(),
         U01           = r.ReadSingle(),
         U02           = r.ReadSingle(),
         U03           = r.ReadSingle(),
         U04           = r.ReadSingle(),
         FarInverse    = r.ReadSingle(),
         FarHue        = r.ReadSingle(),
         FarSaturation = r.ReadSingle(), // from center
         FarBrightness = r.ReadSingle(), // from center
         FarContrast   = r.ReadSingle(), // from center
         FarRGB        = r.ReadVec3(),
         FarU01        = r.ReadSingle(),
         FarU02        = r.ReadSingle(),
         FarU03        = r.ReadSingle(),
         FarU04        = r.ReadSingle()
     });
 }
Example #3
0
            public override void Read(CGameCtnMacroBlockInfo n, GameBoxReader r, GameBoxWriter unknownW)
            {
                var version = r.ReadInt32();
                var nodrefs = r.ReadArray(i => r.ReadNodeRef());

                r.ReadArray <int>(2);
            }
Example #4
0
 public override void Write(CGameCtnMediaBlockFxColors n, GameBoxWriter w, GameBoxReader unknownR)
 {
     w.Write(n.Keys, x =>
     {
         w.Write(x.Time);
         w.Write(x.Intensity);
         w.Write(x.BlendZ);
         w.Write(x.Distance);
         w.Write(x.FarDistance);
         w.Write(x.Inverse);
         w.Write(x.Hue);
         w.Write(x.Saturation);
         w.Write(x.Brightness);
         w.Write(x.Contrast);
         w.Write(x.RGB);
         w.Write(x.U01);
         w.Write(x.U02);
         w.Write(x.U03);
         w.Write(x.U04);
         w.Write(x.FarInverse);
         w.Write(x.FarHue);
         w.Write(x.FarSaturation);
         w.Write(x.FarBrightness);
         w.Write(x.FarContrast);
         w.Write(x.FarRGB);
         w.Write(x.FarU01);
         w.Write(x.FarU02);
         w.Write(x.FarU03);
         w.Write(x.FarU04);
     });
 }
Example #5
0
        public void Write(GameBoxWriter w)
        {
            w.Write(ExternalNodes.Length);
            w.Write(RootFolder.Folders.Count);

            // ...
        }
            public override void Read(CGameCtnMediaClipGroup n, GameBoxReader r, GameBoxWriter unknownW)
            {
                Version = r.ReadInt32();

                var clips = r.ReadArray(i => r.ReadNodeRef<CGameCtnMediaClip>());
                var triggers = r.ReadArray(i =>
                {
                    var coords = r.ReadArray(j => r.ReadInt3());
                    var u01 = r.ReadInt32();
                    var u02 = r.ReadInt32();
                    var u03 = r.ReadInt32();
                    var u04 = r.ReadInt32();

                    return new Trigger()
                    {
                        Coords = coords,
                        U01 = u01,
                        U02 = u02,
                        U03 = u03,
                        U04 = u04
                    };
                });

                n.Clips = clips.Select((clip, index) =>
                    Tuple.Create(clip, triggers[index])
                ).ToList();
            }
Example #7
0
            public override void Read(CGameCtnReplayRecord n, GameBoxReader r, GameBoxWriter unknownW)
            {
                var size = r.ReadInt32();

                if (size > 0)
                {
                    var trackGbx = r.ReadBytes(size);

                    n.Challenge = Task.Run(() =>
                    {
                        using (var ms = new MemoryStream(trackGbx))
                            return(GameBox.Parse <CGameCtnChallenge>(ms));
                    });

                    n.Challenge.ContinueWith(x =>
                    {
#if DEBUG
                        if (x.IsFaulted)
                        {
                            var e = x.Exception.InnerException;
                            Debug.WriteLine(e.Message);
                            Debug.WriteLine(e.StackTrace);
                        }
#endif
                    });
                }
            }
Example #8
0
            public override void Write(CGameCtnMediaBlockCameraPath n, GameBoxWriter w, GameBoxReader unknownR)
            {
                w.Write(Version);

                w.Write(n.Keys, x =>
                {
                    w.Write(x.Time);
                    w.Write(x.Position);
                    w.Write(x.PitchYawRoll);
                    w.Write(x.FOV);
                    if (Version >= 3)
                    {
                        w.Write(x.NearZ.GetValueOrDefault());
                    }
                    w.Write(x.AnchorRot);
                    w.Write(x.Anchor);
                    w.Write(x.AnchorVis);
                    w.Write(x.Target);
                    w.Write(x.TargetPosition);

                    w.Write((float)x.Unknown[0]);
                    w.Write((float)x.Unknown[1]);
                    w.Write((float)x.Unknown[2]);
                    w.Write((float)x.Unknown[3]);
                    w.Write((float)x.Unknown[4]);

                    if (Version >= 4)
                    {
                        w.Write((int)x.Unknown[5]);
                        w.Write((int)x.Unknown[6]);
                    }
                });
            }
Example #9
0
 public override void Read(CGameCtnCollection n, GameBoxReader r, GameBoxWriter unknownW)
 {
     _ = r.ReadString();
     _ = r.ReadInt32();
     _ = r.ReadString();
     _ = r.ReadString();
 }
Example #10
0
 public override void Write(CPlugEntRecordData n, GameBoxWriter w)
 {
     w.Write(Version);
     w.Write(UncompressedSize);
     w.Write(CompressedSize);
     w.Write(Data, 0, Data.Length);
 }
Example #11
0
    private static GameBoxReaderWriter PrepareInWriteMode()
    {
        var ms = new MemoryStream();
        var w  = new GameBoxWriter(ms);

        return(new GameBoxReaderWriter(w));
    }
Example #12
0
 public override void Write(CPlugEntRecordData n, GameBoxWriter w)
 {
     w.Write(Version);
     w.Write(UncompressedSize);
     w.Write(CompressedSize);
     w.WriteBytes(data);
 }
Example #13
0
    internal void Write(GameBoxWriter w)
    {
        var allFiles = GetAllFiles();
        var numFiles = allFiles.Count();

        w.Write(numFiles);

        if (numFiles <= 0)
        {
            return;
        }

        w.Write(AncestorLevel);
        w.Write(Folders.Count);

        WriteFolders(Folders);

        void WriteFolders(IEnumerable <Folder> folders)
        {
            if (folders == null)
            {
                return;
            }

            foreach (var folder in folders)
            {
                w.Write(folder.Name);
                w.Write(folder.Folders.Count);

                WriteFolders(folder.Folders);
            }
        }

        foreach (var file in allFiles)
        {
            w.Write(file.Flags);

            if ((file.Flags & 4) == 0)
            {
                w.Write(file.FileName);
            }
            else
            {
                w.Write(file.ResourceIndex.GetValueOrDefault());
            }

            w.Write(file.NodeIndex);

            if (Header.Version >= 5)
            {
                w.Write(file.UseFile.GetValueOrDefault());
            }

            if ((file.Flags & 4) == 0)
            {
                w.Write(file.FolderIndex.GetValueOrDefault());
            }
        }
    }
Example #14
0
 public override void Write(CGameCtnMediaBlockFxBloom n, GameBoxWriter w, GameBoxReader unknownR)
 {
     w.Write(n.Keys, x =>
     {
         w.Write(x.Time);
         w.Write(x.Intensity);
         w.Write(x.Sensitivity);
     });
 }
Example #15
0
 public override void Read(CGameCtnReplayRecord n, GameBoxReader r, GameBoxWriter unknownW)
 {
     Version           = r.ReadInt32();
     n.AuthorVersion   = r.ReadInt32();
     n.AuthorLogin     = r.ReadString();
     n.AuthorNickname  = r.ReadString();
     n.AuthorZone      = r.ReadString();
     n.AuthorExtraInfo = r.ReadString();
 }
Example #16
0
 public override void Read(CGameCtnCollection n, GameBoxReader r, GameBoxWriter unknownW)
 {
     _         = r.ReadId();
     _         = r.ReadInt32();
     _         = r.ReadArray(x => r.ReadInt32());
     _         = r.ReadInt32();
     _         = r.ReadArray <float>(3);
     n.Vehicle = r.ReadIdent();
 }
            public override void Write(CGameCtnMediaBlockDirtyLens n, GameBoxWriter w, GameBoxReader unknownR)
            {
                w.Write(Version);

                w.Write(n.Keys, x =>
                {
                    w.Write(x.Time);
                    w.Write(x.Intensity);
                });
            }
        public override void Write(CGameCtnMediaClipGroup n, GameBoxWriter w)
        {
            w.Write(n.ClipsVersion);

            w.Write(n.Clips, (x, w) => w.Write(x.Clip));
            w.Write(n.Clips, (x, w) =>
            {
                w.Write(x.Trigger.Coords, (y, w) => w.Write(y));
            });
        }
            public override void Write(CGameCtnMediaClipGroup n, GameBoxWriter w)
            {
                w.Write(n.ClipsVersion);

                w.Write(n.Clips, (x, w1) => w1.Write(x.Item1));
                w.Write(n.Clips, (x, w1) =>
                {
                    w1.Write(x.Item2.Coords, (y, w2) => w2.Write(y));
                });
            }
            public override void Write(CGameCtnMediaClipGroup n, GameBoxWriter w, GameBoxReader unknownR)
            {
                w.Write(Version);

                w.Write(n.Clips, x => w.Write(x.Item1));
                w.Write(n.Clips, x =>
                {
                    w.Write(x.Item2.Coords, y => w.Write(y));
                });
            }
 public override void Write(CGameCtnMediaBlockFxBlurDepth n, GameBoxWriter w, GameBoxReader unknownR)
 {
     w.Write(n.Keys, x =>
     {
         w.Write(x.Time);
         w.Write(x.LensSize);
         w.Write(x.ForceFocus);
         w.Write(x.FocusZ);
     });
 }
Example #22
0
    private static GameBoxReaderWriter PrepareInReadMode(Action <GameBoxWriter> initialWrites)
    {
        var ms = new MemoryStream();

        using var w = new GameBoxWriter(ms);
        initialWrites.Invoke(w);
        ms.Seek(0, SeekOrigin.Begin);

        var r = new GameBoxReader(ms);

        return(new GameBoxReaderWriter(r));
    }
Example #23
0
 public override void Read(CGameCtnMediaBlockFxBloom n, GameBoxReader r, GameBoxWriter unknownW)
 {
     n.Keys = r.ReadArray(i =>
     {
         return(new Key()
         {
             Time = r.ReadSingle(),
             Intensity = r.ReadSingle(),
             Sensitivity = r.ReadSingle()
         });
     });
 }
        public override void Write(CGameCtnMediaClipGroup n, GameBoxWriter w)
        {
            w.Write(n.ClipsVersion);

            w.Write(n.Clips, (x, w1) => w1.Write(x.Clip));
            w.Write(n.Clips, (x, w1) =>
            {
                w1.Write(x.Trigger.Coords, (y, w2) => w2.Write(y));
                w1.Write(x.Trigger.U01);
                w1.Write(x.Trigger.U02);
                w1.Write(x.Trigger.U03);
                w1.Write(x.Trigger.U04);
            });
        }
Example #25
0
            public override void Read(CGameCtnMacroBlockInfo n, GameBoxReader r, GameBoxWriter unknownW)
            {
                var unknown = r.ReadArray(i =>
                {
                    return(new object[]
                    {
                        r.ReadInt32(),
                        r.ReadArray(j => r.ReadIdent()),

                        r.ReadInt32(),
                        r.ReadInt32(),
                        r.ReadInt32()
                    });
                });
            }
Example #26
0
            public override void Read(CGameCtnReplayRecord n, GameBoxReader r, GameBoxWriter unknownW)
            {
                var v = r.ReadInt32();

                if (v != 0)
                {
                    r.ReadInt32();
                    var controlNames = r.ReadArray(i =>
                    {
                        r.ReadInt32();
                        r.ReadInt32();
                        return(r.ReadString());
                    });

                    var numControlEntries = r.ReadInt32() - 1;
                    var controlEntries    = new (int, int, int)[numControlEntries];
            public override void Write(CGameCtnMediaClipGroup n, GameBoxWriter w, GameBoxReader unknownR)
            {
                w.Write(Version);

                w.Write(n.Clips, x => w.Write(x.Item1));
                w.Write(n.Clips, x =>
                {
                    var trigger = x.Item2;

                    w.Write(trigger.Coords, y => w.Write(y));
                    w.Write(trigger.U01);
                    w.Write(trigger.U02);
                    w.Write(trigger.U03);
                    w.Write(trigger.U04);
                });
            }
            public override void Write(CGameCtnMediaClipGroup n, GameBoxWriter w)
            {
                w.Write(n.ClipsVersion);

                w.Write(n.Clips, (x, w1) => w1.Write(x.Item1));
                w.Write(n.Clips, (x, w1) =>
                {
                    var trigger = x.Item2;

                    w1.Write(trigger.U01);
                    w1.Write(trigger.U02);
                    w1.Write(trigger.U03);
                    w1.Write(trigger.U04);
                    w1.Write((int)trigger.Condition);
                    w1.Write(trigger.ConditionValue);
                    w1.Write(trigger.Coords, (y, w2) => w2.Write(y));
                });
            }
Example #29
0
 public override void Read(CGameCtnCollection n, GameBoxReader r, GameBoxWriter unknownW)
 {
     Version        = r.ReadByte();
     n.CollectionID = r.ReadByte();
     _ = r.ReadBytes(6);
     n.CollectionPackMask = r.ReadByte();
     n.DisplayName        = r.ReadString();
     _ = r.ReadInt32();
     n.CollectionIcon = r.ReadString();
     _ = r.ReadArray <int>(2);
     n.BlockInfoFlat = r.ReadId(this);
     n.Vehicle       = r.ReadIdent(this);
     _ = r.ReadInt32();
     _ = r.ReadArray <float>(4);
     n.LoadingScreen = r.ReadString();
     _ = r.ReadArray <int>(7);
     _ = r.ReadString();
     _ = r.ReadInt32();
 }
Example #30
0
 public override void Write(CGameCtnMediaBlockCameraPath n, GameBoxWriter w, GameBoxReader unknownR)
 {
     w.Write(n.Keys, x =>
     {
         w.Write(x.Time);
         w.Write(x.Position);
         w.Write(x.PitchYawRoll);
         w.Write(x.FOV);
         w.Write(x.AnchorRot);
         w.Write(x.Anchor);
         w.Write(x.AnchorVis);
         w.Write(x.Target);
         w.Write(x.TargetPosition);
         w.Write((float)x.Unknown[0]);
         w.Write((float)x.Unknown[1]);
         w.Write((float)x.Unknown[2]);
         w.Write((float)x.Unknown[3]);
         w.Write((float)x.Unknown[4]);
     });
 }