extends Node2D


# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var default_mask
export var enabled = true

# Called when the node enters the scene tree for the first time.
func _ready():
	default_mask = $Area2D.collision_mask
	enable(enabled)
	get_node("switch").connect("activate",self,"swich")
	var area = ($Area2D/CollisionShape2D.shape as RectangleShape2D).extents
	$CPUParticles2D.emission_rect_extents = area
	$CPUParticles2D.amount = floor(area.x * area.y * 0.025)
	
	pass # Replace with function body.
	
func swich():
	enable(not enabled)
	
func enable(swich):
	if swich:
		$Area2D.collision_mask = default_mask
		$CPUParticles2D.emitting = true
		enabled = true
	else:
		$Area2D.collision_mask = 0
		$CPUParticles2D.emitting = false
		enabled = false


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