private List <Task> BroadcastAsyncHere(IEnumerable <IPacket> packets, IBroadcastRule rule) { return(PlayerEntities.Select(s => Task.Run(() => rule == null || rule.Match(s.Value) ? s.Value.Session.SendPacketsAsync(packets) : Task.CompletedTask)).ToList()); }
private List <Task> BroadcastEventAsyncHere(ILogicEvent logicEvent, IBroadcastEventRule rule, bool onlyPlayers) { if (onlyPlayers) { return(PlayerEntities.Select(s => Task.Run(() => rule == null || rule.Match(s.Value) ? s.Value.EmitEventAsync(logicEvent) : Task.CompletedTask)).ToList()); } return(SubstantialEntities.Select(s => Task.Run(() => rule == null || rule.Match(s.Value) ? s.Value.EmitEventAsync(logicEvent) : Task.CompletedTask)).ToList()); }
public Task BroadcastAsync(IEnumerable <IPacket> packets, IBroadcastRule rule) { return(Task.WhenAll(PlayerEntities.Select(s => Task.Run(() => rule == null || rule.Match(s.Value) ? s.Value.Session.SendPacketsAsync(packets) : Task.CompletedTask)))); }
public Task BroadcastAsync <T>(T packet, IBroadcastRule rule) where T : IPacket { return(Task.WhenAll(PlayerEntities.Select(s => Task.Run(() => rule == null || rule.Match(s.Value) ? s.Value.Session.SendPacketAsync(packet) : Task.CompletedTask)))); }