objetos raros, objetos decorativos rompibles
This commit is contained in:
1 parent
827e16cf50
commit
66f4d8b33b
55 files changed
+4793
-163
No files matched your search
@@ -0,0 +1,93 @@
|
||||
extends SceneTree
|
||||
|
||||
## Impactos sobre SceneryProp y drops reales, con el perfil aislado de la partida.
|
||||
const BARREL: PackedScene = preload("res://world/props/barrel.tscn")
|
||||
const PLAYER: PackedScene = preload("res://player/player.tscn")
|
||||
const REWARD: PackedScene = preload("res://pickups/variants/beer.tscn")
|
||||
var _failures: int = 0
|
||||
var _arena: Node2D
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
preload("res://tests/runtime_test_profile.gd").prepare(self)
|
||||
_arena = Node2D.new()
|
||||
_arena.position = Vector2(140, 80)
|
||||
root.add_child(_arena)
|
||||
current_scene = _arena
|
||||
var barrel: SceneryProp = _barrel(Vector2(400, 300), REWARD)
|
||||
barrel.collision_enabled = false
|
||||
await process_frame
|
||||
_check((barrel.get_node("Body") as StaticBody2D).collision_layer == 0, "La colision solida es opcional")
|
||||
_check((barrel.get_node("Hurtbox") as Area2D).collision_layer == 32, "Sin colision solida sigue siendo golpeable")
|
||||
barrel.take_damage(0, Vector2.ZERO)
|
||||
_check(barrel.current_health == 5, "Cero dano no rompe")
|
||||
barrel.take_damage(2, Vector2.ZERO)
|
||||
_check(barrel.current_health == 3 and not barrel.is_broken, "Se acumula dano hasta la resistencia")
|
||||
barrel.take_damage(3, Vector2.ZERO)
|
||||
barrel.take_damage(100, Vector2.ZERO)
|
||||
_check(barrel.is_broken, "El bloqueo de rotura es inmediato")
|
||||
await process_frame
|
||||
await process_frame
|
||||
var drops: Array[Node] = get_nodes_in_group("pickup")
|
||||
_check(drops.size() == 1, "Dos impactos simultaneos solo crean un premio")
|
||||
if not drops.is_empty():
|
||||
var pickup: Pickup = drops[0] as Pickup
|
||||
_check(pickup.pickup_data.id == &"beer", "Usa exactamente el objeto asignado")
|
||||
_check(is_equal_approx(pickup.global_position.x, 540.0), "Convierte la posicion del padre trasladado")
|
||||
_check(is_equal_approx(pickup.collection_delay_seconds, 0.75), "Deja ver el objeto antes de recogerlo")
|
||||
pickup.queue_free()
|
||||
await process_frame
|
||||
|
||||
var empty: SceneryProp = _barrel(Vector2(500, 300), null)
|
||||
empty.take_damage(5, Vector2.ZERO)
|
||||
await process_frame
|
||||
await process_frame
|
||||
_check(get_nodes_in_group("pickup").is_empty(), "Un barril sin premio solo se rompe")
|
||||
var decoration: SceneryProp = _barrel(Vector2(600, 300), REWARD)
|
||||
decoration.breakable = false
|
||||
decoration.take_damage(999, Vector2.ZERO)
|
||||
_check(not decoration.is_broken, "Breakable desactivado conserva la decoracion")
|
||||
decoration.queue_free()
|
||||
|
||||
# El mismo contrato usado por el punetazo alcanza la hurtbox de un adorno.
|
||||
var player: CharacterBody2D = PLAYER.instantiate() as CharacterBody2D
|
||||
player.position = Vector2(0, 0)
|
||||
_arena.add_child(player)
|
||||
player.set_physics_process(false)
|
||||
var target: SceneryProp = _barrel(Vector2(40, 26), null)
|
||||
player.call("_damage_target", target.get_node("Hurtbox"), 5, {})
|
||||
_check(target.is_broken, "El ataque resuelve la entidad propietaria de la hurtbox")
|
||||
_check(int(player.get("special_charge")) == 0, "Romper no cuenta como una baja enemiga")
|
||||
await process_frame
|
||||
await process_frame
|
||||
|
||||
var solo_target: SceneryProp = _barrel(Vector2(40, 26), null)
|
||||
await physics_frame
|
||||
player.call("_apply_special_attack", 100, 0)
|
||||
_check(solo_target.is_broken, "El solo alcanza objetos rompibles visibles")
|
||||
_check(int(player.get("special_charge")) == 0, "El solo tampoco gana carga al romper adornos")
|
||||
await process_frame
|
||||
current_scene = null
|
||||
_arena.queue_free()
|
||||
await process_frame
|
||||
if _failures == 0:
|
||||
print("OK BREAKABLES: resistencia, colision opcional, premio unico, vacio, punetazo y solo")
|
||||
quit(0 if _failures == 0 else 1)
|
||||
|
||||
|
||||
func _barrel(at: Vector2, reward: PackedScene) -> SceneryProp:
|
||||
var barrel: SceneryProp = BARREL.instantiate() as SceneryProp
|
||||
barrel.position = at
|
||||
barrel.drop_scene = reward
|
||||
_arena.add_child(barrel)
|
||||
return barrel
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
if not condition:
|
||||
_failures += 1
|
||||
push_error(message)
|
||||
Reference in new issue
Block a user