Esempio n. 1
0
        public override void Process(PDAEntryProgress packet)
        {
            using (packetSender.Suppress <PDAEntryAdd>())
                using (packetSender.Suppress <PDAEntryProgress>())
                {
                    TechType             techType  = packet.TechType.ToUnity();
                    PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);

                    PDAScanner.Entry entry;
                    if (PDAScanner.GetPartialEntryByKey(techType, out entry))
                    {
                        if (packet.Unlocked > entry.unlocked)
                        {
                            Log.Info("PDAEntryProgress Upldate Old:" + entry.unlocked + " New" + packet.Unlocked);
                            entry.unlocked = packet.Unlocked;
                        }
                    }
                    else
                    {
                        Log.Info("PDAEntryProgress New TechType:" + techType + " Unlocked:" + packet.Unlocked);
                        MethodInfo methodAdd = typeof(PDAScanner).GetMethod("Add", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(TechType), typeof(int) }, null);
                        entry = (PDAScanner.Entry)methodAdd.Invoke(null, new object[] { techType, packet.Unlocked });
                    }
                }
        }
        public override void Process(PDAEntryAdd packet)
        {
            using (packetSender.Suppress <PDAEntryAdd>())
                using (packetSender.Suppress <PDAEntryProgress>())
                {
                    TechType             techType  = packet.TechType.ToUnity();
                    PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);

                    if (!PDAScanner.GetPartialEntryByKey(techType, out PDAScanner.Entry entry))
                    {
                        entry = PDAScanner.Add(techType, packet.Unlocked);
                    }

                    if (entry != null)
                    {
                        entry.unlocked++;

                        if (entry.unlocked >= entryData.totalFragments)
                        {
                            PDAScanner.partial.Remove(entry);
                            PDAScanner.complete.Add(entry.techType);
                        }
                        else
                        {
                            int totalFragments = entryData.totalFragments;
                            if (totalFragments > 1)
                            {
                                float num2 = (float)entry.unlocked / (float)totalFragments;
                                float arg  = (float)Mathf.RoundToInt(num2 * 100f);
                                ErrorMessage.AddError(Language.main.GetFormat <string, float, int, int>("ScannerInstanceScanned", Language.main.Get(entry.techType.AsString(false)), arg, entry.unlocked, totalFragments));
                            }
                        }
                    }
                }
        }
Esempio n. 3
0
        private void Process(ClientScanProgress msg)
        {
            var entryData = PDAScanner.GetEntryData(msg.tech);

            if (entryData == null)
            {
                return;
            }

            using (new MessageBlocker()) {
                PDAScanner.Entry entry;
                if (!PDAScanner.GetPartialEntryByKey(msg.tech, out entry))
                {
                    var methodAdd = typeof(PDAScanner).GetMethod("Add", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(TechType), typeof(int) }, null);
                    entry = (PDAScanner.Entry)methodAdd.Invoke(null, new object[] { msg.tech, 0 });
                }

                if (entry != null)
                {
                    entry.unlocked = msg.progress;
                    if (entry.unlocked >= entryData.totalFragments)
                    {
                        var partial  = (List <PDAScanner.Entry>)(typeof(PDAScanner).GetField("partial", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null));
                        var complete = (HashSet <TechType>)(typeof(PDAScanner).GetField("complete", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null));

                        partial.Remove(entry);
                        complete.Add(entry.techType);
                    }
                }
            }
        }
        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 });
                    }
                }
        }
Esempio n. 5
0
            public PDAScanner.Entry GetEntry()
            {
                if (PDAScanner.GetPartialEntryByKey(EntryTechType, out PDAScanner.Entry entry) && entry.unlocked > Entry.unlocked)
                {
                    Unlocked       = true;
                    Entry.unlocked = entry.unlocked;
                }

                return(Entry);
            }
