Example #1
0
        public static List <TNPC> generateNPCList()
        {
            List <TNPC>          tocreate = new List <TNPC>();
            List <NPCDefinition> broken   = BrokenNPCs.getBrokenNPCs();

            for (int i = 0; i < NPCLoader.NPCCount; i++)
            {
                NPC npc = new NPC();
                npc.SetDefaults(i);
                TNPC mem = new TNPC();
                mem.Name  = new string(npc.FullName.ToCharArray().Where(c => !char.IsWhiteSpace(c)).ToArray());
                mem.ID    = npc.type;
                mem.Price = npc.lifeMax + (npc.defense * 2) + (npc.damage * damagepricemultiplier);
                if (npc.modNPC != null)
                {
                    mem.Mod = npc.modNPC.mod.ToString();
                }
                else
                {
                    mem.Mod = "Vanilla";
                }
                if (mem.Price <= 0)
                {
                    mem.Price = 99999;
                }
                NPCDefinition totest = new NPCDefinition(npc.type);
                if (!broken.Contains(totest))
                {
                    tocreate.Add(mem);
                }
            }
            return(tocreate);
        }
Example #2
0
        public static List <TNPC> RepopulateNPCs(List <TNPC> old)
        {
            //Adds all missing NPCs, but doesn't remove unused ones.
            List <TNPC> tocreate = new List <TNPC>();

            for (int i = 0; i < NPCLoader.NPCCount; i++)
            {
                try
                {
                    NPC npc = new NPC();
                    npc.SetDefaults(i);
                    string normalizedname = new string(npc.FullName.ToCharArray().Where(c => !char.IsWhiteSpace(c)).ToArray());
                    bool   found          = false;
                    foreach (var item in old)
                    {
                        if (item.Name == normalizedname && item.ID == npc.type)
                        {
                            found = true;
                            tocreate.Add(item);
                            break;
                        }
                    }
                    if (!found)
                    {
                        TNPC mem = new TNPC();
                        mem.Name  = normalizedname;
                        mem.ID    = npc.type;
                        mem.Price = npc.lifeMax + (npc.damage * damagepricemultiplier);
                        if (mem.Price <= 0)
                        {
                            mem.Price = 99999;
                        }
                        tocreate.Add(mem);
                    }
                }
                catch { }
            }

            return(tocreate);
        }