示例#1
0
 public static IEnumerable <VitriBuff> GetNPCBuffs(int globalID)
 {
     if (AllNPCBuffs.TryGetValue(globalID, out Dictionary <string, int> map))
     {
         foreach (string name in map.Keys)
         {
             yield return(TranslateVitri(name));
         }
     }
 }
示例#2
0
        internal static void ApplyAllBuffs()
        {
            // Add cached projectile buffs to their owner
            for (int i = 0; i < Main.projectile.Length; i++)
            {
                if (Main.projectile[i].active && Main.projectile[i].minion)
                {
                    ProjCache.GetData(Main.projectile[i]).ApplyBuffs();
                }
            }

            // Then activate both npcs and players together
            for (int i = 0; i < Main.npc.Length; i++)
            {
                if (i < 255 && Main.player[i].active)
                {
                    int pid = VPlayer.GetData(Main.player[i]).GlobalID;
                    if (AllPlayerBuffers.TryGetValue(pid, out Dictionary <string, int> pbuffer) &&
                        AllPlayerBuffs.TryGetValue(pid, out Dictionary <string, int> playerbuffs))
                    {
                        playerbuffs.Clear();
                        playerbuffs.AddRange(pbuffer);
                        pbuffer.Clear();

                        if (!Main.player[i].dead && !Main.player[i].ghost)
                        {
                            foreach ((string buff, int duration) in playerbuffs)
                            {
                                int vanilla = TranslateVanilla(buff);
                                Main.player[i].AddBuff(vanilla != -1 ? vanilla : TranslateVitri(buff).Type, duration);
                            }
                        }
                    }
                }

                if (Main.npc[i].active)
                {
                    int nid = VNPC.GetData(Main.npc[i]).GlobalID;
                    if (AllNPCBuffers.TryGetValue(nid, out Dictionary <string, int> nbuffer) &&
                        AllNPCBuffs.TryGetValue(nid, out Dictionary <string, int> npcbuffs))
                    {
                        npcbuffs.Clear();
                        npcbuffs.AddRange(nbuffer);
                        nbuffer.Clear();

                        foreach ((string buff, int duration) in npcbuffs)
                        {
                            int vanilla = TranslateVanilla(buff);
                            Main.npc[i].AddBuff(vanilla != -1 ? vanilla : TranslateVitri(buff).Type, duration);
                        }
                    }
                }
            }
        }
示例#3
0
        public static bool HasBuff(this NPC npc, string buffname)
        {
            buffname = buffname.ToLower();
            int id = VNPC.GetData(npc).GlobalID;

            if (AllNPCBuffs.TryGetValue(id, out Dictionary <string, int> map))
            {
                return(map.ContainsKey(buffname));
            }

            if (AllNPCBuffers.TryGetValue(id, out Dictionary <string, int> map2))
            {
                return(map2.ContainsKey(buffname));
            }

            return(false);
        }