/// <summary> /// Subscribes to the event fired when a GameObject is assigned a new Waypoint. /// </summary> /// <param name="toSubscribe">We want to know when this GameObject has a Waypoint assigned to it.</param> /// <param name="onNewWaypoint">The OnNewWaypoint delegate to be called.</param> public void SubscribeToAssignedWaypointEvent(GameObject toSubscribe, OnNewWaypoint onNewWaypoint) { if (!onAssignNewWaypoint.ContainsKey(toSubscribe)) onAssignNewWaypoint.Add(toSubscribe, null); onAssignNewWaypoint[toSubscribe] += onNewWaypoint; }
/// <summary> /// Unsubscribes from the event fired when a GameObject is assigned a new Waypoint. /// </summary> /// <param name="toSubscribe">We no longer want to know when this GameObject has a Waypoint assigned to it.</param> /// /// <param name="onNewWaypoint">The OnNewWaypoint delegate that was originally forwarded by the subscriber.</param> public void UnsubscribeToAssignedWaypointEvent(GameObject toSubscribe, OnNewWaypoint onNewWaypoint) { if (onAssignNewWaypoint.ContainsKey(toSubscribe)) onAssignNewWaypoint[toSubscribe] -= onNewWaypoint; }