@tool
extends EditorPlugin

var org_dock:Control;

func _enable_plugin() -> void:
	# Add autoloads here.
	pass


func _disable_plugin() -> void:
	# Remove autoloads here.
	pass


func _enter_tree() -> void:
	# Initialization of the plugin goes here.ù
	org_dock = preload("res://addons/discretized_loader/scenes/dock_chuck_organization.tscn").instantiate();
	add_control_to_dock(EditorPlugin.DOCK_SLOT_RIGHT_UL, org_dock);
	
	var command_palette = EditorInterface.get_command_palette();
	var command_callable = Callable(self, "command_change_prop");
	command_palette.add_command("set_collider_visibility", "disel/command",command_callable);
	pass


func _exit_tree() -> void:
	# Clean-up of the plugin goes here.
	remove_control_from_docks(org_dock);
	org_dock.free();
	
	var command_palette = EditorInterface.get_command_palette();
	command_palette.remove_command("disel/command");
	pass

func command_change_prop() -> void:
	var scene: Node = EditorInterface.get_edited_scene_root();
	print("Scene Name: " + scene.name);
	for node : Node in scene.get_children():
		if not node:
			continue;
		if node is TileMapLayer:
			var layer:TileMapLayer = node as TileMapLayer;
			if layer:
				layer.collision_visibility_mode = TileMapLayer.DEBUG_VISIBILITY_MODE_FORCE_HIDE;
				print("Set Object: " + layer.name);
	pass;
