private void UpdateCurrentInteractable(Collider2D other) { ObjectiveInteractable interactable = other.GetComponentInParent <ObjectiveInteractable>(); if (!interactable.HasInteraction()) { interactable.ExitRange(); currentInteractable = null; return; } currentInteractable = interactable; if (currentInteractable != null && !player.IsGrounded) { currentInteractable.InRange(InteractableState.DisabledVisible); return; } currentInteractable.InRange(InteractableState.Enabled); }
public void HandleStay(Collider2D other) { if ((1 << other.gameObject.layer & interactableLayer) != 0) { currentInteractable = other.GetComponentInParent <Interactable>(); currentInteractable.InRange(player.IsGrounded ? InteractableState.Enabled : InteractableState.DisabledVisible); } if ((1 << other.gameObject.layer & objectiveInteractableLayer) != 0) { currentObjectiveInteractable = other.GetComponentInParent <ObjectiveInteractable>(); if (currentObjectiveInteractable.HasInteraction()) { currentObjectiveInteractable.InRange(player.IsGrounded ? InteractableState.Enabled : InteractableState.DisabledVisible); } else { currentObjectiveInteractable.ExitRange(); } } if ((1 << other.gameObject.layer & guardAttentionLayer) != 0) { currentZone = other.GetComponentInChildren <AttentionZone>(); currentZone.StayAttention(gameObject); } if ((1 << other.gameObject.layer & lineOfSightLayer) != 0) { currentLineOfSight = other.GetComponentInChildren <LineOfSight>(); currentLineOfSight.EnterAttention(); } if ((1 << other.gameObject.layer & lightLayer) != 0) { playerLitManager.IsLit = true; } if ((1 << other.gameObject.layer & eventSequenceLayer) != 0) { var eventSequence = other.GetComponentInParent <EventSequence>(); StartCoroutine(eventSequence.ExecuteSequence()); } if ((1 << other.gameObject.layer & conditionalDisplayLayer) != 0) { var conditionalDisplay = other.GetComponentInParent <ConditionalDisplay>(); conditionalDisplay.UpdateCondition(); } }
public void HandleEnter(Collider2D other) { if ((1 << other.gameObject.layer & interactableLayer) != 0) { currentInteractable = other.GetComponentInParent <Interactable>(); currentInteractable.InRange(player.IsGrounded ? InteractableState.Enabled : InteractableState.DisabledVisible); } if ((1 << other.gameObject.layer & objectiveInteractableLayer) != 0) { currentObjectiveInteractable = other.GetComponentInParent <ObjectiveInteractable>(); if (currentObjectiveInteractable.HasInteraction()) { currentObjectiveInteractable.InRange(player.IsGrounded ? InteractableState.Enabled : InteractableState.DisabledVisible); } else { currentObjectiveInteractable.ExitRange(); } } if ((1 << other.gameObject.layer & eventSequenceLayer) != 0) { var eventSequence = other.GetComponentInParent <EventSequence>(); StartCoroutine(eventSequence.ExecuteSequence()); } if ((1 << other.gameObject.layer & oneWayTriggerLayer) != 0) { var oneWayPlatform = other.GetComponentInParent <OneWayPlatform>(); oneWayPlatform.IntersectTrigger(); } if ((1 << other.gameObject.layer & guardAttentionLayer) != 0) { currentZone = other.GetComponentInChildren <AttentionZone>(); currentZone.EnterAttention(gameObject); } if ((1 << other.gameObject.layer & lineOfSightLayer) != 0) { currentLineOfSight = other.GetComponentInChildren <LineOfSight>(); currentLineOfSight.EnterAttention(); } if ((1 << other.gameObject.layer & vantageLayer) != 0) { var vantage = other.GetComponentInChildren <VantagePoint>(); vantage.ShowIndicator(); vantagePointManager.RegisterCurrentVantage(vantage); } if ((1 << other.gameObject.layer & lightLayer) != 0) { playerLitManager.IsLit = true; } if ((1 << other.gameObject.layer & checkpointLayer) != 0) { var checkpoint = other.GetComponentInParent <Checkpoint>(); checkpoint.UpdateLastCheckpoint(); } if ((1 << other.gameObject.layer & conditionalDisplayLayer) != 0) { var conditionalDisplay = other.GetComponentInParent <ConditionalDisplay>(); conditionalDisplay.Show(); } }