public override void Read(CGameCtnReplayRecord n, GameBoxReader r) { var size = r.ReadInt32(); if (size <= 0) { throw new Exception(); } var trackGbx = r.ReadBytes(size); n.challenge = Task.Run(() => { using var ms = new MemoryStream(trackGbx); return(GameBox.ParseNode <CGameCtnChallenge>(ms)); }); #if DEBUG n.challenge.ContinueWith(x => { if (!x.IsFaulted) { return; } var e = x.Exception?.InnerException; Debug.WriteLine(e?.Message); Debug.WriteLine(e?.StackTrace); }); #endif }
static void Main(string[] args) { var random = new Random(); foreach (var fileName in args) { var node = GameBox.ParseNode(fileName); if (node is CGameCtnChallenge ch) { var colors = Enum.GetValues <DifficultyColor>(); foreach (var block in ch.Blocks) { var randomColor = colors[random.Next(colors.Length)]; block.Color = randomColor; } foreach (var item in ch.AnchoredObjects) { var randomColor = colors[random.Next(colors.Length)]; item.Color = randomColor; } ch.CreateChunk <CGameCtnChallenge.Chunk03043062>(); ch.Save(Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(fileName)) + "-LEGO.Map.Gbx"); } } }
public void ParseSaveMapWithoutExceptions(string fileName) { var node = GameBox.ParseNode(Path.Combine("Files", fileName)); using var ms = new MemoryStream(); node.Save(ms); }
static void Main(string[] args) { foreach (var fileName in args) { var node = GameBox.ParseNode(fileName); var ghosts = new List <CGameCtnGhost>(); var isStuntsMap = false; if (node is CGameCtnReplayRecord replay) { foreach (var g in replay.GetGhosts()) { ghosts.Add(g); } if (replay.Challenge.Result.Mode == CGameCtnChallenge.PlayMode.Stunts) { isStuntsMap = true; } } else if (node is CGameCtnGhost ghost) { ghosts.Add(ghost); } else { return; } foreach (var ghost in ghosts) { var ghostName = $"{ghost.RaceTime.ToStringTM()} by {Formatter.Deformat(ghost.GhostNickname)}"; Console.Write(ghostName); Console.WriteLine($" ({Path.GetFileName(fileName)})"); Console.WriteLine(new string('-', ghostName.Length)); for (var i = 0; i < ghost.Checkpoints.Length - 1; i++) { var cp = ghost.Checkpoints[i]; if (isStuntsMap) { Console.WriteLine($"CP{i + 1}: {cp.Time.ToStringTM()} | {cp.StuntsScore}pts"); } else { Console.WriteLine($"CP{i + 1}: {cp.Time.ToStringTM()}"); } } Console.WriteLine(); } } Console.ReadKey(true); }
static void Main(string[] args) { var fileName = args.FirstOrDefault(); if (fileName == null) { return; } Log.OnLogEvent += Log_OnLogEvent; var node = GameBox.ParseNode(fileName); if (node is CGameCtnGhost ghost) { var clip = new CGameCtnMediaClip(); clip.CreateChunk <CGameCtnMediaClip.Chunk0307900D>(); var track = new CGameCtnMediaTrack() { Name = ghost.GhostNickname }; track.CreateChunk <CGameCtnMediaTrack.Chunk03078001>(); track.CreateChunk <CGameCtnMediaTrack.Chunk03078005>(); clip.Tracks.Add(track); var ghostBlock = new CGameCtnMediaBlockGhost() { GhostModel = ghost, Keys = new List <CGameCtnMediaBlockGhost.Key> { new CGameCtnMediaBlockGhost.Key(), new CGameCtnMediaBlockGhost.Key() { Time = ghost.RaceTime.GetValueOrDefault(TimeSpan.FromSeconds(3)) } } }; var chunk002 = ghostBlock.CreateChunk <CGameCtnMediaBlockGhost.Chunk030E5002>(); chunk002.Version = 3; track.Blocks.Add(ghostBlock); clip.Save(Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(node.GBX.FileName)) + ".Clip.Gbx"); } }
static void Main(string[] args) { Log.OnLogEvent += Log_OnLogEvent; foreach (var fileName in args) { var node = GameBox.ParseNode(fileName); if (node is CGameCtnChallenge map) { map.CrackPassword(); var savePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(fileName)); map.Save(savePath); } } }
static void Main(string[] args) { var fileName = args.FirstOrDefault(); if (fileName == null) { return; } Log.OnLogEvent += Log_OnLogEvent; var node = GameBox.ParseNode(fileName); if (node is CGameCtnChallenge map) { map.ExtractOriginalEmbedZip(map.GBX.FileName + ".zip"); } }
static void Main(string[] args) { var fileName = args.FirstOrDefault(); if (fileName == null) { return; } Log.OnLogEvent += Log_OnLogEvent; var node = GameBox.ParseNode(fileName); if (node is CGameCtnReplayRecord replay) { var map = replay.Challenge; map.Save(Formatter.Deformat(map.MapName + ".Map.Gbx")); } }
static void Main(string[] args) { var fileName = args.FirstOrDefault(); if (fileName == null) { return; } Log.OnLogEvent += Log_OnLogEvent; var node = GameBox.ParseNode(fileName); if (node is CGameCtnChallenge map) { map.CrackPassword(); var savePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(fileName)); map.Save(savePath); } }
private static void ProcessGbx(string fileName) { if (!File.Exists(fileName)) { return; } var node = GameBox.ParseNode(fileName); if (node is not CGameCtnChallenge map) { return; } if (map.Blocks is null || map.Blocks.Count == 0) { return; } var locatorUrls = map.Blocks .Select(x => x.Skin?.PackDesc?.LocatorUrl !) .Where(x => x is not null) .Distinct(); var newDictionary = locatorUrls.ToDictionary(x => x.ToString(), x => default(string)); var dictionary = UpdateLocatorList(newDictionary); foreach (var block in map.Blocks) { ProcessBlock(block, dictionary); } Directory.CreateDirectory(rootPath + "output"); node.Save(rootPath + "output/" + Path.GetFileName(map.GBX !.FileName)); }
public override void OnGlobalSetup() { map = GameBox.ParseNode <CGameCtnChallenge>(stream); }
public CGameCtnChallenge ParseMap() { return(GameBox.ParseNode <CGameCtnChallenge>(stream)); }
public void ParseMap(string fileName) { var node = GameBox.ParseNode(Path.Combine("Files", fileName)); }