class_name SpriteAtlas
extends RefCounted

static var _sheet: Texture2D


static func sheet() -> Texture2D:
	if _sheet == null:
		_sheet = load("res://assets/Spritesheet/sheet.png")
	return _sheet


static func region(x: int, y: int, w: int, h: int) -> AtlasTexture:
	var tex := AtlasTexture.new()
	tex.atlas = sheet()
	tex.region = Rect2i(x, y, w, h)
	return tex


static func named(name: String) -> AtlasTexture:
	match name:
		"meteorBrown_big1":
			return region(224, 664, 101, 84)
		"playerShip1_blue":
			return region(211, 941, 99, 75)
		"playerShip1_orange":
			return region(247, 84, 99, 75)
		"laserBlue01":
			return region(856, 421, 9, 54)
		"laserRed01":
			return region(858, 230, 9, 54)
		"laserGreen01":
			return region(855, 173, 9, 57)
		"star1":
			return region(628, 681, 25, 24)
		"star2":
			return region(222, 84, 25, 24)
		_:
			push_warning("SpriteAtlas: unknown sprite '%s'" % name)
			return region(0, 0, 1, 1)
