The base TooltipSpawner does not know the conditions for which the tooltip can be created, as it’s generic… It doesn’t even know that it’s an IItemHolder… all it knows is that it’s going to spawn a GameObject and try to place it at the right location, that’s all.
This is best handled by the child class which has more information about whether or not the tooltip can be generated… For example, you might have a tooltip spawner on an enemy that spawns a tooltip describing the enemy and it’s strengths and weaknesses. IItemHolder is for InventoryItems, so that wouldn’t work. If the character is in combat (like you’re actively fighting it), a tooltip could get in the way, so we don’t want to display it then. So for an Enemy Tooltip, you might have
[RequireComponent(typeof(EnemyInformationHolder))]
public class EnemyTooltipSpawner : TooltipSpawner
{
public override bool CanCreateTooltip()
{
if(GetComponent<Fighter>().IsInCombat()) return false;
return true;
}
}