/// <summary> /// Client side interaction checking logic. Goes through each interactable component (starting from the bottom of the object's /// component list) and checks for triggered interactions, returning the first one that /// triggers an interaction, null if none are triggered. Messages the server to request an interaction for the interaction that /// was triggered (if any). Doesn't message the server if only a clientside interaction was triggered. /// </summary> /// <param name="interactables">component to check</param> /// <param name="interaction">interaction attempting to be performed</param> /// <typeparam name="T">type of interaction being checked</typeparam> /// <returns></returns> public static IBaseInteractable <T> ClientCheckAndTrigger <T>(IEnumerable <IBaseInteractable <T> > interactables, T interaction) where T : Interaction { if (Cooldowns.IsOnClient(interaction, CommonCooldowns.Instance.Interaction)) { return(null); } Logger.LogTraceFormat("Checking {0} interactions", Category.Interaction, typeof(T).Name); foreach (var interactable in interactables.Reverse()) { if (ClientCheckAndTrigger(interactable, interaction)) { return(interactable); } } return(null); }
/// <summary> /// Client side interaction checking logic. Goes through each interactable component (starting from the bottom of the object's /// component list) and checks for triggered interactions, returning the first one that /// triggers an interaction, null if none are triggered. Messages the server to request an interaction for the interaction that /// was triggered (if any). /// </summary> /// <param name="interactables"></param> /// <param name="interaction"></param> /// <param name="side"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public static IBaseInteractable <T> ClientCheckAndTrigger <T>(IEnumerable <IBaseInteractable <T> > interactables, T interaction) where T : Interaction { if (Cooldowns.IsOnClient(interaction, CommonCooldowns.Instance.Interaction)) { return(null); } Logger.LogTraceFormat("Checking {0} interactions", Category.Interaction, typeof(T).Name); foreach (var interactable in interactables.Reverse()) { if (interactable.CheckInteractInternal(interaction, NetworkSide.Client, out var wasClientInteractable)) { //don't send a message for clientside-only interactions if (!wasClientInteractable) { RequestInteract(interaction, interactable); } return(interactable); } } return(null); }