/// <summary> /// Should occur when an NPC dies; gives rewards out to all the players that hit it. /// </summary> protected void ProcessNPCDeath(Terraria.NPC NPC) { List <PlayerDamage> playerDamageList = null; Dictionary <Player, double> argsDict; NPCDeathEventArgs args; lock (__dictionaryMutex) { if (DamageDictionary.ContainsKey(NPC)) { playerDamageList = DamageDictionary[NPC]; if (DamageDictionary.Remove(NPC) == false) { TShock.Log.ConsoleError("seconomy: world economy: Remove of NPC after reward failed. This is an internal error."); } } } if (playerDamageList == null || NPCDeath == null) { return; } argsDict = new Dictionary <Player, double>(); args = new NPCDeathEventArgs(NPC, argsDict); foreach (PlayerDamage dmg in playerDamageList) { argsDict.Add(dmg.Player, dmg.Damage); } NPCDeath(this, args); }
/// <summary> /// Should occur when an NPC dies; gives rewards out to all the players that hit it. /// </summary> protected void ProcessNPCDeath(Terraria.NPC NPC) { List<PlayerDamage> playerDamageList = null; Dictionary<Player, double> argsDict; NPCDeathEventArgs args; lock (__dictionaryMutex) { if (DamageDictionary.ContainsKey(NPC)) { playerDamageList = DamageDictionary[NPC]; if (DamageDictionary.Remove(NPC) == false) { TShock.Log.ConsoleError("seconomy: world economy: Remove of NPC after reward failed. This is an internal error."); } } } if (playerDamageList == null || NPCDeath == null) { return; } argsDict = new Dictionary<Player,double>(); args = new NPCDeathEventArgs(NPC, argsDict); foreach (PlayerDamage dmg in playerDamageList) { argsDict.Add(dmg.Player, dmg.Damage); } NPCDeath(this, args); }