@tool
extends Node


# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
	pass

func get_tags(selectedObject:Node):
	var _tags: PackedStringArray
	if (selectedObject.has_meta("tags")):
		_tags = selectedObject.get_meta("tags")
		return _tags
	else:
		printerr("no tags inside %",selectedObject)
		return _tags
		
## Add tag on selected object by adding metadata
func add_tag(selectedObject:Node,tag:String):
	var _all_tags:PackedStringArray
	if (selectedObject.has_meta("tags")):
		_all_tags = selectedObject.get_meta("tags")
		if (_all_tags.find(tag) == -1):
			_all_tags.append(tag)
	else:
		_all_tags.append(tag)
	selectedObject.set_meta("tags",_all_tags)

func add_tags(selectedObject:Node,tags:PackedStringArray):
	var _all_tags:PackedStringArray
	if (selectedObject.has_meta("tags")):
		_all_tags = selectedObject.get_meta("tags")
	_all_tags.append_array(tags)
	selectedObject.set_meta("tags",_all_tags)

func remove_tags(selectedObject:Node,tags:PackedStringArray):
	if (selectedObject.has_meta("tags")):
		var _all_tags:PackedStringArray
		_all_tags = selectedObject.get_meta("tags")
		for _tag:String in tags:
			if(_all_tags.find(_tag) !=-1):
				_all_tags.remove_at(_all_tags.find(_tag))
		selectedObject.set_meta("tags",_all_tags)
			
func isSticker(selectedObject:Node):
	var _isSticker:bool = false
	var _tags = get_tags(selectedObject)
	if (_tags.size() > 0):
		if (_tags.find("sticker") != -1):
			_isSticker = true
		
	return _isSticker
