37 lines
745 B
GDScript
37 lines
745 B
GDScript
@tool
|
|
class_name Bullet
|
|
extends Area2D
|
|
|
|
|
|
static var _hitbox_shapes: Dictionary[Vector2i, RectangleShape2D] = {}
|
|
|
|
|
|
@export var texture: Texture2D:
|
|
set(value):
|
|
texture = value
|
|
queue_redraw()
|
|
|
|
@export var hitbox_size: Vector2i:
|
|
set(value):
|
|
hitbox_size = value
|
|
if not _hitbox_shapes.has(hitbox_size):
|
|
var new_shape = RectangleShape2D.new()
|
|
new_shape.size = hitbox_size
|
|
_hitbox_shapes[hitbox_size] = new_shape
|
|
_hitbox.shape = _hitbox_shapes[hitbox_size]
|
|
|
|
|
|
var _hitbox: CollisionShape2D = CollisionShape2D.new()
|
|
|
|
|
|
func _init() -> void:
|
|
_hitbox.debug_color.a = 0.0
|
|
add_child(_hitbox)
|
|
|
|
|
|
func _draw() -> void:
|
|
draw_texture(texture, -texture.get_size() * 0.5)
|
|
|
|
|
|
func _get_configuration_warnings() -> PackedStringArray:
|
|
return []
|