public void AddFlagChangeHandler(InteractionsGraph graph) { if (onFlagChangeHandlers == null) { onFlagChangeHandlers = new List <InteractionsGraph>(); } onFlagChangeHandlers.Add(graph); }
public void RemoveFlagChangeHandler(InteractionsGraph graph) { if (toRemoveHandlers == null) { toRemoveHandlers = new List <InteractionsGraph>(); } toRemoveHandlers.Add(graph); }
void OnTriggerEnter2D(Collider2D collider) { Debug.Log("Trigger entered"); InteractionsGraph interactable = collider.GetComponent <InteractionsGraph>(); if (interactable) { player.TriggerHit(interactable); } }
void OnInteract(InputAction.CallbackContext action_context) { Debug.Log("INTERACTING!"); if (context.complete) { foreach (var interactions in interactables) { if (interactions == null) { continue; } if (interactions.gameObject == null) { continue; } foreach (var entry in interactions.GetEntryPoints()) { if (entry.Action != "Interact") { continue; } if (entry.FlagsMeetRequirements(flags)) { // If we start the interaction, but it does not complete // then we want to zero velocity as we will likely be in dialogue if (!interactions.StartInteraction( entry, flags, UIController, out context )) { activeInteraction = interactions; body.velocity = Vector2.zero; } UpdateFlagChangeListeners(context.flagsAdded, context.flagsRemoved); return; } break; } } // Trigger animation for sword swing if (flags.Contains("keyboard")) { swung_sword = true; my_animator.SetTrigger("Slash"); } } else { if (activeInteraction.FollowInteraction(ref context)) { activeInteraction = null; if (queue != null) { while (queue.Count > 0) { UpdateFlagChangeListeners(context.flagsAdded, context.flagsRemoved); var next = queue[0]; queue.RemoveAt(0); if (!next.Item1.StartInteraction( next.Item2, flags, UIController, out context )) { activeInteraction = next.Item1; break; } } } } UpdateFlagChangeListeners(context.flagsAdded, context.flagsRemoved); } }