Added AbstractActivatableObject

This commit is contained in:
2026-03-15 22:59:24 +03:00
parent 60c36d8666
commit b5b2c7691b
9 changed files with 216 additions and 0 deletions
@@ -0,0 +1,23 @@
class_name AbstractActivatableObject
extends Node2D
@onready var hint_sprite : Sprite2D = $HintSprite
func activate() -> void:
pass
func _ready() -> void:
hint_sprite.hide()
func _on_body_entered(body: Node2D) -> void:
if body is Player:
hint_sprite.show()
func _on_body_exited(body: Node2D) -> void:
if body is Player:
hint_sprite.hide()
@@ -0,0 +1 @@
uid://cfqo4k2uarorm
@@ -0,0 +1,20 @@
[gd_scene format=3 uid="uid://725frvpqe1c8"]
[ext_resource type="Script" uid="uid://cfqo4k2uarorm" path="res://game/objects/interactive/abstract_activatable_object.gd" id="1_b4djr"]
[ext_resource type="Texture2D" uid="uid://c42nswehn307r" path="res://images/level/activation_hint.png" id="1_rexes"]
[sub_resource type="CircleShape2D" id="CircleShape2D_n2cvl"]
[node name="AbstractActivatableObject" type="Area2D" unique_id=1823472506]
collision_layer = 256
collision_mask = 136
script = ExtResource("1_b4djr")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=2065213362]
shape = SubResource("CircleShape2D_n2cvl")
[node name="HintSprite" type="Sprite2D" parent="." unique_id=1362423739]
texture = ExtResource("1_rexes")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
[connection signal="body_exited" from="." to="." method="_on_body_exited"]
+5
View File
@@ -0,0 +1,5 @@
extends AbstractActivatableObject
func activate() -> void:
pass
+1
View File
@@ -0,0 +1 @@
uid://nkhmjep3evjx
+122
View File
@@ -0,0 +1,122 @@
[gd_scene format=3 uid="uid://dsww084wps0d0"]
[ext_resource type="PackedScene" uid="uid://725frvpqe1c8" path="res://game/objects/interactive/abstract_activatable_object.tscn" id="1_rl4ey"]
[ext_resource type="Script" uid="uid://nkhmjep3evjx" path="res://game/objects/interactive/lever.gd" id="2_5hu3b"]
[ext_resource type="Texture2D" uid="uid://c8a451rgx116q" path="res://images/level/lever.png" id="3_tnscr"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tnscr"]
size = Vector2(32, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_ap6wp"]
atlas = ExtResource("3_tnscr")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_wb3bq"]
atlas = ExtResource("3_tnscr")
region = Rect2(80, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_fmhac"]
atlas = ExtResource("3_tnscr")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_gclvq"]
atlas = ExtResource("3_tnscr")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_m2d68"]
atlas = ExtResource("3_tnscr")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_eom63"]
atlas = ExtResource("3_tnscr")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_0m1ch"]
atlas = ExtResource("3_tnscr")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_l5vfu"]
atlas = ExtResource("3_tnscr")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_b2o5l"]
atlas = ExtResource("3_tnscr")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_5h41l"]
atlas = ExtResource("3_tnscr")
region = Rect2(64, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_kky3u"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ap6wp")
}],
"loop": true,
"name": &"turned_left",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_wb3bq")
}],
"loop": true,
"name": &"turned_right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_fmhac")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gclvq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m2d68")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_eom63")
}],
"loop": false,
"name": &"turning_left",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_0m1ch")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_l5vfu")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_b2o5l")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5h41l")
}],
"loop": false,
"name": &"turning_right",
"speed": 10.0
}]
[sub_resource type="AtlasTexture" id="AtlasTexture_5upgc"]
atlas = ExtResource("3_tnscr")
region = Rect2(96, 0, 16, 16)
[node name="Lever" unique_id=1479061220 instance=ExtResource("1_rl4ey")]
script = ExtResource("2_5hu3b")
[node name="CollisionShape2D" parent="." index="0" unique_id=2065213362]
position = Vector2(0, -4)
shape = SubResource("RectangleShape2D_tnscr")
[node name="HintSprite" parent="." index="1" unique_id=1362423739]
position = Vector2(0, -11)
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="2" unique_id=2086579452]
sprite_frames = SubResource("SpriteFrames_kky3u")
animation = &"turned_left"
[node name="BaseSprite" type="Sprite2D" parent="." index="3" unique_id=256419860]
texture = SubResource("AtlasTexture_5upgc")
Binary file not shown.
+40
View File
@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c42nswehn307r"
path="res://.godot/imported/activation_hint.png-d71cb806d34b5813c305102aca86fa65.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://images/level/activation_hint.png"
dest_files=["res://.godot/imported/activation_hint.png-d71cb806d34b5813c305102aca86fa65.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
+1
View File
@@ -162,6 +162,7 @@ pause={
2d_physics/layer_6="White world" 2d_physics/layer_6="White world"
2d_physics/layer_7="White enemy" 2d_physics/layer_7="White enemy"
2d_physics/layer_8="White player" 2d_physics/layer_8="White player"
2d_physics/layer_9="ActivatableObjects"
[physics] [physics]