/// <summary> /// Called when the remote signaler receives a signal. Puts a little message in chat if you're holding it. /// </summary> /// <param name="signal"></param> public void ServerReceiveSignal(RadioSignal signal) { if (pickupable.ItemSlot != null && pickupable.ItemSlot.Player != null) { UpdateChatMessage.Send(pickupable.ItemSlot.Player.gameObject, ChatChannel.Examine, ChatModifier.None, "You feel your signaler vibrate."); } hackDevice.SendOutputSignal(); }
public void SendRadioSignal(RadioSignal signal, RadioMessager originator) { foreach (RadioReceiver rec in receivers) { if (CanReceiverReceiverSignal(rec, signal, originator)) { rec.OnReceiveSignal(signal); } } }
private void OnRadioMsg(RadioSignal signal) { if (dicRadioSenders.ContainsKey(signal.Sender)) { dicRadioSenders[signal.Sender].Reset(); } else { dicRadioSenders.Add(signal.Sender, new RadioSenderMark(signal.Sender)); } }
public virtual void SendSignal() { if (useFrequencyRange) { RadioSignal signal = new RadioSignal(frequencyMin, frequencyMax, amplitude, intensity, message); RadioManager.Instance.SendRadioSignal(signal, this); } else { RadioSignal signal = new RadioSignal(frequency, amplitude, intensity, message); RadioManager.Instance.SendRadioSignal(signal, this); } }
public void OnReceiveSignal(RadioSignal signal) { signalCallbacks.Invoke(signal); }
/// <summary> /// Check if a receiver can receive a signal from a messager. Probably a better way to do this. /// </summary> /// <param name="rec"></param> /// <param name="signal"></param> /// <param name="originator"></param> /// <returns></returns> //TODO //Degrade the message in a sent signal if it's below the sensitivity of the receiver (up to a certain range). //i.e. add corrupted text and stuff private bool CanReceiverReceiverSignal(RadioReceiver rec, RadioSignal signal, RadioMessager originator) { //Prevent a receiver picking up a signal if it was the one that sent it. if (rec.gameObject.Equals(originator.gameObject)) { return(false); } if (signal.broadRange) { if (rec.UseFrequencyRange) { if (signal.frequencyMin >= rec.MinFrequency || signal.frequencyMax <= rec.MaxFrequency) { float distance = Vector3.Distance(rec.RegisterTitle.WorldPosition, originator.RegisterTitle.WorldPosition); if (signal.intensity / (Mathf.Pow(distance, 2)) >= rec.Sensitivity) { return(true); } } } else { if (signal.frequencyMin < rec.Frequency && signal.frequencyMax > rec.Frequency) { float distance = Vector3.Distance(rec.RegisterTitle.WorldPosition, originator.RegisterTitle.WorldPosition); if (signal.intensity / (Mathf.Pow(distance, 2)) >= rec.Sensitivity) { return(true); } } } } else { if (rec.UseFrequencyRange) { if (signal.frequency >= rec.MinFrequency && signal.frequency <= rec.MaxFrequency) { float distance = Vector3.Distance(rec.RegisterTitle.WorldPosition, originator.RegisterTitle.WorldPosition); if (signal.intensity / (Mathf.Pow(distance, 2)) >= rec.Sensitivity) { return(true); } } } else { //Have to use an epsilon check here, since floats are imperfect. if (Mathf.Abs(signal.frequency - rec.Frequency) < 0.01) { float distance = Vector3.Distance(rec.RegisterTitle.WorldPosition, originator.RegisterTitle.WorldPosition); if (signal.intensity / (Mathf.Pow(distance, 2)) >= rec.Sensitivity) { return(true); } } } } return(false); }
public void SendRadioSignalFromLocation(RadioSignal signal, Vector2 origin) { }