SummerDay/addons/summer_day/tool/tool_system/tool_pool.gd

21 lines
635 B
GDScript

extends Reference
class_name SummerDayToolPool
var persistent_tool_pool = []
var modifiable_tool_pool = []
func run_most_prior(
event: InputEvent, tool_context: SummerDayToolContext):
var priority_high_score = 0
var currently_most_prior: SummerDayTool = null
for list in [persistent_tool_pool, modifiable_tool_pool]:
for i in list:
if i._check_for_use(event, tool_context):
var priority_score = i.get_priority_score()
if priority_score > priority_high_score:
priority_high_score = priority_score
currently_most_prior = i
if currently_most_prior != null:
currently_most_prior._run(event, tool_context)