Esempio n. 6
0
 public override void Process(PDAEntryRemove packet)
 {
     using (packetSender.Suppress <PDAEntryRemove>())
     {
         if (PDAScanner.GetPartialEntryByKey(packet.TechType.ToUnity(), out PDAScanner.Entry entry))
         {
             PDAScanner.partial.Remove(entry);
             PDAScanner.complete.Add(entry.techType);
         }
     }
 }
 public override void Process(PDAEntryRemove packet)
 {
     using (packetSender.Suppress <PDAEntryRemove>())
     {
         if (PDAScanner.GetPartialEntryByKey(packet.TechType.ToUnity(), out PDAScanner.Entry entry))
         {
             List <PDAScanner.Entry> partial  = (List <PDAScanner.Entry>)(typeof(PDAScanner).GetField("partial", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null));
             HashSet <TechType>      complete = (HashSet <TechType>)(typeof(PDAScanner).GetField("complete", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null));
             partial.Remove(entry);
             complete.Add(entry.techType);
         }
     }
 }
Esempio n. 8
0
        public static void Postfix(Pickupable pickupable)
        {
            if (newgame && Main.config.Hardcore && !Utils.GetContinueMode() && pickupable.GetTechType() != TechType.FireExtinguisher)
            {
                CoroutineHost.StartCoroutine(GiveHardcoreScanner());
                newgame = false;
                SMLHelper.V2.Handlers.IngameMenuHandler.RegisterOnQuitEvent(() => newgame = true);
            }

            TechType techType = pickupable.GetTechType();

            PDAScanner.EntryData entryData  = PDAScanner.GetEntryData(techType);
            GameObject           gameObject = pickupable.gameObject;

            if (Main.config.ScanOnPickup && Inventory.main.container.Contains(TechType.Scanner) && entryData != null)
            {
                if (!PDAScanner.GetPartialEntryByKey(techType, out PDAScanner.Entry entry))
                {
                    entry = PDAScanner.Add(techType, 1);
                }
                if (entry != null)
                {
                    PDAScanner.partial.Remove(entry);
                    PDAScanner.complete.Add(entry.techType);
                    PDAScanner.NotifyRemove(entry);
                    PDAScanner.Unlock(entryData, true, true, true);
                    KnownTech.Add(techType, false);
                    if (gameObject != null)
                    {
                        gameObject.SendMessage("OnScanned", null, SendMessageOptions.DontRequireReceiver);
                    }
#if SN1
                    ResourceTracker.UpdateFragments();
#endif
                }
            }

            if (!Main.config.Hardcore && entryData == null)
            {
                KnownTech.Add(techType, true);
            }
        }
Esempio n. 9
0
        public override void Process(PDAEntryAdd packet)
        {
            using (packetSender.Suppress <PDAEntryAdd>())
                using (packetSender.Suppress <PDAEntryProgress>())
                {
                    TechType             techType  = packet.TechType.Enum();
                    PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);

                    PDAScanner.Entry entry;
                    if (!PDAScanner.GetPartialEntryByKey(techType, out entry))
                    {
                        MethodInfo methodAdd = typeof(PDAScanner).GetMethod("Add", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(TechType), typeof(int) }, null);
                        entry = (PDAScanner.Entry)methodAdd.Invoke(null, new object[] { techType, packet.Unlocked });
                    }

                    if (entry != null)
                    {
                        entry.unlocked++;

                        if (entry.unlocked >= entryData.totalFragments)
                        {
                            List <PDAScanner.Entry> partial  = (List <PDAScanner.Entry>)(typeof(PDAScanner).GetField("partial", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null));
                            HashSet <TechType>      complete = (HashSet <TechType>)(typeof(PDAScanner).GetField("complete", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null));
                            partial.Remove(entry);
                            complete.Add(entry.techType);
                        }
                        else
                        {
                            int totalFragments = entryData.totalFragments;
                            if (totalFragments > 1)
                            {
                                float num2 = (float)entry.unlocked / (float)totalFragments;
                                float arg  = (float)Mathf.RoundToInt(num2 * 100f);
                                ErrorMessage.AddError(Language.main.GetFormat <string, float, int, int>("ScannerInstanceScanned", Language.main.Get(entry.techType.AsString(false)), arg, entry.unlocked, totalFragments));
                            }
                        }
                    }
                }
        }
        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)
                        {
                            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 });
                    }
                }
        }