public void EntryProgressChanged(NitroxTechType techType, float progress, int unlocked, NitroxId nitroxId) { if (!PartiallyUnlockedByTechType.TryGetValue(techType, out PDAEntry pdaEntry)) { PartiallyUnlockedByTechType[techType] = pdaEntry = new PDAEntry(techType, progress, unlocked); } // Update progress for specific entity if NitroxID is provided. if (nitroxId != null) { if (!CachedProgress.TryGetValue(techType, out PDAProgressEntry pdaProgressEntry)) { CachedProgress.Add(techType, pdaProgressEntry = new PDAProgressEntry(techType, new Dictionary <NitroxId, float>())); } // Prevents decreasing progress if (!pdaProgressEntry.Entries.ContainsKey(nitroxId) || (unlocked == pdaEntry.Unlocked && pdaProgressEntry.Entries.TryGetValue(nitroxId, out float oldProgress) && oldProgress < progress)) { pdaProgressEntry.Entries[nitroxId] = progress; pdaEntry.Progress = progress; } } // This needs to occur after the progress update because // progress update needs to know what was the old unlocked state pdaEntry.Unlocked = unlocked; }
public override void Process(PDAEntryProgress packet) { using (packetSender.Suppress <PDAEntryAdd>()) using (packetSender.Suppress <PDAEntryProgress>()) { TechType techType = packet.TechType.ToUnity(); if (PDAScanner.GetPartialEntryByKey(techType, out PDAScanner.Entry entry)) { if (packet.Unlocked == entry.unlocked) { // Add the entry as a cached progress if (!PDAManagerEntry.CachedEntries.TryGetValue(packet.TechType, out PDAProgressEntry pdaProgressEntry)) { PDAManagerEntry.CachedEntries.Add(packet.TechType, pdaProgressEntry = new PDAProgressEntry(packet.TechType, new Dictionary <NitroxId, float>())); } pdaProgressEntry.Entries[packet.NitroxId] = packet.Progress; } else if (packet.Unlocked > entry.unlocked) { Log.Info($"PDAEntryProgress Update For TechType:{techType} Old:{entry.unlocked} New:{packet.Unlocked}"); entry.unlocked = packet.Unlocked; } } else { Log.Info($"PDAEntryProgress New TechType:{techType} Unlocked:{packet.Unlocked}"); methodAdd.Invoke(null, new object[] { techType, packet.Unlocked }); } } }