Esempio n. 1
0
 protected override void OnEnabledChanged()
 {
     ResourceSink.Update();
     if (onceUpdated)
     {
         RadioReceiver.UpdateBroadcastersInRange();
     }
     base.OnEnabledChanged();
 }
Esempio n. 2
0
    private void EnsureInit()
    {
        if (pickupable != null)
        {
            return;
        }

        pickupable   = GetComponent <Pickupable>();
        itemAtts     = GetComponent <ItemAttributesV2>();
        registerTile = GetComponent <RegisterTile>();

        radioMessager = GetComponent <RadioMessager>();
        radioReceiver = GetComponent <RadioReceiver>();

        hackDevice = GetComponent <HackingDevice>();
    }
Esempio n. 3
0
 public override void UpdateAfterSimulation10()
 {
     base.UpdateAfterSimulation10();
     RadioReceiver.UpdateBroadcastersInRange();
 }
Esempio n. 4
0
    /// <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);
    }
Esempio n. 5
0
 public void RemoveReceiver(RadioReceiver rec)
 {
     receivers.Remove(rec);
 }
Esempio n. 6
0
 public void RegisterReceiver(RadioReceiver rec)
 {
     receivers.Add(rec);
 }