public override void OnSpeech(SpeechEventArgs e) { if (!Active || Receivers.Count == 0 || RootParent != null && !(RootParent is Mobile)) { return; } if (e.Type == MessageType.Emote) { return; } Mobile from = e.Mobile; string speech = e.Speech; foreach (ReceiverCrystal receiver in new List <ReceiverCrystal>(Receivers)) { if (receiver.Deleted) { Receivers.Remove(receiver); } else if (Charges > 0) { receiver.TransmitMessage(from, speech); Charges--; } else { this.Active = false; break; } } }
private void OnAddReceiver() { var viewModel = new ReceiverEntryViewModel(new BleReceiver()); viewModel.OnRemove += vm => Receivers.Remove(vm); Receivers.Add(viewModel); }
private void ClientDisconnected(object sender, EventArgs args) { Receiver client = sender as Receiver; if (client != null) { lock (ReceiversLock) Receivers.Remove(client); OnClientDisonnected?.Invoke(this, client); } }
/// <summary> /// Removes the <paramref name="receiver"/> from the <see cref="ImportManager"/> /// </summary> /// <param name="receiver">The <see cref="Receiver"/> to be removed</param> /// <param name="destroyGameObject">When True, the <paramref name="receiver"/>'s <see cref="Component.gameObject"/> will be removed from the scene</param> public void RemoveReceiver(Receiver receiver, bool destroyGameObject = true) { HideReceiver(receiver, false); Receivers.Remove(receiver.StreamId); busyReceivers.RemoveItem(receiver); UpdateBusy(); if (destroyGameObject) { Destroy(receiver.gameObject); } OnReceiverRemove?.Invoke(StreamFromID[receiver.StreamId], receiver); }
/// <summary> /// Unregisters receivers for log notifications /// </summary> /// <param name="receiver">Log receiver (instance)</param> /// <returns>Operation status</returns> public static bool UnregisterReceiver(ILogReceiver receiver) { if (receiver == null) { return(false); } try { lock (LockObject) { LogEntryEvent -= receiver.WriteEntry; Receivers.Remove(receiver); } return(true); } catch (Exception) { return(false); } }
private void LoadExistingConfiguration() { var config = BleLocatorModel.Instance.BleSystemConfiguration; ReceiverPaths = config.ReceiverPaths.HasSomething()? new List <ReceiverPath>(config.ReceiverPaths):new List <ReceiverPath>(); UseWeightedPoints = config.UseWeightedPaths; if (config.BleReceivers.HasSomething()) { foreach (var bleReceiver in config.BleReceivers) { var viewModel = new ReceiverEntryViewModel(bleReceiver.Value); viewModel.OnRemove += vm => Receivers.Remove(vm); Receivers.Add(viewModel); } } else { var viewModel = new ReceiverEntryViewModel(new BleReceiver()); viewModel.OnRemove += vm => Receivers.Remove(vm); Receivers.Add(viewModel); } if (config.BleTransmitters.HasSomething()) { foreach (var transmitter in config.BleTransmitters) { var viewModel = new TransmitterEntryViewModel(transmitter.Value); viewModel.OnRemove += vm => Transmitters.Remove(vm); Transmitters.Add(viewModel); } } else { var viewModel = new TransmitterEntryViewModel(new BleTransmitter()); viewModel.OnRemove += vm => Transmitters.Remove(vm); Transmitters.Add(viewModel); } }
public void RemoveReceiver(Action <byte> receiver) { Receivers.Remove(receiver); }
public void Detach(Action <T> action) { Receivers.Remove(action); }
public void Detach(IReceiver <T> receiver) { Receivers.Remove(receiver.Receive); }