extends Node2D const MINE = preload("res://scripts/game/enemy_mine.gd") func create_mine(ship: CharacterBody2D) -> Node2D: var mine := Node2D.new() mine.set_script(MINE) mine.player = ship mine.position = Vector2.ZERO add_child(mine) mine.set_physics_process(false) return mine func _ready() -> void: GameState.start_new_run() var ship := preload("res://scenes/game/player_ship.tscn").instantiate() add_child(ship) ship.set_physics_process(false) ship.get_node("WeaponController").set_physics_process(false) ship.get_node("ExtensionSystems").set_physics_process(false) ship.max_hull = 300.0 ship.hull = 210.0 ship.shields = 0.0 var mine := create_mine(ship) assert(mine.has_node("MineArtwork")) var image := MINE.MINE_TEXTURE.get_image() if image.is_compressed(): image.decompress() assert(image.get_pixel(0, 0).a == 0.0) assert(image.get_pixel(image.get_width() / 2, image.get_height() / 2).a > 0.9) mine._physics_process(0.69) assert(ship.hull == 210.0 and not mine._triggered) ship.position = Vector2(MINE.TRIGGER_RADIUS + 1.0, 0.0) mine._physics_process(0.02) assert(ship.hull == 210.0 and not mine._triggered) ship.position = Vector2(MINE.TRIGGER_RADIUS, 0.0) mine._physics_process(0.01) assert(mine._triggered and mine.is_queued_for_deletion()) assert(is_equal_approx(ship.hull, 60.0), "Damage must use 50% of maximum hull (150), not current hull") mine._physics_process(0.01) assert(ship.hull == 60.0, "Mine must hit only once") ship.position = Vector2.ZERO ship.max_hull = 200.0 ship.hull = 150.0 ship.shields = 100.0 var shielded_mine := create_mine(ship) shielded_mine._physics_process(0.8) assert(ship.shields == 0.0 and ship.hull == 150.0, "Normal shield absorption remains in effect") var expired := create_mine(ship) expired._physics_process(MINE.LIFETIME) assert(expired.is_queued_for_deletion() and not expired._triggered) print("ENEMY_MINE_TEST: PASS transparent artwork, 50% maximum hull, shields, arming, proximity, one explosion and expiry") get_tree().quit()