Files
EGJ25/addons/guide/guide_set.gd
minimata 9a79715e47
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 6s
Create tag and build when new code gets to main / Export (push) Successful in 3m16s
feat: made sure the aspect ration fit a pixel art game and added useful addons
2025-06-27 15:19:12 +02:00

41 lines
720 B
GDScript

## Helper class for modelling sets
var _values:Dictionary = {}
func add(value:Variant) -> void:
_values[value] = value
func remove(value:Variant) -> void:
_values.erase(value)
func clear() -> void:
_values.clear()
func is_empty() -> bool:
return _values.is_empty()
func pull() -> Variant:
if is_empty():
return null
var key = _values.keys()[0]
remove(key)
return key
func has(value:Variant) -> bool:
return _values.has(value)
## Returns the first item for which the given matcher function returns
## a true value.
func first_match(matcher:Callable) -> Variant:
for key in _values.keys():
if matcher.call(key):
return key
return null
func values() -> Array:
return _values.keys()