예제 #1
0
파일: BuffCache.cs 프로젝트: GLugia/Vitrium
 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
파일: BuffCache.cs 프로젝트: GLugia/Vitrium
        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
파일: BuffCache.cs 프로젝트: GLugia/Vitrium
        internal static int ReserveNPC()
        {
            int id;

            do
            {
                if (NextNPCID == int.MaxValue)
                {
                    NextNPCID = int.MinValue;
                }

                id = NextNPCID;
                NextNPCID++;
            }while (!AllNPCBuffs.TryAdd(id, new Dictionary <string, int>()));
            AllNPCBuffers.Add(id, new Dictionary <string, int>());
            return(id);
        }
예제 #4
0
파일: BuffCache.cs 프로젝트: GLugia/Vitrium
        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);
        }
예제 #5
0
파일: BuffCache.cs 프로젝트: GLugia/Vitrium
 internal static void DeleteNPC(int globalID)
 {
     AllNPCBuffers.Remove(globalID);
     AllNPCBuffs.Remove(globalID);
 }