void OnTriggerExit(Collider other)
    {
        SegmentStreamer.Broadcast(SegmentEvent.TriggerExit, other.gameObject, this);

        if (!other.name.Equals("PlayerObject"))
        {
            return;
        }

        if (_playerObject.CurrentSegments.Contains(this))
        {
            _playerObject.CurrentSegments.Remove(this);
        }

        foreach (GameObject seg in _currentSegments)
        {
            if (seg.Equals(this.gameObject) || LinkedSegments.Contains(seg))
            {
                continue;
            }
            else
            {
                // seg.SetActive(false);
            }
        }
    }
    void OnTriggerEnter(Collider other)
    {
        SegmentStreamer.Broadcast(SegmentEvent.TriggerEnter, other.gameObject, this);

        if (!other.name.Equals("PlayerObject"))
        {
            return;
        }

        if (!_playerObject.CurrentSegments.Contains(this))
        {
            _playerObject.CurrentSegments.Add(this);
        }

        foreach (GameObject linkedSeg in LinkedSegments)
        {
            if (_currentSegments.Contains(linkedSeg))
            {
                continue;
            }
            else
            {
                //Instantiate(linkedSeg);
                // load linked segments
                linkedSeg.SetActive(true);
            }
        }

        foreach (GameObject seg in _currentSegments)
        {
            if (seg.Equals(this.gameObject) || LinkedSegments.Contains(seg))
            {
                continue;
            }
            else
            {
                seg.SetActive(false);
            }
        }
    }
Exemplo n.º 3
0
 public void OnEnable()
 => SegmentStreamer.Subscribe(this.gameObject, OnWorldSegmentEvent, SubscriptionMode.Self);
Exemplo n.º 4
0
 public void OnDisable()
 => SegmentStreamer.Unsubscribe(this.gameObject, OnWorldSegmentEvent, true);
 void OnCollisionEnter(Collision other) =>
 SegmentStreamer.Broadcast(SegmentEvent.CollisionEnter, other.gameObject, this);