public void RaiseNewPCEntries(List <ActorEntity> actorEntities) { if (!actorEntities.Any()) { return; } PCWorkerDelegate.ReplaceNPCEntities(new List <ActorEntity>(actorEntities)); Func <bool> saveToDictionary = delegate { try { var enumerable = PCWorkerDelegate.GetUniqueNPCEntities(); foreach (var actor in actorEntities) { var exists = enumerable.FirstOrDefault(n => String.Equals(n.Name, actor.Name, Constants.InvariantComparer)); if (exists != null) { continue; } PCWorkerDelegate.AddUniqueNPCEntity(actor); } } catch (Exception ex) { } return(true); }; saveToDictionary.BeginInvoke(null, saveToDictionary); // THIRD PARTY PluginHost.Instance.RaiseNewPCEntries(actorEntities); }
private static void OnNewPCEntries(object sender, ActorEntitiesEvent actorEntitiesEvent) { // delegate event from player 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 pcEntities = actorEntitiesEvent.ActorEntities; if (!pcEntities.Any()) { return; } PCWorkerDelegate.CurrentUser = pcEntities.First(); PCWorkerDelegate.ReplaceNPCEntities(new List <ActorEntity>(pcEntities)); Func <bool> saveToDictionary = delegate { try { var enumerable = PCWorkerDelegate.GetUniqueNPCEntities(); foreach (var actor in pcEntities) { var exists = enumerable.FirstOrDefault(n => String.Equals(n.Name, actor.Name, Constants.InvariantComparer)); if (exists != null) { continue; } PCWorkerDelegate.AddUniqueNPCEntity(actor); } } catch (Exception ex) { } return(true); }; saveToDictionary.BeginInvoke(null, saveToDictionary); }