public static ProjCache GetData(Projectile proj) { ProjCache ret = proj.GetGlobalProjectile <ProjCache>(); ret.projectile = proj; return(ret); }
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); } } } } }