Create Level Transition Interactable

This commit is contained in:
Dustin 2025-03-28 21:35:37 -07:00
parent 7106fe35de
commit 2309558593
5 changed files with 35 additions and 10 deletions

View File

@ -44,7 +44,7 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://src/Interactables/HealthPickup.gd" "path": "res://src/Interactables/HealthPickup.gd"
}, { }, {
"base": "Area2D", "base": "Reference",
"class": "Interactable", "class": "Interactable",
"language": "GDScript", "language": "GDScript",
"path": "res://lib/templates/Interactable/Interactable.gd" "path": "res://lib/templates/Interactable/Interactable.gd"
@ -59,6 +59,11 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://src/classes/Level.gd" "path": "res://src/classes/Level.gd"
}, { }, {
"base": "Interactable",
"class": "LevelTransition",
"language": "GDScript",
"path": "res://src/Interactables/LevelTransition.gd"
}, {
"base": "Node2D", "base": "Node2D",
"class": "Modifier_Receiver", "class": "Modifier_Receiver",
"language": "GDScript", "language": "GDScript",
@ -120,6 +125,7 @@ _global_script_class_icons={
"Interactable": "", "Interactable": "",
"Interactable_Receiver": "", "Interactable_Receiver": "",
"Level": "", "Level": "",
"LevelTransition": "",
"Modifier_Receiver": "", "Modifier_Receiver": "",
"MovementComponent": "", "MovementComponent": "",
"Movement_StateReceiver": "", "Movement_StateReceiver": "",

View File

@ -0,0 +1,14 @@
class_name LevelTransition
extends Interactable
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
func trigger_interaction():
# This is something that should maybe be extended for every differant interactible.
# They could inherit from this base class and implement this function.
print("Okay, I'll transition the level now!")

View File

@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://src/Interactables/LevelTransition.gd" type="Script" id=1]
[node name="LevelTransition" type="Area2D"]
script = ExtResource( 1 )
type_name = "LevelTransition"
[connection signal="body_entered" from="." to="." method="_on_Interactable_Component_body_entered"]
[connection signal="body_exited" from="." to="." method="_on_Interactable_Component_body_exited"]

View File

@ -31,4 +31,6 @@ func touch_the_thing(the_thing: Interactable) -> bool:
# Do some healthy stuff. # Do some healthy stuff.
the_thing.trigger_interaction() the_thing.trigger_interaction()
return false return false
if the_thing is LevelTransition:
the_thing.trigger_interaction()
return true return true

View File

@ -3,7 +3,7 @@
[ext_resource path="res://src/templates/level_templates/LevelTemplate.tscn" type="PackedScene" id=1] [ext_resource path="res://src/templates/level_templates/LevelTemplate.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/levels/LegacyFantasy-High_Forest/tileset.tres" type="TileSet" id=2] [ext_resource path="res://assets/levels/LegacyFantasy-High_Forest/tileset.tres" type="TileSet" id=2]
[ext_resource path="res://lib/components/Hitbox_Component.tscn" type="PackedScene" id=3] [ext_resource path="res://lib/components/Hitbox_Component.tscn" type="PackedScene" id=3]
[ext_resource path="res://lib/templates/Interactable/Interactable.gd" type="Script" id=4] [ext_resource path="res://src/Interactables/LevelTransition.tscn" type="PackedScene" id=4]
[sub_resource type="CircleShape2D" id=1] [sub_resource type="CircleShape2D" id=1]
radius = 5.09902 radius = 5.09902
@ -38,16 +38,9 @@ modulate = Color( 1, 0, 0, 1 )
position = Vector2( 268, 119 ) position = Vector2( 268, 119 )
shape = SubResource( 1 ) shape = SubResource( 1 )
[node name="LevelTransition" type="Area2D" parent="." index="5"] [node name="LevelTransition" parent="." index="5" instance=ExtResource( 4 )]
collision_layer = 0
collision_mask = 2
script = ExtResource( 4 )
type_name = "LevelTransition"
[node name="CollisionShape2D" type="CollisionShape2D" parent="LevelTransition" index="0"] [node name="CollisionShape2D" type="CollisionShape2D" parent="LevelTransition" index="0"]
modulate = Color( 1, 0, 1, 1 ) modulate = Color( 1, 0, 1, 1 )
position = Vector2( 316, 121 ) position = Vector2( 316, 121 )
shape = SubResource( 2 ) shape = SubResource( 2 )
[connection signal="body_entered" from="LevelTransition" to="LevelTransition" method="_on_Interactable_Component_body_entered"]
[connection signal="body_exited" from="LevelTransition" to="LevelTransition" method="_on_Interactable_Component_body_exited"]