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));
                            }
                        }
                    }
                }
        }
Exemple #2
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);
            }
        }