public static void Initialize() { foreach (string level1 in Content.GetLevels("challenge", LevelLocation.Content)) { LevelData level2 = Content.GetLevel(level1); string guid = level2.metaData.guid; foreach (BinaryClassChunk node in level2.objects.objects) { string property = node.GetProperty <string>("type"); if (property != null) { if (property.Contains("DuckGame.ChallengeMode,")) { try { if (Thing.LoadThing(node, false) is ChallengeMode challengeMode) { challengeMode.challenge.fileName = level1; challengeMode.challenge.levelID = guid; challengeMode.challenge.preview = level2.previewData.preview; if (challengeMode.challenge.trophies[5].goodies == -1 && challengeMode.challenge.trophies[5].targets == -1) { int timeRequirement = challengeMode.challenge.trophies[5].timeRequirement; } Challenges._challenges.Add(level2.metaData.guid, challengeMode.challenge); } } catch (Exception ex) { } } } } } foreach (string file in DuckFile.GetFiles(DuckFile.challengeDirectory)) { XDocument xdocument = DuckFile.LoadXDocument(file); if (xdocument != null) { string withoutExtension = Path.GetFileNameWithoutExtension(file); XElement xelement = xdocument.Element((XName)"Data"); if (xelement != null) { foreach (XElement element1 in xelement.Elements((XName)"challengeSaveData")) { ChallengeSaveData element2 = new ChallengeSaveData(); element2.LegacyDeserialize(element1); element2.challenge = withoutExtension; Challenges._saveData.Add(withoutExtension, element2); } } } } }