void Update()
    {
        if (m_BasePerson == null && RequiresPerson)
        {
            return;
        }

        if (RequiresPerson && !m_BasePerson.IsInfected())
        {
            return;
        }

        if (m_PeopleTracker == null)
        {
            return;
        }

        float fDistance = 0f;

        List <BasePerson> people = m_PeopleTracker.GetPeople();

        Vector3 myPos = transform.position;

        myPos.y = 0f;

        Vector3 theirPos;

        // Check the distance between this person and all the others and spread the infection if in-range
        foreach (BasePerson person in people)
        {
            if (person == null)
            {
                continue;
            }

            if (person.gameObject != transform.gameObject)
            {
                if (!person.IsInfected() && person.IsVulnerableToInfection())
                {
                    theirPos   = person.transform.position;
                    theirPos.y = 0f;

                    fDistance = Vector3.Distance(myPos, theirPos);

                    if (fDistance <= InfectionRadius)
                    {
                        person.SetInfected();
                    }
                }
            }
        }
    }
    // Roll the dice based on our chance of randomly becoming infected
    private void PerformInfectionRoll()
    {
        if (m_Person == null)
        {
            return;
        }

        if (m_Person.IsInfected() || !m_Person.IsVulnerableToInfection())
        {
            return;
        }

        // Perform the random chance check to see if this person should become infected
        if (Random.Range(0, 100) <= m_fInfectionChance)
        {
            m_Person.SetInfected();
        }

        // We should always invoke the next check incase something happens that makes us lose our infection or PPE gets removed, etc
        InvokeNextRoll();
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (!Enabled)
        {
            return;
        }

        if (!m_BasePerson.IsInfected())
        {
            return;
        }

        if (!RoundManager.Instance.IsRoundInProgress())
        {
            return;
        }

        m_fDropTimer -= Time.deltaTime;

        if (m_fDropTimer <= 0.0f)
        {
            RollSpawnChance();
        }
    }