public void RaiseNewMonsterEntries(List <ActorEntity> actorEntities) { if (!actorEntities.Any()) { return; } MonsterWorkerDelegate.ReplaceNPCEntities(new List <ActorEntity>(actorEntities)); Func <bool> saveToDictionary = delegate { try { var enumerable = MonsterWorkerDelegate.GetUniqueNPCEntities(); foreach (var actor in actorEntities) { var exists = enumerable.FirstOrDefault(n => n.ID == actor.ID); if (exists != null) { continue; } MonsterWorkerDelegate.AddUniqueNPCEntity(actor); } } catch (Exception ex) { } return(true); }; saveToDictionary.BeginInvoke(null, saveToDictionary); // THIRD PARTY PluginHost.Instance.RaiseNewMonsterEntries(actorEntities); }
private static void OnNewMonsterEntries(object sender, ActorEntitiesEvent actorEntitiesEvent) { // delegate event from monster entities from ram, not required to subsribe // this updates 10x a second and only sends data if the items are found in ram // currently there no change/new/removed event handling (looking into it) if (sender == null) { return; } var monsterEntities = actorEntitiesEvent.ActorEntities; if (!monsterEntities.Any()) { return; } MonsterWorkerDelegate.ReplaceNPCEntities(new List <ActorEntity>(monsterEntities)); Func <bool> saveToDictionary = delegate { try { var enumerable = MonsterWorkerDelegate.GetUniqueNPCEntities(); foreach (var actor in monsterEntities) { var exists = enumerable.FirstOrDefault(n => n.ID == actor.ID); if (exists != null) { continue; } MonsterWorkerDelegate.AddUniqueNPCEntity(actor); } } catch (Exception ex) { } return(true); }; saveToDictionary.BeginInvoke(null, saveToDictionary); }