FN_Interactable
FN_Interactable checks task state before it shows a prompt or runs an interaction. Each object can be set up for one use or repeated use.
Task availability
// Returns true if task is null or currently active
public bool IsActive()
{
if (linkedTask == null) return true;
if (!linkedTask.RequiresActiveStatus) return true;
return FN_TaskManager.Instance != null &&
FN_TaskManager.Instance.IsTaskActive(linkedTask);
}
Objects without a linked task stay usable. If the linked task requires active status, the manager must report that task as active.
Running an interaction
public void Interact()
{
if (!IsActive()) return;
if (!bl_hasInteracted || bl_isReusable)
{
onInteractEvent?.Invoke();
bl_hasInteracted = true;
}
}
Interact() returns when IsActive() is false. It invokes the event once, unless bl_isReusable permits repeat use.
Showing the prompt
public void ShowWidget()
{
if (!IsActive()) return;
if (go_Interact_Widget != null)
{
go_Interact_Widget.SetActive(true);
if (txt_prompt != null)
txt_prompt.text = st_interactionPrompt;
}
}
ShowWidget() enables the assigned prompt object and copies st_interactionPrompt into its text field.