Ejemplo n.º 1
0
 public void StopObserving(Competitor <GameObject> competitor)
 {
     if (competitor != null && !competitor.Value.IsDestroyed())
     {
         ParticipationObserver component = competitor.Value.GetComponent <ParticipationObserver>();
         if (component != null && !component.gameObject.IsDestroyed() && !base.gameObject.IsDestroyed())
         {
             component.StopObserving(base.gameObject);
             component.ObserverDisable -= OnObserverDisable;
             component.ObserverExit    -= OnObserverExit;
         }
     }
 }
Ejemplo n.º 2
0
    private void AddObserverAndListenersToParticipationRequestor(Competitor <GameObject> participant)
    {
        ParticipationObserver participationObserver = participant.Value.GetComponent <ParticipationObserver>();

        if (participationObserver == null)
        {
            participationObserver = participant.Value.AddComponent <ParticipationObserver>();
        }
        if (participationObserver != null && !participationObserver.IsObserving(base.gameObject))
        {
            participationObserver.StartObserving(base.gameObject, this, participant);
            participationObserver.ObserverExit    += OnObserverExit;
            participationObserver.ObserverDisable += OnObserverDisable;
        }
    }
Ejemplo n.º 3
0
    private void OnObserverDisable(GameObject go, ParticipationObserver observer)
    {
        Competitor <GameObject> competitor = PriorityCompetition.GetCompetitor(go);

        if (competitor != null)
        {
            bool flag = false;
            try
            {
                PriorityCompetition.RemoveCompetitor(go);
                if (participationData.CurrentParticipationState != ParticipationState.Retained)
                {
                    Internal_UpdateParticipationWhenSomethingGotRemoved(competitor, "Controller_triggerExit");
                    StopObserving(competitor);
                    flag = true;
                }
            }
            catch
            {
                ClearPriorityCompetition(competitor);
            }
        }
    }
Ejemplo n.º 4
0
 private void OnObserverExit(Competitor <GameObject> competitor, GameObject playerGameObject, ParticipationObserver observer)
 {
     Assert.IsTrue(playerGameObject == base.gameObject, "Not my player!");
     if (playerGameObject == base.gameObject && PriorityCompetition.GetCompetitor(competitor.theObject) != null)
     {
         bool flag = false;
         try
         {
             PriorityCompetition.RemoveCompetitor(competitor);
             if (participationData.CurrentParticipationState != ParticipationState.Retained)
             {
                 Internal_UpdateParticipationWhenSomethingGotRemoved(competitor, "triggerExit");
                 StopObserving(competitor);
                 flag = true;
             }
         }
         catch (Exception ex)
         {
             Log.LogException(this, ex);
             ClearPriorityCompetition(competitor);
         }
     }
 }